diff options
| author | mo khan <mo@mokhan.ca> | 2013-07-19 15:28:36 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-07-19 15:28:36 -0600 |
| commit | 46cc1816bc192cf770af5035e3e7986f84ed58ef (patch) | |
| tree | d6d88240d8b91d51cb2e9ac37e47e4961391755b /spec/controllers/api | |
| parent | af5afe04208610f9515df80800357227451cbac8 (diff) | |
add specs for login controller
Diffstat (limited to 'spec/controllers/api')
| -rw-r--r-- | spec/controllers/api/v1/logins_controller_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/controllers/api/v1/logins_controller_spec.rb b/spec/controllers/api/v1/logins_controller_spec.rb new file mode 100644 index 00000000..5678ebbb --- /dev/null +++ b/spec/controllers/api/v1/logins_controller_spec.rb @@ -0,0 +1,22 @@ +require "spec_helper" + +describe Api::V1::LoginsController do + context "when logging in with proper credentials" do + let(:user) { FactoryGirl.create(:user) } + + it "should return the auth token" do + post :create, { :email => user.email, :password => user.password } + response.body.should == { auth_token: user.authentication_token }.to_json + end + end + + context "when logging in with invalid credentials" do + let(:user) { FactoryGirl.create(:user) } + + before { post :create, { :email => user.email, :password => user.password.reverse } } + + it "should return an empty auth token" do + response.body.should == { :auth_token => "" }.to_json + end + end +end |
