Class: RuboCop::Cop::RSpec::Focus
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/rspec/focus.rb
Overview
Checks if examples are focused.
This cop does not support autocorrection in some cases.
Constant Summary collapse
- MSG =
'Focused spec found.'
Instance Method Summary collapse
- #focusable_selector?(node) ⇒ Object
- #focused_block?(node) ⇒ Object
- #metadata(node) ⇒ Object
- #on_send(node) ⇒ Object
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
permalink #focusable_selector?(node) ⇒ Object
[View source]
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rubocop/cop/rspec/focus.rb', line 53 def_node_matcher :focusable_selector?, <<~PATTERN { #ExampleGroups.regular #ExampleGroups.skipped #Examples.regular #Examples.skipped #Examples.pending #SharedGroups.all } PATTERN |
permalink #focused_block?(node) ⇒ Object
[View source]
71 72 73 |
# File 'lib/rubocop/cop/rspec/focus.rb', line 71 def_node_matcher :focused_block?, <<~PATTERN (send #rspec? {#ExampleGroups.focused #Examples.focused} ...) PATTERN |
permalink #metadata(node) ⇒ Object
[View source]
65 66 67 68 |
# File 'lib/rubocop/cop/rspec/focus.rb', line 65 def_node_matcher :metadata, <<~PATTERN {(send #rspec? #focusable_selector? <$(sym :focus) ...>) (send #rspec? #focusable_selector? ... (hash <$(pair (sym :focus) true) ...>))} PATTERN |
permalink #on_send(node) ⇒ Object
[View source]
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rubocop/cop/rspec/focus.rb', line 75 def on_send(node) return if node.chained? || node.each_ancestor(:def, :defs).any? if focused_block?(node) on_focused_block(node) else (node) do |focus| (focus) end end end |