state_machine 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/Rakefile +1 -1
- data/lib/state_machine.rb +0 -4
- data/lib/state_machine/callback.rb +21 -19
- data/lib/state_machine/integrations/active_record.rb +32 -0
- data/lib/state_machine/integrations/data_mapper.rb +38 -0
- data/lib/state_machine/integrations/sequel.rb +35 -0
- data/lib/state_machine/machine.rb +33 -8
- data/lib/state_machine/transition.rb +4 -6
- data/test/active_record.log +9825 -0
- data/test/sequel.log +3276 -0
- data/test/unit/callback_test.rb +213 -41
- data/test/unit/machine_collection_test.rb +31 -46
- data/test/unit/machine_test.rb +2 -2
- data/test/unit/transition_test.rb +4 -21
- metadata +2 -2
data/test/unit/machine_test.rb
CHANGED
@@ -1276,9 +1276,9 @@ class MachineWithTransitionCallbacksTest < Test::Unit::TestCase
|
|
1276
1276
|
assert_nothing_raised {@machine.before_transition :invalid => true, :do => lambda {}}
|
1277
1277
|
end
|
1278
1278
|
|
1279
|
-
def
|
1279
|
+
def test_should_raise_exception_if_method_not_specified
|
1280
1280
|
exception = assert_raise(ArgumentError) {@machine.before_transition :to => :idling}
|
1281
|
-
assert_equal '
|
1281
|
+
assert_equal 'Method(s) for callback must be specified', exception.message
|
1282
1282
|
end
|
1283
1283
|
|
1284
1284
|
def test_should_invoke_callbacks_during_transition
|
@@ -79,27 +79,6 @@ class TransitionTest < Test::Unit::TestCase
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
class TransitionWithoutEventTest < Test::Unit::TestCase
|
83
|
-
def setup
|
84
|
-
@klass = Class.new
|
85
|
-
@machine = StateMachine::Machine.new(@klass)
|
86
|
-
@machine.state :parked, :idling
|
87
|
-
|
88
|
-
@object = @klass.new
|
89
|
-
@object.state = 'parked'
|
90
|
-
|
91
|
-
@transition = StateMachine::Transition.new(@object, @machine, nil, :parked, :idling)
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_should_not_have_an_event
|
95
|
-
assert_nil @transition.event
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_should_not_have_a_qualified_event
|
99
|
-
assert_nil @transition.qualified_event
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
82
|
class TransitionWithInvalidNodesTest < Test::Unit::TestCase
|
104
83
|
def setup
|
105
84
|
@klass = Class.new
|
@@ -111,6 +90,10 @@ class TransitionWithInvalidNodesTest < Test::Unit::TestCase
|
|
111
90
|
@object.state = 'parked'
|
112
91
|
end
|
113
92
|
|
93
|
+
def test_should_raise_exception_without_event
|
94
|
+
assert_raise(IndexError) { StateMachine::Transition.new(@object, @machine, nil, :parked, :idling) }
|
95
|
+
end
|
96
|
+
|
114
97
|
def test_should_raise_exception_with_invalid_event
|
115
98
|
assert_raise(IndexError) { StateMachine::Transition.new(@object, @machine, :invalid, :parked, :idling) }
|
116
99
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: state_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Pfeifer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-08 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|