aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJorie Tappa <jorie@jorietappa.com>2018-08-23 15:06:21 -0700
committerJorie Tappa <jorie@jorietappa.com>2018-08-23 15:06:21 -0700
commitb8e2a253bdcaabf548dcce46f7de2c4bfcb5b0c7 (patch)
tree4c09108c62461d993d96aa51f034a42fae052ce7 /spec
parent1f813c3820c8da6753f6dccb594b69ab714a52a0 (diff)
downloadpuppet-cron_core-b8e2a253bdcaabf548dcce46f7de2c4bfcb5b0c7.tar.gz
puppet-cron_core-b8e2a253bdcaabf548dcce46f7de2c4bfcb5b0c7.tar.bz2
Clean up newly broken cops since import
Diffstat (limited to 'spec')
-rw-r--r--spec/acceptance/tests/resource/cron/should_allow_changing_parameters_spec.rb68
-rw-r--r--spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb16
-rw-r--r--spec/spec_helper_acceptance.rb20
3 files changed, 48 insertions, 56 deletions
diff --git a/spec/acceptance/tests/resource/cron/should_allow_changing_parameters_spec.rb b/spec/acceptance/tests/resource/cron/should_allow_changing_parameters_spec.rb
index 2df0ea2..615d617 100644
--- a/spec/acceptance/tests/resource/cron/should_allow_changing_parameters_spec.rb
+++ b/spec/acceptance/tests/resource/cron/should_allow_changing_parameters_spec.rb
@@ -18,52 +18,46 @@ RSpec.context 'when changing parameters' do
compatible_agents.each do |agent|
it "manages cron entries on #{agent}" do
step 'Cron: basic - verify that it can be created'
- apply_manifest_on(agent, 'cron { "myjob": command => "/bin/false", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do
- expect(@result.stdout).to match(%r{ensure: created})
- end
- run_cron_on(agent, :list, 'tstuser') do
- expect(@result.stdout).to match(%r{.bin.false})
- end
+ result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/false", user => "tstuser", hour => "*", minute => [1], ensure => present,}')
+ expect(result.stdout).to match(%r{ensure: created})
+ result = run_cron_on(agent, :list, 'tstuser')
+ expect(result.stdout).to match(%r{.bin.false})
step 'Cron: allow changing command'
- apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do
- expect(@result.stdout).to match(%r{command changed '.bin.false'.* to '.bin.true'})
- end
- run_cron_on(agent, :list, 'tstuser') do
- expect(@result.stdout).to match(%r{1 . . . . .bin.true})
- end
+ result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}')
+ expect(result.stdout).to match(%r{command changed '.bin.false'.* to '.bin.true'})
+
+ result = run_cron_on(agent, :list, 'tstuser')
+ expect(result.stdout).to match(%r{1 . . . . .bin.true})
step 'Cron: allow changing time'
- apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "1", minute => [1], ensure => present,}') do
- expect(@result.stdout).to match(%r{hour: defined 'hour' as \['1'\]})
- end
- run_cron_on(agent, :list, 'tstuser') do
- expect(@result.stdout).to match(%r{1 1 . . . .bin.true})
- end
+ result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "1", minute => [1], ensure => present,}')
+ expect(result.stdout).to match(%r{hour: defined 'hour' as \['1'\]})
+
+ result = run_cron_on(agent, :list, 'tstuser')
+ expect(result.stdout).to match(%r{1 1 . . . .bin.true})
step 'Cron: allow changing time(array)'
- apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => ["1","2"], minute => [1], ensure => present,}') do
- expect(@result.stdout).to match(%r{hour: hour changed \['1'\].* to \['1', '2'\]})
- end
- run_cron_on(agent, :list, 'tstuser') do
- expect(@result.stdout).to match(%r{1 1,2 . . . .bin.true})
- end
+ result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => ["1","2"], minute => [1], ensure => present,}')
+ expect(result.stdout).to match(%r{hour: hour changed \['1'\].* to \['1', '2'\]})
+
+ result = run_cron_on(agent, :list, 'tstuser')
+ expect(result.stdout).to match(%r{1 1,2 . . . .bin.true})
step 'Cron: allow changing time(array modification)'
- apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => ["3","2"], minute => [1], ensure => present,}') do
- expect(@result.stdout).to match(%r{hour: hour changed \['1', '2'\].* to \['3', '2'\]})
- end
- run_cron_on(agent, :list, 'tstuser') do
- expect(@result.stdout).to match(%r{1 3,2 . . . .bin.true})
- end
+ result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => ["3","2"], minute => [1], ensure => present,}')
+ expect(result.stdout).to match(%r{hour: hour changed \['1', '2'\].* to \['3', '2'\]})
+
+ result = run_cron_on(agent, :list, 'tstuser')
+ expect(result.stdout).to match(%r{1 3,2 . . . .bin.true})
+
step 'Cron: allow changing time(array modification to *)'
- apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => "*", ensure => present,}') do
- expect(@result.stdout).to match(%r{minute: undefined 'minute' from \['1'\]})
- expect(@result.stdout).to match(%r{hour: undefined 'hour' from \['3', '2'\]})
- end
- run_cron_on(agent, :list, 'tstuser') do
- expect(@result.stdout).to match(%r{\* \* . . . .bin.true})
- end
+ result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => "*", ensure => present,}')
+ expect(result.stdout).to match(%r{minute: undefined 'minute' from \['1'\]})
+ expect(result.stdout).to match(%r{hour: undefined 'hour' from \['3', '2'\]})
+
+ result = run_cron_on(agent, :list, 'tstuser')
+ expect(result.stdout).to match(%r{\* \* . . . .bin.true})
end
end
end
diff --git a/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb b/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb
index 4bf515e..35a91b7 100644
--- a/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb
+++ b/spec/acceptance/tests/resource/cron/should_be_idempotent_spec.rb
@@ -18,17 +18,15 @@ RSpec.context 'when checking idempotency' do
compatible_agents.each do |agent|
it "ensures idempotency on #{agent}" do
step 'Cron: basic - verify that it can be created'
- apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do
- expect(@result.stdout).to match(%r{ensure: created})
- end
- run_cron_on(agent, :list, 'tstuser') do
- expect(@result.stdout).to match(%r{. . . . . .bin.true})
- end
+ result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}')
+ expect(result.stdout).to match(%r{ensure: created})
+
+ result = run_cron_on(agent, :list, 'tstuser')
+ expect(result.stdout).to match(%r{. . . . . .bin.true})
step 'Cron: basic - should not create again'
- apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}') do
- expect(@result.stdout).not_to match(%r{ensure: created})
- end
+ result = apply_manifest_on(agent, 'cron { "myjob": command => "/bin/true", user => "tstuser", hour => "*", minute => [1], ensure => present,}')
+ expect(result.stdout).not_to match(%r{ensure: created})
end
end
end
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index b56c203..4759227 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -13,20 +13,20 @@ def compatible_agents
agents.reject { |agent| agent['platform'].include?('windows') || agent['platform'].include?('eos-') || agent['platform'].include?('fedora-28') }
end
-def clean(agent, o={})
- o = {:user => 'tstuser'}.merge(o)
- run_cron_on(agent, :remove, o[:user])
- apply_manifest_on(agent, %[user { '%s': ensure => absent, managehome => false }] % o[:user])
- end
+def clean(agent, o = {})
+ o = { user: 'tstuser' }.merge(o)
+ run_cron_on(agent, :remove, o[:user])
+ apply_manifest_on(agent, %([user{'%s': ensure => absent, managehome => false }]) % o[:user])
+end
-def setup(agent, o={})
- o = {:user => 'tstuser'}.merge(o)
- apply_manifest_on(agent, %[user { '%s': ensure => present, managehome => false }] % o[:user])
- apply_manifest_on(agent, %[case $operatingsystem {
+def setup(agent, o = {})
+ o = { user: 'tstuser' }.merge(o)
+ apply_manifest_on(agent, %(user { '%s': ensure => present, managehome => false }) % o[:user])
+ apply_manifest_on(agent, %(case $operatingsystem {
centos, redhat: {$cron = 'cronie'}
solaris: { $cron = 'core-os' }
default: {$cron ='cron'} }
- package {'cron': name=> $cron, ensure=>present, }])
+ package {'cron': name=> $cron, ensure=>present, }))
end
RSpec.configure do |c|