Sha256: 7cb9dcfae31e7f8a0a570c8f7ab6c8742d3bb52dba74d4dc8c542913bd98519b

Contents?: true

Size: 881 Bytes

Versions: 19

Compression:

Stored size: 881 Bytes

Contents

require_relative 'test_helper'

class MachineWithModelStateAttributeTest < BaseTestCase
  def setup
    @model = new_model
    @machine = StateMachines::Machine.new(@model, initial: :parked, integration: :active_model)
    @machine.other_states(:idling)

    @record = @model.new
  end

  def test_should_have_an_attribute_predicate
    assert @record.respond_to?(:state?)
  end

  def test_should_raise_exception_for_predicate_without_parameters
    assert_raises(ArgumentError) { @record.state? }
  end

  def test_should_return_false_for_predicate_if_does_not_match_current_value
    assert !@record.state?(:idling)
  end

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

  def test_should_raise_exception_for_predicate_if_invalid_state_specified
    assert_raises(IndexError) { @record.state?(:invalid) }
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
state_machines-activemodel-0.9.0 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.8.0 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.7.1 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.7.0 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.6.0 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.5.1 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.5.0 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.4.1 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.4.0 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.4.0.pre test/machine_with_model_state_attribute_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-activemodel-0.1.2/test/machine_with_model_state_attribute_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-activemodel-0.1.2/test/machine_with_model_state_attribute_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-activemodel-0.1.2/test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.3.0 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.2.0 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.1.2 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.1.1 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.1.0 test/machine_with_model_state_attribute_test.rb
state_machines-activemodel-0.0.3 test/machine_with_model_state_attribute_test.rb