Class: RuboCop::Cop::RSpec::PendingWithoutReason
- Inherits:
-
Base
- Object
- Base
- Base
- RuboCop::Cop::RSpec::PendingWithoutReason
show all
- Defined in:
- lib/rubocop/cop/rspec/pending_without_reason.rb
Overview
Checks for pending or skipped examples without reason.
Constant Summary
collapse
- MSG =
'Give the reason for pending or skip.'
Instance Method Summary
collapse
Methods inherited from Base
inherited, #on_new_investigation
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
82
83
84
85
86
87
88
89
90
|
# File 'lib/rubocop/cop/rspec/pending_without_reason.rb', line 82
def_node_matcher :metadata_without_reason?, <<~PATTERN
(send #rspec?
{#ExampleGroups.all #Examples.all} ...
{
<(sym ${:pending :skip}) ...>
(hash <(pair (sym ${:pending :skip}) true) ...>)
}
)
PATTERN
|
#on_send(node) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/rubocop/cop/rspec/pending_without_reason.rb', line 102
def on_send(node)
on_pending_by_metadata(node)
return unless (parent = parent_node(node))
if spec_group?(parent) || block_node_example_group?(node)
on_skipped_by_example_method(node)
on_skipped_by_example_group_method(node)
elsif example?(parent)
on_skipped_by_in_example_method(node)
end
end
|
#pending_step_without_reason?(node) ⇒ Object
98
99
100
|
# File 'lib/rubocop/cop/rspec/pending_without_reason.rb', line 98
def_node_matcher :pending_step_without_reason?, <<~PATTERN
(send nil? {:skip :pending})
PATTERN
|
#skipped_by_example_group_method?(node) ⇒ Object
93
94
95
|
# File 'lib/rubocop/cop/rspec/pending_without_reason.rb', line 93
def_node_matcher :skipped_by_example_group_method?, <<~PATTERN
(send #rspec? ${#ExampleGroups.skipped} ...)
PATTERN
|
#skipped_by_example_method?(node) ⇒ Object
72
73
74
|
# File 'lib/rubocop/cop/rspec/pending_without_reason.rb', line 72
def_node_matcher :skipped_by_example_method?, <<~PATTERN
(send nil? ${#Examples.skipped #Examples.pending})
PATTERN
|
#skipped_by_example_method_with_block?(node) ⇒ Object
77
78
79
|
# File 'lib/rubocop/cop/rspec/pending_without_reason.rb', line 77
def_node_matcher :skipped_by_example_method_with_block?, <<~PATTERN
({block numblock} (send nil? ${#Examples.skipped #Examples.pending} ...) ...)
PATTERN
|
#skipped_in_example?(node) ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/rubocop/cop/rspec/pending_without_reason.rb', line 63
def_node_matcher :skipped_in_example?, <<~PATTERN
{
(send nil? ${#Examples.skipped #Examples.pending})
(block (send nil? ${#Examples.skipped}) ...)
(numblock (send nil? ${#Examples.skipped}) ...)
}
PATTERN
|