Sha256: 677bdf00c40161fea40d0dd8436df0ce26ae2b97a446ef62a1bcbe86908d7b60

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

# encoding: utf-8

class Nanoc::Extra::PiperTest < Nanoc::TestCase

  def test_basic
    stdout = StringIO.new
    stderr = StringIO.new

    cmd = %w( ls -l )

    File.open('foo.txt', 'w') { |io| io.write('hi') }
    File.open('bar.txt', 'w') { |io| io.write('ho') }

    piper = Nanoc::Extra::Piper.new(:stdout => stdout, :stderr => stderr)
    piper.run(cmd, nil)

    assert_match(/foo\.txt/, stdout.string)
    assert_match(/bar\.txt/, stdout.string)
    assert stderr.string.empty?
  end

  def test_stdin
    stdout = StringIO.new
    stderr = StringIO.new

    input = 'Hello World!'
    cmd = %w( cat )

    piper = Nanoc::Extra::Piper.new(:stdout => stdout, :stderr => stderr)
    piper.run(cmd, input)

    assert_equal(input, stdout.string)
    assert_equal('', stderr.string)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-3.6.9 test/extra/test_piper.rb