Skip to content

Commit 4aced75

Browse files
authored
Merge pull request rspec#2751 from glaucocustodio/avoid-crash-in-rails-generators
Document/suggest workaround to avoid crash when running rails generators
2 parents ecac77b + 8acac38 commit 4aced75

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
require_relative '../config/environment'
55
# Prevent database truncation if the environment is production
66
abort("The Rails environment is running in production mode!") if Rails.env.production?
7+
<% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
8+
# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file
9+
# that will avoid rails generators crashing because migrations haven't been run yet
10+
# return unless Rails.env.test?
11+
<% end -%>
712
require 'rspec/rails'
813
# Add additional requires below this line. Rails is not loaded until this point!
914

0 commit comments

Comments
 (0)