spec/unit/is_spec.rb in finite_machine-0.11.3 vs spec/unit/is_spec.rb in finite_machine-0.12.0

- old
+ new

@@ -1,21 +1,17 @@ -# encoding: utf-8 +# frozen_string_literal: true -require 'spec_helper' +RSpec.describe FiniteMachine, '#is?' do -RSpec.describe FiniteMachine, 'is?' do - it "allows to check if state is reachable" do - fsm = FiniteMachine.define do + fsm = FiniteMachine.new do initial :green - events { - event :slow, :green => :yellow - event :stop, :yellow => :red - event :ready, :red => :yellow - event :go, :yellow => :green - } + 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.is?(:green)).to be true @@ -30,18 +26,16 @@ 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 + fsm = FiniteMachine.new do initial :green - events { - event :slow, :green => :yellow - event :stop, :yellow => :red - event :ready, :red => :yellow - event :go, :yellow => :green - } + 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