How do I access cookies in a helper spec?
rspec, ruby-on-rails, ruby-on-rails-3
Solution
Substituting a simple rspec mock for the CookieJar works, if you're willing to:
helper.stubs(:cookies => cookies = mock)
cookies.expects(:[]=).with('foo', 'bar')
helper.my_helper('foo', 'bar')
Problem
I can't figure out how to test that a cookie has been set when testing my helper method. Hypothetical helper method: ``` def my_helper(k,v) cookies[k] = v end ``` Test: ``` it 'should set cookies' do helper.my_helper("foo", "bar") helper.cookies["foo"].should == "bar" #nil helper.response.cookies["foo"].should == "bar" #nil end ``` Anyone know how to do this?