Sha256: 50613bb1001c2ad0caaf0622253c5b15e744a06870598e5bec7c250a94bf7f08

Contents?: true

Size: 410 Bytes

Versions: 2

Compression:

Stored size: 410 Bytes

Contents

module Linepipe
  class Expectation
    def initialize(msg="Assertion failed", io=STDOUT, &block)
      @msg   = msg
      @io    = io
      @block = block
    end

    def successful?(data)
      if !block.call(data)
        io.puts "Expectation failed at #{block.source_location.join(':')} (#{msg})"
        return false
      end
      true
    end

    private
    attr_reader :block, :msg, :io
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
linepipe-0.1.1 lib/linepipe/expectation.rb
linepipe-0.1.0 lib/linepipe/expectation.rb