~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to spec/unit/type/component.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../../spec_helper'
 
4
 
 
5
component = Puppet::Type.type(:component)
 
6
 
 
7
describe component do
 
8
    it "should have a :name attribute" do
 
9
        component.attrclass(:name).should_not be_nil
 
10
    end
 
11
 
 
12
    it "should use Class as its type when a normal string is provided as the title" do
 
13
        component.new(:name => "bar").ref.should == "Class[bar]"
 
14
    end
 
15
 
 
16
    it "should always produce a resource reference string as its title" do
 
17
        component.new(:name => "bar").title.should == "Class[bar]"
 
18
    end
 
19
 
 
20
    it "should have a reference string equivalent to its title" do
 
21
        comp = component.new(:name => "Foo[bar]")
 
22
        comp.title.should == comp.ref
 
23
    end
 
24
 
 
25
    it "should alias itself to its reference if it has a catalog and the catalog does not already have a resource with the same reference" do
 
26
        catalog = mock 'catalog'
 
27
        catalog.expects(:resource).with("Foo[bar]").returns nil
 
28
 
 
29
        catalog.expects(:alias).with { |resource, name| resource.is_a?(component) and name == "Foo[bar]" }
 
30
 
 
31
        component.new(:name => "Foo[bar]", :catalog => catalog)
 
32
    end
 
33
 
 
34
    it "should not fail when provided an invalid value" do
 
35
        comp = component.new(:name => "Foo[bar]")
 
36
        lambda { comp[:yayness] = "ey" }.should_not raise_error
 
37
    end
 
38
 
 
39
    it "should return previously provided invalid values" do
 
40
        comp = component.new(:name => "Foo[bar]")
 
41
        comp[:yayness] = "eh"
 
42
        comp[:yayness].should == "eh"
 
43
    end
 
44
 
 
45
    it "should correctly support metaparameters" do
 
46
        comp = component.new(:name => "Foo[bar]", :require => "Foo[bar]")
 
47
        comp.parameter(:require).should be_instance_of(component.attrclass(:require))
 
48
    end
 
49
 
 
50
    describe "when building up the path" do
 
51
        it "should produce the class name if the component models a class" do
 
52
            component.new(:name => "Class[foo]").pathbuilder.must == ["foo"]
 
53
        end
 
54
 
 
55
        it "should produce an empty string if the component models the 'main' class" do
 
56
            component.new(:name => "Class[main]").pathbuilder.must == [""]
 
57
        end
 
58
 
 
59
        it "should produce a resource reference if the component does not model a class" do
 
60
            component.new(:name => "Foo[bar]").pathbuilder.must == ["Foo[bar]"]
 
61
        end
 
62
    end
 
63
end