Class: Tengu::ItBlock
- Inherits:
-
Object
- Object
- Tengu::ItBlock
- Includes:
- Matchers
- Defined in:
- lib/tengu/it_block.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#expectations ⇒ Object
readonly
Returns the value of attribute expectations.
Instance Method Summary collapse
-
#initialize(description, block) ⇒ ItBlock
constructor
A new instance of ItBlock.
- #pending? ⇒ Boolean
- #run(runner, listeners = []) ⇒ Object
- #success? ⇒ Boolean
Methods included from Matchers
#be, #be_false, #be_instance_of, #be_kind_of, #be_nil, #be_true, #eq, #eql, #equal, #have_received, #include, #match
Constructor Details
#initialize(description, block) ⇒ ItBlock
Returns a new instance of ItBlock.
11 12 13 14 15 16 17 |
# File 'lib/tengu/it_block.rb', line 11 def initialize(description, block) @description = description @block = block @success = true @pending = false @expectations = [] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/tengu/it_block.rb', line 9 def description @description end |
#expectations ⇒ Object (readonly)
Returns the value of attribute expectations.
9 10 11 |
# File 'lib/tengu/it_block.rb', line 9 def expectations @expectations end |
Instance Method Details
#pending? ⇒ Boolean
32 33 34 |
# File 'lib/tengu/it_block.rb', line 32 def pending? @pending end |
#run(runner, listeners = []) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/tengu/it_block.rb', line 19 def run(runner, listeners = []) @runner = runner instance_eval(&@block) @runner.reset_overrides notify(listeners) end |
#success? ⇒ Boolean
26 27 28 29 30 |
# File 'lib/tengu/it_block.rb', line 26 def success? unless pending? @expectations.all? { |expectation| expectation.success? } end end |