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

前端 未结 14 2024
面向向阳花
面向向阳花 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:58

    My two-cents, as it may help someone else. I had this same issue when upgrading rails 4.2 to 5.0 I saw a thread post somewhere that suggested running one spec-test by itself / at a time. When I did that, I got a different error: superclass must be a Class and pointed me to my new .../models/application_record.rb file, in which I had made a syntax error by omission:

    class ApplicationRecord < ActiveRecord                              
      self.abstract_class = true
    end
    

    The above is missing ::Base after ActiveRecord -- first line.

    class ApplicationRecord < ActiveRecord::Base                                
      self.abstract_class = true
    end
    

    Adding that back in fixed all my specs.

提交回复
热议问题