Add "exec" action to allow execution of arbitrary commands with the app's environment.

This commit is contained in:
Matt Griffin
2012-01-04 15:22:10 -05:00
parent fff15bc627
commit a34bc59721
4 changed files with 88 additions and 0 deletions
+49
View File
@@ -89,5 +89,54 @@ describe "Foreman::CLI" do
end
end
end
describe "exec" do
describe "with a valid Procfile" do
before { write_procfile }
describe "and a command" do
let(:command) { ["ls", "-l"] }
before(:each) do
stub(Kernel).exec
end
it "should load the environment file" do
write_env
preserving_env do
subject.exec *command
ENV["FOO"].should == "bar"
end
ENV["FOO"].should be_nil
end
it "should execute the command as a string" do
mock(Kernel).exec(command.join(" "))
subject.exec *command
end
end
describe "and a non-existent command" do
let(:command) { "iuhtngrglhulhdfg" }
it "should print an error" do
mock_error(subject, "command not found: #{command}") do
subject.exec command
end
end
end
describe "and a non-executable command" do
let(:command) { __FILE__ }
it "should print an error" do
mock_error(subject, "not executable: #{command}") do
subject.exec command
end
end
end
end
end
end