diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 728ecd83..8841dd9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,14 +7,7 @@ jobs: fail-fast: false matrix: ruby: [ '2.7', '3.0.2', 'head' ] - rails: [ '6.0', '6.1', 'edge' ] - include: - - ruby: '2.6' - rails: '5.2' - - ruby: '2.6' - rails: '6.0' - - ruby: '2.6' - rails: '6.1' + rails: [ '6.0', '6.1', '7.0', 'edge' ] env: RAILS_VERSION: ${{ matrix.rails }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 55c66435..a836a9c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ * Stop requiring `set` before bundler can select the proper version. This could result in `already defined constant` warnings during boot (#659). +* Require Ruby 2.7. +* Require Rails 6.0. ## 3.1.1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6774556f..a5dfa5bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,7 @@ acceptance tests again, which will generate a new app. You can set the `RAILS_VERSION` environment variable: ``` -$ RAILS_VERSION="~> 3.2.0" rake test:acceptance +$ RAILS_VERSION="6.1" rake test:acceptance ``` The apps in `test/apps` will be named based on the rails version, and the diff --git a/Gemfile b/Gemfile index b283d758..cba4d3a4 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,9 @@ gemspec if ENV["RAILS_VERSION"] == "edge" gem "activesupport", github: "rails/rails", branch: "main" +elsif ENV['RAILS_VERSION'] == "7.0" + gem "activesupport", ">= 7.0.0.alpha" + ">= 7.0.0.alpha" elsif ENV["RAILS_VERSION"] - gem "activesupport", ENV["RAILS_VERSION"] + gem "activesupport", "~> #{ENV["RAILS_VERSION"]}.0" end diff --git a/README.md b/README.md index a0eb3150..5266cafd 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,8 @@ boot it every time you run a test, rake task or migration. ## Compatibility -* Ruby versions: MRI 2.5, MRI 2.6 -* Rails versions: 5.2, 6.0 (Spring is installed by default when you do - `rails new` to generate your application) +* Ruby versions: MRI 2.7, MRI 3.0, MRI 3.1 +* Rails versions: 6.0, 6.1, 7.0 Spring makes extensive use of `Process.fork`, so won't be able to provide a speed up on platforms which don't support forking (Windows, JRuby). diff --git a/lib/spring/application.rb b/lib/spring/application.rb index 9261ac8c..b6054abf 100644 --- a/lib/spring/application.rb +++ b/lib/spring/application.rb @@ -92,8 +92,8 @@ def preload require Spring.application_root_path.join("config", "application") - unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('5.2.0') - raise "Spring only supports Rails >= 5.2.0" + unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('6.0.0') + raise "Spring only supports Rails >= 6.0.0" end Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do diff --git a/lib/spring/application_manager.rb b/lib/spring/application_manager.rb index c759fba7..1ccd7d8c 100644 --- a/lib/spring/application_manager.rb +++ b/lib/spring/application_manager.rb @@ -93,7 +93,7 @@ def stop def start_child(preload = false) @child, child_socket = UNIXSocket.pair - Bundler.with_original_env do + Bundler.with_unbundled_env do bundler_dir = File.expand_path("../..", $LOADED_FEATURES.grep(/bundler\/setup\.rb$/).first) @pid = Process.spawn( { diff --git a/spring.gemspec b/spring.gemspec index 7e20cef5..99834785 100644 --- a/spring.gemspec +++ b/spring.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |gem| gem.files = Dir["LICENSE.txt", "README.md", "lib/**/*", "bin/*"] gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } - gem.required_ruby_version = ">= 2.5.0" + gem.required_ruby_version = ">= 2.7.0" gem.add_development_dependency 'rake' gem.add_development_dependency 'bump' diff --git a/test/support/acceptance_test.rb b/test/support/acceptance_test.rb index fcf3e3cb..678988ef 100644 --- a/test/support/acceptance_test.rb +++ b/test/support/acceptance_test.rb @@ -12,9 +12,11 @@ class AcceptanceTest < ActiveSupport::TestCase def rails_version if ENV['RAILS_VERSION'] == "edge" - "7.0.0.alpha" + "7.1.0.alpha" + elsif ENV['RAILS_VERSION'] == "7.0" + ">= 7.0.0.alpha" else - '~> 6.0.0' + "~> #{ENV['RAILS_VERSION'] || "6.1"}.0" end end @@ -157,7 +159,7 @@ def without_gem(name) end test "code changes in pre-referenced app files are picked up" do - File.write(app.path("config/initializers/load_posts_controller.rb"), "PostsController\n") + File.write(app.path("config/initializers/load_posts_controller.rb"), "Rails.application.config.to_prepare { PostsController }\n") assert_speedup do assert_success app.spring_test_command, stdout: "0 failures" @@ -271,6 +273,7 @@ def exec_name test "binstub when spring gem is missing" do without_gem "spring-#{Spring::VERSION}" do File.write(app.gemfile, app.gemfile.read.gsub(/gem 'spring.*/, "")) + app.run! "bundle install", timeout: 300 assert_success "bin/rake -T", stdout: "rake db:migrate" end end @@ -518,7 +521,8 @@ def exec_name test "changing the Gemfile works" do assert_success %(bin/rails runner 'require "sqlite3"') - File.write(app.gemfile, app.gemfile.read.gsub(%{gem 'sqlite3'}, %{# gem 'sqlite3'})) + File.write(app.gemfile, app.gemfile.read.gsub(%r{gem ['"]sqlite3['"]}, %{# gem "sqlite3"})) + puts app.gemfile.read app.await_reload assert_failure %(bin/rails runner 'require "sqlite3"'), stderr: "sqlite3" @@ -530,7 +534,7 @@ def exec_name assert_success %(bin/rails runner 'require "sqlite3"') - File.write(app.gems_rb, app.gems_rb.read.sub(%{gem 'sqlite3'}, %{# gem 'sqlite3'})) + File.write(app.gems_rb, app.gems_rb.read.gsub(%r{gem ['"]sqlite3['"]}, %{# gem "sqlite3"})) app.await_reload assert_failure %(bin/rails runner 'require "sqlite3"'), stderr: "sqlite3" @@ -540,7 +544,7 @@ def exec_name File.write(app.path("script.rb"), <<-RUBY.strip_heredoc) gemfile = Rails.root.join("Gemfile") File.write(gemfile, "\#{gemfile.read}gem 'text'\\n") - Bundler.with_clean_env do + Bundler.with_unbundled_env do system(#{app.env.inspect}, "bundle install") end output = `\#{Rails.root.join('bin/rails')} runner 'require "text"; puts "done";'` @@ -557,7 +561,7 @@ def exec_name File.write(app.path("script.rb"), <<-RUBY.strip_heredoc) gemfile = Rails.root.join("gems.rb") File.write(gemfile, "\#{gemfile.read}gem 'text'\\n") - Bundler.with_clean_env do + Bundler.with_unbundled_env do system(#{app.env.inspect}, "bundle install") end output = `\#{Rails.root.join('bin/rails')} runner 'require "text"; puts "done";'` diff --git a/test/support/application.rb b/test/support/application.rb index 9d999466..baeb0092 100644 --- a/test/support/application.rb +++ b/test/support/application.rb @@ -111,7 +111,7 @@ def spring_client_config def run(command, opts = {}) start_time = Time.now - Bundler.with_original_env do + Bundler.with_unbundled_env do Process.spawn( env.merge(opts[:env] || {}), command.to_s, diff --git a/test/support/application_generator.rb b/test/support/application_generator.rb index 13d85277..8b813495 100644 --- a/test/support/application_generator.rb +++ b/test/support/application_generator.rb @@ -31,7 +31,7 @@ def system(command) end def generate - Bundler.with_original_env { generate_files } + Bundler.with_unbundled_env { generate_files } install_spring generate_scaffold end @@ -60,17 +60,9 @@ def generate_files c.sub!("https://rubygems.org", "http://rubygems.org") c.gsub!(/(gem '(byebug|web-console|sdoc|jbuilder)')/, "# \\1") - if @version.to_s < '5.2' - c.gsub!(/(gem 'sqlite3')/, "# \\1") - end - c end - if @version.to_s < '5.2' - append_to_file(application.gemfile, "gem 'sqlite3', '< 1.4'") - end - rewrite_file(application.path("config/environments/test.rb")) do |c| c.sub!(/config\.cache_classes\s*=\s*true/, "config.cache_classes = false") c