diff options
author | Jacob Helwig <jacob@puppetlabs.com> | 2011-04-15 09:52:56 -0700 |
---|---|---|
committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-04-19 11:03:40 -0700 |
commit | 656eff821bec534a23e3e81e86ddbe3fc28f10ed (patch) | |
tree | c38ace649b9488a40d46dc3db07b9bc9eb790ab8 /spec/unit/parser/compiler_spec.rb | |
parent | bee1ef73e5c83541edcf1249f062ba832618da48 (diff) | |
download | puppet-656eff821bec534a23e3e81e86ddbe3fc28f10ed.tar.gz puppet-656eff821bec534a23e3e81e86ddbe3fc28f10ed.tar.xz puppet-656eff821bec534a23e3e81e86ddbe3fc28f10ed.zip |
(#4655) Allow stage to be set using a default class parameter
For example:
stage{ pre: before => Stage[main] }
class someclass ($stage=pre ) { ... }
class { someclass: }
This transplants adding the edge from the resource to the stage from
the compiler into when the resource is evaluated. This moves adding
the stage edges to after when the defaults are copied into the
resources, making them available.
Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
Diffstat (limited to 'spec/unit/parser/compiler_spec.rb')
-rwxr-xr-x | spec/unit/parser/compiler_spec.rb | 54 |
1 files changed, 8 insertions, 46 deletions
diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb index 261cfdec1..4cab3cb65 100755 --- a/spec/unit/parser/compiler_spec.rb +++ b/spec/unit/parser/compiler_spec.rb @@ -33,6 +33,14 @@ class CompilerTestResource def evaluate end + + def file + "/fake/file/goes/here" + end + + def line + "42" + end end describe Puppet::Parser::Compiler do @@ -418,52 +426,6 @@ describe Puppet::Parser::Compiler do @compiler.catalog.should be_edge(@scope.resource, resource) end - it "should add an edge to any specified stage for class resources" do - other_stage = resource(:stage, "other") - @compiler.add_resource(@scope, other_stage) - resource = resource(:class, "foo") - resource[:stage] = 'other' - - @compiler.add_resource(@scope, resource) - - @compiler.catalog.edge?(other_stage, resource).should be_true - end - - it "should fail if a non-class resource attempts to set a stage" do - other_stage = resource(:stage, "other") - @compiler.add_resource(@scope, other_stage) - resource = resource(:file, "foo") - resource[:stage] = 'other' - - lambda { @compiler.add_resource(@scope, resource) }.should raise_error(ArgumentError) - end - - it "should fail if an unknown stage is specified" do - resource = resource(:class, "foo") - resource[:stage] = 'other' - - lambda { @compiler.add_resource(@scope, resource) }.should raise_error(ArgumentError) - end - - it "should add edges from the class resources to the parent's stage if no stage is specified" do - main = @compiler.catalog.resource(:stage, :main) - foo_stage = resource(:stage, :foo_stage) - @compiler.add_resource(@scope, foo_stage) - resource = resource(:class, "foo") - @scope.stubs(:resource).returns(:stage => :foo_stage) - @compiler.add_resource(@scope, resource) - - @compiler.catalog.should be_edge(foo_stage, resource) - end - - it "should add edges from top-level class resources to the main stage if no stage is specified" do - main = @compiler.catalog.resource(:stage, :main) - resource = resource(:class, "foo") - @compiler.add_resource(@scope, resource) - - @compiler.catalog.should be_edge(main, resource) - end - it "should not add non-class resources that don't specify a stage to the 'main' stage" do main = @compiler.catalog.resource(:stage, :main) resource = resource(:file, "foo") |