Class: MotionSpec::Matcher::SingleMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-spec/matcher/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.



5
6
7
8
# File 'lib/motion-spec/matcher/single_method.rb', line 5

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

Instance Method Details

#fail!(subject, negated) ⇒ Object

Raises:



14
15
16
# File 'lib/motion-spec/matcher/single_method.rb', line 14

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

#fail_message(subject, negated = false) ⇒ Object



18
19
20
21
22
# File 'lib/motion-spec/matcher/single_method.rb', line 18

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

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/motion-spec/matcher/single_method.rb', line 10

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