I am developing an API and want to test the login method. API specification located in spec/api/instead spec/controller. I am using rspec-rails. Now I have this specification:
describe "/api/login.json", :type => :api do
let(:user) { FactoryGirl.create(:user) }
context "when called with correct credentials" do
before(:all) do
post "/api/v1/passenger/login.json",:email => user.email, :password => user.password
end
it "responds with HTTP 200" do
last_response.status.should == 200
end
it "sets the session correctly" do
session[:user_id].should == user.id
end
end
end
He is failing. sessionequal to zero. How to access session variable?
Think I need to add some things to my block RSpec.configure?
iblue source
share