rspec-rails 4.1.2 → 5.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/Changelog.md +43 -10
  4. data/README.md +23 -17
  5. data/lib/generators/rspec/install/templates/spec/rails_helper.rb +1 -1
  6. data/lib/generators/rspec/job/job_generator.rb +2 -1
  7. data/lib/generators/rspec/job/templates/job_spec.rb.erb +1 -1
  8. data/lib/generators/rspec/mailer/templates/mailer_spec.rb +2 -2
  9. data/lib/generators/rspec/mailer/templates/preview.rb +1 -1
  10. data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +13 -13
  11. data/lib/generators/rspec/scaffold/templates/api_request_spec.rb +10 -10
  12. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +10 -58
  13. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +0 -4
  14. data/lib/generators/rspec/scaffold/templates/new_spec.rb +0 -4
  15. data/lib/generators/rspec/scaffold/templates/request_spec.rb +9 -9
  16. data/lib/generators/rspec/system/system_generator.rb +14 -16
  17. data/lib/rspec/rails/configuration.rb +2 -4
  18. data/lib/rspec/rails/example/controller_example_group.rb +1 -0
  19. data/lib/rspec/rails/example/request_example_group.rb +1 -4
  20. data/lib/rspec/rails/example/system_example_group.rb +1 -1
  21. data/lib/rspec/rails/file_fixture_support.rb +9 -11
  22. data/lib/rspec/rails/fixture_file_upload_support.rb +31 -10
  23. data/lib/rspec/rails/fixture_support.rb +4 -13
  24. data/lib/rspec/rails/matchers/action_mailbox.rb +14 -5
  25. data/lib/rspec/rails/matchers/have_enqueued_mail.rb +30 -2
  26. data/lib/rspec/rails/matchers/have_http_status.rb +4 -4
  27. data/lib/rspec/rails/version.rb +1 -1
  28. data/lib/rspec-rails.rb +5 -7
  29. data.tar.gz.sig +0 -0
  30. metadata +26 -14
  31. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b530810e523033d7513c99d9c37e6d6489803fa6d5cc3f2f734f453f4f1820e7
4
- data.tar.gz: ba735aede717f9b8474f74a35bfa9377192ecbe234dbb215ece3f0a41583db3f
3
+ metadata.gz: 829e7ddefdd0596e8b0015b56de40850a711f970ed3bebbe541f34a415b46a40
4
+ data.tar.gz: cb3a76cc3cb01705a92c1679473d3a0a488041fb47933a513bee90c91fc2da5c
5
5
  SHA512:
6
- metadata.gz: 29d53a4939bb2c0f18a80eac33e18fa9d7e905497f2735a30800c2be5bf0b0499f0b84be8ffbec93e6793ed8dcb14fe648017aecd36e52439d5f4a6f0e8c3450
7
- data.tar.gz: c3d15b2bf8a9c5182aef5760027142898394ec83d75a210dce65f78f4dd5496cdb7451f2b30908a06942c9e897a1b7ba96254e00f59eefab3f151a805e8cda36
6
+ metadata.gz: f84c6e4ad2c9d546c3d305daf8c6ef4a65f3559fdbea88bd148e3f25503e0b9c1bd520df473a6c0ae2579a40bce2d937edbb7e7b6cada7ad43320f7c7a124303
7
+ data.tar.gz: d6e2f6ad0a19e7b821149c0df545f39a0529fd8660bac992b365ec60015a1e2cb0aec7f54cd99ebd8ee6a60eead7aa9fead5c5ade5d7df380304268d630ecc2f
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,17 +1,50 @@
1
- ### 4.1.2 / 2021-03-10
2
- [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.1.1...v4.1.2)
1
+ ### Development
2
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.3...5-0-maintenance)
3
+
4
+ ### 5.0.3 / 2022-01-26
5
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.2...v5.0.3)
6
+
7
+ Bug Fixes:
8
+
9
+ * Properly name params in controller and request spec templates when
10
+ using the `--model-name` parameter. (@kenzo-tanaka, #2534)
11
+ * Fix support for `have_enqueued_mail` on Ruby 3.1 with Rails 6.1.
12
+ (Fabio Napoleoni, Mikael Henriksson, Phil Pirozhkov, Jon Rowe, #2566)
13
+
14
+ ### 5.0.2 / 2021-08-14
15
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.1...v5.0.2)
3
16
 
4
17
  Bug Fixes:
5
18
 
6
- * Prevent `NoMethodError` on Rails 4.2 when checking if a test is run
7
- in transaction. (Geremia Taglialatela, #2480)
19
+ * Prevent generated job specs from duplicating `_job` in filenames.
20
+ (Nick Flückiger, #2496)
21
+ * Fix `ActiveRecord::TestFixture#uses_transaction` by using example description
22
+ to replace example name rather than example in our monkey patched
23
+ `run_in_transaction?` method. (Stan Lo, #2495)
24
+ * Prevent keyword arguments being lost when methods are invoked dynamically
25
+ in controller specs. (Josh Cheek, #2509, #2514)
26
+
27
+ ### 5.0.1 / 2021-03-18
28
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.0...v5.0.1)
29
+
30
+ Bug Fixes:
31
+
32
+ * Limit multibyte example descriptions when used in system tests for #method_name
33
+ which ends up as screenshot names etc. (@y-yagi, #2405, #2487)
34
+
35
+ ### 5.0.0 / 2021-03-09
36
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.1.1...v5.0.0)
37
+
38
+ Enhancements:
39
+
40
+ * Support new #file_fixture_path and new fixture test support code. (Jon Rowe, #2398)
41
+ * Support for Rails 6.1. (Benoit Tigeot, Jon Rowe, Phil Pirozhkov, and more #2398)
42
+
43
+ Breaking Changes:
8
44
 
9
- *Note* Rails 4.2 is only soft supported by the 4.x series of rspec-rails,
10
- an exception was made here as it was a regression introduced by another
11
- bug fix.
45
+ * Drop support for Rails below 5.2.
12
46
 
13
47
  ### 4.1.1 / 2021-03-09
14
- [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.1.0...v4.1.1)
15
48
 
16
49
  Bug Fixes:
17
50
 
@@ -19,7 +52,6 @@ Bug Fixes:
19
52
  (@Naokimi, #2475)
20
53
 
21
54
  ### 4.1.0 / 2021-03-06
22
- [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.2...v4.1.0)
23
55
 
24
56
  Enhancements:
25
57
 
@@ -46,6 +78,7 @@ Bug Fixes:
46
78
  (Phil Pirozhkov, Jon Rowe, #2353, #2354)
47
79
  * Remove old #fixture_path feature detection code which broke under newer Rails.
48
80
  (Koen Punt, Jon Rowe, #2370)
81
+ * Fix an error when `use_active_record` is `false` (Phil Pirozhkov, #2423)
49
82
 
50
83
  ### 4.0.1 / 2020-05-16
51
84
  [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0...v4.0.1)
@@ -83,7 +116,7 @@ Enhancements:
83
116
  generating a controller (Luka Lüdicke, #2222)
84
117
  * Allow `ActiveJob` matchers `#on_queue` modifier to take symbolic queue names. (Nils Sommer, #2283)
85
118
  * The scaffold generator now generates request specs in preference to controller specs.
86
- (Luka Lüdicke, #2288)
119
+ (Luka Lüdicke, #2288)
87
120
  * Add configuration option to disable ActiveRecord. (Jon Rowe, Phil Pirozhkov, Hermann Mayer, #2266)
88
121
  * Set `ActionDispatch::SystemTesting::Server.silence_puma = true` when running system specs.
89
122
  (ta1kt0me, Benoit Tigeot, #2289)
data/README.md CHANGED
@@ -8,8 +8,11 @@ They’re also specifications (or _specs,_ for short):
8
8
  detailed explanations of how the application is supposed to behave,
9
9
  expressed in plain English.
10
10
 
11
- Use **[`rspec-rails` 3.x][]** for Rails earlier than 5.0.
12
- Use **[`rspec-rails` 1.x][]** for Rails 2.x.
11
+ According to [RSpec Rails new versioning strategy][] use:
12
+ * **[`rspec-rails` 5.x][]** for Rails 6.x.
13
+ * **[`rspec-rails` 4.x][]** for Rails from 5.x or 6.x.
14
+ * **[`rspec-rails` 3.x][]** for Rails earlier than 5.0.
15
+ * **[`rspec-rails` 1.x][]** for Rails 2.x.
13
16
 
14
17
  [Build Status]: https://secure.travis-ci.org/rspec/rspec-rails.svg?branch=main
15
18
  [travis-ci]: https://travis-ci.org/rspec/rspec-rails
@@ -21,19 +24,22 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x.
21
24
  [Ruby on Rails]: https://rubyonrails.org/
22
25
  [`rspec-rails` 1.x]: https://github.com/dchelimsky/rspec-rails
23
26
  [`rspec-rails` 3.x]: https://github.com/rspec/rspec-rails/tree/3-9-maintenance
27
+ [`rspec-rails` 4.x]: https://github.com/rspec/rspec-rails/tree/4-1-maintenance
28
+ [`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-0-maintenance
29
+ [RSpec Rails new versioning strategy]: https://github.com/rspec/rspec-rails/blob/main/rfcs/versioning-strategy.md
24
30
 
25
31
  ## Installation
26
32
 
27
- **IMPORTANT** This README / branch refers to the `4.1.x` series of releases.
33
+ **IMPORTANT** This README / branch refers to the 5.0.x series of releases.
28
34
  See the [`main` branch on Github](https://github.com/rspec/rspec-rails/tree/main) for more up to date releases.
29
35
 
30
36
  1. Add `rspec-rails` to **both** the `:development` and `:test` groups
31
37
  of your app’s `Gemfile`:
32
38
 
33
39
  ```ruby
34
- # Run against the latest stable release
40
+ # Run against this stable release
35
41
  group :development, :test do
36
- gem 'rspec-rails', '~> 4.1.0'
42
+ gem 'rspec-rails', '~> 5.0.0'
37
43
  end
38
44
 
39
45
  # Or, run against the main branch
@@ -227,18 +233,18 @@ Each one inherits from one of Rails’ built-in `TestCase` classes,
227
233
  meaning the helper methods provided by default in Rails tests
228
234
  are available in RSpec, as well.
229
235
 
230
- | Spec type | Corresponding Rails test class |
231
- | -------------- | -------------------------------- |
232
- | [model][] | |
233
- | [controller][] | [`ActionController::TestCase`][] |
234
- | [mailer][] | `ActionMailer::TestCase` |
235
- | [job][] | |
236
- | [view][] | `ActionView::TestCase` |
237
- | [routing][] | |
238
- | [helper][] | `ActionView::TestCase` |
239
- | [request][] | [`ActionDispatch::IntegrationTest`][] |
240
- | [feature][] | |
241
- | [system][] | [`ActionDispatch::SystemTestCase`][] |
236
+ | Spec type | Corresponding Rails test class |
237
+ | -------------- | -------------------------------- |
238
+ | [model][] | |
239
+ | [controller][] | [`ActionController::TestCase`][] |
240
+ | [mailer][] | `ActionMailer::TestCase` |
241
+ | [job][] | |
242
+ | [view][] | `ActionView::TestCase` |
243
+ | [routing][] | |
244
+ | [helper][] | `ActionView::TestCase` |
245
+ | [request][] | [`ActionDispatch::IntegrationTest`][] |
246
+ | [feature][] | |
247
+ | [system][] | [`ActionDispatch::SystemTestCase`][] |
242
248
 
243
249
  Follow the links above to see examples of each spec type,
244
250
  or for official Rails API documentation on the given `TestCase` class.
@@ -1,7 +1,7 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
2
  require 'spec_helper'
3
3
  ENV['RAILS_ENV'] ||= 'test'
4
- require File.expand_path('../config/environment', __dir__)
4
+ require_relative '../config/environment'
5
5
  # Prevent database truncation if the environment is production
6
6
  abort("The Rails environment is running in production mode!") if Rails.env.production?
7
7
  require 'rspec/rails'
@@ -5,7 +5,8 @@ module Rspec
5
5
  # @private
6
6
  class JobGenerator < Base
7
7
  def create_job_spec
8
- template 'job_spec.rb.erb', File.join('spec/jobs', class_path, "#{file_name}_job_spec.rb")
8
+ file_suffix = file_name.end_with?('job') ? 'spec.rb' : 'job_spec.rb'
9
+ template 'job_spec.rb.erb', File.join('spec/jobs', class_path, [file_name, file_suffix].join('_'))
9
10
  end
10
11
  end
11
12
  end
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  <% module_namespacing do -%>
4
- RSpec.describe <%= class_name %>Job, <%= type_metatag(:job) %> do
4
+ RSpec.describe <%= class_name %><%= "Job" unless class_name.end_with?("Job")%>, <%= type_metatag(:job) %> do
5
5
  pending "add some examples to (or delete) #{__FILE__}"
6
6
  end
7
7
  <% end -%>
@@ -1,10 +1,10 @@
1
1
  require "rails_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- RSpec.describe <%= Rails.version.to_f >= 5.0 ? class_name.sub(/(Mailer)?$/, 'Mailer') : class_name %>, <%= type_metatag(:mailer) %> do
4
+ RSpec.describe <%= class_name.sub(/(Mailer)?$/, 'Mailer') %>, <%= type_metatag(:mailer) %> do
5
5
  <% for action in actions -%>
6
6
  describe "<%= action %>" do
7
- let(:mail) { <%= Rails.version.to_f >= 5.0 ? class_name.sub(/(Mailer)?$/, 'Mailer') : class_name %>.<%= action %> }
7
+ let(:mail) { <%= class_name.sub(/(Mailer)?$/, 'Mailer') %>.<%= action %> }
8
8
 
9
9
  it "renders the headers" do
10
10
  expect(mail.subject).to eq(<%= action.to_s.humanize.inspect %>)
@@ -5,7 +5,7 @@ class <%= class_name %>Preview < ActionMailer::Preview
5
5
 
6
6
  # Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>/<%= action %>
7
7
  def <%= action %>
8
- <%= Rails.version.to_f >= 5.0 ? class_name.sub(/(Mailer)?$/, 'Mailer') : class_name %>.<%= action %>
8
+ <%= class_name.sub(/(Mailer)?$/, 'Mailer') %>.<%= action %>
9
9
  end
10
10
  <% end -%>
11
11
 
@@ -64,21 +64,21 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
64
64
  context "with valid params" do
65
65
  it "creates a new <%= class_name %>" do
66
66
  expect {
67
- post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
67
+ post :create, params: {<%= singular_table_name %>: valid_attributes}, session: valid_session
68
68
  }.to change(<%= class_name %>, :count).by(1)
69
69
  end
70
70
 
71
- it "renders a JSON response with the new <%= ns_file_name %>" do
72
- post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
71
+ it "renders a JSON response with the new <%= singular_table_name %>" do
72
+ post :create, params: {<%= singular_table_name %>: valid_attributes}, session: valid_session
73
73
  expect(response).to have_http_status(:created)
74
74
  expect(response.content_type).to eq('application/json')
75
- expect(response.location).to eq(<%= ns_file_name %>_url(<%= class_name %>.last))
75
+ expect(response.location).to eq(<%= singular_table_name %>_url(<%= class_name %>.last))
76
76
  end
77
77
  end
78
78
 
79
79
  context "with invalid params" do
80
- it "renders a JSON response with errors for the new <%= ns_file_name %>" do
81
- post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
80
+ it "renders a JSON response with errors for the new <%= singular_table_name %>" do
81
+ post :create, params: {<%= singular_table_name %>: invalid_attributes}, session: valid_session
82
82
  expect(response).to have_http_status(:unprocessable_entity)
83
83
  expect(response.content_type).to eq('application/json')
84
84
  end
@@ -91,25 +91,25 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
91
91
  skip("Add a hash of attributes valid for your model")
92
92
  }
93
93
 
94
- it "updates the requested <%= ns_file_name %>" do
94
+ it "updates the requested <%= singular_table_name %>" do
95
95
  <%= file_name %> = <%= class_name %>.create! valid_attributes
96
- put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session
96
+ put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: new_attributes}, session: valid_session
97
97
  <%= file_name %>.reload
98
98
  skip("Add assertions for updated state")
99
99
  end
100
100
 
101
- it "renders a JSON response with the <%= ns_file_name %>" do
101
+ it "renders a JSON response with the <%= singular_table_name %>" do
102
102
  <%= file_name %> = <%= class_name %>.create! valid_attributes
103
- put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
103
+ put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: valid_attributes}, session: valid_session
104
104
  expect(response).to have_http_status(:ok)
105
105
  expect(response.content_type).to eq('application/json')
106
106
  end
107
107
  end
108
108
 
109
109
  context "with invalid params" do
110
- it "renders a JSON response with errors for the <%= ns_file_name %>" do
110
+ it "renders a JSON response with errors for the <%= singular_table_name %>" do
111
111
  <%= file_name %> = <%= class_name %>.create! valid_attributes
112
- put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
112
+ put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: invalid_attributes}, session: valid_session
113
113
  expect(response).to have_http_status(:unprocessable_entity)
114
114
  expect(response.content_type).to eq('application/json')
115
115
  end
@@ -117,7 +117,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
117
117
  end
118
118
 
119
119
  describe "DELETE #destroy" do
120
- it "destroys the requested <%= ns_file_name %>" do
120
+ it "destroys the requested <%= singular_table_name %>" do
121
121
  <%= file_name %> = <%= class_name %>.create! valid_attributes
122
122
  expect {
123
123
  delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
@@ -56,13 +56,13 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
56
56
  it "creates a new <%= class_name %>" do
57
57
  expect {
58
58
  post <%= index_helper %>_url,
59
- params: { <%= ns_file_name %>: valid_attributes }, headers: valid_headers, as: :json
59
+ params: { <%= singular_table_name %>: valid_attributes }, headers: valid_headers, as: :json
60
60
  }.to change(<%= class_name %>, :count).by(1)
61
61
  end
62
62
 
63
- it "renders a JSON response with the new <%= ns_file_name %>" do
63
+ it "renders a JSON response with the new <%= singular_table_name %>" do
64
64
  post <%= index_helper %>_url,
65
- params: { <%= ns_file_name %>: valid_attributes }, headers: valid_headers, as: :json
65
+ params: { <%= singular_table_name %>: valid_attributes }, headers: valid_headers, as: :json
66
66
  expect(response).to have_http_status(:created)
67
67
  expect(response.content_type).to match(a_string_including("application/json"))
68
68
  end
@@ -72,13 +72,13 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
72
72
  it "does not create a new <%= class_name %>" do
73
73
  expect {
74
74
  post <%= index_helper %>_url,
75
- params: { <%= ns_file_name %>: invalid_attributes }, as: :json
75
+ params: { <%= singular_table_name %>: invalid_attributes }, as: :json
76
76
  }.to change(<%= class_name %>, :count).by(0)
77
77
  end
78
78
 
79
- it "renders a JSON response with errors for the new <%= ns_file_name %>" do
79
+ it "renders a JSON response with errors for the new <%= singular_table_name %>" do
80
80
  post <%= index_helper %>_url,
81
- params: { <%= ns_file_name %>: invalid_attributes }, headers: valid_headers, as: :json
81
+ params: { <%= singular_table_name %>: invalid_attributes }, headers: valid_headers, as: :json
82
82
  expect(response).to have_http_status(:unprocessable_entity)
83
83
  expect(response.content_type).to eq("application/json")
84
84
  end
@@ -91,7 +91,7 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
91
91
  skip("Add a hash of attributes valid for your model")
92
92
  }
93
93
 
94
- it "updates the requested <%= ns_file_name %>" do
94
+ it "updates the requested <%= singular_table_name %>" do
95
95
  <%= file_name %> = <%= class_name %>.create! valid_attributes
96
96
  patch <%= show_helper.tr('@', '') %>,
97
97
  params: { <%= singular_table_name %>: new_attributes }, headers: valid_headers, as: :json
@@ -99,7 +99,7 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
99
99
  skip("Add assertions for updated state")
100
100
  end
101
101
 
102
- it "renders a JSON response with the <%= ns_file_name %>" do
102
+ it "renders a JSON response with the <%= singular_table_name %>" do
103
103
  <%= file_name %> = <%= class_name %>.create! valid_attributes
104
104
  patch <%= show_helper.tr('@', '') %>,
105
105
  params: { <%= singular_table_name %>: new_attributes }, headers: valid_headers, as: :json
@@ -109,7 +109,7 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
109
109
  end
110
110
 
111
111
  context "with invalid parameters" do
112
- it "renders a JSON response with errors for the <%= ns_file_name %>" do
112
+ it "renders a JSON response with errors for the <%= singular_table_name %>" do
113
113
  <%= file_name %> = <%= class_name %>.create! valid_attributes
114
114
  patch <%= show_helper.tr('@', '') %>,
115
115
  params: { <%= singular_table_name %>: invalid_attributes }, headers: valid_headers, as: :json
@@ -120,7 +120,7 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
120
120
  end
121
121
 
122
122
  describe "DELETE /destroy" do
123
- it "destroys the requested <%= ns_file_name %>" do
123
+ it "destroys the requested <%= singular_table_name %>" do
124
124
  <%= file_name %> = <%= class_name %>.create! valid_attributes
125
125
  expect {
126
126
  delete <%= show_helper.tr('@', '') %>, headers: valid_headers, as: :json
@@ -46,11 +46,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
46
46
  describe "GET #index" do
47
47
  it "returns a success response" do
48
48
  <%= class_name %>.create! valid_attributes
49
- <% if Rails::VERSION::STRING < '5.0' -%>
50
- get :index, {}, valid_session
51
- <% else -%>
52
49
  get :index, params: {}, session: valid_session
53
- <% end -%>
54
50
  expect(response).to be_successful
55
51
  end
56
52
  end
@@ -59,22 +55,14 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
59
55
  describe "GET #show" do
60
56
  it "returns a success response" do
61
57
  <%= file_name %> = <%= class_name %>.create! valid_attributes
62
- <% if Rails::VERSION::STRING < '5.0' -%>
63
- get :show, {id: <%= file_name %>.to_param}, valid_session
64
- <% else -%>
65
58
  get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
66
- <% end -%>
67
59
  expect(response).to be_successful
68
60
  end
69
61
  end
70
62
 
71
63
  describe "GET #new" do
72
64
  it "returns a success response" do
73
- <% if Rails::VERSION::STRING < '5.0' -%>
74
- get :new, {}, valid_session
75
- <% else -%>
76
65
  get :new, params: {}, session: valid_session
77
- <% end -%>
78
66
  expect(response).to be_successful
79
67
  end
80
68
  end
@@ -82,11 +70,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
82
70
  describe "GET #edit" do
83
71
  it "returns a success response" do
84
72
  <%= file_name %> = <%= class_name %>.create! valid_attributes
85
- <% if Rails::VERSION::STRING < '5.0' -%>
86
- get :edit, {id: <%= file_name %>.to_param}, valid_session
87
- <% else -%>
88
73
  get :edit, params: {id: <%= file_name %>.to_param}, session: valid_session
89
- <% end -%>
90
74
  expect(response).to be_successful
91
75
  end
92
76
  end
@@ -95,31 +79,19 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
95
79
  context "with valid params" do
96
80
  it "creates a new <%= class_name %>" do
97
81
  expect {
98
- <% if Rails::VERSION::STRING < '5.0' -%>
99
- post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
100
- <% else -%>
101
- post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
102
- <% end -%>
82
+ post :create, params: {<%= singular_table_name %>: valid_attributes}, session: valid_session
103
83
  }.to change(<%= class_name %>, :count).by(1)
104
84
  end
105
85
 
106
- it "redirects to the created <%= ns_file_name %>" do
107
- <% if Rails::VERSION::STRING < '5.0' -%>
108
- post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
109
- <% else -%>
110
- post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
111
- <% end -%>
86
+ it "redirects to the created <%= singular_table_name %>" do
87
+ post :create, params: {<%= singular_table_name %>: valid_attributes}, session: valid_session
112
88
  expect(response).to redirect_to(<%= class_name %>.last)
113
89
  end
114
90
  end
115
91
 
116
92
  context "with invalid params" do
117
93
  it "returns a success response (i.e. to display the 'new' template)" do
118
- <% if Rails::VERSION::STRING < '5.0' -%>
119
- post :create, {<%= ns_file_name %>: invalid_attributes}, valid_session
120
- <% else -%>
121
- post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
122
- <% end -%>
94
+ post :create, params: {<%= singular_table_name %>: invalid_attributes}, session: valid_session
123
95
  expect(response).to be_successful
124
96
  end
125
97
  end
@@ -131,24 +103,16 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
131
103
  skip("Add a hash of attributes valid for your model")
132
104
  }
133
105
 
134
- it "updates the requested <%= ns_file_name %>" do
106
+ it "updates the requested <%= singular_table_name %>" do
135
107
  <%= file_name %> = <%= class_name %>.create! valid_attributes
136
- <% if Rails::VERSION::STRING < '5.0' -%>
137
- put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, valid_session
138
- <% else -%>
139
- put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session
140
- <% end -%>
108
+ put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: new_attributes}, session: valid_session
141
109
  <%= file_name %>.reload
142
110
  skip("Add assertions for updated state")
143
111
  end
144
112
 
145
- it "redirects to the <%= ns_file_name %>" do
113
+ it "redirects to the <%= singular_table_name %>" do
146
114
  <%= file_name %> = <%= class_name %>.create! valid_attributes
147
- <% if Rails::VERSION::STRING < '5.0' -%>
148
- put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, valid_session
149
- <% else -%>
150
- put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
151
- <% end -%>
115
+ put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: valid_attributes}, session: valid_session
152
116
  expect(response).to redirect_to(<%= file_name %>)
153
117
  end
154
118
  end
@@ -156,35 +120,23 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
156
120
  context "with invalid params" do
157
121
  it "returns a success response (i.e. to display the 'edit' template)" do
158
122
  <%= file_name %> = <%= class_name %>.create! valid_attributes
159
- <% if Rails::VERSION::STRING < '5.0' -%>
160
- put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, valid_session
161
- <% else -%>
162
- put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
163
- <% end -%>
123
+ put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: invalid_attributes}, session: valid_session
164
124
  expect(response).to be_successful
165
125
  end
166
126
  end
167
127
  end
168
128
 
169
129
  describe "DELETE #destroy" do
170
- it "destroys the requested <%= ns_file_name %>" do
130
+ it "destroys the requested <%= singular_table_name %>" do
171
131
  <%= file_name %> = <%= class_name %>.create! valid_attributes
172
132
  expect {
173
- <% if Rails::VERSION::STRING < '5.0' -%>
174
- delete :destroy, {id: <%= file_name %>.to_param}, valid_session
175
- <% else -%>
176
133
  delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
177
- <% end -%>
178
134
  }.to change(<%= class_name %>, :count).by(-1)
179
135
  end
180
136
 
181
137
  it "redirects to the <%= table_name %> list" do
182
138
  <%= file_name %> = <%= class_name %>.create! valid_attributes
183
- <% if Rails::VERSION::STRING < '5.0' -%>
184
- delete :destroy, {id: <%= file_name %>.to_param}, valid_session
185
- <% else -%>
186
139
  delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
187
- <% end -%>
188
140
  expect(response).to redirect_to(<%= index_helper %>_url)
189
141
  end
190
142
  end
@@ -16,11 +16,7 @@ RSpec.describe "<%= ns_table_name %>/edit", <%= type_metatag(:view) %> do
16
16
  assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(@<%= ns_file_name %>), "post" do
17
17
  <% for attribute in output_attributes -%>
18
18
  <%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
19
- <% if Rails.version.to_f >= 5.1 -%>
20
19
  assert_select "<%= attribute.input_type -%>[name=?]", "<%= ns_file_name %>[<%= name %>]"
21
- <% else -%>
22
- assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= name %>[name=?]", "<%= ns_file_name %>[<%= name %>]"
23
- <% end -%>
24
20
  <% end -%>
25
21
  end
26
22
  end
@@ -15,11 +15,7 @@ RSpec.describe "<%= ns_table_name %>/new", <%= type_metatag(:view) %> do
15
15
  assert_select "form[action=?][method=?]", <%= index_helper %>_path, "post" do
16
16
  <% for attribute in output_attributes -%>
17
17
  <%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
18
- <% if Rails.version.to_f >= 5.1 -%>
19
18
  assert_select "<%= attribute.input_type -%>[name=?]", "<%= ns_file_name %>[<%= name %>]"
20
- <% else -%>
21
- assert_select "<%= attribute.input_type -%>#<%= ns_file_name %>_<%= name %>[name=?]", "<%= ns_file_name %>[<%= name %>]"
22
- <% end -%>
23
19
  <% end -%>
24
20
  end
25
21
  end
@@ -1,4 +1,4 @@
1
- require 'rails_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  # This spec was generated by rspec-rails when you ran the scaffold generator.
4
4
  # It demonstrates how one might use RSpec to test the controller code that
@@ -65,12 +65,12 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
65
65
  context "with valid parameters" do
66
66
  it "creates a new <%= class_name %>" do
67
67
  expect {
68
- post <%= index_helper %>_url, params: { <%= ns_file_name %>: valid_attributes }
68
+ post <%= index_helper %>_url, params: { <%= singular_table_name %>: valid_attributes }
69
69
  }.to change(<%= class_name %>, :count).by(1)
70
70
  end
71
71
 
72
- it "redirects to the created <%= ns_file_name %>" do
73
- post <%= index_helper %>_url, params: { <%= ns_file_name %>: valid_attributes }
72
+ it "redirects to the created <%= singular_table_name %>" do
73
+ post <%= index_helper %>_url, params: { <%= singular_table_name %>: valid_attributes }
74
74
  expect(response).to redirect_to(<%= show_helper.gsub("\@#{file_name}", class_name+".last") %>)
75
75
  end
76
76
  end
@@ -78,12 +78,12 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
78
78
  context "with invalid parameters" do
79
79
  it "does not create a new <%= class_name %>" do
80
80
  expect {
81
- post <%= index_helper %>_url, params: { <%= ns_file_name %>: invalid_attributes }
81
+ post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
82
82
  }.to change(<%= class_name %>, :count).by(0)
83
83
  end
84
84
 
85
85
  it "renders a successful response (i.e. to display the 'new' template)" do
86
- post <%= index_helper %>_url, params: { <%= ns_file_name %>: invalid_attributes }
86
+ post <%= index_helper %>_url, params: { <%= singular_table_name %>: invalid_attributes }
87
87
  expect(response).to be_successful
88
88
  end
89
89
  end
@@ -95,14 +95,14 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
95
95
  skip("Add a hash of attributes valid for your model")
96
96
  }
97
97
 
98
- it "updates the requested <%= ns_file_name %>" do
98
+ it "updates the requested <%= singular_table_name %>" do
99
99
  <%= file_name %> = <%= class_name %>.create! valid_attributes
100
100
  patch <%= show_helper.tr('@', '') %>, params: { <%= singular_table_name %>: new_attributes }
101
101
  <%= file_name %>.reload
102
102
  skip("Add assertions for updated state")
103
103
  end
104
104
 
105
- it "redirects to the <%= ns_file_name %>" do
105
+ it "redirects to the <%= singular_table_name %>" do
106
106
  <%= file_name %> = <%= class_name %>.create! valid_attributes
107
107
  patch <%= show_helper.tr('@', '') %>, params: { <%= singular_table_name %>: new_attributes }
108
108
  <%= file_name %>.reload
@@ -120,7 +120,7 @@ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %
120
120
  end
121
121
 
122
122
  describe "DELETE /destroy" do
123
- it "destroys the requested <%= ns_file_name %>" do
123
+ it "destroys the requested <%= singular_table_name %>" do
124
124
  <%= file_name %> = <%= class_name %>.create! valid_attributes
125
125
  expect {
126
126
  delete <%= show_helper.tr('@', '') %>
@@ -1,25 +1,23 @@
1
1
  require 'generators/rspec'
2
2
 
3
- if ::Rails::VERSION::STRING >= '5.1'
4
- module Rspec
5
- module Generators
6
- # @private
7
- class SystemGenerator < Base
8
- class_option :system_specs, type: :boolean, default: true, desc: "Generate system specs"
3
+ module Rspec
4
+ module Generators
5
+ # @private
6
+ class SystemGenerator < Base
7
+ class_option :system_specs, type: :boolean, default: true, desc: "Generate system specs"
9
8
 
10
- def generate_system_spec
11
- return unless options[:system_specs]
9
+ def generate_system_spec
10
+ return unless options[:system_specs]
12
11
 
13
- template template_name, File.join('spec/system', class_path, filename)
14
- end
12
+ template template_name, File.join('spec/system', class_path, filename)
13
+ end
15
14
 
16
- def template_name
17
- 'system_spec.rb'
18
- end
15
+ def template_name
16
+ 'system_spec.rb'
17
+ end
19
18
 
20
- def filename
21
- "#{table_name}_spec.rb"
22
- end
19
+ def filename
20
+ "#{table_name}_spec.rb"
23
21
  end
24
22
  end
25
23
  end
@@ -80,10 +80,8 @@ module RSpec
80
80
  # `RSpec::Rails::FixtureSupport` directly instead
81
81
  config.include RSpec::Rails::FixtureSupport
82
82
 
83
- if ::Rails::VERSION::STRING > '5'
84
- config.add_setting :file_fixture_path, default: 'spec/fixtures/files'
85
- config.include RSpec::Rails::FileFixtureSupport
86
- end
83
+ config.add_setting :file_fixture_path, default: 'spec/fixtures/files'
84
+ config.include RSpec::Rails::FileFixtureSupport
87
85
 
88
86
  # Add support for fixture_path on fixture_file_upload
89
87
  config.include RSpec::Rails::FixtureFileUploadSupport
@@ -176,6 +176,7 @@ module RSpec
176
176
  super
177
177
  end
178
178
  end
179
+ ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
179
180
 
180
181
  included do
181
182
  subject { controller }
@@ -10,10 +10,7 @@ module RSpec
10
10
  include RSpec::Rails::Matchers::RedirectTo
11
11
  include RSpec::Rails::Matchers::RenderTemplate
12
12
  include ActionController::TemplateAssertions
13
-
14
- if ActionPack::VERSION::MAJOR >= 5
15
- include ActionDispatch::IntegrationTest::Behavior
16
- end
13
+ include ActionDispatch::IntegrationTest::Behavior
17
14
 
18
15
  # Delegates to `Rails.application`.
19
16
  def app
@@ -41,7 +41,7 @@ module RSpec
41
41
  @method_name ||= [
42
42
  self.class.name.underscore,
43
43
  RSpec.current_example.description.underscore
44
- ].join("_").tr(CHARS_TO_TRANSLATE.join, "_")[0...200] + "_#{rand(1000)}"
44
+ ].join("_").tr(CHARS_TO_TRANSLATE.join, "_").byteslice(0...200).scrub("") + "_#{rand(1000)}"
45
45
  end
46
46
 
47
47
  # Delegates to `Rails.application`.
@@ -1,16 +1,14 @@
1
- if ::Rails::VERSION::STRING > '5'
2
- require 'active_support/testing/file_fixtures'
1
+ require 'active_support/testing/file_fixtures'
3
2
 
4
- module RSpec
5
- module Rails
6
- # @private
7
- module FileFixtureSupport
8
- extend ActiveSupport::Concern
9
- include ActiveSupport::Testing::FileFixtures
3
+ module RSpec
4
+ module Rails
5
+ # @private
6
+ module FileFixtureSupport
7
+ extend ActiveSupport::Concern
8
+ include ActiveSupport::Testing::FileFixtures
10
9
 
11
- included do
12
- self.file_fixture_path = RSpec.configuration.file_fixture_path
13
- end
10
+ included do
11
+ self.file_fixture_path = RSpec.configuration.file_fixture_path
14
12
  end
15
13
  end
16
14
  end
@@ -6,21 +6,42 @@ module RSpec
6
6
 
7
7
  private
8
8
 
9
- def rails_fixture_file_wrapper
10
- RailsFixtureFileWrapper.fixture_path = nil
11
- resolved_fixture_path =
12
- if respond_to?(:fixture_path) && !fixture_path.nil?
13
- fixture_path.to_s
14
- else
15
- (RSpec.configuration.fixture_path || '').to_s
16
- end
17
- RailsFixtureFileWrapper.fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
18
- RailsFixtureFileWrapper.instance
9
+ # In Rails 6.2 fixture file path needs to be relative to `file_fixture_path` instead, this change
10
+ # was brought in with a deprecation warning on 6.1. In Rails 6.2 expect to rework this to remove
11
+ # the old accessor.
12
+ if ::Rails.version.to_f >= 6.1
13
+ def rails_fixture_file_wrapper
14
+ RailsFixtureFileWrapper.file_fixture_path = nil
15
+ resolved_fixture_path =
16
+ if respond_to?(:file_fixture_path) && !file_fixture_path.nil?
17
+ file_fixture_path.to_s
18
+ else
19
+ (RSpec.configuration.fixture_path || '').to_s
20
+ end
21
+ RailsFixtureFileWrapper.file_fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
22
+ RailsFixtureFileWrapper.instance
23
+ end
24
+ else
25
+ def rails_fixture_file_wrapper
26
+ RailsFixtureFileWrapper.fixture_path = nil
27
+ resolved_fixture_path =
28
+ if respond_to?(:fixture_path) && !fixture_path.nil?
29
+ fixture_path.to_s
30
+ else
31
+ (RSpec.configuration.fixture_path || '').to_s
32
+ end
33
+ RailsFixtureFileWrapper.fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
34
+ RailsFixtureFileWrapper.instance
35
+ end
19
36
  end
20
37
 
21
38
  class RailsFixtureFileWrapper
22
39
  include ActionDispatch::TestProcess if defined?(ActionDispatch::TestProcess)
23
40
 
41
+ if ::Rails.version.to_f >= 6.1
42
+ include ActiveSupport::Testing::FileFixtures
43
+ end
44
+
24
45
  class << self
25
46
  attr_accessor :fixture_path
26
47
 
@@ -12,14 +12,9 @@ module RSpec
12
12
  # @private prevent ActiveSupport::TestFixtures to start a DB transaction.
13
13
  # Monkey patched to avoid collisions with 'let(:name)' in Rails 6.1 and after
14
14
  # and let(:method_name) before Rails 6.1.
15
- if ::Rails::VERSION::STRING > '5'
16
- def run_in_transaction?
17
- use_transactional_tests && !self.class.uses_transaction?(self)
18
- end
19
- else
20
- def run_in_transaction?
21
- use_transactional_fixtures && !self.class.uses_transaction?(self)
22
- end
15
+ def run_in_transaction?
16
+ current_example_name = (RSpec.current_example && RSpec.current_example.metadata[:description])
17
+ use_transactional_tests && !self.class.uses_transaction?(current_example_name)
23
18
  end
24
19
 
25
20
  included do
@@ -27,11 +22,7 @@ module RSpec
27
22
  include Fixtures
28
23
 
29
24
  self.fixture_path = RSpec.configuration.fixture_path
30
- if ::Rails::VERSION::STRING > '5'
31
- self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
32
- else
33
- self.use_transactional_fixtures = RSpec.configuration.use_transactional_fixtures
34
- end
25
+ self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
35
26
  self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
36
27
 
37
28
  fixtures RSpec.configuration.global_fixtures if RSpec.configuration.global_fixtures
@@ -22,11 +22,20 @@ module RSpec
22
22
  @inbound_email = create_inbound_email(message)
23
23
  end
24
24
 
25
- def matches?(mailbox)
26
- @mailbox = mailbox
27
- @receiver = ApplicationMailbox.router.send(:match_to_mailbox, inbound_email)
25
+ if defined?(::ApplicationMailbox) && ::ApplicationMailbox.router.respond_to?(:mailbox_for)
26
+ def matches?(mailbox)
27
+ @mailbox = mailbox
28
+ @receiver = ApplicationMailbox.router.mailbox_for(inbound_email)
28
29
 
29
- @receiver == @mailbox
30
+ @receiver == @mailbox
31
+ end
32
+ else
33
+ def matches?(mailbox)
34
+ @mailbox = mailbox
35
+ @receiver = ApplicationMailbox.router.send(:match_to_mailbox, inbound_email)
36
+
37
+ @receiver == @mailbox
38
+ end
30
39
  end
31
40
 
32
41
  def failure_message
@@ -41,7 +50,7 @@ module RSpec
41
50
  "expected #{describe_inbound_email} not to route to #{mailbox}"
42
51
  end
43
52
 
44
- private
53
+ private
45
54
 
46
55
  attr_reader :inbound_email, :mailbox, :receiver
47
56
 
@@ -4,6 +4,7 @@
4
4
  require "rspec/mocks/argument_matchers"
5
5
  require "rspec/rails/matchers/active_job"
6
6
 
7
+ # rubocop: disable Metrics/ClassLength
7
8
  module RSpec
8
9
  module Rails
9
10
  module Matchers
@@ -119,9 +120,11 @@ module RSpec
119
120
  end
120
121
 
121
122
  def mail_job_message(job)
122
- mailer_method = job[:args][0..1].join('.')
123
+ job_args = deserialize_arguments(job)
124
+
125
+ mailer_method = job_args[0..1].join('.')
126
+ mailer_args = job_args[3..-1]
123
127
 
124
- mailer_args = job[:args][3..-1]
125
128
  msg_parts = []
126
129
  msg_parts << "with #{mailer_args}" if mailer_args.any?
127
130
  msg_parts << "on queue #{job[:queue]}" if job[:queue] && job[:queue] != 'mailers'
@@ -130,6 +133,30 @@ module RSpec
130
133
  "#{mailer_method} #{msg_parts.join(', ')}".strip
131
134
  end
132
135
 
136
+ # Ruby 3.1 changed how params were serialized on Rails 6.1
137
+ # so we override the active job implementation and customise it here.
138
+ def deserialize_arguments(job)
139
+ args = super
140
+
141
+ return args unless Hash === args.last
142
+
143
+ hash = args.pop
144
+
145
+ if hash.key?("_aj_ruby2_keywords")
146
+ keywords = hash["_aj_ruby2_keywords"]
147
+
148
+ original_hash = keywords.each_with_object({}) { |new_hash, keyword| new_hash[keyword.to_sym] = hash[keyword] }
149
+
150
+ args + [original_hash]
151
+ elsif hash.key?(:args) && hash.key?(:params)
152
+ args + [hash]
153
+ elsif hash.key?(:args)
154
+ args + hash[:args]
155
+ else
156
+ args + [hash]
157
+ end
158
+ end
159
+
133
160
  def legacy_mail?(job)
134
161
  job[:job] <= ActionMailer::DeliveryJob
135
162
  end
@@ -196,3 +223,4 @@ module RSpec
196
223
  end
197
224
  end
198
225
  end
226
+ # rubocop: enable Metrics/ClassLength
@@ -1,6 +1,6 @@
1
1
  # The following code inspired and modified from Rails' `assert_response`:
2
2
  #
3
- # https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/testing/assertions/response.rb#L22-L38
3
+ # https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/testing/assertions/response.rb#L22-L38
4
4
  #
5
5
  # Thank you to all the Rails devs who did the heavy lifting on this!
6
6
 
@@ -243,7 +243,7 @@ module RSpec
243
243
 
244
244
  # @return [Array<Symbol>] of status codes which represent a HTTP status
245
245
  # code "group"
246
- # @see https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
246
+ # @see https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
247
247
  def self.valid_statuses
248
248
  [
249
249
  :error, :success, :missing,
@@ -313,7 +313,7 @@ module RSpec
313
313
 
314
314
  # @return [String] formatting the associated code(s) for the various
315
315
  # status code "groups"
316
- # @see https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
316
+ # @see https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
317
317
  # @see https://github.com/rack/rack/blob/master/lib/rack/response.rb `Rack::Response`
318
318
  def type_codes
319
319
  # At the time of this commit the most recent version of
@@ -373,7 +373,7 @@ module RSpec
373
373
  # expect(response).to have_http_status(404)
374
374
  # expect(page).to have_http_status(:created)
375
375
  #
376
- # @see https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
376
+ # @see https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
377
377
  # @see https://github.com/rack/rack/blob/master/lib/rack/utils.rb `Rack::Utils::SYMBOL_TO_STATUS_CODE`
378
378
  def have_http_status(target)
379
379
  raise ArgumentError, "Invalid HTTP status: nil" unless target
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec Rails.
4
4
  module Version
5
5
  # Current version of RSpec Rails, in semantic versioning format.
6
- STRING = '4.1.2'
6
+ STRING = '5.0.3'
7
7
  end
8
8
  end
9
9
  end
data/lib/rspec-rails.rb CHANGED
@@ -7,13 +7,11 @@ module RSpec
7
7
  # Railtie to hook into Rails.
8
8
  class Railtie < ::Rails::Railtie
9
9
  # As of Rails 5.1.0 you can register directories to work with `rake notes`
10
- if ::Rails::VERSION::STRING >= '5.1'
11
- require 'rails/source_annotation_extractor'
12
- if ::Rails::VERSION::STRING >= '6.0'
13
- ::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec")
14
- else
15
- SourceAnnotationExtractor::Annotation.register_directories("spec")
16
- end
10
+ require 'rails/source_annotation_extractor'
11
+ if ::Rails::VERSION::STRING >= '6.0'
12
+ ::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec")
13
+ else
14
+ SourceAnnotationExtractor::Annotation.register_directories("spec")
17
15
  end
18
16
  generators = config.app_generators
19
17
  generators.integration_tool :rspec
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -44,7 +44,7 @@ cert_chain:
44
44
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
45
45
  F3MdtaDehhjC
46
46
  -----END CERTIFICATE-----
47
- date: 2021-03-10 00:00:00.000000000 Z
47
+ date: 2022-01-26 00:00:00.000000000 Z
48
48
  dependencies:
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: actionpack
@@ -52,42 +52,42 @@ dependencies:
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: '4.2'
55
+ version: '5.2'
56
56
  type: :runtime
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '4.2'
62
+ version: '5.2'
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: activesupport
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '4.2'
69
+ version: '5.2'
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: '4.2'
76
+ version: '5.2'
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: railties
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: '4.2'
83
+ version: '5.2'
84
84
  type: :runtime
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: '4.2'
90
+ version: '5.2'
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec-core
93
93
  requirement: !ruby/object:Gem::Requirement
@@ -176,16 +176,28 @@ dependencies:
176
176
  name: cucumber
177
177
  requirement: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - "~>"
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '3.2'
182
+ - - "!="
183
+ - !ruby/object:Gem::Version
184
+ version: 4.0.0
185
+ - - "<"
180
186
  - !ruby/object:Gem::Version
181
- version: 1.3.5
187
+ version: 8.0.0
182
188
  type: :development
183
189
  prerelease: false
184
190
  version_requirements: !ruby/object:Gem::Requirement
185
191
  requirements:
186
- - - "~>"
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '3.2'
195
+ - - "!="
196
+ - !ruby/object:Gem::Version
197
+ version: 4.0.0
198
+ - - "<"
187
199
  - !ruby/object:Gem::Version
188
- version: 1.3.5
200
+ version: 8.0.0
189
201
  description: rspec-rails is a testing framework for Rails 5+.
190
202
  email: rspec@googlegroups.com
191
203
  executables: []
@@ -296,7 +308,7 @@ licenses:
296
308
  - MIT
297
309
  metadata:
298
310
  bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
299
- changelog_uri: https://github.com/rspec/rspec-rails/blob/v4.1.2/Changelog.md
311
+ changelog_uri: https://github.com/rspec/rspec-rails/blob/v5.0.3/Changelog.md
300
312
  documentation_uri: https://rspec.info/documentation/
301
313
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
302
314
  source_code_uri: https://github.com/rspec/rspec-rails
@@ -316,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
328
  - !ruby/object:Gem::Version
317
329
  version: '0'
318
330
  requirements: []
319
- rubygems_version: 3.2.4
331
+ rubygems_version: 3.3.3
320
332
  signing_key:
321
333
  specification_version: 4
322
334
  summary: RSpec for Rails
metadata.gz.sig CHANGED
Binary file