Skip to content

Commit dbb7362

Browse files
committed
Merge pull request #2380 from rspec/reckless-rubygems-workaround-removal
Experimental removal of Rubygems workarounds (main branch)
1 parent 2188ea2 commit dbb7362

File tree

3 files changed

+41
-87
lines changed

3 files changed

+41
-87
lines changed

Gemfile

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,32 @@ group :documentation do
1414
gem 'relish', '~> 0.7.1'
1515
end
1616

17-
platforms :jruby do
18-
gem "jruby-openssl"
19-
end
17+
gem 'rake', '> 12'
2018

21-
case RAILS_VERSION
22-
when /main/
23-
MAJOR = 6
24-
MINOR = 0
25-
when /5-2-stable/
26-
MAJOR = 5
27-
MINOR = 2
28-
when /stable/
29-
MAJOR = 6
30-
MINOR = 0
31-
when nil, false, ""
32-
MAJOR = 6
33-
MINOR = 0
34-
else
35-
match = /(\d+)(\.|-)(\d+)/.match(RAILS_VERSION)
36-
MAJOR, MINOR = match.captures.map(&:to_i).compact
19+
if RUBY_VERSION.to_f >= 2.3
20+
gem 'rubocop', '~> 0.80.1'
3721
end
3822

23+
gem 'capybara'
24+
25+
MAJOR =
26+
case RAILS_VERSION
27+
when /5-2-stable/
28+
5
29+
when /main/, /stable/, nil, false, ''
30+
6
31+
else
32+
/(\d+)[\.|-]\d+/.match(RAILS_VERSION).captures.first.to_i
33+
end
34+
3935
if MAJOR >= 6
40-
gem 'selenium-webdriver', '~> 3.5', require: false
36+
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`
4137
gem 'sqlite3', '~> 1.4', platforms: [:ruby]
4238
else
39+
# Similarly, Rails 5.0 only supports '~> 1.3.6'. Rails 5.1-5.2 support '~> 1.3', '>= 1.3.6'
4340
gem 'sqlite3', '~> 1.3.6', platforms: [:ruby]
4441
end
4542

46-
gem 'ffi', '~> 1.9.25'
47-
48-
gem 'rake', '~> 12'
49-
50-
gem 'mime-types', "~> 3"
51-
52-
if RUBY_VERSION.to_f < 2.3
53-
gem 'capybara', '~> 3.1.0'
54-
elsif RUBY_VERSION.to_f < 2.4
55-
gem 'capybara', '< 3.16'
56-
elsif RUBY_VERSION.to_f < 2.5
57-
gem 'capybara', '< 3.33'
58-
else
59-
gem 'capybara', '>= 2.13', '< 4.0', require: false
60-
end
61-
62-
if MAJOR < 6
63-
gem 'nokogiri', '1.9.1'
64-
else
65-
gem 'nokogiri', '>= 1.10.8'
66-
end
67-
68-
gem "rubyzip", '~> 1.2'
69-
70-
if RUBY_VERSION.to_f >= 2.3
71-
gem 'rubocop', '~> 0.80.1'
72-
end
73-
7443
custom_gemfile = File.expand_path('Gemfile-custom', __dir__)
7544
eval_gemfile custom_gemfile if File.exist?(custom_gemfile)
7645

Gemfile-rails-dependencies

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ when /main/
1414
gem 'sprockets-rails', :git => 'https://github.com/rails/sprockets-rails.git', :branch => 'master'
1515
gem 'puma', "3.12.1"
1616
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby]
17+
gem 'selenium-webdriver', require: false
1718
when /stable$/
1819
gem_list = %w[rails railties actionmailer actionpack activerecord activesupport activejob actionview]
1920
gem 'puma', "3.12.1" if version > '5-0-stable'
2021
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby]
21-
gem "sprockets", '~> 3.0' if RUBY_VERSION < '2.5'
2222

2323
gem_list.each do |rails_gem|
2424
gem rails_gem, :git => "https://github.com/rails/rails.git", :branch => version
@@ -27,14 +27,13 @@ when nil, false, ""
2727
gem "rails", "~> 6.0.0"
2828
gem "puma"
2929
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
30+
gem 'selenium-webdriver', require: false
3031
else
3132
gem "rails", version
3233
gem "sprockets", '~> 3.0' if RUBY_VERSION < '2.5'
3334
gem "puma" if version >= '5-1-stable'
34-
35-
if version.gsub(/[^\d\.]/,'').to_f >= 6.0
36-
gem "activerecord-jdbcsqlite3-adapter", "~> 60.0.rc1", platforms: [:jruby]
37-
else
38-
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
39-
end
35+
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
36+
gem 'selenium-webdriver', require: false if version >= '5'
4037
end
38+
39+
gem 'jruby-openssl', platforms: [:jruby]

example_app_generator/generate_app.rb

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,54 +21,40 @@
2121
gsub_file 'Gemfile', /^.*\bgem 'rails.*$/, ''
2222
gsub_file "Gemfile", /.*web-console.*/, ''
2323
gsub_file "Gemfile", /.*debugger.*/, ''
24-
gsub_file "Gemfile", /.*byebug.*/, "gem 'byebug', '~> 9.0.6'"
25-
gsub_file "Gemfile", /.*puma.*/, ""
26-
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'"
27-
gsub_file "Gemfile", /.*bootsnap.*/, ""
24+
gsub_file "Gemfile", /.*puma.*/, ''
25+
gsub_file "Gemfile", /.*bootsnap.*/, ''
2826

29-
if Rails::VERSION::STRING >= '5.0.0'
30-
append_to_file('Gemfile', "gem 'rails-controller-testing'\n")
27+
# We soft-support Rails 4.2. `rails-controller-testing` only supports Rails 5+.
28+
# This conditional is to facilitate local testing against Rails 4.2.
29+
if Rails::VERSION::STRING >= '5'
30+
append_to_file 'Gemfile', "gem 'rails-controller-testing'\n"
3131
end
3232

3333
if Rails::VERSION::STRING >= '6'
34-
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'"
3534
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
3635
end
3736

38-
if RUBY_VERSION < "2.3.0"
39-
gsub_file "Gemfile", /.*childprocess.*/, "gem 'childprocess', '< 2.0.0'"
40-
gsub_file "Gemfile", /.*i18n.*/, "gem 'i18n', '< 1.5.2'"
41-
gsub_file "Gemfile", /.*nio4r.*/, "gem 'nio4r', '< 2.4.0'"
42-
gsub_file "Gemfile", /.*public_suffix.*/, "gem 'public_suffix', '< 4.0.0'"
43-
gsub_file "Gemfile", /.*rack.*/, "gem 'rack', '< 2.2.0', '!= 2.1.0'"
44-
gsub_file "Gemfile", /.*xpath.*/, "gem 'xpath', '< 3.2.0'"
37+
if Rails::VERSION::STRING >= '6'
38+
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`
39+
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'"
40+
else
41+
# Similarly, Rails 5.0 only supports '~> 1.3.6'. Rails 5.1-5.2 support '~> 1.3', '>= 1.3.6'
42+
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'"
4543
end
4644

4745
if Rails::VERSION::STRING >= "5.1.0"
48-
if RUBY_VERSION < "2.3"
49-
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.1.0'"
50-
elsif RUBY_VERSION < "2.4"
51-
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'"
52-
elsif RUBY_VERSION < "2.5"
53-
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.32.0'"
54-
end
55-
if Rails::VERSION::STRING >= "5.2.0"
56-
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'"
57-
else
58-
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
59-
end
46+
# webdrivers 4 up until 4.3.0 don't specify `required_ruby_version`, but contain
47+
# Ruby 2.2-incompatible syntax (safe navigation).
48+
# That basically means we use pre-4.0 for Ruby 2.2, and 4.3+ for newer Rubies.
49+
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'"
6050
end
6151

6252
if Rails::VERSION::STRING >= '5.2.0' && Rails::VERSION::STRING < '6'
6353
copy_file sqlite_initializer, 'config/initializers/sqlite3_fix.rb'
6454
end
6555

66-
# Nokogiri version is pinned in rspec-rails' Gemfile since it tend to cause installation problems
67-
# on Travis CI, so we pin nokogiri in this example app also.
68-
if RUBY_ENGINE != "jruby"
69-
append_to_file 'Gemfile', "gem 'nokogiri', '#{Nokogiri::VERSION}'\n"
70-
else
71-
gsub_file "Gemfile", /.*jdbc.*/, ""
56+
if RUBY_ENGINE == "jruby"
57+
gsub_file "Gemfile", /.*jdbc.*/, ''
7258
end
7359

7460
# Use our version of RSpec and Rails

0 commit comments

Comments
 (0)