Permalink
Browse files

Fix match_yaml for psych

Psych to_yaml method appends string "...\n", but Syck doesn't. We remove
it for test portability.

Three dots ("...") indicate the end of a document.
http://yaml.org/spec/1.1/#id857577

Example:
Object#to_yaml returns the YAML representation of a TrueClass FAILED
Expected "--- true\n...\n"
 to equal "--- true\n"
  • Loading branch information...
1 parent 8ea1d4f commit 9886b53255a26191ad335853e4c08985da6c3f14 @shirosaki committed Aug 25, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/mspec/matchers/match_yaml.rb
@@ -9,7 +9,7 @@ def initialize(expected)
end
def matches?(actual)
- @actual = actual
+ @actual = actual
clean_yaml(@actual) == clean_yaml(@expected)
end
@@ -20,11 +20,11 @@ def failure_message
def negative_failure_message
["Expected #{@actual.inspect}", " to match #{@expected.inspect}"]
end
-
+
protected
-
+
def clean_yaml(yaml)
- yaml.gsub(/([^-]|^---)\s+\n/, "\\1\n")
+ yaml.gsub(/([^-]|^---)\s+\n/, "\\1\n").sub(/\n\.\.\.\n$/, "\n")
end
def valid_yaml?(obj)

0 comments on commit 9886b53

Please sign in to comment.