Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra specs for YAML output #1114

Merged
merged 3 commits into from
Nov 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it "returns the YAML representation of an unnamed Struct object" do
it "returns the YAML representation of an unnamed Struct subclass 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