Class: Linepipe::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/linepipe/step.rb

Defined Under Namespace

Classes: StepExpectation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, &block) ⇒ Step

Returns a new instance of Step.



5
6
7
8
9
# File 'lib/linepipe/step.rb', line 5

def initialize(name=nil, &block)
  @name  = name
  @block = block
  @expectations = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/linepipe/step.rb', line 3

def name
  @name
end

Instance Method Details

#apply(data) ⇒ Object



11
12
13
# File 'lib/linepipe/step.rb', line 11

def apply(data)
  block.call(data)
end

#expect(name = nil, &block) ⇒ Object



19
20
21
# File 'lib/linepipe/step.rb', line 19

def expect(name=nil, &block)
  @expectations << StepExpectation.new(name, &block)
end

#verify_expectations(result) ⇒ Object



15
16
17
# File 'lib/linepipe/step.rb', line 15

def verify_expectations(result)
  @expectations.each { |exp| exp.verify(result) }
end