diff options
| author | mo k <mo@mokhan.ca> | 2012-02-16 23:32:42 -0700 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-02-16 23:32:42 -0700 |
| commit | 272c52e0402378d209e96af29a6edce963d8868c (patch) | |
| tree | b68ef4a6c276ec3cfc19e4a1ae79ac191d8e139f | |
| parent | faa9af85891ceee8ea87e01b5b4412d6aa6cbc55 (diff) | |
create anonymous command.
| -rw-r--r-- | lib/anonymous_command.rb | 8 | ||||
| -rw-r--r-- | spec/anonymous_command_specs.rb | 16 | ||||
| -rw-r--r-- | spec/command_processor_specs.rb | 2 | ||||
| -rwxr-xr-x | spec/ts_all.rb | 2 |
4 files changed, 27 insertions, 1 deletions
diff --git a/lib/anonymous_command.rb b/lib/anonymous_command.rb new file mode 100644 index 0000000..767d689 --- /dev/null +++ b/lib/anonymous_command.rb @@ -0,0 +1,8 @@ +class AnonymousCommand + def initialize(block) + @block = block + end + def run + @block.call() + end +end diff --git a/spec/anonymous_command_specs.rb b/spec/anonymous_command_specs.rb new file mode 100644 index 0000000..2616770 --- /dev/null +++ b/spec/anonymous_command_specs.rb @@ -0,0 +1,16 @@ +require "anonymous_command" + +describe AnonymousCommand do + describe "when run" do + it "should run the block" do + assert_equal true, @called + end + before(:each) do + #block = lambda { @called = true } + block = Proc.new { @called = true } + @called = false + @sut = AnonymousCommand.new(block) + @sut.run + end + end +end diff --git a/spec/command_processor_specs.rb b/spec/command_processor_specs.rb index 22c4099..6bb90ba 100644 --- a/spec/command_processor_specs.rb +++ b/spec/command_processor_specs.rb @@ -1,6 +1,6 @@ require "command_processor" -describe CommandProcessorSpecs do +describe CommandProcessor do before(:each) do @sut = CommandProcessor.new end diff --git a/spec/ts_all.rb b/spec/ts_all.rb index a7dff2d..ac6c8b6 100755 --- a/spec/ts_all.rb +++ b/spec/ts_all.rb @@ -11,4 +11,6 @@ require "north_specs" require "south_specs" require "terrain_specs" require "console_specs" +require "command_processor_specs" +require "anonymous_command_specs" require "specifications/find_all_books_by_author_specs" |
