Skip to content

Commit a855b26

Browse files
committed
Apply gem version constraints for older Rubies
Sprockets 4.0 depend on Ruby >= 2.5 https://rubygems.org/gems/sprockets/versions/4.0.0 This results in build failures (https://travis-ci.org/github/rspec/rspec-rails/jobs/713253057): Installing sprockets 4.0.2 Gem::RuntimeRequirementNotMetError: sprockets requires Ruby version >= 2.5.0. The current ruby version is 2.4.10.364. Surprisingly, Ruby 2.3.8 and Ruby 2.2.10 builds don't fail, and install sprockets 3.7.2. Other failures follow: Gem::RuntimeRequirementNotMetError: capybara requires Ruby version >= 2.5.0. The current ruby version is 2.4.10.364. An error occurred while installing capybara (3.33.0), and Bundler cannot continue. Make sure that `gem install capybara -v '3.33.0' --source 'https://rubygems.org/'` succeeds before bundling. Gem::RuntimeRequirementNotMetError: childprocess requires Ruby version >= 2.3.0. The current ruby version is 2.2.0. An error occurred while installing childprocess (3.0.0), and Bundler cannot continue. Make sure that `gem install childprocess -v '3.0.0' --source Gem::RuntimeRequirementNotMetError: nio4r requires Ruby version >= 2.3. The current ruby version is 2.2.0. An error occurred while installing nio4r (2.5.2), and Bundler cannot continue. Make sure that `gem install nio4r -v '2.5.2' --source 'https://rubygems.org/'` succeeds before bundling. Gem::RuntimeRequirementNotMetError: rack requires Ruby version >= 2.3.0. The current ruby version is 2.2.0. An error occurred while installing rack (2.2.3), and Bundler cannot continue. Make sure that `gem install rack -v '2.2.3' --source 'https://rubygems.org/'` succeeds before bundling. Gem::RuntimeRequirementNotMetError: i18n requires Ruby version >= 2.3.0. The current ruby version is 2.2.0. An error occurred while installing i18n (1.8.5), and Bundler cannot continue. Make sure that `gem install i18n -v '1.8.5' --source 'https://rubygems.org/'` succeeds before bundling. We always generate example apps for >= 5.0.0 (4.2 is not in the matrix), hence the removal of a condition. This is a forgotten forward-port from https://github.com/rspec/rspec-rails/pull/2360/files#diff-8c3955be04b733dbd31e54e50844fb84R31
1 parent 60dc9c4 commit a855b26

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

Gemfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ gem 'rake', '~> 12'
4949

5050
gem 'mime-types', "~> 3"
5151

52-
if RUBY_VERSION.to_f == 2.2
52+
if RUBY_VERSION.to_f < 2.3
5353
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'
5458
else
5559
gem 'capybara', '>= 2.13', '< 4.0', require: false
5660
end

Gemfile-rails-dependencies

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ when /stable$/
1818
gem_list = %w[rails railties actionmailer actionpack activerecord activesupport activejob actionview]
1919
gem 'puma', "3.12.1" if version > '5-0-stable'
2020
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby]
21+
gem "sprockets", '~> 3.0' if RUBY_VERSION < '2.5'
2122

2223
gem_list.each do |rails_gem|
2324
gem rails_gem, :git => "https://github.com/rails/rails.git", :branch => version
@@ -28,7 +29,7 @@ when nil, false, ""
2829
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
2930
else
3031
gem "rails", version
31-
32+
gem "sprockets", '~> 3.0' if RUBY_VERSION < '2.5'
3233
gem "puma" if version >= '5-1-stable'
3334

3435
if version.gsub(/[^\d\.]/,'').to_f >= 6.0

example_app_generator/generate_app.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,29 @@
2626
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'"
2727
gsub_file "Gemfile", /.*bootsnap.*/, ""
2828

29-
if Rails::VERSION::STRING >= '5.0.0'
30-
append_to_file('Gemfile', "gem 'rails-controller-testing'\n")
31-
end
29+
append_to_file('Gemfile', "gem 'rails-controller-testing'\n")
3230

3331
if Rails::VERSION::STRING >= '6'
3432
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'"
3533
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
3634
end
3735

36+
if RUBY_VERSION < "2.3.0"
37+
gsub_file "Gemfile", /.*childprocess.*/, "gem 'childprocess', '< 2.0.0'"
38+
gsub_file "Gemfile", /.*i18n.*/, "gem 'i18n', '< 1.5.2'"
39+
gsub_file "Gemfile", /.*nio4r.*/, "gem 'nio4r', '< 2.4.0'"
40+
gsub_file "Gemfile", /.*public_suffix.*/, "gem 'public_suffix', '< 4.0.0'"
41+
gsub_file "Gemfile", /.*rack.*/, "gem 'rack', '< 2.2.0', '!= 2.1.0'"
42+
gsub_file "Gemfile", /.*xpath.*/, "gem 'xpath', '< 3.2.0'"
43+
end
44+
3845
if Rails::VERSION::STRING >= "5.1.0"
3946
if RUBY_VERSION < "2.3"
4047
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.1.0'"
4148
elsif RUBY_VERSION < "2.4"
4249
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'"
50+
elsif RUBY_VERSION < "2.5"
51+
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.32.0'"
4352
end
4453
if Rails::VERSION::STRING >= "5.2.0"
4554
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'"

0 commit comments

Comments
 (0)