Skip to content

Commit

Permalink
Skip bootsnap on the test project creation (#1478)
Browse files Browse the repository at this point in the history
* Skip bootsnap on the test project creation

Use the Rails --skip-bootsnap option instead of commenting it on
boot.rb

* Use the same `rails new` command on acceptance and unit tests

* Fix the Rails version comparison

The `=~ '~> 6.0'` comparison is evaluated to `false` on newer
versions of Rails, thus not skipping the JavaScript dependencies.
  • Loading branch information
neilvcarvalho committed Jan 31, 2022
1 parent 38db235 commit 206d2da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 32 deletions.
6 changes: 3 additions & 3 deletions spec/support/acceptance/helpers/step_helpers.rb
Expand Up @@ -88,10 +88,10 @@ def create_rails_application
end

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"
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"
"bundle exec rails new #{fs.project_directory} --database=#{database.adapter_name} --skip-bundle --no-rc --skip-bootsnap"
end
end

Expand Down
32 changes: 3 additions & 29 deletions spec/support/unit/rails_application.rb
Expand Up @@ -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
Expand All @@ -90,25 +89,10 @@ def rails_new
end

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',
]
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
[
'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

Expand All @@ -124,16 +108,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
Expand Down

0 comments on commit 206d2da

Please sign in to comment.