Class: ADSP::Test::Stream::Abstract
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- ADSP::Test::Stream::Abstract
- Defined in:
- lib/adsp/test/stream/abstract.rb
Overview
ADSP::Test::Stream::Abstract class.
Constant Summary collapse
- SOURCE_PATH =
Common::SOURCE_PATH
Instance Method Summary collapse
- #test_invalid_initialize ⇒ Object
- #test_invalid_set_encoding ⇒ Object
- #test_io_delegates ⇒ Object
- #test_stat ⇒ Object
- #test_to_io ⇒ Object
Instance Method Details
#test_invalid_initialize ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/adsp/test/stream/abstract.rb', line 18 def test_invalid_initialize (Validation::INVALID_STRINGS - [nil] + Validation::INVALID_ENCODINGS).each do |invalid_encoding| assert_raises ValidateError do target.new ::StringIO.new, {}, :external_encoding => invalid_encoding end assert_raises ValidateError do target.new ::StringIO.new, {}, :internal_encoding => invalid_encoding end end (Validation::INVALID_HASHES - [nil]).each do |invalid_hash| assert_raises ValidateError do target.new ::StringIO.new, {}, :transcode_options => invalid_hash end end end |
#test_invalid_set_encoding ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/adsp/test/stream/abstract.rb', line 36 def test_invalid_set_encoding instance = target.new ::StringIO.new (Validation::INVALID_STRINGS - [nil] + Validation::INVALID_ENCODINGS).each do |invalid_encoding| assert_raises ValidateError do instance.set_encoding invalid_encoding end assert_raises ValidateError do instance.set_encoding ::Encoding::BINARY, invalid_encoding end end Validation::INVALID_ENCODINGS.each do |invalid_encoding| assert_raises ValidateError do instance.set_encoding "#{::Encoding::BINARY}:#{invalid_encoding}" end assert_raises ValidateError do instance.set_encoding "#{invalid_encoding}:#{::Encoding::BINARY}" end end (Validation::INVALID_HASHES - [nil]).each do |invalid_hash| assert_raises ValidateError do instance.set_encoding ::Encoding::BINARY, ::Encoding::BINARY, invalid_hash end assert_raises ValidateError do instance.set_encoding "#{::Encoding::BINARY}:#{::Encoding::BINARY}", invalid_hash end end end |
#test_io_delegates ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/adsp/test/stream/abstract.rb', line 75 def test_io_delegates ::File.open SOURCE_PATH, "wb+" do |file| instance = target.new file instance.autoclose = true assert_predicate instance, :autoclose? instance.binmode assert_predicate instance, :binmode instance.close_on_exec = true assert_predicate instance, :close_on_exec? # Fcntl may not be available. if Fcntl.const_defined? :F_GETFL stats = instance.fcntl Fcntl::F_GETFL, 0 refute_nil stats end instance.fdatasync fd = instance.fileno refute_nil fd refute_predicate instance, :isatty assert_nil instance.pid instance.sync = true assert_predicate instance, :sync refute_nil instance.to_i refute_predicate instance, :tty? end end |
#test_stat ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/adsp/test/stream/abstract.rb', line 110 def test_stat instance = target.new $stdout refute_predicate instance.stat, :file? refute_predicate instance.stat, :pipe? refute_predicate instance.stat, :socket? end |
#test_to_io ⇒ Object
70 71 72 73 |
# File 'lib/adsp/test/stream/abstract.rb', line 70 def test_to_io instance = target.new ::StringIO.new assert_equal instance, instance.to_io end |