Sha256: 9d17d769d97894ce642aa027da0e99709c513a734efec56e2a05390711e010d7

Contents?: true

Size: 1.09 KB

Versions: 18

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'helper'

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

18 entries across 18 versions & 1 rubygems

Version Path
nanoc-4.8.12 test/extra/test_piper.rb
nanoc-4.8.11 test/extra/test_piper.rb
nanoc-4.8.10 test/extra/test_piper.rb
nanoc-4.8.9 test/extra/test_piper.rb
nanoc-4.8.8 test/extra/test_piper.rb
nanoc-4.8.7 test/extra/test_piper.rb
nanoc-4.8.6 test/extra/test_piper.rb
nanoc-4.8.5 test/extra/test_piper.rb
nanoc-4.8.4 test/extra/test_piper.rb
nanoc-4.8.3 test/extra/test_piper.rb
nanoc-4.8.2 test/extra/test_piper.rb
nanoc-4.8.1 test/extra/test_piper.rb
nanoc-4.8.0 test/extra/test_piper.rb
nanoc-4.7.14 test/extra/test_piper.rb
nanoc-4.7.13 test/extra/test_piper.rb
nanoc-4.7.12 test/extra/test_piper.rb
nanoc-4.7.11 test/extra/test_piper.rb
nanoc-4.7.10 test/extra/test_piper.rb