New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rspec should not require user to call rake db:test:prepare #949
Comments
Can you elaborate? We should still be executing the |
After poking at it, I'll concede that this may just be operator error, but then I'd argue it may be a documentation bug. Consider the following description of the problem and tell me which you think it is:
You may argue that at step 4. I should have run Where is the documentation that says we should be running |
All of those commands are provided by Rails, and is changing in 4.1 anyway because, I assume of this confusion. |
When you run rspec, are you using the rake task, or the rspec command? |
Raw rspec command. (Edited comment above to emphasize the fact.) |
@JonRowe: The Rails team made a conscious decision to remove the documentation for |
The rake task invokes it… I'm not sure the naked rspec command actually should invoke it since not all specs depend will on the database, and you may be using the command to run individual files or tests. |
@soulcutter: I can confirm that running But in all the documentation I've read, I've never seen any suggestion that rspec should be called via a rake task. Indeed, all the examples for command line args (e.g. --no-color) or autotest show rspec being called directly, not as a rake task. Am I (and the StackOverflow community) missing something? |
I haven't done rails in a long time (most of my rails experience is from the rails 2.x days), but if memory serves, At this point, it sounds like it's enough of a pain point for users that we should consider changing that, particularly with the rails core team hiding
|
I believe the task is going away in Rails 4.1 anyway (being replaced by an API call), I'd be on board with making it a setting/or api call thats set to on in the default spec_helper but documented how to make it selective, e.g.: config.before(:all, type: :model) do
config.ensure_database_migrated!
end |
You'd want |
True |
I did some digging into how this is managed in Rails 4.1 and it looks isolated to this commit: rails/rails@ff7ab3b So, there's Harder to figure out the pre-4.1 behavior IMO |
Yeah I already added |
BTW @rdpoor have you tried Rails 4.1 and the new spec helper? |
@JonRowe: not yet but I will. It will take a couple of days to get to it... |
@JonRowe I have tried Rails 4.1 with rspec-rails 3.0.0.beta2 and the rails g rspec:install doesn't generate the line ActiveRecord::Migration.maintain_test_schema! I also experience another issue - the examples are not cleaned after tests run (config.use_transactional_fixtures = true). I'm using FactoryGirls as well and this wasn't a problem before. |
@tomasgregor 3beta2 does not have the new |
I think we can close this. We no longer call Based on my research the current My only change would be to possibly turn: if ::Rails::VERSION::STRING.to_f < 4.1
Rake::Task["test:prepare"].invoke
end into if Rake::Task.task_defined?("test:prepare")
Rake::Task["test:prepare"].invoke
end |
The user should not need to call
rake db:test:prepare
prior to running the tests. (I cannot point to when this became an issue, but I know it's an issue in Ruby 2.0 / Rails 4.0 / rspec-rails 2.14.)FWIW, I argued for reinstating documentation on db:test:prepare in rails/rails#2560 (comment), and zzak sensibly pointed out that user's shouldn't need to call it.
This is probably related to #663, #944 and #936, but I admit that I haven't kept up with the more recent developments.
Feel free to close this if it's already been addressed. Thanks.
The text was updated successfully, but these errors were encountered: