Sha256: 4b9e9c81e6ea285118e2f62bd022187a9f399b9bc23c3aff61266739a107e8db

Contents?: true

Size: 1.05 KB

Versions: 22

Compression:

Stored size: 1.05 KB

Contents

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

  def test_no_such_command
    stdout = StringIO.new
    stderr = StringIO.new

    cmd = %w( cat kafhawilgoiwaejagoualjdsfilofiewaguihaifeowuiga )

    piper = Nanoc::Extra::Piper.new(stdout: stdout, stderr: stderr)
    assert_raises(Nanoc::Extra::Piper::Error) do
      piper.run(cmd, nil)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
nanoc-4.2.1 test/extra/test_piper.rb
nanoc-4.2.0 test/extra/test_piper.rb
nanoc-4.1.6 test/extra/test_piper.rb
nanoc-4.2.0b1 test/extra/test_piper.rb
nanoc-4.1.5 test/extra/test_piper.rb
nanoc-4.1.4 test/extra/test_piper.rb
nanoc-4.1.3 test/extra/test_piper.rb
nanoc-4.1.2 test/extra/test_piper.rb
nanoc-4.1.1 test/extra/test_piper.rb
nanoc-4.1.0 test/extra/test_piper.rb
nanoc-4.1.0rc2 test/extra/test_piper.rb
nanoc-4.1.0rc1 test/extra/test_piper.rb
nanoc-4.1.0b1 test/extra/test_piper.rb
nanoc-4.1.0a1 test/extra/test_piper.rb
nanoc-4.0.2 test/extra/test_piper.rb
nanoc-4.0.1 test/extra/test_piper.rb
nanoc-4.0.0 test/extra/test_piper.rb
nanoc-4.0.0rc3 test/extra/test_piper.rb
nanoc-4.0.0rc2 test/extra/test_piper.rb
nanoc-4.0.0rc1 test/extra/test_piper.rb