summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/functions
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/parser/functions')
-rwxr-xr-xspec/unit/parser/functions/create_resources_spec.rb2
-rwxr-xr-xspec/unit/parser/functions/extlookup_spec.rb10
-rwxr-xr-xspec/unit/parser/functions/fqdn_rand_spec.rb12
3 files changed, 8 insertions, 16 deletions
diff --git a/spec/unit/parser/functions/create_resources_spec.rb b/spec/unit/parser/functions/create_resources_spec.rb
index da76e75d0..94b1e7c68 100755
--- a/spec/unit/parser/functions/create_resources_spec.rb
+++ b/spec/unit/parser/functions/create_resources_spec.rb
@@ -78,7 +78,7 @@ notify{test:}
end
it 'should fail if defines are missing params' do
@scope.function_create_resources(['foo', {'blah'=>{}}])
- lambda { @scope.compiler.compile }.should raise_error(Puppet::ParseError, 'Must pass one to Foo[blah] at line 1')
+ lambda { @scope.compiler.compile }.should raise_error(Puppet::ParseError, /Must pass one to Foo\[blah\]/)
end
it 'should be able to add multiple defines' do
hash = {}
diff --git a/spec/unit/parser/functions/extlookup_spec.rb b/spec/unit/parser/functions/extlookup_spec.rb
index f68daaf3f..30962e137 100755
--- a/spec/unit/parser/functions/extlookup_spec.rb
+++ b/spec/unit/parser/functions/extlookup_spec.rb
@@ -64,7 +64,7 @@ describe "the extlookup function" do
describe "should look in $extlookup_datadir for data files listed by $extlookup_precedence" do
before do
- @scope.stubs(:lookupvar).with('::extlookup_datadir').returns("/tmp")
+ @scope.stubs(:[]).with('::extlookup_datadir').returns("/tmp")
File.open("/tmp/one.csv","w"){|one| one.puts "key,value1" }
File.open("/tmp/two.csv","w") do |two|
two.puts "key,value2"
@@ -73,21 +73,21 @@ describe "the extlookup function" do
end
it "when the key is in the first file" do
- @scope.stubs(:lookupvar).with('::extlookup_precedence').returns(["one","two"])
+ @scope.stubs(:[]).with('::extlookup_precedence').returns(["one","two"])
result = @scope.function_extlookup([ "key" ])
result.should == "value1"
end
it "when the key is in the second file" do
- @scope.stubs(:lookupvar).with('::extlookup_precedence').returns(["one","two"])
+ @scope.stubs(:[]).with('::extlookup_precedence').returns(["one","two"])
result = @scope.function_extlookup([ "key2" ])
result.should == "value_two"
end
it "should not modify extlookup_precedence data" do
variable = '%{fqdn}'
- @scope.stubs(:lookupvar).with('::extlookup_precedence').returns([variable,"one"])
- @scope.stubs(:lookupvar).with('::fqdn').returns('myfqdn')
+ @scope.stubs(:[]).with('::extlookup_precedence').returns([variable,"one"])
+ @scope.stubs(:[]).with('::fqdn').returns('myfqdn')
result = @scope.function_extlookup([ "key" ])
variable.should == '%{fqdn}'
end
diff --git a/spec/unit/parser/functions/fqdn_rand_spec.rb b/spec/unit/parser/functions/fqdn_rand_spec.rb
index 90fc0ef41..53c498453 100755
--- a/spec/unit/parser/functions/fqdn_rand_spec.rb
+++ b/spec/unit/parser/functions/fqdn_rand_spec.rb
@@ -8,6 +8,7 @@ describe "the fqdn_rand function" do
before :each do
@scope = Puppet::Parser::Scope.new
+ @scope[:fqdn] = "127.0.0.1"
end
it "should exist" do
@@ -15,49 +16,40 @@ describe "the fqdn_rand function" do
end
it "should handle 0 arguments" do
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([]) }.should_not raise_error(Puppet::ParseError)
end
it "should handle 1 argument'}" do
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([3]) }.should_not raise_error(Puppet::ParseError)
end
(1..10).each { |n|
it "should handle #{n} additional arguments" do
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([3,1,2,3,4,5,6,7,8,9,10][0..n]) }.should_not raise_error(Puppet::ParseError)
end
it "should handle #{n} additional string arguments" do
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
lambda { @scope.function_fqdn_rand([3,%w{ 1 2 3 4 5 6 7 8 9 10}].flatten[0..n]) }.should_not raise_error(Puppet::ParseError)
end
}
it "should return a value less than max" do
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
@scope.function_fqdn_rand([3]).should satisfy {|n| n.to_i < 3 }
end
it "should return the same values on subsequent invocations for the same host" do
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1").twice
@scope.function_fqdn_rand([3,4]).should eql(@scope.function_fqdn_rand([3, 4]))
end
it "should return different sequences of value for different hosts" do
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
val1 = @scope.function_fqdn_rand([10000000,4])
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.2")
+ @scope.expects(:[]).with("::fqdn").returns("127.0.0.2")
val2 = @scope.function_fqdn_rand([10000000,4])
val1.should_not eql(val2)
end
it "should return different values for the same hosts with different seeds" do
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
val1 = @scope.function_fqdn_rand([10000000,4])
- @scope.expects(:lookupvar).with("::fqdn").returns("127.0.0.1")
val2 = @scope.function_fqdn_rand([10000000,42])
val1.should_not eql(val2)
end