Skip to content

Commit 8c870d6

Browse files
authored
Merge pull request #2788 from rspec/7-0-prep
Prepare changes for 7.0.0
2 parents 9c2eb58 + a5d0635 commit 8c870d6

16 files changed

+71
-94
lines changed

.github/workflows/ci.yml

-17
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,6 @@ jobs:
8989
env:
9090
RAILS_VERSION: '~> 7.0.0'
9191

92-
# Rails 6.1 builds >= 2.5
93-
- ruby: 3.1
94-
env:
95-
RAILS_VERSION: '~> 6.1.0'
96-
- ruby: '3.0'
97-
env:
98-
RAILS_VERSION: '~> 6.1.0'
99-
- ruby: 2.7
100-
env:
101-
RAILS_VERSION: '~> 6.1.0'
102-
- ruby: 2.6
103-
env:
104-
RAILS_VERSION: '~> 6.1.0'
105-
- ruby: 2.5
106-
env:
107-
RAILS_VERSION: '~> 6.1.0'
108-
10992
env: ${{ matrix.env }}
11093
steps:
11194
- uses: actions/checkout@v4

CODE_OF_CONDUCT.md

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
<!---
2-
This file was generated on 2023-04-16T20:53:24+01:00 from the rspec-dev repo.
3-
DO NOT modify it by hand as your changes will get lost the next time it is generated.
4-
-->
5-
61
# Contributor Code of Conduct
72

83
For the purpose of building a welcoming, harassment-free community that

Changelog.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### Development
2-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.5...main)
2+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.0.0...main)
33

44
Enhancements:
55

README.md

+27-25
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ detailed explanations of how the application is supposed to behave,
99
expressed in plain English.
1010

1111
According to [RSpec Rails new versioning strategy][] use:
12-
* **[`rspec-rails` 6.x][]** for Rails 6.1 or 7.x.
12+
* **[`rspec-rails` 7.x][]** for Rails 7.x.
13+
* **[`rspec-rails` 6.x][]** for Rails 6.1.
1314
* **[`rspec-rails` 5.x][]** for Rails 5.2 or 6.x.
1415
* **[`rspec-rails` 4.x][]** for Rails from 5.x or 6.x.
1516
* **[`rspec-rails` 3.x][]** for Rails earlier than 5.0.
@@ -26,20 +27,21 @@ According to [RSpec Rails new versioning strategy][] use:
2627
[`rspec-rails` 4.x]: https://github.com/rspec/rspec-rails/tree/4-1-maintenance
2728
[`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-1-maintenance
2829
[`rspec-rails` 6.x]: https://github.com/rspec/rspec-rails/tree/6-1-maintenance
30+
[`rspec-rails` 7.x]: https://github.com/rspec/rspec-rails/tree/7-0-maintenance
2931
[RSpec Rails new versioning strategy]: https://github.com/rspec/rspec-rails/blob/main/rfcs/versioning-strategy.md
3032

3133
## Installation
3234

3335
**IMPORTANT** This README / branch refers to the current development build.
34-
See the [`6-1-maintenance` branch on Github](https://github.com/rspec/rspec-rails/tree/6-1-maintenance) if you want or require the latest stable release.
36+
See the [`7-0-maintenance` branch on Github](https://github.com/rspec/rspec-rails/tree/7-0-maintenance) if you want or require the latest stable release.
3537

3638
1. Add `rspec-rails` to **both** the `:development` and `:test` groups
3739
of your app’s `Gemfile`:
3840

3941
```ruby
4042
# Run against this stable release
4143
group :development, :test do
42-
gem 'rspec-rails', '~> 6.1.0'
44+
gem 'rspec-rails', '~> 7.0.0'
4345
end
4446

4547
# Or, run against the main branch
@@ -86,7 +88,7 @@ read the [`rspec-rails` upgrade notes][] to find out what to watch out for.
8688

8789
Be sure to check the general [RSpec upgrade notes][] as well.
8890

89-
[`rspec-rails` upgrade notes]: https://rspec.info/features/6-0/rspec-rails/upgrade
91+
[`rspec-rails` upgrade notes]: https://rspec.info/features/7-0/rspec-rails/upgrade
9092
[RSpec upgrade notes]: https://rspec.info/upgrading-from-rspec-2/
9193

9294
## Usage
@@ -208,22 +210,22 @@ to test the various parts of a Rails system:
208210
Follow the links above for examples of how each matcher is used.
209211

210212
[the matchers that come standard in RSpec]: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers
211-
[`be_a_new`]: https://rspec.info/features/6-0/rspec-rails/matchers/new-record-matcher
212-
[`render_template`]: https://rspec.info/features/6-0/rspec-rails/matchers/render-template-matcher
213-
[`redirect_to`]: https://rspec.info/features/6-0/rspec-rails/matchers/redirect-to-matcher
214-
[`route_to`]: https://rspec.info/features/6-0/rspec-rails/routing-specs/route-to-matcher
215-
[`be_routable`]: https://rspec.info/features/6-0/rspec-rails/routing-specs/be-routable-matcher
216-
[`have_http_status`]: https://rspec.info/features/6-0/rspec-rails/matchers/have-http-status-matcher
217-
[`match_array`]: https://rspec.info/features/6-0/rspec-rails/matchers/relation-match-array
218-
[`have_been_enqueued`]: https://rspec.info/features/6-0/rspec-rails/matchers/have-been-enqueued-matcher
219-
[`have_enqueued_job`]: https://rspec.info/features/6-0/rspec-rails/matchers/have-enqueued-job-matcher
213+
[`be_a_new`]: https://rspec.info/features/7-0/rspec-rails/matchers/new-record-matcher
214+
[`render_template`]: https://rspec.info/features/7-0/rspec-rails/matchers/render-template-matcher
215+
[`redirect_to`]: https://rspec.info/features/7-0/rspec-rails/matchers/redirect-to-matcher
216+
[`route_to`]: https://rspec.info/features/7-0/rspec-rails/routing-specs/route-to-matcher
217+
[`be_routable`]: https://rspec.info/features/7-0/rspec-rails/routing-specs/be-routable-matcher
218+
[`have_http_status`]: https://rspec.info/features/7-0/rspec-rails/matchers/have-http-status-matcher
219+
[`match_array`]: https://rspec.info/features/7-0/rspec-rails/matchers/relation-match-array
220+
[`have_been_enqueued`]: https://rspec.info/features/7-0/rspec-rails/matchers/have-been-enqueued-matcher
221+
[`have_enqueued_job`]: https://rspec.info/features/7-0/rspec-rails/matchers/have-enqueued-job-matcher
220222

221223
### What else does RSpec Rails add?
222224

223225
For a comprehensive look at RSpec Rails’ features,
224226
read the [official Cucumber documentation][].
225227

226-
[official Cucumber documentation]: https://rspec.info/features/6-0/rspec-rails
228+
[official Cucumber documentation]: https://rspec.info/features/7-0/rspec-rails
227229

228230
## What tests should I write?
229231

@@ -268,20 +270,20 @@ RSpec.describe User, type: :model do
268270
...
269271
```
270272

271-
[request]: https://rspec.info/features/6-0/rspec-rails/request-specs/request-spec
272-
[feature]: https://rspec.info/features/6-0/rspec-rails/feature-specs/feature-spec
273-
[system]: https://rspec.info/features/6-0/rspec-rails/system-specs/system-specs
274-
[model]: https://rspec.info/features/6-0/rspec-rails/model-specs
275-
[controller]: https://rspec.info/features/6-0/rspec-rails/controller-specs
276-
[mailer]: https://rspec.info/features/6-0/rspec-rails/mailer-specs
277-
[job]: https://rspec.info/features/6-0/rspec-rails/job-specs/job-spec
278-
[view]: https://rspec.info/features/6-0/rspec-rails/view-specs/view-spec
279-
[routing]: https://rspec.info/features/6-0/rspec-rails/routing-specs
280-
[helper]: https://rspec.info/features/6-0/rspec-rails/helper-specs/helper-spec
273+
[request]: https://rspec.info/features/7-0/rspec-rails/request-specs/request-spec
274+
[feature]: https://rspec.info/features/7-0/rspec-rails/feature-specs/feature-spec
275+
[system]: https://rspec.info/features/7-0/rspec-rails/system-specs/system-specs
276+
[model]: https://rspec.info/features/7-0/rspec-rails/model-specs
277+
[controller]: https://rspec.info/features/7-0/rspec-rails/controller-specs
278+
[mailer]: https://rspec.info/features/7-0/rspec-rails/mailer-specs
279+
[job]: https://rspec.info/features/7-0/rspec-rails/job-specs/job-spec
280+
[view]: https://rspec.info/features/7-0/rspec-rails/view-specs/view-spec
281+
[routing]: https://rspec.info/features/7-0/rspec-rails/routing-specs
282+
[helper]: https://rspec.info/features/7-0/rspec-rails/helper-specs/helper-spec
281283
[`ActionDispatch::IntegrationTest`]: https://api.rubyonrails.org/classes/ActionDispatch/IntegrationTest.html
282284
[`ActionDispatch::SystemTestCase`]: https://api.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html
283285
[`ActionController::TestCase`]: https://api.rubyonrails.org/classes/ActionController/TestCase.html
284-
[in the appropriate folder]: https://rspec.info/features/6-0/rspec-rails/directory-structure
286+
[in the appropriate folder]: https://rspec.info/features/7-0/rspec-rails/directory-structure
285287

286288
### System specs, feature specs, request specs–what’s the difference?
287289

features/GettingStarted.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Getting Started
22

3-
Install Rails 6
3+
Install Rails
44

55
```console
6-
$ gem install rails -v "~> 6.0.0"
6+
$ gem install rails -v "~> 7.2.0"
77
```
88

99
### Generate an app

features/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ check their documentation for help as well.
77

88
## Rails
99

10-
rspec-rails 6 supports Rails 6.1 to 7.0. For earlier versions of Rails, you
11-
should use [rspec-rails-5](https://github.com/rspec/rspec-rails/tree/5-1-maintenance)
10+
rspec-rails 7 supports Rails 7.0 to 7.2. For earlier versions of Rails, you
11+
should use [rspec-rails-6](https://github.com/rspec/rspec-rails/tree/5-1-maintenance)
12+
for Rails 6.1, [rspec-rails-5](https://github.com/rspec/rspec-rails/tree/5-1-maintenance)
1213
for Rails 5.2 and 6.0, [rspec-rails-4](https://github.com/rspec/rspec-rails/tree/4-1-maintenance)
1314
for Rails 5.x, and [rspec-rails 3](https://github.com/rspec/rspec-rails/tree/3-9-maintenance)
1415
for even older versions.
@@ -33,7 +34,7 @@ Add rspec-rails to the :test and :development groups in the Gemfile:
3334

3435
```ruby
3536
group :test, :development do
36-
gem 'rspec-rails', '~> 6.0.0'
37+
gem 'rspec-rails', '~> 7.0.0'
3738
end
3839
```
3940

features/upgrade/README.md

+26-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,39 @@
1-
# Upgrading from rspec-rails 5.x to version 6
1+
# Upgrading
2+
3+
RSpec Rails versions follow semantic versioning of x.y.z where:
4+
5+
- `x` is a major release containing breaking changes and support changes for Rails.
6+
- `y` is a minor release which will contain only feature additions and bug fixes.
7+
- `z` is a patch release which will contain only bug fixes for the minor levels currently supported version of Rails.
8+
9+
On new Rails minor releases we will usually release our own new minor version to support that version, occasionally
10+
we will release a new major version instead to allow us to remove support for now unsupported versions of Rails
11+
as defined by the Rails team themselves.
12+
13+
The RSpec team will only maintain the current major / minor version, although it is common for the `main` branch
14+
to contain changes for the next upcoming version of Rails and usage of this branch directly is also supported.
215

3-
RSpec Rails 6 is a major version under semantic versioning, it also follows our new versioning strategy for RSpec-Rails, which is to keep in step with Rails supported versions. Thus it supports 6.1 and 7.0. There are no changes required to upgrade to RSpec Rails 6 if you are using a supported version of Rails.
16+
# Upgrading from rspec-rails 6.x to version 7
17+
18+
RSpec Rails 7 supports Rails versions 7.0, 7.1 and 7.2. There are no changes required to upgrade from 6.x to 7 for these versions of Rails,
19+
but we encourage those doing multiple step upgrades to upgrade to Rails 7.1 and RSpec Rails 6.1.x before upgrading to Rails 7.2 and RSpec Rails 7.0.
20+
21+
If you are on Rails 6.1 you will need to keep using RSpec Rails 6.1.
22+
23+
# Upgrading from rspec-rails 5.x to version 6
424

5-
If you are using an older version of Rails, you can use 5.x which hard supports 5.2 and 6.x.
25+
RSpec Rails 6 supports Rails versions 6.1, 7.0 and 7.1. There are no changes required to upgrade from 5.x to 6 for these versions of Rails.
626

727
# Upgrading from rspec-rails 4.x to version 5
828

9-
RSpec Rails 5 is a major version under semantic versioning, it also follows our new versioning strategy for RSpec-Rails, which is to keep in step with Rails supported versions. Thus it supports 5.2, 6.0 and 6.1. There are no changes required to upgrade to RSpec Rails 5 if you are using a supported version of Rails.
29+
RSpec Rails 5 supports 5.2, 6.0 and 6.1. There are no changes required to upgrade from 4.x to 5 for these versions of Rails.
1030

1131
If you are using an older version of Rails, you can use 4.x which hard supports 5.0 and 5.1, and soft supports 4.2 (which is unmaintained).
1232

1333
# Upgrading from rspec-rails 3.x to version 4
1434

15-
RSpec Rails 4 is a major version under semantic versioning, it allowed us to change the supported Rails versions to 5 and 6 only. There are no changes required to upgrade to RSpec Rails 4 if you are using Rails 5 or 6.
35+
RSpec Rails 4 was the first version to be released out of step with rspec, as a major version under semantic versioning, it allowed us to change the supported Rails versions to 5 and 6 only.
36+
There are no changes required to upgrade to RSpec Rails 4 from 3.x if you are using Rails 5 or 6.
1637

1738
If you are using Rails 4.2 you can use RSpec Rails 4, but note that support for it is not maintained, we consider this a breaking change hence the version change, and you must be on Ruby 2.2 as a minimum.
1839

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
# end
8080
#
8181
# The different available types are documented in the features, such as in
82-
# https://rspec.info/features/6-0/rspec-rails
82+
# https://rspec.info/features/7-0/rspec-rails
8383
config.infer_spec_type_from_file_location!
8484
8585
# Filter lines from Rails gems in backtraces.

lib/rspec/rails/fixture_support.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ module FixtureSupport
1010
include ActiveRecord::TestFixtures
1111

1212
# @private prevent ActiveSupport::TestFixtures to start a DB transaction.
13-
# Monkey patched to avoid collisions with 'let(:name)' in Rails 6.1 and after
14-
# and let(:method_name) before Rails 6.1.
13+
# Monkey patched to avoid collisions with 'let(:name)' since Rails 6.1
1514
def run_in_transaction?
1615
current_example_name = (RSpec.current_example && RSpec.current_example.metadata[:description])
1716
use_transactional_tests && !self.class.uses_transaction?(current_example_name)

lib/rspec/rails/matchers/active_job.rb

+3-14
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ def base_job_message(job)
148148
msg_parts << "on queue #{job[:queue]}" if job[:queue]
149149
msg_parts << "at #{Time.at(job[:at])}" if job[:at]
150150
msg_parts <<
151-
if fetch_priority(job)
152-
"with priority #{fetch_priority(job)}"
151+
if job[:priority]
152+
"with priority #{job[:priority]}"
153153
else
154154
"with no priority specified"
155155
end
@@ -167,17 +167,6 @@ def job_matches?(job)
167167
@job ? @job == job[:job] : true
168168
end
169169

170-
# Rails 6.1 serializes the priority with a string key
171-
if ::Rails.version.to_f >= 7
172-
def fetch_priority(job)
173-
job[:priority]
174-
end
175-
else
176-
def fetch_priority(job)
177-
job['priority']
178-
end
179-
end
180-
181170
def arguments_match?(job)
182171
if @args.any?
183172
args = serialize_and_deserialize_arguments(@args)
@@ -218,7 +207,7 @@ def queue_match?(job)
218207
def priority_match?(job)
219208
return true unless @priority
220209

221-
@priority == fetch_priority(job)
210+
@priority == job[:priority]
222211
end
223212

224213
def at_match?(job)

lib/rspec/rails/matchers/have_http_status.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def set_expected_code!
233233
# expect(response).to have_http_status(:redirect)
234234
#
235235
# @see RSpec::Rails::Matchers#have_http_status
236-
# @see https://github.com/rails/rails/blob/6-0-stable/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
236+
# @see https://github.com/rails/rails/blob/7-2-stable/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
237237
class GenericStatus < RSpec::Rails::Matchers::BaseMatcher
238238
include HaveHttpStatus
239239

lib/rspec/rails/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Rails
33
# Version information for RSpec Rails.
44
module Version
55
# Current version of RSpec Rails, in semantic versioning format.
6-
STRING = '6.2.0.pre'
6+
STRING = '7.0.0.pre'
77
end
88
end
99
end

rspec-rails.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
1111
s.homepage = "https://github.com/rspec/rspec-rails"
1212
s.summary = "RSpec for Rails"
1313
s.description = "rspec-rails integrates the Rails testing helpers into RSpec."
14-
s.required_ruby_version = ">= 2.5.0"
14+
s.required_ruby_version = ">= 2.7.0"
1515

1616
s.metadata = {
1717
'bug_tracker_uri' => 'https://github.com/rspec/rspec-rails/issues',
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
3333
s.cert_chain = [File.expand_path('~/.gem/rspec-gem-public_cert.pem')]
3434
end
3535

36-
version_string = ['>= 6.1']
36+
version_string = ['>= 7.0']
3737

3838
s.add_runtime_dependency 'actionpack', version_string
3939
s.add_runtime_dependency 'activesupport', version_string

snippets/avoid_fixture_name_collision.rb

-3
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@
4747
RSpec.describe 'Foo' do
4848
subject { true }
4949

50-
# Rails 6.1 and after
5150
let(:name) { raise "Should never raise" }
52-
# Before Rails 6.1
53-
let(:method_name) { raise "Should never raise" }
5451

5552
it { is_expected.to be_truthy }
5653
end

snippets/include_activesupport_testing_tagged_logger.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ def perform
5656

5757
describe 'error raised in perform_enqueued_jobs with block' do
5858
it 'raises the explicitly thrown error' do
59-
# Rails 6.1+ wraps unexpected errors in tests
60-
expected_error = if Rails::VERSION::STRING.to_f >= 6.1
61-
Minitest::UnexpectedError.new(TestError)
62-
else
63-
TestError
64-
end
59+
expected_error = Minitest::UnexpectedError.new(TestError)
6560

6661
expect { perform_enqueued_jobs { TestJob.perform_later } }
6762
.to raise_error(expected_error)

spec/rspec/rails/example/controller_example_group_spec.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,7 @@ def my_helper
5454
end
5555
end
5656

57-
# Rails 6.1 removes config from ./activerecord/lib/active_record/test_fixtures.rb
58-
if respond_to?(:config)
59-
config.include mod
60-
else
61-
ActiveRecord::Base.include mod
62-
end
57+
ActiveRecord::Base.include mod
6358

6459
group.class_exec do
6560
let(:my_helper) { "my_value" }

0 commit comments

Comments
 (0)