1require 'psych/helper' 2 3module Psych 4 module Nodes 5 class TestEnumerable < TestCase 6 def test_includes_enumerable 7 yaml = '--- hello' 8 assert_equal 3, Psych.parse_stream(yaml).to_a.length 9 end 10 11 def test_returns_enumerator 12 yaml = '--- hello' 13 assert_equal 3, Psych.parse_stream(yaml).each.map { |x| x }.length 14 end 15 16 def test_scalar 17 assert_equal 3, calls('--- hello').length 18 end 19 20 def test_sequence 21 assert_equal 4, calls("---\n- hello").length 22 end 23 24 def test_mapping 25 assert_equal 5, calls("---\nhello: world").length 26 end 27 28 def test_alias 29 assert_equal 5, calls("--- &yay\n- foo\n- *yay\n").length 30 end 31 32 private 33 34 def calls yaml 35 calls = [] 36 Psych.parse_stream(yaml).each do |node| 37 calls << node 38 end 39 calls 40 end 41 end 42 end 43end 44