spec/command-line.rb in mattock-0.2.13 vs spec/command-line.rb in mattock-0.3.0

- old
+ new

@@ -44,9 +44,55 @@ result.stdout.should == "Some text" end end end +describe Mattock::CommandLineDSL do + include described_class + + describe "using the - operator" do + let :command do + cmd("sudo") - ["gem", "install", "bundler"] + end + + it "should define commands" do + command.should be_an_instance_of(Mattock::WrappingChain) + command.should have(2).commands + command.commands[0].should be_an_instance_of(Mattock::CommandLine) + command.commands[1].should be_an_instance_of(Mattock::CommandLine) + command.command.should == "sudo -- gem install bundler" + end + end + + describe "using the | operator" do + let :command do + cmd("cat", "/etc/passwd") | ["grep", "root"] + end + + it "should define commands" do + command.should be_an_instance_of(Mattock::PipelineChain) + command.should have(2).commands + command.commands[0].should be_an_instance_of(Mattock::CommandLine) + command.commands[1].should be_an_instance_of(Mattock::CommandLine) + command.command.should == "cat /etc/passwd | grep root" + end + end + + describe "using the && operator" do + let :command do + cmd("cd", "/tmp/trash") & %w{rm -rf *} + end + + it "should define commands" do + command.should be_an_instance_of(Mattock::PrereqChain) + command.should have(2).commands + command.commands[0].should be_an_instance_of(Mattock::CommandLine) + command.commands[1].should be_an_instance_of(Mattock::CommandLine) + command.command.should == "cd /tmp/trash && rm -rf *" + end + end +end + describe Mattock::CommandLine, "that fails" do let :commandline do Mattock::CommandLine.new("false") end