Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 9886b53255a26191ad335853e4c08985da6c3f14 1 parent 8ea1d4f
Hiroshi Shirosaki authored August 25, 2012

Showing 1 changed file with 4 additions and 4 deletions. Show diff stats Hide diff stats

  1. 8  lib/mspec/matchers/match_yaml.rb
8  lib/mspec/matchers/match_yaml.rb
@@ -9,7 +9,7 @@ def initialize(expected)
9 9
   end
10 10
 
11 11
   def matches?(actual)
12  
-    @actual = actual    
  12
+    @actual = actual
13 13
     clean_yaml(@actual) == clean_yaml(@expected)
14 14
   end
15 15
 
@@ -20,11 +20,11 @@ def failure_message
20 20
   def negative_failure_message
21 21
     ["Expected #{@actual.inspect}", " to match #{@expected.inspect}"]
22 22
   end
23  
-  
  23
+
24 24
   protected
25  
-  
  25
+
26 26
   def clean_yaml(yaml)
27  
-    yaml.gsub(/([^-]|^---)\s+\n/, "\\1\n")
  27
+    yaml.gsub(/([^-]|^---)\s+\n/, "\\1\n").sub(/\n\.\.\.\n$/, "\n")
28 28
   end
29 29
 
30 30
   def valid_yaml?(obj)

0 notes on commit 9886b53

Please sign in to comment.
Something went wrong with that request. Please try again.