Here's something that got me this weekend and I couldn't find much info on it anywhere. So like my Internet taught me, I'm sharing.
links_controller.rb
cookies[:phone] = params[:phone]
links_controller_spec.rb
it "should save the phone number in a cookie" do @my_cookies = mock('cookies') @my_cookies.stub!(:[]=) controller.stub!(:cookies).and_return(@my_cookies) @my_cookies.should_receive(:[]=).with(:phone, '804-755-7555') do_post end
Here I'm making the expectation that a cookie will be set with the key of 'phone' and a value of a passed in parameter. My do_post method takes care of the post and passes in the parameter :phone => '804-755-7555'.
Popularity: 14% [?]



About
Mmm, Del.icio.us