lib/rubocop/cop/rspec/shared_context.rb in rubocop-rspec-2.0.0.pre vs lib/rubocop/cop/rspec/shared_context.rb in rubocop-rspec-2.0.0

- old
+ new

@@ -57,17 +57,27 @@ 'define context.' MSG_CONTEXT = "Use `shared_context` when you don't "\ 'define examples.' - examples = (Examples::ALL + Includes::EXAMPLES) - def_node_search :examples?, examples.send_pattern + def_node_search :examples?, + send_pattern('{#Includes.examples #Examples.all}') - context = (Hooks::ALL + Helpers::ALL + Includes::CONTEXT + Subject::ALL) - def_node_search :context?, context.send_pattern + def_node_search :context?, <<-PATTERN + ( + send #rspec? { + #Subjects.all + #Helpers.all + #Includes.context + #Hooks.all + } ... + ) + PATTERN - def_node_matcher :shared_context, SharedGroups::CONTEXT.block_pattern - def_node_matcher :shared_example, SharedGroups::EXAMPLES.block_pattern + def_node_matcher :shared_context, + block_pattern('#SharedGroups.context') + def_node_matcher :shared_example, + block_pattern('#SharedGroups.examples') def on_block(node) context_with_only_examples(node) do add_offense(node.send_node, message: MSG_EXAMPLES) do |corrector| corrector.replace(node.send_node.loc.selector, 'shared_examples')