Sha256: ab0c14bf57f351129e42ca74e06f716df3953d2bda0ae735170d1937560fa341

Contents?: true

Size: 911 Bytes

Versions: 38

Compression:

Stored size: 911 Bytes

Contents

require 'psych/helper'

module Psych
  module Nodes
    class TestEnumerable < TestCase
      def test_includes_enumerable
        yaml = '--- hello'
        assert_equal 3, Psych.parse_stream(yaml).to_a.length
      end

      def test_returns_enumerator
        yaml = '--- hello'
        assert_equal 3, Psych.parse_stream(yaml).each.map { |x| x }.length
      end

      def test_scalar
        assert_equal 3, calls('--- hello').length
      end

      def test_sequence
        assert_equal 4, calls("---\n- hello").length
      end

      def test_mapping
        assert_equal 5, calls("---\nhello: world").length
      end

      def test_alias
        assert_equal 5, calls("--- &yay\n- foo\n- *yay\n").length
      end

      private

      def calls yaml
        calls = []
        Psych.parse_stream(yaml).each do |node|
          calls << node
        end
        calls
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
psych-2.0.17-java test/psych/nodes/test_enumerable.rb
psych-2.0.17 test/psych/nodes/test_enumerable.rb
psych-2.0.16-java test/psych/nodes/test_enumerable.rb
psych-2.0.16 test/psych/nodes/test_enumerable.rb
psych-2.0.15-java test/psych/nodes/test_enumerable.rb
psych-2.0.15 test/psych/nodes/test_enumerable.rb
psych-2.0.14-java test/psych/nodes/test_enumerable.rb
psych-2.0.14 test/psych/nodes/test_enumerable.rb
psych-shopifork-2.0.13 test/psych/nodes/test_enumerable.rb
psych-2.0.14.pre1-java test/psych/nodes/test_enumerable.rb
psych-2.0.13 test/psych/nodes/test_enumerable.rb
psych-2.0.12 test/psych/nodes/test_enumerable.rb
psych-2.0.11 test/psych/nodes/test_enumerable.rb
psych-2.0.10 test/psych/nodes/test_enumerable.rb
psych-2.0.9 test/psych/nodes/test_enumerable.rb
psych-2.0.8 test/psych/nodes/test_enumerable.rb
psych-2.0.7 test/psych/nodes/test_enumerable.rb
psych-2.0.6 test/psych/nodes/test_enumerable.rb
psych-shopifork-2.0.5 test/psych/nodes/test_enumerable.rb
psych-2.0.5 test/psych/nodes/test_enumerable.rb