moody 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/moody.rb +1 -0
- data/moody.gemspec +1 -1
- data/test/test_moody.rb +15 -0
- metadata +2 -2
data/lib/moody.rb
CHANGED
data/moody.gemspec
CHANGED
data/test/test_moody.rb
CHANGED
@@ -72,6 +72,15 @@ class TestMoodyByExample < Test::Unit::TestCase
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
class EmptyContext
|
76
|
+
class A < Moody::State; end
|
77
|
+
class B < Moody::State; end
|
78
|
+
|
79
|
+
extend Moody::Context
|
80
|
+
|
81
|
+
initial_state A
|
82
|
+
end
|
83
|
+
|
75
84
|
def setup
|
76
85
|
$callbacks = []
|
77
86
|
@context_class = Class.new(SiegeTank)
|
@@ -92,6 +101,12 @@ class TestMoodyByExample < Test::Unit::TestCase
|
|
92
101
|
assert test_context.state.is_a?(TankMode)
|
93
102
|
end
|
94
103
|
|
104
|
+
def test_switch_from_context
|
105
|
+
test_context = EmptyContext.new
|
106
|
+
test_context.switch_to EmptyContext::B
|
107
|
+
assert test_context.state.is_a?(EmptyContext::B)
|
108
|
+
end
|
109
|
+
|
95
110
|
def test_delegates_methods
|
96
111
|
test_context = @context_class.new
|
97
112
|
test_context.siege_mode!
|