Class: MatchYAMLMatcher

Inherits:
Object show all
Defined in:
lib/extensions/mspec/mspec/matchers/match_yaml.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ MatchYAMLMatcher

Returns a new instance of MatchYAMLMatcher.



3
4
5
6
7
8
9
# File 'lib/extensions/mspec/mspec/matchers/match_yaml.rb', line 3

def initialize(expected)
  if valid_yaml?(expected)
    @expected = expected
  else
    @expected = expected.to_yaml
  end
end

Instance Method Details

#failure_messageObject



16
17
18
# File 'lib/extensions/mspec/mspec/matchers/match_yaml.rb', line 16

def failure_message
  ["Expected #{@actual.inspect}", " to match #{@expected.inspect}"]
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/extensions/mspec/mspec/matchers/match_yaml.rb', line 11

def matches?(actual)
  @actual = actual    
  clean_yaml(@actual) == @expected
end

#negative_failure_messageObject



20
21
22
# File 'lib/extensions/mspec/mspec/matchers/match_yaml.rb', line 20

def negative_failure_message
  ["Expected #{@actual.inspect}", " to match #{@expected.inspect}"]
end