Skip to content

Commit d52a135

Browse files
committed
Remove code related to Rails < 5.0
1 parent 930c141 commit d52a135

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+71
-1103
lines changed

.rubocop.yml

-12
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,6 @@ Style/ParallelAssignment:
246246
Style/ParenthesesAroundCondition:
247247
Enabled: false
248248

249-
Style/PerlBackrefs:
250-
Exclude:
251-
# We probably can refactor the backref out, but for now excluding it since
252-
# we can't use named matches in 1.8.7
253-
- lib/generators/rspec/scaffold/scaffold_generator.rb
254-
255249
Style/PercentLiteralDelimiters:
256250
PreferredDelimiters:
257251
'%': () # double-quoted string
@@ -264,12 +258,6 @@ Style/PercentLiteralDelimiters:
264258
'%W': '[]' # array of double-quoted strings
265259
'%x': () # a shell command as a string
266260

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

.rubocop_todo.yml

+11
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ Style/EachWithObject:
2121
# the new lambda syntax was not supported in ruby 1.8.7
2222
Style/Lambda:
2323
Enabled: false
24+
25+
# we couldn't use named matches in ruby 1.8.7
26+
Style/PerlBackrefs:
27+
Exclude:
28+
- lib/generators/rspec/scaffold/scaffold_generator.rb
29+
30+
# On 1.8 `proc` was `lambda`, so we used `Proc.new` to ensure we got real procs
31+
# on all supported versions.
32+
# http://batsov.com/articles/2014/02/04/the-elements-of-style-in-ruby-number-12-proc-vs-proc-dot-new/
33+
Style/Proc:
34+
Enabled: false

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ bundler_args: "--binstubs --path ../bundle --retry=3 --jobs=3"
2222

2323
before_install:
2424
- script/update_rubygems_and_install_bundler
25-
- script/downgrade_bundler_on_old_rails
2625
- script/clone_all_rspec_repos
2726

2827
before_script:
29-
# Rails 4.x complains with a bundler rails binstub in PROJECT_ROOT/bin/
28+
# Rails 4+ complains with a bundler rails binstub in PROJECT_ROOT/bin/
3029
- rm -f bin/rails
3130
- bundle exec rails --version
3231

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ gem 'mime-types', "~> 3"
5151
gem 'capybara', '~> 2.13', require: false
5252

5353
if MAJOR < 6
54-
gem 'nokogiri', '1.8.5'
54+
gem 'nokogiri', '1.9.1'
5555
else
5656
gem 'nokogiri', '>= 1.10.4'
5757
end

Gemfile-custom.sample

-7
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,5 @@ group :development do
88
platform :mri do
99
gem 'rb-fsevent', '~> 0.9.0'
1010
gem 'ruby-prof', '~> 0.10.0'
11-
12-
case RUBY_VERSION
13-
when /^1.8/
14-
gem 'ruby-debug'
15-
when /^1.9/
16-
gem 'debugger'
17-
end
1811
end
1912
end

Gemfile-rails-dependencies

+2-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ when /master/
1414
gem 'puma', "3.12.1"
1515
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby]
1616
when /stable$/
17-
gem_list = %w[rails railties actionmailer actionpack activerecord activesupport]
18-
gem_list << 'activejob' if version >= '4-2-stable'
19-
gem_list << 'actionview' if version >= '4-2-stable'
17+
gem_list = %w[rails railties actionmailer actionpack activerecord activesupport activejob actionview]
2018
gem 'puma', "3.12.1" if version > '5-0-stable'
2119
gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby]
2220

@@ -29,9 +27,7 @@ when nil, false, ""
2927
else
3028
gem "rails", version
3129

32-
if version >= '5-1-stable' && RUBY_VERSION >= "2.3"
33-
gem "puma"
34-
end
30+
gem "puma" if version >= '5-1-stable'
3531

3632
if version.gsub(/[^\d\.]/,'').to_f >= 6.0
3733
gem "activerecord-jdbcsqlite3-adapter", "~> 60.0.rc1", platforms: [:jruby]

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ $ bundle exec rspec --help
119119
```
120120

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

125124
```sh
126125
$ bundle binstubs rspec-core

Rakefile

+6-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require 'rspec/core/rake_task'
1212
require 'cucumber/rake/task'
1313

1414
def rails_template_command
15-
require "rails"
15+
require "rails/version"
1616
if Rails.version.to_f >= 5.0
1717
"app:template"
1818
else
@@ -27,7 +27,7 @@ RSpec::Core::RakeTask.new(:spec) do |t|
2727
end
2828

2929
Cucumber::Rake::Task.new(:cucumber) do |t|
30-
version = ENV.fetch("RAILS_VERSION", "~> 4.2.0")[/\d[\.-]\d/]
30+
version = ENV.fetch("RAILS_VERSION", "~> 5.2.0")[/\d[\.-]\d/]
3131
if version == "master" || version.nil?
3232
version = Float::INFINITY
3333
end
@@ -37,19 +37,10 @@ Cucumber::Rake::Task.new(:cucumber) do |t|
3737
tags << "~@rails_pre_5.1"
3838
end
3939

40-
if version.to_f >= 5.0
41-
tags << "~@rails_pre_5"
42-
end
43-
4440
if version.to_f == 5.0
4541
tags << "~@system_test"
4642
end
4743

48-
if tags.empty?
49-
tags << "~@rails_post_5"
50-
tags << "~@system_test"
51-
end
52-
5344
if version.to_f >= 6.0
5445
tags << "~@rails_pre_6"
5546
end
@@ -69,13 +60,13 @@ namespace :generate do
6960
unless File.directory?('./tmp/example_app')
7061
bindir = File.expand_path("bin")
7162

72-
# Rails 4 cannot use a `rails` binstub generated by Bundler
63+
# Rails 4+ cannot use a `rails` binstub generated by Bundler
7364
sh "rm -f #{bindir}/rails"
7465
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"
7566

7667
in_example_app do
7768
sh "./travis_retry_bundle_install.sh 2>&1"
78-
# Rails 4 cannot use a `rails` binstub generated by Bundler
69+
# Rails 4+ cannot use a `rails` binstub generated by Bundler
7970
sh "bundle binstubs bundler rspec-core rake --force"
8071
sh "bundle binstubs railties" unless File.exist?("bin/rails")
8172

@@ -192,13 +183,13 @@ namespace :no_active_record do
192183
unless File.directory?(example_app_dir)
193184
bindir = File.expand_path("bin")
194185

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

199190
in_example_app(:app_dir => example_app_dir) do
200191
sh "./travis_retry_bundle_install.sh 2>&1"
201-
# Rails 4 cannot use a `rails` binstub generated by Bundler
192+
# Rails 4+ cannot use a `rails` binstub generated by Bundler
202193
sh "bundle binstubs bundler rspec-core rake --force"
203194
sh "bundle binstubs railties" unless File.exist?("bin/rails")
204195

appveyor.yml

-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ test_script:
3333

3434
environment:
3535
matrix:
36-
- ruby_version: 200
37-
- ruby_version: 21
38-
- ruby_version: 22
3936
- ruby_version: 23-x64
4037
- ruby_version: 24-x64
4138
- ruby_version: 25-x64

example_app_generator/generate_action_mailer_specs.rb

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
require 'active_support'
22
require 'active_support/core_ext/module'
33

4-
# We need to copy this method from Thor for older Rails versions
5-
def comment_lines(path, flag, *args)
6-
flag = flag.respond_to?(:source) ? flag.source : flag
7-
gsub_file(path, /^(\s*)([^#|\n]*#{flag})/, '\1# \2', *args)
8-
end
9-
104
using_source_path(File.expand_path('..', __FILE__)) do
115
# Comment out the default mailer stuff
126
comment_lines 'config/environments/development.rb', /action_mailer/

example_app_generator/generate_app.rb

+2-19
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
gsub_file "Gemfile", /.*puma.*/, ""
2626
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'"
2727
gsub_file "Gemfile", /.*bootsnap.*/, ""
28-
if RUBY_VERSION < '2.2.2'
29-
gsub_file "Gemfile", /.*rdoc.*/, "gem 'rdoc', '< 6'"
30-
end
3128

3229
if Rails::VERSION::STRING >= '5.0.0'
3330
append_to_file('Gemfile', "gem 'rails-controller-testing'\n")
@@ -42,7 +39,7 @@
4239
if RUBY_VERSION < "2.4"
4340
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'"
4441
end
45-
if Rails::VERSION::STRING >= "5.2.0" && RUBY_VERSION < '2.3.0'
42+
if Rails::VERSION::STRING >= "5.2.0"
4643
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'"
4744
else
4845
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
@@ -63,21 +60,7 @@
6360

6461
# Use our version of RSpec and Rails
6562
append_to_file 'Gemfile', <<-EOT.gsub(/^ +\|/, '')
66-
|# Rack::Cache 1.3.0 requires Ruby >= 2.0.0
67-
|gem 'rack-cache', '< 1.3.0' if RUBY_VERSION < '2.0.0'
68-
|
69-
|if RUBY_VERSION >= '2.0.0'
70-
| gem 'rake', '>= 10.0.0'
71-
|elsif RUBY_VERSION >= '1.9.3'
72-
| gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later
73-
|else
74-
| gem 'rake', '< 11.0.0' # rake 11 requires Ruby 1.9.3 or later
75-
|end
76-
|
77-
|# Version 3 of mime-types 3 requires Ruby 2.0
78-
|if RUBY_VERSION < '2.0.0'
79-
| gem 'mime-types', '< 3'
80-
|end
63+
|gem 'rake', '>= 10.0.0'
8164
|
8265
|gem 'rspec-rails',
8366
| :path => '#{rspec_rails_repo_path}',

example_app_generator/no_active_record/app/models/in_memory/model.rb

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Rails 4.0.x seems to be the only version that does not autoload `ActiveModel`
2-
require 'active_model'
3-
41
raise "ActiveRecord is defined but should not be!" if defined?(::ActiveRecord)
52

63
module InMemory

example_app_generator/spec/support/default_preview_path

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ require_file_stub 'config/environment' do
4747
end
4848
end
4949

50-
I18n.enforce_available_locales = true if I18n.respond_to?(:enforce_available_locales)
50+
I18n.enforce_available_locales = true
5151
end
5252

5353
# Initialize the Rails application.

example_app_generator/spec/verify_mailer_preview_path_spec.rb

+3-72
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ def as_commandline(ops)
1616
end
1717

1818
def capture_exec(*ops)
19-
io = if RUBY_VERSION.to_f < 1.9
20-
IO.popen(as_commandline(ops))
21-
else
22-
ops << { :err => [:child, :out] }
23-
IO.popen(ops)
24-
end
19+
ops << { :err => [:child, :out] }
20+
io = IO.popen(ops)
2521
# Necessary to ignore warnings from Rails code base
2622
out = io.readlines.
2723
reject { |line| line =~ /warning: circular argument reference/ }.
@@ -39,7 +35,7 @@ def have_no_preview
3935
File.expand_path(File.join(__FILE__, '../support/default_preview_path'))
4036
}
4137

42-
if RSpec::Rails::FeatureCheck.has_action_mailer_show_preview?
38+
if RSpec::Rails::FeatureCheck.has_action_mailer_preview?
4339
context 'in the development environment' do
4440
let(:custom_env) { { 'RAILS_ENV' => rails_env } }
4541
let(:rails_env) { 'development' }
@@ -111,71 +107,6 @@ def have_no_preview
111107
).to eq('test-host')
112108
end
113109

114-
it 'handles action mailer not being available' do
115-
expect(
116-
capture_exec(
117-
custom_env.merge('NO_ACTION_MAILER' => 'true'),
118-
exec_script
119-
)
120-
).to have_no_preview
121-
end
122-
end
123-
elsif RSpec::Rails::FeatureCheck.has_action_mailer_preview?
124-
context 'in the development environment', 'without `show_previews`' do
125-
let(:custom_env) { { 'RAILS_ENV' => rails_env } }
126-
let(:rails_env) { 'development' }
127-
128-
it 'sets the preview path to the default rspec path' do
129-
expect(capture_exec(custom_env, exec_script)).to eq(
130-
"#{::Rails.root}/spec/mailers/previews"
131-
)
132-
end
133-
134-
it 'respects a custom `preview_path`' do
135-
expect(
136-
capture_exec(
137-
custom_env.merge('CUSTOM_PREVIEW_PATH' => '/custom/path'),
138-
exec_script
139-
)
140-
).to eq('/custom/path')
141-
end
142-
143-
it 'allows initializers to set options' do
144-
expect(
145-
capture_exec(
146-
custom_env.merge('DEFAULT_URL' => 'test-host'),
147-
exec_script
148-
)
149-
).to eq('test-host')
150-
end
151-
152-
it 'handles action mailer not being available' do
153-
expect(
154-
capture_exec(
155-
custom_env.merge('NO_ACTION_MAILER' => 'true'),
156-
exec_script
157-
)
158-
).to have_no_preview
159-
end
160-
end
161-
162-
context 'in a non-development environment', 'without `show_previews`' do
163-
let(:custom_env) { { 'RAILS_ENV' => rails_env } }
164-
let(:rails_env) { 'test' }
165-
166-
it 'does not set the preview path by default' do
167-
expect(capture_exec(custom_env, exec_script)).to have_no_preview
168-
end
169-
170-
it 'respects a custom `preview_path`' do
171-
expect(
172-
capture_exec(
173-
custom_env.merge('CUSTOM_PREVIEW_PATH' => '/custom/path'),
174-
exec_script
175-
)
176-
).to eq('/custom/path')
177-
end
178-
179110
it 'handles action mailer not being available' do
180111
expect(
181112
capture_exec(

example_app_generator/travis_retry_bundle_install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
source FUNCTIONS_SCRIPT_FILE
55

66
echo "Starting bundle install using shared bundle path"
7-
if is_mri_192_plus; then
7+
if is_mri; then
88
travis_retry eval "RUBYOPT=$RUBYOPT:' --enable rubygems' bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"
99
else
1010
travis_retry eval "bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3"

0 commit comments

Comments
 (0)