Skip to content

Commit

Permalink
(PUP-3239) Add additional spec tests
Browse files Browse the repository at this point in the history
Added some spec tests for `unsafe_manifest_interpolation?` and revised
the function to return booleans only.
  • Loading branch information
Britt Gresham committed Sep 29, 2014
1 parent f69d984 commit 776a2a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/node/environment.rb
Expand Up @@ -264,8 +264,8 @@ def conflicting_manifest_settings?
# in either of the settings then return true, otherwise return false.
# @api public
def unsafe_manifest_interpolation?
return /\$environment/ =~ Puppet.settings.value(:environmentpath, name, true) ||
/\$environment/ =~ Puppet.settings.value(:basemodulepath, name, true)
return !!Puppet.settings.value(:environmentpath, name, true).match(/\$environment/) ||
!!Puppet.settings.value(:basemodulepath, name, true).match(/\$environment/)
end

# Validates a manifest for this environment. If the manifest cannot be
Expand Down
16 changes: 16 additions & 0 deletions spec/unit/node/environment_spec.rb
Expand Up @@ -175,6 +175,22 @@
env.modulepath.should == [real_file]
end

context "unsafe_manifest_interpolation?" do
it "should return true when environmentpath is unsafe" do
Puppet[:environmentpath] = "/tmp/$environment/"
expect(env.unsafe_manifest_interpolation?).to eq(true)
end
it "should return true when basemodulepath is unsafe" do
Puppet[:basemodulepath] = "/tmp/$environment/"
expect(env.unsafe_manifest_interpolation?).to eq(true)
end
it "should return false when environmentpath and basemodulepath are safe" do
Puppet[:environmentpath] = "/tmp/environments/"
Puppet[:basemodulepath] = "/tmp/modules/"
expect(env.unsafe_manifest_interpolation?).to eq(false)
end
end

it "should prefix the value of the 'PUPPETLIB' environment variable to the module path if present" do
first_puppetlib = tmpdir('puppetlib1')
second_puppetlib = tmpdir('puppetlib2')
Expand Down

0 comments on commit 776a2a2

Please sign in to comment.