rubocop-discourse 2.2.0 → 2.3.0

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: 4393a2ad64c2662ce3c1dcdb1608501b93b6c13bc31b9a7a2a25b2c8a1404e89
4
- data.tar.gz: eabd1def336f6290d8a694c209256827585b4a28baa2f0a84fa74f65cfc76f07
3
+ metadata.gz: 954b3ae3f59036a9880d2d055c37e97e5bbc0d454207638cc390efb41cfde649
4
+ data.tar.gz: 7b5607256ae2d3190a9d7d1ef7d95f73deb23964139a8a10c3fb628663912d96
5
5
  SHA512:
6
- metadata.gz: 40a5a38b088a3ab91c3a155ab4a2bcf78ed44ecd62a4fc98ccbf2b21cba5aac0d6d906b460e5be293f48dace6be3295d73841b0c147f9c4296002b094971d95b
7
- data.tar.gz: 72b08959eb26c04941c3fc972a3d9725f6465355f02c0fb1913dfa7826a76ca42ad716327a1a40ea541eebadbfc01715783dc2467fa255d204cff7d09c36f213
6
+ metadata.gz: 4916ff3fcd7569705f59ced1716acbbeec52d763eff392e6eb148d5bc72d4fe6cff5644a0dfedc89353b4f856d77e609159d178b2b2d9643f904bed88d59cb4a
7
+ data.tar.gz: 8c1a20229b96ef6b69085147c95c5b799c6f7c9b0d38e8dc63c5cb5dc07931a332c231771f45fe656bd03c563fd3fa85f8f1c2bf79d9d64ad96415ce6ce764e3
@@ -44,3 +44,9 @@ Discourse/NoJsonParseResponse:
44
44
  Patterns:
45
45
  - _spec.rb
46
46
  - "(?:^|/)spec/"
47
+
48
+ Discourse/NoMockingJobs:
49
+ Enabled: true
50
+ Patterns:
51
+ - _spec.rb
52
+ - "(?:^|/)spec/"
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Discourse
6
+ class NoMockingJobs < Cop
7
+ MSG = "Use the test helpers provided by Sidekiq instead of mocking `Jobs`."
8
+
9
+ def_node_matcher :mocking_jobs?, <<~MATCHER
10
+ (send (const nil? :Jobs) :expects ...)
11
+ MATCHER
12
+
13
+ def on_send(node)
14
+ return unless mocking_jobs?(node)
15
+ add_offense(node, message: MSG)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rubocop-discourse"
5
- s.version = "2.2.0"
5
+ s.version = "2.3.0"
6
6
  s.summary = "Custom rubocop cops used by Discourse"
7
7
  s.authors = ["David Taylor"]
8
8
  s.files = `git ls-files`.split($/)
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe RuboCop::Cop::Discourse::NoMockingJobs, :config do
6
+ subject(:cop) { described_class.new(config) }
7
+
8
+ let(:config) do
9
+ RuboCop::Config.new
10
+ end
11
+
12
+ it "raises an offense if Jobs is mocked" do
13
+ inspect_source(<<~RUBY)
14
+ Jobs.expects(:enqueue)
15
+ RUBY
16
+
17
+ expect(cop.offenses.first.message).to eq(described_class::MSG)
18
+ end
19
+
20
+ it "does not raise an offense if Jobs is not mocked" do
21
+ inspect_source(<<~RUBY)
22
+ Jobs.enqueue(:some_job)
23
+ RUBY
24
+
25
+ expect(cop.offenses).to eq([])
26
+ end
27
+ end
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.2.0
4
+ version: 2.3.0
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-06-17 00:00:00.000000000 Z
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -86,6 +86,7 @@ files:
86
86
  - lib/rubocop/cop/discourse/no_chdir.rb
87
87
  - lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
88
88
  - lib/rubocop/cop/discourse/no_json_parse_response.rb
89
+ - lib/rubocop/cop/discourse/no_mocking_jobs.rb
89
90
  - lib/rubocop/cop/discourse/no_nokogiri_html_fragment.rb
90
91
  - lib/rubocop/cop/discourse/no_reset_column_information_in_migrations.rb
91
92
  - lib/rubocop/cop/discourse/no_time_new_without_args.rb
@@ -98,6 +99,7 @@ files:
98
99
  - rubocop-discourse.gemspec
99
100
  - rubocop-rspec.yml
100
101
  - spec/lib/rubocop/cop/no_add_reference_active_record_migrations_spec.rb
102
+ - spec/lib/rubocop/cop/no_mocking_jobs_spec.rb
101
103
  - spec/lib/rubocop/cop/no_reset_column_information_migrations_spec.rb
102
104
  - spec/spec_helper.rb
103
105
  homepage: