Module: SpecSelectorUtil::DataMap
- Included in:
- SpecSelector
- Defined in:
- lib/spec_selector/data_map.rb
Overview
The DataMap module contains methods used to build a hash map of nested lists, which can be rendered in their interactive form through the DataPresentation methods.
Instance Method Summary collapse
- #map_example(example) ⇒ Object
- #map_group(group) ⇒ Object
- #parent_data(data) ⇒ Object
- #top_level_push(group) ⇒ Object
Instance Method Details
#map_example(example) ⇒ Object
33 34 35 36 |
# File 'lib/spec_selector/data_map.rb', line 33 def map_example(example) group = example.example_group @map[group.[:block]] << example end |
#map_group(group) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/spec_selector/data_map.rb', line 22 def map_group(group) if !group.[:parent_example_group] top_level_push(group) else parent = group.[:parent_example_group][:block] @map[parent] ||= [] @map[parent] << group @map[group.[:block]] ||= [] end end |
#parent_data(data) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/spec_selector/data_map.rb', line 14 def parent_data(data) keys = data.keys return data[:example_group] if keys.include?(:example_group) return data[:parent_example_group] if keys.include?(:parent_example_group) nil end |
#top_level_push(group) ⇒ Object
8 9 10 11 12 |
# File 'lib/spec_selector/data_map.rb', line 8 def top_level_push(group) @map[:top_level] ||= [] @map[:top_level] << group @map[group.[:block]] ||= [] end |