Commit 46cc1816
Changed files (1)
spec
controllers
api
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