Sha256: 653de35488c15617db1274570b27313320eb89dc59799cc18dc5b90f8b2f448a

Contents?: true

Size: 719 Bytes

Versions: 14

Compression:

Stored size: 719 Bytes

Contents

require "helper"

class ChecksTestSubject
  include Transitions

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

    event :open do
      transitions :from => :initial, :to => :opened
    end

    event :close do
      transitions :from => :opened, :to => :closed
    end
  end
end

class StateMachineChecksTest < Test::Unit::TestCase
  test "checks if a given transition is possible" do
    subject = ChecksTestSubject.new
    assert_equal :initial, subject.current_state
    assert_equal true, subject.can_open?
    assert_equal false, subject.can_close?

    subject.open

    assert_equal false, subject.can_open?
    assert_equal true, subject.can_close?
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
transitions-0.2.0 test/event/test_event_checks.rb
transitions-0.1.13 test/event/test_event_checks.rb
transitions-0.1.12 test/event/test_event_checks.rb
transitions-0.1.11 test/event/test_event_checks.rb
transitions-0.1.10 test/event/test_event_checks.rb
transitions-0.1.9 test/event/test_event_checks.rb
transitions-0.1.8 test/event/test_event_checks.rb
transitions-0.1.7 test/event/test_event_checks.rb
transitions-0.1.6 test/event/test_event_checks.rb
transitions-0.1.5 test/event/test_event_checks.rb
transitions-0.1.4 test/event/test_event_checks.rb
transitions-0.1.3 test/event/test_event_checks.rb
transitions-0.1.2 test/event/test_event_checks.rb
transitions-0.1.1 test/event/test_event_checks.rb