Class: Stendhal::Matchers::Predicate

Inherits:
AbstractMatcher show all
Defined in:
lib/stendhal/matchers/predicate.rb

Instance Attribute Summary

Attributes inherited from AbstractMatcher

#target

Instance Method Summary collapse

Methods inherited from AbstractMatcher

#initialize

Constructor Details

This class inherits a constructor from Stendhal::Matchers::AbstractMatcher

Instance Method Details

#match(original, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/stendhal/matchers/predicate.rb', line 5

def match(original, options = {})
  message = "expected #{original.inspect} #{options[:negative] ? 'not ' : ''}to be #{@target.to_s.gsub('?','')}"
  if options[:negative]
    raise Stendhal::Exceptions::ExpectationNotMet.new(message) if original.send(@target)
  else
    raise Stendhal::Exceptions::ExpectationNotMet.new(message) unless original.send(@target)
  end
  true
end