Sha256: eb343247a7bcbcb23c831cf95bae20ff68d157f050ccd3c5fae87e3b0baa74e3

Contents?: true

Size: 1021 Bytes

Versions: 14

Compression:

Stored size: 1021 Bytes

Contents

require_relative '../../test_helper'

class EventTest < StateMachinesTest
  def setup
    @machine = StateMachines::Machine.new(Class.new)
    @machine.events << @event = StateMachines::Event.new(@machine, :ignite)
    @event.transition parked: :idling
  end

  def test_should_allow_changing_machine
    new_machine = StateMachines::Machine.new(Class.new)
    @event.machine = new_machine
    assert_equal new_machine, @event.machine
  end

  def test_should_allow_changing_human_name
    @event.human_name = 'Stop'
    assert_equal 'Stop', @event.human_name
  end

  def test_should_provide_matcher_helpers_during_initialization
    matchers = []

    @event.instance_eval do
      matchers = [all, any, same]
    end

    assert_equal [StateMachines::AllMatcher.instance, StateMachines::AllMatcher.instance, StateMachines::LoopbackMatcher.instance], matchers
  end

  def test_should_use_pretty_inspect
    assert_match '#<StateMachines::Event name=:ignite transitions=[:parked => :idling]>', @event.inspect
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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