ezcater_rubocop 0.57.0 → 0.57.1.rc1

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: 8943926de27d2e7dc09368390a4c99a307182ea02fa169bb9d2a99ba86215411
4
- data.tar.gz: 0f281ac0be4b5091c34807f1a8ea0207a9bd4c397d559f4ca11f21e40943fd7a
3
+ metadata.gz: 594f9a35130cc34ff4d3cf3ab5df960fad929a7595f489ec490d421a626aa570
4
+ data.tar.gz: 4c45aa0ca4f30aeec78a47fa4ca6306d295aa46f29e43dec2be1b7a3cae4cde5
5
5
  SHA512:
6
- metadata.gz: b36ff32b48d9459f6674c0aba02b9a7cb6bd7d43094699005b9361ef125ecd18c857b6a3e81a1afbcb32076209a8d960a193f0dd461e1e9cf117a51beca6a8c8
7
- data.tar.gz: bb10cfc742a558e85976663c536a1f035e70c8a31d0f3c268e1fd23625478dd9330401e17875a8a292b6f1f0f25697dc9d594000b9edfe07e32f5d16b9822de6
6
+ metadata.gz: 47befdebcbbacf4e3ecf2d323b429b672e488af3e04767b1c27b280008a4e6df721e63bec6c536065d9bdba92d6458d4a8d651f189421aaa7ea2b3f81ed38ab1
7
+ data.tar.gz: cffce667d759c26c966fd5fe13ec74ae59ff1e974201a78dcaf9070855742b1d0c9dae51ca8f3c761dce6e17502853609ba1feae7bf736b94d34688dd23cf8c7
@@ -0,0 +1,7 @@
1
+ ## What did we change?
2
+
3
+ ## Why are we doing this?
4
+
5
+ ## How was it tested?
6
+ - [ ] Specs
7
+ - [ ] Locally
@@ -1,5 +1,9 @@
1
1
  # ezcater_rubocop
2
2
 
3
+ ## v0.57.1
4
+ - Add `Ezcater/RspecRequireHttpStatusMatcher` cop.
5
+ - Enable `RSpec/Rails/HttpStatus` cop and enforce symbols.
6
+
3
7
  ## v0.57.0
4
8
  - Update to rubocop v0.57.2 and rubocop-rspec v1.27.0.
5
9
  - Disable new cop `Naming/MemoizedInstanceVariableName` until configuration
data/README.md CHANGED
@@ -90,6 +90,7 @@ is updated.
90
90
  1. [RspecMatchOrderedArray](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb) - Enforce use of `match_ordered_array` matcher instead of `eq` matcher. This matcher comes from the [ezcater_matchers](https://github.com/ezcater/ezcater_matchers) gem.
91
91
  1. [RspecRequireBrowserMock](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb) - Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly.
92
92
  1. [RspecRequireFeatureFlagMock](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb) - Enforce use of `mock_feature_flag` helper instead of mocking `FeatureFlag.is_active?` directly.
93
+ 1. [RspecRequireHttpStatusMatcher](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_http_status_matcher.rb) - Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`
93
94
  1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
94
95
 
95
96
  ## Development
@@ -15,6 +15,9 @@ Rails/RelativeDateConstant:
15
15
  # constant but does not update references to it.
16
16
  AutoCorrect: false
17
17
 
18
+ RSpec/Rails/HttpStatus:
19
+ EnforcedStyle: symbolic
20
+
18
21
  Style/MixinUsage:
19
22
  Exclude:
20
23
  - "bin/**/*"
@@ -24,6 +24,12 @@ Ezcater/RspecRequireFeatureFlagMock:
24
24
  Include:
25
25
  - '**/*_spec.rb'
26
26
 
27
+ Ezcater/RspecRequireHttpStatusMatcher:
28
+ Description: 'Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`'
29
+ Enabled: true
30
+ Include:
31
+ - '**/*_spec.rb'
32
+
27
33
  Ezcater/RequireGqlErrorHelpers:
28
34
  Description: 'Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.'
29
35
  Enabled: true
@@ -20,5 +20,6 @@ require "rubocop/cop/ezcater/require_gql_error_helpers"
20
20
  require "rubocop/cop/ezcater/rspec_match_ordered_array"
21
21
  require "rubocop/cop/ezcater/rspec_require_browser_mock"
22
22
  require "rubocop/cop/ezcater/rspec_require_feature_flag_mock"
23
+ require "rubocop/cop/ezcater/rspec_require_http_status_matcher"
23
24
  require "rubocop/cop/ezcater/rspec_dot_not_self_dot"
24
25
  require "rubocop/cop/ezcater/style_dig"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzcaterRubocop
4
- VERSION = "0.57.0"
4
+ VERSION = "0.57.1.rc1"
5
5
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Ezcater
6
+ # Enforce use of HTTP status code matchers rather than asserting on on random numbers.
7
+ #
8
+ # @example
9
+ #
10
+ # # good
11
+ # expect(response).to be_created
12
+ # expect(response).to be_bad_request
13
+ #
14
+ # # bad
15
+ # expect(response).to have_http_status 201
16
+ # expect(response).to have_http_status 400
17
+ class RspecRequireHttpStatusMatcher < Cop
18
+ MSG = "Use the `have_http_status_code` matcher, like `expect(response).to have_http_status :bad_request`, "\
19
+ "rather than `%<node_source>s`"
20
+
21
+ def_node_matcher :response_code_assertion, <<~PATTERN
22
+ (send (send _ :expect (send (send _ :response) :code)) :to (send _ :eq (int _)))
23
+ PATTERN
24
+
25
+ def on_send(node)
26
+ return unless response_code_assertion(node)
27
+
28
+ add_offense(node,
29
+ location: :expression,
30
+ message: format(MSG, node_source: node.source))
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezcater_rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.57.0
4
+ version: 0.57.1.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-22 00:00:00.000000000 Z
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,6 +130,7 @@ executables:
130
130
  extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
+ - ".github/PULL_REQUEST_TEMPLATE.md"
133
134
  - CHANGELOG.md
134
135
  - Gemfile
135
136
  - LICENSE.txt
@@ -149,6 +150,7 @@ files:
149
150
  - lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb
150
151
  - lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
151
152
  - lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
153
+ - lib/rubocop/cop/ezcater/rspec_require_http_status_matcher.rb
152
154
  - lib/rubocop/cop/ezcater/style_dig.rb
153
155
  - lib/rubocop/rspec/language/each_selector.rb
154
156
  homepage: https://github.com/ezcater/ezcater_rubocop
@@ -167,9 +169,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
169
  version: '0'
168
170
  required_rubygems_version: !ruby/object:Gem::Requirement
169
171
  requirements:
170
- - - ">="
172
+ - - ">"
171
173
  - !ruby/object:Gem::Version
172
- version: '0'
174
+ version: 1.3.1
173
175
  requirements: []
174
176
  rubyforge_project:
175
177
  rubygems_version: 2.7.6