lib/linepipe/expectation.rb in linepipe-0.1.1 vs lib/linepipe/expectation.rb in linepipe-0.1.2

- old
+ new

@@ -1,21 +1,19 @@ module Linepipe class Expectation - def initialize(msg="Assertion failed", io=STDOUT, &block) - @msg = msg - @io = io - @block = block + 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) - io.puts "Expectation failed at #{block.source_location.join(':')} (#{msg})" + log_method.call("Expectation", "Failed at #{block.source_location.join(':')} (#{msg})") return false end true end private - attr_reader :block, :msg, :io + attr_reader :block, :msg, :log_method end end