class MachineWithCustomAttributeTest

Public Instance Methods

create_with_scope(name) click to toggle source
# File test/unit/machine_test.rb, line 2907
def create_with_scope(name)
  lambda {}
end
create_without_scope(name) click to toggle source
# File test/unit/machine_test.rb, line 2911
def create_without_scope(name)
  lambda {}
end
setup() click to toggle source
# File test/unit/machine_test.rb, line 2901
def setup
  StateMachine::Integrations.const_set('Custom', Module.new do  
    include StateMachine::Integrations::Base
    
    @defaults = {:action => :save, :use_transactions => false}
    
    def create_with_scope(name)
      lambda {}
    end
    
    def create_without_scope(name)
      lambda {}
    end
  end)
  
  @klass = Class.new
  @machine = StateMachine::Machine.new(@klass, :state, :attribute => :state_id, :initial => :active, :integration => :custom) do
    event :ignite do
      transition :parked => :idling
    end
  end
  @object = @klass.new
end
teardown() click to toggle source
# File test/unit/machine_test.rb, line 2986
def teardown
  StateMachine::Integrations.send(:remove_const, 'Custom')
end
test_should_define_a_human_attribute_name_reader() click to toggle source
# File test/unit/machine_test.rb, line 2957
def test_should_define_a_human_attribute_name_reader
  assert @klass.respond_to?(:human_state_name)
end
test_should_define_a_human_event_name_reader() click to toggle source
# File test/unit/machine_test.rb, line 2961
def test_should_define_a_human_event_name_reader
  assert @klass.respond_to?(:human_state_event_name)
end
test_should_define_a_human_name_reader_for_the_attribute() click to toggle source
# File test/unit/machine_test.rb, line 2941
def test_should_define_a_human_name_reader_for_the_attribute
  assert @object.respond_to?(:state_name)
end
test_should_define_a_name_reader_for_the_attribute() click to toggle source
# File test/unit/machine_test.rb, line 2937
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 2953
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 2933
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 2925
def test_should_define_a_reader_attribute_for_the_attribute
  assert @object.respond_to?(:state_id)
end
test_should_define_a_transition_reader_for_the_attribute() click to toggle source
# File test/unit/machine_test.rb, line 2949
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 2929
def test_should_define_a_writer_attribute_for_the_attribute
  assert @object.respond_to?(:state_id=)
end
test_should_define_an_event_reader_for_the_attribute() click to toggle source
# File test/unit/machine_test.rb, line 2945
def test_should_define_an_event_reader_for_the_attribute
  assert @object.respond_to?(:state_events)
end
test_should_define_plural_with_scope() click to toggle source
# File test/unit/machine_test.rb, line 2973
def test_should_define_plural_with_scope
  assert @klass.respond_to?(:with_states)
end
test_should_define_plural_without_scope() click to toggle source
# File test/unit/machine_test.rb, line 2977
def test_should_define_plural_without_scope
  assert @klass.respond_to?(:without_states)
end
test_should_define_singular_with_scope() click to toggle source
# File test/unit/machine_test.rb, line 2965
def test_should_define_singular_with_scope
  assert @klass.respond_to?(:with_state)
end
test_should_define_singular_without_scope() click to toggle source
# File test/unit/machine_test.rb, line 2969
def test_should_define_singular_without_scope
  assert @klass.respond_to?(:without_state)
end
test_should_define_state_machines_reader() click to toggle source
# File test/unit/machine_test.rb, line 2981
def test_should_define_state_machines_reader
  expected = {:state => @machine}
  assert_equal expected, @klass.state_machines
end