Created
December 8, 2010 12:06
-
-
Save kasperbn/733200 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.join(File.dirname(__FILE__), 'test_helper') | |
require 'workflow' | |
class BeforeTransitionTest < Test::Unit::TestCase | |
class MyFlow | |
attr_reader :history | |
def initialize | |
@history = [] | |
end | |
include Workflow | |
workflow do | |
state :first do | |
event :forward, :transitions_to => :second do | |
@history << 'forward' | |
end | |
end | |
state :second do | |
event :back, :transitions_to => :first do | |
@history << 'back' | |
end | |
end | |
before_transition { @history << 'before' } | |
on_transition { @history << 'on' } | |
end | |
end | |
test 'that before_transition is run before the action' do | |
flow = MyFlow.new | |
flow.forward! | |
flow.back! | |
assert flow.history == ['before', 'forward', 'on','before', 'back', 'on'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment