spec/unit/events_spec.rb in finite_machine-0.5.0 vs spec/unit/events_spec.rb in finite_machine-0.6.0

- old
+ new

@@ -245,22 +245,40 @@ event :cycle, [:yellow, :red, :pink] => :green } end expect(fsm.current).to eql(:green) - expect(fsm.can?(:stop)).to be_true - fsm.stop expect(fsm.current).to eql(:yellow) fsm.stop expect(fsm.current).to eql(:red) fsm.stop expect(fsm.current).to eql(:pink) fsm.cycle expect(fsm.current).to eql(:green) fsm.stop expect(fsm.current).to eql(:yellow) + end + + it "groups transitions under one event name" do + fsm = FiniteMachine.define do + initial :initial + + events { + event :bump, :initial => :low, + :low => :medium, + :medium => :high + } + end + + expect(fsm.current).to eq(:initial) + fsm.bump + expect(fsm.current).to eq(:low) + fsm.bump + expect(fsm.current).to eq(:medium) + fsm.bump + expect(fsm.current).to eq(:high) end it "returns values for events" do fsm = FiniteMachine.define do initial :neutral