From 44f313e3e385894ec8564c7f7d4dcfe5cc07ae2c Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 19 Jun 2024 12:48:55 +0100 Subject: [PATCH] Merge pull request #2768 from rspec/fix-rails-main-build Fix deprecation warning from Rails 8 alpha --- Gemfile-rails-dependencies | 7 ++++++- example_app_generator/generate_app.rb | 8 ++++++-- .../spec/verify_mailer_preview_path_spec.rb | 2 +- spec/spec_helper.rb | 5 +++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Gemfile-rails-dependencies b/Gemfile-rails-dependencies index 44419e904..7b1289f5f 100644 --- a/Gemfile-rails-dependencies +++ b/Gemfile-rails-dependencies @@ -12,7 +12,12 @@ def add_net_gems_dependency end # sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4` -gem 'sqlite3', '~> 1.4', platforms: [:ruby] +if RUBY_VERSION.to_f < 3 + # sqlite3 1.7.x doesn't work on all platforms for Ruby 2.x + gem 'sqlite3', '~> 1.4', '< 1.7', platforms: [:ruby] +else + gem 'sqlite3', '~> 1.4', platforms: [:ruby] +end if RUBY_VERSION.to_f < 2.7 gem 'puma', '< 6.0.0' diff --git a/example_app_generator/generate_app.rb b/example_app_generator/generate_app.rb index 4b2c539d5..5af004407 100644 --- a/example_app_generator/generate_app.rb +++ b/example_app_generator/generate_app.rb @@ -28,8 +28,12 @@ gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'" - # sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4` - gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'" + # sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`, and Ruby 2.7 only supports < 1.7 + if RUBY_VERSION.to_f < 3 + gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4', '< 1.7'" + else + gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'" + end # remove webdrivers gsub_file "Gemfile", /gem ['"]webdrivers['"]/, "" diff --git a/example_app_generator/spec/verify_mailer_preview_path_spec.rb b/example_app_generator/spec/verify_mailer_preview_path_spec.rb index 50f145497..b35b285fa 100644 --- a/example_app_generator/spec/verify_mailer_preview_path_spec.rb +++ b/example_app_generator/spec/verify_mailer_preview_path_spec.rb @@ -38,7 +38,7 @@ def capture_exec(*ops) CaptureExec.new(out, $?.exitstatus) end - if ENV['RAILS_VERSION'] == 'main' && Rails::VERSION::STRING == "7.2.0.alpha" + if ENV['RAILS_VERSION'] == 'main' && Rails::VERSION::STRING == "8.0.0.alpha" before do skip('This is broken on Rails main but is skipped for green builds of 7.1.x, please fix') end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0f020214b..91fd92fa9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -35,6 +35,11 @@ def self.run_all(reporter = nil) end end +# This behaviour will become the default in Rails 8, for now it silences a deprecation +if ActiveSupport.respond_to?(:to_time_preserves_timezone) + ActiveSupport.to_time_preserves_timezone = true +end + # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.expect_with :rspec do |expectations|