diff options
| author | Luke Kanies <luke@puppetlabs.com> | 2011-07-05 16:32:03 -0700 |
|---|---|---|
| committer | Luke Kanies <luke@puppetlabs.com> | 2011-07-15 11:52:41 -0700 |
| commit | bdc0f8716ae8ccb2b2657dfab591afe9589d8902 (patch) | |
| tree | 6f6b25251f0a581c878b833a90e5b3bab0ac5d11 /spec | |
| parent | 9662045bfe551821823b38fe6511e621998aef0b (diff) | |
| download | puppet-bdc0f8716ae8ccb2b2657dfab591afe9589d8902.tar.gz puppet-bdc0f8716ae8ccb2b2657dfab591afe9589d8902.tar.xz puppet-bdc0f8716ae8ccb2b2657dfab591afe9589d8902.zip | |
Scope[] now returns nil for undefined variables
Given that we have the 'include?' method, this feature
is unnecessary, and it makes sense to convert to more
ruby-like behavior.
Any code that previously checked whether lookupvar
(or the new []) returned :undefined should now check
whether 'scope.include?(var)'. Thus, you can have
the same behavior, but it takes a bit different code
to get it.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/parser/scope_spec.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb index d3ea8dfa8..3c0d15cd7 100755 --- a/spec/unit/parser/scope_spec.rb +++ b/spec/unit/parser/scope_spec.rb @@ -88,8 +88,8 @@ describe Puppet::Parser::Scope do @scope.lookupvar("var").should == "yep" end - it "should return ':undefined' for unset variables" do - @scope["var"].should == :undefined + it "should return nil for unset variables" do + @scope["var"].should be_nil end it "should be able to look up values" do @@ -180,32 +180,32 @@ describe Puppet::Parser::Scope do @scope["other::deep::klass::var"].should == "otherval" end - it "should return ':undefined' for qualified variables that cannot be found in other classes" do + it "should return nil for qualified variables that cannot be found in other classes" do other_scope = create_class_scope("other::deep::klass") - @scope["other::deep::klass::var"].should == :undefined + @scope["other::deep::klass::var"].should be_nil end - it "should warn and return ':undefined' for qualified variables whose classes have not been evaluated" do + it "should warn and return nil for qualified variables whose classes have not been evaluated" do klass = newclass("other::deep::klass") @scope.expects(:warning) - @scope["other::deep::klass::var"].should == :undefined + @scope["other::deep::klass::var"].should be_nil end - it "should warn and return ':undefined' for qualified variables whose classes do not exist" do + it "should warn and return nil for qualified variables whose classes do not exist" do @scope.expects(:warning) - @scope["other::deep::klass::var"].should == :undefined + @scope["other::deep::klass::var"].should be_nil end - it "should return ':undefined' when asked for a non-string qualified variable from a class that does not exist" do + it "should return nil when asked for a non-string qualified variable from a class that does not exist" do @scope.stubs(:warning) - @scope["other::deep::klass::var"].should == :undefined + @scope["other::deep::klass::var"].should be_nil end - it "should return ':undefined' when asked for a non-string qualified variable from a class that has not been evaluated" do + it "should return nil when asked for a non-string qualified variable from a class that has not been evaluated" do @scope.stubs(:warning) klass = newclass("other::deep::klass") - @scope["other::deep::klass::var"].should == :undefined + @scope["other::deep::klass::var"].should be_nil end end end @@ -320,7 +320,7 @@ describe Puppet::Parser::Scope do @scope.unset_ephemeral_var - @scope["1"].should == :undefined + @scope["1"].should be_nil end it "should not remove classic variables when unset_ephemeral_var is called" do @@ -393,7 +393,7 @@ describe Puppet::Parser::Scope do @scope.unset_ephemeral_var - @scope["1"].should == :undefined + @scope["1"].should be_nil end end @@ -449,13 +449,13 @@ describe Puppet::Parser::Scope do it "should be able to unset normal variables" do @scope["foo"] = "bar" @scope.unsetvar("foo") - @scope["foo"].should == :undefined + @scope["foo"].should be_nil end it "should be able to unset ephemeral variables" do @scope.setvar("0", "bar", :ephemeral => true) @scope.unsetvar("0") - @scope["0"].should == :undefined + @scope["0"].should be_nil end it "should not unset ephemeral variables in previous ephemeral scope" do |
