Skip to content

Commit 44f313e

Browse files
committed
Merge pull request #2768 from rspec/fix-rails-main-build
Fix deprecation warning from Rails 8 alpha
1 parent 32d0413 commit 44f313e

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

Gemfile-rails-dependencies

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ def add_net_gems_dependency
1212
end
1313

1414
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`
15-
gem 'sqlite3', '~> 1.4', platforms: [:ruby]
15+
if RUBY_VERSION.to_f < 3
16+
# sqlite3 1.7.x doesn't work on all platforms for Ruby 2.x
17+
gem 'sqlite3', '~> 1.4', '< 1.7', platforms: [:ruby]
18+
else
19+
gem 'sqlite3', '~> 1.4', platforms: [:ruby]
20+
end
1621

1722
if RUBY_VERSION.to_f < 2.7
1823
gem 'puma', '< 6.0.0'

example_app_generator/generate_app.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828

2929
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
3030

31-
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`
32-
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'"
31+
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`, and Ruby 2.7 only supports < 1.7
32+
if RUBY_VERSION.to_f < 3
33+
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4', '< 1.7'"
34+
else
35+
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'"
36+
end
3337

3438
# remove webdrivers
3539
gsub_file "Gemfile", /gem ['"]webdrivers['"]/, ""

example_app_generator/spec/verify_mailer_preview_path_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def capture_exec(*ops)
3838
CaptureExec.new(out, $?.exitstatus)
3939
end
4040

41-
if ENV['RAILS_VERSION'] == 'main' && Rails::VERSION::STRING == "7.2.0.alpha"
41+
if ENV['RAILS_VERSION'] == 'main' && Rails::VERSION::STRING == "8.0.0.alpha"
4242
before do
4343
skip('This is broken on Rails main but is skipped for green builds of 7.1.x, please fix')
4444
end

spec/spec_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def self.run_all(reporter = nil)
3535
end
3636
end
3737

38+
# This behaviour will become the default in Rails 8, for now it silences a deprecation
39+
if ActiveSupport.respond_to?(:to_time_preserves_timezone)
40+
ActiveSupport.to_time_preserves_timezone = true
41+
end
42+
3843
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
3944
RSpec.configure do |config|
4045
config.expect_with :rspec do |expectations|

0 commit comments

Comments
 (0)