spec/unit/events_spec.rb in finite_machine-0.3.0 vs spec/unit/events_spec.rb in finite_machine-0.4.0

- old
+ new

@@ -148,9 +148,24 @@ expect(fsm.current).to eql(:green) expect { fsm.stop }.to raise_error(FiniteMachine::InvalidStateError, /state 'green'/) end + it "allows to transition to any state" do + fsm = FiniteMachine.define do + initial :green + + events { + event :slow, from: :green, to: :yellow + event :stop, from: :yellow, to: :red + } + end + expect(fsm.current).to eql(:green) + expect(fsm.can?(:stop)).to be_false + fsm.stop! + expect(fsm.current).to eql(:red) + end + context 'when multiple from states' do it "allows for array from key" do fsm = FiniteMachine.define do initial :green