Sha256: 5a20e0231b78c6517b89689e299a4a9de32ffafdc76322ec14da1fcc59cdde34

Contents?: true

Size: 898 Bytes

Versions: 2

Compression:

Stored size: 898 Bytes

Contents

require 'test_helper_ar'
class ArTest < Test::Unit::TestCase
  
  context 'AR' do
    
    should 'set the state' do
      o1 = Order.new
      assert_equal  :open, o1.state
      o1.save!
      o2 = Order.find o1.id
      assert_equal  'open', o2[:state]
      assert_equal  :open, o2.state
    end
    
    should 'return initial state when state is empty string' do
      o1 = Order.new(:state => '')
      assert_equal :open, o1.state
    end
    
    should 'make transition' do
      o = Order.new
      assert_equal :open, o.state
      o.deliver
      assert_equal :delivered, o.state
      o.save!
      assert_equal :delivered, o.state
      o.reload
      o = Order.find(o.id)
      assert_equal :delivered, o.state
    end
    
    
    should 'have state check methods' do
      o = Order.new
      assert o.state_open?
      o.deliver
      assert o.state_delivered?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simplificator-fsm-0.3.9 test/ar_test.rb
simplificator-fsm-0.3.8 test/ar_test.rb