puppet 2.7.18 → 2.7.19

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 (137) hide show
  1. data/CHANGELOG +82 -0
  2. data/CONTRIBUTING.md +114 -171
  3. data/README.md +8 -0
  4. data/README_DEVELOPER.md +38 -3
  5. data/Rakefile +19 -3
  6. data/conf/osx/createpackage.sh +3 -1
  7. data/conf/redhat/logrotate +1 -1
  8. data/conf/redhat/puppet.spec +35 -8
  9. data/lib/puppet.rb +1 -1
  10. data/lib/puppet/application/agent.rb +2 -0
  11. data/lib/puppet/application/master.rb +2 -0
  12. data/lib/puppet/configurer.rb +2 -3
  13. data/lib/puppet/defaults.rb +6 -5
  14. data/lib/puppet/face/module/install.rb +2 -1
  15. data/lib/puppet/file_bucket/dipper.rb +1 -1
  16. data/lib/puppet/indirector/file_content.rb +2 -2
  17. data/lib/puppet/indirector/file_metadata.rb +2 -2
  18. data/lib/puppet/indirector/indirection.rb +3 -4
  19. data/lib/puppet/indirector/rest.rb +12 -6
  20. data/lib/puppet/interface/action_manager.rb +1 -2
  21. data/lib/puppet/module_tool/applications/unpacker.rb +22 -3
  22. data/lib/puppet/network/handler/fileserver.rb +2 -2
  23. data/lib/puppet/parser/ast/resource.rb +9 -2
  24. data/lib/puppet/parser/functions/fqdn_rand.rb +2 -1
  25. data/lib/puppet/parser/functions/md5.rb +2 -2
  26. data/lib/puppet/parser/functions/sha1.rb +2 -2
  27. data/lib/puppet/parser/functions/template.rb +0 -2
  28. data/lib/puppet/parser/type_loader.rb +1 -2
  29. data/lib/puppet/provider/augeas/augeas.rb +19 -1
  30. data/lib/puppet/provider/confine.rb +1 -1
  31. data/lib/puppet/provider/package/msi.rb +97 -51
  32. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -0
  33. data/lib/puppet/provider/service/gentoo.rb +0 -2
  34. data/lib/puppet/provider/service/openrc.rb +69 -0
  35. data/lib/puppet/provider/service/windows.rb +6 -4
  36. data/lib/puppet/provider/user/aix.rb +8 -4
  37. data/lib/puppet/provider/user/useradd.rb +6 -0
  38. data/lib/puppet/rails/benchmark.rb +2 -2
  39. data/lib/puppet/reports/store.rb +9 -9
  40. data/lib/puppet/resource/catalog.rb +2 -1
  41. data/lib/puppet/resource/type_collection.rb +2 -1
  42. data/lib/puppet/ssl/base.rb +1 -2
  43. data/lib/puppet/ssl/certificate_authority/interface.rb +1 -0
  44. data/lib/puppet/test/test_helper.rb +2 -1
  45. data/lib/puppet/type.rb +1 -1
  46. data/lib/puppet/type/augeas.rb +1 -1
  47. data/lib/puppet/type/file.rb +4 -2
  48. data/lib/puppet/type/scheduled_task.rb +8 -10
  49. data/lib/puppet/type/tidy.rb +1 -1
  50. data/lib/puppet/util.rb +63 -25
  51. data/lib/puppet/util/autoload.rb +6 -4
  52. data/lib/puppet/util/checksums.rb +3 -8
  53. data/lib/puppet/util/diff.rb +2 -1
  54. data/lib/puppet/util/filetype.rb +1 -3
  55. data/lib/puppet/util/run_mode.rb +2 -1
  56. data/lib/puppet/util/suidmanager.rb +1 -1
  57. data/lib/puppet/util/windows.rb +1 -0
  58. data/lib/puppet/util/windows/file.rb +27 -0
  59. data/lib/puppet/util/windows/user.rb +1 -2
  60. data/man/man8/puppet-agent.8 +4 -0
  61. data/man/man8/puppet-master.8 +4 -0
  62. data/man/man8/puppetmasterd.8 +4 -0
  63. data/spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug +13 -0
  64. data/spec/fixtures/unit/provider/augeas/augeas/etc/fstab +10 -0
  65. data/spec/fixtures/unit/provider/augeas/augeas/etc/hosts +6 -0
  66. data/spec/fixtures/unit/provider/augeas/augeas/etc/test +3 -0
  67. data/spec/fixtures/unit/provider/augeas/augeas/test.aug +13 -0
  68. data/spec/fixtures/unit/provider/service/openrc/rcservice_list +8 -0
  69. data/spec/fixtures/unit/provider/service/openrc/rcstatus +43 -0
  70. data/spec/integration/defaults_spec.rb +3 -3
  71. data/spec/integration/network/server/mongrel_spec.rb +8 -6
  72. data/spec/integration/parser/parser_spec.rb +1 -1
  73. data/spec/integration/type/file_spec.rb +49 -12
  74. data/spec/lib/puppet_spec/database.rb +5 -3
  75. data/spec/lib/puppet_spec/files.rb +2 -1
  76. data/spec/monkey_patches/alias_should_to_must.rb +15 -2
  77. data/spec/shared_behaviours/file_serving_model.rb +9 -6
  78. data/spec/shared_behaviours/path_parameters.rb +5 -5
  79. data/spec/shared_behaviours/things_that_declare_options.rb +5 -5
  80. data/spec/unit/application/facts_spec.rb +1 -1
  81. data/spec/unit/application_spec.rb +10 -8
  82. data/spec/unit/configurer_spec.rb +11 -2
  83. data/spec/unit/face/ca_spec.rb +15 -15
  84. data/spec/unit/face/help_spec.rb +5 -5
  85. data/spec/unit/face/module/install_spec.rb +13 -2
  86. data/spec/unit/face/node_spec.rb +7 -6
  87. data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -1
  88. data/spec/unit/indirector/envelope_spec.rb +0 -13
  89. data/spec/unit/indirector/facts/inventory_service_spec.rb +1 -1
  90. data/spec/unit/indirector/queue_spec.rb +3 -3
  91. data/spec/unit/indirector/rest_spec.rb +31 -20
  92. data/spec/unit/indirector_spec.rb +5 -5
  93. data/spec/unit/interface/action_builder_spec.rb +3 -2
  94. data/spec/unit/interface/action_manager_spec.rb +1 -1
  95. data/spec/unit/interface/action_spec.rb +4 -3
  96. data/spec/unit/interface/face_collection_spec.rb +1 -1
  97. data/spec/unit/interface/option_spec.rb +13 -9
  98. data/spec/unit/interface_spec.rb +5 -5
  99. data/spec/unit/module_tool/applications/unpacker_spec.rb +61 -0
  100. data/spec/unit/network/handler/fileserver_spec.rb +3 -3
  101. data/spec/unit/other/transbucket_spec.rb +6 -9
  102. data/spec/unit/parser/ast/resource_spec.rb +27 -0
  103. data/spec/unit/parser/functions/create_resources_spec.rb +12 -12
  104. data/spec/unit/parser/lexer_spec.rb +5 -5
  105. data/spec/unit/provider/augeas/augeas_spec.rb +78 -0
  106. data/spec/unit/provider/nameservice/directoryservice_spec.rb +6 -6
  107. data/spec/unit/provider/package/freebsd_spec.rb +2 -2
  108. data/spec/unit/provider/package/msi_spec.rb +181 -114
  109. data/spec/unit/provider/package/openbsd_spec.rb +1 -0
  110. data/spec/unit/provider/package/pkgdmg_spec.rb +3 -3
  111. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1 -1
  112. data/spec/unit/provider/service/openrc_spec.rb +209 -0
  113. data/spec/unit/provider/service/windows_spec.rb +57 -59
  114. data/spec/unit/provider/user/useradd_spec.rb +7 -0
  115. data/spec/unit/reports/store_spec.rb +13 -13
  116. data/spec/unit/resource/catalog_spec.rb +29 -24
  117. data/spec/unit/resource_spec.rb +13 -13
  118. data/spec/unit/simple_graph_spec.rb +12 -12
  119. data/spec/unit/ssl/certificate_authority/interface_spec.rb +3 -3
  120. data/spec/unit/ssl/certificate_authority_spec.rb +11 -10
  121. data/spec/unit/transaction_spec.rb +3 -3
  122. data/spec/unit/type/cron_spec.rb +171 -171
  123. data/spec/unit/type/exec_spec.rb +29 -27
  124. data/spec/unit/type/file_spec.rb +22 -13
  125. data/spec/unit/type/interface_spec.rb +1 -1
  126. data/spec/unit/type/scheduled_task_spec.rb +15 -14
  127. data/spec/unit/type/tidy_spec.rb +2 -2
  128. data/spec/unit/type/user_spec.rb +15 -15
  129. data/spec/unit/type/vlan_spec.rb +1 -1
  130. data/spec/unit/type_spec.rb +22 -25
  131. data/spec/unit/util/autoload_spec.rb +13 -7
  132. data/spec/unit/util/backups_spec.rb +36 -67
  133. data/spec/unit/util/storage_spec.rb +2 -9
  134. data/spec/unit/util/suidmanager_spec.rb +1 -1
  135. data/spec/unit/util_spec.rb +20 -28
  136. data/test/ral/manager/attributes.rb +1 -1
  137. metadata +1553 -1542
@@ -93,36 +93,47 @@ describe Puppet::Indirector::REST do
93
93
  describe "when making http requests" do
94
94
  include PuppetSpec::Files
95
95
 
96
- it "should provide a suggestive error message when certificate verify failed" do
96
+ def a_connection_that_verifies(args)
97
97
  connection = Net::HTTP.new('my_server', 8140)
98
- @searcher.stubs(:network).returns(connection)
98
+ connection.stubs(:get).with do
99
+ connection.verify_callback.call(args[:has_passed_pre_checks], args[:in_context])
100
+ true
101
+ end.raises(OpenSSL::SSL::SSLError.new(args[:fails_with]))
102
+ connection
103
+ end
99
104
 
100
- connection.stubs(:get).raises(OpenSSL::SSL::SSLError.new('certificate verify failed'))
105
+ def a_store_context(args)
106
+ Puppet[:confdir] = tmpdir('conf')
107
+ cert = Puppet::SSL::CertificateAuthority.new.generate(args[:for_server], :dns_alt_names => args[:for_aliases]).content
108
+ ssl_context = mock('OpenSSL::X509::StoreContext')
109
+ ssl_context.stubs(:current_cert).returns(cert)
110
+ ssl_context.stubs(:error_string).returns(args[:with_error_string])
111
+ ssl_context
112
+ end
101
113
 
114
+ it "should provide a useful error message when one is available and certificate validation fails", :unless => Puppet.features.microsoft_windows? do
115
+ @searcher.stubs(:network).
116
+ returns(a_connection_that_verifies(:has_passed_pre_checks => false,
117
+ :in_context => a_store_context(:for_server => 'not_my_server',
118
+ :with_error_string => 'shady looking signature'),
119
+ :fails_with => 'certificate verify failed'))
102
120
  expect do
103
121
  @searcher.http_request(:get, stub('request'))
104
- end.to raise_error(/This is often because the time is out of sync on the server or client/)
122
+ end.to raise_error(Puppet::Error, "certificate verify failed: [shady looking signature for /CN=not_my_server]")
105
123
  end
106
124
 
107
125
  it "should provide a helpful error message when hostname was not match with server certificate", :unless => Puppet.features.microsoft_windows? do
108
- Puppet[:confdir] = tmpdir('conf')
109
- cert = Puppet::SSL::CertificateAuthority.new.generate('not_my_server', :dns_alt_names => 'foo,bar,baz').content
110
-
111
- connection = Net::HTTP.new('my_server', 8140)
112
- @searcher.stubs(:network).returns(connection)
113
- ssl_context = OpenSSL::SSL::SSLContext.new
114
- ssl_context.stubs(:current_cert).returns(cert)
115
- connection.stubs(:get).with do
116
- connection.verify_callback.call(true, ssl_context)
117
- end.raises(OpenSSL::SSL::SSLError.new('hostname was not match with server certificate'))
118
-
119
- msg = /Server hostname 'my_server' did not match server certificate; expected one of (.+)/
120
- expect { @searcher.http_request(:get, stub('request')) }.to(
121
- raise_error(Puppet::Error, msg) do |error|
122
- error.message =~ msg
126
+ @searcher.stubs(:network).
127
+ returns(a_connection_that_verifies(:has_passed_pre_checks => true,
128
+ :in_context => a_store_context(:for_server => 'not_my_server',
129
+ :for_aliases => 'foo,bar,baz'),
130
+ :fails_with => 'hostname was not match with server certificate'))
131
+
132
+ expect { @searcher.http_request(:get, stub('request')) }.
133
+ to raise_error(Puppet::Error) do |error|
134
+ error.message =~ /Server hostname 'my_server' did not match server certificate; expected one of (.+)/
123
135
  $1.split(', ').should =~ %w[DNS:foo DNS:bar DNS:baz DNS:not_my_server not_my_server]
124
136
  end
125
- )
126
137
  end
127
138
 
128
139
  it "should pass along the error message otherwise" do
@@ -37,7 +37,7 @@ describe Puppet::Indirector, "when configuring routes" do
37
37
  }
38
38
  }
39
39
 
40
- expect { Puppet::Indirector.configure_routes(routes) }.should raise_error(/fake_indirection does not exist/)
40
+ expect { Puppet::Indirector.configure_routes(routes) }.to raise_error(/fake_indirection does not exist/)
41
41
  end
42
42
 
43
43
  it "should fail when given an invalid terminus" do
@@ -48,7 +48,7 @@ describe Puppet::Indirector, "when configuring routes" do
48
48
  }
49
49
  }
50
50
 
51
- expect { Puppet::Indirector.configure_routes(routes) }.should raise_error(/Could not find terminus fake_terminus/)
51
+ expect { Puppet::Indirector.configure_routes(routes) }.to raise_error(/Could not find terminus fake_terminus/)
52
52
  end
53
53
 
54
54
  it "should fail when given an invalid cache" do
@@ -59,7 +59,7 @@ describe Puppet::Indirector, "when configuring routes" do
59
59
  }
60
60
  }
61
61
 
62
- expect { Puppet::Indirector.configure_routes(routes) }.should raise_error(/Could not find terminus fake_cache/)
62
+ expect { Puppet::Indirector.configure_routes(routes) }.to raise_error(/Could not find terminus fake_cache/)
63
63
  end
64
64
  end
65
65
 
@@ -87,7 +87,7 @@ describe Puppet::Indirector, "when registering an indirection" do
87
87
  end
88
88
 
89
89
  it "should require a name when registering a model" do
90
- Proc.new {@thingie.send(:indirects) }.should raise_error(ArgumentError)
90
+ expect {@thingie.send(:indirects) }.to raise_error(ArgumentError)
91
91
  end
92
92
 
93
93
  it "should create an indirection instance to manage each indirecting model" do
@@ -98,7 +98,7 @@ describe Puppet::Indirector, "when registering an indirection" do
98
98
  it "should not allow a model to register under multiple names" do
99
99
  # Keep track of the indirection instance so we can delete it on cleanup
100
100
  @indirection = @thingie.indirects :first
101
- Proc.new { @thingie.indirects :second }.should raise_error(ArgumentError)
101
+ expect { @thingie.indirects :second }.to raise_error(ArgumentError)
102
102
  end
103
103
 
104
104
  it "should make the indirection available via an accessor" do
@@ -23,8 +23,9 @@ describe Puppet::Interface::ActionBuilder do
23
23
  end
24
24
 
25
25
  it "should require a block" do
26
- expect { Puppet::Interface::ActionBuilder.build(nil, :foo) }.
27
- should raise_error("Action :foo must specify a block")
26
+ expect {
27
+ Puppet::Interface::ActionBuilder.build(nil, :foo)
28
+ }.to raise_error("Action :foo must specify a block")
28
29
  end
29
30
 
30
31
  it "should require an invocation block" do
@@ -259,7 +259,7 @@ describe Puppet::Interface::ActionManager do
259
259
  when_invoked do |options| true end
260
260
  default
261
261
  }
262
- }.should raise_error /cannot both be default/
262
+ }.to raise_error /cannot both be default/
263
263
  end
264
264
  end
265
265
 
@@ -6,8 +6,9 @@ describe Puppet::Interface::Action do
6
6
  describe "when validating the action name" do
7
7
  [nil, '', 'foo bar', '-foobar'].each do |input|
8
8
  it "should treat #{input.inspect} as an invalid name" do
9
- expect { Puppet::Interface::Action.new(nil, input) }.
10
- should raise_error(/is an invalid action name/)
9
+ expect {
10
+ Puppet::Interface::Action.new(nil, input)
11
+ }.to raise_error(/is an invalid action name/)
11
12
  end
12
13
  end
13
14
  end
@@ -261,7 +262,7 @@ describe Puppet::Interface::Action do
261
262
  option "--foo"
262
263
  action :bar do option "--foo" end
263
264
  end
264
- }.should raise_error ArgumentError, /Option foo conflicts with existing option foo/i
265
+ }.to raise_error ArgumentError, /Option foo conflicts with existing option foo/i
265
266
  end
266
267
 
267
268
  it "should fail when a required action option is not provided" do
@@ -166,7 +166,7 @@ describe Puppet::Interface::FaceCollection do
166
166
  faulty.each do |input|
167
167
  it "should fail when presented with #{input.inspect} (#{input.class})" do
168
168
  expect { subject.underscorize(input) }.
169
- should raise_error ArgumentError, /not a valid face name/
169
+ to raise_error ArgumentError, /not a valid face name/
170
170
  end
171
171
  end
172
172
  end
@@ -17,27 +17,31 @@ describe Puppet::Interface::Option do
17
17
 
18
18
  [:foo, 12, nil, {}, []].each do |input|
19
19
  it "should fail sensible when given #{input.inspect}" do
20
- expect { Puppet::Interface::Option.new(face, input) }.
21
- should raise_error ArgumentError, /is not valid for an option argument/
20
+ expect {
21
+ Puppet::Interface::Option.new(face, input)
22
+ }.to raise_error ArgumentError, /is not valid for an option argument/
22
23
  end
23
24
  end
24
25
 
25
26
  ["-foo", "-foo=BAR", "-foo BAR"].each do |input|
26
27
  it "should fail with a single dash for long option #{input.inspect}" do
27
- expect { Puppet::Interface::Option.new(face, input) }.
28
- should raise_error ArgumentError, /long options need two dashes \(--\)/
28
+ expect {
29
+ Puppet::Interface::Option.new(face, input)
30
+ }.to raise_error ArgumentError, /long options need two dashes \(--\)/
29
31
  end
30
32
  end
31
33
  end
32
34
 
33
35
  it "requires a face when created" do
34
- expect { Puppet::Interface::Option.new }.
35
- should raise_error ArgumentError, /wrong number of arguments/
36
+ expect {
37
+ Puppet::Interface::Option.new
38
+ }.to raise_error ArgumentError, /wrong number of arguments/
36
39
  end
37
40
 
38
41
  it "also requires some declaration arguments when created" do
39
- expect { Puppet::Interface::Option.new(face) }.
40
- should raise_error ArgumentError, /No option declarations found/
42
+ expect {
43
+ Puppet::Interface::Option.new(face)
44
+ }.to raise_error ArgumentError, /No option declarations found/
41
45
  end
42
46
 
43
47
  it "should infer the name from an optparse string" do
@@ -113,7 +117,7 @@ describe Puppet::Interface::Option do
113
117
  its :default do should be_nil end
114
118
 
115
119
  it "should set a proc as default" do
116
- expect { subject.default = proc { 12 } }.should_not raise_error
120
+ expect { subject.default = proc { 12 } }.to_not raise_error
117
121
  end
118
122
 
119
123
  [1, {}, [], Object.new, "foo"].each do |input|
@@ -20,15 +20,15 @@ describe Puppet::Interface do
20
20
 
21
21
  describe "#[]" do
22
22
  it "should fail when no version is requested" do
23
- expect { subject[:huzzah] }.should raise_error ArgumentError
23
+ expect { subject[:huzzah] }.to raise_error ArgumentError
24
24
  end
25
25
 
26
26
  it "should raise an exception when the requested version is unavailable" do
27
- expect { subject[:huzzah, '17.0.0'] }.should raise_error, Puppet::Error
27
+ expect { subject[:huzzah, '17.0.0'] }.to raise_error, Puppet::Error
28
28
  end
29
29
 
30
30
  it "should raise an exception when the requested face doesn't exist" do
31
- expect { subject[:burrble_toot, :current] }.should raise_error, Puppet::Error
31
+ expect { subject[:burrble_toot, :current] }.to raise_error, Puppet::Error
32
32
  end
33
33
 
34
34
  describe "version matching" do
@@ -98,7 +98,7 @@ describe Puppet::Interface do
98
98
 
99
99
  it "should require a valid version number" do
100
100
  expect { subject.new(:bad_version, 'Rasins') }.
101
- should raise_error ArgumentError
101
+ to raise_error ArgumentError
102
102
  end
103
103
 
104
104
  it "should instance-eval any provided block", :'fails_on_ruby_1.9.2' => true do
@@ -159,7 +159,7 @@ describe Puppet::Interface do
159
159
  end
160
160
  option "--foo"
161
161
  end
162
- }.should raise_error ArgumentError, /Option foo conflicts with existing option foo on/i
162
+ }.to raise_error ArgumentError, /Option foo conflicts with existing option foo on/i
163
163
  end
164
164
 
165
165
  it "should work when two actions have the same option" do
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+ require 'puppet/module_tool/applications'
3
+ require 'puppet_spec/modules'
4
+
5
+ describe Puppet::ModuleTool::Applications::Unpacker, :fails_on_windows => true do
6
+ include PuppetSpec::Files
7
+
8
+ let(:target) { tmpdir("unpacker") }
9
+
10
+ context "initialization" do
11
+ it "should support filename and basic options" do
12
+ Puppet::ModuleTool::Applications::Unpacker.new("myusername-mytarball-1.0.0.tar.gz", :target_dir => target)
13
+ end
14
+
15
+ it "should raise ArgumentError when filename is invalid" do
16
+ expect { Puppet::ModuleTool::Applications::Unpacker.new("invalid.tar.gz", :target_dir => target) }.to raise_error(ArgumentError)
17
+ end
18
+ end
19
+
20
+ context "#run" do
21
+ let(:cache_base_path) { Pathname.new(tmpdir("unpacker")) }
22
+ let(:filename) { tmpdir("module") + "/myusername-mytarball-1.0.0.tar.gz" }
23
+ let(:build_dir) { Pathname.new(tmpdir("build_dir")) }
24
+ let(:unpacker) do
25
+ Puppet::ModuleTool::Applications::Unpacker.new(filename, :target_dir => target)
26
+ end
27
+
28
+ before :each do
29
+ # Mock redhat for most test cases
30
+ Facter.stubs(:value).with("operatingsystem").returns("Redhat")
31
+ build_dir.stubs(:mkpath => nil, :rmtree => nil, :children => [])
32
+ unpacker.stubs(:build_dir).at_least_once.returns(build_dir)
33
+ FileUtils.stubs(:mv)
34
+ end
35
+
36
+ context "on linux" do
37
+ it "should attempt to untar file to temporary location using system tar" do
38
+ Puppet::Util.expects(:execute).with("tar xzf #{filename} -C #{build_dir}").returns(true)
39
+ unpacker.run
40
+ end
41
+ end
42
+
43
+ context "on solaris" do
44
+ before :each do
45
+ Facter.expects(:value).with("operatingsystem").returns("Solaris")
46
+ end
47
+
48
+ it "should attempt to untar file to temporary location using gnu tar" do
49
+ Puppet::Util.stubs(:which).with('gtar').returns('/usr/sfw/bin/gtar')
50
+ Puppet::Util.expects(:execute).with("gtar xzf #{filename} -C #{build_dir}").returns(true)
51
+ unpacker.run
52
+ end
53
+
54
+ it "should throw exception if gtar is not in the path exists" do
55
+ Puppet::Util.stubs(:which).with('gtar').returns(nil)
56
+ expect { unpacker.run }.to raise_error RuntimeError, "Cannot find the command 'gtar'. Make sure GNU tar is installed, and is in your PATH."
57
+ end
58
+ end
59
+ end
60
+
61
+ end
@@ -50,9 +50,9 @@ describe Puppet::Network::Handler::FileServer do
50
50
  config_file = tmpfile('fileserver.conf')
51
51
  File.open(config_file, 'w') { |f| f.puts "#{arg} 127.0.0.1/24" }
52
52
 
53
- expect {
54
- Puppet::Network::Handler::FileServer.new(:Config => config_file)
55
- }.should raise_error(Puppet::Network::Handler::FileServerError, "No mount specified for argument #{arg} 127.0.0.1/24")
53
+ expect {
54
+ Puppet::Network::Handler::FileServer.new(:Config => config_file)
55
+ }.to raise_error(Puppet::Network::Handler::FileServerError, "No mount specified for argument #{arg} 127.0.0.1/24")
56
56
  end
57
57
  end
58
58
  end
@@ -12,7 +12,7 @@ describe Puppet::TransBucket do
12
12
 
13
13
  resource = nil
14
14
  proc { resource = @bucket.to_ral }.should_not raise_error
15
- resource.should be_instance_of(Puppet::Type::Component)
15
+ resource.must be_instance_of(Puppet::Type::Component)
16
16
  resource.title.should == "Foo[luke]"
17
17
  end
18
18
 
@@ -93,7 +93,7 @@ describe Puppet::TransBucket, " when generating a catalog" do
93
93
  it "should convert all transportable objects to RAL resources" do
94
94
  @catalog = @top.to_catalog
95
95
  @users.each do |name|
96
- @catalog.vertices.find { |r| r.class.name == :notify and r.title == name }.should be_instance_of(Puppet::Type.type(:notify))
96
+ @catalog.vertices.find { |r| r.class.name == :notify and r.title == name }.must be_instance_of(Puppet::Type.type(:notify))
97
97
  end
98
98
  end
99
99
 
@@ -105,18 +105,15 @@ describe Puppet::TransBucket, " when generating a catalog" do
105
105
  it "should convert all transportable buckets to RAL components" do
106
106
  @catalog = @top.to_catalog
107
107
  @fakes.each do |name|
108
- @catalog.vertices.find { |r| r.class.name == :component and r.title == name }.should be_instance_of(Puppet::Type.type(:component))
108
+ @catalog.vertices.find { |r| r.class.name == :component and r.title == name }.must be_instance_of(Puppet::Type.type(:component))
109
109
  end
110
110
  end
111
111
 
112
112
  it "should add all resources to the graph's resource table" do
113
113
  @catalog = @top.to_catalog
114
- @catalog.resource("fake[top]").should equal(@top)
115
- end
116
-
117
- it "should finalize all resources" do
118
- @catalog = @top.to_catalog
119
- @catalog.vertices.each do |vertex| vertex.should be_finalized end
114
+ @fakes.each do |name|
115
+ @catalog.resource(name).must be
116
+ end
120
117
  end
121
118
 
122
119
  it "should only call to_ral on each resource once" do
@@ -41,6 +41,33 @@ describe Puppet::Parser::AST::Resource do
41
41
  result.should be_include("two")
42
42
  end
43
43
 
44
+
45
+ [5, 5.0, true, false, :three, "foo"].each do |title|
46
+ it "should stringify the title if it is a #{title.class}" do
47
+ @instance.title.stubs(:safeevaluate).returns title
48
+
49
+ result = @resource.evaluate(@scope).map(&:title)
50
+ result.first.should == title.to_s
51
+ end
52
+ end
53
+
54
+ [
55
+ {:a => 1},
56
+ /noway/i,
57
+ Puppet::Resource.new(:notify, "something"),
58
+ Pathname.new("foo"),
59
+ (1..50),
60
+ nil,
61
+ ].each do |title|
62
+ it "should fail if the title is a #{title.class}" do
63
+ @instance.title.stubs(:safeevaluate).returns title
64
+
65
+ expect do
66
+ @resource.evaluate(@scope)
67
+ end.to raise_error(Puppet::ParseError, /Resource title must be a String, not #{title.class}/)
68
+ end
69
+ end
70
+
44
71
  it "should create and return one resource objects per title" do
45
72
  titles = []
46
73
  %w{one two}.each do |title|
@@ -19,8 +19,8 @@ describe 'function for dynamically creating resources' do
19
19
  end
20
20
 
21
21
  it 'should require two or three arguments' do
22
- expect { @scope.function_create_resources(['foo']) }.should raise_error(ArgumentError, 'create_resources(): wrong number of arguments (1; must be 2 or 3)')
23
- expect { @scope.function_create_resources(['foo', 'bar', 'blah', 'baz']) }.should raise_error(ArgumentError, 'create_resources(): wrong number of arguments (4; must be 2 or 3)')
22
+ expect { @scope.function_create_resources(['foo']) }.to raise_error(ArgumentError, 'create_resources(): wrong number of arguments (1; must be 2 or 3)')
23
+ expect { @scope.function_create_resources(['foo', 'bar', 'blah', 'baz']) }.to raise_error(ArgumentError, 'create_resources(): wrong number of arguments (4; must be 2 or 3)')
24
24
  end
25
25
 
26
26
  describe 'when the caller does not supply a name parameter' do
@@ -57,7 +57,7 @@ describe 'function for dynamically creating resources' do
57
57
  end
58
58
 
59
59
  it 'should fail to add non-existing type' do
60
- expect { @scope.function_create_resources(['create-resource-foo', {}]) }.should raise_error(ArgumentError, 'could not create resource of unknown type create-resource-foo')
60
+ expect { @scope.function_create_resources(['create-resource-foo', {}]) }.to raise_error(ArgumentError, 'could not create resource of unknown type create-resource-foo')
61
61
  end
62
62
 
63
63
  it 'should be able to add edges' do
@@ -65,8 +65,8 @@ describe 'function for dynamically creating resources' do
65
65
  rg = catalog.to_ral.relationship_graph
66
66
  test = rg.vertices.find { |v| v.title == 'test' }
67
67
  foo = rg.vertices.find { |v| v.title == 'foo' }
68
- test.should be
69
- foo.should be
68
+ test.must be
69
+ foo.must be
70
70
  rg.path_between(test,foo).should be
71
71
  end
72
72
 
@@ -89,7 +89,7 @@ describe 'function for dynamically creating resources' do
89
89
  end
90
90
 
91
91
  it 'should fail if defines are missing params' do
92
- expect {
92
+ expect {
93
93
  compile_to_catalog(<<-MANIFEST)
94
94
  define foocreateresource($one) {
95
95
  notify { $name: message => $one }
@@ -97,7 +97,7 @@ describe 'function for dynamically creating resources' do
97
97
 
98
98
  create_resources('foocreateresource', {'blah'=>{}})
99
99
  MANIFEST
100
- }.should raise_error(Puppet::Error, 'Must pass one to Foocreateresource[blah] at line 1 on node foonode')
100
+ }.to raise_error(Puppet::Error, 'Must pass one to Foocreateresource[blah] at line 1 on node foonode')
101
101
  end
102
102
 
103
103
  it 'should be able to add multiple defines' do
@@ -127,8 +127,8 @@ describe 'function for dynamically creating resources' do
127
127
  rg = catalog.to_ral.relationship_graph
128
128
  test = rg.vertices.find { |v| v.title == 'test' }
129
129
  blah = rg.vertices.find { |v| v.title == 'blah' }
130
- test.should be
131
- blah.should be
130
+ test.must be
131
+ blah.must be
132
132
  rg.path_between(test,blah).should be
133
133
  catalog.resource(:notify, "blah")['message'].should == 'two'
134
134
  end
@@ -165,7 +165,7 @@ describe 'function for dynamically creating resources' do
165
165
  compile_to_catalog(<<-MANIFEST)
166
166
  create_resources('class', {'blah'=>{'one'=>'two'}})
167
167
  MANIFEST
168
- }.should raise_error(Puppet::Error ,'could not find hostclass blah at line 1 on node foonode')
168
+ }.to raise_error(Puppet::Error ,'could not find hostclass blah at line 1 on node foonode')
169
169
  end
170
170
 
171
171
  it 'should be able to add edges' do
@@ -182,8 +182,8 @@ describe 'function for dynamically creating resources' do
182
182
  rg = catalog.to_ral.relationship_graph
183
183
  test = rg.vertices.find { |v| v.title == 'test' }
184
184
  tester = rg.vertices.find { |v| v.title == 'tester' }
185
- test.should be
186
- tester.should be
185
+ test.must be
186
+ tester.must be
187
187
  rg.path_between(tester,test).should be
188
188
  end
189
189