This is the version of RSpec @gmcnaughton.
This is in spec_helper.rb :
RSpec.configure do |config| config.around(:each, :with_csrf_protection) do |example| orig = ActionController::Base.allow_forgery_protection begin ActionController::Base.allow_forgery_protection = true example.run ensure ActionController::Base.allow_forgery_protection = orig end end end
Then you write tests, for example:
it "foo", with_csrf_protection: true do
Or, depending on the RSpec settings:
it "foo", :with_csrf_protection do
Henrik N
source share