spec/unit/is_spec.rb in finite_machine-0.2.0 vs spec/unit/is_spec.rb in finite_machine-0.3.0

- old
+ new

@@ -28,6 +28,28 @@ expect(fsm.is?(:green)).to be_false expect(fsm.is?(:yellow)).to be_true expect(fsm.is?([:green, :red])).to be_false expect(fsm.is?([:yellow, :red])).to be_true end + + it "defines helper methods to check current state" do + fsm = FiniteMachine.define do + initial :green + + events { + event :slow, :green => :yellow + event :stop, :yellow => :red + event :ready, :red => :yellow + event :go, :yellow => :green + } + end + expect(fsm.current).to eql(:green) + + expect(fsm.green?).to be_true + expect(fsm.yellow?).to be_false + + fsm.slow + + expect(fsm.green?).to be_false + expect(fsm.yellow?).to be_true + end end