Sha256: cc607265f82dd1e34e50f64c65fd964b81ca7f3763bc37b232c1141991322c0f

Contents?: true

Size: 1.02 KB

Versions: 16

Compression:

Stored size: 1.02 KB

Contents

require "helper"

class TestStateTransitionGuardCheck < Test::Unit::TestCase
  test "should return true of there is no guard" do
    opts = {:from => "foo", :to => "bar"}
      st = Transitions::StateTransition.new(opts)

    assert st.perform(nil)
  end

  test "should call the method on the object if guard is a symbol" do
    opts = {:from => "foo", :to => "bar", :guard => :test_guard}
    st = Transitions::StateTransition.new(opts)

    obj = stub
    obj.expects(:test_guard)

    st.perform(obj)
  end

  test "should call the method on the object if guard is a string" do
    opts = {:from => "foo", :to => "bar", :guard => "test_guard"}
    st = Transitions::StateTransition.new(opts)

    obj = stub
    obj.expects(:test_guard)

    st.perform(obj)
  end

  test "should call the proc passing the object if the guard is a proc" do
    opts = {:from => "foo", :to => "bar", :guard => Proc.new {|o| o.test_guard}}
    st = Transitions::StateTransition.new(opts)

    obj = stub
    obj.expects(:test_guard)

    st.perform(obj)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
transitions-0.1.5 test/state_transition/test_state_transition_guard_check.rb
transitions-0.1.4 test/state_transition/test_state_transition_guard_check.rb
transitions-0.1.3 test/state_transition/test_state_transition_guard_check.rb
transitions-0.1.2 test/state_transition/test_state_transition_guard_check.rb
transitions-0.1.1 test/state_transition/test_state_transition_guard_check.rb
transitions-0.1.0 test/test_state_transition_guard_check.rb
transitions-0.0.18 test/test_state_transition_guard_check.rb
transitions-0.0.17 test/test_state_transition_guard_check.rb
transitions-0.0.16 test/test_state_transition_guard_check.rb
transitions-0.0.14 test/test_state_transition_guard_check.rb
transitions-0.0.13 test/test_state_transition_guard_check.rb
transitions-0.0.12 test/test_state_transition_guard_check.rb
transitions-0.0.11 test/test_state_transition_guard_check.rb
transitions-0.0.10 test/test_state_transition_guard_check.rb
transitions-0.0.9 test/test_state_transition_guard_check.rb
transitions-0.0.5 test/test_state_transition_guard_check.rb