Sha256: 439161954b0f11aa9ab5d27934478ced3e2455c2cdb8a092d1c11e52c5a5192a

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

# encoding: utf-8

class Nanoc::CLI::CleaningStreamTest < MiniTest::Unit::TestCase

  include Nanoc::TestHelpers

  class Stream

    attr_accessor :called_methods

    def initialize
      @called_methods = Set.new
    end
    
    def method_missing(symbol, *args)
      @called_methods << symbol
    end

  end

  def test_forward
    methods = [ :write, :<<, :tty?, :flush, :tell, :print, :puts, :string, :reopen, :exist?, :exists? ]

    s = Stream.new
    cs = Nanoc::CLI::CleaningStream.new(s)

    cs.write('aaa')
    cs << 'bb'
    cs.tty?
    cs.flush
    cs.tell
    cs.print('cc')
    cs.puts('dd')
    cs.string
    cs.reopen('/dev/null', 'r')
    cs.exist?
    cs.exists?

    methods.each do |m|
      assert s.called_methods.include?(m), "expected #{m} to be called"
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nanoc-3.4.2 test/cli/test_cleaning_stream.rb
nanoc-3.4.1 test/cli/test_cleaning_stream.rb