puppet 2.7.3 → 2.7.4

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 (337) hide show
  1. data/CHANGELOG +166 -0
  2. data/install.rb +27 -7
  3. data/lib/puppet/application/agent.rb +29 -29
  4. data/lib/puppet/application/doc.rb +1 -1
  5. data/lib/puppet/application/inspect.rb +9 -1
  6. data/lib/puppet/application/master.rb +2 -0
  7. data/lib/puppet/application/queue.rb +1 -1
  8. data/lib/puppet/application/resource.rb +3 -0
  9. data/lib/puppet/application.rb +4 -5
  10. data/lib/puppet/configurer.rb +1 -4
  11. data/lib/puppet/defaults.rb +45 -15
  12. data/lib/puppet/feature/base.rb +28 -17
  13. data/lib/puppet/feature/rails.rb +0 -3
  14. data/lib/puppet/feature/rubygems.rb +0 -3
  15. data/lib/puppet/file_bucket/dipper.rb +3 -2
  16. data/lib/puppet/file_bucket/file.rb +3 -3
  17. data/lib/puppet/file_serving/base.rb +4 -5
  18. data/lib/puppet/file_serving/configuration.rb +7 -13
  19. data/lib/puppet/file_serving/content.rb +0 -4
  20. data/lib/puppet/file_serving/fileset.rb +7 -6
  21. data/lib/puppet/file_serving/indirection_hooks.rb +1 -4
  22. data/lib/puppet/file_serving/metadata.rb +0 -4
  23. data/lib/puppet/file_serving/mount/file.rb +9 -12
  24. data/lib/puppet/file_serving/mount.rb +0 -5
  25. data/lib/puppet/file_serving/terminus_helper.rb +0 -4
  26. data/lib/puppet/file_serving.rb +0 -4
  27. data/lib/puppet/indirector/catalog/compiler.rb +0 -18
  28. data/lib/puppet/indirector/catalog/store_configs.rb +5 -0
  29. data/lib/puppet/indirector/direct_file_server.rb +0 -4
  30. data/lib/puppet/indirector/facts/facter.rb +2 -2
  31. data/lib/puppet/indirector/facts/store_configs.rb +5 -0
  32. data/lib/puppet/indirector/file_content/file.rb +0 -4
  33. data/lib/puppet/indirector/file_content/file_server.rb +0 -4
  34. data/lib/puppet/indirector/file_content/rest.rb +0 -4
  35. data/lib/puppet/indirector/file_metadata/file.rb +0 -4
  36. data/lib/puppet/indirector/file_metadata/file_server.rb +0 -4
  37. data/lib/puppet/indirector/file_metadata/rest.rb +0 -4
  38. data/lib/puppet/indirector/file_server.rb +1 -5
  39. data/lib/puppet/indirector/indirection.rb +3 -5
  40. data/lib/puppet/indirector/node/store_configs.rb +5 -0
  41. data/lib/puppet/indirector/request.rb +3 -1
  42. data/lib/puppet/indirector/resource/active_record.rb +97 -0
  43. data/lib/puppet/indirector/resource/store_configs.rb +3 -0
  44. data/lib/puppet/indirector/ssl_file.rb +5 -1
  45. data/lib/puppet/indirector/store_configs.rb +30 -0
  46. data/lib/puppet/indirector/yaml.rb +5 -0
  47. data/lib/puppet/indirector.rb +7 -0
  48. data/lib/puppet/network/client.rb +0 -5
  49. data/lib/puppet/network/http_pool.rb +0 -56
  50. data/lib/puppet/node/environment.rb +9 -11
  51. data/lib/puppet/parameter/path.rb +1 -5
  52. data/lib/puppet/parameter.rb +1 -7
  53. data/lib/puppet/parser/ast/collection.rb +2 -2
  54. data/lib/puppet/parser/ast/collexpr.rb +10 -39
  55. data/lib/puppet/parser/collector.rb +41 -90
  56. data/lib/puppet/parser/compiler.rb +0 -3
  57. data/lib/puppet/parser/functions/create_resources.rb +22 -10
  58. data/lib/puppet/parser/functions/versioncmp.rb +9 -6
  59. data/lib/puppet/parser/resource.rb +1 -1
  60. data/lib/puppet/parser/type_loader.rb +2 -1
  61. data/lib/puppet/provider/augeas/augeas.rb +5 -3
  62. data/lib/puppet/provider/cron/crontab.rb +2 -2
  63. data/lib/puppet/provider/exec/posix.rb +23 -96
  64. data/lib/puppet/provider/exec/shell.rb +11 -2
  65. data/lib/puppet/provider/exec/windows.rb +35 -0
  66. data/lib/puppet/provider/exec.rb +79 -0
  67. data/lib/puppet/provider/group/windows_adsi.rb +48 -0
  68. data/lib/puppet/provider/host/parsed.rb +3 -0
  69. data/lib/puppet/provider/macauthorization/macauthorization.rb +4 -4
  70. data/lib/puppet/provider/mount.rb +0 -3
  71. data/lib/puppet/provider/naginator.rb +0 -3
  72. data/lib/puppet/provider/package/appdmg.rb +0 -1
  73. data/lib/puppet/provider/package/apple.rb +3 -7
  74. data/lib/puppet/provider/package/apt.rb +0 -1
  75. data/lib/puppet/provider/package/aptitude.rb +0 -1
  76. data/lib/puppet/provider/package/aptrpm.rb +0 -1
  77. data/lib/puppet/provider/package/blastwave.rb +0 -1
  78. data/lib/puppet/provider/package/dpkg.rb +5 -6
  79. data/lib/puppet/provider/package/fink.rb +3 -4
  80. data/lib/puppet/provider/package/freebsd.rb +0 -1
  81. data/lib/puppet/provider/package/gem.rb +0 -1
  82. data/lib/puppet/provider/package/hpux.rb +3 -3
  83. data/lib/puppet/provider/package/macports.rb +0 -1
  84. data/lib/puppet/provider/package/msi.rb +82 -0
  85. data/lib/puppet/provider/package/openbsd.rb +18 -19
  86. data/lib/puppet/provider/package/pip.rb +0 -1
  87. data/lib/puppet/provider/package/pkg.rb +0 -1
  88. data/lib/puppet/provider/package/pkgdmg.rb +9 -7
  89. data/lib/puppet/provider/package/pkgutil.rb +0 -1
  90. data/lib/puppet/provider/package/ports.rb +0 -1
  91. data/lib/puppet/provider/package/portupgrade.rb +183 -193
  92. data/lib/puppet/provider/package/rpm.rb +1 -1
  93. data/lib/puppet/provider/package/sun.rb +0 -1
  94. data/lib/puppet/provider/package/sunfreeware.rb +0 -2
  95. data/lib/puppet/provider/package/up2date.rb +0 -1
  96. data/lib/puppet/provider/package/urpmi.rb +0 -1
  97. data/lib/puppet/provider/package/yum.rb +1 -1
  98. data/lib/puppet/provider/package.rb +4 -3
  99. data/lib/puppet/provider/service/systemd.rb +64 -0
  100. data/lib/puppet/provider/service/windows.rb +110 -0
  101. data/lib/puppet/provider/user/windows_adsi.rb +71 -0
  102. data/lib/puppet/rails/resource.rb +1 -1
  103. data/lib/puppet/relationship.rb +0 -3
  104. data/lib/puppet/reports/tagmail.rb +15 -11
  105. data/lib/puppet/resource/catalog.rb +17 -24
  106. data/lib/puppet/ssl/certificate_authority.rb +7 -5
  107. data/lib/puppet/ssl/host.rb +6 -10
  108. data/lib/puppet/type/augeas.rb +19 -13
  109. data/lib/puppet/type/cron.rb +13 -12
  110. data/lib/puppet/type/exec.rb +17 -17
  111. data/lib/puppet/type/file/content.rb +7 -3
  112. data/lib/puppet/type/file/source.rb +14 -9
  113. data/lib/puppet/type/file.rb +44 -23
  114. data/lib/puppet/type/filebucket.rb +13 -5
  115. data/lib/puppet/type/package.rb +14 -1
  116. data/lib/puppet/type/service.rb +11 -1
  117. data/lib/puppet/type/ssh_authorized_key.rb +3 -1
  118. data/lib/puppet/type.rb +8 -17
  119. data/lib/puppet/util/adsi.rb +278 -0
  120. data/lib/puppet/util/autoload.rb +0 -2
  121. data/lib/puppet/util/cacher.rb +15 -67
  122. data/lib/puppet/util/feature.rb +0 -3
  123. data/lib/puppet/util/graph.rb +0 -3
  124. data/lib/puppet/util/ldap/connection.rb +0 -3
  125. data/lib/puppet/util/ldap/generator.rb +0 -3
  126. data/lib/puppet/util/ldap.rb +0 -3
  127. data/lib/puppet/util/log_paths.rb +0 -3
  128. data/lib/puppet/util/network_device/cisco/device.rb +2 -1
  129. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  130. data/lib/puppet/util/pidlock.rb +5 -1
  131. data/lib/puppet/util/rdoc/parser.rb +3 -1
  132. data/lib/puppet/util/run_mode.rb +2 -2
  133. data/lib/puppet/util/settings/file_setting.rb +3 -2
  134. data/lib/puppet/util/settings.rb +4 -6
  135. data/lib/puppet/util/suidmanager.rb +62 -15
  136. data/lib/puppet/util.rb +113 -131
  137. data/lib/puppet.rb +1 -1
  138. data/spec/integration/application/doc_spec.rb +1 -1
  139. data/spec/integration/defaults_spec.rb +22 -17
  140. data/spec/integration/file_serving/content_spec.rb +0 -6
  141. data/spec/integration/file_serving/metadata_spec.rb +0 -6
  142. data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
  143. data/spec/integration/indirector/direct_file_server_spec.rb +5 -7
  144. data/spec/integration/indirector/file_content/file_server_spec.rb +2 -6
  145. data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -5
  146. data/spec/integration/network/server/webrick_spec.rb +6 -9
  147. data/spec/integration/node/facts_spec.rb +0 -6
  148. data/spec/integration/node_spec.rb +3 -4
  149. data/spec/integration/parser/compiler_spec.rb +2 -1
  150. data/spec/integration/parser/parser_spec.rb +2 -4
  151. data/spec/integration/provider/mount_spec.rb +1 -1
  152. data/spec/integration/provider/package_spec.rb +13 -3
  153. data/spec/integration/provider/ssh_authorized_key_spec.rb +4 -4
  154. data/spec/integration/reports_spec.rb +0 -4
  155. data/spec/integration/resource/catalog_spec.rb +0 -5
  156. data/spec/integration/ssl/certificate_authority_spec.rb +6 -14
  157. data/spec/integration/ssl/certificate_request_spec.rb +10 -17
  158. data/spec/integration/ssl/certificate_revocation_list_spec.rb +8 -13
  159. data/spec/integration/ssl/host_spec.rb +8 -14
  160. data/spec/integration/transaction/report_spec.rb +0 -5
  161. data/spec/integration/transaction_spec.rb +11 -13
  162. data/spec/integration/type/file_spec.rb +16 -16
  163. data/spec/integration/type/tidy_spec.rb +1 -1
  164. data/spec/integration/util/settings_spec.rb +2 -2
  165. data/spec/integration/util_spec.rb +13 -0
  166. data/spec/lib/puppet_spec/files.rb +18 -10
  167. data/spec/shared_behaviours/file_server_terminus.rb +1 -5
  168. data/spec/shared_behaviours/file_serving.rb +0 -4
  169. data/spec/shared_behaviours/memory_terminus.rb +0 -4
  170. data/spec/shared_behaviours/path_parameters.rb +20 -18
  171. data/spec/shared_behaviours/store_configs_terminus.rb +21 -0
  172. data/spec/spec_helper.rb +31 -0
  173. data/spec/unit/agent_spec.rb +0 -4
  174. data/spec/unit/application/apply_spec.rb +8 -2
  175. data/spec/unit/application/certificate_spec.rb +2 -0
  176. data/spec/unit/application/device_spec.rb +8 -6
  177. data/spec/unit/application/inspect_spec.rb +2 -1
  178. data/spec/unit/application/master_spec.rb +7 -2
  179. data/spec/unit/application/queue_spec.rb +3 -4
  180. data/spec/unit/application/resource_spec.rb +26 -0
  181. data/spec/unit/application/secret_agent_spec.rb +3 -1
  182. data/spec/unit/application_spec.rb +4 -0
  183. data/spec/unit/configurer/downloader_spec.rb +4 -3
  184. data/spec/unit/configurer_spec.rb +11 -4
  185. data/spec/unit/daemon_spec.rb +3 -1
  186. data/spec/unit/face/ca_spec.rb +1 -1
  187. data/spec/unit/face/node_spec.rb +5 -1
  188. data/spec/unit/face/secret_agent_spec.rb +3 -1
  189. data/spec/unit/file_bucket/dipper_spec.rb +4 -4
  190. data/spec/unit/file_bucket/file_spec.rb +9 -3
  191. data/spec/unit/file_serving/configuration_spec.rb +26 -37
  192. data/spec/unit/file_serving/fileset_spec.rb +71 -55
  193. data/spec/unit/file_serving/indirection_hooks_spec.rb +0 -4
  194. data/spec/unit/file_serving/mount/file_spec.rb +163 -169
  195. data/spec/unit/file_serving/terminus_helper_spec.rb +0 -4
  196. data/spec/unit/indirector/catalog/compiler_spec.rb +0 -22
  197. data/spec/unit/indirector/catalog/store_configs_spec.rb +17 -0
  198. data/spec/unit/indirector/certificate/ca_spec.rb +0 -4
  199. data/spec/unit/indirector/certificate/file_spec.rb +0 -4
  200. data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -5
  201. data/spec/unit/indirector/certificate_request/file_spec.rb +0 -4
  202. data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -4
  203. data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -4
  204. data/spec/unit/indirector/certificate_status/file_spec.rb +1 -1
  205. data/spec/unit/indirector/direct_file_server_spec.rb +0 -4
  206. data/spec/unit/indirector/facts/facter_spec.rb +0 -4
  207. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +3 -0
  208. data/spec/unit/indirector/facts/store_configs_spec.rb +17 -0
  209. data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
  210. data/spec/unit/indirector/file_content/file_server_spec.rb +0 -4
  211. data/spec/unit/indirector/file_content/file_spec.rb +0 -4
  212. data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -4
  213. data/spec/unit/indirector/file_metadata/file_spec.rb +0 -4
  214. data/spec/unit/indirector/file_server_spec.rb +1 -5
  215. data/spec/unit/indirector/indirection_spec.rb +0 -4
  216. data/spec/unit/indirector/key/ca_spec.rb +0 -4
  217. data/spec/unit/indirector/key/file_spec.rb +0 -4
  218. data/spec/unit/indirector/node/store_configs_spec.rb +16 -0
  219. data/spec/unit/indirector/report/processor_spec.rb +0 -4
  220. data/spec/unit/indirector/resource/active_record_spec.rb +192 -0
  221. data/spec/unit/indirector/resource/ral_spec.rb +1 -1
  222. data/spec/unit/indirector/resource/store_configs_spec.rb +12 -0
  223. data/spec/unit/indirector/resource_type/parser_spec.rb +3 -3
  224. data/spec/unit/indirector/ssl_file_spec.rb +25 -6
  225. data/spec/unit/indirector/store_configs_spec.rb +8 -0
  226. data/spec/unit/indirector/yaml_spec.rb +14 -0
  227. data/spec/unit/module_spec.rb +2 -2
  228. data/spec/unit/network/handler/fileserver_spec.rb +5 -5
  229. data/spec/unit/network/http/mongrel_spec.rb +0 -4
  230. data/spec/unit/network/http/webrick_spec.rb +5 -9
  231. data/spec/unit/network/http_pool_spec.rb +4 -75
  232. data/spec/unit/network/http_spec.rb +0 -4
  233. data/spec/unit/network/server_spec.rb +0 -4
  234. data/spec/unit/node/environment_spec.rb +18 -31
  235. data/spec/unit/node/facts_spec.rb +0 -4
  236. data/spec/unit/node_spec.rb +1 -8
  237. data/spec/unit/other/selinux_spec.rb +3 -1
  238. data/spec/unit/parameter_spec.rb +0 -10
  239. data/spec/unit/parser/ast/collexpr_spec.rb +17 -13
  240. data/spec/unit/parser/collector_spec.rb +147 -263
  241. data/spec/unit/parser/compiler_spec.rb +3 -1
  242. data/spec/unit/parser/files_spec.rb +7 -4
  243. data/spec/unit/parser/functions/extlookup_spec.rb +6 -3
  244. data/spec/unit/parser/functions/sprintf_spec.rb +2 -1
  245. data/spec/unit/parser/type_loader_spec.rb +7 -7
  246. data/spec/unit/property_spec.rb +1 -1
  247. data/spec/unit/provider/augeas/augeas_spec.rb +14 -0
  248. data/spec/unit/provider/exec/posix_spec.rb +102 -106
  249. data/spec/unit/provider/exec/shell_spec.rb +1 -1
  250. data/spec/unit/provider/exec/windows_spec.rb +119 -0
  251. data/spec/unit/provider/group/ldap_spec.rb +0 -4
  252. data/spec/unit/provider/group/windows_adsi_spec.rb +79 -0
  253. data/spec/unit/provider/ldap_spec.rb +0 -4
  254. data/spec/unit/provider/macauthorization_spec.rb +5 -0
  255. data/spec/unit/provider/mount/parsed_spec.rb +1 -5
  256. data/spec/unit/provider/package/msi_spec.rb +170 -0
  257. data/spec/unit/provider/service/redhat_spec.rb +2 -0
  258. data/spec/unit/provider/service/smf_spec.rb +3 -0
  259. data/spec/unit/provider/service/systemd_spec.rb +25 -0
  260. data/spec/unit/provider/service/windows_spec.rb +166 -0
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
  262. data/spec/unit/provider/user/ldap_spec.rb +0 -4
  263. data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
  264. data/spec/unit/provider/user/useradd_spec.rb +1 -1
  265. data/spec/unit/provider/user/windows_adsi_spec.rb +110 -0
  266. data/spec/unit/relationship_spec.rb +0 -4
  267. data/spec/unit/resource/catalog_spec.rb +37 -25
  268. data/spec/unit/resource/status_spec.rb +4 -2
  269. data/spec/unit/resource_spec.rb +5 -5
  270. data/spec/unit/simple_graph_spec.rb +0 -4
  271. data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
  272. data/spec/unit/ssl/host_spec.rb +12 -13
  273. data/spec/unit/ssl/inventory_spec.rb +2 -2
  274. data/spec/unit/sslcertificates/ca_spec.rb +6 -10
  275. data/spec/unit/transaction/event_manager_spec.rb +4 -2
  276. data/spec/unit/transaction/event_spec.rb +3 -1
  277. data/spec/unit/transaction/report_spec.rb +2 -6
  278. data/spec/unit/transaction/resource_harness_spec.rb +9 -5
  279. data/spec/unit/transaction_spec.rb +3 -1
  280. data/spec/unit/type/cron_spec.rb +1 -1
  281. data/spec/unit/type/exec_spec.rb +80 -47
  282. data/spec/unit/type/file/checksum_spec.rb +9 -8
  283. data/spec/unit/type/file/content_spec.rb +2 -1
  284. data/spec/unit/type/file/selinux_spec.rb +10 -8
  285. data/spec/unit/type/file/source_spec.rb +18 -36
  286. data/spec/unit/type/file_spec.rb +170 -217
  287. data/spec/unit/type/group_spec.rb +1 -1
  288. data/spec/unit/type/mount_spec.rb +5 -5
  289. data/spec/unit/type/noop_metaparam_spec.rb +3 -1
  290. data/spec/unit/type/package_spec.rb +15 -3
  291. data/spec/unit/type/resources_spec.rb +2 -2
  292. data/spec/unit/type/service_spec.rb +19 -4
  293. data/spec/unit/type/ssh_authorized_key_spec.rb +10 -4
  294. data/spec/unit/type/tidy_spec.rb +3 -1
  295. data/spec/unit/type/user_spec.rb +1 -1
  296. data/spec/unit/type_spec.rb +29 -34
  297. data/spec/unit/util/adsi_spec.rb +202 -0
  298. data/spec/unit/util/autoload_spec.rb +23 -19
  299. data/spec/unit/util/backups_spec.rb +16 -13
  300. data/spec/unit/util/cacher_spec.rb +64 -141
  301. data/spec/unit/util/checksums_spec.rb +0 -4
  302. data/spec/unit/util/constant_inflector_spec.rb +0 -4
  303. data/spec/unit/util/execution_stub_spec.rb +1 -1
  304. data/spec/unit/util/ldap/connection_spec.rb +0 -4
  305. data/spec/unit/util/ldap/generator_spec.rb +0 -4
  306. data/spec/unit/util/ldap/manager_spec.rb +0 -4
  307. data/spec/unit/util/log_spec.rb +4 -2
  308. data/spec/unit/util/logging_spec.rb +2 -2
  309. data/spec/unit/util/nagios_maker_spec.rb +0 -4
  310. data/spec/unit/util/network_device/cisco/device_spec.rb +2 -1
  311. data/spec/unit/util/network_device/cisco/facts_spec.rb +3 -1
  312. data/spec/unit/util/network_device/config_spec.rb +5 -3
  313. data/spec/unit/util/rdoc/parser_spec.rb +7 -1
  314. data/spec/unit/util/run_mode_spec.rb +6 -2
  315. data/spec/unit/util/settings/file_setting_spec.rb +29 -2
  316. data/spec/unit/util/settings_spec.rb +28 -15
  317. data/spec/unit/util/storage_spec.rb +1 -1
  318. data/spec/unit/util/suidmanager_spec.rb +310 -0
  319. data/spec/unit/util/tagging_spec.rb +0 -4
  320. data/spec/unit/util_spec.rb +335 -0
  321. data/test/language/ast/variable.rb +0 -4
  322. data/test/lib/puppettest/support/resources.rb +0 -4
  323. data/test/lib/puppettest/testcase.rb +0 -4
  324. data/test/lib/puppettest.rb +0 -1
  325. data/test/network/handler/master.rb +0 -5
  326. data/test/network/server/webrick.rb +5 -22
  327. data/test/ral/manager/attributes.rb +0 -4
  328. data/test/ral/manager/instances.rb +0 -4
  329. data/test/ral/manager/manager.rb +0 -4
  330. data/test/ral/providers/cron/crontab.rb +1 -0
  331. data/test/ral/providers/service/base.rb +0 -4
  332. data/test/ral/type/filesources.rb +0 -1
  333. data/test/ral/type/resources.rb +0 -4
  334. data/test/util/utiltest.rb +0 -13
  335. metadata +36 -9
  336. data/spec/unit/network/client_spec.rb +0 -45
  337. data/test/puppet/tc_suidmanager.rb +0 -120
@@ -4,28 +4,31 @@ require 'spec_helper'
4
4
  require 'puppet/util/backups'
5
5
 
6
6
  describe Puppet::Util::Backups do
7
+ include PuppetSpec::Files
8
+
7
9
  before do
8
10
  FileTest.stubs(:exists?).returns true
11
+ @nosuchfile = make_absolute('/no/such/file')
9
12
  end
10
13
 
11
14
  describe "when backing up a file" do
12
15
  it "should noop if the file does not exist" do
13
16
  FileTest.expects(:exists?).returns false
14
- file = Puppet::Type.type(:file).new(:name => '/no/such/file')
17
+ file = Puppet::Type.type(:file).new(:name => @nosuchfile)
15
18
  file.expects(:bucket).never
16
19
 
17
20
  file.perform_backup
18
21
  end
19
22
 
20
23
  it "should succeed silently if self[:backup] is false" do
21
- file = Puppet::Type.type(:file).new(:name => '/no/such/file', :backup => false)
24
+ file = Puppet::Type.type(:file).new(:name => @nosuchfile, :backup => false)
22
25
  file.expects(:bucket).never
23
26
  FileTest.expects(:exists?).never
24
27
  file.perform_backup
25
28
  end
26
29
 
27
30
  it "a bucket should be used when provided" do
28
- path = '/my/file'
31
+ path = make_absolute('/my/file')
29
32
 
30
33
  File.stubs(:stat).with(path).returns(mock('stat', :ftype => 'file'))
31
34
 
@@ -39,7 +42,7 @@ describe Puppet::Util::Backups do
39
42
  end
40
43
 
41
44
  it "should propagate any exceptions encountered when backing up to a filebucket" do
42
- path = '/my/file'
45
+ path = make_absolute('/my/file')
43
46
 
44
47
  File.stubs(:stat).with(path).returns(mock('stat', :ftype => 'file'))
45
48
 
@@ -54,7 +57,7 @@ describe Puppet::Util::Backups do
54
57
 
55
58
  describe "and no filebucket is configured" do
56
59
  it "should remove any local backup if one exists" do
57
- path = '/my/file'
60
+ path = make_absolute('/my/file')
58
61
  FileTest.stubs(:exists?).returns true
59
62
 
60
63
  backup = path + ".foo"
@@ -69,7 +72,7 @@ describe Puppet::Util::Backups do
69
72
  end
70
73
 
71
74
  it "should fail when the old backup can't be removed" do
72
- path = '/my/file'
75
+ path = make_absolute('/my/file')
73
76
  FileTest.stubs(:exists?).returns true
74
77
 
75
78
  backup = path + ".foo"
@@ -84,7 +87,7 @@ describe Puppet::Util::Backups do
84
87
  end
85
88
 
86
89
  it "should not try to remove backups that don't exist" do
87
- path = '/my/file'
90
+ path = make_absolute('/my/file')
88
91
  FileTest.stubs(:exists?).returns true
89
92
 
90
93
  backup = path + ".foo"
@@ -99,7 +102,7 @@ describe Puppet::Util::Backups do
99
102
  end
100
103
 
101
104
  it "a copy should be created in the local directory" do
102
- path = '/my/file'
105
+ path = make_absolute('/my/file')
103
106
  FileTest.stubs(:exists?).with(path).returns true
104
107
 
105
108
  FileUtils.expects(:cp_r).with(path, path + ".foo", :preserve => true)
@@ -109,7 +112,7 @@ describe Puppet::Util::Backups do
109
112
  end
110
113
 
111
114
  it "should propagate exceptions if no backup can be created" do
112
- path = '/my/file'
115
+ path = make_absolute('/my/file')
113
116
  FileTest.stubs(:exists?).with(path).returns true
114
117
 
115
118
  FileUtils.expects(:cp_r).raises ArgumentError
@@ -122,13 +125,13 @@ describe Puppet::Util::Backups do
122
125
 
123
126
  describe "when backing up a directory" do
124
127
  it "a bucket should work when provided" do
125
- path = '/my/dir'
128
+ path = make_absolute('/my/dir')
126
129
 
127
130
  File.stubs(:file?).returns true
128
- Find.expects(:find).with(path).yields("/my/dir/file")
131
+ Find.expects(:find).with(path).yields(make_absolute("/my/dir/file"))
129
132
 
130
133
  bucket = stub('bucket', :name => "eh")
131
- bucket.expects(:backup).with("/my/dir/file").returns true
134
+ bucket.expects(:backup).with(make_absolute("/my/dir/file")).returns true
132
135
 
133
136
  file = Puppet::Type.type(:file).new(:name => path, :backup => 'foo')
134
137
  file.stubs(:bucket).returns bucket
@@ -139,7 +142,7 @@ describe Puppet::Util::Backups do
139
142
  end
140
143
 
141
144
  it "should do nothing when recursing" do
142
- path = '/my/dir'
145
+ path = make_absolute('/my/dir')
143
146
 
144
147
  bucket = stub('bucket', :name => "eh")
145
148
  bucket.expects(:backup).never
@@ -3,182 +3,105 @@ require 'spec_helper'
3
3
 
4
4
  require 'puppet/util/cacher'
5
5
 
6
- class ExpirerTest
7
- include Puppet::Util::Cacher::Expirer
8
- end
9
-
10
6
  class CacheTest
11
- @@init_count = 0
12
-
13
- include Puppet::Util::Cacher
14
- cached_attr(:instance_cache) { Time.now }
15
- end
7
+ @@count = 0
16
8
 
17
- describe Puppet::Util::Cacher::Expirer do
18
- before do
19
- @expirer = ExpirerTest.new
9
+ def self.count
10
+ @@count
20
11
  end
21
12
 
22
- it "should be able to test whether a timestamp is expired" do
23
- @expirer.should respond_to(:dependent_data_expired?)
24
- end
25
-
26
- it "should be able to expire all values" do
27
- @expirer.should respond_to(:expire)
28
- end
29
-
30
- it "should consider any value to be valid if it has never been expired" do
31
- @expirer.should_not be_dependent_data_expired(Time.now)
32
- end
13
+ include Puppet::Util::Cacher
33
14
 
34
- it "should consider any value created after expiration to be expired" do
35
- @expirer.expire
36
- @expirer.should be_dependent_data_expired(Time.now - 1)
15
+ cached_attr(:instance_cache, 10) do
16
+ @@count += 1
17
+ {:number => @@count}
37
18
  end
38
19
  end
39
20
 
40
21
  describe Puppet::Util::Cacher do
41
- it "should be extended with the Expirer module" do
42
- Puppet::Util::Cacher.singleton_class.ancestors.should be_include(Puppet::Util::Cacher::Expirer)
22
+ before :each do
23
+ CacheTest.set_attr_ttl(:instance_cache, 10)
24
+ @object = CacheTest.new
43
25
  end
44
26
 
45
- it "should support defining cached attributes", :'fails_on_ruby_1.9.2' => true do
46
- CacheTest.methods.should be_include("cached_attr")
27
+ it "should return a value calculated from the provided block" do
28
+ @object.instance_cache.should == {:number => CacheTest.count}
47
29
  end
48
30
 
49
- it "should default to the Cacher module as its expirer" do
50
- CacheTest.new.expirer.should equal(Puppet::Util::Cacher)
31
+ it "should return the cached value from the getter every time if the value is not expired" do
32
+ @object.instance_cache.should equal(@object.instance_cache)
51
33
  end
52
34
 
53
- describe "when using cached attributes" do
54
- before do
55
- @expirer = ExpirerTest.new
56
- @object = CacheTest.new
35
+ it "should regenerate and return a new value using the provided block if the value has expired" do
36
+ initial = @object.instance_cache
57
37
 
58
- @object.stubs(:expirer).returns @expirer
59
- end
60
-
61
- it "should create a getter for the cached attribute" do
62
- @object.should respond_to(:instance_cache)
63
- end
64
-
65
- it "should return a value calculated from the provided block" do
66
- time = Time.now
67
- Time.stubs(:now).returns time
68
- @object.instance_cache.should equal(time)
69
- end
38
+ # Ensure the value is expired immediately
39
+ CacheTest.set_attr_ttl(:instance_cache, -10)
40
+ @object.send(:set_expiration, :instance_cache)
70
41
 
71
- it "should return the cached value from the getter every time if the value is not expired" do
72
- @object.instance_cache.should equal(@object.instance_cache)
73
- end
74
-
75
- it "should regenerate and return a new value using the provided block if the value has been expired" do
76
- value = @object.instance_cache
77
- @expirer.expire
78
- @object.instance_cache.should_not equal(value)
79
- end
42
+ @object.instance_cache.should_not equal(initial)
43
+ end
80
44
 
81
- it "should be able to trigger expiration on its expirer" do
82
- @expirer.expects(:expire)
83
- @object.expire
84
- end
45
+ it "should be able to cache false values" do
46
+ @object.expects(:init_instance_cache).once.returns false
47
+ @object.instance_cache.should be_false
48
+ @object.instance_cache.should be_false
49
+ end
85
50
 
86
- it "should do nothing when asked to expire when no expirer is available" do
87
- cacher = CacheTest.new
88
- class << cacher
89
- def expirer
90
- nil
91
- end
92
- end
93
- lambda { cacher.expire }.should_not raise_error
94
- end
51
+ it "should cache values again after expiration" do
52
+ initial = @object.instance_cache
95
53
 
96
- it "should be able to cache false values" do
97
- @object.expects(:init_instance_cache).returns false
98
- @object.instance_cache.should be_false
99
- @object.instance_cache.should be_false
100
- end
54
+ # Ensure the value is expired immediately
55
+ CacheTest.set_attr_ttl(:instance_cache, -10)
56
+ @object.send(:set_expiration, :instance_cache)
101
57
 
102
- it "should cache values again after expiration" do
103
- @object.instance_cache
104
- @expirer.expire
105
- @object.instance_cache.should equal(@object.instance_cache)
106
- end
58
+ # Reset ttl so this new value doesn't get expired
59
+ CacheTest.set_attr_ttl(:instance_cache, 10)
60
+ after_expiration = @object.instance_cache
107
61
 
108
- it "should always consider a value expired if it has no expirer" do
109
- @object.stubs(:expirer).returns nil
110
- @object.instance_cache.should_not equal(@object.instance_cache)
111
- end
62
+ after_expiration.should_not == initial
63
+ @object.instance_cache.should == after_expiration
64
+ end
112
65
 
113
- it "should allow writing of the attribute" do
114
- @object.should respond_to(:instance_cache=)
115
- end
66
+ it "should allow writing of the attribute" do
67
+ initial = @object.instance_cache
116
68
 
117
- it "should correctly configure timestamps for expiration when the cached attribute is written to" do
118
- @object.instance_cache = "foo"
119
- @expirer.expire
120
- @object.instance_cache.should_not == "foo"
121
- end
69
+ @object.instance_cache = "another value"
70
+ @object.instance_cache.should == "another value"
71
+ end
122
72
 
123
- it "should allow specification of a ttl for cached attributes" do
124
- klass = Class.new do
125
- include Puppet::Util::Cacher
126
- end
73
+ it "should update the expiration when the cached attribute is set manually" do
74
+ # Freeze time
75
+ now = Time.now
76
+ Time.stubs(:now).returns now
127
77
 
128
- klass.cached_attr(:myattr, :ttl => 5) { Time.now }
78
+ @object.instance_cache
129
79
 
130
- klass.attr_ttl(:myattr).should == 5
131
- end
80
+ # Set expiration to something far in the future
81
+ CacheTest.set_attr_ttl(:instance_cache, 60)
82
+ @object.send(:set_expiration, :instance_cache)
132
83
 
133
- it "should allow specification of a ttl as a string" do
134
- klass = Class.new do
135
- include Puppet::Util::Cacher
136
- end
84
+ CacheTest.set_attr_ttl(:instance_cache, 10)
137
85
 
138
- klass.cached_attr(:myattr, :ttl => "5") { Time.now }
86
+ @object.instance_cache = "foo"
87
+ @object.instance_variable_get(:@attr_expirations)[:instance_cache].should == now + 10
88
+ end
139
89
 
140
- klass.attr_ttl(:myattr).should == 5
90
+ it "should allow specification of a ttl as a string" do
91
+ klass = Class.new do
92
+ include Puppet::Util::Cacher
141
93
  end
142
94
 
143
- it "should fail helpfully if the ttl cannot be converted to an integer" do
144
- klass = Class.new do
145
- include Puppet::Util::Cacher
146
- end
147
-
148
- lambda { klass.cached_attr(:myattr, :ttl => "yep") { Time.now } }.should raise_error(ArgumentError)
149
- end
95
+ klass.cached_attr(:myattr, "5") { 10 }
150
96
 
151
- it "should not check for a ttl expiration if the class does not support that method" do
152
- klass = Class.new do
153
- extend Puppet::Util::Cacher
154
- end
97
+ klass.attr_ttl(:myattr).should == 5
98
+ end
155
99
 
156
- klass.singleton_class.cached_attr(:myattr) { "eh" }
157
- klass.myattr
100
+ it "should fail helpfully if the ttl cannot be converted to an integer" do
101
+ klass = Class.new do
102
+ include Puppet::Util::Cacher
158
103
  end
159
104
 
160
- it "should automatically expire cached attributes whose ttl has expired, even if no expirer is present" do
161
- klass = Class.new do
162
- def self.to_s
163
- "CacheTestClass"
164
- end
165
- include Puppet::Util::Cacher
166
- attr_accessor :value
167
- end
168
-
169
- klass.cached_attr(:myattr, :ttl => 5) { self.value += 1; self.value }
170
-
171
- now = Time.now
172
- later = Time.now + 15
173
-
174
- instance = klass.new
175
- instance.value = 0
176
- instance.myattr.should == 1
177
-
178
- Time.expects(:now).returns later
179
-
180
- # This call should get the new Time value, which should expire the old value
181
- instance.myattr.should == 2
182
- end
105
+ lambda { klass.cached_attr(:myattr, "yep") { 10 } }.should raise_error(ArgumentError)
183
106
  end
184
107
  end
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env rspec
2
- #
3
- # Created by Luke Kanies on 2007-9-22.
4
- # Copyright (c) 2007. All rights reserved.
5
-
6
2
  require 'spec_helper'
7
3
 
8
4
  require 'puppet/util/checksums'
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env rspec
2
- #
3
- # Created by Luke Kanies on 2008-02-12.
4
- # Copyright (c) 2007. All rights reserved.
5
-
6
2
  require 'spec_helper'
7
3
 
8
4
  require 'puppet/util/constant_inflector'
@@ -16,7 +16,7 @@ describe Puppet::Util::ExecutionStub do
16
16
  Puppet::Util::ExecutionStub.current_value.should == nil
17
17
  end
18
18
 
19
- it "should restore normal execution after 'reset' is called" do
19
+ it "should restore normal execution after 'reset' is called", :fails_on_windows => true do
20
20
  true_command = Puppet::Util.which('true') # Note: "true" exists at different paths in different OSes
21
21
  stub_call_count = 0
22
22
  Puppet::Util::ExecutionStub.set do |command, options|
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env rspec
2
- #
3
- # Created by Luke Kanies on 2008-3-19.
4
- # Copyright (c) 2006. All rights reserved.
5
-
6
2
  require 'spec_helper'
7
3
 
8
4
  require 'puppet/util/ldap/connection'
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env rspec
2
- #
3
- # Created by Luke Kanies on 2008-3-28.
4
- # Copyright (c) 2008. All rights reserved.
5
-
6
2
  require 'spec_helper'
7
3
 
8
4
  require 'puppet/util/ldap/generator'
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env rspec
2
- #
3
- # Created by Luke Kanies on 2008-3-19.
4
- # Copyright (c) 2006. All rights reserved.
5
-
6
2
  require 'spec_helper'
7
3
 
8
4
  require 'puppet/util/ldap/manager'
@@ -4,6 +4,8 @@ require 'spec_helper'
4
4
  require 'puppet/util/log'
5
5
 
6
6
  describe Puppet::Util::Log do
7
+ include PuppetSpec::Files
8
+
7
9
  it "should write a given message to the specified destination" do
8
10
  arraydest = []
9
11
  Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(arraydest))
@@ -167,7 +169,7 @@ describe Puppet::Util::Log do
167
169
 
168
170
  describe "when setting the source as a RAL object" do
169
171
  it "should tag itself with any tags the source has" do
170
- source = Puppet::Type.type(:file).new :path => "/foo/bar"
172
+ source = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar")
171
173
  log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source)
172
174
  source.tags.each do |tag|
173
175
  log.tags.should be_include(tag)
@@ -188,7 +190,7 @@ describe Puppet::Util::Log do
188
190
  end
189
191
 
190
192
  it "should copy over any file and line information" do
191
- source = Puppet::Type.type(:file).new :path => "/foo/bar"
193
+ source = Puppet::Type.type(:file).new :path => make_absolute("/foo/bar")
192
194
  source.file = "/my/file"
193
195
  source.line = 50
194
196
  log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => source)
@@ -46,7 +46,7 @@ describe Puppet::Util::Logging do
46
46
  @logger.notice "foo"
47
47
  end
48
48
 
49
- it "should use the path of any provided resource type" do
49
+ it "should use the path of any provided resource type", :fails_on_windows => true do
50
50
  resource = Puppet::Type.type(:mount).new :name => "foo"
51
51
 
52
52
  resource.expects(:path).returns "/path/to/mount".to_sym
@@ -56,7 +56,7 @@ describe Puppet::Util::Logging do
56
56
  resource.notice "foo"
57
57
  end
58
58
 
59
- it "should use the path of any provided resource parameter" do
59
+ it "should use the path of any provided resource parameter", :fails_on_windows => true do
60
60
  resource = Puppet::Type.type(:mount).new :name => "foo"
61
61
 
62
62
  param = resource.parameter(:name)
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env rspec
2
- #
3
- # Created by Luke Kanies on 2007-11-18.
4
- # Copyright (c) 2007. All rights reserved.
5
-
6
2
  require 'spec_helper'
7
3
 
8
4
  require 'puppet/util/nagios_maker'
@@ -137,7 +137,8 @@ eos
137
137
  "Fa 0/1" => "FastEthernet0/1",
138
138
  "Fa0/1" => "FastEthernet0/1",
139
139
  "FastEth 0/1" => "FastEthernet0/1",
140
- "Gi1" => "GigEthernet1",
140
+ "Gi1" => "GigabitEthernet1",
141
+ "Te2" => "TenGigabitEthernet2",
141
142
  "Di9" => "Dialer9",
142
143
  "Ethernet 0/0/1" => "Ethernet0/0/1",
143
144
  "E0" => "Ethernet0",
@@ -31,7 +31,9 @@ eos
31
31
  "Switch uptime is 1 year, 12 weeks, 6 days, 22 hours, 32 minutes" => { :hostname => "Switch", :uptime => "1 year, 12 weeks, 6 days, 22 hours, 32 minutes", :uptime_seconds => 39393120, :uptime_days => 455 },
32
32
  "c2950 uptime is 3 weeks, 1 day, 23 hours, 36 minutes" => { :hostname => "c2950", :uptime => "3 weeks, 1 day, 23 hours, 36 minutes", :uptime_days => 22, :uptime_seconds => 1985760},
33
33
  "router uptime is 5 weeks, 1 day, 3 hours, 30 minutes" => { :hostname => "router", :uptime => "5 weeks, 1 day, 3 hours, 30 minutes", :uptime_days => 36, :uptime_seconds => 3123000 },
34
- "c2950 uptime is 1 minute" => { :hostname => "c2950", :uptime => "1 minute", :uptime_days => 0, :uptime_seconds => 60 }
34
+ "c2950 uptime is 1 minute" => { :hostname => "c2950", :uptime => "1 minute", :uptime_days => 0, :uptime_seconds => 60 },
35
+ "c2950 uptime is 20 weeks, 6 minutes" => { :hostname => "c2950", :uptime=>"20 weeks, 6 minutes", :uptime_seconds=>12096360, :uptime_days=>140 },
36
+ "c2950 uptime is 2 years, 20 weeks, 6 minutes" => { :hostname => "c2950", :uptime=>"2 years, 20 weeks, 6 minutes", :uptime_seconds=>75168360, :uptime_days=>870 }
35
37
  }.each do |ver, expected|
36
38
  it "should parse show ver output for device uptime facts" do
37
39
  @transport.stubs(:command).with("sh ver").returns(<<eos)
@@ -4,9 +4,11 @@ require 'spec_helper'
4
4
  require 'puppet/util/network_device/config'
5
5
 
6
6
  describe Puppet::Util::NetworkDevice::Config do
7
+ include PuppetSpec::Files
8
+
7
9
  before(:each) do
8
- Puppet[:deviceconfig] = "/dummy"
9
- FileTest.stubs(:exists?).with("/dummy").returns(true)
10
+ Puppet[:deviceconfig] = make_absolute("/dummy")
11
+ FileTest.stubs(:exists?).with(make_absolute("/dummy")).returns(true)
10
12
  end
11
13
 
12
14
  describe "when initializing" do
@@ -15,7 +17,7 @@ describe Puppet::Util::NetworkDevice::Config do
15
17
  end
16
18
 
17
19
  it "should use the deviceconfig setting as pathname" do
18
- Puppet.expects(:[]).with(:deviceconfig).returns("/dummy")
20
+ Puppet.expects(:[]).with(:deviceconfig).returns(make_absolute("/dummy"))
19
21
 
20
22
  Puppet::Util::NetworkDevice::Config.new
21
23
  end
@@ -8,6 +8,8 @@ require 'rdoc/options'
8
8
  require 'rdoc/rdoc'
9
9
 
10
10
  describe RDoc::Parser, :'fails_on_ruby_1.9.2' => true do
11
+ include PuppetSpec::Files
12
+
11
13
  before :each do
12
14
  File.stubs(:stat).with("init.pp")
13
15
  @top_level = stub_everything 'toplevel', :file_relative_name => "init.pp"
@@ -21,7 +23,7 @@ describe RDoc::Parser, :'fails_on_ruby_1.9.2' => true do
21
23
  Puppet::Parser::Parser.stubs(:new).returns(parser)
22
24
  parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new('')).at_least_once
23
25
  parser.expects(:file=).with("module/manifests/init.pp")
24
- parser.expects(:file=).with("/dev/null/manifests/site.pp")
26
+ parser.expects(:file=).with(make_absolute("/dev/null/manifests/site.pp"))
25
27
 
26
28
  @parser.scan
27
29
  end
@@ -147,6 +149,10 @@ describe RDoc::Parser, :'fails_on_ruby_1.9.2' => true do
147
149
  File.stubs(:identical?).returns(false)
148
150
  @parser.split_module("/path/to/manifests/init.pp").should == RDoc::Parser::SITE
149
151
  end
152
+
153
+ it "should handle windows paths with drive letters", :if => Puppet.features.microsoft_windows? do
154
+ @parser.split_module("C:/temp/init.pp").should == RDoc::Parser::SITE
155
+ end
150
156
  end
151
157
 
152
158
  describe "when parsing AST elements" do
@@ -8,7 +8,9 @@ describe Puppet::Util::RunMode do
8
8
 
9
9
  it "should have confdir /etc/puppet when run as root" do
10
10
  Puppet.features.stubs(:root?).returns(true)
11
- @run_mode.conf_dir.should == '/etc/puppet'
11
+ etcdir = Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc") : '/etc/puppet'
12
+ # REMIND: issue with windows backslashes
13
+ @run_mode.conf_dir.should == File.expand_path(etcdir)
12
14
  end
13
15
 
14
16
  it "should have confdir ~/.puppet when run as non-root" do
@@ -19,7 +21,9 @@ describe Puppet::Util::RunMode do
19
21
 
20
22
  it "should have vardir /var/lib/puppet when run as root" do
21
23
  Puppet.features.stubs(:root?).returns(true)
22
- @run_mode.var_dir.should == '/var/lib/puppet'
24
+ vardir = Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var") : '/var/lib/puppet'
25
+ # REMIND: issue with windows backslashes
26
+ @run_mode.var_dir.should == File.expand_path(vardir)
23
27
  end
24
28
 
25
29
  it "should have vardir ~/.puppet/var when run as non-root" do
@@ -7,8 +7,10 @@ require 'puppet/util/settings/file_setting'
7
7
  describe Puppet::Util::Settings::FileSetting do
8
8
  FileSetting = Puppet::Util::Settings::FileSetting
9
9
 
10
+ include PuppetSpec::Files
11
+
10
12
  before do
11
- @basepath = Puppet.features.posix? ? "/somepath" : "C:/somepath"
13
+ @basepath = make_absolute("/somepath")
12
14
  end
13
15
 
14
16
  describe "when determining whether the service user should be used" do
@@ -165,7 +167,10 @@ describe Puppet::Util::Settings::FileSetting do
165
167
 
166
168
  it "should fully qualified returned files if necessary (#795)" do
167
169
  @settings.stubs(:value).with(:mydir).returns "myfile"
168
- @file.to_resource.title.should == File.join(Dir.getwd, "myfile")
170
+ path = File.join(Dir.getwd, "myfile")
171
+ # Dir.getwd can return windows paths with backslashes, so we normalize them using expand_path
172
+ path = File.expand_path(path) if Puppet.features.microsoft_windows?
173
+ @file.to_resource.title.should == path
169
174
  end
170
175
 
171
176
  it "should set the mode on the file if a mode is provided" do
@@ -184,6 +189,8 @@ describe Puppet::Util::Settings::FileSetting do
184
189
 
185
190
  it "should set the owner if running as root and the owner is provided" do
186
191
  Puppet.features.expects(:root?).returns true
192
+ Puppet.features.stubs(:microsoft_windows?).returns false
193
+
187
194
  @file.stubs(:owner).returns "foo"
188
195
  @file.to_resource[:owner].should == "foo"
189
196
  end
@@ -198,6 +205,8 @@ describe Puppet::Util::Settings::FileSetting do
198
205
 
199
206
  it "should set the group if running as root and the group is provided" do
200
207
  Puppet.features.expects(:root?).returns true
208
+ Puppet.features.stubs(:microsoft_windows?).returns false
209
+
201
210
  @file.stubs(:group).returns "foo"
202
211
  @file.to_resource[:group].should == "foo"
203
212
  end
@@ -213,16 +222,34 @@ describe Puppet::Util::Settings::FileSetting do
213
222
 
214
223
  it "should not set owner if not running as root" do
215
224
  Puppet.features.expects(:root?).returns false
225
+ Puppet.features.stubs(:microsoft_windows?).returns false
216
226
  @file.stubs(:owner).returns "foo"
217
227
  @file.to_resource[:owner].should be_nil
218
228
  end
219
229
 
220
230
  it "should not set group if not running as root" do
221
231
  Puppet.features.expects(:root?).returns false
232
+ Puppet.features.stubs(:microsoft_windows?).returns false
222
233
  @file.stubs(:group).returns "foo"
223
234
  @file.to_resource[:group].should be_nil
224
235
  end
225
236
 
237
+ describe "on Microsoft Windows systems" do
238
+ before :each do
239
+ Puppet.features.stubs(:microsoft_windows?).returns true
240
+ end
241
+
242
+ it "should not set owner" do
243
+ @file.stubs(:owner).returns "foo"
244
+ @file.to_resource[:owner].should be_nil
245
+ end
246
+
247
+ it "should not set group" do
248
+ @file.stubs(:group).returns "foo"
249
+ @file.to_resource[:group].should be_nil
250
+ end
251
+ end
252
+
226
253
  it "should set :ensure to the file type" do
227
254
  @file.expects(:type).returns :directory
228
255
  @file.to_resource[:ensure].should == :directory