rubygem-shoulda-matchers/rubygem-shoulda-matchers-5.1.0-Skip-bootsnap-on-the-test-project-creation.patch
2023-01-17 14:54:09 +08:00

139 lines
5.5 KiB
Diff

From 8e1303957ba2c0828c2eb2b91b9edea723d1553d Mon Sep 17 00:00:00 2001
From: Neil <me@neil.pro>
Date: Sat, 15 Jan 2022 19:37:42 -0300
Subject: [PATCH 1/3] Skip bootsnap on the test project creation
Use the Rails --skip-bootsnap option instead of commenting it on
boot.rb
---
spec/support/acceptance/helpers/step_helpers.rb | 4 ++--
spec/support/unit/rails_application.rb | 11 -----------
2 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/spec/support/acceptance/helpers/step_helpers.rb b/spec/support/acceptance/helpers/step_helpers.rb
index fa972ecf4..878b27d3e 100644
--- a/spec/support/acceptance/helpers/step_helpers.rb
+++ b/spec/support/acceptance/helpers/step_helpers.rb
@@ -93,9 +93,9 @@ def create_rails_application
def rails_new_command
if rails_version =~ '~> 6.0'
- "bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --skip-javascript --no-rc"
+ "bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --skip-javascript --no-rc --skip-bootsnap"
else
- "bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --no-rc"
+ "bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --no-rc --skip-bootsnap"
end
end
diff --git a/spec/support/unit/rails_application.rb b/spec/support/unit/rails_application.rb
index b55b12cee..4480fd21a 100644
--- a/spec/support/unit/rails_application.rb
+++ b/spec/support/unit/rails_application.rb
@@ -77,7 +77,6 @@ def temp_view_path_for(path)
def generate
rails_new
fix_available_locales_warning
- remove_bootsnap
write_database_configuration
write_activerecord_model_with_default_connection
write_activerecord_model_with_different_connection
@@ -124,16 +123,6 @@ def fix_available_locales_warning
end
end
- def remove_bootsnap
- # Rails 5.2 introduced bootsnap, which is helpful when you're developing
- # or deploying an app, but we don't really need it (and it messes with
- # Zeus anyhow)
- fs.comment_lines_matching(
- 'config/boot.rb',
- %r{\Arequire 'bootsnap/setup'},
- )
- end
-
def write_database_configuration
YAML.dump(database.config.load_file, fs.open('config/database.yml', 'w'))
end
From df9c312134a939ab1c220b071d95fe3e32fe2601 Mon Sep 17 00:00:00 2001
From: Neil <me@neil.pro>
Date: Wed, 19 Jan 2022 07:32:15 -0300
Subject: [PATCH 2/3] Use the same `rails new` command on acceptance and unit
tests
---
spec/support/unit/rails_application.rb | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/spec/support/unit/rails_application.rb b/spec/support/unit/rails_application.rb
index 4480fd21a..511b99960 100644
--- a/spec/support/unit/rails_application.rb
+++ b/spec/support/unit/rails_application.rb
@@ -90,24 +90,9 @@ def rails_new
def rails_new_command
if rails_version > 5
- [
- 'rails',
- 'new',
- fs.project_directory.to_s,
- "--database=#{database.adapter_name}",
- '--skip-bundle',
- '--no-rc',
- '--skip-webpack-install',
- ]
+ "bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --skip-javascript --no-rc --skip-bootsnap"
else
- [
- 'rails',
- 'new',
- fs.project_directory.to_s,
- "--database=#{database.adapter_name}",
- '--skip-bundle',
- '--no-rc',
- ]
+ "bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --no-rc --skip-bootsnap"
end
end
From 2f9c975c77e8adf1ebb2f0fe921756a9527e504c Mon Sep 17 00:00:00 2001
From: Neil <me@neil.pro>
Date: Wed, 19 Jan 2022 07:32:57 -0300
Subject: [PATCH 3/3] Fix the Rails version comparison
The `=~ '~> 6.0'` comparison is evaluated to `false` on newer
versions of Rails, thus not skipping the JavaScript dependencies.
---
spec/support/acceptance/helpers/step_helpers.rb | 2 +-
spec/support/unit/rails_application.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/spec/support/acceptance/helpers/step_helpers.rb b/spec/support/acceptance/helpers/step_helpers.rb
index 878b27d3e..818b08842 100644
--- a/spec/support/acceptance/helpers/step_helpers.rb
+++ b/spec/support/acceptance/helpers/step_helpers.rb
@@ -92,7 +92,7 @@ def create_rails_application
end
def rails_new_command
- if rails_version =~ '~> 6.0'
+ if rails_version >= 6.0
"bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --skip-javascript --no-rc --skip-bootsnap"
else
"bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --no-rc --skip-bootsnap"
diff --git a/spec/support/unit/rails_application.rb b/spec/support/unit/rails_application.rb
index 511b99960..5f097099d 100644
--- a/spec/support/unit/rails_application.rb
+++ b/spec/support/unit/rails_application.rb
@@ -89,7 +89,7 @@ def rails_new
end
def rails_new_command
- if rails_version > 5
+ if rails_version >= 6.0
"bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --skip-javascript --no-rc --skip-bootsnap"
else
"bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --no-rc --skip-bootsnap"