Module: RuboCop::Cop::RSpec::Metadata
Overview
Helper methods to find RSpec metadata.
Instance Method Summary
collapse
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
26
27
28
|
# File 'lib/rubocop/cop/rspec/mixin/metadata.rb', line 26
def_node_search :metadata_in_block, <<~PATTERN
(send (lvar %) #Hooks.all _ $...)
PATTERN
|
#on_block(node) ⇒ Object
Also known as:
on_numblock
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/rubocop/cop/rspec/mixin/metadata.rb', line 30
def on_block(node)
rspec_configure(node) do |block_var|
metadata_in_block(node, block_var) do |metadata_arguments|
on_metadata_arguments(metadata_arguments)
end
end
rspec_metadata(node) do |metadata_arguments|
on_metadata_arguments(metadata_arguments)
end
end
|
43
44
45
|
# File 'lib/rubocop/cop/rspec/mixin/metadata.rb', line 43
def on_metadata(_symbols, _hash)
raise ::NotImplementedError
end
|
21
22
23
|
# File 'lib/rubocop/cop/rspec/mixin/metadata.rb', line 21
def_node_matcher :rspec_configure, <<~PATTERN
(block (send #rspec? :configure) (args (arg $_)) ...)
PATTERN
|
13
14
15
16
17
18
|
# File 'lib/rubocop/cop/rspec/mixin/metadata.rb', line 13
def_node_matcher :rspec_metadata, <<~PATTERN
(block
(send
#rspec? {#Examples.all #ExampleGroups.all #SharedGroups.all #Hooks.all} _ $...)
...)
PATTERN
|