Sha256: c20d4df6627ca9b2b5297c5d8cd65a2d2e386ca87dc7d1a328cf82603eb8e2c7

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

Given /^streams containing$/ do |text|
  @input_stream1 = StringIO.new
  @input_stream2 = StringIO.new
  
  text.split("\n").each do |line|
    left_line, right_line = line.split("||").map(&:strip)
    @input_stream1 << left_line.gsub('\n', "\n") unless left_line == "-" * left_line.length and not left_line.empty?
    @input_stream2 << right_line.gsub('\n', "\n") unless right_line == "-" * right_line.length and not right_line.empty?
  end
  @input_stream1.rewind
  @input_stream2.rewind
end

When /^ascii\-data\-qdiff is invoked on files containing:$/ do |string|
  Given "streams containing", string
  When "ascii-data-qdiff is invoked"
end

When /^ascii\-data\-qdiff is invoked$/ do
  @actual_output1 = @actual_output2 = nil
  AsciiDataTools::Controller::QDiffController.new(
    :input_sources        => [AsciiDataTools::InputSource.new(nil, @input_stream1),
                              AsciiDataTools::InputSource.new(nil, @input_stream2)],
    :editor               => lambda do |filenames|
                               @actual_output1 = File.read(filenames.first)
                               @actual_output2 = File.read(filenames.last)
                             end,
    :output_stream        => @output_stream,
    :record_types         => @record_types,
    :user_feedback_stream => @user_feedback_stream
  ).run
end

Then /^the diffed result should be:$/ do |text|
  expected_output1, expected_output2 = "", ""
  text.split("\n").each do |line|
    left_line, right_line = line.split("||").map(&:strip)
    expected_output1 << left_line + "\n" unless left_line == "-" * left_line.length and not left_line.empty?
    expected_output2 << right_line + "\n" unless right_line == "-" * right_line.length and not right_line.empty?
  end
  @actual_output1.should == expected_output1
  @actual_output2.should == expected_output2
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ascii-data-tools-0.9 features/step_definitions/ascii-data-qdiff_steps.rb