Class: DTest::SharedContext::Manager
- Inherits:
-
Object
- Object
- DTest::SharedContext::Manager
- Defined in:
- lib/dtest/shared_context.rb
Instance Attribute Summary collapse
-
#contexts ⇒ Object
readonly
Returns the value of attribute contexts.
Instance Method Summary collapse
- #add(name, option, &block) ⇒ Object
- #clear ⇒ Object
- #has_key?(name) ⇒ Boolean
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
Methods included from Hook
Methods included from Singleton
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
14 15 16 |
# File 'lib/dtest/shared_context.rb', line 14 def initialize clear end |
Instance Attribute Details
#contexts ⇒ Object (readonly)
Returns the value of attribute contexts.
12 13 14 |
# File 'lib/dtest/shared_context.rb', line 12 def contexts @contexts end |
Instance Method Details
#add(name, option, &block) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/dtest/shared_context.rb', line 27 def add(name, option, &block) file, line, = DTest::failure_line(caller(2).first) str = ["#{name} context already defined"] str << " in #{file}:#{line}" if file && line raise str.join("\n") if @contexts.has_key?(name) @contexts[name] = block end |
#clear ⇒ Object
18 19 20 21 |
# File 'lib/dtest/shared_context.rb', line 18 def clear remove_instance_var @contexts = {} end |
#has_key?(name) ⇒ Boolean
23 24 25 |
# File 'lib/dtest/shared_context.rb', line 23 def has_key?(name) @contexts.has_key?(name) end |