Sha256: 72b5df087fecea3c8fd299188eb49d0e9b990ef60f0ce7c19a331e01117bd8be

Contents?: true

Size: 899 Bytes

Versions: 8

Compression:

Stored size: 899 Bytes

Contents

require "helper"

class MachineTestSubject
  include Transitions

  state_machine :initial => :closed do
    state :open
    state :closed

    event :shutdown do
      transitions :from => :open, :to => :closed
    end

    event :timeout do
      transitions :from => :open, :to => :closed
    end
  end
end

class TransitionsMachineTest < Test::Unit::TestCase
  test "sets #initial_state from :initial option" do
    assert_equal :closed, MachineTestSubject.get_state_machine.initial_state
  end

  test "`get_state_machine` returns Transitions::Machine" do
    assert_kind_of Transitions::Machine, MachineTestSubject.get_state_machine
  end

  test "finds events for given state" do
    events = MachineTestSubject.get_state_machine.events_for(:open)
    assert events.include?(:shutdown)
    assert events.include?(:timeout)
  end

  test "test fire_event" do
    pend "Implement me"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
transitions-0.1.8 test/machine/test_machine.rb
transitions-0.1.7 test/machine/test_machine.rb
transitions-0.1.6 test/machine/test_machine.rb
transitions-0.1.5 test/machine/test_machine.rb
transitions-0.1.4 test/machine/test_machine.rb
transitions-0.1.3 test/machine/test_machine.rb
transitions-0.1.2 test/machine/test_machine.rb
transitions-0.1.1 test/machine/test_machine.rb