rubocop-discourse 2.3.0 → 2.3.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab3bab04445e93feec2c095fbd6f2c39c4a2df8e304727bd61138205fe32aa6f
|
4
|
+
data.tar.gz: 0b5727aa611459b01ccc2f5c664c8944f97682079dd698434b6b90468c99929e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 :
|
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
|
-
|
15
|
-
|
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
|
data/rubocop-discourse.gemspec
CHANGED
@@ -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 "
|
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.
|
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-
|
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/
|
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:
|