Skip to content

Change rails_helper.rb template to friendly error log #1924

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

Merged
merged 1 commit into from
Dec 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions lib/generators/rspec/install/templates/spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@

<% if RSpec::Rails::FeatureCheck.can_maintain_test_schema? -%>
# Checks for pending migrations and applies them before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.maintain_test_schema!

# If you are not using ActiveRecord, you can remove these lines.
begin
ActiveRecord::Migration.maintain_test_schema!
rescue ActiveRecord::PendingMigrationError => e
puts e.to_s.strip
exit 1
end
<% elsif RSpec::Rails::FeatureCheck.can_check_pending_migrations? -%>
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending!

# If you are not using ActiveRecord, you can remove these lines.
begin
ActiveRecord::Migration.check_pending!
rescue ActiveRecord::PendingMigrationError => e
puts e.to_s.strip
exit 1
end
<% end -%>
RSpec.configure do |config|
<% if RSpec::Rails::FeatureCheck.has_active_record? -%>
Expand Down