Sha256: 24d09dff1cc56d59c1e06001dc771f27353385b3eab370100ae8c97c0e3135c5
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 KB
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 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
6 entries across 6 versions & 1 rubygems