Module: Shoulda::Callback::Matchers::ActiveModel
- Included in:
- RSpec::Matchers, Test::Unit::TestCase, Test::Unit::TestCase
- Defined in:
- lib/shoulda/callback/matchers/active_model.rb
Overview
:nodoc:
Defined Under Namespace
Classes: CallbackMatcher
Instance Method Summary collapse
-
#callback(method) ⇒ Object
Ensures that the given model has a callback defined for the given method.
Instance Method Details
#callback(method) ⇒ Object
Ensures that the given model has a callback defined for the given method
Options:
-
before(:lifecycle)
.Symbol
. - define the callback as a callback before the fact. :lifecycle can be :save, :create, :update, :destroy, :validation -
after(:lifecycle)
.Symbol
. - define the callback as a callback after the fact. :lifecycle can be :save, :create, :update, :destroy, :validation, :initialize, :find, :touch -
around(:lifecycle)
.Symbol
. - define the callback as a callback around the fact. :lifecycle can be :save, :create, :update, :destroyif(:condition)
.Symbol
. - add a positive condition to the callback to be matched againstunless(:condition)
.Symbol
. - add a negative condition to the callback to be matched against
Examples:
it { should callback(:method).after(:create) }
it { should callback(:method).before(:validation).unless(:should_it_not?) }
it { should callback(CallbackClass).before(:validation).unless(:should_it_not?) }
20 21 22 |
# File 'lib/shoulda/callback/matchers/active_model.rb', line 20 def callback(method) CallbackMatcher.new(method) end |