Sha256: 4e385f892aa3035c5c2891242017a3a74d6b025b8d844b2ecdc699d234367108

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 Bytes

Contents

require 'helper'

class TestEventBeingFired < Test::Unit::TestCase
  test 'should raise an Transitions::InvalidTransition error if the transitions are empty' do
    event = Transitions::Event.new(nil, :event_that_is_fired)
    class AnotherDummy; end
    obj = AnotherDummy.new
    obj.stubs(:current_state).returns(:running)

    exception = assert_raise Transitions::InvalidTransition do
      event.fire(obj)
    end
    assert_match /Can't fire event `event_that_is_fired` in current state `running` for `TestEventBeingFired::AnotherDummy`/, exception.message
  end

  test 'should return the state of the first matching transition it finds' do
    event = Transitions::Event.new(nil, :event) do
      transitions to: :closed, from: [:open, :received]
    end

    obj = stub
    obj.stubs(:current_state).returns(:open)

    assert_equal :closed, event.fire(obj)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
transitions-1.0.0 test/event/test_event_being_fired.rb
transitions-0.2.1 test/event/test_event_being_fired.rb