1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
aasm/spec/unit/event_naming_spec.rb
Michael Xavier 6dd484fb95 Fix stack level too deep error due to namespacing
If you have a state machine with a "failed" event and you transition it
and it fails to transition, AASM will call the "failed" method it
defines but will hit your transition instead and blow the stack.

All other methods in AASM are prefixed with AASM to avoid this, so this
patch does the same thing with the private methods `failed` and `fired`.
2014-07-25 09:05:31 -07:00

24 lines
467 B
Ruby

require 'spec_helper'
class SimpleStateMachine
include AASM
aasm do
state :init, :initial => true
state :failed
event :failed do
transitions :from => :init, :to => :failed
end
end
end
describe "event naming" do
let(:state_machine) { SimpleStateMachine.new }
it "allows an event of failed without blowing the stack" do
state_machine.failed
expect { state_machine.failed }.to raise_error(AASM::InvalidTransition)
end
end