class EventCollectionAttributeWithNamespacedMachineTest

Public Instance Methods

save() click to toggle source
# File test/unit/event_collection_test.rb, line 232
def save
end
setup() click to toggle source
# File test/unit/event_collection_test.rb, line 230
def setup
  @klass = Class.new do
    def save
    end
  end
  
  @machine = StateMachine::Machine.new(@klass, :namespace => 'alarm', :initial => :active, :action => :save)
  @events = StateMachine::EventCollection.new(@machine)
  
  @machine.state :active, :off
  @events << @disable = StateMachine::Event.new(@machine, :disable)
  @machine.events.concat(@events)
  
  @object = @klass.new
end
test_should_have_invalid_transition_if_event_cannot_be_fired() click to toggle source
# File test/unit/event_collection_test.rb, line 251
def test_should_have_invalid_transition_if_event_cannot_be_fired
  @object.state_event = 'disable'
  assert_equal false, @events.attribute_transition_for(@object)
end
test_should_have_valid_transition_if_event_can_be_fired() click to toggle source
# File test/unit/event_collection_test.rb, line 256
def test_should_have_valid_transition_if_event_can_be_fired
  @disable.transition :active => :off
  @object.state_event = 'disable'
  
  assert_instance_of StateMachine::Transition, @events.attribute_transition_for(@object)
end
test_should_not_have_transition_if_nil() click to toggle source
# File test/unit/event_collection_test.rb, line 246
def test_should_not_have_transition_if_nil
  @object.state_event = nil
  assert_nil @events.attribute_transition_for(@object)
end