RuntimeError: can't modify frozen Array when running rspec in rails 5.1

前端 未结 14 2025
面向向阳花
面向向阳花 2021-01-03 20:10

I recently upgraded to Rails 5.1 from v4.3 and am now getting this error when running tests:

An error occurred while loading 

./spec/controllers/admin/capac         


        
相关标签:
14条回答
  • 2021-01-03 20:47

    Try to run redis and sidekiq on background. In my case it was one of reasons.

    0 讨论(0)
  • 2021-01-03 20:52

    Suggestion: try loading the app in development after adding config.eager_load = true to your development.rb file, which should give you an actually useful error message pinpointing the problem code.

    In my case, a Rails 5.2 app, it was purely a result of upgrading from Ruby 2.4.5 to 2.5.8 which pinpointed the sole issue was unmatched range specifier in char-class in a very long regex that has been working for years.

    0 讨论(0)
  • 2021-01-03 20:53

    When i got the same error with similar stacktrace, it helped me to fix a syntax error in factories.

    0 讨论(0)
  • 2021-01-03 20:53

    Check that your Test DB is up to date before anything else.

    rake db:test:prepare.

    0 讨论(0)
  • 2021-01-03 20:56

    Turns out this was caused by test failures higher in the stack trace. It was hard to see what the root cause was because there was so much in the console. If you get this issue, I'd suggest using --fail-fast so you don't get overwhelmed with recurrent error messages. Then check what the first error is.

    0 讨论(0)
  • 2021-01-03 20:58

    For me it was a FactoryBot update from version 4 to 5. I didn't see the deprecation warning because I jumped versions:

    DEPRECATION WARNING: Static attributes will be removed in FactoryBot 5.0.
    
    0 讨论(0)
提交回复
热议问题