Object
# File lib/mspec/matchers/match_yaml.rb, line 3 def initialize(expected) if valid_yaml?(expected) @expected = expected else @expected = expected.to_yaml end end
# File lib/mspec/matchers/match_yaml.rb, line 16 def failure_message ["Expected #{@actual.inspect}", " to match #{@expected.inspect}"] end
# File lib/mspec/matchers/match_yaml.rb, line 11 def matches?(actual) @actual = actual clean_yaml(@actual) == clean_yaml(@expected) end
# File lib/mspec/matchers/match_yaml.rb, line 20 def negative_failure_message ["Expected #{@actual.inspect}", " to match #{@expected.inspect}"] end
# File lib/mspec/matchers/match_yaml.rb, line 26 def clean_yaml(yaml) yaml.gsub(/([^-]|^---)\s+\n/, "\\1\n").sub(/\n\.\.\.\n$/, "\n") end
# File lib/mspec/matchers/match_yaml.rb, line 30 def valid_yaml?(obj) require 'yaml' begin YAML.load(obj) rescue false else true end end
[Validate]
Generated with the Darkfish Rdoc Generator 2.