Skip to content

Update the CI matrix and fix test suite on Rails 7.1 #707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -6,15 +6,11 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ '2.7', '3.0.2', '3.1', '3.2', 'head' ]
rails: [ '6.0', '6.1', '7.0', 'edge' ]
ruby: [ '2.7', '3.0', '3.1', '3.2', 'head' ]
rails: [ '6.1', '7.0', '7.1', 'edge' ]
exclude:
- ruby: '3.1'
rails: '6.0'
- ruby: '3.1'
rails: '6.1'
- ruby: '3.2'
rails: '6.0'
- ruby: '3.2'
rails: '6.1'

7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -3,10 +3,13 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in spring.gemspec
gemspec

gem "rake"
gem "bump"

if ENV["RAILS_VERSION"] == "edge"
gem "activesupport", github: "rails/rails", branch: "main"
elsif ENV['RAILS_VERSION'] == "7.0"
gem "activesupport", ">= 7.0.0.alpha"
elsif ENV["RAILS_VERSION"]
gem "activesupport", "~> #{ENV["RAILS_VERSION"]}.0"
else
gem "activesupport"
end
4 changes: 0 additions & 4 deletions spring.gemspec
Original file line number Diff line number Diff line change
@@ -15,10 +15,6 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = ">= 2.7.0"

gem.add_development_dependency 'rake'
gem.add_development_dependency 'bump'
gem.add_development_dependency 'activesupport'

gem.metadata = {
"rubygems_mfa_required" => "true",
}
8 changes: 6 additions & 2 deletions test/support/acceptance_test.rb
Original file line number Diff line number Diff line change
@@ -139,7 +139,11 @@ def without_gem(name)
test "raises if config.cache_classes is true" do
config_path = app.path("config/environments/development.rb")
config = File.read(config_path)
config.sub!(/config.cache_classes\s*=\s*false/, "config.cache_classes = true")
if config.include?("config.cache_classes")
config.sub!(/config\.cache_classes\s*=\s*false/, "config.cache_classes = true")
else # 7.1+ doesn't have config.cache_classes in the config at all
config.sub!(/config.enable_reloading = true/, "config.enable_reloading = true\nconfig.cache_classes = true")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing

Why set both enable_reloading and cache_classes?
The settings are basically aliases but opposite. enable_reloading = !cache_classes.

The Rails documentation is confusing in its description of enable_reloading and cache_classes, so maybe that is why it ended up this way here.

Suggested change
config.sub!(/config.enable_reloading = true/, "config.enable_reloading = true\nconfig.cache_classes = true")
config.sub!(/config.enable_reloading = true/, "config.enable_reloading = false")

end
File.write(config_path, config)

assert_failure "bin/rails runner 1", stderr: "Please, set config.cache_classes to false"
@@ -258,7 +262,7 @@ def exec_name
end

test "binstub" do
assert_success "bin/rails server --help", stdout: /Usage:\s+rails server/ # rails command fallback
assert_success "bin/rails server --help", stdout: /Usage:\s+(bin\/)?rails server/ # rails command fallback

assert_success "#{app.spring} binstub rake", stdout: "bin/rake: Spring already present"

6 changes: 5 additions & 1 deletion test/support/application_generator.rb
Original file line number Diff line number Diff line change
@@ -64,7 +64,11 @@ def generate_files
end

rewrite_file(application.path("config/environments/test.rb")) do |c|
c.sub!(/config\.cache_classes\s*=\s*true/, "config.cache_classes = false")
if c.include?("config.cache_classes")
c.sub!(/config\.cache_classes\s*=\s*true/, "config.cache_classes = false")
else # 7.1+ doesn't have config.cache_classes in the config at all
c.sub!(/config.enable_reloading = false/, "config.enable_reloading = false\nconfig.cache_classes = false")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in acceptance_test.rb

Suggested change
c.sub!(/config.enable_reloading = false/, "config.enable_reloading = false\nconfig.cache_classes = false")
c.sub!(/config.enable_reloading = false/, "config.enable_reloading = true")

end
c
end