I updated my Ruby on Rails app to Ruby on Rails 5.1.4. When I run my tests, every test returns the following error:
An error occurred while loading {path to specific spec file}
Failure/Error: require File.expand_path('../../config/environment', __FILE__)
RuntimeError:
can't modify frozen Array
# ./config/environment.rb:6:in `<top (required)>'
# ./spec/rails_helper.rb:4:in `<top (required)>'
How can I fix that?
EDIT:
I was updating from 5.0.0.1 to 5.1.4.
spec/views/surveys/results.html.haml_spec.rb
at least. – Denesedengue.ruby-version
file had been updated to a Ruby 2.4.x version, and my localrbenv
was still using a Ruby 2.3.x version. When I updated therbenv
Ruby version to match the.ruby-version
, things were fixed. – Dippoldbundle exec rails c
, the real error messages are shown. Not sure why the irrelativeRuntimeError: can't modify frozen Array
is thrown when running test. – Ultramontanismrails s
and it will show you the problems, fix them and run your tests again after the rails server run successfully :-) It worked for me. Should work for you too! – Whiffetsyntax error
. – Pellarails c
was the key to seeing the real error. – Epigeal