Controller specifications do not generate / run real HTTP requests, they simply configure the controller under test and invoke the requested action on it. No http request is made, and no real HTTP response is generated. That way, you can test the inner workings of the Rails controller at a more abstract level.
The handling of cookies in these specifications is quite simple, setting cookies in the following step:
def set_cookies cookies[:foo] = 'bar' cookies[:lorem] = {:value => 'ipsum', :expires => 3.days.from_now} render :nothing => true end
results in the following values available in the specification:
it "should set some cookie values" do get :set_cookies # response.cookies looks like this: # {'foo' => 'bar', 'lorem' => 'ipsum'} response.cookies['foo'].should == 'bar' response.cookies['lorem'].should == 'ipsum' end
In order to check the types of cookie flags that you see in your responses, you will need to use what real HTTP requests do. Maybe you can use capybara gem for this?
severin
source share