rubocop-discourse 2.3.0 → 2.3.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: 954b3ae3f59036a9880d2d055c37e97e5bbc0d454207638cc390efb41cfde649
4
- data.tar.gz: 7b5607256ae2d3190a9d7d1ef7d95f73deb23964139a8a10c3fb628663912d96
3
+ metadata.gz: ab3bab04445e93feec2c095fbd6f2c39c4a2df8e304727bd61138205fe32aa6f
4
+ data.tar.gz: 0b5727aa611459b01ccc2f5c664c8944f97682079dd698434b6b90468c99929e
5
5
  SHA512:
6
- metadata.gz: 4916ff3fcd7569705f59ced1716acbbeec52d763eff392e6eb148d5bc72d4fe6cff5644a0dfedc89353b4f856d77e609159d178b2b2d9643f904bed88d59cb4a
7
- data.tar.gz: 8c1a20229b96ef6b69085147c95c5b799c6f7c9b0d38e8dc63c5cb5dc07931a332c231771f45fe656bd03c563fd3fa85f8f1c2bf79d9d64ad96415ce6ce764e3
6
+ metadata.gz: c4b717bce864cf92b1e3340f826e6671df6bc1fe3d1eecb5488ce1775c42fd8e321e345f728ef8c5852136e43d97f8a0605656b8b22b14b30637791b8666866b
7
+ data.tar.gz: 445c4334c24ee08db442ac0dd7f6b24908f206797d60613b8a22cce5f672753da955d8f084928f9cd8556aca5e3e4e853fbc23f7db1e90008a2914ee306ee496
@@ -4,15 +4,20 @@ module RuboCop
4
4
  module Cop
5
5
  module Discourse
6
6
  class NoMockingJobs < Cop
7
- MSG = "Use the test helpers provided by Sidekiq instead of mocking `Jobs`."
7
+ MSG = "Use the test helpers provided by Sidekiq instead of mocking `Jobs.expects(:enqueue)`."
8
8
 
9
- def_node_matcher :mocking_jobs?, <<~MATCHER
10
- (send (const nil? :Jobs) :expects ...)
9
+ def_node_matcher :mocking_jobs_enqueue?, <<~MATCHER
10
+ (send (const nil? :Jobs) :expects (:sym :enqueue))
11
+ MATCHER
12
+
13
+ def_node_matcher :mocking_jobs_enqueue_in?, <<~MATCHER
14
+ (send (const nil? :Jobs) :expects (:sym :enqueue_in))
11
15
  MATCHER
12
16
 
13
17
  def on_send(node)
14
- return unless mocking_jobs?(node)
15
- add_offense(node, message: MSG)
18
+ if mocking_jobs_enqueue?(node) || mocking_jobs_enqueue_in?(node)
19
+ add_offense(node, message: MSG)
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rubocop-discourse"
5
- s.version = "2.3.0"
5
+ s.version = "2.3.1"
6
6
  s.summary = "Custom rubocop cops used by Discourse"
7
7
  s.authors = ["David Taylor"]
8
8
  s.files = `git ls-files`.split($/)
@@ -9,7 +9,7 @@ describe RuboCop::Cop::Discourse::NoMockingJobs, :config do
9
9
  RuboCop::Config.new
10
10
  end
11
11
 
12
- it "raises an offense if Jobs is mocked" do
12
+ it "raises an offense if Jobs is mocked with :enqueue" do
13
13
  inspect_source(<<~RUBY)
14
14
  Jobs.expects(:enqueue)
15
15
  RUBY
@@ -17,7 +17,15 @@ describe RuboCop::Cop::Discourse::NoMockingJobs, :config do
17
17
  expect(cop.offenses.first.message).to eq(described_class::MSG)
18
18
  end
19
19
 
20
- it "does not raise an offense if Jobs is not mocked" do
20
+ it "raises an offense if Jobs is mocked with :enqueue_in" do
21
+ inspect_source(<<~RUBY)
22
+ Jobs.expects(:enqueue_in)
23
+ RUBY
24
+
25
+ expect(cop.offenses.first.message).to eq(described_class::MSG)
26
+ end
27
+
28
+ it "does not raise an offense if Jobs is not mocked with :enqueue or :enqueue_in" do
21
29
  inspect_source(<<~RUBY)
22
30
  Jobs.enqueue(:some_job)
23
31
  RUBY
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-discourse
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Taylor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-21 00:00:00.000000000 Z
11
+ date: 2020-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -99,7 +99,7 @@ files:
99
99
  - rubocop-discourse.gemspec
100
100
  - rubocop-rspec.yml
101
101
  - spec/lib/rubocop/cop/no_add_reference_active_record_migrations_spec.rb
102
- - spec/lib/rubocop/cop/no_mocking_jobs_spec.rb
102
+ - spec/lib/rubocop/cop/no_mocking_jobs_enqueue_spec.rb
103
103
  - spec/lib/rubocop/cop/no_reset_column_information_migrations_spec.rb
104
104
  - spec/spec_helper.rb
105
105
  homepage: