summaryrefslogtreecommitdiffstats
path: root/spec/unit/util
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-08-18 21:50:59 -0500
committerLuke Kanies <luke@madstop.com>2008-08-20 12:13:25 -0500
commita5ab52c628cae7ac9ed5ca1bd5de779944840802 (patch)
treed2c0db0f2859efaa25225fba82c40da94623d910 /spec/unit/util
parent4f275b669b0336c6032204bfa9694fa6522eb267 (diff)
Adding files temporarily, since I've decided this work is a dead-end.
I'm merely adding these so that they're in the history if I decided to look at them again. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/util')
-rwxr-xr-xspec/unit/util/state_machine.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/unit/util/state_machine.rb b/spec/unit/util/state_machine.rb
new file mode 100755
index 000000000..e8ffc629d
--- /dev/null
+++ b/spec/unit/util/state_machine.rb
@@ -0,0 +1,59 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/util/state_machine'
+
+describe Puppet::Util::StateMachine do
+ before do
+ @class = Puppet::Util::StateMachine
+ @machine = @class.new
+ end
+
+ it "should instance_eval any provided block" do
+ f = @class.new { state(:foo, "foo") }
+ f.should be_state(:foo)
+ end
+
+ it "should be able to declare states" do
+ @machine.should respond_to(:state)
+ end
+
+ it "should require documentation when declaring states" do
+ lambda { @machine.state(:foo) }.should raise_error(ArgumentError)
+ end
+
+ it "should be able to detect when states are set" do
+ @machine.state(:foo, "bar")
+ @machine.should be_state(:foo)
+ end
+
+ it "should be able to declare transitions" do
+ @machine.should respond_to(:transition)
+ end
+
+ describe "when adding transitions" do
+ it "should fail if the starting state of a transition is unknown" do
+ @machine.state(:end, "foo")
+ lambda { @machine.transition(:start, :end) }.should raise_error(ArgumentError)
+ end
+
+ it "should fail if the ending state of a transition is unknown" do
+ @machine.state(:start, "foo")
+ lambda { @machine.transition(:start, :end) }.should raise_error(ArgumentError)
+ end
+
+ it "should fail if an equivalent transition already exists" do
+ @machine.state(:start, "foo")
+ @machine.state(:end, "foo")
+ @machine.transition(:start, :end)
+ lambda { @machine.transition(:start, :end) }.should raise_error(ArgumentError)
+ end
+ end
+
+ describe "when making a transition" do
+ it "should require the initial state"
+
+ it "should return all of the transitions to be made"
+ end
+end