diff options
author | Jorie Tappa <jorie@jorietappa.com> | 2018-08-01 16:09:42 -0500 |
---|---|---|
committer | Jorie Tappa <jorie@jorietappa.com> | 2018-08-01 16:13:33 -0500 |
commit | 286f7aaa3a1387b689a6a00db705f15b46579ce6 (patch) | |
tree | a933458cb52f606dbb3715773874fb4a480128a8 | |
parent | 45c0c71d2e3b3b7268a356eea86231a1b35cd4f0 (diff) | |
download | puppet-cron_core-286f7aaa3a1387b689a6a00db705f15b46579ce6.tar.gz puppet-cron_core-286f7aaa3a1387b689a6a00db705f15b46579ce6.tar.bz2 |
Fix Style/RegexpLiteral violations
-rw-r--r-- | lib/puppet/type/cron.rb | 8 | ||||
-rw-r--r-- | spec/acceptance/tests/resource/cron/should_create_cron.rb | 2 | ||||
-rw-r--r-- | spec/acceptance/tests/resource/cron/should_match_existing.rb | 2 | ||||
-rw-r--r-- | spec/acceptance/tests/resource/cron/should_remove_cron.rb | 2 | ||||
-rw-r--r-- | spec/acceptance/tests/resource/cron/should_update_existing.rb | 4 | ||||
-rw-r--r-- | spec/unit/type/cron_spec.rb | 20 |
6 files changed, 19 insertions, 19 deletions
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb index 3a106c4..fada980 100644 --- a/lib/puppet/type/cron.rb +++ b/lib/puppet/type/cron.rb @@ -156,8 +156,8 @@ Puppet::Type.newtype(:cron) do return :absent end - # Allow the */2 syntax - if value =~ /^\*\/[0-9]+$/ + # Allow step syntax + if value =~ %r{^\*/[0-9]+$} return value end @@ -166,8 +166,8 @@ Puppet::Type.newtype(:cron) do return value end - # Allow ranges + */2 - if value =~ /^[0-9]+-[0-9]+\/[0-9]+$/ + # Allow ranges with step + if value =~ %r{^[0-9]+-[0-9]+/[0-9]+$} return value end diff --git a/spec/acceptance/tests/resource/cron/should_create_cron.rb b/spec/acceptance/tests/resource/cron/should_create_cron.rb index 29dcfc4..d01c091 100644 --- a/spec/acceptance/tests/resource/cron/should_create_cron.rb +++ b/spec/acceptance/tests/resource/cron/should_create_cron.rb @@ -30,6 +30,6 @@ agents.each do |host| step 'verify that crontab -l contains what you expected' run_cron_on(host, :list, 'tstuser') do - assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Incorrect crontab for tstuser on #{host}") + assert_match(%r{\* \* \* \* \* /bin/true}, stdout, "Incorrect crontab for tstuser on #{host}") end end diff --git a/spec/acceptance/tests/resource/cron/should_match_existing.rb b/spec/acceptance/tests/resource/cron/should_match_existing.rb index d309a84..96545e3 100644 --- a/spec/acceptance/tests/resource/cron/should_match_existing.rb +++ b/spec/acceptance/tests/resource/cron/should_match_existing.rb @@ -31,6 +31,6 @@ agents.each do |host| step 'Verify that crontab -l contains what you expected' run_cron_on(host, :list, 'tstuser') do - assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Did not find crontab for tstuser on #{host}") + assert_match(%r{\* \* \* \* \* /bin/true}, stdout, "Did not find crontab for tstuser on #{host}") end end diff --git a/spec/acceptance/tests/resource/cron/should_remove_cron.rb b/spec/acceptance/tests/resource/cron/should_remove_cron.rb index 1759172..0713c95 100644 --- a/spec/acceptance/tests/resource/cron/should_remove_cron.rb +++ b/spec/acceptance/tests/resource/cron/should_remove_cron.rb @@ -33,6 +33,6 @@ agents.each do |host| step 'verify that crontab -l contains what you expected' run_cron_on(host, :list, 'tstuser') do - assert_no_match(/\/bin\/true/, stderr, "Error: Found entry for tstuser on #{host}") + assert_no_match(%r{/bin/true}, stderr, "Error: Found entry for tstuser on #{host}") end end diff --git a/spec/acceptance/tests/resource/cron/should_update_existing.rb b/spec/acceptance/tests/resource/cron/should_update_existing.rb index eff634b..b9b9bec 100644 --- a/spec/acceptance/tests/resource/cron/should_update_existing.rb +++ b/spec/acceptance/tests/resource/cron/should_update_existing.rb @@ -27,7 +27,7 @@ agents.each do |host| step 'verify that crontab -l contains what you expected' run_cron_on(host, :list, 'tstuser') do - assert_match(/\* \* \* \* \* \/bin\/true/, stdout, "Didn't find correct crobtab entry for tstuser on #{host}") + assert_match(%r{\* \* \* \* \* /bin/true}, stdout, "Didn't find correct crobtab entry for tstuser on #{host}") end step 'apply the resource change on the host' @@ -37,6 +37,6 @@ agents.each do |host| step 'verify that crontab -l contains what you expected' run_cron_on(host, :list, 'tstuser') do - assert_match(/\* 0-6 \* \* \* \/bin\/true/, stdout, "Didn't find correctly modified time entry in crobtab entry for tstuser on #{host}") + assert_match(%r{\* 0-6 \* \* \* /bin/true}, stdout, "Didn't find correctly modified time entry in crobtab entry for tstuser on #{host}") end end diff --git a/spec/unit/type/cron_spec.rb b/spec/unit/type/cron_spec.rb index 32cab5c..32bde11 100644 --- a/spec/unit/type/cron_spec.rb +++ b/spec/unit/type/cron_spec.rb @@ -122,8 +122,8 @@ describe Puppet::Type.type(:cron), unless: Puppet.features.microsoft_windows? do end it 'does not support invalid steps' do - expect { described_class.new(name: 'foo', minute: '*/A') }.to raise_error(Puppet::Error, /\*\/A is not a valid minute/) - expect { described_class.new(name: 'foo', minute: '*/2A') }.to raise_error(Puppet::Error, /\*\/2A is not a valid minute/) + expect { described_class.new(name: 'foo', minute: '*/A') }.to raise_error(Puppet::Error, %r{\*/A is not a valid minute}) + expect { described_class.new(name: 'foo', minute: '*/2A') }.to raise_error(Puppet::Error, %r{\*/2A is not a valid minute}) # As it turns out cron does not complaining about steps that exceed the valid range # expect { described_class.new(:name => 'foo', :minute => '*/120' ) }.to raise_error(Puppet::Error, /is not a valid minute/) end @@ -189,8 +189,8 @@ describe Puppet::Type.type(:cron), unless: Puppet.features.microsoft_windows? do end it 'does not support invalid steps' do - expect { described_class.new(name: 'foo', hour: '*/A') }.to raise_error(Puppet::Error, /\*\/A is not a valid hour/) - expect { described_class.new(name: 'foo', hour: '*/2A') }.to raise_error(Puppet::Error, /\*\/2A is not a valid hour/) + expect { described_class.new(name: 'foo', hour: '*/A') }.to raise_error(Puppet::Error, %r{\*/A is not a valid hour}) + expect { described_class.new(name: 'foo', hour: '*/2A') }.to raise_error(Puppet::Error, %r{\*/2A is not a valid hour}) # As it turns out cron does not complaining about steps that exceed the valid range # expect { described_class.new(:name => 'foo', :hour => '*/26' ) }.to raise_error(Puppet::Error, /is not a valid hour/) end @@ -272,8 +272,8 @@ describe Puppet::Type.type(:cron), unless: Puppet.features.microsoft_windows? do end it 'does not support invalid steps' do - expect { described_class.new(name: 'foo', weekday: '*/A') }.to raise_error(Puppet::Error, /\*\/A is not a valid weekday/) - expect { described_class.new(name: 'foo', weekday: '*/2A') }.to raise_error(Puppet::Error, /\*\/2A is not a valid weekday/) + expect { described_class.new(name: 'foo', weekday: '*/A') }.to raise_error(Puppet::Error, %r{\*/A is not a valid weekday}) + expect { described_class.new(name: 'foo', weekday: '*/2A') }.to raise_error(Puppet::Error, %r{\*/2A is not a valid weekday}) # As it turns out cron does not complaining about steps that exceed the valid range # expect { described_class.new(:name => 'foo', :weekday => '*/9' ) }.to raise_error(Puppet::Error, /is not a valid weekday/) end @@ -371,8 +371,8 @@ describe Puppet::Type.type(:cron), unless: Puppet.features.microsoft_windows? do end it 'does not support invalid steps' do - expect { described_class.new(name: 'foo', month: '*/A') }.to raise_error(Puppet::Error, /\*\/A is not a valid month/) - expect { described_class.new(name: 'foo', month: '*/2A') }.to raise_error(Puppet::Error, /\*\/2A is not a valid month/) + expect { described_class.new(name: 'foo', month: '*/A') }.to raise_error(Puppet::Error, %r{\*/A is not a valid month}) + expect { described_class.new(name: 'foo', month: '*/2A') }.to raise_error(Puppet::Error, %r{\*/2A is not a valid month}) # As it turns out cron does not complaining about steps that exceed the valid range # expect { described_class.new(:name => 'foo', :month => '*/13' ) }.to raise_error(Puppet::Error, /is not a valid month/) end @@ -436,8 +436,8 @@ describe Puppet::Type.type(:cron), unless: Puppet.features.microsoft_windows? do end it 'does not support invalid steps' do - expect { described_class.new(name: 'foo', monthday: '*/A') }.to raise_error(Puppet::Error, /\*\/A is not a valid monthday/) - expect { described_class.new(name: 'foo', monthday: '*/2A') }.to raise_error(Puppet::Error, /\*\/2A is not a valid monthday/) + expect { described_class.new(name: 'foo', monthday: '*/A') }.to raise_error(Puppet::Error, %r{\*/A is not a valid monthday}) + expect { described_class.new(name: 'foo', monthday: '*/2A') }.to raise_error(Puppet::Error, %r{\*/2A is not a valid monthday}) # As it turns out cron does not complaining about steps that exceed the valid range # expect { described_class.new(:name => 'foo', :monthday => '*/32' ) }.to raise_error(Puppet::Error, /is not a valid monthday/) end |