class ActiveModelTest::MachineWithModelStateAttributeTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/active_model_test.rb, line 180
def setup
  @model = new_model
  @machine = StateMachine::Machine.new(@model, :initial => :parked, :integration => :active_model)
  @machine.other_states(:idling)
  
  @record = @model.new
end
test_should_have_an_attribute_predicate() click to toggle source
# File test/unit/integrations/active_model_test.rb, line 188
def test_should_have_an_attribute_predicate
  assert @record.respond_to?(:state?)
end
test_should_raise_exception_for_predicate_if_invalid_state_specified() click to toggle source
# File test/unit/integrations/active_model_test.rb, line 205
def test_should_raise_exception_for_predicate_if_invalid_state_specified
  assert_raise(IndexError) { @record.state?(:invalid) }
end
test_should_raise_exception_for_predicate_without_parameters() click to toggle source
# File test/unit/integrations/active_model_test.rb, line 192
def test_should_raise_exception_for_predicate_without_parameters
  exception = assert_raise(ArgumentError) { @record.state? }
  assert_equal 'wrong number of arguments (1 for 2)', exception.message
end
test_should_return_false_for_predicate_if_does_not_match_current_value() click to toggle source
# File test/unit/integrations/active_model_test.rb, line 197
def test_should_return_false_for_predicate_if_does_not_match_current_value
  assert !@record.state?(:idling)
end
test_should_return_true_for_predicate_if_matches_current_value() click to toggle source
# File test/unit/integrations/active_model_test.rb, line 201
def test_should_return_true_for_predicate_if_matches_current_value
  assert @record.state?(:parked)
end