Cookies continue to bedevil me in rspec.
The doc seems to imply they're supported now
(http://rspec.info/rails/changes-rspec-rails.html: "* Added proxy to
cookies so you can set them in examples the same way you set them in
controllers").
Maybe because it's because I'm trying to use them in a helper test?
Here's my example:
(in application_helper_spec.rb)
it "should return false and set the cookie to true if it is not set" do
cookies[:fp_skip_hp_video].should == nil
skip_hp_video.should == false
cookies[:fp_skip_hp_video].should include({:value => true})
end
and here's the helper method (in application_helper.rb):
def skip_hp_video
v = cookies[:fp_skip_hp_video] || false
cookies[:fp_skip_hp_video] = { :value => true, :expires =>
10.years.from_now, :domain => 'example.com'}
v
end
but when I run the example I get:
NoMethodError in 'ApplicationHelper fp_skip_hp_video cooke should return
false and set the cookie to true if it is not set'
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?
./spec/helpers/application_helper_spec.rb:53:
Previously I was using a workaround of just stubbing out :cookies, as
mentioned somewhere in this thread:
http://www.mail-archive.com/[email protected]/msg05342.html
Maybe I'll just go back to that for now for the helper example;
controller examples seem to be using cookies okay without a workaround.
Thanks,
dwh
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users