diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad118a06b..f9c3c9ab4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,12 +18,12 @@ concurrency: jobs: rubocop: name: Rubocop - runs-on: 'ubuntu-20.04' + runs-on: 'ubuntu-latest' steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0' + ruby-version: '3.3' - run: script/update_rubygems_and_install_bundler - run: bundle install --standalone - run: bundle binstubs --all @@ -31,12 +31,15 @@ jobs: test: name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.env.RAILS_VERSION }}' - runs-on: ubuntu-20.04 + runs-on: 'ubuntu-latest' strategy: fail-fast: false matrix: include: # Edge Rails (?) builds >= 3.1 + - ruby: 3.4 + env: + RAILS_VERSION: 'main' - ruby: 3.3 env: RAILS_VERSION: 'main' @@ -44,6 +47,17 @@ jobs: env: RAILS_VERSION: 'main' + # Rails 8.0 builds >= 3.2 + - ruby: 3.4 + env: + RAILS_VERSION: '~> 8.0.0' + - ruby: 3.3 + env: + RAILS_VERSION: '~> 8.0.0' + - ruby: 3.2 + env: + RAILS_VERSION: '~> 8.0.0' + # Rails 7.2 builds >= 3.1 - ruby: 3.3 env: diff --git a/Changelog.md b/Changelog.md index 6bebf46bb..d8ba3f72d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,27 +1,50 @@ ### Development -[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.0.1...main) +[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.1.1...main) + +Enhancements: + +* Add Rails 8 authentication generator support. (Jerome Dalbert, rspec/rspec-rails#2811) +* Improve install generator comment for `ActiveRecord::Migration.maintain_test_schema!` +(rspec/rspec-rails#2832) +* Add support for `served_by` in system specs. (Sam Giffney, rspec/rspec-rails#2841) + +### 7.1.1 / 2025-02-06 +[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.1.0...v7.1.1) + +Bug Fixes: + +* Check wether rspec-mocks has been loaded before enabling signature + verification for `have_enqueued_job` et al (Jon Rowe, rspec/rspec-rails#2823) + +### 7.1.0 / 2024-11-09 +[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.0.2...v7.1.0) Enhancements: * Improve implicit description for ActionCable matchers `have_broadcasted_to` / - `have_broadcast`. (Simon Fish, #2795) + `have_broadcast`. (Simon Fish, rspec/rspec-rails#2795) * Comment out `infer_spec_type_from_file_location!` in newly generated - `rails_helper.rb` files. (Jon Rowe, #2804) + `rails_helper.rb` files. (Jon Rowe, rspec/rspec-rails#2804) +* Allow turning off active job / mailer argument validation. + (Oli Peate, rspec/rspec-rails#2808) + +### 7.0.2 / 2024-11-09 +[Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.0.1...v7.0.2) Bug Fixes: * Fix issue with `have_enqueued_mail` when jobs were incorrectly matched due - to refactoring in #2780. (David Runger, #2793) + to refactoring in rspec/rspec-rails#2780. (David Runger, rspec/rspec-rails#2793) ### 7.0.1 / 2024-09-03 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v7.0.0...v7.0.1) Bug Fixes: -* Remove mutation of Rails constant in favour of public api. (Petrik de Heus, #2789) -* Cleanup Rails scaffold for unsupported versions. (Matt Jankowski, #2790) +* Remove mutation of Rails constant in favour of public api. (Petrik de Heus, rspec/rspec-rails#2789) +* Cleanup Rails scaffold for unsupported versions. (Matt Jankowski, rspec/rspec-rails#2790) * Remove deprecated scaffold that was unintentionally included in 7.0.0 - (Jon Rowe, #2791) + (Jon Rowe, rspec/rspec-rails#2791) ### 7.0.0 / 2024-09-02 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.5...v7.0.0) @@ -29,19 +52,19 @@ Bug Fixes: Enhancements: * Change default driver for system specs on Rails 7.2 to match its default. - (Steve Polito, #2746) -* Verify ActiveJob arguments by comparing to the method signature. (Oli Peate, #2745) -* Add suggestion to rails_helper.rb to skip when not in test mode. (Glauco Custódio, #2751) -* Add `at_priority` qualifier to `have_enqueued_job` set of matchers. (mbajur, #2759) -* Add spec directories to `rails stats` on Rails main / 8.0.0. (Petrik de Heus, #2781) + (Steve Polito, rspec/rspec-rails#2746) +* Verify ActiveJob arguments by comparing to the method signature. (Oli Peate, rspec/rspec-rails#2745) +* Add suggestion to rails_helper.rb to skip when not in test mode. (Glauco Custódio, rspec/rspec-rails#2751) +* Add `at_priority` qualifier to `have_enqueued_job` set of matchers. (mbajur, rspec/rspec-rails#2759) +* Add spec directories to `rails stats` on Rails main / 8.0.0. (Petrik de Heus, rspec/rspec-rails#2781) ### 6.1.5 / 2024-09-02 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.4...v6.1.5) Bug Fixes: -* Restore old order of requiring support files. (Franz Liedke, #2785) -* Prevent running `rake spec:statsetup` on Rails main / 8.0.0. (Petrik de Heus, #2781) +* Restore old order of requiring support files. (Franz Liedke, rspec/rspec-rails#2785) +* Prevent running `rake spec:statsetup` on Rails main / 8.0.0. (Petrik de Heus, rspec/rspec-rails#2781) ### 6.1.4 / 2024-08-15 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.3...v6.1.4) @@ -49,26 +72,26 @@ Bug Fixes: Bug Fixes: * Prevent `have_http_status` matcher raising an error when encountering a raw `Rack::MockResponse`. - (Christophe Bliard, #2771) -* Move Rails version conditional from index scaffold generated file to template. (Matt Jankowski, #2777) + (Christophe Bliard, rspec/rspec-rails#2771) +* Move Rails version conditional from index scaffold generated file to template. (Matt Jankowski, rspec/rspec-rails#2777) ### 6.1.3 / 2024-06-19 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.2...v6.1.3) Bug Fixes: -* Reset `ActiveSupport::CurrentAttributes` between examples. (Javier Julio, #2752) -* Fix a broken link in generated mailer previews. (Chiara Núñez, #2764) +* Reset `ActiveSupport::CurrentAttributes` between examples. (Javier Julio, rspec/rspec-rails#2752) +* Fix a broken link in generated mailer previews. (Chiara Núñez, rspec/rspec-rails#2764) * Fix `have_status_code` behaviour with deprecated status names by delegating - to `Rack::Utils.status_code/1` to set the expected status code. (Darren Boyd, #2765) + to `Rack::Utils.status_code/1` to set the expected status code. (Darren Boyd, rspec/rspec-rails#2765) ### 6.1.2 / 2024-03-19 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.1...v6.1.2) Bug Fixes: -* Fix generated mailer paths to match Rails convention. (Patrício dos Santos, #2735) -* Fix class in template for generator specs. (Nicolas Buduroi, #2744) +* Fix generated mailer paths to match Rails convention. (Patrício dos Santos, rspec/rspec-rails#2735) +* Fix class in template for generator specs. (Nicolas Buduroi, rspec/rspec-rails#2744) ### 6.1.1 / 2024-01-25 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.0...v6.1.1) @@ -76,8 +99,8 @@ Bug Fixes: Bug Fixes: * Improved deprecation message for `RSpec::Rails::Configuration.fixture_paths` - (Benoit Tigeot, #2720) -* Fix support for namespaced fixtures in Rails 7.1. (Benedikt Deicke, #2716) + (Benoit Tigeot, rspec/rspec-rails#2720) +* Fix support for namespaced fixtures in Rails 7.1. (Benedikt Deicke, rspec/rspec-rails#2716) ### 6.1.0 / 2023-11-21 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.4...v6.1.0) @@ -86,17 +109,17 @@ Enhancements: * Support for Rails 7.1 * Minor tweak to generated `rails_helper.rb` to use `Rails.root.join`. - (@masato-bkn, Ryo Nakamura, #2640, #2678) + (@masato-bkn, Ryo Nakamura, rspec/rspec-rails#2640, rspec/rspec-rails#2678) * Add `RSpec::Rails::Configuration.fixture_paths` configuration to support the matching change to `ActiveRecord::TestFixtures`, previous singular - form is deprecated and will be removed in Rails 7.2. (Juan Gueçaimburu, #2673) + form is deprecated and will be removed in Rails 7.2. (Juan Gueçaimburu, rspec/rspec-rails#2673) * Add `send_email` matcher to match emails rather than specific jobs. - (Andrei Kaleshka, #2670) + (Andrei Kaleshka, rspec/rspec-rails#2670) * When using `render` in view specs, `:locals` will now be merged into the default implicit template, allowing `render locals: {...}` style calls. - (Jon Rowe, #2686) + (Jon Rowe, rspec/rspec-rails#2686) * Add support for `Rails.config.action_mailer.preview_paths` on Rails 7.1/ - (Jon Rowe, #2706) + (Jon Rowe, rspec/rspec-rails#2706) ### 6.0.4 / 2023-11-21 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.3...v6.0.4) @@ -104,14 +127,14 @@ Enhancements: Bug Fixes: * Fuzzy match `have_broadcasted_to` so that argument matchers can be used. - (Timothy Peraza, #2684) -* Fix fixture warning during `:context` hooks on Rails `main`. (Jon Rowe, #2685) -* Fix `stub_template` on Rails `main`. (Jon Rowe, #2685) -* Fix variable name in scaffolded view specs when namespaced. (Taketo Takashima, #2694) + (Timothy Peraza, rspec/rspec-rails#2684) +* Fix fixture warning during `:context` hooks on Rails `main`. (Jon Rowe, rspec/rspec-rails#2685) +* Fix `stub_template` on Rails `main`. (Jon Rowe, rspec/rspec-rails#2685) +* Fix variable name in scaffolded view specs when namespaced. (Taketo Takashima, rspec/rspec-rails#2694) * Prevent `take_failed_screenshot` producing an additional error through `metadata` - access. (Jon Rowe, #2704) -* Use `ActiveSupport::ExecutionContext::TestHelper` on Rails 7+. (Jon Rowe, #2711) -* Fix leak of templates stubbed with `stub_template` on Rails 7.1. (Jon Rowe, #2714) + access. (Jon Rowe, rspec/rspec-rails#2704) +* Use `ActiveSupport::ExecutionContext::TestHelper` on Rails 7+. (Jon Rowe, rspec/rspec-rails#2711) +* Fix leak of templates stubbed with `stub_template` on Rails 7.1. (Jon Rowe, rspec/rspec-rails#2714) ### 6.0.3 / 2023-05-31 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.2...v6.0.3) @@ -119,8 +142,8 @@ Bug Fixes: Bug Fixes: * Set `ActiveStorage::FixtureSet.file_fixture_path` when including file fixture support. - (Jason Yates, #2671) -* Allow `broadcast_to` matcher to take Symbols. (@Vagab, #2680) + (Jason Yates, rspec/rspec-rails#2671) +* Allow `broadcast_to` matcher to take Symbols. (@Vagab, rspec/rspec-rails#2680) ### 6.0.2 / 2023-05-04 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.1...v6.0.2) @@ -128,18 +151,18 @@ Bug Fixes: Bug Fixes: * Fix ActionView::PathSet when `render_views` is off for Rails 7.1. - (Eugene Kenny, Iliana, #2631) + (Eugene Kenny, Iliana, rspec/rspec-rails#2631) * Support Rails 7.1's `#fixtures_paths` in example groups (removes a deprecation warning). - (Nicholas Simmons, #2664) + (Nicholas Simmons, rspec/rspec-rails#2664) * Fix `have_enqueued_job` to properly detect enqueued jobs when other jobs were - performed inside the expectation block. (Slava Kardakov, Phil Pirozhkov, #2573) + performed inside the expectation block. (Slava Kardakov, Phil Pirozhkov, rspec/rspec-rails#2573) ### 6.0.1 / 2022-10-18 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.0.0...v6.0.1) Bug Fixes: -* Prevent tagged logged support in Rails 7 calling `#name`. (Jon Rowe, #2625) +* Prevent tagged logged support in Rails 7 calling `#name`. (Jon Rowe, rspec/rspec-rails#2625) ### 6.0.0 / 2022-10-10 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.2...v6.0.0) @@ -147,29 +170,29 @@ Bug Fixes: Enhancements: * Support Rails 7 -* Template tweaks to remove instance variables from generated specs. (Takuma Ishikawa, #2599) -* Generators now respects default path configuration option. (@vivekmiyani, #2508) +* Template tweaks to remove instance variables from generated specs. (Takuma Ishikawa, rspec/rspec-rails#2599) +* Generators now respects default path configuration option. (@vivekmiyani, rspec/rspec-rails#2508) Breaking Changes: * Drop support for Rails below 6.1 * Drop support for Ruby below 2.5 (following supported versions of Rails 6.1) * Change the order of `after_teardown` from `after` to `around` in system - specs to improve compatibility with extensions and Capybara. (Tim Diggins, #2596) + specs to improve compatibility with extensions and Capybara. (Tim Diggins, rspec/rspec-rails#2596) Deprecations: * Deprecates integration spec generator (`rspec:integration`) which was an alias of request spec generator (`rspec:request`) - (Luka Lüdicke, #2374) + (Luka Lüdicke, rspec/rspec-rails#2374) ### 5.1.2 / 2022-04-24 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.1...v5.1.2) Bug Fixes: -* Fix controller scaffold templates parameter name. (Taketo Takashima, #2591) -* Include generator specs in the inferred list of specs. (Jason Karns, #2597) +* Fix controller scaffold templates parameter name. (Taketo Takashima, rspec/rspec-rails#2591) +* Include generator specs in the inferred list of specs. (Jason Karns, rspec/rspec-rails#2597) ### 5.1.1 / 2022-03-07 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.0...v5.1.1) @@ -177,7 +200,7 @@ Bug Fixes: Bug Fixes: * Properly handle global id serialised arguments in `have_enqueued_mail`. - (Jon Rowe, #2578) + (Jon Rowe, rspec/rspec-rails#2578) ### 5.1.0 / 2022-01-26 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.3...v5.1.0) @@ -185,9 +208,9 @@ Bug Fixes: Enhancements: * Make the API request scaffold template more consistent and compatible with - Rails 6.1. (Naoto Hamada, #2484) + Rails 6.1. (Naoto Hamada, rspec/rspec-rails#2484) * Change the scaffold `rails_helper.rb` template to use `require_relative`. - (Jon Dufresne, #2528) + (Jon Dufresne, rspec/rspec-rails#2528) ### 5.0.3 / 2022-01-26 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.2...v5.0.3) @@ -195,10 +218,10 @@ Enhancements: Bug Fixes: * Properly name params in controller and request spec templates when - using the `--model-name` parameter. (@kenzo-tanaka, #2534) + using the `--model-name` parameter. (@kenzo-tanaka, rspec/rspec-rails#2534) * Fix parameter matching with mail delivery job and - ActionMailer::MailDeliveryJob. (Fabio Napoleoni, #2516, #2546) -* Fix Rails 7 `have_enqueued_mail` compatibility (Mikael Henriksson, #2537, #2546) + ActionMailer::MailDeliveryJob. (Fabio Napoleoni, rspec/rspec-rails#2516, rspec/rspec-rails#2546) +* Fix Rails 7 `have_enqueued_mail` compatibility (Mikael Henriksson, rspec/rspec-rails#2537, rspec/rspec-rails#2546) ### 5.0.2 / 2021-08-14 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.1...v5.0.2) @@ -206,12 +229,12 @@ Bug Fixes: Bug Fixes: * Prevent generated job specs from duplicating `_job` in filenames. - (Nick Flückiger, #2496) + (Nick Flückiger, rspec/rspec-rails#2496) * Fix `ActiveRecord::TestFixture#uses_transaction` by using example description to replace example name rather than example in our monkey patched - `run_in_transaction?` method. (Stan Lo, #2495) + `run_in_transaction?` method. (Stan Lo, rspec/rspec-rails#2495) * Prevent keyword arguments being lost when methods are invoked dynamically - in controller specs. (Josh Cheek, #2509, #2514) + in controller specs. (Josh Cheek, rspec/rspec-rails#2509, rspec/rspec-rails#2514) ### 5.0.1 / 2021-03-18 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.0...v5.0.1) @@ -219,15 +242,15 @@ Bug Fixes: Bug Fixes: * Limit multibyte example descriptions when used in system tests for #method_name - which ends up as screenshot names etc. (@y-yagi, #2405, #2487) + which ends up as screenshot names etc. (@y-yagi, rspec/rspec-rails#2405, rspec/rspec-rails#2487) ### 5.0.0 / 2021-03-09 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.1.1...v5.0.0) Enhancements: -* Support new #file_fixture_path and new fixture test support code. (Jon Rowe, #2398) -* Support for Rails 6.1. (Benoit Tigeot, Jon Rowe, Phil Pirozhkov, and more #2398) +* Support new #file_fixture_path and new fixture test support code. (Jon Rowe, rspec/rspec-rails#2398) +* Support for Rails 6.1. (Benoit Tigeot, Jon Rowe, Phil Pirozhkov, and more rspec/rspec-rails#2398) Breaking Changes: @@ -238,102 +261,102 @@ Breaking Changes: Bug Fixes: * Remove generated specs when destroying a generated controller. - (@Naokimi, #2475) + (@Naokimi, rspec/rspec-rails#2475) ### 4.1.0 / 2021-03-06 Enhancements: * Issue a warning when using job matchers with `#at` mismatch on `usec` precision. - (Jon Rowe, #2350) + (Jon Rowe, rspec/rspec-rails#2350) * Generated request specs now have a bare `_spec` suffix instead of `request_spec`. - (Eloy Espinaco, Luka Lüdicke, #2355, #2356, #2378) + (Eloy Espinaco, Luka Lüdicke, rspec/rspec-rails#2355, rspec/rspec-rails#2356, rspec/rspec-rails#2378) * Generated scaffold now includes engine route helpers when inside a mountable engine. - (Andrew W. Lee, #2372) + (Andrew W. Lee, rspec/rspec-rails#2372) * Improve request spec "controller" scaffold when no action is specified. - (Thomas Hareau, #2399) -* Introduce testing snippets concept (Phil Pirozhkov, Benoit Tigeot, #2423) + (Thomas Hareau, rspec/rspec-rails#2399) +* Introduce testing snippets concept (Phil Pirozhkov, Benoit Tigeot, rspec/rspec-rails#2423) * Prevent collisions with `let(:name)` for Rails 6.1 and `let(:method_name)` on older - Rails. (Benoit Tigeot, #2461) + Rails. (Benoit Tigeot, rspec/rspec-rails#2461) ### 4.0.2 / 2020-12-26 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.1...v4.0.2) Bug Fixes: -* Indent all extra failure lines output from system specs. (Alex Robbin, #2321) -* Generated request spec for update now uses the correct let. (Paul Hanyzewski, #2344) +* Indent all extra failure lines output from system specs. (Alex Robbin, rspec/rspec-rails#2321) +* Generated request spec for update now uses the correct let. (Paul Hanyzewski, rspec/rspec-rails#2344) * Return `true`/`false` from predicate methods in config rather than raw values. - (Phil Pirozhkov, Jon Rowe, #2353, #2354) + (Phil Pirozhkov, Jon Rowe, rspec/rspec-rails#2353, rspec/rspec-rails#2354) * Remove old #fixture_path feature detection code which broke under newer Rails. - (Koen Punt, Jon Rowe, #2370) -* Fix an error when `use_active_record` is `false` (Phil Pirozhkov, #2423) + (Koen Punt, Jon Rowe, rspec/rspec-rails#2370) +* Fix an error when `use_active_record` is `false` (Phil Pirozhkov, rspec/rspec-rails#2423) ### 4.0.1 / 2020-05-16 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0...v4.0.1) Bug Fixes: -* Remove warning when calling `driven_by` in system specs. (Aubin Lorieux, #2302) -* Fix comparison of times for `#at` in job matchers. (Jon Rowe, Markus Doits, #2304) +* Remove warning when calling `driven_by` in system specs. (Aubin Lorieux, rspec/rspec-rails#2302) +* Fix comparison of times for `#at` in job matchers. (Jon Rowe, Markus Doits, rspec/rspec-rails#2304) * Allow `have_enqueued_mail` to match when a sub class of `ActionMailer::DeliveryJob` - is set using `.delivery_job=`. (Atsushi Yoshida #2305) -* Restore Ruby 2.2.x compatibility. (Jon Rowe, #2332) -* Add `required_ruby_version` to gem spec. (Marc-André Lafortune, #2319, #2338) + is set using `.delivery_job=`. (Atsushi Yoshida rspec/rspec-rails#2305) +* Restore Ruby 2.2.x compatibility. (Jon Rowe, rspec/rspec-rails#2332) +* Add `required_ruby_version` to gem spec. (Marc-André Lafortune, rspec/rspec-rails#2319, rspec/rspec-rails#2338) ### 4.0.0 / 2020-03-24 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.9.1...v4.0.0) Enhancements: -* Adds support for Rails 6. (Penelope Phippen, Benoit Tigeot, Jon Rowe, #2071) +* Adds support for Rails 6. (Penelope Phippen, Benoit Tigeot, Jon Rowe, rspec/rspec-rails#2071) * Adds support for JRuby on Rails 5.2 and 6 -* Add support for parameterised mailers (Ignatius Reza, #2125) -* Add ActionMailbox spec helpers and test type (James Dabbs, #2119) -* Add ActionCable spec helpers and test type (Vladimir Dementyev, #2113) +* Add support for parameterised mailers (Ignatius Reza, rspec/rspec-rails#2125) +* Add ActionMailbox spec helpers and test type (James Dabbs, rspec/rspec-rails#2119) +* Add ActionCable spec helpers and test type (Vladimir Dementyev, rspec/rspec-rails#2113) * Add support for partial args when using `have_enqueued_mail` - (Ignatius Reza, #2118, #2125) -* Add support for time arguments for `have_enqueued_job` (@alpaca-tc, #2157) -* Improve path parsing in view specs render options. (John Hawthorn, #2115) + (Ignatius Reza, rspec/rspec-rails#2118, rspec/rspec-rails#2125) +* Add support for time arguments for `have_enqueued_job` (@alpaca-tc, rspec/rspec-rails#2157) +* Improve path parsing in view specs render options. (John Hawthorn, rspec/rspec-rails#2115) * Add routing spec template as an option for generating controller specs. - (David Revelo, #2134) -* Add argument matcher support to `have_enqueued_*` matchers. (Phil Pirozhkov, #2206) -* Switch generated templates to use ruby 1.9 hash keys. (Tanbir Hasan, #2224) + (David Revelo, rspec/rspec-rails#2134) +* Add argument matcher support to `have_enqueued_*` matchers. (Phil Pirozhkov, rspec/rspec-rails#2206) +* Switch generated templates to use ruby 1.9 hash keys. (Tanbir Hasan, rspec/rspec-rails#2224) * Add `have_been_performed`/`have_performed_job`/`perform_job` ActiveJob - matchers (Isaac Seymour, #1785) + matchers (Isaac Seymour, rspec/rspec-rails#1785) * Default to generating request specs rather than controller specs when - generating a controller (Luka Lüdicke, #2222) -* Allow `ActiveJob` matchers `#on_queue` modifier to take symbolic queue names. (Nils Sommer, #2283) + generating a controller (Luka Lüdicke, rspec/rspec-rails#2222) +* Allow `ActiveJob` matchers `#on_queue` modifier to take symbolic queue names. (Nils Sommer, rspec/rspec-rails#2283) * The scaffold generator now generates request specs in preference to controller specs. - (Luka Lüdicke, #2288) -* Add configuration option to disable ActiveRecord. (Jon Rowe, Phil Pirozhkov, Hermann Mayer, #2266) + (Luka Lüdicke, rspec/rspec-rails#2288) +* Add configuration option to disable ActiveRecord. (Jon Rowe, Phil Pirozhkov, Hermann Mayer, rspec/rspec-rails#2266) * Set `ActionDispatch::SystemTesting::Server.silence_puma = true` when running system specs. - (ta1kt0me, Benoit Tigeot, #2289) + (ta1kt0me, Benoit Tigeot, rspec/rspec-rails#2289) Bug Fixes: * `EmptyTemplateHandler.call` now needs to support an additional argument in - Rails 6. (Pavel Rosický, #2089) + Rails 6. (Pavel Rosický, rspec/rspec-rails#2089) * Suppress warning from `SQLite3Adapter.represent_boolean_as_integer` which is - deprecated. (Pavel Rosický, #2092) + deprecated. (Pavel Rosický, rspec/rspec-rails#2092) * `ActionView::Template#formats` has been deprecated and replaced by - `ActionView::Template#format`(Seb Jacobs, #2100) + `ActionView::Template#format`(Seb Jacobs, rspec/rspec-rails#2100) * Replace `before_teardown` as well as `after_teardown` to ensure screenshots - are generated correctly. (Jon Rowe, #2164) + are generated correctly. (Jon Rowe, rspec/rspec-rails#2164) * `ActionView::FixtureResolver#hash` has been renamed to `ActionView::FixtureResolver#data`. - (Penelope Phippen, #2076) + (Penelope Phippen, rspec/rspec-rails#2076) * Prevent `driven_by(:selenium)` being called due to hook precedence. - (Takumi Shotoku, #2188) + (Takumi Shotoku, rspec/rspec-rails#2188) * Prevent a `WrongScopeError` being thrown during loading fixtures on Rails - 6.1 development version. (Edouard Chin, #2215) -* Fix Mocha mocking support with `should`. (Phil Pirozhkov, #2256) + 6.1 development version. (Edouard Chin, rspec/rspec-rails#2215) +* Fix Mocha mocking support with `should`. (Phil Pirozhkov, rspec/rspec-rails#2256) * Restore previous conditional check for setting `default_url_options` in feature - specs, prevents a `NoMethodError` in some scenarios. (Eugene Kenny, #2277) + specs, prevents a `NoMethodError` in some scenarios. (Eugene Kenny, rspec/rspec-rails#2277) * Allow changing `ActiveJob::Base.queue_adapter` inside a system spec. - (Jonathan Rochkind, #2242) -* `rails generate generator` command now creates related spec file (Joel Azemar, #2217) -* Relax upper `capybara` version constraint to allow for Capybara 3.x (Phil Pirozhkov, #2281) -* Clear ActionMailer test mailbox after each example (Benoit Tigeot, #2293) + (Jonathan Rochkind, rspec/rspec-rails#2242) +* `rails generate generator` command now creates related spec file (Joel Azemar, rspec/rspec-rails#2217) +* Relax upper `capybara` version constraint to allow for Capybara 3.x (Phil Pirozhkov, rspec/rspec-rails#2281) +* Clear ActionMailer test mailbox after each example (Benoit Tigeot, rspec/rspec-rails#2293) Breaking Changes: @@ -345,7 +368,7 @@ Breaking Changes: Bug Fixes: -* Add missing require for have_enqueued_mail matcher. (Ignatius Reza, #2117) +* Add missing require for have_enqueued_mail matcher. (Ignatius Reza, rspec/rspec-rails#2117) ### 3.9.0 / 2019-10-08 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.8.3...v3.9.0) @@ -353,18 +376,18 @@ Bug Fixes: Enhancements * Use `__dir__` instead of `__FILE__` in generated `rails_helper.rb` where - supported. (OKURA Masafumi, #2048) + supported. (OKURA Masafumi, rspec/rspec-rails#2048) * Add `have_enqueued_mail` matcher as a "super" matcher to the `ActiveJob` matchers - making it easier to match on `ActiveJob` delivered emails. (Joel Lubrano, #2047) -* Add generator for system specs on Rails 5.1 and above. (Andrzej Sliwa, #1933) -* Add generator for generator specs. (@ConSou, #2085) -* Add option to generate routes when generating controller specs. (David Revelo, #2134) + making it easier to match on `ActiveJob` delivered emails. (Joel Lubrano, rspec/rspec-rails#2047) +* Add generator for system specs on Rails 5.1 and above. (Andrzej Sliwa, rspec/rspec-rails#1933) +* Add generator for generator specs. (@ConSou, rspec/rspec-rails#2085) +* Add option to generate routes when generating controller specs. (David Revelo, rspec/rspec-rails#2134) Bug Fixes: * Make the `ActiveJob` matchers fail when multiple jobs are queued for negated matches. e.g. `expect { job; job; }.to_not have_enqueued_job`. - (Emric Istanful, #2069) + (Emric Istanful, rspec/rspec-rails#2069) ### 3.8.3 / 2019-10-03 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.8.2...v3.8.3) @@ -372,9 +395,9 @@ Bug Fixes: Bug Fixes: * Namespaced fixtures now generate a `/` separated path rather than an `_`. - (@nxlith, #2077) + (@nxlith, rspec/rspec-rails#2077) * Check the arity of `errors` before attempting to use it to generate the `be_valid` - error message. (Kevin Kuchta, #2096) + error message. (Kevin Kuchta, rspec/rspec-rails#2096) ### 3.8.2 / 2019-01-13 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.8.1...v3.8.2) @@ -382,13 +405,13 @@ Bug Fixes: Bug Fixes: * Fix issue with generator for preview specs where `Mailer` would be duplicated - in the name. (Kohei Sugi, #2037) -* Fix the request spec generator to handle namespaced files. (Kohei Sugi, #2057) + in the name. (Kohei Sugi, rspec/rspec-rails#2037) +* Fix the request spec generator to handle namespaced files. (Kohei Sugi, rspec/rspec-rails#2057) * Further truncate system test filenames to handle cases when extra words are - prepended. (Takumi Kaji, #2058) + prepended. (Takumi Kaji, rspec/rspec-rails#2058) * Backport: Make the `ActiveJob` matchers fail when multiple jobs are queued for negated matches. e.g. `expect { job; job; }.to_not have_enqueued_job - (Emric Istanful, #2069) + (Emric Istanful, rspec/rspec-rails#2069) ### 3.8.1 / 2018-10-23 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.8.0...v3.8.1) @@ -396,11 +419,11 @@ Bug Fixes: Bug Fixes: * Fix `NoMethodError: undefined method 'strip'` when using a `Pathname` object - as the fixture file path. (Aaron Kromer, #2026) + as the fixture file path. (Aaron Kromer, rspec/rspec-rails#2026) * When generating feature specs, do not duplicate namespace in the path name. - (Laura Paakkinen, #2034) + (Laura Paakkinen, rspec/rspec-rails#2034) * Prevent `ActiveJob::DeserializationError` from being issued when `ActiveJob` - matchers de-serialize arguments. (@aymeric-ledorze, #2036) + matchers de-serialize arguments. (@aymeric-ledorze, rspec/rspec-rails#2036) ### 3.8.0 / 2018-08-04 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.7.2...v3.8.0) @@ -408,25 +431,25 @@ Bug Fixes: Enhancements: * Improved message when migrations are pending in the default `rails_helper.rb` - (Koichi ITO, #1924) + (Koichi ITO, rspec/rspec-rails#1924) * `have_http_status` matcher now supports Rails 5.2 style response symbols - (Douglas Lovell, #1951) + (Douglas Lovell, rspec/rspec-rails#1951) * Change generated Rails helper to match Rails standards for Rails.root - (Alessandro Rodi, #1960) + (Alessandro Rodi, rspec/rspec-rails#1960) * At support for asserting enqueued jobs have no wait period attached. - (Brad Charna, #1977) + (Brad Charna, rspec/rspec-rails#1977) * Cache instances of `ActionView::Template` used in `stub_template` resulting - in increased performance due to less allocations and setup. (Simon Coffey, #1979) + in increased performance due to less allocations and setup. (Simon Coffey, rspec/rspec-rails#1979) * Rails scaffold generator now respects longer namespaces (e.g. api/v1/\). - (Laura Paakkinen, #1958) + (Laura Paakkinen, rspec/rspec-rails#1958) Bug Fixes: * Escape quotation characters when producing method names for system spec - screenshots. (Shane Cavanaugh, #1955) + screenshots. (Shane Cavanaugh, rspec/rspec-rails#1955) * Use relative path for resolving fixtures when `fixture_path` is not set. - (Laurent Cobos, #1943) -* Allow custom template resolvers in view specs. (@ahorek, #1941) + (Laurent Cobos, rspec/rspec-rails#1943) +* Allow custom template resolvers in view specs. (@ahorek, rspec/rspec-rails#1941) ### 3.7.2 / 2017-11-20 @@ -434,16 +457,16 @@ Bug Fixes: Bug Fixes: -* Delay loading system test integration until used. (Jon Rowe, #1903) +* Delay loading system test integration until used. (Jon Rowe, rspec/rspec-rails#1903) * Ensure specs using the aggregate failures feature take screenshots on failure. - (Matt Brictson, #1907) + (Matt Brictson, rspec/rspec-rails#1907) ### 3.7.1 / 2017-10-18 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.7.0...v3.7.1) Bug Fixes: -* Prevent system test integration loading when puma or capybara are missing (Sam Phippen, #1884) +* Prevent system test integration loading when puma or capybara are missing (Sam Phippen, rspec/rspec-rails#1884) ### 3.7.0 / 2017-10-17 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.6.0...v3.7.0) @@ -451,27 +474,27 @@ Bug Fixes: Bug Fixes: * Prevent "template not rendered" log message from erroring in threaded - environments. (Samuel Cochran, #1831) -* Correctly generate job name in error message. (Wojciech Wnętrzak, #1814) + environments. (Samuel Cochran, rspec/rspec-rails#1831) +* Correctly generate job name in error message. (Wojciech Wnętrzak, rspec/rspec-rails#1814) Enhancements: * Allow `be_a_new(...).with(...)` matcher to accept matchers for - attribute values. (Britni Alexander, #1811) -* Only configure RSpec Mocks if it is fully loaded. (James Adam, #1856) -* Integrate with `ActionDispatch::SystemTestCase`. (Sam Phippen, #1813) + attribute values. (Britni Alexander, rspec/rspec-rails#1811) +* Only configure RSpec Mocks if it is fully loaded. (James Adam, rspec/rspec-rails#1856) +* Integrate with `ActionDispatch::SystemTestCase`. (Sam Phippen, rspec/rspec-rails#1813) ### 3.6.0 / 2017-05-04 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.6.0.beta2...v3.6.0) Enhancements: -* Add compatibility for Rails 5.1. (Sam Phippen, Yuichiro Kaneko, #1790) +* Add compatibility for Rails 5.1. (Sam Phippen, Yuichiro Kaneko, rspec/rspec-rails#1790) Bug Fixes: * Fix scaffold generator so that it does not generate broken controller specs - on Rails 3.x and 4.x. (Yuji Nakayama, #1710) + on Rails 3.x and 4.x. (Yuji Nakayama, rspec/rspec-rails#1710) ### 3.6.0.beta2 / 2016-12-12 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.6.0.beta1...v3.6.0.beta2) @@ -479,19 +502,19 @@ Bug Fixes: Enhancements: * Improve failure output of ActiveJob matchers by listing queued jobs. - (Wojciech Wnętrzak, #1722) + (Wojciech Wnętrzak, rspec/rspec-rails#1722) * Load `spec_helper.rb` earlier in `rails_helper.rb` by default. - (Kevin Glowacz, #1795) + (Kevin Glowacz, rspec/rspec-rails#1795) ### 3.6.0.beta1 / 2016-10-09 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.5.2...v3.6.0.beta1) Enhancements: -* Add support for `rake notes` in Rails `>= 5.1`. (John Meehan, #1661) +* Add support for `rake notes` in Rails `>= 5.1`. (John Meehan, rspec/rspec-rails#1661) * Remove `assigns` and `assert_template` from scaffold spec generators (Josh - Justice, #1689) -* Add support for generating scaffolds for api app specs. (Krzysztof Zych, #1685) + Justice, rspec/rspec-rails#1689) +* Add support for generating scaffolds for api app specs. (Krzysztof Zych, rspec/rspec-rails#1685) ### 3.5.2 / 2016-08-26 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.5.1...v3.5.2) @@ -499,9 +522,9 @@ Enhancements: Bug Fixes: * Stop unnecessarily loading `rspec/core` from `rspec/rails` to avoid - IRB context warning. (Myron Marston, #1678) + IRB context warning. (Myron Marston, rspec/rspec-rails#1678) * Deserialize arguments within ActiveJob matchers correctly. - (Wojciech Wnętrzak, #1684) + (Wojciech Wnętrzak, rspec/rspec-rails#1684) ### 3.5.1 / 2016-07-08 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.5.0...v3.5.1) @@ -522,30 +545,30 @@ Bug Fixes: Enhancements: -* Add support for block when using `with` on `have_enqueued_job`. (John Schroeder, #1578) -* Add support for `file_fixture(...)`. (Wojciech Wnętrzak, #1587) -* Add support for `setup` and `teardown` with blocks (Miklós Fazekas, #1598) +* Add support for block when using `with` on `have_enqueued_job`. (John Schroeder, rspec/rspec-rails#1578) +* Add support for `file_fixture(...)`. (Wojciech Wnętrzak, rspec/rspec-rails#1587) +* Add support for `setup` and `teardown` with blocks (Miklós Fazekas, rspec/rspec-rails#1598) * Add `enqueue_job ` alias for `have_enqueued_job`, support `once`/`twice`/ `thrice`, add `have_been_enqueued` matcher to support use without blocks. - (Sergey Alexandrovich, #1613) + (Sergey Alexandrovich, rspec/rspec-rails#1613) Bug fixes: -* Prevent asset helpers from taking precedence over route helpers. (Prem Sichanugrist, #1496) +* Prevent asset helpers from taking precedence over route helpers. (Prem Sichanugrist, rspec/rspec-rails#1496) * Prevent `NoMethodError` during failed `have_rendered` assertions on weird templates. - (Jon Rowe, #1623). + (Jon Rowe, rspec/rspec-rails#1623). ### 3.5.0.beta3 / 2016-04-02 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.5.0.beta2...v3.5.0.beta3) Enhancements: -* Add support for Rails 5 Beta 3 (Sam Phippen, Benjamin Quorning, Koen Punt, #1589, #1573) +* Add support for Rails 5 Beta 3 (Sam Phippen, Benjamin Quorning, Koen Punt, rspec/rspec-rails#1589, rspec/rspec-rails#1573) Bug fixes: * Support custom resolvers when preventing views from rendering. - (Jon Rowe, Benjamin Quorning, #1580) + (Jon Rowe, Benjamin Quorning, rspec/rspec-rails#1580) ### 3.5.0.beta2 / 2016-03-10 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.5.0.beta1...v3.5.0.beta2) @@ -554,12 +577,12 @@ Enhancements: * Include `ActionDispatch::IntegrationTest::Behavior` in request spec example groups when on Rails 5, allowing integration test helpers - to be used in request specs. (Scott Bronson, #1560) + to be used in request specs. (Scott Bronson, rspec/rspec-rails#1560) Bug fixes: * Make it possible to use floats in auto generated (scaffold) tests. - (Alwahsh, #1550) + (Alwahsh, rspec/rspec-rails#1550) ### 3.5.0.beta1 / 2016-02-06 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.4.2...v3.5.0.beta1) @@ -567,20 +590,20 @@ Bug fixes: Enhancements: * Add a `--singularize` option for the feature spec generator (Felicity McCabe, - #1503) -* Prevent leaking TestUnit methods in Rails 4+ (Fernando Seror Garcia, #1512) -* Add support for Rails 5 (Sam Phippen, #1492) + rspec/rspec-rails#1503) +* Prevent leaking TestUnit methods in Rails 4+ (Fernando Seror Garcia, rspec/rspec-rails#1512) +* Add support for Rails 5 (Sam Phippen, rspec/rspec-rails#1492) Bug fixes: * Make it possible to write nested specs within helper specs on classes that are - internal to helper classes. (Sam Phippen, Peter Swan, #1499). + internal to helper classes. (Sam Phippen, Peter Swan, rspec/rspec-rails#1499). * Warn if a fixture method is called from a `before(:context)` block, instead of - crashing with a `undefined method for nil:NilClass`. (Sam Phippen, #1501) -* Expose path to view specs (Ryan Clark, Sarah Mei, Sam Phippen, #1402) -* Prevent installing Rails 3.2.22.1 on Ruby 1.8.7. (Jon Rowe, #1540) + crashing with a `undefined method for nil:NilClass`. (Sam Phippen, rspec/rspec-rails#1501) +* Expose path to view specs (Ryan Clark, Sarah Mei, Sam Phippen, rspec/rspec-rails#1402) +* Prevent installing Rails 3.2.22.1 on Ruby 1.8.7. (Jon Rowe, rspec/rspec-rails#1540) * Raise a clear error when `have_enqueued_job` is used with non-test - adapter. (Wojciech Wnętrzak, #1489) + adapter. (Wojciech Wnętrzak, rspec/rspec-rails#1489) ### 3.4.2 / 2016-02-02 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.4.1...v3.4.2) @@ -588,7 +611,7 @@ Bug fixes: Bug Fixes: * Cache template resolvers during path lookup to prevent performance - regression from #1535. (Andrew White, #1544) + regression from rspec/rspec-rails#1535. (Andrew White, rspec/rspec-rails#1544) ### 3.4.1 / 2016-01-25 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.4.0...v3.4.1) @@ -596,7 +619,7 @@ Bug Fixes: Bug Fixes: * Fix no method error when rendering templates with explicit `:file` - parameters for Rails version `4.2.5.1`. (Andrew White, Sam Phippen, #1535) + parameters for Rails version `4.2.5.1`. (Andrew White, Sam Phippen, rspec/rspec-rails#1535) ### 3.4.0 / 2015-11-11 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.3.3...v3.4.0) @@ -604,20 +627,20 @@ Bug Fixes: Enhancements: * Improved the failure message for `have_rendered` matcher on a redirect - response. (Alex Egan, #1440) + response. (Alex Egan, rspec/rspec-rails#1440) * Add configuration option to filter out Rails gems from backtraces. - (Bradley Schaefer, #1458) + (Bradley Schaefer, rspec/rspec-rails#1458) * Enable resolver cache for view specs for a large speed improvement - (Chris Zetter, #1452) + (Chris Zetter, rspec/rspec-rails#1452) * Add `have_enqueued_job` matcher for checking if a block has queued jobs. - (Wojciech Wnętrzak, #1464) + (Wojciech Wnętrzak, rspec/rspec-rails#1464) Bug Fixes: * Fix another load order issued which causes an undefined method `fixture_path` error - when loading rspec-rails after a spec has been created. (Nikki Murray, #1430) + when loading rspec-rails after a spec has been created. (Nikki Murray, rspec/rspec-rails#1430) * Removed incorrect surrounding whitespace in the rspec-rails backtrace - exclusion pattern for its own `lib` code. (Jam Black, #1439) + exclusion pattern for its own `lib` code. (Jam Black, rspec/rspec-rails#1439) ### 3.3.3 / 2015-07-15 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.3.2...v3.3.3) @@ -625,7 +648,7 @@ Bug Fixes: Bug Fixes: * Fix issue with generators caused by `Rails.configuration.hidden_namespaces` - including symbols. (Dan Kohn, #1414) + including symbols. (Dan Kohn, rspec/rspec-rails#1414) ### 3.3.2 / 2015-06-18 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.3.1...v3.3.2) @@ -635,7 +658,7 @@ Bug Fixes: * Fix regression that caused stubbing abstract ActiveRecord model classes to trigger internal errors in rails due the the verifying double lifecycle wrongly calling `define_attribute_methods` on the - abstract AR class. (Jon Rowe, #1396) + abstract AR class. (Jon Rowe, rspec/rspec-rails#1396) ### 3.3.1 / 2015-06-14 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.3.0...v3.3.1) @@ -643,25 +666,25 @@ Bug Fixes: Bug Fixes: * Fix regression that caused stubbing ActiveRecord model classes to - trigger internal errors in rails. (Myron Marston, Aaron Kromer, #1395) + trigger internal errors in rails. (Myron Marston, Aaron Kromer, rspec/rspec-rails#1395) ### 3.3.0 / 2015-06-12 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.2.3...v3.3.0) Enhancements: -* Add support for PATCH to route specs created via scaffold. (Igor Zubkov, #1336) +* Add support for PATCH to route specs created via scaffold. (Igor Zubkov, rspec/rspec-rails#1336) * Improve controller and routing spec calls to `routes` by using `yield` - instead of `call`. (Anton Davydov, #1308) + instead of `call`. (Anton Davydov, rspec/rspec-rails#1308) * Add support for `ActiveJob` specs as standard `RSpec::Rails::RailsExampleGroup`s via both `type: :job` and inferring type from spec directory `spec/jobs`. - (Gabe Martin-Dempesy, #1361) + (Gabe Martin-Dempesy, rspec/rspec-rails#1361) * Include `RSpec::Rails::FixtureSupport` into example groups using metadata - `use_fixtures: true`. (Aaron Kromer, #1372) + `use_fixtures: true`. (Aaron Kromer, rspec/rspec-rails#1372) * Include `rspec:request` generator for generating request specs; this is an - alias of `rspec:integration` (Aaron Kromer, #1378) + alias of `rspec:integration` (Aaron Kromer, rspec/rspec-rails#1378) * Update `rails_helper` generator with a default check to abort the spec run - when the Rails environment is production. (Aaron Kromer, #1383) + when the Rails environment is production. (Aaron Kromer, rspec/rspec-rails#1383) ### 3.2.3 / 2015-06-06 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.2.2...v3.2.3) @@ -669,7 +692,7 @@ Enhancements: Bug Fixes: * Fix regression with the railtie resulting in undefined method `preview_path=` - on Rails 3.x and 4.0 (Aaron Kromer, #1388) + on Rails 3.x and 4.0 (Aaron Kromer, rspec/rspec-rails#1388) ### 3.2.2 / 2015-06-03 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.2.1...v3.2.2) @@ -677,12 +700,12 @@ Bug Fixes: Bug Fixes: * Fix auto-including of generic `Helper` object for view specs sitting in the - `app/views` root (David Daniell, #1289) -* Remove pre-loading of ActionMailer in the Railtie (Aaron Kromer, #1327) + `app/views` root (David Daniell, rspec/rspec-rails#1289) +* Remove pre-loading of ActionMailer in the Railtie (Aaron Kromer, rspec/rspec-rails#1327) * Fix undefined method `need_auto_run=` error when using Ruby 2.1 and Rails 3.2 - without the test-unit gem (Orien Madgwick, #1350) + without the test-unit gem (Orien Madgwick, rspec/rspec-rails#1350) * Fix load order issued which causes an undefined method `fixture_path` error - when loading rspec-rails after a spec has been created. (Aaron Kromer, #1372) + when loading rspec-rails after a spec has been created. (Aaron Kromer, rspec/rspec-rails#1372) ### 3.2.1 / 2015-02-23 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.2.0...v3.2.1) @@ -690,71 +713,71 @@ Bug Fixes: Bug Fixes: * Add missing `require` to RSpec generator root fixing an issue where Rail's - autoload does not find it in some environments. (Aaron Kromer, #1305) -* `be_routable` matcher now has the correct description. (Tony Ta, #1310) -* Fix dependency to allow Rails 4.2.x patches / pre-releases (Lucas Mazza, #1318) + autoload does not find it in some environments. (Aaron Kromer, rspec/rspec-rails#1305) +* `be_routable` matcher now has the correct description. (Tony Ta, rspec/rspec-rails#1310) +* Fix dependency to allow Rails 4.2.x patches / pre-releases (Lucas Mazza, rspec/rspec-rails#1318) * Disable the `test-unit` gem's autorunner on projects running Rails < 4.1 and - Ruby < 2.2 (Aaron Kromer, #1320) + Ruby < 2.2 (Aaron Kromer, rspec/rspec-rails#1320) ### 3.2.0 / 2015-02-03 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.1.0...v3.2.0) Enhancements: -* Include generator for `ActionMailer` mailer previews (Takashi Nakagawa, #1185) -* Configure the `ActionMailer` preview path via a Railtie (Aaron Kromer, #1236) -* Show all RSpec generators when running `rails generate` (Eliot Sykes, #1248) -* Support Ruby 2.2 with Rails 3.2 and 4.x (Aaron Kromer, #1264, #1277) +* Include generator for `ActionMailer` mailer previews (Takashi Nakagawa, rspec/rspec-rails#1185) +* Configure the `ActionMailer` preview path via a Railtie (Aaron Kromer, rspec/rspec-rails#1236) +* Show all RSpec generators when running `rails generate` (Eliot Sykes, rspec/rspec-rails#1248) +* Support Ruby 2.2 with Rails 3.2 and 4.x (Aaron Kromer, rspec/rspec-rails#1264, rspec/rspec-rails#1277) * Improve `instance_double` to support verifying dynamic column methods defined - by `ActiveRecord` (Jon Rowe, #1238) + by `ActiveRecord` (Jon Rowe, rspec/rspec-rails#1238) * Mirror the use of Ruby 1.9 hash syntax for the `type` tags in the spec - generators on Rails 4. (Michael Stock, #1292) + generators on Rails 4. (Michael Stock, rspec/rspec-rails#1292) Bug Fixes: * Fix `rspec:feature` generator to use `RSpec` namespace preventing errors when - monkey-patching is disabled. (Rebecca Skinner, #1231) + monkey-patching is disabled. (Rebecca Skinner, rspec/rspec-rails#1231) * Fix `NoMethodError` caused by calling `RSpec.feature` when Capybara is not - available or the Capybara version is < 2.4.0. (Aaron Kromer, #1261) + available or the Capybara version is < 2.4.0. (Aaron Kromer, rspec/rspec-rails#1261) * Fix `ArgumentError` when using an anonymous controller which inherits an - outer group's anonymous controller. (Yuji Nakayama, #1260) + outer group's anonymous controller. (Yuji Nakayama, rspec/rspec-rails#1260) * Fix "Test is not a class (TypeError)" error when using a custom `Test` class - in Rails 4.1 and 4.2. (Aaron Kromer, #1295) + in Rails 4.1 and 4.2. (Aaron Kromer, rspec/rspec-rails#1295) ### 3.1.0 / 2014-09-04 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.0.2...v3.1.0) Enhancements: -* Switch to using the `have_http_status` matcher in spec generators. (Aaron Kromer, #1086) +* Switch to using the `have_http_status` matcher in spec generators. (Aaron Kromer, rspec/rspec-rails#1086) * Update `rails_helper` generator to allow users to opt-in to auto-loading - `spec/support` files instead of forcing it upon them. (Aaron Kromer, #1137) -* Include generator for `ActiveJob`. (Abdelkader Boudih, #1155) + `spec/support` files instead of forcing it upon them. (Aaron Kromer, rspec/rspec-rails#1137) +* Include generator for `ActiveJob`. (Abdelkader Boudih, rspec/rspec-rails#1155) * Improve support for non-ActiveRecord apps by not loading ActiveRecord related - settings in the generated `rails_helper`. (Aaron Kromer, #1150) -* Remove Ruby warnings as a suggested configuration. (Aaron Kromer, #1163) -* Improve the semantics of the controller spec for scaffolds. (Griffin Smith, #1204) -* Use `#method` syntax in all generated controller specs. (Griffin Smith, #1206) + settings in the generated `rails_helper`. (Aaron Kromer, rspec/rspec-rails#1150) +* Remove Ruby warnings as a suggested configuration. (Aaron Kromer, rspec/rspec-rails#1163) +* Improve the semantics of the controller spec for scaffolds. (Griffin Smith, rspec/rspec-rails#1204) +* Use `#method` syntax in all generated controller specs. (Griffin Smith, rspec/rspec-rails#1206) Bug Fixes: -* Fix controller route lookup for Rails 4.2. (Tomohiro Hashidate, #1142) +* Fix controller route lookup for Rails 4.2. (Tomohiro Hashidate, rspec/rspec-rails#1142) ### 3.0.2 / 2014-07-21 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.0.1...v3.0.2) Bug Fixes: -* Suppress warning in `SetupAndTeardownAdapter`. (André Arko, #1085) -* Remove dependency on Rubygems. (Andre Arko & Doc Riteze, #1099) -* Standardize controller spec template style. (Thomas Kriechbaumer, #1122) +* Suppress warning in `SetupAndTeardownAdapter`. (André Arko, rspec/rspec-rails#1085) +* Remove dependency on Rubygems. (Andre Arko & Doc Riteze, rspec/rspec-rails#1099) +* Standardize controller spec template style. (Thomas Kriechbaumer, rspec/rspec-rails#1122) ### 3.0.1 / 2014-06-02 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.0.0...v3.0.1) Bug Fixes: -* Fix missing require in `rails g rspec:install`. (Sam Phippen, #1058) +* Fix missing require in `rails g rspec:install`. (Sam Phippen, rspec/rspec-rails#1058) ### 3.0.0 / 2014-06-01 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.0.0.rc1...v3.0.0) diff --git a/Gemfile b/Gemfile index 688f8d499..5df5cc6e4 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ group :documentation do end gem 'capybara' -gem 'ffi', '~> 1.15.5' +gem 'ffi', '> 1.15.5' gem 'rake', '> 12' gem 'rubocop', '~> 1.28.2' diff --git a/Gemfile-rails-dependencies b/Gemfile-rails-dependencies index 0d08d7663..21a8eede9 100644 --- a/Gemfile-rails-dependencies +++ b/Gemfile-rails-dependencies @@ -11,13 +11,15 @@ def add_net_gems_dependency end end -def add_sqlite3_gem_dependency - # sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4` +def add_sqlite3_gem_dependency(rails_version) + # sqlite3 is an optional, unspecified, dependency and Rails 8.0 only supports `~> 2.0` if RUBY_VERSION.to_f < 3 # sqlite3 1.7.x doesn't work on all platforms for Ruby 2.x gem 'sqlite3', '~> 1.4', '< 1.7', platforms: [:ruby] + elsif rails_version.to_f >= 8 + gem 'sqlite3', '~> 2.0', platforms: [:ruby] else - gem 'sqlite3', '~> 1.4', platforms: [:ruby] + gem 'sqlite3', '~> 1.7', platforms: [:ruby] end end @@ -29,24 +31,25 @@ when /main/ gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby] gem 'selenium-webdriver', require: false - # Rails 8 requires 2.0.0 gem 'sqlite3', '~> 2.0', platforms: [:ruby] -when /stable$/ - gem_list = %w[rails railties actionmailer actionpack activerecord activesupport activejob actionview] - gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby] - - gem_list.each do |rails_gem| - gem rails_gem, :git => "https://github.com/rails/rails.git", :branch => version - end - add_sqlite3_gem_dependency when nil, false, "" - gem "rails", "~> 7.0.0" + if RUBY_VERSION.to_f > 3.1 + gem "rails", "~> 8.0.0" + gem 'sqlite3', '~> 2.0', platforms: [:ruby] + elsif RUBY_VERSION.to_f > 3.0 + gem "rails", "~> 7.2.0" + gem 'sqlite3', '~> 1.7', platforms: [:ruby] + else + gem "rails", "~> 7.1.0" + gem 'sqlite3', '~> 1.7', platforms: [:ruby] + end + gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby] gem 'selenium-webdriver', require: false - add_sqlite3_gem_dependency else version_number = version.split(' ').last - add_net_gems_dependency if version_number < '7.0' + + gem 'concurrent-ruby', '1.3.4' if version_number < '7.1' gem "rails", version gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby] @@ -58,5 +61,5 @@ else else gem 'selenium-webdriver', require: false end - add_sqlite3_gem_dependency + add_sqlite3_gem_dependency(version_number) end diff --git a/Gemfile-rspec-dependencies b/Gemfile-rspec-dependencies index a0af7b2f5..e68e5fdb8 100644 --- a/Gemfile-rspec-dependencies +++ b/Gemfile-rspec-dependencies @@ -1,13 +1,9 @@ branch = File.read(File.expand_path("../maintenance-branch", __FILE__)).chomp %w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib| - library_path = File.expand_path("../../#{lib}", __FILE__) + library_path = File.expand_path("../../rspec/#{lib}", __FILE__) if File.exist?(library_path) && !ENV['USE_GIT_REPOS'] - gem lib, :path => library_path, :require => false + gem lib, path: library_path, require: false else - if lib == 'rspec' - gem 'rspec', :git => "https://github.com/rspec/rspec-metagem.git", :branch => branch, :require => false - else - gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => branch, :require => false - end + gem lib, git: "https://github.com/rspec/rspec", glob: "#{lib}/#{lib}.gemspec" end end diff --git a/README.md b/README.md index e000e0140..b62729988 100644 --- a/README.md +++ b/README.md @@ -27,13 +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` 7.x]: https://github.com/rspec/rspec-rails/tree/7-1-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 [`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. +See the [`7-1-maintenance` branch on Github](https://github.com/rspec/rspec-rails/tree/7-1-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`: @@ -45,11 +45,8 @@ See the [`7-0-maintenance` branch on Github](https://github.com/rspec/rspec-rail end # Or, run against the main branch - # (requires main-branch versions of all related RSpec libraries) group :development, :test do - %w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib| - gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'main' - end + gem 'rspec-rails', git: 'https://github.com/rspec/rspec-rails' end ``` @@ -88,7 +85,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/7-0/rspec-rails/upgrade +[`rspec-rails` upgrade notes]: https://rspec.info/features/7-1/rspec-rails/upgrade [RSpec upgrade notes]: https://rspec.info/upgrading-from-rspec-2/ ## Usage @@ -210,22 +207,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/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 +[`be_a_new`]: https://rspec.info/features/7-1/rspec-rails/matchers/new-record-matcher +[`render_template`]: https://rspec.info/features/7-1/rspec-rails/matchers/render-template-matcher +[`redirect_to`]: https://rspec.info/features/7-1/rspec-rails/matchers/redirect-to-matcher +[`route_to`]: https://rspec.info/features/7-1/rspec-rails/routing-specs/route-to-matcher +[`be_routable`]: https://rspec.info/features/7-1/rspec-rails/routing-specs/be-routable-matcher +[`have_http_status`]: https://rspec.info/features/7-1/rspec-rails/matchers/have-http-status-matcher +[`match_array`]: https://rspec.info/features/7-1/rspec-rails/matchers/relation-match-array +[`have_been_enqueued`]: https://rspec.info/features/7-1/rspec-rails/matchers/have-been-enqueued-matcher +[`have_enqueued_job`]: https://rspec.info/features/7-1/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/7-0/rspec-rails +[official Cucumber documentation]: https://rspec.info/features/7-1/rspec-rails ## What tests should I write? @@ -270,20 +267,20 @@ RSpec.describe User, type: :model do ... ``` -[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 +[request]: https://rspec.info/features/7-1/rspec-rails/request-specs/request-spec +[feature]: https://rspec.info/features/7-1/rspec-rails/feature-specs/feature-spec +[system]: https://rspec.info/features/7-1/rspec-rails/system-specs/system-specs +[model]: https://rspec.info/features/7-1/rspec-rails/model-specs +[controller]: https://rspec.info/features/7-1/rspec-rails/controller-specs +[mailer]: https://rspec.info/features/7-1/rspec-rails/mailer-specs +[job]: https://rspec.info/features/7-1/rspec-rails/job-specs/job-spec +[view]: https://rspec.info/features/7-1/rspec-rails/view-specs/view-spec +[routing]: https://rspec.info/features/7-1/rspec-rails/routing-specs +[helper]: https://rspec.info/features/7-1/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/7-0/rspec-rails/directory-structure +[in the appropriate folder]: https://rspec.info/features/7-1/rspec-rails/directory-structure ### System specs, feature specs, request specs–what’s the difference? @@ -367,9 +364,6 @@ you can run the specs and Cucumber features, or submit a pull request. ### RSpec base libraries * https://github.com/rspec/rspec -* https://github.com/rspec/rspec-core -* https://github.com/rspec/rspec-expectations -* https://github.com/rspec/rspec-mocks ### Recommended third-party extensions diff --git a/benchmarks/before_block_capture_block_vs_yield.rb b/benchmarks/before_block_capture_block_vs_yield.rb index e294c0683..e8be2954a 100644 --- a/benchmarks/before_block_capture_block_vs_yield.rb +++ b/benchmarks/before_block_capture_block_vs_yield.rb @@ -42,11 +42,11 @@ def capture_block_and_call_n_times(n, &block) example context. rspec-core has already performed [many related benchmarks about -this](https://github.com/rspec/rspec-core/tree/main/benchmarks): +this](https://github.com/rspec/rspec/tree/main/rspec-core/benchmarks): -- [call vs yield](https://github.com/rspec/rspec-core/blob/main/benchmarks/call_v_yield.rb) -- [capture block vs yield](https://github.com/rspec/rspec-core/blob/main/benchmarks/capture_block_vs_yield.rb) -- [flat map vs inject](https://github.com/rspec/rspec-core/blob/main/benchmarks/flat_map_vs_inject.rb) +- [call vs yield](https://github.com/rspec/rspec/blob/main/rspec-core/benchmarks/call_v_yield.rb) +- [capture block vs yield](https://github.com/rspec/rspec/blob/main/rspec-core/benchmarks/capture_block_vs_yield.rb) +- [flat map vs inject](https://github.com/rspec/rspec/blob/main/rspec-core/benchmarks/flat_map_vs_inject.rb) The results are very interesting: @@ -64,7 +64,7 @@ def capture_block_and_call_n_times(n, &block) > See also `flat_map_vs_inject.rb`, which appears to contradict these > results a little bit. > -> -- https://github.com/rspec/rspec-core/blob/main/benchmarks/capture_block_vs_yield.rb#L83-L95 +> -- https://github.com/rspec/rspec/blob/main/rspec-core/benchmarks/capture_block_vs_yield.rb#L83-L95 and @@ -75,7 +75,7 @@ def capture_block_and_call_n_times(n, &block) > version remains faster in my benchmarks here no matter how small > I shrink the `words` array. I'm not sure why! > -> -- https://github.com/rspec/rspec-core/blob/main/benchmarks/flat_map_vs_inject.rb#L37-L42 +> -- https://github.com/rspec/rspec/blob/main/rspec-core/benchmarks/flat_map_vs_inject.rb#L37-L42 This seems to show that the error margin is enough to negate any benefit from capturing the block initially. It also shows that not capturing the block is diff --git a/example_app_generator/generate_app.rb b/example_app_generator/generate_app.rb index aaa727663..77e99bffc 100644 --- a/example_app_generator/generate_app.rb +++ b/example_app_generator/generate_app.rb @@ -35,7 +35,7 @@ elsif Rails::VERSION::STRING > '8' gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 2.0'" else - gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'" + gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.7'" end # remove webdrivers diff --git a/example_app_generator/spec/support/default_preview_path b/example_app_generator/spec/support/default_preview_path index 6ce03ef52..98ee5acf7 100755 --- a/example_app_generator/spec/support/default_preview_path +++ b/example_app_generator/spec/support/default_preview_path @@ -7,6 +7,7 @@ end ENV['RAILS_ENV'] ||= 'development' # Pick the frameworks you want: begin + require "openssl" require "active_storage" require "active_storage/engine" rescue LoadError diff --git a/example_app_generator/spec/verify_mailer_preview_path_spec.rb b/example_app_generator/spec/verify_mailer_preview_path_spec.rb index 68bb840a4..d045d4c3e 100644 --- a/example_app_generator/spec/verify_mailer_preview_path_spec.rb +++ b/example_app_generator/spec/verify_mailer_preview_path_spec.rb @@ -40,12 +40,6 @@ def capture_exec(*ops) CaptureExec.new(out, $?.exitstatus) end - if ENV['RAILS_VERSION'] == 'main' && Rails::VERSION::STRING == "8.0.0.alpha" - before do - skip('This is broken on Rails main but is skipped for green builds, please fix') - end - end - if Rails::VERSION::STRING.to_f >= 7.1 let(:expected_custom_path) { "/custom/path\n#{::Rails.root}/test/mailers/previews" } let(:expected_rspec_path) { "#{::Rails.root}/spec/mailers/previews\n#{::Rails.root}/test/mailers/previews" } diff --git a/lib/generators/rspec/authentication/authentication_generator.rb b/lib/generators/rspec/authentication/authentication_generator.rb new file mode 100644 index 000000000..f653c5c4e --- /dev/null +++ b/lib/generators/rspec/authentication/authentication_generator.rb @@ -0,0 +1,25 @@ +require 'generators/rspec' + +module Rspec + module Generators + # @private + class AuthenticationGenerator < Base + def initialize(args, *options) + args.replace(['User']) + super + end + + def create_user_spec + template 'user_spec.rb', target_path('models', 'user_spec.rb') + end + + hook_for :fixture_replacement + + def create_fixture_file + return if options[:fixture_replacement] + + template 'users.yml', target_path('fixtures', 'users.yml') + end + end + end +end diff --git a/lib/generators/rspec/authentication/templates/user_spec.rb b/lib/generators/rspec/authentication/templates/user_spec.rb new file mode 100644 index 000000000..4dfb2b069 --- /dev/null +++ b/lib/generators/rspec/authentication/templates/user_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe User, <%= type_metatag(:model) %> do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/lib/generators/rspec/authentication/templates/users.yml b/lib/generators/rspec/authentication/templates/users.yml new file mode 100644 index 000000000..d2eae44a2 --- /dev/null +++ b/lib/generators/rspec/authentication/templates/users.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +<%% password_digest = BCrypt::Password.create("password") %> + +one: + email_address: one@example.com + password_digest: <%%= password_digest %> + +two: + email_address: two@example.com + password_digest: <%%= password_digest %> diff --git a/lib/generators/rspec/install/templates/spec/rails_helper.rb b/lib/generators/rspec/install/templates/spec/rails_helper.rb index c31d1e9f3..0f3ef72ae 100644 --- a/lib/generators/rspec/install/templates/spec/rails_helper.rb +++ b/lib/generators/rspec/install/templates/spec/rails_helper.rb @@ -28,7 +28,9 @@ # Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f } <% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%> -# Checks for pending migrations and applies them before tests are run. +# Ensures that the test database schema matches the current schema file. +# If there are pending migrations it will invoke `db:test:prepare` to +# recreate the test database by loading the schema. # If you are not using ActiveRecord, you can remove these lines. begin ActiveRecord::Migration.maintain_test_schema! @@ -75,7 +77,7 @@ # end # # The different available types are documented in the features, such as in - # https://rspec.info/features/7-0/rspec-rails + # https://rspec.info/features/7-1/rspec-rails # # You can also this infer these behaviours automatically by location, e.g. # /spec/models would pull in the same behaviour as `type: :model` but this diff --git a/lib/rspec/rails/example/system_example_group.rb b/lib/rspec/rails/example/system_example_group.rb index b66b8fbbf..9a5feef8f 100644 --- a/lib/rspec/rails/example/system_example_group.rb +++ b/lib/rspec/rails/example/system_example_group.rb @@ -153,6 +153,12 @@ def driven_by(driver, **driver_options, &blk) @driver = ::ActionDispatch::SystemTestCase.driven_by(driver, **driver_options, &blk).tap(&:use) end + if ::Rails::VERSION::STRING.to_f >= 7.2 + def served_by(**options) + ::ActionDispatch::SystemTestCase.served_by(**options) + end + end + before do @routes = ::Rails.application.routes end diff --git a/lib/rspec/rails/matchers/active_job.rb b/lib/rspec/rails/matchers/active_job.rb index 40c676c0c..f3da81e48 100644 --- a/lib/rspec/rails/matchers/active_job.rb +++ b/lib/rspec/rails/matchers/active_job.rb @@ -178,6 +178,8 @@ def arguments_match?(job) end def detect_args_signature_mismatch(jobs) + return if skip_signature_verification? + jobs.each do |job| args = deserialize_arguments(job) @@ -189,6 +191,13 @@ def detect_args_signature_mismatch(jobs) nil end + def skip_signature_verification? + return true unless defined?(::RSpec::Mocks) && (::RSpec::Mocks.respond_to?(:configuration)) + + !RSpec::Mocks.configuration.verify_partial_doubles? || + RSpec::Mocks.configuration.temporarily_suppress_partial_double_verification + end + def check_args_signature_mismatch(job_class, job_method, args) signature = Support::MethodSignature.new(job_class.public_instance_method(job_method)) verifier = Support::StrictSignatureVerifier.new(signature, args) diff --git a/lib/rspec/rails/matchers/have_enqueued_mail.rb b/lib/rspec/rails/matchers/have_enqueued_mail.rb index 85aaea274..14f8f0111 100644 --- a/lib/rspec/rails/matchers/have_enqueued_mail.rb +++ b/lib/rspec/rails/matchers/have_enqueued_mail.rb @@ -93,6 +93,7 @@ def arguments_match?(job) def detect_args_signature_mismatch(jobs) return if @method_name.nil? + return if skip_signature_verification? mailer_class = mailer_class_name.constantize @@ -128,13 +129,13 @@ def unmatching_mail_jobs end def unmatching_mail_jobs_message - msg = "Queued deliveries:" + messages = ["Queued deliveries:"] unmatching_mail_jobs.each do |job| - msg << "\n #{mail_job_message(job)}" + messages << " #{mail_job_message(job)}" end - msg + messages.join("\n") end def mail_job_message(job) diff --git a/lib/rspec/rails/version.rb b/lib/rspec/rails/version.rb index 96fe5d6c7..e03e64027 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 = '7.1.0.pre' + STRING = '7.2.0.pre' end end end diff --git a/rspec-rails.gemspec b/rspec-rails.gemspec index 788977e11..dd8e24ea6 100644 --- a/rspec-rails.gemspec +++ b/rspec-rails.gemspec @@ -55,5 +55,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'ammeter', '~> 1.1.5' s.add_development_dependency 'aruba', '~> 0.14.12' - s.add_development_dependency 'cucumber', '~> 7.0' + s.add_development_dependency 'cucumber', '> 7.0' end diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index c2673e341..aa87daca6 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -11,9 +11,21 @@ function is_ruby_3_plus { fi } -if is_ruby_3_plus; then +function is_ruby_3_1_plus { + if ruby -e "exit(RUBY_VERSION.to_f >= 3.1)"; then + return 0 + else + return 1 + fi +} + + +if is_ruby_3_1_plus; then gem update --no-document --system gem install --no-document bundler +elif is_ruby_3_plus; then + gem update --no-document --system '3.5.23' + gem install --no-document bundler else gem update --no-document --system '3.4.22' gem install --no-document bundler diff --git a/spec/generators/rspec/authentication/authentication_generator_spec.rb b/spec/generators/rspec/authentication/authentication_generator_spec.rb new file mode 100644 index 000000000..e5590aedd --- /dev/null +++ b/spec/generators/rspec/authentication/authentication_generator_spec.rb @@ -0,0 +1,34 @@ +# Generators are not automatically loaded by Rails +require 'generators/rspec/authentication/authentication_generator' +require 'support/generators' + +RSpec.describe Rspec::Generators::AuthenticationGenerator, type: :generator do + setup_default_destination + + it 'runs both the model and fixture tasks' do + gen = generator + expect(gen).to receive :create_user_spec + expect(gen).to receive :create_fixture_file + gen.invoke_all + end + + describe 'the generated files' do + it 'creates the user spec' do + run_generator + + expect(File.exist?(file('spec/models/user_spec.rb'))).to be true + end + + describe 'with fixture replacement' do + before do + run_generator ['--fixture-replacement=factory_bot'] + end + + describe 'the fixtures' do + it "will skip the file" do + expect(File.exist?(file('spec/fixtures/users.yml'))).to be false + end + end + end + end +end diff --git a/spec/rspec/rails/example/system_example_group_spec.rb b/spec/rspec/rails/example/system_example_group_spec.rb index d9f3306c7..8a000a8c2 100644 --- a/spec/rspec/rails/example/system_example_group_spec.rb +++ b/spec/rspec/rails/example/system_example_group_spec.rb @@ -78,6 +78,21 @@ module RSpec::Rails expect(example).to have_received(:driven_by).once end + + it 'calls :served_by method only once', if: ::Rails::VERSION::STRING.to_f >= 7.2 do + group = RSpec::Core::ExampleGroup.describe do + include SystemExampleGroup + + before do + served_by(host: 'rails', port: 8080) + end + end + example = group.new + allow(example).to receive(:served_by).and_call_original + group.hooks.run(:before, :example, example) + + expect(example).to have_received(:served_by).once + end end describe '#after' do diff --git a/spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb b/spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb index 7e9470b3f..fb37fec13 100644 --- a/spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb +++ b/spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb @@ -246,13 +246,18 @@ def broadcast(stream, msg) it "has an appropriate description including the expected contents when qualified with `#with`" do expect(have_broadcasted_to("my_stream").from_channel(channel).with("hello world").description).to eq("have broadcasted exactly 1 messages to my_stream with \"hello world\"") end + it "has an appropriate description including the matcher's description when qualified with `#with` and a composable matcher" do - expect( - have_broadcasted_to("my_stream") + description = have_broadcasted_to("my_stream") .from_channel(channel) .with(a_hash_including(a: :b)) .description - ).to eq("have broadcasted exactly 1 messages to my_stream with a hash including {:a => :b}") + + if RUBY_VERSION >= '3.4' + expect(description).to eq("have broadcasted exactly 1 messages to my_stream with a hash including {a: :b}") + else + expect(description).to eq("have broadcasted exactly 1 messages to my_stream with a hash including {:a => :b}") + end end end end diff --git a/spec/rspec/rails/matchers/active_job_spec.rb b/spec/rspec/rails/matchers/active_job_spec.rb index 86e191ae5..2111e3435 100644 --- a/spec/rspec/rails/matchers/active_job_spec.rb +++ b/spec/rspec/rails/matchers/active_job_spec.rb @@ -42,6 +42,13 @@ def self.find(_id) ActiveJob::Base.logger = original_logger end + around do |example| + original_value = RSpec::Mocks.configuration.verify_partial_doubles? + example.run + ensure + RSpec::Mocks.configuration.verify_partial_doubles = original_value + end + let(:heavy_lifting_job) do Class.new(ActiveJob::Base) do def perform; end @@ -372,20 +379,54 @@ def perform; raise StandardError; end }.to have_enqueued_job.with(42, "David") end - it "fails if the arguments do not match the job's signature" do - expect { + describe "verifying the arguments passed match the job's signature" do + it "fails if there is an arity mismatch" do expect { - two_args_job.perform_later(1) - }.to have_enqueued_job.with(1) - }.to fail_with(/Incorrect arguments passed to TwoArgsJob: Wrong number of arguments/) - end + expect { + two_args_job.perform_later(1) + }.to have_enqueued_job.with(1) + }.to fail_with(/Incorrect arguments passed to TwoArgsJob: Wrong number of arguments/) + end - it "fails if the job's signature/arguments are mismatched keyword/positional arguments" do - expect { + it "fails if there is a keyword/positional arguments mismatch" do expect { - keyword_args_job.perform_later(1, 2) - }.to have_enqueued_job.with(1, 2) - }.to fail_with(/Incorrect arguments passed to KeywordArgsJob: Missing required keyword arguments/) + expect { + keyword_args_job.perform_later(1, 2) + }.to have_enqueued_job.with(1, 2) + }.to fail_with(/Incorrect arguments passed to KeywordArgsJob: Missing required keyword arguments/) + end + + context "with partial double verification disabled" do + before do + RSpec::Mocks.configuration.verify_partial_doubles = false + end + + it "skips signature checks" do + expect { two_args_job.perform_later(1) }.to have_enqueued_job.with(1) + end + end + + context "when partial double verification is temporarily suspended" do + it "skips signature checks" do + without_partial_double_verification { + expect { + two_args_job.perform_later(1) + }.to have_enqueued_job.with(1) + } + end + end + + context "without rspec-mocks loaded" do + before do + # Its hard for us to unload this, but its fairly safe to assume that we can run + # a defined? check, this just mocks the "short circuit" + allow(::RSpec::Mocks).to receive(:respond_to?).with(:configuration) { false } + end + + it "skips signature checks" do + expect { two_args_job.perform_later(1) }.to have_enqueued_job.with(1) + end + end end it "passes with provided arguments containing global id object" do @@ -521,20 +562,44 @@ def perform; raise StandardError; end }.to fail_with(/expected to enqueue exactly 1 jobs, but enqueued 0/) end - it "fails if the arguments do not match the job's signature" do - two_args_job.perform_later(1) + describe "verifying the arguments passed match the job's signature" do + it "fails if there is an arity mismatch" do + two_args_job.perform_later(1) - expect { - expect(two_args_job).to have_been_enqueued.with(1) - }.to fail_with(/Incorrect arguments passed to TwoArgsJob: Wrong number of arguments/) - end + expect { + expect(two_args_job).to have_been_enqueued.with(1) + }.to fail_with(/Incorrect arguments passed to TwoArgsJob: Wrong number of arguments/) + end - it "fails if the job's signature/arguments are mismatched keyword/positional arguments" do - keyword_args_job.perform_later(1, 2) + it "fails if there is a keyword/positional arguments mismatch" do + keyword_args_job.perform_later(1, 2) - expect { - expect(keyword_args_job).to have_been_enqueued.with(1, 2) - }.to fail_with(/Incorrect arguments passed to KeywordArgsJob: Missing required keyword arguments/) + expect { + expect(keyword_args_job).to have_been_enqueued.with(1, 2) + }.to fail_with(/Incorrect arguments passed to KeywordArgsJob: Missing required keyword arguments/) + end + + context "with partial double verification disabled" do + before do + RSpec::Mocks.configuration.verify_partial_doubles = false + end + + it "skips signature checks" do + keyword_args_job.perform_later(1, 2) + + expect(keyword_args_job).to have_been_enqueued.with(1, 2) + end + end + + context "when partial double verification is temporarily suspended" do + it "skips signature checks" do + keyword_args_job.perform_later(1, 2) + + without_partial_double_verification { + expect(keyword_args_job).to have_been_enqueued.with(1, 2) + } + end + end end it "fails when negated and several jobs enqueued" do diff --git a/spec/rspec/rails/matchers/be_a_new_spec.rb b/spec/rspec/rails/matchers/be_a_new_spec.rb index 76906a56f..d24e3c699 100644 --- a/spec/rspec/rails/matchers/be_a_new_spec.rb +++ b/spec/rspec/rails/matchers/be_a_new_spec.rb @@ -71,10 +71,16 @@ def new_record?; true; end end it "fails" do + message = + if RUBY_VERSION >= '3.4' + "attribute {\"foo\" => (a string matching \"bar\")} was not set on #{record.inspect}" + else + "attribute {\"foo\"=>(a string matching \"bar\")} was not set on #{record.inspect}" + end expect { expect(record).to be_a_new(record.class).with( foo: a_string_matching("bar")) - }.to raise_error("attribute {\"foo\"=>(a string matching \"bar\")} was not set on #{record.inspect}") + }.to raise_error(message) end context "matcher is wrong type" do @@ -101,12 +107,18 @@ def new_record?; true; end context "only one matcher present in actual" do it "fails" do + message = + if RUBY_VERSION >= '3.4' + "attribute {\"bar\" => (a string matching \"barn\")} was not set on #{record.inspect}" + else + "attribute {\"bar\"=>(a string matching \"barn\")} was not set on #{record.inspect}" + end expect { expect(record).to be_a_new(record.class).with( foo: a_string_matching("foo"), bar: a_string_matching("barn") ) - }.to raise_error("attribute {\"bar\"=>(a string matching \"barn\")} was not set on #{record.inspect}") + }.to raise_error(message) end end end @@ -118,19 +130,29 @@ def new_record?; true; end expect(record).to be_a_new(record.class).with(zoo: 'zoo', car: 'car') }.to raise_error { |e| expect(e.message).to match(/attributes \{.*\} were not set on #{Regexp.escape record.inspect}/) - expect(e.message).to match(/"zoo"=>"zoo"/) - expect(e.message).to match(/"car"=>"car"/) + if RUBY_VERSION >= '3.4' + expect(e.message).to match(/"zoo" => "zoo"/) + expect(e.message).to match(/"car" => "car"/) + else + expect(e.message).to match(/"zoo"=>"zoo"/) + expect(e.message).to match(/"car"=>"car"/) + end } end end context "one attribute value not the same" do it "fails" do + message = + if RUBY_VERSION >= '3.4' + %(attribute {"foo" => "bar"} was not set on #{record.inspect}) + else + %(attribute {"foo"=>"bar"} was not set on #{record.inspect}) + end + expect { expect(record).to be_a_new(record.class).with(foo: 'bar') - }.to raise_error( - %(attribute {"foo"=>"bar"} was not set on #{record.inspect}) - ) + }.to raise_error(message) end end end @@ -166,20 +188,30 @@ def new_record?; false; end expect(record).to be_a_new(String).with(zoo: 'zoo', car: 'car') }.to raise_error { |e| expect(e.message).to match(/expected #{Regexp.escape record.inspect} to be a new String and attributes \{.*\} were not set on #{Regexp.escape record.inspect}/) - expect(e.message).to match(/"zoo"=>"zoo"/) - expect(e.message).to match(/"car"=>"car"/) + if RUBY_VERSION >= '3.4' + expect(e.message).to match(/"zoo" => "zoo"/) + expect(e.message).to match(/"car" => "car"/) + else + expect(e.message).to match(/"zoo"=>"zoo"/) + expect(e.message).to match(/"car"=>"car"/) + end } end end context "one attribute value not the same" do it "fails" do + message = + "expected #{record.inspect} to be a new String and " + + if RUBY_VERSION >= '3.4' + %(attribute {"foo" => "bar"} was not set on #{record.inspect}) + else + %(attribute {"foo"=>"bar"} was not set on #{record.inspect}) + end + expect { expect(record).to be_a_new(String).with(foo: 'bar') - }.to raise_error( - "expected #{record.inspect} to be a new String and " + - %(attribute {"foo"=>"bar"} was not set on #{record.inspect}) - ) + }.to raise_error(message) end end end diff --git a/spec/rspec/rails/matchers/be_routable_spec.rb b/spec/rspec/rails/matchers/be_routable_spec.rb index c3a6a1b15..65edb2bb5 100644 --- a/spec/rspec/rails/matchers/be_routable_spec.rb +++ b/spec/rspec/rails/matchers/be_routable_spec.rb @@ -18,9 +18,17 @@ it "fails if routes do not recognize the path" do allow(routes).to receive(:recognize_path) { raise ActionController::RoutingError, 'ignore' } + + message = + if RUBY_VERSION >= '3.4' + /expected \{get: "\/a\/path"\} to be routable/ + else + /expected \{:get=>"\/a\/path"\} to be routable/ + end + expect do expect({ get: "/a/path" }).to be_routable - end.to raise_error(/expected \{:get=>"\/a\/path"\} to be routable/) + end.to raise_error(message) end end @@ -35,9 +43,17 @@ it "fails if routes recognize the path" do allow(routes).to receive(:recognize_path) { { controller: "foo" } } + + message = + if RUBY_VERSION >= '3.4' + /expected \{get: "\/a\/path"\} not to be routable, but it routes to \{controller: "foo"\}/ + else + /expected \{:get=>"\/a\/path"\} not to be routable, but it routes to \{:controller=>"foo"\}/ + end + expect do expect({ get: "/a/path" }).not_to be_routable - end.to raise_error(/expected \{:get=>"\/a\/path"\} not to be routable, but it routes to \{:controller=>"foo"\}/) + end.to raise_error(message) end end end diff --git a/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb b/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb index 14b886189..d2cc57ba4 100644 --- a/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb +++ b/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb @@ -60,6 +60,13 @@ def test_email; end ActiveJob::Base.logger = original_logger end + around do |example| + original_value = RSpec::Mocks.configuration.verify_partial_doubles? + example.run + ensure + RSpec::Mocks.configuration.verify_partial_doubles = original_value + end + describe "have_enqueued_mail" do it "passes when a mailer method is called with deliver_later" do expect { @@ -251,12 +258,35 @@ def test_email; end }.not_to have_enqueued_mail(TestMailer, :email_with_args).with(3, 4) end - it "fails if the arguments do not match the mailer method's signature" do - expect { + describe "verifying the arguments passed match the mailer's signature" do + it "fails if there is a mismatch" do expect { - TestMailer.email_with_args(1).deliver_later - }.to have_enqueued_mail(TestMailer, :email_with_args).with(1) - }.to fail_with(/Incorrect arguments passed to TestMailer: Wrong number of arguments/) + expect { + TestMailer.email_with_args(1).deliver_later + }.to have_enqueued_mail(TestMailer, :email_with_args).with(1) + }.to fail_with(/Incorrect arguments passed to TestMailer: Wrong number of arguments/) + end + + context "with partial double verification disabled" do + before do + RSpec::Mocks.configuration.verify_partial_doubles = false + end + + it "skips signature checks" do + expect { TestMailer.email_with_args(1).deliver_later } + .to have_enqueued_mail(TestMailer, :email_with_args).with(1) + end + end + + context "when partial double verification is temporarily suspended" do + it "skips signature checks" do + without_partial_double_verification { + expect { + TestMailer.email_with_args(1).deliver_later + }.to have_enqueued_mail(TestMailer, :email_with_args).with(1) + } + end + end end it "generates a failure message" do diff --git a/spec/rspec/rails/matchers/route_to_spec.rb b/spec/rspec/rails/matchers/route_to_spec.rb index ae49791f8..8b1d7836b 100644 --- a/spec/rspec/rails/matchers/route_to_spec.rb +++ b/spec/rspec/rails/matchers/route_to_spec.rb @@ -9,7 +9,15 @@ def assert_recognizes(*) it "provides a description" do matcher = route_to("these" => "options") matcher.matches?(get: "path") - expect(matcher.description).to eq("route {:get=>\"path\"} to {\"these\"=>\"options\"}") + + description = + if RUBY_VERSION >= '3.4' + "route {get: \"path\"} to {\"these\" => \"options\"}" + else + "route {:get=>\"path\"} to {\"these\"=>\"options\"}" + end + + expect(matcher.description).to eq(description) end it "delegates to assert_recognizes" do @@ -107,9 +115,16 @@ def assert_recognizes(*) context "with should_not" do context "when assert_recognizes passes" do it "fails with custom message" do + message = + if RUBY_VERSION >= '3.4' + /expected \{get: "path"\} not to route to \{"these" => "options"\}/ + else + /expected \{:get=>"path"\} not to route to \{"these"=>"options"\}/ + end + expect { expect({ get: "path" }).not_to route_to("these" => "options") - }.to raise_error(/expected \{:get=>"path"\} not to route to \{"these"=>"options"\}/) + }.to raise_error(message) end end diff --git a/spec/sanity_check_spec.rb b/spec/sanity_check_spec.rb index 4746a157e..7faef98a8 100644 --- a/spec/sanity_check_spec.rb +++ b/spec/sanity_check_spec.rb @@ -29,6 +29,7 @@ def with_clean_env .to match(/uninitialized constant RSpec::Support/) .or match(/undefined method `require_rspec_core' for RSpec::Support:Module/) .or match(/undefined method `require_rspec_core' for module RSpec::Support/) + .or match(/undefined method 'require_rspec_core' for module RSpec::Support/) expect($?.exitstatus).to eq(1) end