Sha256: 301df4d38edb055c833cc0c9b2f957e2b9123fb678d2ded1f879243ecbb510a4
Contents?: true
Size: 980 Bytes
Versions: 2
Compression:
Stored size: 980 Bytes
Contents
# frozen_string_literal: true module RuboCop module RSpec # Helper methods for top level example group cops module TopLevelGroup extend RuboCop::NodePattern::Macros include RuboCop::RSpec::Language def_node_matcher :example_or_shared_group?, (ExampleGroups::ALL + SharedGroups::ALL).block_pattern def on_block(node) return unless respond_to?(:on_top_level_group) return unless top_level_group?(node) on_top_level_group(node) end private def top_level_group?(node) top_level_groups.include?(node) end def top_level_groups @top_level_groups ||= top_level_nodes.select { |n| example_or_shared_group?(n) } end def top_level_nodes if root_node.begin_type? root_node.children else [root_node] end end def root_node processed_source.ast end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-1.42.0 | lib/rubocop/rspec/top_level_group.rb |
rubocop-rspec-1.41.0 | lib/rubocop/rspec/top_level_group.rb |