Why consider_all_requests_local fails with rspec config

后端 未结 4 1588
名媛妹妹
名媛妹妹 2021-01-04 12:00

rspec-rails (2.7.0) rails (3.0.10) post: Rails 3.1 Error Catching is irrelevant for me.

Code:

class ApplicationController < ActionController::Base         


        
4条回答
  •  死守一世寂寞
    2021-01-04 12:30

    Ok I found quite easy solution

    before do
      Rails.application.config.consider_all_requests_local = false
      load "application_controller.rb"
    end
    
    after do
      Rails.application.config.consider_all_requests_local = true
      load "application_controller.rb"
    end
    

    It is part of anonymous application controller test suite.

    You have to add after block... because this change will persist through other suites.

    Any improvements welcome :D

    edit: Using spork and guard causes for me sometimes random errors... before :all seems to solve that problem

提交回复
热议问题