summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--lib/command_processor.rb4
-rw-r--r--spec/command_processor_specs.rb9
3 files changed, 13 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6e92f57
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+tags
diff --git a/lib/command_processor.rb b/lib/command_processor.rb
index 7e9de08..738b9b1 100644
--- a/lib/command_processor.rb
+++ b/lib/command_processor.rb
@@ -6,6 +6,8 @@ class CommandProcessor
@commands << command
end
def run
- @commands.each { |e| e.run }
+ while @commands.length > 0 do
+ @commands.shift.run
+ end
end
end
diff --git a/spec/command_processor_specs.rb b/spec/command_processor_specs.rb
index 6bb90ba..0d47f3a 100644
--- a/spec/command_processor_specs.rb
+++ b/spec/command_processor_specs.rb
@@ -16,5 +16,14 @@ describe CommandProcessor do
@sut.add(@second_command)
@sut.run
end
+ describe "when run again" do
+ it "should have nothing to run" do
+ @first_command.received(:run).times?(1).must_equal true
+ @second_command.received(:run).times?(1).must_equal true
+ end
+ before(:each) do
+ @sut.run
+ end
+ end
end
end