From 616630b3559f458be2b321bcc05125d21105782a Mon Sep 17 00:00:00 2001 From: Masato Ohba Date: Wed, 5 Feb 2025 23:52:42 +0900 Subject: [PATCH 1/3] Update comment about `ActiveRecord::Migration.maintain_test_schema!` The original comment implies that `maintain_test_schema!` applies pending migrations, but in reality, it purges and recreates the database, then loads the schema. --- lib/generators/rspec/install/templates/spec/rails_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/generators/rspec/install/templates/spec/rails_helper.rb b/lib/generators/rspec/install/templates/spec/rails_helper.rb index d27f3673c..5747d1a72 100644 --- a/lib/generators/rspec/install/templates/spec/rails_helper.rb +++ b/lib/generators/rspec/install/templates/spec/rails_helper.rb @@ -28,7 +28,9 @@ # Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f } <% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%> -# Checks for pending migrations and applies them before tests are run. +# Ensures that the test database schema matches the current schema file. +# This call checks for pending migrations and, if any are found, +# purges and recreates the test database by loading the schema. # If you are not using ActiveRecord, you can remove these lines. begin ActiveRecord::Migration.maintain_test_schema! From 6526b07e9c396723198d1793174a42f901b2853e Mon Sep 17 00:00:00 2001 From: Masato Ohba Date: Thu, 6 Feb 2025 10:00:42 +0900 Subject: [PATCH 2/3] Update lib/generators/rspec/install/templates/spec/rails_helper.rb Co-authored-by: Jon Rowe --- lib/generators/rspec/install/templates/spec/rails_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/rspec/install/templates/spec/rails_helper.rb b/lib/generators/rspec/install/templates/spec/rails_helper.rb index 5747d1a72..725337338 100644 --- a/lib/generators/rspec/install/templates/spec/rails_helper.rb +++ b/lib/generators/rspec/install/templates/spec/rails_helper.rb @@ -29,8 +29,8 @@ <% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%> # Ensures that the test database schema matches the current schema file. -# This call checks for pending migrations and, if any are found, -# purges and recreates the test database by loading the schema. +# If there are pending migrations it will invoke `db:test:prepare` to +# recreate the test database by loading the schema. # If you are not using ActiveRecord, you can remove these lines. begin ActiveRecord::Migration.maintain_test_schema! From 6c05dfc9de99fac1352179a1ef455fb60372836f Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 6 Feb 2025 08:07:20 +0000 Subject: [PATCH 3/3] Update lib/generators/rspec/install/templates/spec/rails_helper.rb --- lib/generators/rspec/install/templates/spec/rails_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/rspec/install/templates/spec/rails_helper.rb b/lib/generators/rspec/install/templates/spec/rails_helper.rb index 725337338..0f3ef72ae 100644 --- a/lib/generators/rspec/install/templates/spec/rails_helper.rb +++ b/lib/generators/rspec/install/templates/spec/rails_helper.rb @@ -29,7 +29,7 @@ <% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%> # Ensures that the test database schema matches the current schema file. -# If there are pending migrations it will invoke `db:test:prepare` to +# If there are pending migrations it will invoke `db:test:prepare` to # recreate the test database by loading the schema. # If you are not using ActiveRecord, you can remove these lines. begin