rubocop-rspec 1.37.0 → 1.37.1

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: 396ca6beb4f3a3bf18ff5bfb0a28481a15060795c84a4e5f1d5a0c44b25ad0f4
4
- data.tar.gz: 4efa382210002292fede62a31709e452bd1482ec979f0de2512a3447c4efdf13
3
+ metadata.gz: 9b83eaf98373fd696c64571d551394a287cecc7577b9b69ecf6b425a392b41e3
4
+ data.tar.gz: 390966b2a4e34f20dadd3b6f162ee812a2386602b32d98de7d5fa62f63af3e3a
5
5
  SHA512:
6
- metadata.gz: e38bd510d3b6061d2f24cd6b50f11fa147c4cd8c679a892e51e4b528e454f2aa8343ad367373d03cdb9b1075fa52fc01f2db049945a59363ec5e4299e41f4544
7
- data.tar.gz: b0c0bccd971f132dbfdc3854dac1c2260482e7f5667f9146a5aec6d9da550cb2016002023648bf6aaca210311dc4e859d44536883095b9d3cf31bea5c8b410d9
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 %<class_name>s."
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
@@ -11,7 +11,7 @@ module RuboCop
11
11
  #
12
12
  # # better
13
13
  # thing = Thing.new(baz: 42)
14
- # allow(foo).to receive(bar: thing)
14
+ # allow(foo).to receive(:bar).and_return(thing)
15
15
  #
16
16
  class MessageChain < Cop
17
17
  MSG = 'Avoid stubbing using `%<method>s`.'
@@ -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/HandleExceptions
12
+ rescue LoadError # rubocop:disable Lint/SuppressedException
13
13
  # Rails/HttpStatus cannot be loaded if rack/utils is unavailable.
14
14
  end
15
15
 
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module RSpec
5
5
  # Version information for the RSpec RuboCop plugin.
6
6
  module Version
7
- STRING = '1.37.0'
7
+ STRING = '1.37.1'
8
8
  end
9
9
  end
10
10
  end
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.0
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-11-25 00:00:00.000000000 Z
13
+ date: 2019-12-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop