Skip to content

[experimental] Drop support of Ruby < 2.2 & Rails < 5.2 #2225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ inherit_from:
- .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.3
Exclude:
# Templates are really ERB which Rubocop does not parse
- 'lib/generators/rspec/*/templates/**/*'
Expand Down Expand Up @@ -246,12 +247,6 @@ Style/ParallelAssignment:
Style/ParenthesesAroundCondition:
Enabled: false

Style/PerlBackrefs:
Exclude:
# We probably can refactor the backref out, but for now excluding it since
# we can't use named matches in 1.8.7
- lib/generators/rspec/scaffold/scaffold_generator.rb

Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': () # double-quoted string
Expand All @@ -264,12 +259,6 @@ Style/PercentLiteralDelimiters:
'%W': '[]' # array of double-quoted strings
'%x': () # a shell command as a string

# On 1.8 `proc` was `lambda`, so we used `Proc.new` to ensure we got real procs
# on all supported versions.
# http://batsov.com/articles/2014/02/04/the-elements-of-style-in-ruby-number-12-proc-vs-proc-dot-new/
Style/Proc:
Enabled: false

Style/RegexpLiteral:
Enabled: false

Expand Down
11 changes: 11 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ Style/HashSyntax:
# the new lambda syntax was not supported in ruby 1.8.7
Style/Lambda:
Enabled: false

# previously we couldn't use named matches in ruby 1.8.7
Style/PerlBackrefs:
Exclude:
- lib/generators/rspec/scaffold/scaffold_generator.rb

# On 1.8 `proc` was `lambda`, so we used `Proc.new` to ensure we got real procs
# on all supported versions.
# http://batsov.com/articles/2014/02/04/the-elements-of-style-in-ruby-number-12-proc-vs-proc-dot-new/
Style/Proc:
Enabled: false
32 changes: 0 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,36 +65,4 @@ matrix:
- rvm: 2.3.8
env: RAILS_VERSION='~> 5.2.0'

# Rails 5.1 Builds >= 2.2.2
- rvm: 2.6.3
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.5.5
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.4.6
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.3.8
env: RAILS_VERSION='~> 5.1.0'

# Rails 5.0 Builds >= 2.2.2
- rvm: 2.6.3
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.5.5
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.4.6
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.3.8
env: RAILS_VERSION='~> 5.0.0'

# Rails 4.2 Builds >= 1.9.3
- rvm: 2.5.5
env: RAILS_VERSION='~> 4.2.0'
- rvm: 2.4.6
env: RAILS_VERSION='~> 4.2.0'
- rvm: 2.4.6
env: RAILS_VERSION='~> 4.2.0'
- rvm: 2.3.8
env: RAILS_VERSION='~> 4.2.0'
- rvm: 2.3.8
env: RAILS_VERSION='~> 4.2.0'

fast_finish: true
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ when /stable/
MINOR = 0
when nil, false, ""
MAJOR = 5
MINOR = 0
MINOR = 2
else
match = /(\d+)(\.|-)(\d+)/.match(RAILS_VERSION)
MAJOR, MINOR = match.captures.map(&:to_i).compact
Expand Down Expand Up @@ -60,7 +60,7 @@ end
gem 'capybara', '~> 2.13', :require => false

if MAJOR < 6
gem 'nokogiri', '1.8.5'
gem 'nokogiri', '1.9.1'
else
gem 'nokogiri', '>= 1.10.4'
end
Expand Down
7 changes: 0 additions & 7 deletions Gemfile-custom.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,5 @@ group :development do
platform :mri do
gem 'rb-fsevent', '~> 0.9.0'
gem 'ruby-prof', '~> 0.10.0'

case RUBY_VERSION
when /^1.8/
gem 'ruby-debug'
when /^1.9/
gem 'debugger'
end
end
end
10 changes: 5 additions & 5 deletions Gemfile-rails-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ when /master/
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby]
when /stable$/
gem_list = %w[rails railties actionmailer actionpack activerecord activesupport]
gem_list << 'activejob' if version >= '4-2-stable'
gem_list << 'actionview' if version >= '4-2-stable'
gem 'puma', "3.12.1" if version > '5-0-stable'
gem_list << 'activejob'
gem_list << 'actionview'
gem 'puma', "3.12.1"
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby]

gem_list.each do |rails_gem|
gem rails_gem, :git => "https://github.com/rails/rails.git", :branch => version
end
when nil, false, ""
gem "rails", "~> 5.0.0"
gem "rails", "~> 5.2.0"
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
else
gem "rails", version

if version >= '5-1-stable' && RUBY_VERSION >= "2.3"
if RUBY_VERSION >= "2.3"
gem "puma"
end

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ $ bundle exec rspec --help
```

**Optional:** If `bundle exec rspec` is too verbose for you,
you can generate a binstub at `bin/rspec`
and use that instead (Rails 4+ only):
you can generate a binstub at `bin/rspec` and use that instead:

```sh
$ bundle binstubs rspec-core
Expand Down
21 changes: 2 additions & 19 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,12 @@ RSpec::Core::RakeTask.new(:spec) do |t|
end

Cucumber::Rake::Task.new(:cucumber) do |t|
version = ENV.fetch("RAILS_VERSION", "~> 4.2.0")[/\d[\.-]\d/]
version = ENV.fetch("RAILS_VERSION", "~> 5.2.0")[/\d[\.-]\d/]
if version == "master" || version.nil?
version = Float::INFINITY
end
tags = []

if version.to_f >= 5.1
tags << "~@rails_pre_5.1"
end

if version.to_f >= 5.0
tags << "~@rails_pre_5"
end

if version.to_f == 5.0
tags << "~@system_test"
end

if tags.empty?
tags << "~@rails_post_5"
tags << "~@system_test"
end

if version.to_f >= 6.0
tags << "~@rails_pre_6"
end
Expand All @@ -69,7 +52,7 @@ namespace :generate do
unless File.directory?('./tmp/example_app')
bindir = File.expand_path("bin")

# Rails 4 cannot use a `rails` binstub generated by Bundler
# Rails 4+ cannot use a `rails` binstub generated by Bundler
sh "rm -f #{bindir}/rails"
sh "bundle exec rails new ./tmp/example_app --no-rc --skip-javascript --skip-bootsnap -skip-sprockets --skip-git --skip-test-unit --skip-listen --skip-bundle --template=example_app_generator/generate_app.rb"

Expand Down
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ test_script:

environment:
matrix:
- ruby_version: 200
- ruby_version: 21
- ruby_version: 22
- ruby_version: 23-x64
- ruby_version: 24-x64
Expand Down
41 changes: 10 additions & 31 deletions example_app_generator/generate_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,24 @@
gsub_file "Gemfile", /.*puma.*/, ""
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'"
gsub_file "Gemfile", /.*bootsnap.*/, ""
if RUBY_VERSION < '2.2.2'
gsub_file "Gemfile", /.*rdoc.*/, "gem 'rdoc', '< 6'"
end

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

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

if Rails::VERSION::STRING >= "5.1.0"
if RUBY_VERSION < "2.4"
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'"
end
if Rails::VERSION::STRING >= "5.2.0" && RUBY_VERSION < '2.3.0'
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'"
else
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
end
if RUBY_VERSION < "2.4"
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'"
end
if RUBY_VERSION < '2.3.0'
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'"
else
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
end

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

Expand All @@ -63,21 +56,7 @@

# Use our version of RSpec and Rails
append_to_file 'Gemfile', <<-EOT.gsub(/^ +\|/, '')
|# Rack::Cache 1.3.0 requires Ruby >= 2.0.0
|gem 'rack-cache', '< 1.3.0' if RUBY_VERSION < '2.0.0'
|
|if RUBY_VERSION >= '2.0.0'
| gem 'rake', '>= 10.0.0'
|elsif RUBY_VERSION >= '1.9.3'
| gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later
|else
| gem 'rake', '< 11.0.0' # rake 11 requires Ruby 1.9.3 or later
|end
|
|# Version 3 of mime-types 3 requires Ruby 2.0
|if RUBY_VERSION < '2.0.0'
| gem 'mime-types', '< 3'
|end
|gem 'rake', '>= 10.0.0'
|
|gem 'rspec-rails',
| :path => '#{rspec_rails_repo_path}',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Rails 4.0.x seems to be the only version that does not autoload `ActiveModel`
require 'active_model'

raise "ActiveRecord is defined but should not be!" if defined?(::ActiveRecord)

module InMemory
Expand Down
8 changes: 2 additions & 6 deletions example_app_generator/spec/verify_mailer_preview_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ def as_commandline(ops)
end

def capture_exec(*ops)
io = if RUBY_VERSION.to_f < 1.9
IO.popen(as_commandline(ops))
else
ops << { :err => [:child, :out] }
IO.popen(ops)
end
ops << { :err => [:child, :out] }
io = IO.popen(ops)
# Necessary to ignore warnings from Rails code base
out = io.readlines.
reject { |line| line =~ /warning: circular argument reference/ }.
Expand Down
2 changes: 1 addition & 1 deletion example_app_generator/travis_retry_bundle_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
source FUNCTIONS_SCRIPT_FILE

echo "Starting bundle install using shared bundle path"
if is_mri_192_plus; then
if is_mri; then
travis_retry eval "RUBYOPT=$RUBYOPT:' --enable rubygems' bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"
else
travis_retry eval "bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"
Expand Down
Loading