Class: BaconExpect::Matcher::SingleMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/bacon-expect/matchers/single_method.rb

Direct Known Subclasses

Be, BeGeneric, Eq, Eql, Match

Instance Method Summary collapse

Constructor Details

#initialize(method_name, *values) ⇒ SingleMethod

Returns a new instance of SingleMethod.



3
4
5
6
# File 'lib/bacon-expect/matchers/single_method.rb', line 3

def initialize(method_name, *values)
  @values = values
  @method_name = method_name
end

Instance Method Details

#fail!(subject, negated) ⇒ Object

Raises:



12
13
14
# File 'lib/bacon-expect/matchers/single_method.rb', line 12

def fail!(subject, negated)
  raise FailedExpectation.new(self.fail_message(subject, negated))
end

#fail_message(subject, negated = false) ⇒ Object



16
17
18
# File 'lib/bacon-expect/matchers/single_method.rb', line 16

def fail_message(subject, negated = false)
  FailMessageRenderer.message_for_be(negated, subject, @method_name, @values)
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/bacon-expect/matchers/single_method.rb', line 8

def matches?(subject)
  subject.send(@method_name, *@values)
end