class MachineByDefaultTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/machine_test.rb, line 4 def setup @klass = Class.new @machine = StateMachine::Machine.new(@klass) @object = @klass.new end
test_should_define_a_human_attribute_name_reader_for_the_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 144 def test_should_define_a_human_attribute_name_reader_for_the_attribute assert @klass.respond_to?(:human_state_name) end
test_should_define_a_human_event_name_reader_for_the_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 148 def test_should_define_a_human_event_name_reader_for_the_attribute assert @klass.respond_to?(:human_state_event_name) end
test_should_define_a_name_reader_for_the_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 112 def test_should_define_a_name_reader_for_the_attribute assert @object.respond_to?(:state_name) end
test_should_define_a_path_reader_for_the_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 124 def test_should_define_a_path_reader_for_the_attribute assert @object.respond_to?(:state_paths) end
test_should_define_a_predicate_for_the_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 108 def test_should_define_a_predicate_for_the_attribute assert @object.respond_to?(:state?) end
test_should_define_a_reader_attribute_for_the_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 100 def test_should_define_a_reader_attribute_for_the_attribute assert @object.respond_to?(:state) end
test_should_define_a_transition_reader_for_the_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 120 def test_should_define_a_transition_reader_for_the_attribute assert @object.respond_to?(:state_transitions) end
test_should_define_a_writer_attribute_for_the_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 104 def test_should_define_a_writer_attribute_for_the_attribute assert @object.respond_to?(:state=) end
test_should_define_an_event_reader_for_the_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 116 def test_should_define_an_event_reader_for_the_attribute assert @object.respond_to?(:state_events) end
test_should_define_state_machines_reader()
click to toggle source
# File test/unit/machine_test.rb, line 176 def test_should_define_state_machines_reader expected = {:state => @machine} assert_equal expected, @klass.state_machines end
test_should_extend_owner_class_with_class_methods()
click to toggle source
# File test/unit/machine_test.rb, line 168 def test_should_extend_owner_class_with_class_methods assert (class << @klass; ancestors; end).include?(StateMachine::ClassMethods) end
test_should_generate_default_messages()
click to toggle source
# File test/unit/machine_test.rb, line 70 def test_should_generate_default_messages assert_equal 'is invalid', @machine.generate_message(:invalid) assert_equal 'cannot transition when parked', @machine.generate_message(:invalid_event, [[:state, :parked]]) assert_equal 'cannot transition via "park"', @machine.generate_message(:invalid_transition, [[:event, :park]]) end
test_should_have_a_name()
click to toggle source
# File test/unit/machine_test.rb, line 14 def test_should_have_a_name assert_equal :state, @machine.name end
test_should_have_a_nil_initial_state()
click to toggle source
# File test/unit/machine_test.rb, line 30 def test_should_have_a_nil_initial_state assert_nil @machine.initial_state(@object).value end
test_should_have_a_nil_state()
click to toggle source
# File test/unit/machine_test.rb, line 62 def test_should_have_a_nil_state assert_equal [nil], @machine.states.keys end
test_should_have_an_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 18 def test_should_have_an_attribute assert_equal :state, @machine.attribute end
test_should_have_an_initial_state()
click to toggle source
# File test/unit/machine_test.rb, line 26 def test_should_have_an_initial_state assert_not_nil @machine.initial_state(@object) end
test_should_have_an_owner_class()
click to toggle source
# File test/unit/machine_test.rb, line 10 def test_should_have_an_owner_class assert_equal @klass, @machine.owner_class end
test_should_include_instance_methods_in_owner_class()
click to toggle source
# File test/unit/machine_test.rb, line 172 def test_should_include_instance_methods_in_owner_class assert @klass.included_modules.include?(StateMachine::InstanceMethods) end
test_should_not_be_extended_by_the_active_model_integration()
click to toggle source
# File test/unit/machine_test.rb, line 80 def test_should_not_be_extended_by_the_active_model_integration assert !(class << @machine; ancestors; end).include?(StateMachine::Integrations::ActiveModel) end
test_should_not_be_extended_by_the_active_record_integration()
click to toggle source
# File test/unit/machine_test.rb, line 84 def test_should_not_be_extended_by_the_active_record_integration assert !(class << @machine; ancestors; end).include?(StateMachine::Integrations::ActiveRecord) end
test_should_not_be_extended_by_the_base_integration()
click to toggle source
# File test/unit/machine_test.rb, line 76 def test_should_not_be_extended_by_the_base_integration assert !(class << @machine; ancestors; end).include?(StateMachine::Integrations::Base) end
test_should_not_be_extended_by_the_datamapper_integration()
click to toggle source
# File test/unit/machine_test.rb, line 88 def test_should_not_be_extended_by_the_datamapper_integration assert !(class << @machine; ancestors; end).include?(StateMachine::Integrations::DataMapper) end
test_should_not_be_extended_by_the_mongo_mapper_integration()
click to toggle source
# File test/unit/machine_test.rb, line 92 def test_should_not_be_extended_by_the_mongo_mapper_integration assert !(class << @machine; ancestors; end).include?(StateMachine::Integrations::MongoMapper) end
test_should_not_be_extended_by_the_sequel_integration()
click to toggle source
# File test/unit/machine_test.rb, line 96 def test_should_not_be_extended_by_the_sequel_integration assert !(class << @machine; ancestors; end).include?(StateMachine::Integrations::Sequel) end
test_should_not_define_an_event_attribute_reader()
click to toggle source
# File test/unit/machine_test.rb, line 128 def test_should_not_define_an_event_attribute_reader assert !@object.respond_to?(:state_event) end
test_should_not_define_an_event_attribute_writer()
click to toggle source
# File test/unit/machine_test.rb, line 132 def test_should_not_define_an_event_attribute_writer assert !@object.respond_to?(:state_event=) end
test_should_not_define_an_event_transition_attribute_reader()
click to toggle source
# File test/unit/machine_test.rb, line 136 def test_should_not_define_an_event_transition_attribute_reader assert !@object.respond_to?(:state_event_transition) end
test_should_not_define_an_event_transition_attribute_writer()
click to toggle source
# File test/unit/machine_test.rb, line 140 def test_should_not_define_an_event_transition_attribute_writer assert !@object.respond_to?(:state_event_transition=) end
test_should_not_define_plural_with_scope()
click to toggle source
# File test/unit/machine_test.rb, line 160 def test_should_not_define_plural_with_scope assert !@klass.respond_to?(:with_states) end
test_should_not_define_plural_without_scope()
click to toggle source
# File test/unit/machine_test.rb, line 164 def test_should_not_define_plural_without_scope assert !@klass.respond_to?(:without_states) end
test_should_not_define_singular_with_scope()
click to toggle source
# File test/unit/machine_test.rb, line 152 def test_should_not_define_singular_with_scope assert !@klass.respond_to?(:with_state) end
test_should_not_define_singular_without_scope()
click to toggle source
# File test/unit/machine_test.rb, line 156 def test_should_not_define_singular_without_scope assert !@klass.respond_to?(:without_state) end
test_should_not_have_a_namespace()
click to toggle source
# File test/unit/machine_test.rb, line 58 def test_should_not_have_a_namespace assert_nil @machine.namespace end
test_should_not_have_an_action()
click to toggle source
# File test/unit/machine_test.rb, line 50 def test_should_not_have_an_action assert_nil @machine.action end
test_should_not_have_any_after_callbacks()
click to toggle source
# File test/unit/machine_test.rb, line 42 def test_should_not_have_any_after_callbacks assert @machine.callbacks[:after].empty? end
test_should_not_have_any_before_callbacks()
click to toggle source
# File test/unit/machine_test.rb, line 38 def test_should_not_have_any_before_callbacks assert @machine.callbacks[:before].empty? end
test_should_not_have_any_events()
click to toggle source
# File test/unit/machine_test.rb, line 34 def test_should_not_have_any_events assert !@machine.events.any? end
test_should_not_have_any_failure_callbacks()
click to toggle source
# File test/unit/machine_test.rb, line 46 def test_should_not_have_any_failure_callbacks assert @machine.callbacks[:failure].empty? end
test_should_prefix_custom_attributes_with_attribute()
click to toggle source
# File test/unit/machine_test.rb, line 22 def test_should_prefix_custom_attributes_with_attribute assert_equal :state_event, @machine.attribute(:event) end
test_should_set_initial_on_nil_state()
click to toggle source
# File test/unit/machine_test.rb, line 66 def test_should_set_initial_on_nil_state assert @machine.state(nil).initial end
test_should_use_tranactions()
click to toggle source
# File test/unit/machine_test.rb, line 54 def test_should_use_tranactions assert_equal true, @machine.use_transactions end