rubocop-rspec 1.37.0 → 1.37.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b83eaf98373fd696c64571d551394a287cecc7577b9b69ecf6b425a392b41e3
|
4
|
+
data.tar.gz: 390966b2a4e34f20dadd3b6f162ee812a2386602b32d98de7d5fa62f63af3e3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e4b4c02a0fb2987cb3fab05a26f557dc8f202262dc77202a1ba82916ac27c43d88d585218f6656c86dcfb1cd2e8c467e3b8ea2a50d790957401c2499d57a7d5
|
7
|
+
data.tar.gz: c496849147815725376d0bfc43c3c6da0cd544144434980460366ee013136df4203992b6fe90a31468d4529af145ee3608de1d80827bb406c69bc371cfec42af
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## Master (Unreleased)
|
4
4
|
|
5
|
+
## 1.37.1 (2019-12-16)
|
6
|
+
|
7
|
+
* Improve message and description of `FactoryBot/FactoryClassName`. ([@ybiquitous][])
|
8
|
+
* Fix `FactoryBot/FactoryClassName` to ignore `Hash` and `OpenStruct`. ([@jfragoulis][])
|
9
|
+
|
5
10
|
## 1.37.0 (2019-11-25)
|
6
11
|
|
7
12
|
* Implement `RSpec/DescribedClassModuleWrapping` to disallow RSpec statements within a module. ([@kellysutton][])
|
@@ -466,3 +471,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
|
|
466
471
|
[@kellysutton]: https://github.com/kellysutton
|
467
472
|
[@mkrawc]: https://github.com/mkrawc
|
468
473
|
[@jfragoulis]: https://github.com/jfragoulis
|
474
|
+
[@ybiquitous]: https://github.com/ybiquitous
|
@@ -6,6 +6,11 @@ module RuboCop
|
|
6
6
|
module FactoryBot
|
7
7
|
# Use string value when setting the class attribute explicitly.
|
8
8
|
#
|
9
|
+
# This cop would promote faster tests by lazy-loading of
|
10
|
+
# application files. Also, this could help you suppress potential bugs
|
11
|
+
# in combination with external libraries by avoiding a preload of
|
12
|
+
# application files from the factory files.
|
13
|
+
#
|
9
14
|
# @example
|
10
15
|
# # bad
|
11
16
|
# factory :foo, class: Foo do
|
@@ -15,7 +20,9 @@ module RuboCop
|
|
15
20
|
# factory :foo, class: 'Foo' do
|
16
21
|
# end
|
17
22
|
class FactoryClassName < Cop
|
18
|
-
MSG = "Pass '%<class_name>s' instead of
|
23
|
+
MSG = "Pass '%<class_name>s' string instead of `%<class_name>s` " \
|
24
|
+
'constant.'
|
25
|
+
ALLOWED_CONSTANTS = %w[Hash OpenStruct].freeze
|
19
26
|
|
20
27
|
def_node_matcher :class_name, <<~PATTERN
|
21
28
|
(send _ :factory _ (hash <(pair (sym :class) $(const ...)) ...>))
|
@@ -23,6 +30,8 @@ module RuboCop
|
|
23
30
|
|
24
31
|
def on_send(node)
|
25
32
|
class_name(node) do |cn|
|
33
|
+
next if allowed?(cn.const_name)
|
34
|
+
|
26
35
|
add_offense(cn, message: format(MSG, class_name: cn.const_name))
|
27
36
|
end
|
28
37
|
end
|
@@ -32,6 +41,12 @@ module RuboCop
|
|
32
41
|
corrector.replace(node.loc.expression, "'#{node.source}'")
|
33
42
|
end
|
34
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def allowed?(const_name)
|
48
|
+
ALLOWED_CONSTANTS.include?(const_name)
|
49
|
+
end
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|
@@ -9,7 +9,7 @@ require_relative 'rspec/factory_bot/factory_class_name'
|
|
9
9
|
|
10
10
|
begin
|
11
11
|
require_relative 'rspec/rails/http_status'
|
12
|
-
rescue LoadError # rubocop:disable Lint/
|
12
|
+
rescue LoadError # rubocop:disable Lint/SuppressedException
|
13
13
|
# Rails/HttpStatus cannot be loaded if rack/utils is unavailable.
|
14
14
|
end
|
15
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.37.
|
4
|
+
version: 1.37.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Backus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-12-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|