Sha256: ddb02419fb3fa6aa20745cb4590a1399fa7365cb55fe0220fb79fb61807ed8b6

Contents?: true

Size: 1.83 KB

Versions: 10

Compression:

Stored size: 1.83 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../helper")

## See state_and_event_common_spec.rb for behaviour shared between
## StateFu::State and StateFu::Event
##

describe StateFu::State do
  include MySpecHelper

  before(:each) do
    @machine = Object.new
    @state   = StateFu::State.new( @machine, :flux, {:meta => "wibble"} )
  end

  describe "instance methods" do

    describe "#after?(other_state)" do
      
      it "should be true when the other state is is after? this one" do
        m = StateFu::Machine.new do
          states :red, :green, :yellow
        end
        m.states[:green].after?(:red).should be_true
        m.states[:green].after?(:yellow).should be_false
        m.states[:green].after?(:green).should be_false        
        m.states[:green].after?(m.states[:red]).should be_true
        m.states[:green].after?(m.states[:yellow]).should be_false
        m.states[:green].after?(m.states[:green]).should be_false        
      end
    end

    describe "##before?(other_state)" do
      
      it "should be true when the other state is is before this one" do
        m = StateFu::Machine.new do
          states :red, :green, :yellow
        end
        m.states[:green].before?(:red).should be_false
        m.states[:green].before?(:yellow).should be_true
        m.states[:green].after?(:green).should be_false        
        m.states[:green].before?(m.states[:red]).should be_false
        m.states[:green].before?(m.states[:yellow]).should be_true
        m.states[:green].after?(m.states[:green]).should be_false        
      end
    end

    describe "#events" do

      it "should call machine.events.from(self)" do
        machine_events = Object.new
        mock( @machine ).events { machine_events }          
        mock( machine_events ).from( @state ) { nil }
        @state.events
      end

    end

  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
davidlee-state-fu-0.10.0 spec/units/state_spec.rb
davidlee-state-fu-0.11.0 spec/units/state_spec.rb
davidlee-state-fu-0.11.1 spec/units/state_spec.rb
davidlee-state-fu-0.12.0 spec/units/state_spec.rb
davidlee-state-fu-0.12.1 spec/units/state_spec.rb
state-fu-0.13.1 spec/units/state_spec.rb
state-fu-0.13.0 spec/units/state_spec.rb
state-fu-0.12.3 spec/units/state_spec.rb
state-fu-0.12.1 spec/units/state_spec.rb
state-fu-0.11.1 spec/units/state_spec.rb