Class: Nutrasuite::Context
- Inherits:
-
Object
- Object
- Nutrasuite::Context
- Defined in:
- lib/nutrasuite/contexts.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#setups ⇒ Object
readonly
Returns the value of attribute setups.
-
#teardowns ⇒ Object
readonly
Returns the value of attribute teardowns.
Class Method Summary collapse
- .build_test_name(name = "") ⇒ Object
- .context_stack ⇒ Object
- .current_context ⇒ Object
- .current_context? ⇒ Boolean
- .push(name, &block) ⇒ Object
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(name, &block) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(name, &block) ⇒ Context
Returns a new instance of Context.
74 75 76 77 78 79 80 |
# File 'lib/nutrasuite/contexts.rb', line 74 def initialize(name, &block) @name = name @block = block @setups = [] @teardowns = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
72 73 74 |
# File 'lib/nutrasuite/contexts.rb', line 72 def name @name end |
#setups ⇒ Object (readonly)
Returns the value of attribute setups.
72 73 74 |
# File 'lib/nutrasuite/contexts.rb', line 72 def setups @setups end |
#teardowns ⇒ Object (readonly)
Returns the value of attribute teardowns.
72 73 74 |
# File 'lib/nutrasuite/contexts.rb', line 72 def teardowns @teardowns end |
Class Method Details
.build_test_name(name = "") ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/nutrasuite/contexts.rb', line 86 def self.build_test_name(name="") full_name = "test " context_stack.each do |context| full_name << context.name << " " end full_name << name end |
.context_stack ⇒ Object
103 104 105 |
# File 'lib/nutrasuite/contexts.rb', line 103 def self.context_stack @context_stack ||= [] end |
.current_context ⇒ Object
107 108 109 |
# File 'lib/nutrasuite/contexts.rb', line 107 def self.current_context context_stack.last end |
.current_context? ⇒ Boolean
111 112 113 |
# File 'lib/nutrasuite/contexts.rb', line 111 def self.current_context? !context_stack.empty? end |
Instance Method Details
#build ⇒ Object
82 83 84 |
# File 'lib/nutrasuite/contexts.rb', line 82 def build @block.call end |