Module: RuboCop::Cop::RSpec::Metadata
Overview
Helper methods to find RSpec metadata.
Instance Method Summary
collapse
#example?, #example_group?, #example_group_with_body?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
#block_pattern, #numblock_pattern, #send_pattern
Instance Method Details
26
27
28
|
# File 'lib/rubocop/cop/rspec/mixin/metadata.rb', line 26
def_node_search :metadata_in_block, "(send (lvar %) #Hooks.all _ ${send str sym}* (hash $...)?)\n"
|
#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 |symbols, pairs|
on_metadata(symbols, pairs.flatten)
end
end
rspec_metadata(node) do |symbols, pairs|
on_metadata(symbols, pairs.flatten)
end
end
|
43
44
45
|
# File 'lib/rubocop/cop/rspec/mixin/metadata.rb', line 43
def on_metadata(_symbols, _pairs)
raise ::NotImplementedError
end
|
21
22
23
|
# File 'lib/rubocop/cop/rspec/mixin/metadata.rb', line 21
def_node_matcher :rspec_configure, "(block (send #rspec? :configure) (args (arg $_)) ...)\n"
|
13
14
15
16
17
18
|
# File 'lib/rubocop/cop/rspec/mixin/metadata.rb', line 13
def_node_matcher :rspec_metadata, "(block\n (send\n #rspec? {#Examples.all #ExampleGroups.all #SharedGroups.all #Hooks.all} _ ${send str sym}* (hash $...)?)\n ...)\n"
|