Sha256: e3d895171393e07d02a97c82c21b1e0527cab1c19cc347f6e5f9f866a4c1c349

Contents?: true

Size: 880 Bytes

Versions: 2

Compression:

Stored size: 880 Bytes

Contents

require 'test_helper'

class TransitionTest < Test::Unit::TestCase
  context "Calling #next_state_for" do
    setup do
      @mum = Object.new
      @mum.class.instance_eval do
          include Apotomo::Transition
      end
    end
    
    should "return nil when no transition is defined" do
      assert_not @mum.send(:next_state_for, :snuggle)
    end
    
    should "return the defined next state" do
      @mum.class.instance_eval do
        transition :from => :snuggle, :to => :sleep
      end
      
      assert_equal :sleep, @mum.send(:next_state_for, :snuggle)
    end
    
    should "return the state that was defined last" do
      @mum.class.instance_eval do
        transition :from => :snuggle, :to => :sleep
        transition :from => :snuggle, :to => :snore
      end
      
      assert_equal :snore, @mum.send(:next_state_for, :snuggle)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apotomo-0.1.4 test/unit/transition_test.rb
apotomo-0.1.3 test/unit/transition_test.rb