Sha256: aa4a9f239a017d91eb18da9cd4b95b39d15be8938fbac11d4f3b84f837657037

Contents?: true

Size: 906 Bytes

Versions: 2

Compression:

Stored size: 906 Bytes

Contents

#! /usr/bin/env ruby
# coding: utf-8

require "helper"
require "stringio"

class Tefil::LineSubstituter
  public :process_stream
end

class TC_LineSubstituter < Test::Unit::TestCase
  def setup
    @is00 = Tefil::LineSubstituter.new('abc', 'XYZ')
    @is01 = Tefil::LineSubstituter.new('abc', 'XYZ', {:global => true})
  end

  def test_process_stream
    setup
    $stdin = StringIO.new
    $stdin.puts "abcdabcd"
    $stdin.puts "ABCDABCD"
    $stdin.rewind
    str = capture_stdout{}
    result = capture_stdout{ @is00.filter([])}
    correct =
      "XYZdabcd\n" +
      "ABCDABCD\n"
    assert_equal(correct, result)


    setup
    $stdin = StringIO.new
    $stdin.puts "abcdabcd"
    $stdin.puts "ABCDABCD"
    $stdin.rewind
    str = capture_stdout{}
    result = capture_stdout{ @is01.filter([])}
    correct =
      "XYZdXYZd\n" +
      "ABCDABCD\n"
    assert_equal(correct, result)

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tefil-0.1.1 test/test_linesubstituter.rb
tefil-0.1.0 test/test_linesubstituter.rb