test/basic_test.rb in state_manager-0.3.3 vs test/basic_test.rb in state_manager-0.3.4
- old
+ new
@@ -3,10 +3,16 @@
class BasicTest < Minitest::Test
class PostStates < StateManager::Base
attr_accessor :title
+ attr_accessor :around_hit
+
+ def initialize(*args)
+ super
+ @around_hit = 0
+ end
state :unsubmitted do
event :submit, :transitions_to => 'submitted.awaiting_review'
end
state :submitted do
@@ -27,10 +33,15 @@
class Active
def entered
state_manager.title = title
end
end
+
+ def around_event(name, *args)
+ @around_hit += 1
+ yield
+ end
end
class Post
@@ -152,8 +163,13 @@
def test_property_proxying
@resource = Post.new
@resource.title = 'some title'
@resource.state_manager.transition_to 'active'
assert_equal 'some title', @resource.state_manager.title
+ end
+
+ def test_around_event
+ @resource.state_manager.send_event! :submit
+ assert_equal 1, @resource.state_manager.around_hit
end
end