class ActiveModelTest::MachineWithNamespacedObserversTest
Public Instance Methods
after_enable_alarm(*args)
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 875 def after_enable_alarm(*args) notifications << args end
before_enable_alarm(*args)
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 863 def before_enable_alarm(*args) notifications << args end
setup()
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 852 def setup @model = new_model { include ActiveModel::Observing } @machine = StateMachine::Machine.new(@model, :state, :namespace => 'alarm') @machine.state :active, :off @machine.event :enable @record = @model.new(:state => 'off') @transition = StateMachine::Transition.new(@record, @machine, :enable, :off, :active) end
test_should_call_namespaced_after_event_method()
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 873 def test_should_call_namespaced_after_event_method observer = new_observer(@model) do def after_enable_alarm(*args) notifications << args end end instance = observer.instance @transition.perform assert_equal [[@record, @transition]], instance.notifications end
test_should_call_namespaced_before_event_method()
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 861 def test_should_call_namespaced_before_event_method observer = new_observer(@model) do def before_enable_alarm(*args) notifications << args end end instance = observer.instance @transition.perform assert_equal [[@record, @transition]], instance.notifications end