Sha256: 9f28be97b9819cc628824e8512b425fec20e3f24281cd7d4f1368a7cb0e28785

Contents?: true

Size: 748 Bytes

Versions: 1

Compression:

Stored size: 748 Bytes

Contents

Spec::Matchers.define :output do |expected_output|
  chain :from_upstream do |*filters|
    @filters = filters.map {|filter| filter.is_a?(String) ? input_source_containing(filter) : filter }
  end

  match do |filter|
    # connect upstream and downstream
    ([filter] + @filters).each_cons(2) {|downstream, upstream| downstream << upstream }
    output = StringIO.new
    
    filter.write(output)
    
    @actual_string = output.string
    output.string == expected_output
  end
  
  failure_message_for_should do |filter|
    "filter should output #{expected_output.inspect} but instead outputs #{@actual_string.inspect}"
  end
end

def input_source_containing(content)
  AsciiDataTools::InputSource.new("some file", StringIO.new(content))
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ascii-data-tools-0.9 spec/filter_helper.rb