summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-02-06 11:34:16 -0800
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit0d704686b923c7827b9fe16f20d4f8722c125d88 (patch)
treebc410cb6b30e8f56b6a8abae93ee8e195febb485 /spec
parentad93d0e442d4e4eff69bb3f444b2eee70a95dfa8 (diff)
downloadpuppet-0d704686b923c7827b9fe16f20d4f8722c125d88.tar.gz
puppet-0d704686b923c7827b9fe16f20d4f8722c125d88.tar.xz
puppet-0d704686b923c7827b9fe16f20d4f8722c125d88.zip
Finishing renaming :params to :parameters internally
I had only done this partway, because it seemed easier, but not surprisingly, it ended up being more complex. In addition to those renames, this commit includes fixes to whatever tests I needed to fix to confirm that things were again working. I think most of these broken tests have been broken for a while. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/integration/parser/collector.rb38
-rwxr-xr-xspec/integration/parser/functions/require.rb2
-rwxr-xr-xspec/unit/other/transbucket.rb2
-rwxr-xr-xspec/unit/parser/ast/resource.rb6
-rwxr-xr-xspec/unit/parser/ast/resource_defaults.rb22
-rwxr-xr-xspec/unit/parser/ast/resource_override.rb10
-rwxr-xr-xspec/unit/parser/collector.rb24
-rwxr-xr-xspec/unit/parser/parser.rb2
-rwxr-xr-xspec/unit/type.rb4
-rwxr-xr-xspec/unit/type/component.rb6
-rw-r--r--spec/unit/util/reference_serializer.rb2
11 files changed, 89 insertions, 29 deletions
diff --git a/spec/integration/parser/collector.rb b/spec/integration/parser/collector.rb
new file mode 100755
index 000000000..4b1279e61
--- /dev/null
+++ b/spec/integration/parser/collector.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/parser/collector'
+
+describe Puppet::Parser::Collector do
+ before do
+ @scope = Puppet::Parser::Scope.new(:compiler => Puppet::Parser::Compiler.new(Puppet::Node.new("mynode")))
+
+ @resource = Puppet::Parser::Resource.new("file", "/tmp/testing", :scope => @scope, :source => "fakesource")
+ {:owner => "root", :group => "bin", :mode => "644"}.each do |param, value|
+ @resource[param] = value
+ end
+ end
+
+ def query(text)
+ code = "File <| #{text} |>"
+ parser = Puppet::Parser::Parser.new(@scope.compiler)
+ parser.parse(code).hostclass("").code[0].query
+ end
+
+ {true => [%{title == "/tmp/testing"}, %{(title == "/tmp/testing")}, %{group == bin},
+ %{title == "/tmp/testing" and group == bin}, %{title == bin or group == bin},
+ %{title == "/tmp/testing" or title == bin}, %{title == "/tmp/testing"},
+ %{(title == "/tmp/testing" or title == bin) and group == bin}],
+ false => [%{title == bin}, %{title == bin or (title == bin and group == bin)},
+ %{title != "/tmp/testing"}, %{title != "/tmp/testing" and group != bin}]
+ }.each do |result, ary|
+ ary.each do |string|
+ it "should return '#{result}' when collecting resources with '#{string}'" do
+ str, code = query(string).evaluate @scope
+ code.should be_instance_of(Proc)
+ code.call(@resource).should == result
+ end
+ end
+ end
+end
diff --git a/spec/integration/parser/functions/require.rb b/spec/integration/parser/functions/require.rb
index 143729967..fa1c1bcbb 100755
--- a/spec/integration/parser/functions/require.rb
+++ b/spec/integration/parser/functions/require.rb
@@ -22,7 +22,7 @@ describe "The require function" do
@scope.resource["require"].should_not be_nil
ref = @scope.resource["require"].shift
ref.type.should == "Class"
- ref.title.should == "requiredclass"
+ ref.title.should == "Requiredclass"
end
it "should queue relationships between the 'required' class and our classes" do
diff --git a/spec/unit/other/transbucket.rb b/spec/unit/other/transbucket.rb
index 63b5137b5..a76195120 100755
--- a/spec/unit/other/transbucket.rb
+++ b/spec/unit/other/transbucket.rb
@@ -44,7 +44,7 @@ describe Puppet::TransBucket do
it "should return use 'component' as the type and the provided type as the title if only a name is provided" do
@bucket.name = "mystuff"
- @bucket.to_ref.should == "Class[mystuff]"
+ @bucket.to_ref.should == "Class[Mystuff]"
end
it "should return nil as its reference when type and name are missing" do
diff --git a/spec/unit/parser/ast/resource.rb b/spec/unit/parser/ast/resource.rb
index 40074c7ca..2473fda25 100755
--- a/spec/unit/parser/ast/resource.rb
+++ b/spec/unit/parser/ast/resource.rb
@@ -10,14 +10,14 @@ describe Puppet::Parser::AST::Resource do
@compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
@scope = Puppet::Parser::Scope.new(:compiler => @compiler)
@scope.stubs(:resource).returns(stub_everything)
- @resource = ast::Resource.new(:title => @title, :type => "file", :params => ast::ASTArray.new(:children => []) )
+ @resource = ast::Resource.new(:title => @title, :type => "file", :parameters => ast::ASTArray.new(:children => []) )
@resource.stubs(:qualified_type).returns("Resource")
end
it "should evaluate all its parameters" do
param = stub 'param'
param.expects(:safeevaluate).with(@scope).returns Puppet::Parser::Resource::Param.new(:name => "myparam", :value => "myvalue", :source => stub("source"))
- @resource.stubs(:params).returns [param]
+ @resource.stubs(:parameters).returns [param]
@resource.evaluate(@scope)
end
@@ -98,7 +98,7 @@ describe Puppet::Parser::AST::Resource do
def resource(type, params = nil)
params ||= Puppet::Parser::AST::ASTArray.new(:children => [])
- Puppet::Parser::AST::Resource.new(:type => type, :title => Puppet::Parser::AST::String.new(:value => "myresource"), :params => params)
+ Puppet::Parser::AST::Resource.new(:type => type, :title => Puppet::Parser::AST::String.new(:value => "myresource"), :parameters => params)
end
it "should be able to generate resources with fully qualified type information" do
diff --git a/spec/unit/parser/ast/resource_defaults.rb b/spec/unit/parser/ast/resource_defaults.rb
new file mode 100755
index 000000000..b2cec31c6
--- /dev/null
+++ b/spec/unit/parser/ast/resource_defaults.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+describe Puppet::Parser::AST::ResourceDefaults do
+
+ ast = Puppet::Parser::AST
+
+ before :each do
+ @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
+ @scope = Puppet::Parser::Scope.new(:compiler => @compiler)
+ @params = Puppet::Parser::AST::ASTArray.new({})
+ @compiler.stubs(:add_override)
+ end
+
+ it "should add defaults when evaluated" do
+ default = Puppet::Parser::AST::ResourceDefaults.new :type => "file", :parameters => Puppet::Parser::AST::ASTArray.new(:children => [])
+ default.evaluate @scope
+
+ @scope.lookupdefaults("file").should_not be_nil
+ end
+end
diff --git a/spec/unit/parser/ast/resource_override.rb b/spec/unit/parser/ast/resource_override.rb
index 2735757d4..d327b57cd 100755
--- a/spec/unit/parser/ast/resource_override.rb
+++ b/spec/unit/parser/ast/resource_override.rb
@@ -7,7 +7,7 @@ describe Puppet::Parser::AST::ResourceOverride do
ast = Puppet::Parser::AST
before :each do
- @compiler = stub 'compiler'
+ @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
@scope = Puppet::Parser::Scope.new(:compiler => @compiler)
@params = ast::ASTArray.new({})
@compiler.stubs(:add_override)
@@ -17,7 +17,7 @@ describe Puppet::Parser::AST::ResourceOverride do
klass = stub 'klass', :title => "title", :type => "type"
object = mock 'object'
object.expects(:safeevaluate).with(@scope).returns(klass)
- ast::ResourceOverride.new(:object => object, :params => @params ).evaluate(@scope)
+ ast::ResourceOverride.new(:object => object, :parameters => @params ).evaluate(@scope)
end
it "should tell the compiler to override the resource with our own" do
@@ -25,13 +25,13 @@ describe Puppet::Parser::AST::ResourceOverride do
klass = stub 'klass', :title => "title", :type => "one"
object = mock 'object', :safeevaluate => klass
- ast::ResourceOverride.new(:object => object , :params => @params).evaluate(@scope)
+ ast::ResourceOverride.new(:object => object , :parameters => @params).evaluate(@scope)
end
it "should return the overriden resource directly when called with one item" do
klass = stub 'klass', :title => "title", :type => "one"
object = mock 'object', :safeevaluate => klass
- override = ast::ResourceOverride.new(:object => object , :params => @params).evaluate(@scope)
+ override = ast::ResourceOverride.new(:object => object , :parameters => @params).evaluate(@scope)
override.should be_an_instance_of(Puppet::Parser::Resource)
override.title.should == "title"
override.type.should == "One"
@@ -43,7 +43,7 @@ describe Puppet::Parser::AST::ResourceOverride do
object = mock 'object', :safeevaluate => [klass1,klass2]
- override = ast::ResourceOverride.new(:object => object , :params => @params).evaluate(@scope)
+ override = ast::ResourceOverride.new(:object => object , :parameters => @params).evaluate(@scope)
override.should have(2).elements
override.each {|o| o.should be_an_instance_of(Puppet::Parser::Resource) }
end
diff --git a/spec/unit/parser/collector.rb b/spec/unit/parser/collector.rb
index 78d47c63f..42da3ff9e 100755
--- a/spec/unit/parser/collector.rb
+++ b/spec/unit/parser/collector.rb
@@ -42,7 +42,7 @@ describe Puppet::Parser::Collector, "when initializing" do
it "should accept an optional resource override" do
@collector = Puppet::Parser::Collector.new(@scope, "resource::type", @equery, @vquery, @form)
- override = { :params => "whatever" }
+ override = { :parameters => "whatever" }
@collector.add_override(override)
@collector.overrides.should equal(override)
end
@@ -181,9 +181,9 @@ describe Puppet::Parser::Collector, "when collecting virtual and catalog resourc
@compiler.expects(:resources).returns([one])
- @collector.add_override(:params => param )
+ @collector.add_override(:parameters => param )
Puppet::Parser::Resource.expects(:new).with { |type, title, h|
- h[:params] == param
+ h[:parameters] == param
}
@collector.evaluate
@@ -197,7 +197,7 @@ describe Puppet::Parser::Collector, "when collecting virtual and catalog resourc
@compiler.expects(:resources).returns([one])
- @collector.add_override(:params => param, :source => source )
+ @collector.add_override(:parameters => param, :source => source )
Puppet::Parser::Resource.stubs(:new)
source.expects(:meta_def).with { |name,block| name == :child_of? }
@@ -213,9 +213,9 @@ describe Puppet::Parser::Collector, "when collecting virtual and catalog resourc
@compiler.expects(:resources).at_least(2).returns([one])
- @collector.add_override(:params => param )
+ @collector.add_override(:parameters => param )
Puppet::Parser::Resource.expects(:new).once.with { |type, title, h|
- h[:params] == param
+ h[:parameters] == param
}
@collector.evaluate
@@ -239,7 +239,7 @@ describe Puppet::Parser::Collector, "when collecting virtual and catalog resourc
one.expects(:virtual=).with(false)
@compiler.expects(:resources).returns([one])
- @collector.add_override(:params => param )
+ @collector.add_override(:parameters => param )
Puppet::Parser::Resource.stubs(:new).returns("whatever")
@compiler.expects(:add_override).with("whatever")
@@ -266,14 +266,14 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
confine "Cannot test Rails integration without ActiveRecord" => Puppet.features.rails?
before do
- @scope = stub 'scope', :host => "myhost", :debug => nil
- @compiler = mock 'compile'
- @scope.stubs(:compiler).returns(@compiler)
+ @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
+ @scope = Puppet::Parser::Scope.new :compiler => @compiler
@resource_type = "Mytype"
@equery = "test = true"
@vquery = proc { |r| true }
Puppet.settings.stubs(:value).with(:storeconfigs).returns true
+ Puppet.settings.stubs(:value).with(:environment).returns "production"
@collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported)
end
@@ -374,9 +374,9 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
@compiler.stubs(:add_override)
@compiler.stubs(:add_resource)
- @collector.add_override(:params => param )
+ @collector.add_override(:parameters => param )
Puppet::Parser::Resource.expects(:new).once.with { |type, title, h|
- h[:params] == param
+ h[:parameters] == param
}
@collector.evaluate
diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb
index 8cc29c9b8..909a73c98 100755
--- a/spec/unit/parser/parser.rb
+++ b/spec/unit/parser/parser.rb
@@ -154,7 +154,7 @@ describe Puppet::Parser do
it "should create an ast::ResourceOverride" do
ast::ResourceOverride.expects(:new).with { |arg|
- arg[:line]==1 and arg[:object].is_a?(ast::ResourceReference) and arg[:params].is_a?(ast::ResourceParam)
+ arg[:line]==1 and arg[:object].is_a?(ast::ResourceReference) and arg[:parameters].is_a?(ast::ResourceParam)
}
@parser.parse('Resource["title1","title2"] { param => value }')
end
diff --git a/spec/unit/type.rb b/spec/unit/type.rb
index b2f4bcbd4..9381c0a83 100755
--- a/spec/unit/type.rb
+++ b/spec/unit/type.rb
@@ -485,9 +485,9 @@ describe Puppet::Type::RelationshipMetaparam do
param = Puppet::Type.metaparamclass(:require).new(:resource => resource, :value => %w{Foo[bar] Class[test]})
catalog.expects(:resource).with("Foo[bar]").returns "something"
- catalog.expects(:resource).with("Class[test]").returns nil
+ catalog.expects(:resource).with("Class[Test]").returns nil
- param.expects(:fail).with { |string| string.include?("Class[test]") }
+ param.expects(:fail).with { |string| string.include?("Class[Test]") }
param.validate_relationship
end
diff --git a/spec/unit/type/component.rb b/spec/unit/type/component.rb
index 64d26d5e2..ab60e02f2 100755
--- a/spec/unit/type/component.rb
+++ b/spec/unit/type/component.rb
@@ -10,11 +10,11 @@ describe component do
end
it "should use Class as its type when a normal string is provided as the title" do
- component.new(:name => "bar").ref.should == "Class[bar]"
+ component.new(:name => "bar").ref.should == "Class[Bar]"
end
it "should always produce a resource reference string as its title" do
- component.new(:name => "bar").title.should == "Class[bar]"
+ component.new(:name => "bar").title.should == "Class[Bar]"
end
it "should have a reference string equivalent to its title" do
@@ -49,7 +49,7 @@ describe component do
describe "when building up the path" do
it "should produce the class name if the component models a class" do
- component.new(:name => "Class[foo]").pathbuilder.must == ["foo"]
+ component.new(:name => "Class[foo]").pathbuilder.must == ["Foo"]
end
it "should produce an empty string if the component models the 'main' class" do
diff --git a/spec/unit/util/reference_serializer.rb b/spec/unit/util/reference_serializer.rb
index c3da45a36..cfabec4cc 100644
--- a/spec/unit/util/reference_serializer.rb
+++ b/spec/unit/util/reference_serializer.rb
@@ -14,7 +14,7 @@ describe Puppet::Util::ReferenceSerializer do
describe "when serializing" do
it "should yaml-dump resource references" do
- ref = Puppet::Parser::Resource::Reference.new(:type => "file", :title => "/foo")
+ ref = Puppet::Resource.new("file", "/foo")
@tester.serialize_value(ref).should =~ /^---/
end