Unable to change frozen array error when rspec starts

Was in the process of getting the Rails Engine upgraded to Rails 5.1, and now in the process of returning rspec tests.

I have a controller, and in this controller I have the following:

module Users class SessionsController < Devise::SessionsController skip_before_action :authenticate_user! skip_before_action :authorize_user! def create super flash[:analytics] = { "data-analytics-form-completed-name" => "#{StewardshipUser.app_slug}/sign-in", "data-analytics-form-completed-type" => "login" } end def repopulate_email (params[:user] && params[:user][:email]) ? params[:user][:email] : '' end helper_method :repopulate_email end end 

If I remove skip_before_action :authorize_user! tests will pass, but not all will succeed.

With the line, I get the following error:

 An error occurred while loading ./spec/validators/rfc_compliant_validator_spec.rb. Failure/Error: Dummy::Application.initialize! RuntimeError: can't modify frozen Array # /Users/ahcarpenter/.rvm/gems/ruby-2.2.2/gems/railties-5.1.4/lib/rails/engine.rb:579:in `unshift' # /Users/ahcarpenter/.rvm/gems/ruby-2.2.2/gems/railties-5.1.4/lib/rails/engine.rb:579:in `block in <class:Engine>' 

Any thoughts on why the initializer will break this line there?

Also, when I initially switched to reinitializing rspec, I had to comment on this method in order to force the initializer to start, because for some reason it was no longer found (I did not seem to have stumbled across any version of gem up that contained this method, but maybe so)

+5
source share

Source: https://habr.com/ru/post/1273110/


All Articles