Skip to content

Commit b9d5676

Browse files
committed
Merge pull request #2791 from rspec/cleanup-rails-6-1
Cleanup for versions 7
1 parent bbf16f9 commit b9d5676

16 files changed

+23
-178
lines changed

Changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Bug Fixes:
55

66
* Remove mutation of Rails constant in favour of public api. (Petrik de Heus, #2789)
77
* Cleanup Rails scaffold for unsupported versions. (Matt Jankowski, #2790)
8+
* Remove deprecated scaffold that was unintentionally included in 7.0.0
9+
(Jon Rowe, #2791)
810

911
### 7.0.0 / 2024-09-02
1012
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.5...v7.0.0)

Gemfile-rails-dependencies

+1-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ def add_sqlite3_gem_dependency
2121
end
2222
end
2323

24-
if RUBY_VERSION.to_f < 2.7
25-
gem 'puma', '< 6.0.0'
26-
else
27-
gem 'puma'
28-
end
24+
gem 'puma'
2925

3026
case version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || ''
3127
when /main/

example_app_generator/generate_app.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
copy_file capybara_backport_path, 'spec/support/capybara.rb'
7171

72-
if Rails::VERSION::STRING > '7' && Rails::VERSION::STRING < '7.2'
72+
if Rails::VERSION::STRING < '7.2'
7373
create_file 'app/assets/config/manifest.js' do
7474
"//= link application.css"
7575
end

example_app_generator/spec/support/default_preview_path

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ require_file_stub 'config/environment' do
3737
module ExampleApp
3838
class Application < Rails::Application
3939
config.eager_load = false
40-
if Rails::VERSION::STRING.to_f >= 7.0
41-
config.active_support.cache_format_version = 7.0
42-
end
40+
config.active_support.cache_format_version = 7.0
4341

4442
# Don't care if the mailer can't send.
4543
config.action_mailer.raise_delivery_errors = false unless ENV['NO_ACTION_MAILER']

example_app_generator/spec/verify_mailer_preview_path_spec.rb

+1-12
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def capture_exec(*ops)
4040

4141
if ENV['RAILS_VERSION'] == 'main' && Rails::VERSION::STRING == "8.0.0.alpha"
4242
before do
43-
skip('This is broken on Rails main but is skipped for green builds of 7.1.x, please fix')
43+
skip('This is broken on Rails main but is skipped for green builds, please fix')
4444
end
4545
end
4646

@@ -139,17 +139,6 @@ def have_no_preview(_opts = {})
139139
)
140140
).to eq('test-host')
141141
end
142-
143-
it 'handles action mailer not being available' do
144-
skip "Rails 7 forces eager loading on CI, loads app/mailers and fails" if Rails::VERSION::STRING.to_f >= 7.0
145-
146-
expect(
147-
capture_exec(
148-
custom_env.merge('NO_ACTION_MAILER' => 'true'),
149-
exec_script
150-
)
151-
).to have_no_preview
152-
end
153142
end
154143
else
155144
context 'in the development environment' do

features/file_fixture.feature

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Feature: Using `file_fixture`
3737
When I run `rspec spec/lib/file_spec.rb`
3838
Then the examples should all pass
3939

40-
@rails_post_7
4140
Scenario: Creating a ActiveStorage::Blob from a file fixture
4241
Given a file named "spec/fixtures/files/sample.txt" with:
4342
"""

features/generator_specs/integration_specs.feature

-21
This file was deleted.

features/support/rails_versions.rb

-15
This file was deleted.

lib/generators/rspec/integration/integration_generator.rb

-29
This file was deleted.

lib/generators/rspec/scaffold/templates/controller_spec.rb

-15
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,10 @@
9090
end
9191
9292
context "with invalid params" do
93-
<% if Rails.version.to_f < 7.0 %>
94-
it "returns a success response (i.e. to display the 'new' template)" do
95-
post :create, params: {<%= singular_table_name %>: invalid_attributes}, session: valid_session
96-
expect(response).to be_successful
97-
end
98-
<% else %>
9993
it "renders a response with 422 status (i.e. to display the 'new' template)" do
10094
post :create, params: {<%= singular_table_name %>: invalid_attributes}, session: valid_session
10195
expect(response).to have_http_status(:unprocessable_entity)
10296
end
103-
<% end %>
10497
end
10598
end
10699
@@ -125,19 +118,11 @@
125118
end
126119
127120
context "with invalid params" do
128-
<% if Rails.version.to_f < 7.0 %>
129-
it "returns a success response (i.e. to display the 'edit' template)" do
130-
<%= file_name %> = <%= class_name %>.create! valid_attributes
131-
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: invalid_attributes}, session: valid_session
132-
expect(response).to be_successful
133-
end
134-
<% else %>
135121
it "renders a response with 422 status (i.e. to display the 'edit' template)" do
136122
<%= file_name %> = <%= class_name %>.create! valid_attributes
137123
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: invalid_attributes}, session: valid_session
138124
expect(response).to have_http_status(:unprocessable_entity)
139125
end
140-
<% end %>
141126
end
142127
end
143128

lib/generators/rspec/scaffold/templates/request_spec.rb

-15
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,10 @@
8383
}.to change(<%= class_name %>, :count).by(0)
8484
end
8585
86-
<% if Rails.version.to_f < 7.0 %>
87-
it "renders a successful response (i.e. to display the 'new' template)" do
88-
post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
89-
expect(response).to be_successful
90-
end
91-
<% else %>
9286
it "renders a response with 422 status (i.e. to display the 'new' template)" do
9387
post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
9488
expect(response).to have_http_status(:unprocessable_entity)
9589
end
96-
<% end %>
9790
end
9891
end
9992
@@ -119,19 +112,11 @@
119112
end
120113
121114
context "with invalid parameters" do
122-
<% if Rails.version.to_f < 7.0 %>
123-
it "renders a successful response (i.e. to display the 'edit' template)" do
124-
<%= file_name %> = <%= class_name %>.create! valid_attributes
125-
patch <%= show_helper %>, params: { <%= singular_table_name %>: invalid_attributes }
126-
expect(response).to be_successful
127-
end
128-
<% else %>
129115
it "renders a response with 422 status (i.e. to display the 'edit' template)" do
130116
<%= file_name %> = <%= class_name %>.create! valid_attributes
131117
patch <%= show_helper %>, params: { <%= singular_table_name %>: invalid_attributes }
132118
expect(response).to have_http_status(:unprocessable_entity)
133119
end
134-
<% end %>
135120
end
136121
end
137122

lib/rspec/rails/example/rails_example_group.rb

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
# suite and ammeter.
33
require 'rspec/rails/matchers'
44

5-
if ::Rails::VERSION::MAJOR >= 7
6-
require 'active_support/current_attributes/test_helper'
7-
require 'active_support/execution_context/test_helper'
8-
end
5+
require 'active_support/current_attributes/test_helper'
6+
require 'active_support/execution_context/test_helper'
97

108
module RSpec
119
module Rails
@@ -17,11 +15,9 @@ module RailsExampleGroup
1715
include RSpec::Rails::MinitestLifecycleAdapter
1816
include RSpec::Rails::MinitestAssertionAdapter
1917
include RSpec::Rails::FixtureSupport
20-
if ::Rails::VERSION::MAJOR >= 7
21-
include RSpec::Rails::TaggedLoggingAdapter
22-
include ActiveSupport::CurrentAttributes::TestHelper
23-
include ActiveSupport::ExecutionContext::TestHelper
24-
end
18+
include RSpec::Rails::TaggedLoggingAdapter
19+
include ActiveSupport::CurrentAttributes::TestHelper
20+
include ActiveSupport::ExecutionContext::TestHelper
2521
end
2622
end
2723
end

script/update_rubygems_and_install_bundler

+1-13
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,10 @@ function is_ruby_3_plus {
1111
fi
1212
}
1313

14-
function is_ruby_26_plus {
15-
if ruby -e "exit(RUBY_VERSION.to_f >= 2.6)"; then
16-
return 0
17-
else
18-
return 1
19-
fi
20-
}
21-
2214
if is_ruby_3_plus; then
2315
gem update --no-document --system
2416
gem install --no-document bundler
25-
elif is_ruby_26_plus; then
17+
else
2618
gem update --no-document --system '3.4.22'
2719
gem install --no-document bundler
28-
else
29-
echo "Warning installing older versions of Rubygems / Bundler"
30-
gem update --system '3.3.26'
31-
gem install bundler -v '2.3.26'
3220
fi

spec/generators/rspec/integration/integration_generator_spec.rb

-14
This file was deleted.

spec/generators/rspec/scaffold/scaffold_generator_spec.rb

+8-22
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,12 @@
2626
.and(contain(/"redirects to the \w+ list"/))
2727
)
2828

29-
if ::Rails::VERSION::STRING >= '7.0.0'
30-
expect(
31-
filename
32-
).to(
33-
contain(/renders a response with 422 status \(i.e. to display the 'new' template\)/)
34-
.and(contain(/renders a response with 422 status \(i.e. to display the 'edit' template\)/))
35-
)
36-
else
37-
expect(
38-
filename
39-
).to(
40-
contain(/renders a successful response \(i.e. to display the 'new' template\)/)
41-
.and(contain(/renders a successful response \(i.e. to display the 'edit' template\)/))
42-
)
43-
end
29+
expect(
30+
filename
31+
).to(
32+
contain(/renders a response with 422 status \(i.e. to display the 'new' template\)/)
33+
.and(contain(/renders a response with 422 status \(i.e. to display the 'edit' template\)/))
34+
)
4435
end
4536
end
4637

@@ -105,13 +96,8 @@
10596
.and(contain(/"redirects to the \w+ list"/))
10697
)
10798

108-
if ::Rails::VERSION::STRING >= '7.0.0'
109-
expect(filename).to contain(/renders a response with 422 status \(i.e. to display the 'new' template\)/)
110-
.and(contain(/renders a response with 422 status \(i.e. to display the 'edit' template\)/))
111-
else
112-
expect(filename).to contain(/returns a success response \(i.e. to display the 'new' template\)/)
113-
.and(contain(/returns a success response \(i.e. to display the 'edit' template\)/))
114-
end
99+
expect(filename).to contain(/renders a response with 422 status \(i.e. to display the 'new' template\)/)
100+
.and(contain(/renders a response with 422 status \(i.e. to display the 'edit' template\)/))
115101

116102
expect(filename).not_to contain(/"renders a JSON response with the new \w+"/)
117103
expect(filename).not_to contain(/"renders a JSON response with errors for the new \w+"/)

spec/rspec/rails/example/rails_example_group_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module RSpec::Rails
22
RSpec.describe RailsExampleGroup do
3-
it 'supports tagged_logger', if: ::Rails::VERSION::MAJOR >= 7 do
3+
it 'supports tagged_logger' do
44
expect(described_class.private_instance_methods).to include(:tagged_logger)
55
end
66

7-
it 'does not leak context between example groups', if: ::Rails::VERSION::MAJOR >= 7 do
7+
it 'does not leak context between example groups' do
88
groups =
99
[
1010
RSpec::Core::ExampleGroup.describe("A group") do
@@ -31,7 +31,7 @@ module RSpec::Rails
3131
expect(results).to all be true
3232
end
3333

34-
it 'will not leak ActiveSupport::CurrentAttributes between examples', if: ::Rails::VERSION::MAJOR >= 7 do
34+
it 'will not leak ActiveSupport::CurrentAttributes between examples' do
3535
group =
3636
RSpec::Core::ExampleGroup.describe("A group", order: :defined) do
3737
include RSpec::Rails::RailsExampleGroup

0 commit comments

Comments
 (0)