Skip to content

Commit 8f449ab

Browse files
authored
Merge pull request #2614 from rspec/remove-some-hacks
Remove version-specific checks for unsupported Rails/Ruby
2 parents 7b7a86f + 880a2d5 commit 8f449ab

35 files changed

+67
-297
lines changed

Gemfile

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,12 @@ group :documentation do
1212
gem 'relish', '~> 0.7.1'
1313
end
1414

15-
gem 'rake', '> 12'
16-
17-
if RUBY_VERSION.to_f >= 2.3
18-
gem 'rubocop', '~> 0.80.1'
19-
end
20-
2115
gem 'capybara'
22-
23-
if RUBY_VERSION.to_f >= 2.3
24-
gem 'ffi', '~> 1.15.5'
25-
else
26-
gem 'ffi', '~> 1.12.0'
27-
end
16+
gem 'ffi', '~> 1.15.5'
17+
gem 'rake', '> 12'
18+
gem 'rubocop', '~> 0.80.1'
2819

2920
custom_gemfile = File.expand_path('Gemfile-custom', __dir__)
3021
eval_gemfile custom_gemfile if File.exist?(custom_gemfile)
3122

32-
eval_gemfile 'Gemfile-sqlite-dependencies'
3323
eval_gemfile 'Gemfile-rails-dependencies'

Gemfile-rails-dependencies

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ def add_net_gems_dependency
1111
end
1212
end
1313

14+
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`
15+
gem 'sqlite3', '~> 1.4', platforms: [:ruby]
16+
1417
case version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || ''
1518
when /main/
1619
gem "rails", :git => "https://github.com/rails/rails.git"

Gemfile-sqlite-dependencies

Lines changed: 0 additions & 20 deletions
This file was deleted.

README_DEV.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ Rails than you are trying to use now.
3434
To run the specs against a different version of Rails, use the `thor` command:
3535

3636
```bash
37-
bin/thor version:use 6.0.2.2
37+
bin/thor version:use 7.0.3.1
3838
bin/rake
3939
```

cucumber.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
default: --require features --format progress --tags 'not @wip'
2-
pretty: --require features --format pretty --tags 'not @wip'
3-
wip: --require features --tags @wip
1+
default: --publish-quiet --require features --format progress --tags 'not @wip'
2+
pretty: --publish-quiet --require features --format pretty --tags 'not @wip'
3+
wip: --publish-quiet --require features --tags @wip

example_app_generator/config/initializers/sqlite3_fix.rb

Lines changed: 0 additions & 3 deletions
This file was deleted.

example_app_generator/generate_action_mailer_specs.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
end
1616
CODE
1717

18-
rails_parent =
19-
if Rails.version.to_f >= 6.0
20-
Rails.application.class.module_parent.to_s
21-
else
22-
Rails.application.class.parent.to_s
23-
end
18+
rails_parent = Rails.application.class.module_parent.to_s
2419

2520
gsub_file 'config/initializers/action_mailer.rb', /ExampleApp/, rails_parent
2621

example_app_generator/generate_app.rb

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
'ci_retry_bundle_install.sh'
1212
)
1313
function_script_file = File.join(rspec_rails_repo_path, 'script/functions.sh')
14-
sqlite_initializer = File.join(rspec_rails_repo_path, "example_app_generator/config/initializers/sqlite3_fix.rb")
1514

1615
in_root do
1716
prepend_to_file "Rakefile", "require 'active_support/all'"
@@ -27,31 +26,12 @@
2726

2827
append_to_file 'Gemfile', "gem 'rails-controller-testing'\n"
2928

30-
if Rails::VERSION::STRING >= '6'
31-
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
29+
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
3230

33-
# TODO: To remove when Rails released with https://github.com/rails/rails/pull/40281
34-
append_to_file 'Gemfile', <<-EOT.gsub(/^ +\|/, '')
35-
|gem 'rexml'
36-
EOT
37-
end
38-
39-
if Rails::VERSION::STRING >= '6'
40-
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`
41-
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'"
42-
else
43-
# Similarly, Rails 5.0 only supports '~> 1.3.6'. Rails 5.1-5.2 support '~> 1.3', '>= 1.3.6'
44-
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'"
45-
end
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'"
4633

47-
# webdrivers 4 up until 4.3.0 don't specify `required_ruby_version`, but contain
48-
# Ruby 2.2-incompatible syntax (safe navigation).
49-
# That basically means we use pre-4.0 for Ruby 2.2, and 4.3+ for newer Rubies.
50-
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '!= 4.0.0', '!= 4.0.1', '!= 4.1.0', '!= 4.1.1', '!= 4.1.2', '!= 4.1.3', '!= 4.2.0'"
51-
52-
if Rails::VERSION::STRING < '6'
53-
copy_file sqlite_initializer, 'config/initializers/sqlite3_fix.rb'
54-
end
34+
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
5535

5636
if RUBY_ENGINE == "jruby"
5737
gsub_file "Gemfile", /.*jdbc.*/, ''

example_app_generator/spec/support/default_preview_path

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ require_file_stub 'config/environment' do
2626
require "action_controller/railtie"
2727
require "action_mailer/railtie" unless ENV['NO_ACTION_MAILER']
2828
require "action_view/railtie"
29-
if Rails::VERSION::STRING >= '6'
30-
require "action_cable/engine"
31-
require "active_job/railtie"
32-
require "action_mailbox/engine"
33-
end
29+
require "action_cable/engine"
30+
require "active_job/railtie"
31+
require "action_mailbox/engine"
3432

3533
# Require the gems listed in Gemfile, including any gems
3634
# you've limited to :test, :development, or :production.

example_app_generator/spec/verify_custom_renderers_spec.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ def index
3636

3737
expect(response).to render_template(:bar)
3838
end
39-
40-
it "renders an empty string", skip: Rails::VERSION::STRING.to_f >= 6.0 do
41-
get :index
42-
43-
expect(response.body).to eq("")
44-
end
4539
end
4640

4741
context "with a custom renderer prepended to the view path" do

0 commit comments

Comments
 (0)