Skip to content

Commit

Permalink
Merge pull request #2751 from glaucocustodio/avoid-crash-in-rails-gen…
Browse files Browse the repository at this point in the history
…erators

Document/suggest workaround to avoid crash when running rails generators
  • Loading branch information
JonRowe committed Apr 10, 2024
2 parents ecac77b + 8acac38 commit 4aced75
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/generators/rspec/install/templates/spec/rails_helper.rb
Expand Up @@ -4,6 +4,11 @@
require_relative '../config/environment'
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
<% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file
# that will avoid rails generators crashing because migrations haven't been run yet
# return unless Rails.env.test?
<% end -%>
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!

Expand Down

0 comments on commit 4aced75

Please sign in to comment.