rubocop-discourse 2.2.0 → 2.4.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: 4393a2ad64c2662ce3c1dcdb1608501b93b6c13bc31b9a7a2a25b2c8a1404e89
4
- data.tar.gz: eabd1def336f6290d8a694c209256827585b4a28baa2f0a84fa74f65cfc76f07
3
+ metadata.gz: 50836476c0589b9ca8acc327ce038e96e0e2896ad1facad4c91d389205aaffca
4
+ data.tar.gz: 42ed42e6fc27220ce081eb59855e72e5397c13aee5763c839777d7cd8172ea61
5
5
  SHA512:
6
- metadata.gz: 40a5a38b088a3ab91c3a155ab4a2bcf78ed44ecd62a4fc98ccbf2b21cba5aac0d6d906b460e5be293f48dace6be3295d73841b0c147f9c4296002b094971d95b
7
- data.tar.gz: 72b08959eb26c04941c3fc972a3d9725f6465355f02c0fb1913dfa7826a76ca42ad716327a1a40ea541eebadbfc01715783dc2467fa255d204cff7d09c36f213
6
+ metadata.gz: 04e74b802d15a2d1c1b2de4e312748733ef1e586220aaf0769b1b9f6212c5fc1fa245c2f4213ec06ac0c2e3b78bfcc10a8ef26c1b84571cc54401c6e17b03531
7
+ data.tar.gz: 30496a225a1d441fdfb83e824b7f9f004131616b703ee14e11b9a51f4d6e6509b2fc714abe775da026d9081e4f08e2a91b87be35f652386302557560518b1a47
@@ -19,7 +19,6 @@ jobs:
19
19
  uses: actions/setup-ruby@v1
20
20
  with:
21
21
  ruby-version: 2.6
22
- architecture: 'x64'
23
22
 
24
23
  - name: Setup bundler
25
24
  run: gem install bundler
data/.gitignore CHANGED
@@ -1,3 +1 @@
1
- .rubocop-http*
2
1
  Gemfile.lock
3
- .byebug_history
@@ -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,25 @@
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.expects(:enqueue)`."
8
+
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))
15
+ MATCHER
16
+
17
+ def on_send(node)
18
+ if mocking_jobs_enqueue?(node) || mocking_jobs_enqueue_in?(node)
19
+ add_offense(node, message: MSG)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Discourse
6
- # Use `time_eq` matcher with timestamps in specs.
6
+ # Use `eq_time` matcher with timestamps in specs.
7
7
  #
8
8
  # @example
9
9
  # # bad
@@ -12,7 +12,7 @@ module RuboCop
12
12
  # # good
13
13
  # expect(user.created_at).to eq_time(Time.zone.now)
14
14
  class TimeEqMatcher < Cop
15
- MSG = "Use time_eq when testing timestamps"
15
+ MSG = "Use eq_time when testing timestamps"
16
16
 
17
17
  def_node_matcher :using_eq_matcher_with_timestamp?, <<-MATCHER
18
18
  (send
@@ -2,15 +2,17 @@
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.4.1"
6
6
  s.summary = "Custom rubocop cops used by Discourse"
7
7
  s.authors = ["David Taylor"]
8
- s.files = `git ls-files`.split($/)
9
- s.license = "MIT"
8
+ s.license = "MIT"
9
+ s.homepage = "https://github.com/discourse/rubocop-discourse"
10
+
11
+ s.files = `git ls-files`.split($/)
10
12
  s.require_paths = ["lib"]
11
13
 
12
- s.add_runtime_dependency "rubocop", ">= 0.69.0"
13
- s.add_runtime_dependency "rubocop-rspec", ">= 1.39.0"
14
+ s.add_runtime_dependency "rubocop", ">= 1.1.0"
15
+ s.add_runtime_dependency "rubocop-rspec", ">= 2.0.0"
14
16
 
15
17
  s.add_development_dependency "rake", "~> 13.0"
16
18
  s.add_development_dependency "rspec"
@@ -99,9 +99,6 @@ RSpec/InstanceSpy:
99
99
  RSpec/InstanceVariable:
100
100
  Enabled: false # TODO
101
101
 
102
- RSpec/InvalidPredicateMatcher:
103
- Enabled: true
104
-
105
102
  RSpec/ItBehavesLike:
106
103
  Enabled: true
107
104
 
@@ -192,20 +189,20 @@ RSpec/VoidExpect:
192
189
  RSpec/Yield:
193
190
  Enabled: true
194
191
 
195
- Capybara/CurrentPathExpectation:
192
+ RSpec/Capybara/CurrentPathExpectation:
196
193
  Enabled: true
197
194
 
198
- Capybara/FeatureMethods:
195
+ RSpec/Capybara/FeatureMethods:
199
196
  Enabled: true
200
197
 
201
- FactoryBot/AttributeDefinedStatically:
198
+ RSpec/FactoryBot/AttributeDefinedStatically:
202
199
  Enabled: true
203
200
 
204
- FactoryBot/CreateList:
201
+ RSpec/FactoryBot/CreateList:
205
202
  Enabled: true
206
203
 
207
- FactoryBot/FactoryClassName:
204
+ RSpec/FactoryBot/FactoryClassName:
208
205
  Enabled: true
209
206
 
210
- Rails/HttpStatus:
207
+ RSpec/Rails/HttpStatus:
211
208
  Enabled: true
@@ -0,0 +1,35 @@
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 with :enqueue" 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 "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
29
+ inspect_source(<<~RUBY)
30
+ Jobs.enqueue(:some_job)
31
+ RUBY
32
+
33
+ expect(cop.offenses).to eq([])
34
+ end
35
+ 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.4.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-06-17 00:00:00.000000000 Z
11
+ date: 2020-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.69.0
19
+ version: 1.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.69.0
26
+ version: 1.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubocop-rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.39.0
33
+ version: 2.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.39.0
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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,9 +99,10 @@ 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_enqueue_spec.rb
101
103
  - spec/lib/rubocop/cop/no_reset_column_information_migrations_spec.rb
102
104
  - spec/spec_helper.rb
103
- homepage:
105
+ homepage: https://github.com/discourse/rubocop-discourse
104
106
  licenses:
105
107
  - MIT
106
108
  metadata: {}