Class: RuboCop::Cop::Ezcater::RspecRequireBrowserMock
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Ezcater::RspecRequireBrowserMock
- Defined in:
- lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
Overview
Enforce use of ‘mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly.
Constant Summary collapse
- MSG =
"Use the mocks provided by `BrowserHelpers` instead of mocking `%<node_source>s`"
Instance Method Summary collapse
Instance Method Details
#on_const(node) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb', line 29 def on_const(node) return unless browser_const?(node) && node.descendants.empty? # Walk to send node where method = :allow match_node = node match_node = match_node.parent while not_allow_send_node?(match_node.parent) match_node = match_node.parent # Validate send node, method = :allow; could have never been found return unless allow_send_node?(match_node) # Finish tree navigation to full line for highlighting match_node = match_node.parent while match_node.parent add_offense(match_node, location: :expression, message: format(MSG, node_source: node.source)) end |