Module: Crspec::SharedRegistry
- Defined in:
- lib/crspec/shared_examples.rb
Overview
Registry of shared example groups / contexts. Registration happens at load time (single-threaded); lookups at group-definition time. Blocks are re-evaluated in the including group, so no state is shared between examples — parallel-safe by construction.
Class Method Summary collapse
Class Method Details
.fetch(name) ⇒ Object
18 19 20 21 |
# File 'lib/crspec/shared_examples.rb', line 18 def fetch(name) registry[name.to_s] or raise ArgumentError, "Could not find shared examples or context #{name.inspect}" end |
.register(name, block) ⇒ Object
14 15 16 |
# File 'lib/crspec/shared_examples.rb', line 14 def register(name, block) registry[name.to_s] = block end |
.registry ⇒ Object
10 11 12 |
# File 'lib/crspec/shared_examples.rb', line 10 def registry @registry ||= {} end |
.reset! ⇒ Object
23 24 25 |
# File 'lib/crspec/shared_examples.rb', line 23 def reset! @registry = {} end |