spec/unit/inspect_spec.rb in finite_machine-0.6.1 vs spec/unit/inspect_spec.rb in finite_machine-0.7.0

- old
+ new

@@ -1,25 +1,18 @@ # encoding: utf-8 require 'spec_helper' -describe FiniteMachine::Transition, 'inspect' do - let(:machine) { double } +describe FiniteMachine, '#inspect' do - subject(:transition) { described_class.new(machine, attrs) } + it "print useful information about state machine" do + fsm = FiniteMachine.define do + initial :green - context 'when inspecting' do - let(:attrs) { {name: :start, :foo => :bar, :baz => :daz} } - - it "displays name and transitions" do - expect(transition.inspect).to eql("<#FiniteMachine::Transition @name=start, @transitions=foo -> bar, baz -> daz, @when=[]>") + events { + event :slow, :green => :yellow + event :stop, :yellow => :red + } end - end - - context 'when converting to string' do - let(:attrs) { {name: :start, :foo => :bar } } - - it "displays name and transitions" do - expect(transition.to_s).to eql("start") - end + expect(fsm.inspect).to match(/^<#FiniteMachine::StateMachine:0x#{fsm.object_id.to_s(16)} @states=\[:none, :green, :yellow, :red\], @events=\[:init, :slow, :stop\], @transitions=.*$/) end end