Sha256: 7ef2ce5d64bd14f6f87c9f525277e4220074462cc45d9e8557178d8c4a226130

Contents?: true

Size: 800 Bytes

Versions: 15

Compression:

Stored size: 800 Bytes

Contents

require_relative 'test_helper'

class MachineWithNonColumnStateAttributeDefinedTest < BaseTestCase
  def setup
    @model = new_model do
      attr_accessor :status
    end

    @machine = StateMachines::Machine.new(@model, :status, :initial => :parked)
    @machine.other_states(:idling)
    @record = @model.new
  end

  def test_should_return_false_for_predicate_if_does_not_match_current_value
    refute @record.status?(:idling)
  end

  def test_should_return_true_for_predicate_if_matches_current_value
    assert @record.status?(:parked)
  end

  def test_should_raise_exception_for_predicate_if_invalid_state_specified
    assert_raise(IndexError) { @record.status?(:invalid) }
  end

  def test_should_set_initial_state_on_created_object
    assert_equal 'parked', @record.status
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
state_machines-activerecord-0.9.0 test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.8.0 test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.6.0 test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.5.2 test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.5.1 test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.5.0 test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.4.1 test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.4.0 test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.4.0.pre test/machine_with_non_column_state_attribute_defined_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_non_column_state_attribute_defined_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.3.0 test/machine_with_non_column_state_attribute_defined_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.2.0 test/machine_with_non_column_state_attribute_defined_test.rb
state_machines-activerecord-0.1.0 test/machine_with_non_column_state_attribute_defined_test.rb