Class: Riot::Context
- Inherits:
-
Object
- Object
- Riot::Context
- Defined in:
- lib/riot/context.rb
Instance Attribute Summary collapse
-
#assertions ⇒ Object
readonly
The protein.
-
#description ⇒ Object
readonly
The protein.
-
#situation ⇒ Object
readonly
The protein.
Instance Method Summary collapse
- #asserts(what, &block) ⇒ Object
-
#bootstrap(a_situation) ⇒ Object
Walk it out.
- #context(description, &block) ⇒ Object
-
#initialize(description, reporter, parent = nil, &context_block) ⇒ Context
constructor
A new instance of Context.
- #report ⇒ Object
-
#setup(&block) ⇒ Object
DSLee stuff.
- #should(what, &block) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(description, reporter, parent = nil, &context_block) ⇒ Context
Returns a new instance of Context.
5 6 7 8 9 10 11 12 |
# File 'lib/riot/context.rb', line 5 def initialize(description, reporter, parent=nil, &context_block) @description, @reporter, @parent = description, reporter, parent @assertions = [] @situation = Situation.new bootstrap(@situation) instance_eval(&context_block) if block_given? # running the context report end |
Instance Attribute Details
#assertions ⇒ Object (readonly)
The protein
4 5 6 |
# File 'lib/riot/context.rb', line 4 def assertions @assertions end |
#description ⇒ Object (readonly)
The protein
4 5 6 |
# File 'lib/riot/context.rb', line 4 def description @description end |
#situation ⇒ Object (readonly)
The protein
4 5 6 |
# File 'lib/riot/context.rb', line 4 def situation @situation end |
Instance Method Details
#asserts(what, &block) ⇒ Object
33 |
# File 'lib/riot/context.rb', line 33 def asserts(what, &block) add_assertion("asserts #{what}", &block); end |
#bootstrap(a_situation) ⇒ Object
Walk it out. Call setup from parent first
15 16 17 18 |
# File 'lib/riot/context.rb', line 15 def bootstrap(a_situation) run_setup(a_situation, &@parent.bootstrap(a_situation)) if @parent @setup end |
#context(description, &block) ⇒ Object
32 |
# File 'lib/riot/context.rb', line 32 def context(description, &block) Context.new(description, @reporter, self, &block); end |
#report ⇒ Object
20 21 22 |
# File 'lib/riot/context.rb', line 20 def report assertions.each { |assertion| @reporter.process_assertion(assertion) } end |
#setup(&block) ⇒ Object
DSLee stuff
28 29 30 |
# File 'lib/riot/context.rb', line 28 def setup(&block) run_setup(situation, &(@setup = block)) end |
#should(what, &block) ⇒ Object
34 |
# File 'lib/riot/context.rb', line 34 def should(what, &block) add_assertion("should #{what}", &block); end |
#to_s ⇒ Object
24 |
# File 'lib/riot/context.rb', line 24 def to_s; @to_s ||= [@parent.to_s, @description].join(' ').strip; end |