summaryrefslogtreecommitdiffstats
path: root/spec/unit/util
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-11-03 19:58:38 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-11-03 19:59:37 -0700
commit9e2a0e41dfb253a19180aeea6b66f65ca8d63133 (patch)
treef102b396669c074b59eab5c2e59c5145b5bae6ab /spec/unit/util
parentb1ef091d0209a59ac747568f83416e992db93ea8 (diff)
parent85543a41978924a42490d0c3f1f5437c95b7c869 (diff)
Merge commit '85543a4'
This updates `master` to the pre-agile-iteration state.
Diffstat (limited to 'spec/unit/util')
-rwxr-xr-xspec/unit/util/rdoc/parser_spec.rb22
-rwxr-xr-xspec/unit/util/zaml_spec.rb25
2 files changed, 39 insertions, 8 deletions
diff --git a/spec/unit/util/rdoc/parser_spec.rb b/spec/unit/util/rdoc/parser_spec.rb
index 28c33c295..04713f293 100755
--- a/spec/unit/util/rdoc/parser_spec.rb
+++ b/spec/unit/util/rdoc/parser_spec.rb
@@ -20,7 +20,7 @@ describe RDoc::Parser do
@parser.stubs(:scan_top_level)
parser = stub 'parser'
Puppet::Parser::Parser.stubs(:new).returns(parser)
- parser.expects(:parse)
+ parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new(''))
parser.expects(:file=).with("module/manifests/init.pp")
@parser.scan
@@ -29,6 +29,7 @@ describe RDoc::Parser do
it "should scan the ast for Puppet files" do
parser = stub_everything 'parser'
Puppet::Parser::Parser.stubs(:new).returns(parser)
+ parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new(''))
@parser.expects(:scan_top_level)
@@ -38,6 +39,7 @@ describe RDoc::Parser do
it "should return a PuppetTopLevel to RDoc" do
parser = stub_everything 'parser'
Puppet::Parser::Parser.stubs(:new).returns(parser)
+ parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new(''))
@parser.expects(:scan_top_level)
@@ -47,8 +49,8 @@ describe RDoc::Parser do
describe "when scanning top level entities" do
before :each do
- @resource_type_collection = stub_everything 'resource_type_collection'
- @parser.ast = @resource_type_collection
+ @resource_type_collection = resource_type_collection = stub_everything('resource_type_collection')
+ @parser.instance_eval { @known_resource_types = resource_type_collection }
@parser.stubs(:split_module).returns("module")
@topcontainer = stub_everything 'topcontainer'
@@ -141,8 +143,8 @@ describe RDoc::Parser do
@definition = stub_everything 'definition', :file => "module/manifests/init.pp", :type => :definition, :name => "mydef"
@node = stub_everything 'node', :file => "module/manifests/init.pp", :type => :node, :name => "mynode"
- @resource_type_collection = Puppet::Resource::TypeCollection.new("env")
- @parser.ast = @resource_type_collection
+ @resource_type_collection = resource_type_collection = Puppet::Resource::TypeCollection.new("env")
+ @parser.instance_eval { @known_resource_types = resource_type_collection }
@container = stub_everything 'container'
end
@@ -437,9 +439,13 @@ describe RDoc::Parser do
@class = stub_everything 'class'
@stmt = Puppet::Parser::AST::Resource.new(
:type => "File",
- :title => "myfile",
- :doc => 'mydoc',
- :parameters => Puppet::Parser::AST::ASTArray.new(:children => [])
+ :instances => Puppet::Parser::AST::ASTArray.new(:children => [
+ Puppet::Parser::AST::ResourceInstance.new(
+ :title => Puppet::Parser::AST::Name.new(:value => "myfile"),
+ :parameters => Puppet::Parser::AST::ASTArray.new(:children => [])
+ )
+ ]),
+ :doc => 'mydoc'
)
@code = stub_everything 'code'
diff --git a/spec/unit/util/zaml_spec.rb b/spec/unit/util/zaml_spec.rb
index f2bcefe01..b223f89d4 100755
--- a/spec/unit/util/zaml_spec.rb
+++ b/spec/unit/util/zaml_spec.rb
@@ -35,5 +35,30 @@ describe "Pure ruby yaml implementation" do
lambda { YAML.load(o.to_yaml) }.should_not raise_error
end
}
+
+ it "should emit proper labels and backreferences for common objects" do
+ # Note: this test makes assumptions about the names ZAML chooses
+ # for labels.
+ x = [1, 2]
+ y = [3, 4]
+ z = [x, y, x, y]
+ z.to_yaml.should == "--- \n - &id001\n - 1\n - 2\n - &id002\n - 3\n - 4\n - *id001\n - *id002"
+ z2 = YAML.load(z.to_yaml)
+ z2.should == z
+ z2[0].should equal(z2[2])
+ z2[1].should equal(z2[3])
+ end
+
+ it "should emit proper labels and backreferences for recursive objects" do
+ x = [1, 2]
+ x << x
+ x.to_yaml.should == "--- &id001\n \n - 1\n - 2\n - *id001"
+ x2 = YAML.load(x.to_yaml)
+ x2.should be_a(Array)
+ x2.length.should == 3
+ x2[0].should == 1
+ x2[1].should == 2
+ x2[2].should equal(x2)
+ end
end