Skip to content

Commit 8bc3f80

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 8bc3f80

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Gemfile

+5-1
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

+2-1
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

+11
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,22 @@
3535
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
3636
end
3737

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'"
45+
end
46+
3847
if Rails::VERSION::STRING >= "5.1.0"
3948
if RUBY_VERSION < "2.3"
4049
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.1.0'"
4150
elsif RUBY_VERSION < "2.4"
4251
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'"
4354
end
4455
if Rails::VERSION::STRING >= "5.2.0"
4556
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'"

0 commit comments

Comments
 (0)