Skip to content

Commit 46779c7

Browse files
authored
Merge pull request #1924 from koic/friendly_pending_migration_error_log
Change `rails_helper.rb` template to friendly error log
2 parents decc627 + 372477c commit 46779c7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/generators/rspec/install/templates/spec/rails_helper.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@
2424

2525
<% if RSpec::Rails::FeatureCheck.can_maintain_test_schema? -%>
2626
# Checks for pending migrations and applies them before tests are run.
27-
# If you are not using ActiveRecord, you can remove this line.
28-
ActiveRecord::Migration.maintain_test_schema!
29-
27+
# If you are not using ActiveRecord, you can remove these lines.
28+
begin
29+
ActiveRecord::Migration.maintain_test_schema!
30+
rescue ActiveRecord::PendingMigrationError => e
31+
puts e.to_s.strip
32+
exit 1
33+
end
3034
<% elsif RSpec::Rails::FeatureCheck.can_check_pending_migrations? -%>
3135
# Checks for pending migrations before tests are run.
32-
# If you are not using ActiveRecord, you can remove this line.
33-
ActiveRecord::Migration.check_pending!
34-
36+
# If you are not using ActiveRecord, you can remove these lines.
37+
begin
38+
ActiveRecord::Migration.check_pending!
39+
rescue ActiveRecord::PendingMigrationError => e
40+
puts e.to_s.strip
41+
exit 1
42+
end
3543
<% end -%>
3644
RSpec.configure do |config|
3745
<% if RSpec::Rails::FeatureCheck.has_active_record? -%>

0 commit comments

Comments
 (0)