spec/command-task.rb in mattock-0.0.1 vs spec/command-task.rb in mattock-0.1.0
- old
+ new
@@ -3,37 +3,35 @@
require 'mattock/testing/mock-command-line'
describe Mattock::RemoteCommandTask do
include Mattock::RakeExampleGroup
let! :remote_task do
- Mattock::RemoteCommandTask.new do |t|
- t.namespace_name = :test
- t.remote_server.address = "nowhere.com"
- t.command = Mattock::PrereqChain.new do |prereq|
- prereq.add Mattock::CommandLine.new("cd", "a_dir")
- prereq.add Mattock::PipelineChain.new do |pipe|
- pipe.add Mattock::CommandLine.new("ls")
- pipe.add Mattock::CommandLine.new("grep") do |cmd|
- cmd.options << "*.rb"
- cmd.redirect_stderr("/dev/null")
- cmd.redirect_stdout("/tmp/rubyfiles.txt")
+ namespace :test do
+ Mattock::RemoteCommandTask.new do |t|
+ t.remote_server.address = "nowhere.com"
+ t.command = Mattock::PrereqChain.new do |prereq|
+ prereq.add Mattock::CommandLine.new("cd", "a_dir")
+ prereq.add Mattock::PipelineChain.new do |pipe|
+ pipe.add Mattock::CommandLine.new("ls")
+ pipe.add Mattock::CommandLine.new("grep") do |cmd|
+ cmd.options << "*.rb"
+ cmd.redirect_stderr("/dev/null")
+ cmd.redirect_stdout("/tmp/rubyfiles.txt")
+ end
end
end
+ t.verify_command = Mattock::CommandLine.new("should_do")
end
- t.verify_command = Mattock::CommandLine.new("should_do")
end
end
describe "when verification indicates command should proceed" do
+ include Mattock::CommandLineExampleGroup
+
it "should run both commands" do
- cmds = [/should_do/, /^ssh.*cd.*ls.*grep.*rubyfiles.txt/]
- res = [1, 0]
- Mattock::CommandLine.should_receive(:execute) do |cmd|
- cmd.should =~ cmds.shift
- Mattock::MockCommandResult.create(res.shift)
- end.exactly(2).times
+ expect_command(/should_do/, 1)
+ expect_command(/^ssh.*cd.*ls.*grep.*rubyfiles.txt/, 0)
rake["test:run"].invoke
- cmds.should == []
end
end
end