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

- (Helper) initialize(name, &definition)



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

- (Array<Symbol>) run(situation)

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