summaryrefslogtreecommitdiff
path: root/spec/ruby/library/yaml/load_stream_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/yaml/load_stream_spec.rb')
-rw-r--r--spec/ruby/library/yaml/load_stream_spec.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/spec/ruby/library/yaml/load_stream_spec.rb b/spec/ruby/library/yaml/load_stream_spec.rb
index 31bc862f5e..5f5d4c7337 100644
--- a/spec/ruby/library/yaml/load_stream_spec.rb
+++ b/spec/ruby/library/yaml/load_stream_spec.rb
@@ -1,9 +1,23 @@
require_relative '../../spec_helper'
require_relative 'fixtures/strings'
-require_relative 'shared/each_document'
-
require 'yaml'
describe "YAML.load_stream" do
- it_behaves_like :yaml_each_document, :load_stream
+ it "calls the block on each successive document" do
+ documents = []
+ YAML.load_stream(YAMLSpecs::MULTIDOCUMENT) do |doc|
+ documents << doc
+ end
+ documents.should == [["Mark McGwire", "Sammy Sosa", "Ken Griffey"],
+ ["Chicago Cubs", "St Louis Cardinals"]]
+ end
+
+ it "works on files" do
+ test_parse_file = fixture __FILE__, "test_yaml.yml"
+ File.open(test_parse_file, "r") do |file|
+ YAML.load_stream(file) do |doc|
+ doc.should == {"project"=>{"name"=>"RubySpec"}}
+ end
+ end
+ end
end