spec/shelly/cli/main_spec.rb in shelly-0.2.22 vs spec/shelly/cli/main_spec.rb in shelly-0.2.23

- old
+ new

@@ -482,21 +482,18 @@ invoke(@main, :add) end end it "should ask if one exist and not overwrite" do + @app.stub(:git_remote_exist?).with('test').and_return(false) $stdout.should_receive(:print).with("Git remote shelly exists, overwrite (yes/no): ") - $stdout.should_receive(:puts).with("You have to manually add git remote:") - $stdout.should_receive(:puts).with("`git remote add NAME git@git.shellycloud.com:foooo.git`") - $stdout.should_receive(:puts).with("\e[32mWhen you make sure all settings are correct please issue following commands:\e[0m") - $stdout.should_receive(:puts).with(" git add .") - $stdout.should_receive(:puts).with(' git commit -m "Application added to Shelly Cloud"') - $stdout.should_receive(:puts).with(" git push") - $stdout.should_receive(:puts).with("\e[32mDeploy to your cloud using:\e[0m") - $stdout.should_receive(:puts).with(" git push NAME master") + $stdout.should_receive(:print).with("Specify remote name: ") + $stdout.should_receive(:puts).with(green "Adding remote test git@git.shellycloud.com:foooo.git") + $stdout.should_receive(:puts).with(" git push test master") + @app.should_not_receive(:add_git_remote) - fake_stdin(["foooo", "", "no"]) do + fake_stdin(["foooo", "", "no", "test"]) do invoke(@main, :add) end end end end @@ -579,24 +576,20 @@ end end context "ask user for organization" do before do - @client.stub(:organizations).and_return([ - {"name" => "aaa"}, - {"name" => "ccc"} - ]) + @client.stub(:organizations).and_return([{"name" => "aaa"}]) end it "should ask user to choose organization if present and use chosen organization" do @app.should_receive(:organization=).with("aaa") $stdout.should_receive(:puts).with("Select organization for this cloud:") $stdout.should_receive(:puts).with("existing organizations:") $stdout.should_receive(:puts).with(" 1) aaa") - $stdout.should_receive(:puts).with(" 2) ccc") $stdout.should_receive(:puts).with("new organization (default as code name):") - $stdout.should_receive(:puts).with(" 3) foooo") + $stdout.should_receive(:puts).with(" 2) foooo") $stdout.should_receive(:print).with("Option: ") fake_stdin(["foooo", "none", "1"]) do invoke(@main, :add) end end @@ -604,15 +597,14 @@ it "should ask user to choose organization if present" do @app.should_receive(:organization=).with(nil) $stdout.should_receive(:puts).with("Select organization for this cloud:") $stdout.should_receive(:puts).with("existing organizations:") $stdout.should_receive(:puts).with(" 1) aaa") - $stdout.should_receive(:puts).with(" 2) ccc") $stdout.should_receive(:puts).with("new organization (default as code name):") - $stdout.should_receive(:puts).with(" 3) foooo") + $stdout.should_receive(:puts).with(" 2) foooo") $stdout.should_receive(:print).with("Option: ") - fake_stdin(["foooo", "none", "3"]) do + fake_stdin(["foooo", "none", "2"]) do invoke(@main, :add) end end end @@ -1111,13 +1103,15 @@ end end context "and user answers no" do it "should display commands to perform manually" do - @app.should_not_receive(:add_git_remote) - @app.should_not_receive(:git_fetch_remote) - @app.should_not_receive(:git_add_tracking_branch) - fake_stdin(["no"]) do + @app.stub(:git_remote_exist?).with('remote').and_return(false) + $stdout.should_receive(:print).with("Specify remote name: ") + @app.should_receive(:add_git_remote).with('remote') + @app.should_receive(:git_fetch_remote).with('remote') + @app.should_receive(:git_add_tracking_branch).with('remote') + fake_stdin(["no", "remote"]) do invoke(@main, :setup) end end end