Class: Warp::ActionMatchers::Matcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/warp/action_matchers/matcher.rb

Direct Known Subclasses

CreateMatcher, DestroyMatcher, UpdateMatcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ Matcher

Returns a new instance of Matcher.



8
9
10
# File 'lib/warp/action_matchers/matcher.rb', line 8

def initialize(model)
  @model = model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/warp/action_matchers/matcher.rb', line 6

def model
  @model
end

Instance Method Details

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
# File 'lib/warp/action_matchers/matcher.rb', line 12

def matches?(actual)
  check_callable!(actual)

  instrument = Warp::Instrument.for(model, instrument_method)

  instrument.reset
  instrument.run { actual.call }

  instrument.calls.size > 0
end