title: Rails : RuntimeError - can't modify frozen Array when running rspec in rails
body: <p>I recently upgraded to Rails 5.1 from v4.3 and am now getting this error when running tests:</p>
  
  <pre><code>An error occurred while loading 
  
  ./spec/controllers/admin/capacity_charges_controller_spec.rb.
  Failure/Error: require File.expand_path('../../config/environment', __FILE__)
  
  RuntimeError:
    can't modify frozen Array
  </code></pre>
  
  <p>I get it for every test file. The line that triggers the error comes from rails_helper. I've checked rails 5.1 sample repos and there's nothing substantially different about our version.</p>
  
  <p>The full stack trace is:</p>
  
  <pre><code>RuntimeError:
  
  
  can't modify frozen Array
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/actionpack-5.1.0/lib/action_dispatch/middleware/stack.rb:74:in `insert'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/actionpack-5.1.0/lib/action_dispatch/middleware/stack.rb:74:in `insert'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/actionpack-5.1.0/lib/action_dispatch/middleware/stack.rb:81:in `insert_after'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/request_store-1.3.2/lib/request_store/railtie.rb:5:in `block in &lt;class:Railtie&gt;'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/railties-5.1.0/lib/rails/initializable.rb:30:in `instance_exec'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/railties-5.1.0/lib/rails/initializable.rb:30:in `run'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/railties-5.1.0/lib/rails/initializable.rb:59:in `block in run_initializers'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/railties-5.1.0/lib/rails/initializable.rb:58:in `run_initializers'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/railties-5.1.0/lib/rails/application.rb:353:in `initialize!'
  # ./config/environment.rb:5:in `&lt;top (required)&gt;'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `block in require'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in `load_dependency'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
  # ./spec/rails_helper.rb:12:in `&lt;top (required)&gt;'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `block in require'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in `load_dependency'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
  # ./spec/controllers/admin/capacity_charges_controller_spec.rb:3:in `&lt;top (required)&gt;'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:286:in `load'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:286:in `block in load'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in `load_dependency'
  # /Users/jeremynagel/.rvm/gems/ruby-2.3.1@Rails4.2_EnergyLink/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:286:in `load'
  </code></pre>