Skip to content

Commit e315e39

Browse files
committed
Prune code supporting Rails < 7.2
1 parent 5f72d6d commit e315e39

18 files changed

+118
-464
lines changed

Gemfile-rails-dependencies

+2-13
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ when nil, false, ""
3636
if RUBY_VERSION.to_f > 3.1
3737
gem "rails", "~> 8.0.0"
3838
gem 'sqlite3', '~> 2.0', platforms: [:ruby]
39-
elsif RUBY_VERSION.to_f > 3.0
40-
gem "rails", "~> 7.2.0"
41-
gem 'sqlite3', '~> 1.7', platforms: [:ruby]
4239
else
43-
gem "rails", "~> 7.1.0"
40+
gem "rails", "~> 7.2.0"
4441
gem 'sqlite3', '~> 1.7', platforms: [:ruby]
4542
end
4643

@@ -49,17 +46,9 @@ when nil, false, ""
4946
else
5047
version_number = version.split(' ').last
5148

52-
gem 'concurrent-ruby', '1.3.4' if version_number < '7.1'
53-
5449
gem "rails", version
5550
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
5651

57-
# This version number reflects our build version not our actual version,
58-
# this will be fixed in 7.1.4 and should be removed then.
59-
if version_number == '7.1.0'
60-
gem 'selenium-webdriver', '< 4.20.0', require: false
61-
else
62-
gem 'selenium-webdriver', require: false
63-
end
52+
gem 'selenium-webdriver', require: false
6453
add_sqlite3_gem_dependency(version_number)
6554
end

example_app_generator/generate_app.rb

+2-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
'ci_retry_bundle_install.sh'
1212
)
1313
function_script_file = File.join(rspec_rails_repo_path, 'script/functions.sh')
14-
capybara_backport_path = File.join(rspec_rails_repo_path, 'example_app_generator/spec/support/capybara.rb')
1514

1615
in_root do
1716
prepend_to_file "Rakefile", "require 'active_support/all'"
@@ -29,10 +28,8 @@
2928

3029
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
3130

32-
# sqlite3 is an optional, unspecified, dependency of which Rails 6.0 only supports `~> 1.4`, Ruby 2.7 only supports < 1.7 and Rails 8.0 only supports `~> 2.0`
33-
if RUBY_VERSION.to_f < 3
34-
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4', '< 1.7'"
35-
elsif Rails::VERSION::STRING > '8'
31+
# sqlite3 is an optional, unspecified, dependency of which Rails 8.0 only supports `~> 2.0`
32+
if Rails::VERSION::STRING > '8'
3633
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 2.0'"
3734
else
3835
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.7'"
@@ -66,13 +63,4 @@
6663
'REPLACE_BUNDLE_PATH',
6764
bundle_install_path
6865
chmod 'ci_retry_bundle_install.sh', 0755
69-
70-
copy_file capybara_backport_path, 'spec/support/capybara.rb'
71-
72-
if Rails::VERSION::STRING < '7.2'
73-
create_file 'app/assets/config/manifest.js' do
74-
"//= link application.css"
75-
end
76-
create_file 'app/assets/stylesheets/application.css'
77-
end
7866
end

example_app_generator/spec/support/capybara.rb

-51
This file was deleted.

example_app_generator/spec/support/default_preview_path

+2-12
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,11 @@ require_file_stub 'config/environment' do
4343
# Don't care if the mailer can't send.
4444
config.action_mailer.raise_delivery_errors = false unless ENV['NO_ACTION_MAILER']
4545
if ENV['CUSTOM_PREVIEW_PATH']
46-
if Rails::VERSION::STRING.to_f >= 7.1
47-
config.action_mailer.preview_paths = [ENV['CUSTOM_PREVIEW_PATH']]
48-
else
49-
config.action_mailer.preview_path = ENV['CUSTOM_PREVIEW_PATH']
50-
end
46+
config.action_mailer.preview_paths = [ENV['CUSTOM_PREVIEW_PATH']]
5147
end
5248
if ENV['SHOW_PREVIEWS']
5349
config.action_mailer.show_previews = (ENV['SHOW_PREVIEWS'] == 'true')
5450
end
55-
56-
config.active_record.legacy_connection_handling = false if Rails::VERSION::STRING.start_with?('7.0')
5751
end
5852
end
5953

@@ -68,11 +62,7 @@ exit(0) if ENV['NO_ACTION_MAILER']
6862
if ENV['DEFAULT_URL']
6963
puts ActionMailer::Base.default_url_options[:host]
7064
elsif defined?(::ActionMailer::Preview)
71-
if Rails::VERSION::STRING.to_f >= 7.1
72-
puts Rails.application.config.action_mailer.preview_paths
73-
else
74-
puts Rails.application.config.action_mailer.preview_path
75-
end
65+
puts Rails.application.config.action_mailer.preview_paths
7666
end
7767

7868
# This will force the loading of ActionMailer settings to ensure we do not

example_app_generator/spec/verify_mailer_preview_path_spec.rb

+11-20
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,17 @@ def capture_exec(*ops)
4040
CaptureExec.new(out, $?.exitstatus)
4141
end
4242

43-
if Rails::VERSION::STRING.to_f >= 7.1
44-
let(:expected_custom_path) { "/custom/path\n#{::Rails.root}/test/mailers/previews" }
45-
let(:expected_rspec_path) { "#{::Rails.root}/spec/mailers/previews\n#{::Rails.root}/test/mailers/previews" }
46-
47-
def have_no_preview(opts = {})
48-
expected_io =
49-
if opts[:actually_blank]
50-
be_blank
51-
else
52-
"#{::Rails.root}/test/mailers/previews"
53-
end
54-
have_attributes(io: expected_io, exit_status: 0)
55-
end
56-
else
57-
let(:expected_custom_path) { '/custom/path' }
58-
let(:expected_rspec_path) { "#{::Rails.root}/spec/mailers/previews" }
59-
60-
def have_no_preview(_opts = {})
61-
have_attributes(io: be_blank, exit_status: 0)
62-
end
43+
let(:expected_custom_path) { "/custom/path\n#{::Rails.root}/test/mailers/previews" }
44+
let(:expected_rspec_path) { "#{::Rails.root}/spec/mailers/previews\n#{::Rails.root}/test/mailers/previews" }
45+
46+
def have_no_preview(opts = {})
47+
expected_io =
48+
if opts[:actually_blank]
49+
be_blank
50+
else
51+
"#{::Rails.root}/test/mailers/previews"
52+
end
53+
have_attributes(io: expected_io, exit_status: 0)
6354
end
6455

6556
let(:exec_script) {

features/support/env.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def with_unbundled_env
5959
# We want fresh `example_app` project with empty `spec` dir except helpers.
6060
# FileUtils.cp_r on Ruby 1.9.2 doesn't preserve permissions.
6161
system('cp', '-r', example_app_dir, aruba_dir)
62-
helpers = %w[spec/spec_helper.rb spec/rails_helper.rb spec/support/capybara.rb]
62+
helpers = %w[spec/spec_helper.rb spec/rails_helper.rb]
6363
directories = []
6464

6565
Dir["#{aruba_dir}/spec/**/*"].each do |path|

lib/generators/rspec/install/templates/spec/rails_helper.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@
4141
RSpec.configure do |config|
4242
<% if RSpec::Rails::FeatureCheck.has_active_record? -%>
4343
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
44-
<% if ::Rails::VERSION::STRING < "7.1.0" -%>
45-
config.fixture_path = Rails.root.join('spec/fixtures')
46-
<% else -%>
4744
config.fixture_paths = [
4845
Rails.root.join('spec/fixtures')
4946
]
50-
<% end -%>
5147
5248
# If you're not using ActiveRecord, or you'd prefer not to run each of your
5349
# examples within a transaction, remove the following line or assign false
@@ -65,7 +61,9 @@
6561
# note if you'd prefer not to run each example within a transaction, you
6662
# should set use_transactional_fixtures to false.
6763
#
68-
# config.fixture_path = Rails.root.join('spec/fixtures')
64+
# config.fixture_paths = [
65+
# Rails.root.join('spec/fixtures')
66+
# ]
6967
# config.use_transactional_fixtures = true
7068
7169
<% end -%>
@@ -77,7 +75,7 @@
7775
# end
7876
#
7977
# The different available types are documented in the features, such as in
80-
# https://rspec.info/features/7-1/rspec-rails
78+
# https://rspec.info/features/8-0/rspec-rails
8179
#
8280
# You can also this infer these behaviours automatically by location, e.g.
8381
# /spec/models would pull in the same behaviour as `type: :model` but this

lib/rspec-rails.rb

+3-11
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,10 @@ def config_preview_path?(options)
6464
end
6565
end
6666

67-
if ::Rails::VERSION::STRING >= "7.1.0"
68-
def config_default_preview_path(options)
69-
return unless options.preview_paths.empty?
67+
def config_default_preview_path(options)
68+
return unless options.preview_paths.empty?
7069

71-
options.preview_paths << "#{::Rails.root}/spec/mailers/previews"
72-
end
73-
else
74-
def config_default_preview_path(options)
75-
return unless options.preview_path.blank?
76-
77-
options.preview_path = "#{::Rails.root}/spec/mailers/previews"
78-
end
70+
options.preview_paths << "#{::Rails.root}/spec/mailers/previews"
7971
end
8072

8173
def supports_action_mailer_previews?(config)

lib/rspec/rails/configuration.rb

+3-67
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# rubocop: disable Metrics/ModuleLength
21
module RSpec
32
module Rails
43
# Fake class to document RSpec Rails configuration options. In practice,
@@ -57,7 +56,7 @@ def self.add_test_type_configurations(config)
5756
end
5857

5958
# @private
60-
def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/AbcSize,Metrics/PerceivedComplexity
59+
def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength
6160
config.backtrace_exclusion_patterns << /vendor\//
6261
config.backtrace_exclusion_patterns << %r{lib/rspec/rails}
6362

@@ -69,12 +68,7 @@ def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength
6968
config.add_setting :use_transactional_fixtures, alias_with: :use_transactional_examples
7069
config.add_setting :use_instantiated_fixtures
7170
config.add_setting :global_fixtures
72-
73-
if ::Rails::VERSION::STRING < "7.1.0"
74-
config.add_setting :fixture_path
75-
else
76-
config.add_setting :fixture_paths
77-
end
71+
config.add_setting :fixture_paths
7872

7973
config.include RSpec::Rails::FixtureSupport, :use_fixtures
8074

@@ -90,7 +84,7 @@ def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength
9084
config.add_setting :file_fixture_path, default: 'spec/fixtures/files'
9185
config.include RSpec::Rails::FileFixtureSupport
9286

93-
# Add support for fixture_path on fixture_file_upload
87+
# Add support for fixture_paths on fixture_file_upload
9488
config.include RSpec::Rails::FixtureFileUploadSupport
9589

9690
# This allows us to expose `render_views` as a config option even though it
@@ -114,40 +108,6 @@ def render_views?
114108
rendering_views?
115109
end
116110

117-
undef :rendering_views? if respond_to?(:rendering_views?)
118-
def rendering_views?
119-
!!rendering_views
120-
end
121-
122-
# Define boolean predicates rather than relying on rspec-core due
123-
# to the bug fix in rspec/rspec-core#2736, note some of these
124-
# predicates are a bit nonsensical, but they exist for backwards
125-
# compatibility, we can tidy these up in `rspec-rails` 5.
126-
undef :fixture_path? if respond_to?(:fixture_path?)
127-
def fixture_path?
128-
!!fixture_path
129-
end
130-
131-
undef :global_fixtures? if respond_to?(:global_fixtures?)
132-
def global_fixtures?
133-
!!global_fixtures
134-
end
135-
136-
undef :infer_base_class_for_anonymous_controllers? if respond_to?(:infer_base_class_for_anonymous_controllers?)
137-
def infer_base_class_for_anonymous_controllers?
138-
!!infer_base_class_for_anonymous_controllers
139-
end
140-
141-
undef :use_instantiated_fixtures? if respond_to?(:use_instantiated_fixtures?)
142-
def use_instantiated_fixtures?
143-
!!use_instantiated_fixtures
144-
end
145-
146-
undef :use_transactional_fixtures? if respond_to?(:use_transactional_fixtures?)
147-
def use_transactional_fixtures?
148-
!!use_transactional_fixtures
149-
end
150-
151111
def infer_spec_type_from_file_location!
152112
DIRECTORY_MAPPINGS.each do |type, dir_parts|
153113
escaped_path = Regexp.compile(dir_parts.join('[\\\/]') + '[\\\/]')
@@ -163,29 +123,6 @@ def filter_rails_from_backtrace!
163123
filter_gems_from_backtrace "activemodel", "activerecord",
164124
"activesupport", "activejob"
165125
end
166-
167-
# @deprecated TestFixtures#fixture_path is deprecated and will be removed in Rails 7.2
168-
if ::Rails::VERSION::STRING >= "7.1.0"
169-
def fixture_path
170-
RSpec.deprecate(
171-
"config.fixture_path",
172-
replacement: "config.fixture_paths",
173-
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array." \
174-
"You should migrate to plural:"
175-
)
176-
fixture_paths&.first
177-
end
178-
179-
def fixture_path=(path)
180-
RSpec.deprecate(
181-
"config.fixture_path = #{path.inspect}",
182-
replacement: "config.fixture_paths = [#{path.inspect}]",
183-
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array." \
184-
"You should migrate to plural:"
185-
)
186-
self.fixture_paths = Array(path)
187-
end
188-
end
189126
end
190127

191128
add_test_type_configurations(config)
@@ -219,4 +156,3 @@ def fixture_path=(path)
219156
initialize_configuration RSpec.configuration
220157
end
221158
end
222-
# rubocop: enable Metrics/ModuleLength

0 commit comments

Comments
 (0)