Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix match_yaml for psych #30

Merged
merged 1 commit into from

2 participants

@shirosaki

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"

@shirosaki shirosaki 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"
9886b53
@brixen brixen merged commit 7c06779 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 25, 2012
  1. @shirosaki

    Fix match_yaml for psych

    shirosaki authored
    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"
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/mspec/matchers/match_yaml.rb
View
8 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)
Something went wrong with that request. Please try again.