spec/common_spec.rb in linux_admin-0.1.0 vs spec/common_spec.rb in linux_admin-0.1.1
- old
+ new
@@ -19,23 +19,36 @@
"--desc=" => "Some Description",
nil => ["pkg1", "some pkg"]
}
end
+ let (:modified_params) do
+ params.to_a + [123, 456].collect {|pool| ["--pool", pool]}
+ end
+
subject { TestClass }
context ".write" do
it "no file no content" do
expect { subject.write("", "") }.to raise_error(ArgumentError)
end
end
+ context ".cmd" do
+ it "looks up local command from id" do
+ d = stub(LinuxAdmin::Distro)
+ d.class::COMMANDS = { :sh => '/bin/sh' }
+ LinuxAdmin::Distro.should_receive(:local).and_return(d)
+ subject.cmd(:sh).should == '/bin/sh'
+ end
+ end
+
context ".run" do
context "with params" do
it "sanitizes crazy params" do
- subject.should_receive(:launch).once.with("true --user bob --pass P@\\$sw0\\^\\&\\ \\|\\<\\>/-\\+\\*d\\% --db --desc=Some\\ Description pkg1 some\\ pkg")
- subject.run("true", :params => params, :return_exitstatus => true)
+ subject.should_receive(:launch).once.with("true --user bob --pass P@\\$sw0\\^\\&\\ \\|\\<\\>/-\\+\\*d\\% --db --desc=Some\\ Description pkg1 some\\ pkg --pool 123 --pool 456")
+ subject.run("true", :params => modified_params, :return_exitstatus => true)
end
it "as empty hash" do
subject.should_receive(:launch).once.with("true")
subject.run("true", :params => {}, :return_exitstatus => true)
@@ -91,6 +104,6 @@
it "command bad" do
expect { subject.run("XXXXX", :return_output => true) }.to raise_error
end
end
end
-end
\ No newline at end of file
+end