rspec-rails 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4fdfac614970485c2587ffc56aa4f4f5a79fc2bb2bd49045d607c61fb5bc510
4
- data.tar.gz: 0b8dabeb32e7b2d9a18c50d722f6c8ebda39610d35e8b45d329e26ff59f9046b
3
+ metadata.gz: 4cfb82b177fd4c881bb331fe78d7c0c7e974d8e886050b67db824aa4e4a93ab2
4
+ data.tar.gz: 1c55d80deaeab9a57af17b7b4c219490be2141c55d04fef428daa4a09fc3fd4f
5
5
  SHA512:
6
- metadata.gz: '09c2ebd8e132d6b98f84265e5175a475cf47cd9ac6145324c722f70fa82d328ce7feb5fc8b14e06a44ca18eb22bd66c124e8694ea84965d80ada15884bee4ac5'
7
- data.tar.gz: 7a58ee48a4f590fde7c376019e531371cd576d7301318f38f1cb53baf817e75b29766d61b10f56fc367d764622478b7baf81c053e72ed63a558726c5dc35eb0e
6
+ metadata.gz: 346b1d7428910e9b79881fa6a5ad616521fe6615c058ba559aa11136929e9f3ec7601d76e8a200123c74708f147d49c665b0fc649cf76a10f8b4ae55e734c6c0
7
+ data.tar.gz: 10478159e4622f40869d46fb36ab8a4472d469b2547bb54238164244511326393a3b66f7568787d0419aeac70fcb24942352f1f3fcdaede273070aa609b12cfc
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,3 +1,20 @@
1
+ ### 4.1.0 / 2021-03-06
2
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.2...v4.1.0)
3
+
4
+ Enhancements:
5
+
6
+ * Issue a warning when using job matchers with `#at` mis-match on `usec` precision.
7
+ (Jon Rowe, #2350)
8
+ * Generated request specs now have a bare `_spec` suffix instead of `request_spec`.
9
+ (Eloy Espinaco, Luka Lüdicke, #2355, #2356, #2378)
10
+ * Generated scaffold now includes engine route helpers when inside a mountable engine.
11
+ (Andrew W. Lee, #2372)
12
+ * Improve request spec "controller" scafold when no action is specified.
13
+ (Thomas Hareau, #2399)
14
+ * Introduce testing snippets concept (Phil Pirozhkov, Benoit Tigeot, #2423)
15
+ * Prevent collisions with `let(:name)` for Rails 6.1 and `let(:method_name)` on older
16
+ Rails. (Benoit Tigeot, #2461)
17
+
1
18
  ### 4.0.2 / 2020-12-26
2
19
  [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.1...v4.0.2)
3
20
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rspec-rails [![Build Status][]][travis-ci] [![Code Climate][]][code-climate] [![Gem Version][]](gem-version)
1
+ # rspec-rails [![Code Climate][]][code-climate] [![Gem Version][]][gem-version]
2
2
 
3
3
  `rspec-rails` brings the [RSpec][] testing framework to [Ruby on Rails][]
4
4
  as a drop-in alternative to its default testing framework, Minitest.
@@ -24,13 +24,16 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x.
24
24
 
25
25
  ## Installation
26
26
 
27
+ **IMPORTANT** This README / branch refers to the `4.1.x` series of releases.
28
+ See the [`main` branch on Github](https://github.com/rspec/rspec-rails/tree/main) for more up to date releases.
29
+
27
30
  1. Add `rspec-rails` to **both** the `:development` and `:test` groups
28
31
  of your app’s `Gemfile`:
29
32
 
30
33
  ```ruby
31
34
  # Run against the latest stable release
32
35
  group :development, :test do
33
- gem 'rspec-rails', '~> 4.0.1'
36
+ gem 'rspec-rails', '~> 4.1.0'
34
37
  end
35
38
 
36
39
  # Or, run against the main branch
@@ -16,7 +16,7 @@ module Rspec
16
16
  return unless options[:request_specs]
17
17
 
18
18
  template 'request_spec.rb',
19
- File.join('spec/requests', class_path, "#{file_name}_request_spec.rb")
19
+ File.join('spec/requests', class_path, "#{file_name}_spec.rb")
20
20
  end
21
21
 
22
22
  def generate_controller_spec
@@ -1,7 +1,12 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  RSpec.describe "<%= class_name.pluralize %>", <%= type_metatag(:request) %> do
4
- <% namespaced_path = regular_class_path.join('/') %>
4
+ <% namespaced_path = regular_class_path.join('/') -%>
5
+ <% if actions.empty? -%>
6
+ describe "GET /index" do
7
+ pending "add some examples (or delete) #{__FILE__}"
8
+ end
9
+ <% end -%>
5
10
  <% for action in actions -%>
6
11
  describe "GET /<%= action %>" do
7
12
  it "returns http success" do
@@ -14,6 +14,10 @@
14
14
 
15
15
  <% module_namespacing do -%>
16
16
  RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %> do
17
+ <% if mountable_engine? -%>
18
+ include Engine.routes.url_helpers
19
+ <% end -%>
20
+
17
21
  # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
18
22
  # adjust the attributes here as well.
19
23
  let(:valid_attributes) {
@@ -9,6 +9,13 @@ module RSpec
9
9
  include RSpec::Rails::MinitestAssertionAdapter
10
10
  include ActiveRecord::TestFixtures
11
11
 
12
+ # @private prevent ActiveSupport::TestFixtures to start a DB transaction.
13
+ # Monkey patched to avoid collisions with 'let(:name)' in Rails 6.1 and after
14
+ # and let(:method_name) before Rails 6.1.
15
+ def run_in_transaction?
16
+ use_transactional_tests && !self.class.uses_transaction?(self)
17
+ end
18
+
12
19
  included do
13
20
  if RSpec.configuration.use_active_record?
14
21
  include Fixtures
@@ -50,13 +57,6 @@ module RSpec
50
57
  end
51
58
  end
52
59
  end
53
-
54
- if ::Rails.version.to_f >= 6.1
55
- # @private return the example name for TestFixtures
56
- def name
57
- @example
58
- end
59
- end
60
60
  end
61
61
  end
62
62
  end
@@ -163,7 +163,29 @@ module RSpec
163
163
  return job[:at].nil? if @at == :no_wait
164
164
  return false unless job[:at]
165
165
 
166
- values_match?(@at, Time.at(job[:at]))
166
+ scheduled_at = Time.at(job[:at])
167
+ values_match?(@at, scheduled_at) || check_for_inprecise_value(scheduled_at)
168
+ end
169
+
170
+ def check_for_inprecise_value(scheduled_at)
171
+ return unless Time === @at && values_match?(@at.change(usec: 0), scheduled_at)
172
+
173
+ RSpec.warn_with((<<-WARNING).gsub(/^\s+\|/, '').chomp)
174
+ |[WARNING] Your expected `at(...)` value does not match the job scheduled_at value
175
+ |unless microseconds are removed. This precision error often occurs when checking
176
+ |values against `Time.current` / `Time.now` which have usec precision, but Rails
177
+ |uses `n.seconds.from_now` internally which has a usec count of `0`.
178
+ |
179
+ |Use `change(usec: 0)` to correct these values. For example:
180
+ |
181
+ |`Time.current.change(usec: 0)`
182
+ |
183
+ |Note: RSpec cannot do this for you because jobs can be scheduled with usec
184
+ |precision and we do not know wether it is on purpose or not.
185
+ |
186
+ |
187
+ WARNING
188
+ false
167
189
  end
168
190
 
169
191
  def set_expected_number(relativity, count)
@@ -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.0.2'
6
+ STRING = '4.1.0'
7
7
  end
8
8
  end
9
9
  end
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.0.2
4
+ version: 4.1.0
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: 2020-12-26 00:00:00.000000000 Z
47
+ date: 2021-03-06 00:00:00.000000000 Z
48
48
  dependencies:
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: actionpack
@@ -150,14 +150,14 @@ dependencies:
150
150
  requirements:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
- version: 1.1.2
153
+ version: 1.1.5
154
154
  type: :development
155
155
  prerelease: false
156
156
  version_requirements: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: 1.1.2
160
+ version: 1.1.5
161
161
  - !ruby/object:Gem::Dependency
162
162
  name: aruba
163
163
  requirement: !ruby/object:Gem::Requirement
@@ -296,7 +296,7 @@ licenses:
296
296
  - MIT
297
297
  metadata:
298
298
  bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
299
- changelog_uri: https://github.com/rspec/rspec-rails/blob/v4.0.2/Changelog.md
299
+ changelog_uri: https://github.com/rspec/rspec-rails/blob/v4.1.0/Changelog.md
300
300
  documentation_uri: https://rspec.info/documentation/
301
301
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
302
302
  source_code_uri: https://github.com/rspec/rspec-rails
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  - !ruby/object:Gem::Version
317
317
  version: '0'
318
318
  requirements: []
319
- rubygems_version: 3.1.4
319
+ rubygems_version: 3.2.4
320
320
  signing_key:
321
321
  specification_version: 4
322
322
  summary: RSpec for Rails
metadata.gz.sig CHANGED
Binary file