guard / guard-rspec

Guard::RSpec automatically run your specs (much like autotest)

Home Page:https://rubygems.org/gems/guard-rspec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

schema loads with every run

mockdeep opened this issue · comments

I'm not sure if this is an issue with guard-rspec or the way I have things configured, but when I have this setting in my spec_helper:

ActiveRecord::Migration.maintain_test_schema!

the schema gets re-loaded for every test run, which really slows down development. Is there a recommended way of handling it so that it only runs on the first run?

guard-rspec just runs RSpec, so if you run guard with the '-d' option, you should see the actual commandline used with RSpec (that same command outside Guard should do exactly the same thing).

If the schema gets reloaded, it means it's different, when it shouldn't be. If you're running something like Spring or Zeus, you want to make sure that you first completely stop the forked tests environment (spring stop or kill all the zeus_slave processes that may still be running).

Then, you may want to manually sync the test db to match the schema, e.g. bin/rake db:migrate RAILS_ENV=test. Then, no migrations should be necessary. (I often just migrate the test databases - and avoid migrating the development ones).

To debug, you may want to run: bin/rake db:migrate:status RAILS_ENV=test, or even manually check the status with select * from schema_migrations - which is how the method knows whether to load the schema or not. (the version numbers should match your migration files and db/schema.rb).

Hope that helps.

Thanks! It looks like someone didn't check in the schema file update after our last migration, so updating that seems to have fixed the issue.

Glad it works :)