puppet 3.1.0.rc1 → 3.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (127) hide show
  1. data/COMMITTERS.md +185 -0
  2. data/ext/debian/changelog.erb +6 -0
  3. data/ext/debian/puppet-common.manpages +1 -0
  4. data/ext/debian/puppet.default +3 -1
  5. data/ext/debian/puppetmaster.default +6 -3
  6. data/ext/redhat/puppet.spec.erb +16 -5
  7. data/lib/puppet.rb +3 -5
  8. data/lib/puppet/defaults.rb +6 -5
  9. data/lib/puppet/dsl.rb +3 -7
  10. data/lib/puppet/dsl/resource_api.rb +120 -0
  11. data/lib/puppet/dsl/resource_type_api.rb +34 -0
  12. data/lib/puppet/module_tool.rb +23 -11
  13. data/lib/puppet/network/formats.rb +1 -1
  14. data/lib/puppet/node/environment.rb +1 -3
  15. data/lib/puppet/parser/ast/definition.rb +5 -2
  16. data/lib/puppet/parser/ast/hostclass.rb +3 -2
  17. data/lib/puppet/parser/ast/node.rb +5 -2
  18. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  19. data/lib/puppet/parser/compiler.rb +0 -10
  20. data/lib/puppet/parser/lexer.rb +50 -39
  21. data/lib/puppet/parser/parser_support.rb +29 -11
  22. data/lib/puppet/parser/scope.rb +2 -2
  23. data/lib/puppet/parser/type_loader.rb +7 -31
  24. data/lib/puppet/provider/package/openbsd.rb +16 -2
  25. data/lib/puppet/provider/package/pip.rb +11 -2
  26. data/lib/puppet/provider/package/portage.rb +29 -12
  27. data/lib/puppet/provider/service/launchd.rb +19 -14
  28. data/lib/puppet/provider/service/upstart.rb +1 -1
  29. data/lib/puppet/provider/user/hpux.rb +37 -2
  30. data/lib/puppet/resource.rb +25 -38
  31. data/lib/puppet/resource/type.rb +6 -14
  32. data/lib/puppet/settings.rb +1 -1
  33. data/lib/puppet/ssl/certificate_authority.rb +4 -1
  34. data/lib/puppet/ssl/certificate_request.rb +3 -1
  35. data/lib/puppet/ssl/certificate_signer.rb +22 -0
  36. data/lib/puppet/type.rb +4 -4
  37. data/lib/puppet/util/methodhelper.rb +0 -19
  38. data/lib/puppet/util/rubygems.rb +3 -1
  39. data/lib/puppet/util/selinux.rb +1 -6
  40. data/lib/puppet/version.rb +1 -1
  41. data/man/man5/puppet.conf.5 +81 -95
  42. data/man/man8/extlookup2hiera.8 +23 -0
  43. data/man/man8/puppet-agent.8 +3 -3
  44. data/man/man8/puppet-apply.8 +2 -6
  45. data/man/man8/puppet-ca.8 +6 -7
  46. data/man/man8/puppet-catalog.8 +6 -7
  47. data/man/man8/puppet-cert.8 +4 -4
  48. data/man/man8/puppet-certificate.8 +6 -7
  49. data/man/man8/puppet-certificate_request.8 +6 -7
  50. data/man/man8/puppet-certificate_revocation_list.8 +6 -7
  51. data/man/man8/puppet-config.8 +4 -8
  52. data/man/man8/puppet-describe.8 +1 -1
  53. data/man/man8/puppet-device.8 +1 -1
  54. data/man/man8/puppet-doc.8 +3 -3
  55. data/man/man8/puppet-facts.8 +4 -8
  56. data/man/man8/puppet-file.8 +6 -7
  57. data/man/man8/puppet-filebucket.8 +1 -1
  58. data/man/man8/puppet-help.8 +2 -6
  59. data/man/man8/puppet-inspect.8 +1 -1
  60. data/man/man8/puppet-instrumentation_data.8 +3 -7
  61. data/man/man8/puppet-instrumentation_listener.8 +3 -7
  62. data/man/man8/puppet-instrumentation_probe.8 +3 -7
  63. data/man/man8/puppet-key.8 +6 -7
  64. data/man/man8/puppet-kick.8 +5 -1
  65. data/man/man8/puppet-man.8 +2 -6
  66. data/man/man8/puppet-master.8 +2 -2
  67. data/man/man8/puppet-module.8 +11 -9
  68. data/man/man8/puppet-node.8 +38 -37
  69. data/man/man8/puppet-parser.8 +2 -6
  70. data/man/man8/puppet-plugin.8 +2 -6
  71. data/man/man8/puppet-queue.8 +1 -1
  72. data/man/man8/puppet-report.8 +3 -7
  73. data/man/man8/puppet-resource.8 +1 -1
  74. data/man/man8/puppet-resource_type.8 +3 -7
  75. data/man/man8/puppet-secret_agent.8 +2 -6
  76. data/man/man8/puppet-status.8 +3 -7
  77. data/man/man8/puppet.8 +1 -1
  78. data/spec/integration/parser/ruby_manifest_spec.rb +128 -0
  79. data/spec/lib/puppet_spec/compiler.rb +0 -11
  80. data/spec/spec_helper.rb +3 -4
  81. data/spec/unit/dsl/resource_api_spec.rb +180 -0
  82. data/spec/unit/dsl/resource_type_api_spec.rb +53 -0
  83. data/spec/unit/module_tool_spec.rb +79 -46
  84. data/spec/unit/network/formats_spec.rb +4 -0
  85. data/spec/unit/node/environment_spec.rb +0 -13
  86. data/spec/unit/parser/compiler_spec.rb +0 -26
  87. data/spec/unit/parser/parser_spec.rb +14 -0
  88. data/spec/unit/parser/type_loader_spec.rb +4 -15
  89. data/spec/unit/provider/package/openbsd_spec.rb +148 -35
  90. data/spec/unit/provider/package/pip_spec.rb +49 -25
  91. data/spec/unit/provider/package/portage_spec.rb +65 -0
  92. data/spec/unit/provider/service/launchd_spec.rb +6 -5
  93. data/spec/unit/provider/user/hpux_spec.rb +39 -11
  94. data/spec/unit/provider/user/useradd_spec.rb +14 -14
  95. data/spec/unit/resource/type_spec.rb +7 -49
  96. data/spec/unit/resource_spec.rb +0 -32
  97. data/spec/unit/ssl/certificate_request_spec.rb +18 -0
  98. data/spec/unit/util/rubygems_spec.rb +1 -1
  99. data/spec/unit/util/selinux_spec.rb +0 -2
  100. metadata +17 -50
  101. data/lib/puppet/dsl/actions.rb +0 -283
  102. data/lib/puppet/dsl/blank_slate.rb +0 -55
  103. data/lib/puppet/dsl/context.rb +0 -393
  104. data/lib/puppet/dsl/parser.rb +0 -57
  105. data/lib/puppet/dsl/resource_decorator.rb +0 -56
  106. data/lib/puppet/dsl/resource_reference.rb +0 -95
  107. data/lib/puppet/dsl/type_reference.rb +0 -102
  108. data/lib/puppet/util/manifest_filetype_helper.rb +0 -22
  109. data/spec/integration/dsl/classes_spec.rb +0 -191
  110. data/spec/integration/dsl/defaults_spec.rb +0 -38
  111. data/spec/integration/dsl/definitions_spec.rb +0 -73
  112. data/spec/integration/dsl/functions_spec.rb +0 -95
  113. data/spec/integration/dsl/nodes_spec.rb +0 -96
  114. data/spec/integration/dsl/params_spec.rb +0 -146
  115. data/spec/integration/dsl/relationships_spec.rb +0 -46
  116. data/spec/integration/dsl/resources_spec.rb +0 -202
  117. data/spec/integration/dsl/type_loading_spec.rb +0 -64
  118. data/spec/lib/matchers/catalog.rb +0 -50
  119. data/spec/lib/puppet_spec/dsl.rb +0 -29
  120. data/spec/unit/dsl/actions_spec.rb +0 -402
  121. data/spec/unit/dsl/blank_slate_spec.rb +0 -27
  122. data/spec/unit/dsl/context_spec.rb +0 -678
  123. data/spec/unit/dsl/parser_spec.rb +0 -56
  124. data/spec/unit/dsl/resource_decorator_spec.rb +0 -94
  125. data/spec/unit/dsl/resource_reference_spec.rb +0 -150
  126. data/spec/unit/dsl/type_reference_spec.rb +0 -164
  127. data/spec/unit/util/manifest_filetype_helper_spec.rb +0 -29
@@ -2,6 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  provider_class = Puppet::Type.type(:package).provider(:pip)
5
+ osfamilies = { 'RedHat' => 'pip-python', 'Not RedHat' => 'pip' }
5
6
 
6
7
  describe provider_class do
7
8
 
@@ -30,19 +31,36 @@ describe provider_class do
30
31
 
31
32
  end
32
33
 
33
- describe "instances" do
34
+ describe "cmd" do
35
+ it "should return pip-python on RedHat systems" do
36
+ Facter.stubs(:value).with(:osfamily).returns("RedHat")
37
+ provider_class.cmd.should == 'pip-python'
38
+ end
34
39
 
35
- it "should return an array when pip is present" do
36
- provider_class.expects(:which).with('pip').returns("/fake/bin/pip")
37
- p = stub("process")
38
- p.expects(:collect).yields("real_package==1.2.5")
39
- provider_class.expects(:execpipe).with("/fake/bin/pip freeze").yields(p)
40
- provider_class.instances
40
+ it "should return pip by default" do
41
+ Facter.stubs(:value).with(:osfamily).returns("Not RedHat")
42
+ provider_class.cmd.should == 'pip'
41
43
  end
42
44
 
43
- it "should return an empty array when pip is missing" do
44
- provider_class.expects(:which).with('pip').returns nil
45
- provider_class.instances.should == []
45
+ end
46
+
47
+ describe "instances" do
48
+
49
+ osfamilies.each do |osfamily, pip_cmd|
50
+ it "should return an array on #{osfamily} when #{pip_cmd} is present" do
51
+ Facter.stubs(:value).with(:osfamily).returns(osfamily)
52
+ provider_class.expects(:which).with(pip_cmd).returns("/fake/bin/pip")
53
+ p = stub("process")
54
+ p.expects(:collect).yields("real_package==1.2.5")
55
+ provider_class.expects(:execpipe).with("/fake/bin/pip freeze").yields(p)
56
+ provider_class.instances
57
+ end
58
+
59
+ it "should return an empty array on #{osfamily} when #{pip_cmd} is missing" do
60
+ Facter.stubs(:value).with(:osfamily).returns(osfamily)
61
+ provider_class.expects(:which).with(pip_cmd).returns nil
62
+ provider_class.instances.should == []
63
+ end
46
64
  end
47
65
 
48
66
  end
@@ -179,23 +197,29 @@ describe provider_class do
179
197
  @provider.method(:lazy_pip).call "freeze"
180
198
  end
181
199
 
182
- it "should retry if pip has not yet been found" do
183
- @provider.expects(:pip).twice.with('freeze').raises(NoMethodError).then.returns(nil)
184
- @provider.expects(:which).with('pip').returns("/fake/bin/pip")
185
- @provider.method(:lazy_pip).call "freeze"
186
- end
200
+ osfamilies.each do |osfamily, pip_cmd|
201
+ it "should retry on #{osfamily} if #{pip_cmd} has not yet been found" do
202
+ Facter.stubs(:value).with(:osfamily).returns(osfamily)
203
+ @provider.expects(:pip).twice.with('freeze').raises(NoMethodError).then.returns(nil)
204
+ @provider.expects(:which).with(pip_cmd).returns("/fake/bin/pip")
205
+ @provider.method(:lazy_pip).call "freeze"
206
+ end
187
207
 
188
- it "should fail if pip is missing" do
189
- @provider.expects(:pip).with('freeze').raises(NoMethodError)
190
- @provider.expects(:which).with('pip').returns(nil)
191
- expect { @provider.method(:lazy_pip).call("freeze") }.to raise_error(NoMethodError)
192
- end
208
+ it "should fail on #{osfamily} if #{pip_cmd} is missing" do
209
+ Facter.stubs(:value).with(:osfamily).returns(osfamily)
210
+ @provider.expects(:pip).with('freeze').raises(NoMethodError)
211
+ @provider.expects(:which).with(pip_cmd).returns(nil)
212
+ expect { @provider.method(:lazy_pip).call("freeze") }.to raise_error(NoMethodError)
213
+ end
214
+
215
+ it "should output a useful error message on #{osfamily} if #{pip_cmd} is missing" do
216
+ Facter.stubs(:value).with(:osfamily).returns(osfamily)
217
+ @provider.expects(:pip).with('freeze').raises(NoMethodError)
218
+ @provider.expects(:which).with(pip_cmd).returns(nil)
219
+ expect { @provider.method(:lazy_pip).call("freeze") }.
220
+ to raise_error(NoMethodError, 'Could not locate the pip command.')
221
+ end
193
222
 
194
- it "should output a useful error message if pip is missing" do
195
- @provider.expects(:pip).with('freeze').raises(NoMethodError)
196
- @provider.expects(:which).with('pip').returns(nil)
197
- expect { @provider.method(:lazy_pip).call("freeze") }.
198
- to raise_error(NoMethodError, 'Could not locate the pip command.')
199
223
  end
200
224
 
201
225
  end
@@ -0,0 +1,65 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'spec_helper'
4
+
5
+ provider = Puppet::Type.type(:package).provider(:portage)
6
+
7
+ describe provider do
8
+ before do
9
+ packagename="sl"
10
+ @resource = stub('resource', :[] => packagename,:should => true)
11
+ @provider = provider.new(@resource)
12
+
13
+ portage = stub(:executable => "foo",:execute => true)
14
+ Puppet::Provider::CommandDefiner.stubs(:define).returns(portage)
15
+
16
+ @nomatch_result = ""
17
+ @match_result = "app-misc sl [] [] http://www.tkl.iis.u-tokyo.ac.jp/~toyoda/index_e.html http://www.izumix.org.uk/sl/ sophisticated graphical program which corrects your miss typing\n"
18
+ end
19
+
20
+ it "is versionable" do
21
+ provider.should be_versionable
22
+ end
23
+
24
+ it "uses :emerge to install packages" do
25
+ @provider.expects(:emerge)
26
+
27
+ @provider.install
28
+ end
29
+
30
+ it "uses query to find the latest package" do
31
+ @provider.expects(:query).returns({:versions_available => "myversion"})
32
+
33
+ @provider.latest
34
+ end
35
+
36
+ it "uses eix to search the lastest version of a package" do
37
+ @provider.stubs(:update_eix)
38
+ @provider.expects(:eix).returns(StringIO.new(@match_result))
39
+
40
+ @provider.query
41
+ end
42
+
43
+ it "eix arguments must not include --stable" do
44
+ @provider.class.eix_search_arguments.should_not include("--stable")
45
+ end
46
+
47
+ it "eix arguments must not include --exact" do
48
+ @provider.class.eix_search_arguments.should_not include("--exact")
49
+ end
50
+
51
+ it "query uses default arguments" do
52
+ @provider.stubs(:update_eix)
53
+ @provider.expects(:eix).returns(StringIO.new(@match_result))
54
+ @provider.class.expects(:eix_search_arguments).returns([])
55
+
56
+ @provider.query
57
+ end
58
+
59
+ it "can handle search output with empty square brackets" do
60
+ @provider.stubs(:update_eix)
61
+ @provider.expects(:eix).returns(StringIO.new(@match_result))
62
+
63
+ @provider.query[:name].should eq("sl")
64
+ end
65
+ end
@@ -60,7 +60,6 @@ describe Puppet::Type.type(:service).provider(:launchd) do
60
60
  provider.expects(:get_macosx_version_major).returns("10.6")
61
61
  subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => true}])
62
62
  provider.expects(:read_plist).returns({joblabel => {"Disabled" => false}})
63
- provider.stubs(:launchd_overrides).returns(launchd_overrides)
64
63
  FileTest.expects(:file?).with(launchd_overrides).returns(true)
65
64
  subject.enabled?.should == :true
66
65
  end
@@ -68,7 +67,6 @@ describe Puppet::Type.type(:service).provider(:launchd) do
68
67
  provider.expects(:get_macosx_version_major).returns("10.6")
69
68
  subject.expects(:plist_from_label).returns([joblabel, {"Disabled" => false}])
70
69
  provider.expects(:read_plist).returns({joblabel => {"Disabled" => true}})
71
- provider.stubs(:launchd_overrides).returns(launchd_overrides)
72
70
  FileTest.expects(:file?).with(launchd_overrides).returns(true)
73
71
  subject.enabled?.should == :false
74
72
  end
@@ -76,7 +74,6 @@ describe Puppet::Type.type(:service).provider(:launchd) do
76
74
  provider.expects(:get_macosx_version_major).returns("10.6")
77
75
  subject.expects(:plist_from_label).returns([joblabel, {}])
78
76
  provider.expects(:read_plist).returns({})
79
- provider.stubs(:launchd_overrides).returns(launchd_overrides)
80
77
  FileTest.expects(:file?).with(launchd_overrides).returns(true)
81
78
  subject.enabled?.should == :true
82
79
  end
@@ -122,6 +119,12 @@ describe Puppet::Type.type(:service).provider(:launchd) do
122
119
  subject.expects(:execute).with([:launchctl, :load, '-w', joblabel])
123
120
  subject.start
124
121
  end
122
+
123
+ it "(#16271) Should stop and start the service when a restart is called" do
124
+ subject.expects(:stop)
125
+ subject.expects(:start)
126
+ subject.restart
127
+ end
125
128
  end
126
129
 
127
130
  describe "when stopping the service" do
@@ -191,7 +194,6 @@ describe Puppet::Type.type(:service).provider(:launchd) do
191
194
  resource[:enable] = true
192
195
  provider.expects(:get_macosx_version_major).returns("10.6")
193
196
  provider.expects(:read_plist).returns({})
194
- provider.stubs(:launchd_overrides).returns(launchd_overrides)
195
197
  Plist::Emit.expects(:save_plist).once
196
198
  subject.enable
197
199
  end
@@ -202,7 +204,6 @@ describe Puppet::Type.type(:service).provider(:launchd) do
202
204
  resource[:enable] = false
203
205
  provider.stubs(:get_macosx_version_major).returns("10.6")
204
206
  provider.stubs(:read_plist).returns({})
205
- provider.stubs(:launchd_overrides).returns(launchd_overrides)
206
207
  Plist::Emit.expects(:save_plist).once
207
208
  subject.enable
208
209
  end
@@ -1,24 +1,52 @@
1
- #! /usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  require 'spec_helper'
3
+ require 'etc'
3
4
 
4
5
  provider_class = Puppet::Type.type(:user).provider(:hpuxuseradd)
5
6
 
6
7
  describe provider_class do
7
- # left from the useradd test... I have no clue what I'm doing.
8
- before do
9
- @resource = stub("resource", :name => "myuser", :managehome? => nil, :should => "fakeval", :[] => "fakeval")
10
- @provider = provider_class.new(@resource)
8
+ let :resource do
9
+ Puppet::Type.type(:user).new(
10
+ :title => 'testuser',
11
+ :comment => 'Test J. User',
12
+ :provider => :hpuxuseradd
13
+ )
11
14
  end
15
+ let(:provider) { resource.provider }
12
16
 
13
17
  it "should add -F when modifying a user" do
14
- @resource.expects(:allowdupe?).returns true
15
- @provider.expects(:execute).with { |args| args.include?("-F") }
16
- @provider.uid = 1000
18
+ resource.stubs(:allowdupe?).returns true
19
+ provider.expects(:execute).with { |args| args.include?("-F") }
20
+ provider.uid = 1000
17
21
  end
18
22
 
19
23
  it "should add -F when deleting a user" do
20
- @provider.stubs(:exists?).returns(true)
21
- @provider.expects(:execute).with { |args| args.include?("-F") }
22
- @provider.delete
24
+ provider.stubs(:exists?).returns(true)
25
+ provider.expects(:execute).with { |args| args.include?("-F") }
26
+ provider.delete
27
+ end
28
+
29
+ context "managing passwords" do
30
+ let :pwent do
31
+ Struct::Passwd.new("testuser", "foopassword")
32
+ end
33
+
34
+ before :each do
35
+ Etc.stubs(:getpwent).returns(pwent)
36
+ Etc.stubs(:getpwnam).returns(pwent)
37
+ end
38
+
39
+ it "should have feature manages_passwords" do
40
+ provider_class.should be_manages_passwords
41
+ end
42
+
43
+ it "should return nil if user does not exist" do
44
+ Etc.stubs(:getpwent).returns(nil)
45
+ provider.password.must be_nil
46
+ end
47
+
48
+ it "should return password entry if exists" do
49
+ provider.password.must == "foopassword"
50
+ end
23
51
  end
24
52
  end
@@ -25,7 +25,7 @@ describe Puppet::Type.type(:user).provider(:useradd) do
25
25
 
26
26
  it "should add -o when allowdupe is enabled and the user is being created" do
27
27
  resource[:allowdupe] = true
28
- provider.expects(:execute).with(['/usr/sbin/useradd', '-o', 'myuser'])
28
+ provider.expects(:execute).with(includes('-o'))
29
29
  provider.create
30
30
  end
31
31
 
@@ -33,7 +33,7 @@ describe Puppet::Type.type(:user).provider(:useradd) do
33
33
  it "should add -r when system is enabled" do
34
34
  resource[:system] = :true
35
35
  provider.should be_system_users
36
- provider.expects(:execute).with(['/usr/sbin/useradd', '-r', 'myuser'])
36
+ provider.expects(:execute).with(includes('-r'))
37
37
  provider.create
38
38
  end
39
39
  end
@@ -51,7 +51,7 @@ describe Puppet::Type.type(:user).provider(:useradd) do
51
51
  described_class.has_feature :manages_password_age
52
52
  resource[:password_min_age] = 5
53
53
  resource[:password_max_age] = 10
54
- provider.expects(:execute).with(['/usr/sbin/useradd', 'myuser'])
54
+ provider.expects(:execute).with(includes('/usr/sbin/useradd'))
55
55
  provider.expects(:execute).with(['/usr/bin/chage', '-m', 5, '-M', 10, 'myuser'])
56
56
  provider.create
57
57
  end
@@ -109,32 +109,32 @@ describe Puppet::Type.type(:user).provider(:useradd) do
109
109
  end
110
110
 
111
111
  describe "#check_manage_home" do
112
- it "should check manage home" do
113
- resource.expects(:managehome?)
114
- provider.check_manage_home
115
- end
116
-
117
112
  it "should return an array with -m flag if home is managed" do
118
113
  resource[:managehome] = :true
119
- provider.check_manage_home.must == ["-m"]
114
+ provider.expects(:execute).with(includes('-m'))
115
+ provider.create
120
116
  end
121
117
 
122
118
  it "should return an array with -r flag if home is managed" do
123
119
  resource[:managehome] = :true
124
120
  resource[:ensure] = :absent
125
- provider.deletecmd.must == ['/usr/sbin/userdel', '-r', 'myuser']
121
+ provider.stubs(:exists?).returns(true)
122
+ provider.expects(:execute).with(includes('-r'))
123
+ provider.delete
126
124
  end
127
125
 
128
- it "should return an array with -M if home is not managed and on Redhat" do
126
+ it "should use -M flag if home is not managed and on Redhat" do
129
127
  Facter.stubs(:value).with(:osfamily).returns("RedHat")
130
128
  resource[:managehome] = :false
131
- provider.check_manage_home.must == ["-M"]
129
+ provider.expects(:execute).with(includes('-M'))
130
+ provider.create
132
131
  end
133
132
 
134
- it "should return an empty array if home is not managed and not on Redhat" do
133
+ it "should not use -M flag if home is not managed and not on Redhat" do
135
134
  Facter.stubs(:value).with(:osfamily).returns("not RedHat")
136
135
  resource[:managehome] = :false
137
- provider.check_manage_home.must == []
136
+ provider.expects(:execute).with(Not(includes('-M')))
137
+ provider.create
138
138
  end
139
139
  end
140
140
 
@@ -8,7 +8,7 @@ describe Puppet::Resource::Type do
8
8
  Puppet::Resource::Type.new(:hostclass, "foo").name.should == "foo"
9
9
  end
10
10
 
11
- [:code, :doc, :line, :file, :resource_type_collection].each do |attr|
11
+ [:code, :doc, :line, :file, :resource_type_collection, :ruby_code].each do |attr|
12
12
  it "should have a '#{attr}' attribute" do
13
13
  type = Puppet::Resource::Type.new(:hostclass, "foo")
14
14
  type.send(attr.to_s + "=", "yay")
@@ -16,22 +16,6 @@ describe Puppet::Resource::Type do
16
16
  end
17
17
  end
18
18
 
19
- it "returns array when calling ruby_code" do
20
- Puppet::Resource::Type.new(:hostclass, "foo").ruby_code.should be_an Array
21
- end
22
-
23
- it "assignment operator should append to ruby_code" do
24
- type = Puppet::Resource::Type.new :hostclass, 'foo'
25
- type.ruby_code << "code"
26
- type.ruby_code << "more code"
27
- type.ruby_code.should == ["code", "more code"]
28
- end
29
-
30
- it "has ruby_code attribute" do
31
- type = Puppet::Resource::Type.new(:hostclass, "foo")
32
- type.ruby_code.should == []
33
- end
34
-
35
19
  [:hostclass, :node, :definition].each do |type|
36
20
  it "should know when it is a #{type}" do
37
21
  Puppet::Resource::Type.new(type, "foo").send("#{type}?").should be_true
@@ -467,10 +451,12 @@ describe Puppet::Resource::Type do
467
451
  end
468
452
 
469
453
  describe "and ruby code is provided" do
470
- it "should evaluate ruby code" do
471
- code = stub 'code'
472
- code.expects(:evaluate).with {|scope, type_collection| scope.is_a? Puppet::Parser::Scope and type_collection.is_a? Puppet::Resource::TypeCollection }
473
- @type.stubs(:ruby_code).returns(Array(code))
454
+ it "should create a DSL Resource API and evaluate it" do
455
+ @type.stubs(:ruby_code).returns(proc { "foo" })
456
+ @api = stub 'api'
457
+ Puppet::DSL::ResourceAPI.expects(:new).with { |res, scope, code| code == @type.ruby_code }.returns @api
458
+ @api.expects(:evaluate)
459
+
474
460
  @type.evaluate_code(@resource)
475
461
  end
476
462
  end
@@ -729,34 +715,6 @@ describe Puppet::Resource::Type do
729
715
  dest.doc.should == "foonessyayness"
730
716
  end
731
717
 
732
- it "copies other's ruby code if it has no ruby code" do
733
- dest = Puppet::Resource::Type.new :hostclass, "bar"
734
- source = Puppet::Resource::Type.new :hostclass, "foo"
735
- source.ruby_code << "bar"
736
-
737
- dest.merge source
738
- dest.ruby_code.should == ["bar"]
739
- end
740
-
741
- it "appends other's ruby code if it has ruby code" do
742
- dest = Puppet::Resource::Type.new :hostclass, "bar"
743
- source = Puppet::Resource::Type.new :hostclass, "foo"
744
- dest.ruby_code << "foo"
745
- source.ruby_code << "bar"
746
-
747
- dest.merge source
748
- dest.ruby_code.should == ["foo", "bar"]
749
- end
750
-
751
- it "returns own ruby code if the other has no ruby code" do
752
- dest = Puppet::Resource::Type.new :hostclass, "bar", :ruby_code => "foo"
753
- source = Puppet::Resource::Type.new :hostclass, "foo"
754
- dest.ruby_code << "foo"
755
-
756
- dest.merge source
757
- dest.ruby_code.should == ["foo"]
758
- end
759
-
760
718
  it "should turn its code into an ASTArray if necessary" do
761
719
  dest = Puppet::Resource::Type.new(:hostclass, "bar", :code => code("foo"))
762
720
  source = Puppet::Resource::Type.new(:hostclass, "foo", :code => code("bar"))
@@ -15,7 +15,6 @@ describe Puppet::Resource do
15
15
  end
16
16
  end
17
17
 
18
-
19
18
  it "should have a :title attribute" do
20
19
  Puppet::Resource.new(:user, "foo").title.should == "foo"
21
20
  end
@@ -306,33 +305,6 @@ describe Puppet::Resource do
306
305
  resource.set_default_parameters(@scope).should == ["a"]
307
306
  end
308
307
 
309
- it "doesn't call safeevaluate on default value when it doesn't respond to safeevaluate" do
310
- Puppet[:manifest] = "test.rb"
311
- value = mock
312
- value.stubs(:respond_to?).with(:safeevaluate).returns false
313
- value.expects(:safeevaluate).never
314
- Puppet::Node::Environment.new.known_resource_types.add(
315
- Puppet::Resource::Type.new :definition, "default_param", :arguments => {"a" => value}
316
- )
317
-
318
- resource = Puppet::Parser::Resource.new "default_param", "name", :scope => Puppet::Parser::Scope.new(Puppet::Parser::Compiler.new(Puppet::Node.new("foo")))
319
- resource.set_default_parameters @scope
320
- end
321
-
322
-
323
- it "calls safeevaluate on default when it responds to safeevaluate" do
324
- value = mock
325
- value.expects(:safeevaluate).returns 42
326
- Puppet::Node::Environment.new.known_resource_types.add(
327
- Puppet::Resource::Type.new :definition, "default_param", :arguments => {"a" => value}
328
- )
329
-
330
- resource = Puppet::Parser::Resource.new "default_param", "name", :scope => Puppet::Parser::Scope.new(Puppet::Parser::Compiler.new(Puppet::Node.new("foo")))
331
- resource.set_default_parameters @scope
332
- end
333
-
334
-
335
-
336
308
  describe "when the resource type is :hostclass" do
337
309
  let(:environment_name) { "testing env" }
338
310
  let(:fact_values) { { :a => 1 } }
@@ -993,8 +965,4 @@ type: File
993
965
  })
994
966
  end
995
967
  end
996
-
997
- it "should be able to return canonical type name" do
998
- Puppet::Resource.canonicalize_type("foo").should == "Foo"
999
- end
1000
968
  end