spec/shelly/cli/database_spec.rb in shelly-0.3.5.pre vs spec/shelly/cli/database_spec.rb in shelly-0.3.5

- old
+ new

@@ -59,7 +59,29 @@ @app.should_receive(:tunnel_connection).and_return(conn) @app.should_receive(:setup_tunnel).with(conn, 10103) @database.options = {:port => 10103} invoke(@database, :tunnel, "mongodb") end + + context "on 404 response from API" do + it "should display error" do + ex = Shelly::Client::NotFoundException.new({"message" => "Virtual server not found"}) + @app.should_receive(:tunnel_connection).and_raise(ex) + $stdout.should_receive(:puts).with(red "Virtual server not found") + lambda { + invoke(@database, :tunnel, "mongodb") + }.should raise_error(SystemExit) + end + end + + context "on 409 response from API" do + it "should display error" do + ex = Shelly::Client::ConflictException.new({"message" => "Unknown service: postgres"}) + @app.should_receive(:tunnel_connection).and_raise(ex) + $stdout.should_receive(:puts).with(red "Unknown service: postgres") + lambda { + invoke(@database, :tunnel, "mongodb") + }.should raise_error(SystemExit) + end + end end end