|
@@ -26,11 +26,8 @@ class CliTest < Test::Unit::TestCase
|
|
|
end
|
|
|
|
|
|
test "add with blank domain" do
|
|
|
- `rm -rf #{@shop_config_dir}/*`
|
|
|
- $stdout.expects(:print).with("Domain? (leave blank for foo.myshopify.com) ")
|
|
|
- $stdout.expects(:print).with("API key? ")
|
|
|
- $stdout.expects(:print).with("Password? ")
|
|
|
- $stdin.expects(:gets).times(3).returns("", "key", "pass")
|
|
|
+ standard_add_shop_prompts
|
|
|
+ $stdin.expects(:gets).times(4).returns("", "key", "pass", "y")
|
|
|
@cli.expects(:puts).with("\nopen https://foo.myshopify.com/admin/api in your browser to get API credentials\n")
|
|
|
@cli.expects(:puts).with("Default connection is foo")
|
|
|
|
|
@@ -40,16 +37,14 @@ class CliTest < Test::Unit::TestCase
|
|
|
assert_equal 'foo.myshopify.com', config['domain']
|
|
|
assert_equal 'key', config['api_key']
|
|
|
assert_equal 'pass', config['password']
|
|
|
+ assert_equal 'pry', config['shell']
|
|
|
assert_equal 'https', config['protocol']
|
|
|
assert_equal config_file('foo'), File.readlink(@default_symlink)
|
|
|
end
|
|
|
|
|
|
test "add with explicit domain" do
|
|
|
- `rm -rf #{@shop_config_dir}/*`
|
|
|
- $stdout.expects(:print).with("Domain? (leave blank for foo.myshopify.com) ")
|
|
|
- $stdout.expects(:print).with("API key? ")
|
|
|
- $stdout.expects(:print).with("Password? ")
|
|
|
- $stdin.expects(:gets).times(3).returns("bar.myshopify.com", "key", "pass")
|
|
|
+ standard_add_shop_prompts
|
|
|
+ $stdin.expects(:gets).times(4).returns("bar.myshopify.com", "key", "pass", "y")
|
|
|
@cli.expects(:puts).with("\nopen https://bar.myshopify.com/admin/api in your browser to get API credentials\n")
|
|
|
@cli.expects(:puts).with("Default connection is foo")
|
|
|
|
|
@@ -59,6 +54,18 @@ class CliTest < Test::Unit::TestCase
|
|
|
assert_equal 'bar.myshopify.com', config['domain']
|
|
|
end
|
|
|
|
|
|
+ test "add with irb as shell" do
|
|
|
+ standard_add_shop_prompts
|
|
|
+ $stdin.expects(:gets).times(4).returns("bar.myshopify.com", "key", "pass", "fuuuuuuu")
|
|
|
+ @cli.expects(:puts).with("\nopen https://bar.myshopify.com/admin/api in your browser to get API credentials\n")
|
|
|
+ @cli.expects(:puts).with("Default connection is foo")
|
|
|
+
|
|
|
+ @cli.add('foo')
|
|
|
+
|
|
|
+ config = YAML.load(File.read(config_file('foo')))
|
|
|
+ assert_equal 'irb', config['shell']
|
|
|
+ end
|
|
|
+
|
|
|
test "list" do
|
|
|
@cli.expects(:puts).with(" bar")
|
|
|
@cli.expects(:puts).with(" * foo")
|
|
@@ -99,11 +106,19 @@ class CliTest < Test::Unit::TestCase
|
|
|
private
|
|
|
|
|
|
def valid_options
|
|
|
- {'domain' => 'snowdevil.myshopify.com', 'api_key' => 'key', 'password' => 'pass', 'protocol' => 'https'}
|
|
|
+ {'domain' => 'snowdevil.myshopify.com', 'api_key' => 'key', 'password' => 'pass', 'shell' => 'pry', 'protocol' => 'https'}
|
|
|
end
|
|
|
|
|
|
def config_file(connection)
|
|
|
File.join(@shop_config_dir, "#{connection}.yml")
|
|
|
end
|
|
|
|
|
|
+ def standard_add_shop_prompts
|
|
|
+ `rm -rf #{@shop_config_dir}/*`
|
|
|
+ $stdout.expects(:print).with("Domain? (leave blank for foo.myshopify.com) ")
|
|
|
+ $stdout.expects(:print).with("API key? ")
|
|
|
+ $stdout.expects(:print).with("Password? ")
|
|
|
+ $stdout.expects(:print).with("Would you like to use pry as your shell? (y/n) ")
|
|
|
+ end
|
|
|
+
|
|
|
end
|