Skip to content

Commit e1bb46f

Browse files
committed
Add back Ruby 2.2 support for Rails 5
1 parent f470bbb commit e1bb46f

File tree

6 files changed

+45
-8
lines changed

6 files changed

+45
-8
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ matrix:
7777
env: RAILS_VERSION='~> 5.2.0'
7878
- rvm: 2.3.8
7979
env: RAILS_VERSION='~> 5.2.0'
80+
- rvm: 2.2.10
81+
env: RAILS_VERSION='~> 5.2.0'
82+
allow_failure: true
83+
- rvm: 2.2.10
84+
env: RAILS_VERSION='5-2-stable'
8085

8186
# Rails 5.1 Builds >= 2.2.2
8287
- rvm: 2.6.6
@@ -87,6 +92,8 @@ matrix:
8792
env: RAILS_VERSION='~> 5.1.0'
8893
- rvm: 2.3.8
8994
env: RAILS_VERSION='~> 5.1.0'
95+
- rvm: 2.2.10
96+
env: RAILS_VERSION='~> 5.1.0'
9097

9198
# Rails 5.0 Builds >= 2.2.2
9299
- rvm: 2.6.6
@@ -97,5 +104,7 @@ matrix:
97104
env: RAILS_VERSION='~> 5.0.0'
98105
- rvm: 2.3.8
99106
env: RAILS_VERSION='~> 5.0.0'
107+
- rvm: 2.2.10
108+
env: RAILS_VERSION='~> 5.0.0'
100109

101110
fast_finish: true

Gemfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ case RAILS_VERSION
2222
when /master/
2323
MAJOR = 6
2424
MINOR = 0
25+
when /5-2-stable/
26+
MAJOR = 5
27+
MINOR = 2
2528
when /stable/
2629
MAJOR = 6
2730
MINOR = 0
@@ -46,7 +49,11 @@ gem 'rake', '~> 12'
4649

4750
gem 'mime-types', "~> 3"
4851

49-
gem 'capybara', '>= 2.13', '< 4.0', require: false
52+
if RUBY_VERSION.to_f == 2.2
53+
gem 'capybara', '~> 3.1.0'
54+
else
55+
gem 'capybara', '>= 2.13', '< 4.0', require: false
56+
end
5057

5158
if MAJOR < 6
5259
gem 'nokogiri', '1.9.1'
@@ -56,7 +63,9 @@ end
5663

5764
gem "rubyzip", '~> 1.2'
5865

59-
gem 'rubocop', '~> 0.80.1'
66+
if RUBY_VERSION.to_f >= 2.3
67+
gem 'rubocop', '~> 0.80.1'
68+
end
6069

6170
custom_gemfile = File.expand_path('Gemfile-custom', __dir__)
6271
eval_gemfile custom_gemfile if File.exist?(custom_gemfile)

example_app_generator/generate_app.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
end
3737

3838
if Rails::VERSION::STRING >= "5.1.0"
39-
if RUBY_VERSION < "2.4"
39+
if RUBY_VERSION < "2.3"
40+
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.1.0'"
41+
elsif RUBY_VERSION < "2.4"
4042
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'"
4143
end
4244
if Rails::VERSION::STRING >= "5.2.0"

lib/rspec/rails/example/mailer_example_group.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module MailerExampleGroup
2121

2222
included do
2323
include ::Rails.application.routes.url_helpers
24-
options = ::Rails.configuration.action_mailer.default_url_options
25-
options&.each { |key, value| default_url_options[key] = value }
24+
options = ::Rails.configuration.action_mailer.default_url_options || {}
25+
options.each { |key, value| default_url_options[key] = value }
2626
end
2727

2828
# Class-level DSL for mailer specs.

script/update_rubygems_and_install_bundler

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@
55
set -e
66
source script/functions.sh
77

8-
gem update --no-document --system
9-
gem install --no-document bundler
8+
if is_ruby_23_plus; then
9+
gem update --no-document --system
10+
gem install --no-document bundler
11+
else
12+
echo "Warning installing older versions of Rubygems / Bundler"
13+
gem update --system '2.7.8'
14+
gem install bundler -v '1.17.3'
15+
fi

spec/rspec/rails/example/view_example_group_spec.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,18 @@ def _view; end # Stub method
236236
expect(view_spec.view).to eq(view)
237237
end
238238

239-
it 'is accessible to hooks' do
239+
if RUBY_VERSION <= "2.3.0" && ENV["RAILS_VERSION"] !=~ /stable/ && ::Rails.version.to_f == 5.2
240+
pending_only_on_ruby_22_rails_52 = """
241+
Rails 5.2.4.2 has a syntax error in ActionDispatch::Request::Session.
242+
(A &. usage which does not work in 2.2.10)
243+
It has been fixed but not released, this spec will not pass until that
244+
has been released.
245+
"""
246+
else
247+
pending_only_on_ruby_22_rails_52 = false
248+
end
249+
250+
it 'is accessible to hooks', pending: pending_only_on_ruby_22_rails_52 do
240251
with_isolated_config do
241252
run_count = 0
242253
RSpec.configuration.before(:each, type: :view) do

0 commit comments

Comments
 (0)