ezcater_rubocop 0.49.6 → 0.49.7.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: e32a7e2e0abe14baf6fa3593746512ced2390928f8f4226cd1fe50ffe1c08514
4
- data.tar.gz: c5604b7ea96840afbe48428d31e2b6690e903eca71ec1bfa6f7ce19302d7e32f
3
+ metadata.gz: 21616f4a6237e3b0d46df21c1f9cd1ce7b0841c4810ab3a0fb43ac6b5d0fad0a
4
+ data.tar.gz: e81db7bbd7dbcdbdeb7485ad7d3a58a95c74ce4271dd6e23feebce084d57bd9a
5
5
  SHA512:
6
- metadata.gz: 8c67093957e4064f049040d145edd3ffe9aa2df350a1146b7e5bdc1071a0bcf4f54c548fdcd93e32b8c516d3dd8e2a4f800c53a25005365190cacb07764ca0a3
7
- data.tar.gz: 9789e2c32a477cb1ef87526af0aeed545d889f8404263f5a4cc5889c5b70102946b91d856316f40f052ba0b70cf58ecb395e93cdf25db16f93c402dc1bfa1538
6
+ metadata.gz: b06b3574202e1da217ee1596732897ac28f4171c5860d50d3bf85dfc542e1d929eb7011f7400d94b4c9e65c6faa53c6e679a77621e560853749a535751c4b24f
7
+ data.tar.gz: 870d38c1c5d743cabe12b857c74056336f263a224ad7af64cacc1eb9457bf35c7d0078f6386d21357c576d6343091706f1dcf08dd390b8163a98d59b8fae1026
@@ -1,5 +1,9 @@
1
1
  # ezcater_rubocop
2
2
 
3
+ ## v0.49.7
4
+ - Add `Ezcater/RspecRequireHttpStatusMatcher` cop.
5
+ - Enable `Rails/HttpStatus` cop and enforce symbols.
6
+
3
7
  ## v0.49.6
4
8
  - Rename `Ezcater/RspecRequireGqlErrorHelpers` cop to `Ezcater/RequireGqlErrorHelpers`.
5
9
 
data/README.md CHANGED
@@ -52,6 +52,7 @@ is updated.
52
52
  1. [RspecDotNotSelfDot](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb) - Enforce ".<class method>" instead of "self.<class method>" for example group description.
53
53
  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.
54
54
  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.
55
+ 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`
55
56
  1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
56
57
 
57
58
  ## Development
@@ -20,6 +20,12 @@ Ezcater/RspecRequireFeatureFlagMock:
20
20
  Include:
21
21
  - '**/*_spec.rb'
22
22
 
23
+ Ezcater/RspecRequireHttpStatusMatcher:
24
+ Description: 'Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`'
25
+ Enabled: true
26
+ Include:
27
+ - '**/*_spec.rb'
28
+
23
29
  Ezcater/RequireGqlErrorHelpers:
24
30
  Description: 'Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.'
25
31
  Enabled: true
@@ -16,5 +16,6 @@ require "rubocop/cop/ezcater/rails_configuration"
16
16
  require "rubocop/cop/ezcater/require_gql_error_helpers"
17
17
  require "rubocop/cop/ezcater/rspec_require_browser_mock"
18
18
  require "rubocop/cop/ezcater/rspec_require_feature_flag_mock"
19
+ require "rubocop/cop/ezcater/rspec_require_http_status_matcher"
19
20
  require "rubocop/cop/ezcater/rspec_dot_not_self_dot"
20
21
  require "rubocop/cop/ezcater/style_dig"
@@ -1,3 +1,3 @@
1
1
  module EzcaterRubocop
2
- VERSION = "0.49.6".freeze
2
+ VERSION = "0.49.7.rc1".freeze
3
3
  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 have_http_status :created
12
+ # expect(response).to have_http_status :bad_request
13
+ #
14
+ # # bad
15
+ # expect(response.code).to eq 201
16
+ # expect(response.code).to eq 400
17
+ class RspecRequireHttpStatusMatcher < Cop
18
+ MSG = "Use the `have_http_status` 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.49.6
4
+ version: 0.49.7.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-24 00:00:00.000000000 Z
11
+ date: 2018-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -138,6 +138,7 @@ files:
138
138
  - lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb
139
139
  - lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
140
140
  - lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
141
+ - lib/rubocop/cop/ezcater/rspec_require_http_status_matcher.rb
141
142
  - lib/rubocop/cop/ezcater/style_dig.rb
142
143
  - lib/rubocop/rspec/language/each_selector.rb
143
144
  homepage: https://github.com/ezcater/ezcater_rubocop
@@ -156,9 +157,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
157
  version: '0'
157
158
  required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  requirements:
159
- - - ">="
160
+ - - ">"
160
161
  - !ruby/object:Gem::Version
161
- version: '0'
162
+ version: 1.3.1
162
163
  requirements: []
163
164
  rubyforge_project:
164
165
  rubygems_version: 2.7.4