Skip to content

Commit

Permalink
- Add specs for parameter environment variable support (mdub#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansissel committed Apr 30, 2012
1 parent 74ad108 commit 59a9d21
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions spec/clamp/command_spec.rb
Expand Up @@ -521,6 +521,40 @@ def color=(c)

end

describe "with :env value" do

before do
@command.class.parameter "[FILE]", "a file", :env => "FILE",
:default => "default"
end

it "should use the default if neither flag nor env var are present" do
@command.parse([])
@command.file.should == "default"
end

it "should use the env value if present (instead of default)" do
ENV["FILE"] = "/etc/motd"
@command.parse([])
@command.file.should == ENV["FILE"]
end

it "should use the the flag value if present (instead of env)" do
ENV["FILE"] = "/etc/motd"
@command.parse(%w(/bin/sh))
@command.file.should == "/bin/sh"
end

describe "#help" do

it "describes the default value and env usage" do
@command.help.should include("a file (default: \"default\") (env: \"FILE\")")
end

end

end

end

describe "with no parameters declared" do
Expand Down

0 comments on commit 59a9d21

Please sign in to comment.