Class: CustomRspecMatchers::Matchers::CallbackMatcher
- Inherits:
-
Object
- Object
- CustomRspecMatchers::Matchers::CallbackMatcher
- Defined in:
- lib/custom_rspec_matchers/matchers/callback_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(kind, callback_on, method) ⇒ CallbackMatcher
constructor
A new instance of CallbackMatcher.
- #matches?(model) ⇒ Boolean
Constructor Details
#initialize(kind, callback_on, method) ⇒ CallbackMatcher
Returns a new instance of CallbackMatcher.
4 5 6 7 8 |
# File 'lib/custom_rspec_matchers/matchers/callback_matcher.rb', line 4 def initialize(kind, callback_on, method) @kind = kind @callback_on = callback_on @method = method end |
Instance Method Details
#description ⇒ Object
15 16 17 |
# File 'lib/custom_rspec_matchers/matchers/callback_matcher.rb', line 15 def description " has #{@kind}_#{@callback_on} callback on #{@method}" end |
#failure_message ⇒ Object
19 20 21 |
# File 'lib/custom_rspec_matchers/matchers/callback_matcher.rb', line 19 def msg = " expected to have #{@kind}_#{@callback_on} callback on #{@method}" end |
#matches?(model) ⇒ Boolean
10 11 12 13 |
# File 'lib/custom_rspec_matchers/matchers/callback_matcher.rb', line 10 def matches?(model) @callbacks = model.send("_#{@callback_on}_callbacks").find_all {|cb| cb.kind == @kind && cb.raw_filter == @method} @callbacks.size == 1 end |