Sha256: 2fc56a419b29376db5d6871d814efc707a42dce0924484e9222b9b627ffdf3b8

Contents?: true

Size: 438 Bytes

Versions: 2

Compression:

Stored size: 438 Bytes

Contents

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

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

    private
    attr_reader :block, :msg, :log_method
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
linepipe-0.2.0 lib/linepipe/expectation.rb
linepipe-0.1.2 lib/linepipe/expectation.rb