I have a variable in the session controller.
session[:facebook_profile_id] = @user_info['id']
@user_info ['id'] is an int. Example: 123
Then I use this session variable in my main controller to get the profile object from the database.
def show @facebook_profile = FacebookProfile.find_by_facebook_id(session[:facebook_profile_id]) end
The new object was found using the session variable and is used in my application, so my rspec test fails without it.
Here is my Factory for FacebookProfile:
FactoryGirl.define do factory :facebook_profile do |f| f.facebook_id 123 end end
In my test test for the application, I create a Factory instance before each test:
FactoryGirl.create(:facebook_profile).should be_valid
How to set session [: facebook_profile_id] variable in my test case so that search in @facebook_profile is not interrupted?
I tried knocking, but couldn't make it work. Also, I tried this in the function specification. Should I do this in the controller specification?
source share