class Riot::Helper

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 {Riot::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

Public Class Methods

new(name, &definition) click to toggle source
Calls superclass method Riot::RunnableBlock.new
# File lib/riot/runnable.rb, line 72
def initialize(name, &definition)
  super("helper #{name}", &definition)
  @name = name
end

Public Instance Methods

run(situation) click to toggle source

Calls {Riot::Situation#helper} with the predefined helper name and block at {Riot::Context} run-time. Though this is like every other kind of {Riot::RunnableBlock}, run will not return a meaningful state, which means the reporter will likely not report anything.

@param [Riot::Situation] situation the situation for the current {Riot::Context} run @return [Array<Symbol>] array containing the evaluation state

# File lib/riot/runnable.rb, line 83
def run(situation)
  situation.helper(@name, &definition)
  [:helper]
end