summaryrefslogtreecommitdiff
path: root/spec/ruby/library/yaml
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 20:18:52 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-20 20:18:52 +0000
commit1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch)
treea3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/ruby/library/yaml
parent75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff)
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/library/yaml')
-rw-r--r--spec/ruby/library/yaml/add_builtin_type_spec.rb2
-rw-r--r--spec/ruby/library/yaml/add_domain_type_spec.rb2
-rw-r--r--spec/ruby/library/yaml/add_private_type_spec.rb2
-rw-r--r--spec/ruby/library/yaml/add_ruby_type_spec.rb2
-rw-r--r--spec/ruby/library/yaml/detect_implicit_spec.rb2
-rw-r--r--spec/ruby/library/yaml/dump_spec.rb51
-rw-r--r--spec/ruby/library/yaml/dump_stream_spec.rb8
-rw-r--r--spec/ruby/library/yaml/each_node_spec.rb2
-rw-r--r--spec/ruby/library/yaml/emitter_spec.rb2
-rw-r--r--spec/ruby/library/yaml/fixtures/common.rb10
-rw-r--r--spec/ruby/library/yaml/fixtures/example_class.rb5
-rw-r--r--spec/ruby/library/yaml/fixtures/strings.rb36
-rw-r--r--spec/ruby/library/yaml/fixtures/test_yaml.yml2
-rw-r--r--spec/ruby/library/yaml/generic_parser_spec.rb2
-rw-r--r--spec/ruby/library/yaml/load_documents_spec.rb10
-rw-r--r--spec/ruby/library/yaml/load_file_spec.rb13
-rw-r--r--spec/ruby/library/yaml/load_spec.rb116
-rw-r--r--spec/ruby/library/yaml/load_stream_spec.rb8
-rw-r--r--spec/ruby/library/yaml/object_maker_spec.rb2
-rw-r--r--spec/ruby/library/yaml/parse_documents_spec.rb2
-rw-r--r--spec/ruby/library/yaml/parse_file_spec.rb10
-rw-r--r--spec/ruby/library/yaml/parse_spec.rb22
-rw-r--r--spec/ruby/library/yaml/parser_spec.rb2
-rw-r--r--spec/ruby/library/yaml/quick_emit_spec.rb2
-rw-r--r--spec/ruby/library/yaml/read_type_class_spec.rb2
-rw-r--r--spec/ruby/library/yaml/shared/each_document.rb18
-rw-r--r--spec/ruby/library/yaml/tagurize_spec.rb11
-rw-r--r--spec/ruby/library/yaml/to_yaml_spec.rb99
-rw-r--r--spec/ruby/library/yaml/transfer_spec.rb2
-rw-r--r--spec/ruby/library/yaml/try_implicit_spec.rb2
30 files changed, 449 insertions, 0 deletions
diff --git a/spec/ruby/library/yaml/add_builtin_type_spec.rb b/spec/ruby/library/yaml/add_builtin_type_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/add_builtin_type_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/add_domain_type_spec.rb b/spec/ruby/library/yaml/add_domain_type_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/add_domain_type_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/add_private_type_spec.rb b/spec/ruby/library/yaml/add_private_type_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/add_private_type_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/add_ruby_type_spec.rb b/spec/ruby/library/yaml/add_ruby_type_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/add_ruby_type_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/detect_implicit_spec.rb b/spec/ruby/library/yaml/detect_implicit_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/detect_implicit_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/dump_spec.rb b/spec/ruby/library/yaml/dump_spec.rb
new file mode 100644
index 0000000..c361352
--- /dev/null
+++ b/spec/ruby/library/yaml/dump_spec.rb
@@ -0,0 +1,51 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+
+# TODO: WTF is this using a global?
+describe "YAML.dump" do
+ after :each do
+ rm_r $test_file
+ end
+
+ it "converts an object to YAML and write result to io when io provided" do
+ File.open($test_file, 'w' ) do |io|
+ YAML.dump( ['badger', 'elephant', 'tiger'], io )
+ end
+ YAML.load_file($test_file).should == ['badger', 'elephant', 'tiger']
+ end
+
+ it "returns a string containing dumped YAML when no io provided" do
+ YAML.dump( :locked ).should match_yaml("--- :locked\n")
+ end
+
+ it "returns the same string that #to_yaml on objects" do
+ ["a", "b", "c"].to_yaml.should == YAML.dump(["a", "b", "c"])
+ end
+
+ it "dumps strings into YAML strings" do
+ YAML.dump("str").should match_yaml("--- str\n")
+ end
+
+ it "dumps hashes into YAML key-values" do
+ YAML.dump({ "a" => "b" }).should match_yaml("--- \na: b\n")
+ end
+
+ it "dumps Arrays into YAML collection" do
+ YAML.dump(["a", "b", "c"]).should match_yaml("--- \n- a\n- b\n- c\n")
+ end
+
+ it "dumps an OpenStruct" do
+ require "ostruct"
+ os = OpenStruct.new("age" => 20, "name" => "John")
+ YAML.dump(os).should match_yaml("--- !ruby/object:OpenStruct\ntable:\n :age: 20\n :name: John\n")
+ end
+
+ it "dumps a File without any state" do
+ file = File.new(__FILE__)
+ begin
+ YAML.dump(file).should match_yaml("--- !ruby/object:File {}\n")
+ ensure
+ file.close
+ end
+ end
+end
diff --git a/spec/ruby/library/yaml/dump_stream_spec.rb b/spec/ruby/library/yaml/dump_stream_spec.rb
new file mode 100644
index 0000000..918b626
--- /dev/null
+++ b/spec/ruby/library/yaml/dump_stream_spec.rb
@@ -0,0 +1,8 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+
+describe "YAML.dump_stream" do
+ it "returns a YAML stream containing the objects passed" do
+ YAML.dump_stream('foo', 20, [], {}).should match_yaml("--- foo\n--- 20\n--- []\n\n--- {}\n\n")
+ end
+end
diff --git a/spec/ruby/library/yaml/each_node_spec.rb b/spec/ruby/library/yaml/each_node_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/each_node_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/emitter_spec.rb b/spec/ruby/library/yaml/emitter_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/emitter_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/fixtures/common.rb b/spec/ruby/library/yaml/fixtures/common.rb
new file mode 100644
index 0000000..1d86880
--- /dev/null
+++ b/spec/ruby/library/yaml/fixtures/common.rb
@@ -0,0 +1,10 @@
+begin
+ require 'syck'
+rescue LoadError
+ # do nothing
+end
+
+require 'yaml'
+
+$test_file = tmp("yaml_test_file")
+$test_parse_file = File.dirname(__FILE__) + "/test_yaml.yml"
diff --git a/spec/ruby/library/yaml/fixtures/example_class.rb b/spec/ruby/library/yaml/fixtures/example_class.rb
new file mode 100644
index 0000000..751435a
--- /dev/null
+++ b/spec/ruby/library/yaml/fixtures/example_class.rb
@@ -0,0 +1,5 @@
+class FooBar
+ def initialize(name)
+ @name = name
+ end
+end
diff --git a/spec/ruby/library/yaml/fixtures/strings.rb b/spec/ruby/library/yaml/fixtures/strings.rb
new file mode 100644
index 0000000..6f66dc3
--- /dev/null
+++ b/spec/ruby/library/yaml/fixtures/strings.rb
@@ -0,0 +1,36 @@
+$complex_key_1 = <<EOY
+ ? # PLAY SCHEDULE
+ - Detroit Tigers
+ - Chicago Cubs
+ :
+ - 2001-07-23
+
+ ? [ New York Yankees,
+ Atlanta Braves ]
+ : [ 2001-07-02, 2001-08-12,
+ 2001-08-14 ]
+EOY
+
+$to_yaml_hash =
+<<EOY
+-
+ avg: 0.278
+ hr: 65
+ name: Mark McGwire
+-
+ avg: 0.288
+ hr: 63
+ name: Sammy Sosa
+EOY
+
+$multidocument = <<EOY
+---
+- Mark McGwire
+- Sammy Sosa
+- Ken Griffey
+
+# Team ranking
+---
+- Chicago Cubs
+- St Louis Cardinals
+EOY
diff --git a/spec/ruby/library/yaml/fixtures/test_yaml.yml b/spec/ruby/library/yaml/fixtures/test_yaml.yml
new file mode 100644
index 0000000..efe3b5c
--- /dev/null
+++ b/spec/ruby/library/yaml/fixtures/test_yaml.yml
@@ -0,0 +1,2 @@
+project:
+ name: RubySpec
diff --git a/spec/ruby/library/yaml/generic_parser_spec.rb b/spec/ruby/library/yaml/generic_parser_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/generic_parser_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/load_documents_spec.rb b/spec/ruby/library/yaml/load_documents_spec.rb
new file mode 100644
index 0000000..77d6dd8
--- /dev/null
+++ b/spec/ruby/library/yaml/load_documents_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../fixtures/strings', __FILE__)
+require File.expand_path('../shared/each_document', __FILE__)
+
+ruby_version_is ''...'2.5' do
+ describe "YAML.load_documents" do
+ it_behaves_like :yaml_each_document, :load_documents
+ end
+end
diff --git a/spec/ruby/library/yaml/load_file_spec.rb b/spec/ruby/library/yaml/load_file_spec.rb
new file mode 100644
index 0000000..d9ba5be
--- /dev/null
+++ b/spec/ruby/library/yaml/load_file_spec.rb
@@ -0,0 +1,13 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+
+describe "YAML.load_file" do
+ after :each do
+ rm_r $test_file
+ end
+
+ it "returns a hash" do
+ File.open($test_file,'w' ){|io| YAML.dump( {"bar"=>2, "car"=>1}, io ) }
+ YAML.load_file($test_file).should == {"bar"=>2, "car"=>1}
+ end
+end
diff --git a/spec/ruby/library/yaml/load_spec.rb b/spec/ruby/library/yaml/load_spec.rb
new file mode 100644
index 0000000..7c5a33d
--- /dev/null
+++ b/spec/ruby/library/yaml/load_spec.rb
@@ -0,0 +1,116 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../fixtures/strings', __FILE__)
+
+describe "YAML.load" do
+ after :each do
+ rm_r $test_file
+ end
+
+ it "returns a document from current io stream when io provided" do
+ File.open($test_file, 'w') do |io|
+ YAML.dump( ['badger', 'elephant', 'tiger'], io )
+ end
+ File.open($test_file) { |yf| YAML.load( yf ) }.should == ['badger', 'elephant', 'tiger']
+ end
+
+ it "loads strings" do
+ strings = ["str",
+ " str",
+ "'str'",
+ "str",
+ " str",
+ "'str'",
+ "\"str\"",
+ "\n str",
+ "--- str",
+ "---\nstr",
+ "--- \nstr",
+ "--- \n str",
+ "--- 'str'"
+ ]
+ strings.each do |str|
+ YAML.load(str).should == "str"
+ end
+ end
+
+ it "fails on invalid keys" do
+ if YAML.to_s == "Psych"
+ error = Psych::SyntaxError
+ else
+ error = ArgumentError
+ end
+ lambda { YAML.load("key1: value\ninvalid_key") }.should raise_error(error)
+ end
+
+ it "accepts symbols" do
+ YAML.load( "--- :locked" ).should == :locked
+ end
+
+ it "accepts numbers" do
+ YAML.load("47").should == 47
+ YAML.load("-1").should == -1
+ end
+
+ it "accepts collections" do
+ expected = ["a", "b", "c"]
+ YAML.load("--- \n- a\n- b\n- c\n").should == expected
+ YAML.load("--- [a, b, c]").should == expected
+ YAML.load("[a, b, c]").should == expected
+ end
+
+ it "parses start markers" do
+ YAML.load("---\n").should == nil
+ YAML.load("--- ---\n").should == "---"
+ YAML.load("--- abc").should == "abc"
+ end
+
+ it "works with block sequence shortcuts" do
+ block_seq = "- - - one\n - two\n - three"
+ YAML.load(block_seq).should == [[["one", "two", "three"]]]
+ end
+
+ it "works on complex keys" do
+ require 'date'
+ expected = {
+ [ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ],
+ [ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ),
+ Date.new( 2001, 8, 12 ),
+ Date.new( 2001, 8, 14 ) ]
+ }
+ YAML.load($complex_key_1).should == expected
+ end
+
+ it "loads a symbol key that contains spaces" do
+ string = ":user name: This is the user name."
+ expected = { :"user name" => "This is the user name."}
+ YAML.load(string).should == expected
+ end
+
+ describe "with iso8601 timestamp" do
+ it "computes the microseconds" do
+ [ [YAML.load("2011-03-22t23:32:11.2233+01:00"), 223300],
+ [YAML.load("2011-03-22t23:32:11.0099+01:00"), 9900],
+ [YAML.load("2011-03-22t23:32:11.000076+01:00"), 76]
+ ].should be_computed_by(:usec)
+ end
+
+ it "rounds values smaller than 1 usec to 0 " do
+ YAML.load("2011-03-22t23:32:11.000000342222+01:00").usec.should == 0
+ end
+ end
+
+ it "loads an OpenStruct" do
+ require "ostruct"
+ os = OpenStruct.new("age" => 20, "name" => "John")
+ loaded = YAML.load("--- !ruby/object:OpenStruct\ntable:\n :age: 20\n :name: John\n")
+ loaded.should == os
+ end
+
+ it "loads a File but raise an error when used as it is uninitialized" do
+ loaded = YAML.load("--- !ruby/object:File {}\n")
+ lambda {
+ loaded.read(1)
+ }.should raise_error(IOError)
+ end
+end
diff --git a/spec/ruby/library/yaml/load_stream_spec.rb b/spec/ruby/library/yaml/load_stream_spec.rb
new file mode 100644
index 0000000..f134f46
--- /dev/null
+++ b/spec/ruby/library/yaml/load_stream_spec.rb
@@ -0,0 +1,8 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../fixtures/strings', __FILE__)
+require File.expand_path('../shared/each_document', __FILE__)
+
+describe "YAML.load_stream" do
+ it_behaves_like :yaml_each_document, :load_stream
+end
diff --git a/spec/ruby/library/yaml/object_maker_spec.rb b/spec/ruby/library/yaml/object_maker_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/object_maker_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/parse_documents_spec.rb b/spec/ruby/library/yaml/parse_documents_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/parse_documents_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/parse_file_spec.rb b/spec/ruby/library/yaml/parse_file_spec.rb
new file mode 100644
index 0000000..d898013
--- /dev/null
+++ b/spec/ruby/library/yaml/parse_file_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+
+describe "YAML#parse_file" do
+ quarantine! do
+ it "returns a YAML::Syck::Map object after parsing a YAML file" do
+ YAML.parse_file($test_parse_file).should be_kind_of(YAML::Syck::Map)
+ end
+ end
+end
diff --git a/spec/ruby/library/yaml/parse_spec.rb b/spec/ruby/library/yaml/parse_spec.rb
new file mode 100644
index 0000000..137fc23
--- /dev/null
+++ b/spec/ruby/library/yaml/parse_spec.rb
@@ -0,0 +1,22 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+
+describe "YAML#parse with an empty string" do
+ it "returns false" do
+ YAML.parse('').should be_false
+ end
+end
+
+describe "YAML#parse" do
+ before :each do
+ @string_yaml = "foo".to_yaml
+ end
+
+ it "returns the value from the object" do
+ if YAML.to_s == "Psych"
+ YAML.parse(@string_yaml).to_ruby.should == "foo"
+ else
+ YAML.parse(@string_yaml).value.should == "foo"
+ end
+ end
+end
diff --git a/spec/ruby/library/yaml/parser_spec.rb b/spec/ruby/library/yaml/parser_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/parser_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/quick_emit_spec.rb b/spec/ruby/library/yaml/quick_emit_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/quick_emit_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/read_type_class_spec.rb b/spec/ruby/library/yaml/read_type_class_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/read_type_class_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/shared/each_document.rb b/spec/ruby/library/yaml/shared/each_document.rb
new file mode 100644
index 0000000..5d9d240
--- /dev/null
+++ b/spec/ruby/library/yaml/shared/each_document.rb
@@ -0,0 +1,18 @@
+describe :yaml_each_document, shared: true do
+ it "calls the block on each succesive document" do
+ documents = []
+ YAML.send(@method, $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
+ File.open($test_parse_file, "r") do |file|
+ YAML.send(@method, file) do |doc|
+ doc.should == {"project"=>{"name"=>"RubySpec"}}
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/yaml/tagurize_spec.rb b/spec/ruby/library/yaml/tagurize_spec.rb
new file mode 100644
index 0000000..f6025cb
--- /dev/null
+++ b/spec/ruby/library/yaml/tagurize_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+
+ruby_version_is ''...'2.5' do
+ describe "YAML.tagurize" do
+ it "converts a type_id to a taguri" do
+ YAML.tagurize('wtf').should == "tag:yaml.org,2002:wtf"
+ YAML.tagurize(1).should == 1
+ end
+ end
+end
diff --git a/spec/ruby/library/yaml/to_yaml_spec.rb b/spec/ruby/library/yaml/to_yaml_spec.rb
new file mode 100644
index 0000000..d129fe2
--- /dev/null
+++ b/spec/ruby/library/yaml/to_yaml_spec.rb
@@ -0,0 +1,99 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
+require File.expand_path('../fixtures/example_class', __FILE__)
+
+describe "Object#to_yaml" do
+
+ it "returns the YAML representation of an Array object" do
+ %w( 30 ruby maz irb 99 ).to_yaml.gsub("'", '"').should match_yaml("--- \n- \"30\"\n- ruby\n- maz\n- irb\n- \"99\"\n")
+ end
+
+ it "returns the YAML representation of a Hash object" do
+ { "a" => "b"}.to_yaml.should match_yaml("--- \na: b\n")
+ end
+
+ it "returns the YAML representation of a Class object" do
+ FooBar.new("baz").to_yaml.should match_yaml("--- !ruby/object:FooBar\nname: baz\n")
+
+ end
+
+ it "returns the YAML representation of a Date object" do
+ require 'date'
+ Date.parse('1997/12/30').to_yaml.should match_yaml("--- 1997-12-30\n")
+ end
+
+ it "returns the YAML representation of a FalseClass" do
+ false_klass = false
+ false_klass.should be_kind_of(FalseClass)
+ false_klass.to_yaml.should match_yaml("--- false\n")
+ end
+
+ it "returns the YAML representation of a Float object" do
+ float = 1.2
+ float.should be_kind_of(Float)
+ float.to_yaml.should match_yaml("--- 1.2\n")
+ end
+
+ it "returns the YAML representation of an Integer object" do
+ int = 20
+ int.should be_kind_of(Integer)
+ int.to_yaml.should match_yaml("--- 20\n")
+ end
+
+ it "returns the YAML representation of a NilClass object" do
+ nil_klass = nil
+ nil_klass.should be_kind_of(NilClass)
+ nil_klass.to_yaml.should match_yaml("--- \n")
+ end
+
+ it "returns the YAML represenation of a RegExp object" do
+ Regexp.new('^a-z+:\\s+\w+').to_yaml.should match_yaml("--- !ruby/regexp /^a-z+:\\s+\\w+/\n")
+ end
+
+ it "returns the YAML representation of a String object" do
+ "I love Ruby".to_yaml.should match_yaml("--- I love Ruby\n")
+ end
+
+ it "returns the YAML representation of a Struct object" do
+ Person = Struct.new(:name, :gender)
+ Person.new("Jane", "female").to_yaml.should match_yaml("--- !ruby/struct:Person\nname: Jane\ngender: female\n")
+ end
+
+ it "returns the YAML representation of a Symbol object" do
+ :symbol.to_yaml.should match_yaml("--- :symbol\n")
+ end
+
+ it "returns the YAML representation of a Time object" do
+ Time.utc(2000,"jan",1,20,15,1).to_yaml.sub(/\.0+/, "").should match_yaml("--- 2000-01-01 20:15:01 Z\n")
+ end
+
+ it "returns the YAML representation of a TrueClass" do
+ true_klass = true
+ true_klass.should be_kind_of(TrueClass)
+ true_klass.to_yaml.should match_yaml("--- true\n")
+ end
+
+ it "returns the YAML representation of a Error object" do
+ StandardError.new("foobar").to_yaml.should match_yaml("--- !ruby/exception:StandardError\nmessage: foobar\n")
+ end
+
+ it "returns the YAML representation for Range objects" do
+ yaml = Range.new(1,3).to_yaml
+ yaml.include?("!ruby/range").should be_true
+ yaml.include?("begin: 1").should be_true
+ yaml.include?("end: 3").should be_true
+ yaml.include?("excl: false").should be_true
+ end
+
+ it "returns the YAML representation of numeric constants" do
+ nan_value.to_yaml.downcase.should match_yaml("--- .nan\n")
+ infinity_value.to_yaml.downcase.should match_yaml("--- .inf\n")
+ (-infinity_value).to_yaml.downcase.should match_yaml("--- -.inf\n")
+ (0.0).to_yaml.should match_yaml("--- 0.0\n")
+ end
+
+ it "returns the YAML representation of an array of hashes" do
+ players = [{"a" => "b"}, {"b" => "c"}]
+ players.to_yaml.should match_yaml("--- \n- a: b\n- b: c\n")
+ end
+end
diff --git a/spec/ruby/library/yaml/transfer_spec.rb b/spec/ruby/library/yaml/transfer_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/transfer_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
diff --git a/spec/ruby/library/yaml/try_implicit_spec.rb b/spec/ruby/library/yaml/try_implicit_spec.rb
new file mode 100644
index 0000000..a8af231
--- /dev/null
+++ b/spec/ruby/library/yaml/try_implicit_spec.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)