Permalink
View
@@ -8,9 +8,10 @@ $:.unshift File.expand_path("../../lib", bin_file)
require "ppl"
bootstrap = Ppl::Application::Bootstrap.new
-input = bootstrap.input
-shell = bootstrap.shell
+input = bootstrap.input
+output = bootstrap.output
+shell = bootstrap.shell
-exit(shell.run(input))
+exit(shell.run(input, output))
@@ -4,7 +4,7 @@ class Ppl::Application::Command
attr_accessor :name
attr_accessor :description
- def execute
+ def execute(input, output)
raise NotImplementedError
end
@@ -3,11 +3,11 @@ class Ppl::Application::Shell
attr_writer :router
- def run(input)
+ def run(input, output)
outcome = false
begin
command = select_command(input)
- outcome = execute_command(command, input)
+ outcome = execute_command(command, input, output)
rescue
outcome = false
end
@@ -21,8 +21,8 @@ def select_command(input)
@router.route(input.arguments.first)
end
- def execute_command(command, input)
- command.execute
+ def execute_command(command, input, output)
+ command.execute(input, output)
end
end
@@ -6,7 +6,7 @@ def initialize
@description = "Show a list of commands"
end
- def execute
+ def execute(input, output)
puts "help text goes here"
return true
end
@@ -6,7 +6,7 @@
end
it "should raise not implemented error" do
- expect{@command.execute}.to raise_error(NotImplementedError)
+ expect{@command.execute(nil, nil)}.to raise_error(NotImplementedError)
end
end
@@ -2,8 +2,9 @@
describe Ppl::Application::Shell do
before(:each) do
- @shell = Ppl::Application::Shell.new
- @input = Ppl::Application::Input.new
+ @shell = Ppl::Application::Shell.new
+ @input = Ppl::Application::Input.new
+ @output = Ppl::Application::Output.new(nil, nil)
@router = double(Ppl::Application::Router)
@command = double(Ppl::Application::Command)
@@ -19,7 +20,7 @@
.should_receive(:route)
.with("foo")
.and_return(nil)
- @shell.run(@input).should eq false
+ @shell.run(@input, @output).should eq false
end
it "should execute the given command" do
@@ -33,7 +34,7 @@
.should_receive(:execute)
.and_return(true)
- @shell.run(@input).should eq true
+ @shell.run(@input, @output).should eq true
end
it "should return false if the command throws an exception" do
@@ -45,7 +46,7 @@
.should_receive(:route)
.and_return(@command)
- @shell.run(@input)
+ @shell.run(@input, @output)
end
end

0 comments on commit 54fe816

Please sign in to comment.