Sha256: 9c464404571718de120d1836888a92f83a5641125050310f6a04c793132585f2

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

module Linepipe
  class Step
    attr_reader :name

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

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

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

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

    private
    attr_reader :block

    class StepExpectation
      attr_reader :name, :status

      def initialize(name=nil, &test)
        @name   = name
        @test   = test
        @status = 'not run'
      end

      def verify(data)
        @status = @test.call(data) ? 'pass' : 'fail'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
linepipe-0.2.0 lib/linepipe/step.rb