Class: MotionSpec::Matcher::HaveGeneric

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-spec/matcher/have_generic.rb

Instance Method Summary collapse

Constructor Details

#initialize(method_name, *args) ⇒ HaveGeneric

Returns a new instance of HaveGeneric.



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

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

Instance Method Details

#fail!(subject, negated) ⇒ Object

Raises:



14
15
16
17
18
19
20
# File 'lib/motion-spec/matcher/have_generic.rb', line 14

def fail!(subject, negated)
  raise FailedExpectation.new(
    FailMessageRenderer.message_for_have_generic(
      negated, subject, @method_name, @args
    )
  )
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


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

def matches?(subject)
  subject.send("has_#{@method_name}?", *@args)
end