diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f3a35987..70b310f2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,23 +89,6 @@ jobs: env: RAILS_VERSION: '~> 7.0.0' - # Rails 6.1 builds >= 2.5 - - ruby: 3.1 - env: - RAILS_VERSION: '~> 6.1.0' - - ruby: '3.0' - env: - RAILS_VERSION: '~> 6.1.0' - - ruby: 2.7 - env: - RAILS_VERSION: '~> 6.1.0' - - ruby: 2.6 - env: - RAILS_VERSION: '~> 6.1.0' - - ruby: 2.5 - env: - RAILS_VERSION: '~> 6.1.0' - env: ${{ matrix.env }} steps: - uses: actions/checkout@v4 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 991b9c476..246ac1b03 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,8 +1,3 @@ - - # Contributor Code of Conduct For the purpose of building a welcoming, harassment-free community that diff --git a/Changelog.md b/Changelog.md index a44914d2e..5e968764d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,5 @@ ### Development -[Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.5...main) +[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.0.0...main) Enhancements: diff --git a/README.md b/README.md index 7b646bfd1..2d8e271f8 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ detailed explanations of how the application is supposed to behave, expressed in plain English. According to [RSpec Rails new versioning strategy][] use: -* **[`rspec-rails` 6.x][]** for Rails 6.1 or 7.x. +* **[`rspec-rails` 7.x][]** for Rails 7.x. +* **[`rspec-rails` 6.x][]** for Rails 6.1. * **[`rspec-rails` 5.x][]** for Rails 5.2 or 6.x. * **[`rspec-rails` 4.x][]** for Rails from 5.x or 6.x. * **[`rspec-rails` 3.x][]** for Rails earlier than 5.0. @@ -26,12 +27,13 @@ According to [RSpec Rails new versioning strategy][] use: [`rspec-rails` 4.x]: https://github.com/rspec/rspec-rails/tree/4-1-maintenance [`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-1-maintenance [`rspec-rails` 6.x]: https://github.com/rspec/rspec-rails/tree/6-1-maintenance +[`rspec-rails` 7.x]: https://github.com/rspec/rspec-rails/tree/7-0-maintenance [RSpec Rails new versioning strategy]: https://github.com/rspec/rspec-rails/blob/main/rfcs/versioning-strategy.md ## Installation **IMPORTANT** This README / branch refers to the current development build. -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. +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. 1. Add `rspec-rails` to **both** the `:development` and `:test` groups of your app’s `Gemfile`: @@ -39,7 +41,7 @@ See the [`6-1-maintenance` branch on Github](https://github.com/rspec/rspec-rail ```ruby # Run against this stable release group :development, :test do - gem 'rspec-rails', '~> 6.1.0' + gem 'rspec-rails', '~> 7.0.0' end # Or, run against the main branch @@ -86,7 +88,7 @@ read the [`rspec-rails` upgrade notes][] to find out what to watch out for. Be sure to check the general [RSpec upgrade notes][] as well. -[`rspec-rails` upgrade notes]: https://rspec.info/features/6-0/rspec-rails/upgrade +[`rspec-rails` upgrade notes]: https://rspec.info/features/7-0/rspec-rails/upgrade [RSpec upgrade notes]: https://rspec.info/upgrading-from-rspec-2/ ## Usage @@ -208,22 +210,22 @@ to test the various parts of a Rails system: Follow the links above for examples of how each matcher is used. [the matchers that come standard in RSpec]: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers -[`be_a_new`]: https://rspec.info/features/6-0/rspec-rails/matchers/new-record-matcher -[`render_template`]: https://rspec.info/features/6-0/rspec-rails/matchers/render-template-matcher -[`redirect_to`]: https://rspec.info/features/6-0/rspec-rails/matchers/redirect-to-matcher -[`route_to`]: https://rspec.info/features/6-0/rspec-rails/routing-specs/route-to-matcher -[`be_routable`]: https://rspec.info/features/6-0/rspec-rails/routing-specs/be-routable-matcher -[`have_http_status`]: https://rspec.info/features/6-0/rspec-rails/matchers/have-http-status-matcher -[`match_array`]: https://rspec.info/features/6-0/rspec-rails/matchers/relation-match-array -[`have_been_enqueued`]: https://rspec.info/features/6-0/rspec-rails/matchers/have-been-enqueued-matcher -[`have_enqueued_job`]: https://rspec.info/features/6-0/rspec-rails/matchers/have-enqueued-job-matcher +[`be_a_new`]: https://rspec.info/features/7-0/rspec-rails/matchers/new-record-matcher +[`render_template`]: https://rspec.info/features/7-0/rspec-rails/matchers/render-template-matcher +[`redirect_to`]: https://rspec.info/features/7-0/rspec-rails/matchers/redirect-to-matcher +[`route_to`]: https://rspec.info/features/7-0/rspec-rails/routing-specs/route-to-matcher +[`be_routable`]: https://rspec.info/features/7-0/rspec-rails/routing-specs/be-routable-matcher +[`have_http_status`]: https://rspec.info/features/7-0/rspec-rails/matchers/have-http-status-matcher +[`match_array`]: https://rspec.info/features/7-0/rspec-rails/matchers/relation-match-array +[`have_been_enqueued`]: https://rspec.info/features/7-0/rspec-rails/matchers/have-been-enqueued-matcher +[`have_enqueued_job`]: https://rspec.info/features/7-0/rspec-rails/matchers/have-enqueued-job-matcher ### What else does RSpec Rails add? For a comprehensive look at RSpec Rails’ features, read the [official Cucumber documentation][]. -[official Cucumber documentation]: https://rspec.info/features/6-0/rspec-rails +[official Cucumber documentation]: https://rspec.info/features/7-0/rspec-rails ## What tests should I write? @@ -268,20 +270,20 @@ RSpec.describe User, type: :model do ... ``` -[request]: https://rspec.info/features/6-0/rspec-rails/request-specs/request-spec -[feature]: https://rspec.info/features/6-0/rspec-rails/feature-specs/feature-spec -[system]: https://rspec.info/features/6-0/rspec-rails/system-specs/system-specs -[model]: https://rspec.info/features/6-0/rspec-rails/model-specs -[controller]: https://rspec.info/features/6-0/rspec-rails/controller-specs -[mailer]: https://rspec.info/features/6-0/rspec-rails/mailer-specs -[job]: https://rspec.info/features/6-0/rspec-rails/job-specs/job-spec -[view]: https://rspec.info/features/6-0/rspec-rails/view-specs/view-spec -[routing]: https://rspec.info/features/6-0/rspec-rails/routing-specs -[helper]: https://rspec.info/features/6-0/rspec-rails/helper-specs/helper-spec +[request]: https://rspec.info/features/7-0/rspec-rails/request-specs/request-spec +[feature]: https://rspec.info/features/7-0/rspec-rails/feature-specs/feature-spec +[system]: https://rspec.info/features/7-0/rspec-rails/system-specs/system-specs +[model]: https://rspec.info/features/7-0/rspec-rails/model-specs +[controller]: https://rspec.info/features/7-0/rspec-rails/controller-specs +[mailer]: https://rspec.info/features/7-0/rspec-rails/mailer-specs +[job]: https://rspec.info/features/7-0/rspec-rails/job-specs/job-spec +[view]: https://rspec.info/features/7-0/rspec-rails/view-specs/view-spec +[routing]: https://rspec.info/features/7-0/rspec-rails/routing-specs +[helper]: https://rspec.info/features/7-0/rspec-rails/helper-specs/helper-spec [`ActionDispatch::IntegrationTest`]: https://api.rubyonrails.org/classes/ActionDispatch/IntegrationTest.html [`ActionDispatch::SystemTestCase`]: https://api.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html [`ActionController::TestCase`]: https://api.rubyonrails.org/classes/ActionController/TestCase.html -[in the appropriate folder]: https://rspec.info/features/6-0/rspec-rails/directory-structure +[in the appropriate folder]: https://rspec.info/features/7-0/rspec-rails/directory-structure ### System specs, feature specs, request specs–what’s the difference? diff --git a/features/GettingStarted.md b/features/GettingStarted.md index 0f3ea7938..df1d19244 100644 --- a/features/GettingStarted.md +++ b/features/GettingStarted.md @@ -1,9 +1,9 @@ # Getting Started -Install Rails 6 +Install Rails ```console -$ gem install rails -v "~> 6.0.0" +$ gem install rails -v "~> 7.2.0" ``` ### Generate an app diff --git a/features/README.md b/features/README.md index e60cff5d2..a27546eae 100644 --- a/features/README.md +++ b/features/README.md @@ -7,8 +7,9 @@ check their documentation for help as well. ## Rails -rspec-rails 6 supports Rails 6.1 to 7.0. For earlier versions of Rails, you -should use [rspec-rails-5](https://github.com/rspec/rspec-rails/tree/5-1-maintenance) +rspec-rails 7 supports Rails 7.0 to 7.2. For earlier versions of Rails, you +should use [rspec-rails-6](https://github.com/rspec/rspec-rails/tree/5-1-maintenance) +for Rails 6.1, [rspec-rails-5](https://github.com/rspec/rspec-rails/tree/5-1-maintenance) for Rails 5.2 and 6.0, [rspec-rails-4](https://github.com/rspec/rspec-rails/tree/4-1-maintenance) for Rails 5.x, and [rspec-rails 3](https://github.com/rspec/rspec-rails/tree/3-9-maintenance) for even older versions. @@ -33,7 +34,7 @@ Add rspec-rails to the :test and :development groups in the Gemfile: ```ruby group :test, :development do - gem 'rspec-rails', '~> 6.0.0' + gem 'rspec-rails', '~> 7.0.0' end ``` diff --git a/features/upgrade/README.md b/features/upgrade/README.md index 5947fb084..059ad3223 100644 --- a/features/upgrade/README.md +++ b/features/upgrade/README.md @@ -1,18 +1,39 @@ -# Upgrading from rspec-rails 5.x to version 6 +# Upgrading + +RSpec Rails versions follow semantic versioning of x.y.z where: + +- `x` is a major release containing breaking changes and support changes for Rails. +- `y` is a minor release which will contain only feature additions and bug fixes. +- `z` is a patch release which will contain only bug fixes for the minor levels currently supported version of Rails. + +On new Rails minor releases we will usually release our own new minor version to support that version, occasionally +we will release a new major version instead to allow us to remove support for now unsupported versions of Rails +as defined by the Rails team themselves. + +The RSpec team will only maintain the current major / minor version, although it is common for the `main` branch +to contain changes for the next upcoming version of Rails and usage of this branch directly is also supported. -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. +# Upgrading from rspec-rails 6.x to version 7 + +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, +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. + +If you are on Rails 6.1 you will need to keep using RSpec Rails 6.1. + +# Upgrading from rspec-rails 5.x to version 6 -If you are using an older version of Rails, you can use 5.x which hard supports 5.2 and 6.x. +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. # Upgrading from rspec-rails 4.x to version 5 -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. +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. 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). # Upgrading from rspec-rails 3.x to version 4 -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. +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. +There are no changes required to upgrade to RSpec Rails 4 from 3.x if you are using Rails 5 or 6. 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. diff --git a/lib/generators/rspec/install/templates/spec/rails_helper.rb b/lib/generators/rspec/install/templates/spec/rails_helper.rb index 36ca9834d..ade688cfb 100644 --- a/lib/generators/rspec/install/templates/spec/rails_helper.rb +++ b/lib/generators/rspec/install/templates/spec/rails_helper.rb @@ -79,7 +79,7 @@ # end # # The different available types are documented in the features, such as in - # https://rspec.info/features/6-0/rspec-rails + # https://rspec.info/features/7-0/rspec-rails config.infer_spec_type_from_file_location! # Filter lines from Rails gems in backtraces. diff --git a/lib/rspec/rails/fixture_support.rb b/lib/rspec/rails/fixture_support.rb index b6727d71b..e56fabeb1 100644 --- a/lib/rspec/rails/fixture_support.rb +++ b/lib/rspec/rails/fixture_support.rb @@ -10,8 +10,7 @@ module FixtureSupport include ActiveRecord::TestFixtures # @private prevent ActiveSupport::TestFixtures to start a DB transaction. - # Monkey patched to avoid collisions with 'let(:name)' in Rails 6.1 and after - # and let(:method_name) before Rails 6.1. + # Monkey patched to avoid collisions with 'let(:name)' since Rails 6.1 def run_in_transaction? current_example_name = (RSpec.current_example && RSpec.current_example.metadata[:description]) use_transactional_tests && !self.class.uses_transaction?(current_example_name) diff --git a/lib/rspec/rails/matchers/active_job.rb b/lib/rspec/rails/matchers/active_job.rb index 583f56faf..40c676c0c 100644 --- a/lib/rspec/rails/matchers/active_job.rb +++ b/lib/rspec/rails/matchers/active_job.rb @@ -148,8 +148,8 @@ def base_job_message(job) msg_parts << "on queue #{job[:queue]}" if job[:queue] msg_parts << "at #{Time.at(job[:at])}" if job[:at] msg_parts << - if fetch_priority(job) - "with priority #{fetch_priority(job)}" + if job[:priority] + "with priority #{job[:priority]}" else "with no priority specified" end @@ -167,17 +167,6 @@ def job_matches?(job) @job ? @job == job[:job] : true end - # Rails 6.1 serializes the priority with a string key - if ::Rails.version.to_f >= 7 - def fetch_priority(job) - job[:priority] - end - else - def fetch_priority(job) - job['priority'] - end - end - def arguments_match?(job) if @args.any? args = serialize_and_deserialize_arguments(@args) @@ -218,7 +207,7 @@ def queue_match?(job) def priority_match?(job) return true unless @priority - @priority == fetch_priority(job) + @priority == job[:priority] end def at_match?(job) diff --git a/lib/rspec/rails/matchers/have_http_status.rb b/lib/rspec/rails/matchers/have_http_status.rb index cc1b178be..91b6c9824 100644 --- a/lib/rspec/rails/matchers/have_http_status.rb +++ b/lib/rspec/rails/matchers/have_http_status.rb @@ -233,7 +233,7 @@ def set_expected_code! # expect(response).to have_http_status(:redirect) # # @see RSpec::Rails::Matchers#have_http_status - # @see https://github.com/rails/rails/blob/6-0-stable/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse` + # @see https://github.com/rails/rails/blob/7-2-stable/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse` class GenericStatus < RSpec::Rails::Matchers::BaseMatcher include HaveHttpStatus diff --git a/lib/rspec/rails/version.rb b/lib/rspec/rails/version.rb index 079a7d5d4..cd746b581 100644 --- a/lib/rspec/rails/version.rb +++ b/lib/rspec/rails/version.rb @@ -3,7 +3,7 @@ module Rails # Version information for RSpec Rails. module Version # Current version of RSpec Rails, in semantic versioning format. - STRING = '6.2.0.pre' + STRING = '7.0.0.pre' end end end diff --git a/rspec-rails.gemspec b/rspec-rails.gemspec index 4e5ffec21..788977e11 100644 --- a/rspec-rails.gemspec +++ b/rspec-rails.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/rspec/rspec-rails" s.summary = "RSpec for Rails" s.description = "rspec-rails integrates the Rails testing helpers into RSpec." - s.required_ruby_version = ">= 2.5.0" + s.required_ruby_version = ">= 2.7.0" s.metadata = { 'bug_tracker_uri' => 'https://github.com/rspec/rspec-rails/issues', @@ -33,7 +33,7 @@ Gem::Specification.new do |s| s.cert_chain = [File.expand_path('~/.gem/rspec-gem-public_cert.pem')] end - version_string = ['>= 6.1'] + version_string = ['>= 7.0'] s.add_runtime_dependency 'actionpack', version_string s.add_runtime_dependency 'activesupport', version_string diff --git a/snippets/avoid_fixture_name_collision.rb b/snippets/avoid_fixture_name_collision.rb index 047d5c218..37f79003d 100644 --- a/snippets/avoid_fixture_name_collision.rb +++ b/snippets/avoid_fixture_name_collision.rb @@ -47,10 +47,7 @@ RSpec.describe 'Foo' do subject { true } - # Rails 6.1 and after let(:name) { raise "Should never raise" } - # Before Rails 6.1 - let(:method_name) { raise "Should never raise" } it { is_expected.to be_truthy } end diff --git a/snippets/include_activesupport_testing_tagged_logger.rb b/snippets/include_activesupport_testing_tagged_logger.rb index c8d87caf3..f3d446c5a 100644 --- a/snippets/include_activesupport_testing_tagged_logger.rb +++ b/snippets/include_activesupport_testing_tagged_logger.rb @@ -56,12 +56,7 @@ def perform describe 'error raised in perform_enqueued_jobs with block' do it 'raises the explicitly thrown error' do - # Rails 6.1+ wraps unexpected errors in tests - expected_error = if Rails::VERSION::STRING.to_f >= 6.1 - Minitest::UnexpectedError.new(TestError) - else - TestError - end + expected_error = Minitest::UnexpectedError.new(TestError) expect { perform_enqueued_jobs { TestJob.perform_later } } .to raise_error(expected_error) diff --git a/spec/rspec/rails/example/controller_example_group_spec.rb b/spec/rspec/rails/example/controller_example_group_spec.rb index fa524b0fc..d50e88ae5 100644 --- a/spec/rspec/rails/example/controller_example_group_spec.rb +++ b/spec/rspec/rails/example/controller_example_group_spec.rb @@ -54,12 +54,7 @@ def my_helper end end - # Rails 6.1 removes config from ./activerecord/lib/active_record/test_fixtures.rb - if respond_to?(:config) - config.include mod - else - ActiveRecord::Base.include mod - end + ActiveRecord::Base.include mod group.class_exec do let(:my_helper) { "my_value" }