jonleighton / spring-commands-rspec

MIT License
378 stars 37 forks source link

README instructions for maintaining test database #36

Closed tylergannon closed 1 year ago

tylergannon commented 8 years ago

This instructs developers how to avoid the "pending migrations" error

jonleighton commented 8 years ago

Does the default helper file not contain something like this? Therefore is additional configuration actually necessary?

peteygao commented 6 years ago

@jonleighton The default helper (as of Rails 5.1.5) is specified globally in rails_helper.rb. That means it is executed once, and only once, when rails_helper is required at app boot. Successive runs with spring will fork the in-memory process, and thus it will not be triggered (as the process no longer needs to require 'rails_helper' again).

What @tylergannon's change proposes is to run ActiveRecord::Migration.maintain_test_schema! before the test suite is run every time (via before(:suite) callback). This seems like a sensible approach when using something like spring.