Skip to content

Commit

Permalink
Merge pull request #2768 from rspec/fix-rails-main-build
Browse files Browse the repository at this point in the history
Fix deprecation warning from Rails 8 alpha
  • Loading branch information
JonRowe committed Jun 19, 2024
1 parent 32d0413 commit 44f313e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Gemfile-rails-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 6 additions & 2 deletions example_app_generator/generate_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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['"]/, ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 44f313e

Please sign in to comment.