forked from jordansissel/fpm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test coverage for jordansissel#607 (safesystem w/ no $SHELL)
Also: Add missing SecureRandom.uuid under 1.8.x (for the tests)
- Loading branch information
jls
committed
Feb 5, 2014
1 parent
a536649
commit f8c7b24
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require "spec_setup" | ||
require "fpm" # local | ||
|
||
describe FPM::Util do | ||
subject do | ||
Class.new do | ||
include FPM::Util | ||
def initialize | ||
@logger = Cabin::Channel.new | ||
end | ||
end.new | ||
end | ||
|
||
describe "#safe_system" do | ||
context "with a missing $SHELL" do | ||
before do | ||
@orig_shell = ENV["SHELL"] | ||
ENV.delete("SHELL") | ||
end | ||
|
||
after do | ||
ENV["SHELL"] = @orig_shell unless @orig_shell.nil? | ||
end | ||
|
||
it "should assume /bin/sh" do | ||
insist { subject.default_shell } == "/bin/sh" | ||
end | ||
|
||
it "should still run commands correctly" do | ||
# This will raise an exception if we can't run it at all. | ||
subject.safesystem("true") | ||
end | ||
end | ||
context "with $SHELL set to an empty string" do | ||
before do | ||
@orig_shell = ENV["SHELL"] | ||
ENV["SHELL"] = "" | ||
end | ||
|
||
after do | ||
ENV["SHELL"] = @orig_shell unless @orig_shell.nil? | ||
end | ||
|
||
it "should assume /bin/sh" do | ||
insist { subject.default_shell } == "/bin/sh" | ||
end | ||
|
||
it "should still run commands correctly" do | ||
# This will raise an exception if we can't run it at all. | ||
subject.safesystem("true") | ||
end | ||
end | ||
end | ||
end |