Sha256: 8714c1343a02f9a708990fa76b1351515cc8637e622191d5cc9e1c8aec66e2a3

Contents?: true

Size: 858 Bytes

Versions: 4

Compression:

Stored size: 858 Bytes

Contents

require 'spec_helper'

class MachineTestSubject
  include EdgeStateMachine

  state_machine do
    state :open
    state :closed
  end

  state_machine do
    initial_state :open

    event :shutdown do
      transition :from => :open, :to => :closed
    end

    event :timeout do
      transition :from => :open, :to => :closed
    end
  end

  state_machine :extra do
    initial_state :bar
  end
end

describe EdgeStateMachine::Machine do

  it 'should allow reuse of existing machines' do
    MachineTestSubject.state_machines.size.should == 2
  end

  it 'should set #initial_state_name from initial_state method' do
    MachineTestSubject.state_machines[:extra].initial_state_name.should == :bar
  end

  it 'should access non-default state machine' do
    MachineTestSubject.state_machines[:extra].class.should == EdgeStateMachine::Machine
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
edge-state-machine-1.0.1 spec/machine_spec.rb
edge-state-machine-1.0.0 spec/machine_spec.rb
edge-state-machine-0.9.1 spec/machine_spec.rb
edge-state-machine-0.9.0 spec/machine_spec.rb