rspec-rails 4.0.2 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4fdfac614970485c2587ffc56aa4f4f5a79fc2bb2bd49045d607c61fb5bc510
4
- data.tar.gz: 0b8dabeb32e7b2d9a18c50d722f6c8ebda39610d35e8b45d329e26ff59f9046b
3
+ metadata.gz: b530810e523033d7513c99d9c37e6d6489803fa6d5cc3f2f734f453f4f1820e7
4
+ data.tar.gz: ba735aede717f9b8474f74a35bfa9377192ecbe234dbb215ece3f0a41583db3f
5
5
  SHA512:
6
- metadata.gz: '09c2ebd8e132d6b98f84265e5175a475cf47cd9ac6145324c722f70fa82d328ce7feb5fc8b14e06a44ca18eb22bd66c124e8694ea84965d80ada15884bee4ac5'
7
- data.tar.gz: 7a58ee48a4f590fde7c376019e531371cd576d7301318f38f1cb53baf817e75b29766d61b10f56fc367d764622478b7baf81c053e72ed63a558726c5dc35eb0e
6
+ metadata.gz: 29d53a4939bb2c0f18a80eac33e18fa9d7e905497f2735a30800c2be5bf0b0499f0b84be8ffbec93e6793ed8dcb14fe648017aecd36e52439d5f4a6f0e8c3450
7
+ data.tar.gz: c3d15b2bf8a9c5182aef5760027142898394ec83d75a210dce65f78f4dd5496cdb7451f2b30908a06942c9e897a1b7ba96254e00f59eefab3f151a805e8cda36
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,3 +1,40 @@
1
+ ### 4.1.2 / 2021-03-10
2
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.1.1...v4.1.2)
3
+
4
+ Bug Fixes:
5
+
6
+ * Prevent `NoMethodError` on Rails 4.2 when checking if a test is run
7
+ in transaction. (Geremia Taglialatela, #2480)
8
+
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.
12
+
13
+ ### 4.1.1 / 2021-03-09
14
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.1.0...v4.1.1)
15
+
16
+ Bug Fixes:
17
+
18
+ * Remove generated specs when destroying a generated controller.
19
+ (@Naokimi, #2475)
20
+
21
+ ### 4.1.0 / 2021-03-06
22
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.2...v4.1.0)
23
+
24
+ Enhancements:
25
+
26
+ * Issue a warning when using job matchers with `#at` mis-match on `usec` precision.
27
+ (Jon Rowe, #2350)
28
+ * Generated request specs now have a bare `_spec` suffix instead of `request_spec`.
29
+ (Eloy Espinaco, Luka Lüdicke, #2355, #2356, #2378)
30
+ * Generated scaffold now includes engine route helpers when inside a mountable engine.
31
+ (Andrew W. Lee, #2372)
32
+ * Improve request spec "controller" scafold when no action is specified.
33
+ (Thomas Hareau, #2399)
34
+ * Introduce testing snippets concept (Phil Pirozhkov, Benoit Tigeot, #2423)
35
+ * Prevent collisions with `let(:name)` for Rails 6.1 and `let(:method_name)` on older
36
+ Rails. (Benoit Tigeot, #2461)
37
+
1
38
  ### 4.0.2 / 2020-12-26
2
39
  [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.1...v4.0.2)
3
40
 
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
@@ -27,7 +27,7 @@ module Rspec
27
27
  end
28
28
 
29
29
  def generate_view_specs
30
- return if actions.empty?
30
+ return if actions.empty? && behavior == :invoke
31
31
  return unless options[:view_specs] && options[:template_engine]
32
32
 
33
33
  empty_directory File.join("spec", "views", file_path)
@@ -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,19 @@ 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
+ 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
23
+ end
24
+
12
25
  included do
13
26
  if RSpec.configuration.use_active_record?
14
27
  include Fixtures
@@ -50,13 +63,6 @@ module RSpec
50
63
  end
51
64
  end
52
65
  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
66
  end
61
67
  end
62
68
  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.2'
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.2
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-10 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.2/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