summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorPaul Berry <paul@puppetlabs.com>2010-11-10 16:05:15 -0800
committerPaul Berry <paul@puppetlabs.com>2010-11-10 16:06:04 -0800
commit2b8e834fcbc548a221b4cd02ee7200fa4f6c2c78 (patch)
treed7c11657d0bfd44488b235c95819f62f7431b949 /spec/unit
parent7236a33d6c5c9fbb0f46ffd7826965dbaae6a39b (diff)
parent275a224ee245577c4213b3a21bf1e98301740a4e (diff)
downloadpuppet-2b8e834fcbc548a221b4cd02ee7200fa4f6c2c78.tar.gz
puppet-2b8e834fcbc548a221b4cd02ee7200fa4f6c2c78.tar.xz
puppet-2b8e834fcbc548a221b4cd02ee7200fa4f6c2c78.zip
Merge branch 'next'
This marks the end of the agile iteration from 11/3-11/10.
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/application/agent_spec.rb41
-rwxr-xr-xspec/unit/parser/ast/resource_spec.rb238
-rwxr-xr-xspec/unit/parser/compiler_spec.rb16
-rwxr-xr-xspec/unit/parser/lexer_spec.rb1
-rwxr-xr-xspec/unit/resource/type_spec.rb26
-rwxr-xr-xspec/unit/type/service_spec.rb4
-rwxr-xr-xspec/unit/type/tidy_spec.rb3
7 files changed, 191 insertions, 138 deletions
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index 54726c185..8fc98b8c1 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -6,6 +6,7 @@ require 'puppet/agent'
require 'puppet/application/agent'
require 'puppet/network/server'
require 'puppet/daemon'
+require 'puppet/network/handler'
describe Puppet::Application::Agent do
before :each do
@@ -13,6 +14,7 @@ describe Puppet::Application::Agent do
@puppetd.stubs(:puts)
@daemon = stub_everything 'daemon'
Puppet::Daemon.stubs(:new).returns(@daemon)
+ Puppet[:daemonize] = false
@agent = stub_everything 'agent'
Puppet::Agent.stubs(:new).returns(@agent)
@puppetd.preinit
@@ -175,11 +177,7 @@ describe Puppet::Application::Agent do
@puppetd.options.stubs(:[])
Puppet.stubs(:info)
FileTest.stubs(:exists?).returns(true)
- Puppet.stubs(:[])
- Puppet.stubs(:[]=)
- Puppet.stubs(:[]).with(:libdir).returns("/dev/null/lib")
- Puppet.settings.stubs(:print_config?)
- Puppet.settings.stubs(:print_config)
+ Puppet[:libdir] = "/dev/null/lib"
Puppet::SSL::Host.stubs(:ca_location=)
Puppet::Transaction::Report.stubs(:terminus_class=)
Puppet::Resource::Catalog.stubs(:terminus_class=)
@@ -192,7 +190,7 @@ describe Puppet::Application::Agent do
describe "with --test" do
before :each do
- Puppet.settings.stubs(:handlearg)
+ #Puppet.settings.stubs(:handlearg)
@puppetd.options.stubs(:[]=)
end
@@ -207,8 +205,9 @@ describe Puppet::Application::Agent do
@puppetd.setup_test
end
it "should set options[:onetime] to true" do
- Puppet.expects(:[]=).with(:onetime,true)
+ Puppet[:onetime] = false
@puppetd.setup_test
+ Puppet[:onetime].should == true
end
it "should set options[:detailed_exitcodes] to true" do
@puppetd.options.expects(:[]=).with(:detailed_exitcodes,true)
@@ -264,7 +263,7 @@ describe Puppet::Application::Agent do
it "should print puppet config if asked to in Puppet config" do
@puppetd.stubs(:exit)
- Puppet.settings.stubs(:print_configs?).returns(true)
+ Puppet[:configprint] = "pluginsync"
Puppet.settings.expects(:print_configs)
@@ -272,14 +271,14 @@ describe Puppet::Application::Agent do
end
it "should exit after printing puppet config if asked to in Puppet config" do
- Puppet.settings.stubs(:print_configs?).returns(true)
+ Puppet[:configprint] = "pluginsync"
lambda { @puppetd.setup }.should raise_error(SystemExit)
end
it "should set a central log destination with --centrallogs" do
@puppetd.options.stubs(:[]).with(:centrallogs).returns(true)
- Puppet.stubs(:[]).with(:server).returns("puppet.reductivelabs.com")
+ Puppet[:server] = "puppet.reductivelabs.com"
Puppet::Util::Log.stubs(:newdestination).with(:syslog)
Puppet::Util::Log.expects(:newdestination).with("puppet.reductivelabs.com")
@@ -313,8 +312,9 @@ describe Puppet::Application::Agent do
end
it "should change the catalog_terminus setting to 'rest'" do
- Puppet.expects(:[]=).with(:catalog_terminus, :rest)
+ Puppet[:catalog_terminus] = :foo
@puppetd.setup
+ Puppet[:catalog_terminus].should == :rest
end
it "should tell the catalog handler to use cache" do
@@ -324,9 +324,10 @@ describe Puppet::Application::Agent do
end
it "should change the facts_terminus setting to 'facter'" do
- Puppet.expects(:[]=).with(:facts_terminus, :facter)
+ Puppet[:facts_terminus] = :foo
@puppetd.setup
+ Puppet[:facts_terminus].should == :facter
end
it "should create an agent" do
@@ -374,7 +375,7 @@ describe Puppet::Application::Agent do
end
it "should daemonize if needed" do
- Puppet.stubs(:[]).with(:daemonize).returns(true)
+ Puppet[:daemonize] = true
@daemon.expects(:daemonize)
@@ -397,7 +398,7 @@ describe Puppet::Application::Agent do
end
it "should setup listen if told to and not onetime" do
- Puppet.stubs(:[]).with(:listen).returns(true)
+ Puppet[:listen] = true
@puppetd.options.stubs(:[]).with(:onetime).returns(false)
@puppetd.expects(:setup_listen)
@@ -407,7 +408,7 @@ describe Puppet::Application::Agent do
describe "when setting up listen" do
before :each do
- Puppet.stubs(:[]).with(:authconfig).returns('auth')
+ Puppet[:authconfig] = 'auth'
FileTest.stubs(:exists?).with('auth').returns(true)
File.stubs(:exist?).returns(true)
@puppetd.options.stubs(:[]).with(:serve).returns([])
@@ -419,7 +420,7 @@ describe Puppet::Application::Agent do
it "should exit if no authorization file" do
Puppet.stubs(:err)
- FileTest.stubs(:exists?).with('auth').returns(false)
+ FileTest.stubs(:exists?).with(Puppet[:authconfig]).returns(false)
@puppetd.expects(:exit)
@@ -440,9 +441,9 @@ describe Puppet::Application::Agent do
end
it "should use puppet default port" do
- Puppet.stubs(:[]).with(:puppetport).returns(:port)
+ Puppet[:puppetport] = 32768
- Puppet::Network::Server.expects(:new).with { |args| args[:port] == :port }
+ Puppet::Network::Server.expects(:new).with { |args| args[:port] == 32768 }
@puppetd.setup_listen
end
@@ -521,7 +522,7 @@ describe Puppet::Application::Agent do
end
it "should exit with report's computed exit status" do
- Puppet.stubs(:[]).with(:noop).returns(false)
+ Puppet[:noop] = false
report = stub 'report', :exit_status => 666
@agent.stubs(:run).returns(report)
@puppetd.expects(:exit).with(666)
@@ -530,7 +531,7 @@ describe Puppet::Application::Agent do
end
it "should always exit with 0 if --noop" do
- Puppet.stubs(:[]).with(:noop).returns(true)
+ Puppet[:noop] = true
report = stub 'report', :exit_status => 666
@agent.stubs(:run).returns(report)
@puppetd.expects(:exit).with(0)
diff --git a/spec/unit/parser/ast/resource_spec.rb b/spec/unit/parser/ast/resource_spec.rb
index a8e783256..3ed7b3e08 100755
--- a/spec/unit/parser/ast/resource_spec.rb
+++ b/spec/unit/parser/ast/resource_spec.rb
@@ -5,134 +5,180 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
describe Puppet::Parser::AST::Resource do
ast = Puppet::Parser::AST
- before :each do
- @title = Puppet::Parser::AST::String.new(:value => "mytitle")
- @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
- @scope = Puppet::Parser::Scope.new(:compiler => @compiler)
- @scope.stubs(:resource).returns(stub_everything)
- @instance = ast::ResourceInstance.new(:title => @title, :parameters => ast::ASTArray.new(:children => []))
- @resource = ast::Resource.new(:type => "file", :instances => ast::ASTArray.new(:children => [@instance]))
- @resource.stubs(:qualified_type).returns("Resource")
- end
+ describe "for builtin types" do
+ before :each do
+ @title = Puppet::Parser::AST::String.new(:value => "mytitle")
+ @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
+ @scope = Puppet::Parser::Scope.new(:compiler => @compiler)
+ @scope.stubs(:resource).returns(stub_everything)
+ @instance = ast::ResourceInstance.new(:title => @title, :parameters => ast::ASTArray.new(:children => []))
+ @resource = ast::Resource.new(:type => "file", :instances => ast::ASTArray.new(:children => [@instance]))
+ @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"))
- @instance.stubs(:parameters).returns [param]
+ 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"))
+ @instance.stubs(:parameters).returns [param]
- @resource.evaluate(@scope)
- end
+ @resource.evaluate(@scope)
+ end
- it "should evaluate its title" do
- @resource.evaluate(@scope)[0].title.should == "mytitle"
- end
+ it "should evaluate its title" do
+ @resource.evaluate(@scope)[0].title.should == "mytitle"
+ end
+
+ it "should flatten the titles array" do
+ titles = []
+ %w{one two}.each do |title|
+ titles << Puppet::Parser::AST::String.new(:value => title)
+ end
- it "should flatten the titles array" do
- titles = []
- %w{one two}.each do |title|
- titles << Puppet::Parser::AST::String.new(:value => title)
+ array = Puppet::Parser::AST::ASTArray.new(:children => titles)
+
+ @instance.title = array
+ result = @resource.evaluate(@scope).collect { |r| r.title }
+ result.should be_include("one")
+ result.should be_include("two")
end
- array = Puppet::Parser::AST::ASTArray.new(:children => titles)
+ it "should create and return one resource objects per title" do
+ titles = []
+ %w{one two}.each do |title|
+ titles << Puppet::Parser::AST::String.new(:value => title)
+ end
- @instance.title = array
- result = @resource.evaluate(@scope).collect { |r| r.title }
- result.should be_include("one")
- result.should be_include("two")
- end
+ array = Puppet::Parser::AST::ASTArray.new(:children => titles)
- it "should create and return one resource objects per title" do
- titles = []
- %w{one two}.each do |title|
- titles << Puppet::Parser::AST::String.new(:value => title)
+ @instance.title = array
+ result = @resource.evaluate(@scope).collect { |r| r.title }
+ result.should be_include("one")
+ result.should be_include("two")
end
- array = Puppet::Parser::AST::ASTArray.new(:children => titles)
+ it "should implicitly iterate over instances" do
+ new_title = Puppet::Parser::AST::String.new(:value => "other_title")
+ new_instance = ast::ResourceInstance.new(:title => new_title, :parameters => ast::ASTArray.new(:children => []))
+ @resource.instances.push(new_instance)
+ @resource.evaluate(@scope).collect { |r| r.title }.should == ["mytitle", "other_title"]
+ end
- @instance.title = array
- result = @resource.evaluate(@scope).collect { |r| r.title }
- result.should be_include("one")
- result.should be_include("two")
- end
+ it "should handover resources to the compiler" do
+ titles = []
+ %w{one two}.each do |title|
+ titles << Puppet::Parser::AST::String.new(:value => title)
+ end
- it "should implicitly iterate over instances" do
- new_title = Puppet::Parser::AST::String.new(:value => "other_title")
- new_instance = ast::ResourceInstance.new(:title => new_title, :parameters => ast::ASTArray.new(:children => []))
- @resource.instances.push(new_instance)
- @resource.evaluate(@scope).collect { |r| r.title }.should == ["mytitle", "other_title"]
- end
+ array = Puppet::Parser::AST::ASTArray.new(:children => titles)
- it "should handover resources to the compiler" do
- titles = []
- %w{one two}.each do |title|
- titles << Puppet::Parser::AST::String.new(:value => title)
+ @instance.title = array
+ result = @resource.evaluate(@scope)
+
+ result.each do |res|
+ @compiler.catalog.resource(res.ref).should be_instance_of(Puppet::Parser::Resource)
+ end
end
- array = Puppet::Parser::AST::ASTArray.new(:children => titles)
+ it "should generate virtual resources if it is virtual" do
+ @resource.virtual = true
+
+ result = @resource.evaluate(@scope)
+ result[0].should be_virtual
+ end
- @instance.title = array
- result = @resource.evaluate(@scope)
+ it "should generate virtual and exported resources if it is exported" do
+ @resource.exported = true
- result.each do |res|
- @compiler.catalog.resource(res.ref).should be_instance_of(Puppet::Parser::Resource)
+ result = @resource.evaluate(@scope)
+ result[0].should be_virtual
+ result[0].should be_exported
end
- end
- it "should generate virtual resources if it is virtual" do
- @resource.virtual = true
- result = @resource.evaluate(@scope)
- result[0].should be_virtual
- end
+ # Related to #806, make sure resources always look up the full path to the resource.
+ describe "when generating qualified resources" do
+ before do
+ @scope = Puppet::Parser::Scope.new :compiler => Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
+ @parser = Puppet::Parser::Parser.new(Puppet::Node::Environment.new)
+ ["one", "one::two", "three"].each do |name|
+ @parser.environment.known_resource_types.add(Puppet::Resource::Type.new(:definition, name, {}))
+ end
+ @twoscope = @scope.newscope(:namespace => "one")
+ @twoscope.resource = @scope.resource
+ end
- it "should generate virtual and exported resources if it is exported" do
- @resource.exported = true
+ def resource(type, params = nil)
+ params ||= Puppet::Parser::AST::ASTArray.new(:children => [])
+ instance = Puppet::Parser::AST::ResourceInstance.new(
+ :title => Puppet::Parser::AST::String.new(:value => "myresource"), :parameters => params)
+ Puppet::Parser::AST::Resource.new(:type => type,
+ :instances => Puppet::Parser::AST::ASTArray.new(:children => [instance]))
+ end
- result = @resource.evaluate(@scope)
- result[0].should be_virtual
- result[0].should be_exported
- end
+ it "should be able to generate resources with fully qualified type information" do
+ resource("two").evaluate(@twoscope)[0].type.should == "One::Two"
+ end
- # Related to #806, make sure resources always look up the full path to the resource.
- describe "when generating qualified resources" do
- before do
- @scope = Puppet::Parser::Scope.new :compiler => Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
- @parser = Puppet::Parser::Parser.new(Puppet::Node::Environment.new)
- ["one", "one::two", "three"].each do |name|
- @parser.environment.known_resource_types.add(Puppet::Resource::Type.new(:definition, name, {}))
+ it "should be able to generate resources with unqualified type information" do
+ resource("one").evaluate(@twoscope)[0].type.should == "One"
end
- @twoscope = @scope.newscope(:namespace => "one")
- @twoscope.resource = @scope.resource
- end
- def resource(type, params = nil)
- params ||= Puppet::Parser::AST::ASTArray.new(:children => [])
- instance = Puppet::Parser::AST::ResourceInstance.new(
- :title => Puppet::Parser::AST::String.new(:value => "myresource"), :parameters => params)
- Puppet::Parser::AST::Resource.new(:type => type,
- :instances => Puppet::Parser::AST::ASTArray.new(:children => [instance]))
- end
+ it "should correctly generate resources that can look up builtin types" do
+ resource("file").evaluate(@twoscope)[0].type.should == "File"
+ end
- it "should be able to generate resources with fully qualified type information" do
- resource("two").evaluate(@twoscope)[0].type.should == "One::Two"
- end
+ it "should correctly generate resources that can look up defined classes by title" do
+ @scope.known_resource_types.add_hostclass Puppet::Resource::Type.new(:hostclass, "Myresource", {})
+ @scope.compiler.stubs(:evaluate_classes)
+ res = resource("class").evaluate(@twoscope)[0]
+ res.type.should == "Class"
+ res.title.should == "Myresource"
+ end
- it "should be able to generate resources with unqualified type information" do
- resource("one").evaluate(@twoscope)[0].type.should == "One"
+ it "should evaluate parameterized classes when they are instantiated" do
+ @scope.known_resource_types.add_hostclass Puppet::Resource::Type.new(:hostclass, "Myresource", {})
+ @scope.compiler.expects(:evaluate_classes).with(['myresource'],@twoscope,false)
+ resource("class").evaluate(@twoscope)[0]
+ end
+
+ it "should fail for resource types that do not exist" do
+ lambda { resource("nosuchtype").evaluate(@twoscope) }.should raise_error(Puppet::ParseError)
+ end
end
+ end
- it "should correctly generate resources that can look up builtin types" do
- resource("file").evaluate(@twoscope)[0].type.should == "File"
+ describe "for class resources" do
+ before do
+ @title = Puppet::Parser::AST::String.new(:value => "classname")
+ @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
+ @scope = Puppet::Parser::Scope.new(:compiler => @compiler)
+ @scope.stubs(:resource).returns(stub_everything)
+ @instance = ast::ResourceInstance.new(:title => @title, :parameters => ast::ASTArray.new(:children => []))
+ @resource = ast::Resource.new(:type => "Class", :instances => ast::ASTArray.new(:children => [@instance]))
+ @resource.stubs(:qualified_type).returns("Resource")
+ @type = Puppet::Resource::Type.new(:hostclass, "classname")
+ @compiler.known_resource_types.add(@type)
end
- it "should correctly generate resources that can look up defined classes by title" do
- @scope.known_resource_types.add_hostclass Puppet::Resource::Type.new(:hostclass, "Myresource", {})
- res = resource("class").evaluate(@twoscope)[0]
- res.type.should == "Class"
- res.title.should == "Myresource"
+ it "should instantiate the class" do
+ @compiler.stubs(:evaluate_classes)
+ result = @resource.evaluate(@scope)
+ result.length.should == 1
+ result.first.ref.should == "Class[Classname]"
+ @compiler.catalog.resource("Class[Classname]").should equal result.first
end
- it "should fail for resource types that do not exist" do
- lambda { resource("nosuchtype").evaluate(@twoscope) }.should raise_error(Puppet::ParseError)
+ it "should cause its parent to be evaluated" do
+ parent_type = Puppet::Resource::Type.new(:hostclass, "parentname")
+ @compiler.stubs(:evaluate_classes)
+ @compiler.known_resource_types.add(parent_type)
+ @type.parent = "parentname"
+ result = @resource.evaluate(@scope)
+ result.length.should == 1
+ result.first.ref.should == "Class[Classname]"
+ @compiler.catalog.resource("Class[Classname]").should equal result.first
+ @compiler.catalog.resource("Class[Parentname]").should be_instance_of(Puppet::Parser::Resource)
end
+
end
+
end
diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb
index 22d52f257..95f3853e2 100755
--- a/spec/unit/parser/compiler_spec.rb
+++ b/spec/unit/parser/compiler_spec.rb
@@ -580,7 +580,7 @@ describe Puppet::Parser::Compiler do
it "should evaluate each class" do
@compiler.catalog.stubs(:tag)
- @class.expects(:mk_plain_resource).with(@scope)
+ @class.expects(:ensure_in_catalog).with(@scope)
@scope.stubs(:class_scope).with(@class)
@compiler.evaluate_classes(%w{myclass}, @scope)
@@ -591,7 +591,7 @@ describe Puppet::Parser::Compiler do
@resource.expects(:evaluate).never
- @class.expects(:mk_plain_resource).returns(@resource)
+ @class.expects(:ensure_in_catalog).returns(@resource)
@scope.stubs(:class_scope).with(@class)
@compiler.evaluate_classes(%w{myclass}, @scope)
@@ -601,7 +601,7 @@ describe Puppet::Parser::Compiler do
@compiler.catalog.stubs(:tag)
@resource.expects(:evaluate)
- @class.expects(:mk_plain_resource).returns(@resource)
+ @class.expects(:ensure_in_catalog).returns(@resource)
@scope.stubs(:class_scope).with(@class)
@compiler.evaluate_classes(%w{myclass}, @scope, false)
@@ -638,7 +638,7 @@ describe Puppet::Parser::Compiler do
@scope.stubs(:class_scope).with(@class)
Puppet::Parser::Resource.stubs(:new).returns(@resource)
- @class.stubs :mk_plain_resource
+ @class.stubs :ensure_in_catalog
@compiler.evaluate_classes(%w{myclass notfound}, @scope).should == %w{myclass}
end
end
@@ -678,7 +678,7 @@ describe Puppet::Parser::Compiler do
@compiler.known_resource_types.stubs(:node).with("c").returns(node_class)
node_resource = stub 'node resource', :ref => "Node[c]", :evaluate => nil, :type => "node"
- node_class.expects(:mk_plain_resource).returns(node_resource)
+ node_class.expects(:ensure_in_catalog).returns(node_resource)
@compiler.compile
end
@@ -688,7 +688,7 @@ describe Puppet::Parser::Compiler do
@compiler.known_resource_types.stubs(:node).with("default").returns(node_class)
node_resource = stub 'node resource', :ref => "Node[default]", :evaluate => nil, :type => "node"
- node_class.expects(:mk_plain_resource).returns(node_resource)
+ node_class.expects(:ensure_in_catalog).returns(node_resource)
@compiler.compile
end
@@ -698,7 +698,7 @@ describe Puppet::Parser::Compiler do
@compiler.known_resource_types.stubs(:node).with("c").returns(node_class)
node_resource = stub 'node resource', :ref => "Node[c]", :type => "node"
- node_class.expects(:mk_plain_resource).returns(node_resource)
+ node_class.expects(:ensure_in_catalog).returns(node_resource)
node_resource.expects(:evaluate)
@@ -707,7 +707,7 @@ describe Puppet::Parser::Compiler do
it "should set the node's scope as the top scope" do
node_resource = stub 'node resource', :ref => "Node[c]", :evaluate => nil, :type => "node"
- node_class = stub 'node', :name => "c", :mk_plain_resource => node_resource
+ node_class = stub 'node', :name => "c", :ensure_in_catalog => node_resource
@compiler.known_resource_types.stubs(:node).with("c").returns(node_class)
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb
index 2d67bf357..d52add399 100755
--- a/spec/unit/parser/lexer_spec.rb
+++ b/spec/unit/parser/lexer_spec.rb
@@ -424,6 +424,7 @@ describe Puppet::Parser::Lexer,"when lexing strings" do
%q{'single quoted string with an escaped "\\\\"'} => [[:STRING,'single quoted string with an escaped "\\\\"']],
%q{"string with an escaped '\\"'"} => [[:STRING,"string with an escaped '\"'"]],
%q{"string with an escaped '\\$'"} => [[:STRING,"string with an escaped '$'"]],
+ %Q{"string with a line ending with a backslash: \\\nfoo"} => [[:STRING,"string with a line ending with a backslash: foo"]],
%q{"string with $v (but no braces)"} => [[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' (but no braces)']],
%q["string with ${v} in braces"] => [[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' in braces']],
%q["string with ${qualified::var} in braces"] => [[:DQPRE,"string with "],[:VARIABLE,'qualified::var'],[:DQPOST,' in braces']],
diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb
index 7701e55d5..ef45712e6 100755
--- a/spec/unit/resource/type_spec.rb
+++ b/spec/unit/resource/type_spec.rb
@@ -579,29 +579,29 @@ describe Puppet::Resource::Type do
end
it "should create a resource instance" do
- @top.mk_plain_resource(@scope).should be_instance_of(Puppet::Parser::Resource)
+ @top.ensure_in_catalog(@scope).should be_instance_of(Puppet::Parser::Resource)
end
it "should set its resource type to 'class' when it is a hostclass" do
- Puppet::Resource::Type.new(:hostclass, "top").mk_plain_resource(@scope).type.should == "Class"
+ Puppet::Resource::Type.new(:hostclass, "top").ensure_in_catalog(@scope).type.should == "Class"
end
it "should set its resource type to 'node' when it is a node" do
- Puppet::Resource::Type.new(:node, "top").mk_plain_resource(@scope).type.should == "Node"
+ Puppet::Resource::Type.new(:node, "top").ensure_in_catalog(@scope).type.should == "Node"
end
it "should fail when it is a definition" do
- lambda { Puppet::Resource::Type.new(:definition, "top").mk_plain_resource(@scope) }.should raise_error(ArgumentError)
+ lambda { Puppet::Resource::Type.new(:definition, "top").ensure_in_catalog(@scope) }.should raise_error(ArgumentError)
end
it "should add the created resource to the scope's catalog" do
- @top.mk_plain_resource(@scope)
+ @top.ensure_in_catalog(@scope)
@compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
end
it "should evaluate the parent class if one exists" do
- @middle.mk_plain_resource(@scope)
+ @middle.ensure_in_catalog(@scope)
@compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
end
@@ -609,40 +609,40 @@ describe Puppet::Resource::Type do
it "should fail to evaluate if a parent class is defined but cannot be found" do
othertop = Puppet::Resource::Type.new :hostclass, "something", :parent => "yay"
@code.add othertop
- lambda { othertop.mk_plain_resource(@scope) }.should raise_error(Puppet::ParseError)
+ lambda { othertop.ensure_in_catalog(@scope) }.should raise_error(Puppet::ParseError)
end
it "should not create a new resource if one already exists" do
@compiler.catalog.expects(:resource).with(:class, "top").returns("something")
@compiler.catalog.expects(:add_resource).never
- @top.mk_plain_resource(@scope)
+ @top.ensure_in_catalog(@scope)
end
it "should return the existing resource when not creating a new one" do
@compiler.catalog.expects(:resource).with(:class, "top").returns("something")
@compiler.catalog.expects(:add_resource).never
- @top.mk_plain_resource(@scope).should == "something"
+ @top.ensure_in_catalog(@scope).should == "something"
end
it "should not create a new parent resource if one already exists and it has a parent class" do
- @top.mk_plain_resource(@scope)
+ @top.ensure_in_catalog(@scope)
top_resource = @compiler.catalog.resource(:class, "top")
- @middle.mk_plain_resource(@scope)
+ @middle.ensure_in_catalog(@scope)
@compiler.catalog.resource(:class, "top").should equal(top_resource)
end
# #795 - tag before evaluation.
it "should tag the catalog with the resource tags when it is evaluated" do
- @middle.mk_plain_resource(@scope)
+ @middle.ensure_in_catalog(@scope)
@compiler.catalog.should be_tagged("middle")
end
it "should tag the catalog with the parent class tags when it is evaluated" do
- @middle.mk_plain_resource(@scope)
+ @middle.ensure_in_catalog(@scope)
@compiler.catalog.should be_tagged("top")
end
diff --git a/spec/unit/type/service_spec.rb b/spec/unit/type/service_spec.rb
index 0958a69fa..77628670a 100755
--- a/spec/unit/type/service_spec.rb
+++ b/spec/unit/type/service_spec.rb
@@ -66,6 +66,10 @@ describe Puppet::Type.type(:service), "when validating attribute values" do
Puppet::Type.type(:service).new(:name => "yay", :hasstatus => :false)
end
+ it "should specify :true as the default value of hasstatus" do
+ Puppet::Type.type(:service).new(:name => "yay")[:hasstatus].should == :true
+ end
+
it "should support :true as a value to :hasrestart" do
Puppet::Type.type(:service).new(:name => "yay", :hasrestart => :true)
end
diff --git a/spec/unit/type/tidy_spec.rb b/spec/unit/type/tidy_spec.rb
index 11edbfbf3..1573ead1b 100755
--- a/spec/unit/type/tidy_spec.rb
+++ b/spec/unit/type/tidy_spec.rb
@@ -110,7 +110,8 @@ describe tidy do
:b => 0,
:kb => 1,
:mb => 2,
- :gb => 3
+ :gb => 3,
+ :tb => 4
}
convertors.each do |unit, multiple|