ezcater_rubocop 0.49.0 → 0.49.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +46 -0
- data/CHANGELOG.md +3 -0
- data/README.md +2 -1
- data/config/default.yml +6 -0
- data/ezcater_rubocop.gemspec +1 -0
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/ezcater_rubocop.rb +1 -0
- data/lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb +55 -0
- data/lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb +1 -2
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77cb533aad14aeabbd81a2a067bc9e3a9c72b534
|
4
|
+
data.tar.gz: 1ffeb88c423c859677da81bf193aa4ef1d235e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94b5280e3f83fbd4b25c6561894d832545377dc663eb809b13d857e9a5602cea32e4c6442140f4ca37859938b90d69b9bef5b93c8fd4f8945275ebf0e9c7b9ca
|
7
|
+
data.tar.gz: 1ad03213dda42ab4b510e8e2886c7b6b047abb06adc4859d517d96ed0a48870522ab04f5497c3efb983ee750282f071a8f6b55c3a9698fea04f6469517e01a4e
|
@@ -0,0 +1,46 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
parallelism: 1
|
5
|
+
working_directory: ~/ezcater
|
6
|
+
docker:
|
7
|
+
- image: circleci/ruby:2.3.3
|
8
|
+
steps:
|
9
|
+
- checkout
|
10
|
+
|
11
|
+
# Restore bundle cache
|
12
|
+
- restore_cache:
|
13
|
+
keys:
|
14
|
+
- ruby-cache-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "ezcater_rubocop.gemspec" }}
|
15
|
+
- ruby-cache-{{ .Branch }}-
|
16
|
+
- ruby-cache-
|
17
|
+
|
18
|
+
# Bundle install dependencies
|
19
|
+
- run: gem install bundler --no-document
|
20
|
+
- run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
|
21
|
+
- run: bundle clean --force
|
22
|
+
|
23
|
+
# Store bundle cache
|
24
|
+
- save_cache:
|
25
|
+
key: ruby-cache-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "ezcater_rubocop.gemspec" }}
|
26
|
+
paths:
|
27
|
+
- vendor/bundle
|
28
|
+
|
29
|
+
# Run Rubocop
|
30
|
+
- run:
|
31
|
+
name: RuboCop
|
32
|
+
command: bundle exec rubocop
|
33
|
+
|
34
|
+
# Run rspec in parallel
|
35
|
+
- type: shell
|
36
|
+
command: |
|
37
|
+
bundle exec rspec --profile 10 \
|
38
|
+
--format RspecJunitFormatter \
|
39
|
+
--out test_results/rspec.xml \
|
40
|
+
--format progress
|
41
|
+
|
42
|
+
# Save test results for timing analysis
|
43
|
+
- store_test_results:
|
44
|
+
path: test_results
|
45
|
+
- store_test_results:
|
46
|
+
path: tmp/capybara
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -48,7 +48,8 @@ is updated.
|
|
48
48
|
|
49
49
|
## Custom Cops
|
50
50
|
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.
|
51
|
-
1. [
|
51
|
+
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.
|
52
|
+
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.
|
52
53
|
1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
|
53
54
|
|
54
55
|
## Development
|
data/config/default.yml
CHANGED
@@ -4,6 +4,12 @@ Ezcater/RspecDotNotSelfDot:
|
|
4
4
|
Include:
|
5
5
|
- '**/*_spec.rb'
|
6
6
|
|
7
|
+
Ezcater/RspecRequireBrowserMock:
|
8
|
+
Description: 'Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly.'
|
9
|
+
Enabled: true
|
10
|
+
Include:
|
11
|
+
- '**/*_spec.rb'
|
12
|
+
|
7
13
|
Ezcater/RspecRequireFeatureFlagMock:
|
8
14
|
Description: 'Enforce use of `mock_feature_flag` helpers instead of mocking `FeatureFlag.is_active?` directly.'
|
9
15
|
Enabled: true
|
data/ezcater_rubocop.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency "bundler", "~> 1.15"
|
35
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
+
spec.add_development_dependency "rspec_junit_formatter"
|
37
38
|
spec.add_development_dependency "pry-byebug"
|
38
39
|
|
39
40
|
spec.add_runtime_dependency "rubocop", "~> 0.49.1"
|
data/lib/ezcater_rubocop.rb
CHANGED
@@ -12,6 +12,7 @@ puts "configuration from #{DEFAULT_FILES}" if RuboCop::ConfigLoader.debug?
|
|
12
12
|
config = RuboCop::ConfigLoader.merge_with_default(config, path)
|
13
13
|
RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
14
14
|
|
15
|
+
require "rubocop/cop/ezcater/rspec_require_browser_mock"
|
15
16
|
require "rubocop/cop/ezcater/rspec_require_feature_flag_mock"
|
16
17
|
require "rubocop/cop/ezcater/rspec_dot_not_self_dot"
|
17
18
|
require "rubocop/cop/ezcater/style_dig"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module RuboCop
|
2
|
+
module Cop
|
3
|
+
module Ezcater
|
4
|
+
# Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers
|
5
|
+
# instead of mocking `Browser` or `EzBrowser` directly.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
#
|
9
|
+
# # good
|
10
|
+
# mock_ezcater_app
|
11
|
+
# mock_chrome_browser
|
12
|
+
# mock_custom_browser
|
13
|
+
# mock_ezcater_app(device: "My Device", version: "1.2.3", language: "en=US,en")
|
14
|
+
# mock_chrome_browser(device: "My Device", version: "1.2.3", language: "en=US,en")
|
15
|
+
# mock_custom_browser(user_agent: "My Custom Agent", language: "en=US,en")
|
16
|
+
#
|
17
|
+
# # bad
|
18
|
+
# allow(Browser).to receive...
|
19
|
+
# allow(EzBrowser).to receive...
|
20
|
+
class RspecRequireBrowserMock < Cop
|
21
|
+
MSG = "Use the mocks provided by `BrowserHelpers` instead of mocking `%s`".freeze
|
22
|
+
|
23
|
+
def_node_matcher :browser_const?, <<~PATTERN
|
24
|
+
(const _ {:Browser, :EzBrowser})
|
25
|
+
PATTERN
|
26
|
+
|
27
|
+
def on_const(node)
|
28
|
+
return unless browser_const?(node) && node.descendants.empty?
|
29
|
+
|
30
|
+
# Walk to send node where method = :allow
|
31
|
+
match_node = node
|
32
|
+
match_node = match_node.parent while not_allow_send_node?(match_node.parent)
|
33
|
+
match_node = match_node.parent
|
34
|
+
|
35
|
+
# Validate send node, method = :allow; could have never been found
|
36
|
+
return unless allow_send_node?(match_node)
|
37
|
+
|
38
|
+
# Finish tree navigation to full line for highlighting
|
39
|
+
match_node = match_node.parent while match_node.parent
|
40
|
+
add_offense(match_node, :expression, MSG % node.source)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def not_allow_send_node?(node)
|
46
|
+
node && !allow_send_node?(node)
|
47
|
+
end
|
48
|
+
|
49
|
+
def allow_send_node?(node)
|
50
|
+
node && node.send_type? && node.method_name == :allow
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module RuboCop
|
2
2
|
module Cop
|
3
3
|
module Ezcater
|
4
|
-
# Enforce
|
5
|
-
# of allow(FeatureFlag) mocking.
|
4
|
+
# Enforce use of `mock_feature_flag` helper instead of mocking `FeatureFlag.is_active?` directly.
|
6
5
|
#
|
7
6
|
# @example
|
8
7
|
#
|
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.
|
4
|
+
version: 0.49.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec_junit_formatter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry-byebug
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,6 +115,7 @@ executables: []
|
|
101
115
|
extensions: []
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
118
|
+
- ".circleci/config.yml"
|
104
119
|
- ".gitignore"
|
105
120
|
- ".rspec"
|
106
121
|
- ".rubocop.yml"
|
@@ -119,6 +134,7 @@ files:
|
|
119
134
|
- lib/ezcater_rubocop.rb
|
120
135
|
- lib/ezcater_rubocop/version.rb
|
121
136
|
- lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb
|
137
|
+
- lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
|
122
138
|
- lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
|
123
139
|
- lib/rubocop/cop/ezcater/style_dig.rb
|
124
140
|
- lib/rubocop/rspec/language/each_selector.rb
|