diff options
| author | mo k <mo@mokhan.ca> | 2012-02-16 23:01:49 -0700 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-02-16 23:01:49 -0700 |
| commit | 23c3c07dcf93c07cfc536cfd5d26933ae2d4b7a8 (patch) | |
| tree | 45ac5fb894f9023e785a92848cd39299d5f9cb11 | |
| parent | fda7402b36f86310afe52e9f30eb87fb73829a26 (diff) | |
figure out how to interact with the console.
| -rwxr-xr-x | bin/app.rb | 2 | ||||
| -rw-r--r-- | lib/console.rb | 29 | ||||
| -rw-r--r-- | spec/console_specs.rb | 22 | ||||
| -rwxr-xr-x | spec/ts_all.rb | 1 |
4 files changed, 54 insertions, 0 deletions
@@ -3,3 +3,5 @@ require "rover"
puts ARGV
+
+console = Console.new(STDIN, STDOUT)
diff --git a/lib/console.rb b/lib/console.rb new file mode 100644 index 0000000..128f6da --- /dev/null +++ b/lib/console.rb @@ -0,0 +1,29 @@ +class Console + def initialize(input, output) + @input = input + @output = output + end + def run(presenter) + @output.puts("Please enter the size of the terrain:") + presenter.provide_upper_right_coordinates(@input.gets) + command = @input.gets + while command != "q" do + presenter.deploy_rover_to(command) + @output.puts("Enter commands to navigate rover:") + presenter.navigate_rover_using(@input.gets) + end + presenter.process_output + end +end +class Presenter + def initialize(command_processor) + end + def provide_upper_right_coordinates(coordinates) + end + def deploy_rover_to(coordinates) + end + def navigate_rover_using(instructions) + end + def process_output + end +end diff --git a/spec/console_specs.rb b/spec/console_specs.rb new file mode 100644 index 0000000..a61855d --- /dev/null +++ b/spec/console_specs.rb @@ -0,0 +1,22 @@ +require "console" + +describe Console do + before do + @input = fake + @output = fake + @presenter = fake + @sut = Console.new(@input, @output) + end + describe "when run" do + it "should ask for the size of the terrain" do + @output.received(:puts).called_with("Please enter the size of the terrain:").wont_be_nil + end + it "should create the terrain" do + @presenter.received(:provide_upper_right_coordinates).called_with("5 5").wont_be_nil + end + before do + @input.stub(:gets).and_return("5 5") + #@sut.run(@presenter) + end + end +end diff --git a/spec/ts_all.rb b/spec/ts_all.rb index 1311bca..a7dff2d 100755 --- a/spec/ts_all.rb +++ b/spec/ts_all.rb @@ -10,4 +10,5 @@ require "rover_specs" require "north_specs" require "south_specs" require "terrain_specs" +require "console_specs" require "specifications/find_all_books_by_author_specs" |
