Class: Riot::Helper
- Inherits:
-
RunnableBlock
- Object
- RunnableBlock
- Riot::Helper
- Defined in:
- lib/riot/runnable.rb
Overview
Used to decorate a helper. A helper generally ends up being a glorified method that can be referenced from within a setup, teardown, hookup, other helpers, assertion blocks, and assertion macro blocks; basically anywhere the Situation instance is available.
context "Making dinner" do
helper(:easy_bake) do |thing|
EasyBake.new(thing, :ingredients => [:ketchup, :chocolate, :syrup])
end
setup do
easy_bake(:meatloaf)
end
asserts(:food_poisoning_probabilty).equals(0.947)
end # Making dinner
Instance Attribute Summary
Attributes inherited from RunnableBlock
Instance Method Summary collapse
-
#initialize(name, &definition) ⇒ Helper
constructor
A new instance of Helper.
-
#run(situation) ⇒ Array<Symbol>
Calls Situation#helper with the predefined helper name and block at Context run-time.
Methods inherited from RunnableBlock
Constructor Details
#initialize(name, &definition) ⇒ Helper
Returns a new instance of Helper.
72 73 74 75 |
# File 'lib/riot/runnable.rb', line 72 def initialize(name, &definition) super("helper #{name}", &definition) @name = name end |
Instance Method Details
#run(situation) ⇒ Array<Symbol>
Calls Situation#helper with the predefined helper name and block at Context run-time. Though this is like every other kind of RunnableBlock, run
will not return a meaningful state, which means the reporter will likely not report anything.
83 84 85 86 |
# File 'lib/riot/runnable.rb', line 83 def run(situation) situation.helper(@name, &definition) [:helper] end |