Skip to content

Commit

Permalink
Merge pull request #1114 from herwinw/yaml_dump
Browse files Browse the repository at this point in the history
Extra specs for YAML output
  • Loading branch information
andrykonchin authored Nov 18, 2023
2 parents 559d17d + 647d2e2 commit f5e9167
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion library/yaml/to_yaml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@
{ "a" => "b"}.to_yaml.should match_yaml("--- \na: b\n")
end

it "returns the YAML representation of a Class object" do
it "returns the YAML representation of an object" do
YAMLSpecs::Example.new("baz").to_yaml.should match_yaml("--- !ruby/object:YAMLSpecs::Example\nname: baz\n")
end

it "returns the YAML representation of a Class object" do
YAMLSpecs::Example.to_yaml.should match_yaml("--- !ruby/class 'YAMLSpecs::Example'\n")
end

it "returns the YAML representation of a Module object" do
Enumerable.to_yaml.should match_yaml("--- !ruby/module 'Enumerable'\n")
end

it "returns the YAML representation of a Date object" do
require 'date'
Date.new(1997, 12, 30).to_yaml.should match_yaml("--- 1997-12-30\n")
Expand Down Expand Up @@ -59,6 +67,11 @@
Person.new("Jane", "female").to_yaml.should match_yaml("--- !ruby/struct:Person\nname: Jane\ngender: female\n")
end

it "returns the YAML representation of an unnamed Struct object" do
person = Struct.new(:name, :gender)
person.new("Jane", "female").to_yaml.should match_yaml("--- !ruby/struct\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
Expand Down

0 comments on commit f5e9167

Please sign in to comment.