Rails 5, Rspec: Environment data not found in the schema

前端 未结 7 1183
南方客
南方客 2020-12-29 01:49

After upgrading a Rails app to Rails 5, running RSpec tests gives me the following error:

rails aborted!
ActiveRecord::NoEnvironmentInSchemaError: 

Environm         


        
7条回答
  •  既然无缘
    2020-12-29 02:37

    New Rails 5 command to generate binstubs:

    rails app:update:bin
    

    Allows me to run the solution as the error suggested:

    bin/rails db:environment:set RAILS_ENV=test
    

    Tip from @max comment: If you are using database_cleaner and this error keeps popping up then change your config to:

    DatabaseCleaner.clean_with(
      :truncation,
      except: %w(ar_internal_metadata)
    )
    

提交回复
热议问题