spec/unit/states_spec.rb in finite_machine-0.11.3 vs spec/unit/states_spec.rb in finite_machine-0.12.0
- old
+ new
@@ -1,34 +1,28 @@
-# encoding: utf-8
+# frozen_string_literal: true
-require 'spec_helper'
-
-RSpec.describe FiniteMachine, 'states' do
+RSpec.describe FiniteMachine, '#states' do
it "retrieves all available states" 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.states).to match_array([:none, :green, :yellow, :red])
end
it "retrieves all unique states for choice transition" do
- fsm = FiniteMachine.define do
+ fsm = FiniteMachine.new do
initial :green
- events {
- event :next, from: :green do
- choice :yellow, if: -> { false }
- choice :red, if: -> { true }
- end
- }
+ event :next, from: :green do
+ choice :yellow, if: -> { false }
+ choice :red, if: -> { true }
+ end
end
expect(fsm.states).to match_array([:none, :green, :yellow, :red])
end
end