Sha256: bd56c3e978a4e941996589029ea8809603cc7395253ea2e254ac1f97ec10b73a

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

require_relative '../../test_helper'

class StateWithNameTest < StateMachinesTest
  def setup
    @klass = Class.new
    @machine = StateMachines::Machine.new(@klass)
    @machine.states << @state = StateMachines::State.new(@machine, :parked)
  end

  def test_should_have_a_name
    assert_equal :parked, @state.name
  end

  def test_should_have_a_qualified_name
    assert_equal :parked, @state.name
  end

  def test_should_have_a_human_name
    assert_equal 'parked', @state.human_name
  end

  def test_should_use_stringify_the_name_as_the_value
    assert_equal 'parked', @state.value
  end

  def test_should_match_stringified_name
    assert @state.matches?('parked')
    refute @state.matches?('idling')
  end

  def test_should_not_include_value_in_description
    assert_equal 'parked', @state.description
  end

  def test_should_allow_using_human_name_in_description
    @state.human_name = 'Parked'
    assert_equal 'Parked', @state.description(human_name: true)
  end

  def test_should_define_predicate
    assert @klass.new.respond_to?(:parked?)
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
state_machines-0.5.0 test/unit/state/state_with_name_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-0.2.2/test/unit/state/state_with_name_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-0.2.2/test/unit/state/state_with_name_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-0.2.2/test/unit/state/state_with_name_test.rb
state_machines-0.4.0 test/unit/state/state_with_name_test.rb
state_machines-0.3.0 test/unit/state/state_with_name_test.rb
state_machines-0.2.2 test/unit/state/state_with_name_test.rb
state_machines-0.2.1 test/unit/state/state_with_name_test.rb
state_machines-0.2.0 test/unit/state/state_with_name_test.rb
state_machines-0.1.4 test/unit/state/state_with_name_test.rb
state_machines-0.1.3 test/unit/state/state_with_name_test.rb
state_machines-0.1.2 test/unit/state/state_with_name_test.rb
state_machines-0.1.1 test/unit/state/state_with_name_test.rb
state_machines-0.1.0 test/unit/state/state_with_name_test.rb