diff --git a/spec/ruby/library/yaml/to_yaml_spec.rb b/spec/ruby/library/yaml/to_yaml_spec.rb index 8e80b02cb4..03ec4f6916 100644 --- a/spec/ruby/library/yaml/to_yaml_spec.rb +++ b/spec/ruby/library/yaml/to_yaml_spec.rb @@ -72,8 +72,16 @@ describe "Object#to_yaml" do 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\nbacktrace: \n") + ruby_version_is ""..."2.7" do + 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 + end + + ruby_version_is "2.7" do + it "returns the YAML representation of a Error object" do + StandardError.new("foobar").to_yaml.should match_yaml("--- !ruby/exception:StandardError\nmessage: foobar\nbacktrace: \n") + end end it "returns the YAML representation for Range objects" do