I am using Rails 4.2 now.
My test file looks like:
# spec/features/my_spec.rb
require 'spec_helper'
feature 'MyFeature', type: :feature do
describe 'MyPage' do
it 'Saved the cookie' do
visit my_path
expect(response.cookies[:my_cookie]).to eq('some_value')
end
end
end
In the controller, I set a cookie as: cookies[:my_cookie] = 'some_value'
, so in the spec file, I will test if the cookie has been saved after access the special path as above, but failed. The response
is only used in the controller, but how to test cookies in this case?
Reference:
https://www.relishapp.com/rspec/rspec-rails/docs/controller-specs/cookies
respond
seems only can be used in a controller test. – s-cho-m