Class: Riot::Helper

Inherits:
RunnableBlock show all
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

#definition

Instance Method Summary collapse

Methods inherited from RunnableBlock

#to_s

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.

Parameters:

Returns:

  • (Array<Symbol>)

    array containing the evaluation state



83
84
85
86
# File 'lib/riot/runnable.rb', line 83

def run(situation)
  situation.helper(@name, &definition)
  [:helper]
end