Permalink
Browse files

Handling Login Error

  • Loading branch information...
1 parent d9cfa18 commit d13d4f293a81c91489080c27c0f97e866a0d1f61 @arailsdemo committed Jun 19, 2011
Showing with 11 additions and 0 deletions.
  1. +2 −0 lib/vmc/cli/methods/user.rb
  2. +9 −0 spec/vmc/cli/methods/user_spec.rb
@@ -13,6 +13,8 @@ def login
token = client.login(email, password)
say "Login successful.", :green
config.update(:tokens, token)
+ rescue VMC::Client::TargetError
+ say "Login failed.", :red
end
protected
@@ -56,6 +56,15 @@ def stub_login_and_update_setting
results.should =~ /Login successful./
end
end
+
+ context "and login will fail" do
+ it "displays a failed message" do
+ mock_client.should_receive(:login).
+ with('foo@bar.com', 'sekret') { raise VMC::Client::TargetError }
+ results = capture(:stdout) { login }
+ results.should =~ /Login failed./
+ end
+ end
end
end
end

0 comments on commit d13d4f2

Please sign in to comment.