puppet 4.1.0-x86-mingw32 → 4.2.0-x86-mingw32

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 (117) hide show
  1. data/ext/osx/puppet.plist +32 -0
  2. data/ext/redhat/client.init +3 -6
  3. data/ext/redhat/client.sysconfig +1 -10
  4. data/ext/suse/client.init +3 -6
  5. data/ext/systemd/puppet.service +2 -1
  6. data/lib/puppet.rb +1 -1
  7. data/lib/puppet/agent.rb +4 -19
  8. data/lib/puppet/application/apply.rb +22 -6
  9. data/lib/puppet/configurer.rb +3 -2
  10. data/lib/puppet/configurer/plugin_handler.rb +6 -2
  11. data/lib/puppet/face/plugin.rb +7 -14
  12. data/lib/puppet/forge/repository.rb +1 -2
  13. data/lib/puppet/indirector/catalog/compiler.rb +4 -3
  14. data/lib/puppet/indirector/facts/facter.rb +8 -0
  15. data/lib/puppet/module.rb +17 -12
  16. data/lib/puppet/network/http/factory.rb +8 -4
  17. data/lib/puppet/node/environment.rb +11 -7
  18. data/lib/puppet/parser/ast/pops_bridge.rb +5 -0
  19. data/lib/puppet/parser/functions/fqdn_rand.rb +2 -2
  20. data/lib/puppet/parser/scope.rb +39 -13
  21. data/lib/puppet/pops.rb +1 -0
  22. data/lib/puppet/pops/evaluator/runtime3_converter.rb +1 -1
  23. data/lib/puppet/pops/evaluator/runtime3_support.rb +31 -0
  24. data/lib/puppet/pops/parser/epp_support.rb +4 -2
  25. data/lib/puppet/property/ensure.rb +1 -1
  26. data/lib/puppet/provider.rb +5 -0
  27. data/lib/puppet/provider/augeas/augeas.rb +5 -0
  28. data/lib/puppet/provider/group/pw.rb +1 -0
  29. data/lib/puppet/provider/group/windows_adsi.rb +9 -0
  30. data/lib/puppet/provider/mount/parsed.rb +15 -1
  31. data/lib/puppet/provider/package.rb +6 -2
  32. data/lib/puppet/provider/package/gem.rb +16 -0
  33. data/lib/puppet/provider/package/openbsd.rb +7 -7
  34. data/lib/puppet/provider/package/pacman.rb +9 -8
  35. data/lib/puppet/provider/package/pip.rb +1 -1
  36. data/lib/puppet/provider/package/pip3.rb +18 -0
  37. data/lib/puppet/provider/package/pkgdmg.rb +4 -2
  38. data/lib/puppet/provider/package/pkgin.rb +3 -3
  39. data/lib/puppet/provider/package/rpm.rb +8 -14
  40. data/lib/puppet/provider/package/yum.rb +5 -4
  41. data/lib/puppet/provider/service/base.rb +3 -2
  42. data/lib/puppet/provider/service/bsd.rb +7 -7
  43. data/lib/puppet/provider/service/debian.rb +2 -1
  44. data/lib/puppet/provider/service/freebsd.rb +1 -1
  45. data/lib/puppet/provider/service/systemd.rb +75 -6
  46. data/lib/puppet/provider/service/upstart.rb +1 -1
  47. data/lib/puppet/provider/user/pw.rb +1 -0
  48. data/lib/puppet/resource/catalog.rb +1 -1
  49. data/lib/puppet/resource/status.rb +9 -0
  50. data/lib/puppet/resource/type.rb +4 -2
  51. data/lib/puppet/settings.rb +43 -16
  52. data/lib/puppet/transaction.rb +27 -13
  53. data/lib/puppet/type/augeas.rb +1 -0
  54. data/lib/puppet/type/exec.rb +11 -2
  55. data/lib/puppet/type/group.rb +9 -1
  56. data/lib/puppet/type/mount.rb +2 -0
  57. data/lib/puppet/type/package.rb +13 -2
  58. data/lib/puppet/type/service.rb +9 -0
  59. data/lib/puppet/util.rb +8 -3
  60. data/lib/puppet/util/execution.rb +2 -2
  61. data/lib/puppet/util/http_proxy.rb +60 -0
  62. data/lib/puppet/util/log.rb +1 -1
  63. data/lib/puppet/util/splayer.rb +18 -0
  64. data/lib/puppet/version.rb +1 -1
  65. data/spec/fixtures/unit/provider/package/yum/yum-check-update-obsoletes.txt +195 -0
  66. data/spec/integration/application/apply_spec.rb +72 -30
  67. data/spec/integration/indirector/facts/facter_spec.rb +38 -0
  68. data/spec/integration/parser/scope_spec.rb +20 -2
  69. data/spec/integration/provider/mount_spec.rb +23 -36
  70. data/spec/integration/transaction_spec.rb +40 -1
  71. data/spec/integration/type/file_spec.rb +36 -0
  72. data/spec/integration/type/package_spec.rb +65 -0
  73. data/spec/lib/matchers/include_in_order.rb +0 -1
  74. data/spec/lib/puppet_spec/files.rb +14 -0
  75. data/spec/unit/agent_spec.rb +0 -38
  76. data/spec/unit/application/apply_spec.rb +13 -0
  77. data/spec/unit/configurer/plugin_handler_spec.rb +42 -13
  78. data/spec/unit/configurer_spec.rb +5 -0
  79. data/spec/unit/face/plugin_spec.rb +33 -4
  80. data/spec/unit/file_serving/configuration/parser_spec.rb +25 -30
  81. data/spec/unit/indirector/catalog/compiler_spec.rb +16 -0
  82. data/spec/unit/indirector/facts/facter_spec.rb +2 -1
  83. data/spec/unit/module_spec.rb +0 -23
  84. data/spec/unit/network/http/factory_spec.rb +14 -0
  85. data/spec/unit/parser/functions/fqdn_rand_spec.rb +6 -2
  86. data/spec/unit/parser/functions/generate_spec.rb +3 -12
  87. data/spec/unit/parser/scope_spec.rb +9 -0
  88. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +19 -0
  89. data/spec/unit/pops/evaluator/variables_spec.rb +1 -1
  90. data/spec/unit/pops/parser/lexer2_spec.rb +35 -3
  91. data/spec/unit/provider/augeas/augeas_spec.rb +9 -0
  92. data/spec/unit/provider/group/windows_adsi_spec.rb +5 -0
  93. data/spec/unit/provider/package/aptrpm_spec.rb +2 -2
  94. data/spec/unit/provider/package/base_spec.rb +18 -0
  95. data/spec/unit/provider/package/gem_spec.rb +70 -0
  96. data/spec/unit/provider/package/pacman_spec.rb +55 -0
  97. data/spec/unit/provider/package/pip3_spec.rb +257 -0
  98. data/spec/unit/provider/package/pip_spec.rb +1 -1
  99. data/spec/unit/provider/package/pkgdmg_spec.rb +18 -0
  100. data/spec/unit/provider/package/pkgin_spec.rb +23 -13
  101. data/spec/unit/provider/package/yum_spec.rb +11 -0
  102. data/spec/unit/provider/service/bsd_spec.rb +130 -0
  103. data/spec/unit/provider/service/debian_spec.rb +12 -1
  104. data/spec/unit/provider/service/freebsd_spec.rb +16 -0
  105. data/spec/unit/provider/service/systemd_spec.rb +84 -7
  106. data/spec/unit/provider/service/upstart_spec.rb +1 -0
  107. data/spec/unit/provider/zone/solaris_spec.rb +45 -12
  108. data/spec/unit/puppet_spec.rb +1 -1
  109. data/spec/unit/resource/catalog_spec.rb +5 -0
  110. data/spec/unit/type/mount_spec.rb +8 -0
  111. data/spec/unit/type/service_spec.rb +5 -0
  112. data/spec/unit/util/http_proxy_spec.rb +87 -0
  113. data/spec/unit/util/log_spec.rb +12 -1
  114. data/spec/unit/util/splayer_spec.rb +45 -0
  115. metadata +3071 -3035
  116. checksums.yaml +0 -7
  117. data/ext/systemd/puppetmaster.service +0 -11
@@ -1,5 +1,4 @@
1
1
  RSpec::Matchers.define :include_in_order do |*expected|
2
- include RSpec::Matchers::Pretty
3
2
 
4
3
  match do |actual|
5
4
  elements = expected.dup
@@ -43,6 +43,20 @@ module PuppetSpec::Files
43
43
  file
44
44
  end
45
45
 
46
+ def script_containing(name, contents) PuppetSpec::Files.script_containing(name, contents) end
47
+ def self.script_containing(name, contents)
48
+ file = tmpfile(name)
49
+ if Puppet.features.microsoft_windows?
50
+ file += '.bat'
51
+ text = contents[:windows]
52
+ else
53
+ text = contents[:posix]
54
+ end
55
+ File.open(file, 'wb') { |f| f.write(text) }
56
+ Puppet::FileSystem.chmod(0755, file)
57
+ file
58
+ end
59
+
46
60
  def tmpdir(name) PuppetSpec::Files.tmpdir(name) end
47
61
  def self.tmpdir(name)
48
62
  dir = Dir.mktmpdir(name)
@@ -234,44 +234,6 @@ describe Puppet::Agent do
234
234
  end
235
235
  end
236
236
 
237
- describe "when splaying" do
238
- before do
239
- Puppet[:splay] = true
240
- Puppet[:splaylimit] = "10"
241
- end
242
-
243
- it "should do nothing if splay is disabled" do
244
- Puppet[:splay] = false
245
- @agent.expects(:sleep).never
246
- @agent.splay
247
- end
248
-
249
- it "should do nothing if it has already splayed" do
250
- @agent.expects(:splayed?).returns true
251
- @agent.expects(:sleep).never
252
- @agent.splay
253
- end
254
-
255
- it "should log that it is splaying" do
256
- @agent.stubs :sleep
257
- Puppet.expects :info
258
- @agent.splay
259
- end
260
-
261
- it "should sleep for a random portion of the splaylimit plus 1" do
262
- Puppet[:splaylimit] = "50"
263
- @agent.expects(:rand).with(51).returns 10
264
- @agent.expects(:sleep).with(10)
265
- @agent.splay
266
- end
267
-
268
- it "should mark that it has splayed" do
269
- @agent.stubs(:sleep)
270
- @agent.splay
271
- expect(@agent).to be_splayed
272
- end
273
- end
274
-
275
237
  describe "when checking execution state" do
276
238
  describe 'with regular run status' do
277
239
  before :each do
@@ -120,6 +120,13 @@ describe Puppet::Application::Apply do
120
120
  expect { @apply.setup }.to exit_with 1
121
121
  end
122
122
 
123
+ it "should use :main, :puppetd, and :ssl" do
124
+ Puppet.settings.unstub(:use)
125
+ Puppet.settings.expects(:use).with(:main, :agent, :ssl)
126
+
127
+ @apply.setup
128
+ end
129
+
123
130
  it "should tell the report handler to cache locally as yaml" do
124
131
  Puppet::Transaction::Report.indirection.expects(:cache_class=).with(:yaml)
125
132
 
@@ -243,6 +250,12 @@ describe Puppet::Application::Apply do
243
250
  expect(msg.level).to eq(:warning)
244
251
  end
245
252
 
253
+ it "should splay" do
254
+ @apply.expects(:splay)
255
+
256
+ expect { @apply.main }.to exit_with 0
257
+ end
258
+
246
259
  it "should raise an error if we can't find the node" do
247
260
  Puppet::Node.indirection.expects(:find).returns(nil)
248
261
 
@@ -14,26 +14,55 @@ describe Puppet::Configurer::PluginHandler do
14
14
  Puppet.expects(:err).never
15
15
  end
16
16
 
17
- it "downloads plugins and facts" do
18
- Puppet.features.stubs(:external_facts?).returns(true)
17
+ context "when external facts are supported" do
18
+ before :each do
19
+ Puppet.features.stubs(:external_facts?).returns(true)
20
+ end
19
21
 
20
- plugin_downloader = stub('plugin-downloader', :evaluate => [])
21
- facts_downloader = stub('facts-downloader', :evaluate => [])
22
+ it "downloads plugins and facts" do
23
+ plugin_downloader = stub('plugin-downloader', :evaluate => [])
24
+ facts_downloader = stub('facts-downloader', :evaluate => [])
22
25
 
23
- factory.expects(:create_plugin_downloader).returns(plugin_downloader)
24
- factory.expects(:create_plugin_facts_downloader).returns(facts_downloader)
26
+ factory.expects(:create_plugin_downloader).returns(plugin_downloader)
27
+ factory.expects(:create_plugin_facts_downloader).returns(facts_downloader)
25
28
 
26
- pluginhandler.download_plugins(environment)
29
+ pluginhandler.download_plugins(environment)
30
+ end
31
+
32
+ it "returns downloaded plugin and fact filenames" do
33
+ plugin_downloader = stub('plugin-downloader', :evaluate => %w[/a])
34
+ facts_downloader = stub('facts-downloader', :evaluate => %w[/b])
35
+
36
+ factory.expects(:create_plugin_downloader).returns(plugin_downloader)
37
+ factory.expects(:create_plugin_facts_downloader).returns(facts_downloader)
38
+
39
+ expect(pluginhandler.download_plugins(environment)).to match_array(%w[/a /b])
40
+ end
27
41
  end
28
42
 
29
- it "skips facts if not enabled" do
30
- Puppet.features.stubs(:external_facts?).returns(false)
43
+ context "when external facts are not supported" do
44
+ before :each do
45
+ Puppet.features.stubs(:external_facts?).returns(false)
46
+ end
47
+
48
+ it "downloads plugins only" do
49
+ plugin_downloader = stub('plugin-downloader', :evaluate => [])
50
+
51
+ factory.expects(:create_plugin_downloader).returns(plugin_downloader)
52
+ factory.expects(:create_plugin_facts_downloader).never
53
+
54
+ pluginhandler.download_plugins(environment)
55
+ end
56
+
57
+ it "returns downloaded plugin filenames only" do
58
+ Puppet.features.stubs(:external_facts?).returns(false)
31
59
 
32
- plugin_downloader = stub('plugin-downloader', :evaluate => [])
60
+ plugin_downloader = stub('plugin-downloader', :evaluate => %w[/a])
61
+ facts_downloader = stub('facts-downloader')
33
62
 
34
- factory.expects(:create_plugin_downloader).returns(plugin_downloader)
35
- factory.expects(:create_plugin_facts_downloader).never
63
+ factory.expects(:create_plugin_downloader).returns(plugin_downloader)
36
64
 
37
- pluginhandler.download_plugins(environment)
65
+ expect(pluginhandler.download_plugins(environment)).to match_array(%w[/a])
66
+ end
38
67
  end
39
68
  end
@@ -531,6 +531,11 @@ describe Puppet::Configurer do
531
531
  Puppet::Node.indirection.expects(:find).with(anything, has_entries(:transaction_uuid => anything)).twice
532
532
  @agent.run
533
533
  end
534
+
535
+ it "sends the configured environment in the request" do
536
+ Puppet::Node.indirection.expects(:find).with(anything, has_entries(:configured_environment => Puppet[:environment])).twice
537
+ @agent.run
538
+ end
534
539
  end
535
540
 
536
541
  describe "when retrieving a catalog" do
@@ -2,9 +2,38 @@
2
2
  require 'spec_helper'
3
3
  require 'puppet/face'
4
4
 
5
- describe Puppet::Face[:plugin, '0.0.1'] do
6
- [:download].each do |action|
7
- it { is_expected.to be_action action }
8
- it { is_expected.to respond_to action }
5
+ describe Puppet::Face[:plugin, :current] do
6
+
7
+ let(:pluginface) { described_class }
8
+ let(:action) { pluginface.get_action(:download) }
9
+
10
+ def render(result)
11
+ action.when_rendering(:console).call(result)
12
+ end
13
+
14
+ context "download" do
15
+ before :each do
16
+ Puppet.features.stubs(:external_facts?).returns(true)
17
+ end
18
+
19
+ it "downloads plugins and external facts" do
20
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).twice.returns([])
21
+
22
+ pluginface.download
23
+ end
24
+
25
+ it "renders 'No plugins downloaded' if nothing was downloaded" do
26
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).twice.returns([])
27
+
28
+ result = pluginface.download
29
+ expect(render(result)).to eq('No plugins downloaded.')
30
+ end
31
+
32
+ it "renders comma separate list of downloaded file names" do
33
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).twice.returns(%w[/a]).then.returns(%w[/b])
34
+
35
+ result = pluginface.download
36
+ expect(render(result)).to eq('Downloaded these plugins: /a, /b')
37
+ end
9
38
  end
10
39
  end
@@ -33,16 +33,6 @@ describe Puppet::FileServing::Configuration::Parser do
33
33
  expect { @parser.parse }.not_to raise_error
34
34
  end
35
35
 
36
- it "should create a new mount for each section in the configuration" do
37
- mount1 = mock 'one', :validate => true
38
- mount2 = mock 'two', :validate => true
39
- Puppet::FileServing::Mount::File.expects(:new).with("one").returns(mount1)
40
- Puppet::FileServing::Mount::File.expects(:new).with("two").returns(mount2)
41
- write_config_file "[one]\n[two]\n"
42
- @parser.parse
43
- end
44
-
45
- # This test is almost the exact same as the previous one.
46
36
  it "should return a hash of the created mounts" do
47
37
  mount1 = mock 'one', :validate => true
48
38
  mount2 = mock 'two', :validate => true
@@ -108,29 +98,34 @@ describe Puppet::FileServing::Configuration::Parser do
108
98
  @parser.parse
109
99
  end
110
100
 
111
- it "should tell the mount to allow any allow values from the section" do
112
- write_config_file "[one]\nallow something\n"
101
+ [:allow,:deny].each { |acl_type|
102
+ it "should support inline comments in #{acl_type}" do
103
+ write_config_file "[one]\n#{acl_type} something \# will it work?\n"
113
104
 
114
105
  @mount.expects(:info)
115
- @mount.expects(:allow).with("something")
106
+ @mount.expects(acl_type).with("something")
116
107
  @parser.parse
117
- end
118
-
119
- it "should support inline comments" do
120
- write_config_file "[one]\nallow something \# will it work?\n"
121
-
122
- @mount.expects(:info)
123
- @mount.expects(:allow).with("something")
124
- @parser.parse
125
- end
126
-
127
- it "should tell the mount to deny any deny values from the section" do
128
- write_config_file "[one]\ndeny something\n"
129
-
130
- @mount.expects(:info)
131
- @mount.expects(:deny).with("something")
132
- @parser.parse
133
- end
108
+ end
109
+
110
+ it "should tell the mount to #{acl_type} from ACLs with varying spacing around commas" do
111
+ write_config_file "[one]\n#{acl_type} someone,sometwo, somethree , somefour ,somefive\n"
112
+
113
+ @mount.expects(:info).times(5)
114
+ @mount.expects(acl_type).times(5).with(any_of('someone','sometwo','somethree','somefour','somefive'))
115
+ @parser.parse
116
+ end
117
+
118
+ # each ip, with glob in the various octet positions
119
+ ['100','4','42','*'].permutation.map {|permutes| permutes.join('.') }.each { |ip_pattern|
120
+ it "should tell the mount to #{acl_type} from ACLs with glob at #{ip_pattern}" do
121
+ write_config_file "[one]\n#{acl_type} #{ip_pattern}\n"
122
+
123
+ @mount.expects(:info)
124
+ @mount.expects(acl_type).with(ip_pattern)
125
+ @parser.parse
126
+ end
127
+ }
128
+ }
134
129
 
135
130
  it "should return comprehensible error message, if failed on invalid attribute" do
136
131
  write_config_file "[one]\ndo something\n"
@@ -200,6 +200,22 @@ describe Puppet::Resource::Catalog::Compiler do
200
200
 
201
201
  compiler.find(request)
202
202
  end
203
+
204
+ it "should pass the configured_environment to the node indirection" do
205
+ environment = 'foo'
206
+ node = Puppet::Node.new("thing")
207
+ compiler = Puppet::Resource::Catalog::Compiler.new
208
+ compiler.stubs(:compile)
209
+ request = Puppet::Indirector::Request.new(:catalog, :find, "thing",
210
+ nil, :configured_environment => environment)
211
+
212
+ Puppet::Node.indirection.expects(:find).with(
213
+ "thing",
214
+ has_entries(:configured_environment => environment)
215
+ ).returns(node)
216
+
217
+ compiler.find(request)
218
+ end
203
219
  end
204
220
 
205
221
  describe "after finding nodes" do
@@ -43,10 +43,11 @@ describe Puppet::Node::Facts::Facter do
43
43
  @facter.find(@request)
44
44
  end
45
45
 
46
- it 'should add the puppetversion fact' do
46
+ it 'should add the puppetversion and agent_specified_environment facts' do
47
47
  reset = sequence 'reset'
48
48
  Facter.expects(:reset).in_sequence(reset)
49
49
  Facter.expects(:add).with(:puppetversion)
50
+ Facter.expects(:add).with(:agent_specified_environment)
50
51
  @facter.find(@request)
51
52
  end
52
53
 
@@ -132,23 +132,6 @@ describe Puppet::Module do
132
132
  mod.description = "GPL2"
133
133
  expect(mod.description).to eq("GPL2")
134
134
  end
135
-
136
- it "should support specifying a compatible puppet version" do
137
- mod.puppetversion = "0.25"
138
- expect(mod.puppetversion).to eq("0.25")
139
- end
140
- end
141
-
142
- it "should validate that the puppet version is compatible" do
143
- mod.puppetversion = "0.25"
144
- Puppet.expects(:version).returns "0.25"
145
- mod.validate_puppet_version
146
- end
147
-
148
- it "should fail if the specified puppet version is not compatible" do
149
- mod.puppetversion = "0.25"
150
- Puppet.stubs(:version).returns "0.24"
151
- expect { mod.validate_puppet_version }.to raise_error(Puppet::Module::IncompatibleModule)
152
135
  end
153
136
 
154
137
  describe "when finding unmet dependencies" do
@@ -670,7 +653,6 @@ describe Puppet::Module do
670
653
  :author => "luke",
671
654
  :version => "1.0",
672
655
  :source => "http://foo/",
673
- :puppetversion => "0.25",
674
656
  :dependencies => []
675
657
  }
676
658
  @module = a_module_with_metadata(@data)
@@ -692,11 +674,6 @@ describe Puppet::Module do
692
674
  )
693
675
  end
694
676
  end
695
-
696
- it "should set puppetversion if present in the metadata file" do
697
- @module.load_metadata
698
- expect(@module.puppetversion).to eq(@data[:puppetversion])
699
- end
700
677
  end
701
678
 
702
679
  it "should be able to tell if there are local changes" do
@@ -1,6 +1,7 @@
1
1
  #! /usr/bin/env ruby
2
2
  require 'spec_helper'
3
3
  require 'puppet/network/http'
4
+ require 'puppet/util/http_proxy'
4
5
 
5
6
  describe Puppet::Network::HTTP::Factory do
6
7
  before :each do
@@ -41,13 +42,25 @@ describe Puppet::Network::HTTP::Factory do
41
42
 
42
43
  it "should not set a proxy if the value is 'none'" do
43
44
  Puppet[:http_proxy_host] = 'none'
45
+ Puppet::Util::HttpProxy.expects(:no_proxy?).returns false
44
46
  conn = create_connection(site)
45
47
 
46
48
  expect(conn.proxy_address).to be_nil
47
49
  end
48
50
 
51
+ it 'should not set a proxy if a no_proxy env var matches the destination' do
52
+ Puppet[:http_proxy_host] = proxy_host
53
+ Puppet[:http_proxy_port] = proxy_port
54
+ Puppet::Util::HttpProxy.expects(:no_proxy?).returns true
55
+ conn = create_connection(site)
56
+
57
+ expect(conn.proxy_address).to be_nil
58
+ expect(conn.proxy_port).to be_nil
59
+ end
60
+
49
61
  it 'sets proxy_address' do
50
62
  Puppet[:http_proxy_host] = proxy_host
63
+ Puppet::Util::HttpProxy.expects(:no_proxy?).returns false
51
64
  conn = create_connection(site)
52
65
 
53
66
  expect(conn.proxy_address).to eq(proxy_host)
@@ -56,6 +69,7 @@ describe Puppet::Network::HTTP::Factory do
56
69
  it 'sets proxy address and port' do
57
70
  Puppet[:http_proxy_host] = proxy_host
58
71
  Puppet[:http_proxy_port] = proxy_port
72
+ Puppet::Util::HttpProxy.expects(:no_proxy?).returns false
59
73
  conn = create_connection(site)
60
74
 
61
75
  expect(conn.proxy_port).to eq(proxy_port)
@@ -4,9 +4,13 @@ require 'puppet_spec/scope'
4
4
 
5
5
  describe "the fqdn_rand function" do
6
6
  include PuppetSpec::Scope
7
-
7
+
8
+ it "returns an integer" do
9
+ expect(fqdn_rand(3)).to be_an(Integer)
10
+ end
11
+
8
12
  it "provides a random number strictly less than the given max" do
9
- expect(fqdn_rand(3)).to satisfy {|n| n.to_i < 3 }
13
+ expect(fqdn_rand(3)).to satisfy {|n| n < 3 }
10
14
  end
11
15
 
12
16
  it "provides the same 'random' value on subsequent calls for the same host" do
@@ -92,18 +92,9 @@ describe "the generate function" do
92
92
  end
93
93
 
94
94
  let :command do
95
- cmd = tmpfile('function_generate')
96
-
97
- if Puppet.features.microsoft_windows?
98
- cmd += '.bat'
99
- text = '@echo off' + "\n" + 'echo a-%1 b-%2'
100
- else
101
- text = '#!/bin/sh' + "\n" + 'echo a-$1 b-$2'
102
- end
103
-
104
- File.open(cmd, 'w') {|fh| fh.puts text }
105
- File.chmod 0700, cmd
106
- cmd
95
+ script_containing('function_generate',
96
+ :windows => '@echo off' + "\n" + 'echo a-%1 b-%2',
97
+ :posix => '#!/bin/sh' + "\n" + 'echo a-$1 b-$2')
107
98
  end
108
99
 
109
100
  after :each do