Sha256: 31b495a69905f703c136c55acf50eeafff5831e6b2edd3063134718425456326
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
require 'test_helper' require 'test/unit' require 'tempfile' require 'grizzled/forwarder' class ForwarderTestDriver < Test::Unit::TestCase class ForwardToFile include Grizzled::Forwarder def initialize(file, exceptions=[]) forward_to file, exceptions end end def test_forward_all path = create_file begin contents = File.open(path).read fwd = ForwardToFile.new(File.open(path)) contents2 = fwd.read assert_equal(contents, contents2) lines = [] fwd = ForwardToFile.new(File.open(path)) fwd.each_line do |line| lines << line end contents2 = lines.join('') assert_equal(contents, contents2) ensure File.unlink path end end def test_forward_all_but_each path = create_file begin contents = File.open(path).read fwd = ForwardToFile.new(File.open(path), [:each]) contents2 = fwd.read assert_equal(contents, contents2) assert_raise(NoMethodError) do fwd.each end ensure File.unlink path end end def test_forward_all_but_each_and_each_line path = create_file begin contents = File.open(path).read fwd = ForwardToFile.new(File.open(path), [:each, :each_line]) contents2 = fwd.read assert_equal(contents, contents2) assert_raise(NoMethodError) do fwd.each do |c| puts(c) # should not get here end end assert_raise(NoMethodError) do fwd.each_line do |line| puts(line) # should not get here end end ensure File.unlink path end end private def create_file temp = Tempfile.new('fwdtest') temp.write((1..80).to_a.join(', ')) temp.write((1..10).to_a.join(', ')) temp.close temp.path end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grizzled-ruby-0.1.4 | test/tc_forwarder.rb |
grizzled-ruby-0.1.3 | test/tc_forwarder.rb |