spec/shelly/cli/main_spec.rb in shelly-0.1.34 vs spec/shelly/cli/main_spec.rb in shelly-0.1.35
- old
+ new
@@ -25,33 +25,34 @@
describe "#help" do
it "should display available commands" do
out = IO.popen("bin/shelly --debug").read.strip
out.should include("Tasks:")
- out.should include("shelly add # Add a new cloud")
- out.should include("shelly backup <command> # Manage database backups")
- out.should include("shelly check # Check if application fulfills Shelly Cloud requirements")
- out.should include("shelly config <command> # Manage application configuration files")
- out.should include("shelly console # Open application console")
- out.should include("shelly dbconsole # Run rails dbconsole")
- out.should include("shelly delete # Delete the cloud")
- out.should include("shelly deploy <command> # View deploy logs")
- out.should include("shelly file <command> # Upload and download files to and from persistent storage")
- out.should include("shelly help [TASK] # Describe available tasks or one specific task")
- out.should include("shelly info # Show basic information about cloud")
- out.should include("shelly list # List available clouds")
- out.should include("shelly login [EMAIL] # Log into Shelly Cloud")
- out.should include("shelly logout # Logout from Shelly Cloud")
- out.should include("shelly logs # Show latest application logs")
- out.should include("shelly open # Open application page in browser")
- out.should include("shelly rake TASK # Run rake task")
- out.should include("shelly redeploy # Redeploy application")
- out.should include("shelly register [EMAIL] # Register new account")
- out.should include("shelly setup # Set up git remotes for deployment on Shelly Cloud")
- out.should include("shelly start # Start the cloud")
- out.should include("shelly stop # Shutdown the cloud")
- out.should include("shelly user <command> # Manage collaborators")
+ out.should include("shelly add # Add a new cloud")
+ out.should include("shelly backup <command> # Manage database backups")
+ out.should include("shelly check # Check if application fulfills Shelly Cloud requirements")
+ out.should include("shelly config <command> # Manage application configuration files")
+ out.should include("shelly console # Open application console")
+ out.should include("shelly dbconsole # Run rails dbconsole")
+ out.should include("shelly delete # Delete the cloud")
+ out.should include("shelly deploy <command> # View deploy logs")
+ out.should include("shelly file <command> # Upload and download files to and from persistent storage")
+ out.should include("shelly help [TASK] # Describe available tasks or one specific task")
+ out.should include("shelly info # Show basic information about cloud")
+ out.should include("shelly list # List available clouds")
+ out.should include("shelly login [EMAIL] # Log into Shelly Cloud")
+ out.should include("shelly logout # Logout from Shelly Cloud")
+ out.should include("shelly logs # Show latest application logs")
+ out.should include("shelly open # Open application page in browser")
+ out.should include("shelly organization <command> # View organizations")
+ out.should include("shelly rake TASK # Run rake task")
+ out.should include("shelly redeploy # Redeploy application")
+ out.should include("shelly register [EMAIL] # Register new account")
+ out.should include("shelly setup # Set up git remotes for deployment on Shelly Cloud")
+ out.should include("shelly start # Start the cloud")
+ out.should include("shelly stop # Shutdown the cloud")
+ out.should include("shelly user <command> # Manage collaborators")
out.should include("Options")
out.should include("[--debug] # Show debug information")
out.should include("-h, [--help] # Describe available tasks or one specific task")
end
@@ -529,21 +530,48 @@
@main.should_not_receive(:check)
fake_stdin(["foooo", "none"]) do
invoke(@main, :add)
end
end
+
+ it "should show forbidden exception" do
+ @main.options = {:organization => "foo"}
+ exception = Shelly::Client::ForbiddenException.new
+ @app.should_receive(:create).and_raise(exception)
+ $stdout.should_receive(:puts).with(red "You have to be the owner of 'foo' organization to add clouds")
+
+ expect do
+ fake_stdin(["foooo", "none"]) do
+ invoke(@main, :add)
+ end
+ end.to raise_error(SystemExit)
+ end
+
+ it "should show that organization was not found" do
+ @main.options = {:organization => "foo"}
+ response = {"resource" => "organization"}
+ exception = Shelly::Client::NotFoundException.new(response)
+ @app.should_receive(:create).and_raise(exception)
+ $stdout.should_receive(:puts).with(red "Organization 'foo' not found")
+ $stdout.should_receive(:puts).with(red "You can list organizations you have access to with `shelly organization list`")
+
+ expect do
+ fake_stdin(["foooo", "none"]) do
+ invoke(@main, :add)
+ end
+ end.to raise_error(SystemExit)
+ end
+
end
describe "#list" do
before do
- @user = Shelly::User.new
@client.stub(:token).and_return("abc")
@client.stub(:apps).and_return([
{"code_name" => "abc", "state" => "running"},
{"code_name" => "fooo", "state" => "deploy_failed"},
{"code_name" => "bar", "state" => "configuration_failed"}
])
- Shelly::User.stub(:new).and_return(@user)
end
it "should ensure user has logged in" do
hooks(@main, :list).should include(:logged_in?)
end