diff options
author | Bobosila Victor <victor.bobosila@puppet.com> | 2021-10-04 11:06:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-04 11:06:38 +0300 |
commit | 74e9d916d182df8a6594403582a8cc9e19dd55c0 (patch) | |
tree | c3070ac7809f3cf0ea04ce83622ae438efbd8203 /spec | |
parent | 4c72fb204bfc98e5d9dd4bff210c9be8178f1258 (diff) | |
parent | dd42efd5323314047d2c44e02f2f7e3472954697 (diff) | |
download | puppet-cron_core-74e9d916d182df8a6594403582a8cc9e19dd55c0.tar.gz puppet-cron_core-74e9d916d182df8a6594403582a8cc9e19dd55c0.tar.bz2 |
Merge pull request #44 from joshcooper/bump_json
(maint) Bump templates to 2.2.0
Diffstat (limited to 'spec')
10 files changed, 37 insertions, 19 deletions
diff --git a/spec/acceptance/tests/resource/cron/should_fail_to_write_a_nonexistent_users_crontab_spec.rb b/spec/acceptance/tests/resource/cron/should_fail_to_write_a_nonexistent_users_crontab_spec.rb index 40fbbd9..167260a 100644 --- a/spec/acceptance/tests/resource/cron/should_fail_to_write_a_nonexistent_users_crontab_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_fail_to_write_a_nonexistent_users_crontab_spec.rb @@ -12,7 +12,7 @@ RSpec.context 'when Puppet attempts to write the crontab of a nonexistent user' end compatible_agents.each do |agent| - it "should fail on #{agent}" do + it "fails on #{agent}" do manifest = cron_manifest('second_entry', command: 'ls', user: nonexistent_username) apply_manifest_on(agent, manifest, expect_failures: true) end diff --git a/spec/acceptance/tests/resource/cron/should_not_overwrite_crontab_file_on_file_read_error_spec.rb b/spec/acceptance/tests/resource/cron/should_not_overwrite_crontab_file_on_file_read_error_spec.rb index 6a5b2c6..60c51c9 100644 --- a/spec/acceptance/tests/resource/cron/should_not_overwrite_crontab_file_on_file_read_error_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_not_overwrite_crontab_file_on_file_read_error_spec.rb @@ -44,7 +44,7 @@ RSpec.context 'when Puppet cannot read a crontab file' do end compatible_agents.each do |agent| - it "should not overwrite it on #{agent}" do + it "does not overwrite it on #{agent}" do if older_agent?(agent) skip('Skipping this test since we are on an older agent that does not have the PUP-9217 changes') end diff --git a/spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb b/spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb index 1846523..e95dc29 100644 --- a/spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_only_fail_associated_resources_on_file_read_error_spec.rb @@ -42,7 +42,7 @@ RSpec.context 'when Puppet cannot read a crontab file' do end compatible_agents.each do |agent| - it "should only fail the associated resources on #{agent}" do + it "onlies fail the associated resources on #{agent}" do if older_agent?(agent) skip('Skipping this test since we are on an older agent that does not have the PUP-9217 changes') end diff --git a/spec/acceptance/tests/resource/cron/should_write_an_originally_unauthorized_users_crontab_if_puppet_authorizes_them_spec.rb b/spec/acceptance/tests/resource/cron/should_write_an_originally_unauthorized_users_crontab_if_puppet_authorizes_them_spec.rb index 834cac7..07d5375 100644 --- a/spec/acceptance/tests/resource/cron/should_write_an_originally_unauthorized_users_crontab_if_puppet_authorizes_them_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_write_an_originally_unauthorized_users_crontab_if_puppet_authorizes_them_spec.rb @@ -61,7 +61,7 @@ RSpec.context 'when Puppet authorizes a previously unauthorized user to use cron compatible_agents.each do |agent| is_aix_or_solaris_agent = agent['platform'].include?('aix') || agent['platform'].include?('solaris') - it "should write that user's crontab on #{agent}", if: is_aix_or_solaris_agent do + it "writes that user's crontab on #{agent}", if: is_aix_or_solaris_agent do step 'Add the unauthorized user to the cron.deny file' do on(agent, "echo #{unauthorized_username} >> #{cron_deny_path[agent]}") end diff --git a/spec/acceptance/tests/resource/cron/should_write_new_users_crontab_after_puppet_creates_them_spec.rb b/spec/acceptance/tests/resource/cron/should_write_new_users_crontab_after_puppet_creates_them_spec.rb index 12506ad..6fb7396 100644 --- a/spec/acceptance/tests/resource/cron/should_write_new_users_crontab_after_puppet_creates_them_spec.rb +++ b/spec/acceptance/tests/resource/cron/should_write_new_users_crontab_after_puppet_creates_them_spec.rb @@ -31,7 +31,7 @@ RSpec.context 'when Puppet creates a user in the middle of its run' do end compatible_agents.each do |agent| - it "should be able to write their crontab on #{agent}" do + it "is able to write their crontab on #{agent}" do puppet_result = nil step "Create the new user, and the known + new user's crontab entries with Puppet" do # Placing Cron[first_entry] before creating the new user diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb index af0e936..7a43100 100644 --- a/spec/lib/puppet_spec/files.rb +++ b/spec/lib/puppet_spec/files.rb @@ -12,7 +12,7 @@ module PuppetSpec::Files begin allow(Dir).to receive(:entries).and_call_original FileUtils.rm_rf path, secure: true - rescue Errno::ENOENT # rubocop:disable Lint/HandleExceptions + rescue Errno::ENOENT # nothing to do end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 29615cd..9b1fa6f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,9 @@ +# frozen_string_literal: true + +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -31,16 +37,28 @@ default_facts.each do |fact, value| end RSpec.configure do |c| - c.mock_with :rspec c.default_facts = default_facts c.before :each do # set to strictest setting for testing # by default Puppet runs at warning level Puppet.settings[:strict] = :warning + Puppet.settings[:strict_variables] = true end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do end + + # Filter backtrace noise + backtrace_exclusion_patterns = [ + %r{spec_helper}, + %r{gems}, + ] + + if c.respond_to?(:backtrace_exclusion_patterns) + c.backtrace_exclusion_patterns = backtrace_exclusion_patterns + elsif c.respond_to?(:backtrace_clean_patterns) + c.backtrace_clean_patterns = backtrace_exclusion_patterns + end end # Ensures that a module is defined diff --git a/spec/unit/provider/cron/crontab_spec.rb b/spec/unit/provider/cron/crontab_spec.rb index 6e28393..4047f82 100644 --- a/spec/unit/provider/cron/crontab_spec.rb +++ b/spec/unit/provider/cron/crontab_spec.rb @@ -37,11 +37,11 @@ describe Puppet::Type.type(:cron).provider(:crontab) do samples = YAML.load(File.read(my_fixture('single_line.yaml'))) # rubocop:disable Security/YAMLLoad samples.each do |name, data| - it "should parse crontab line #{name} correctly" do + it "parses crontab line #{name} correctly" do compare_crontab_record subject.parse_line(data[:text]), data[:record] end - it "should reconstruct the crontab line #{name} from the record" do + it "reconstructs the crontab line #{name} from the record" do expect(subject.to_line(data[:record])).to eq(data[:text]) end end diff --git a/spec/unit/provider/cron/parsed_spec.rb b/spec/unit/provider/cron/parsed_spec.rb index e4fa4cd..8e02ce6 100644 --- a/spec/unit/provider/cron/parsed_spec.rb +++ b/spec/unit/provider/cron/parsed_spec.rb @@ -81,7 +81,7 @@ describe Puppet::Type.type(:cron).provider(:crontab) do # I'd use expect(ENV).to receive(:[]).with('USER') but this does not work because # ENV["USER"] is evaluated at load time. describe 'when determining the default target' do - it "should use the current user #{ENV['USER']}", if: ENV['USER'] do + it "uses the current user #{ENV['USER']}", if: ENV['USER'] do expect(described_class.default_target).to eq(ENV['USER']) end @@ -166,7 +166,7 @@ describe Puppet::Type.type(:cron).provider(:crontab) do describe 'it should support special strings' do ['reboot', 'yearly', 'anually', 'monthly', 'weekly', 'daily', 'midnight', 'hourly'].each do |special| - it "should support @#{special}" do + it "supports @#{special}" do expect(described_class.parse_line("@#{special} /bin/true")).to eq(record_type: :crontab, hour: :absent, minute: :absent, @@ -300,7 +300,7 @@ describe Puppet::Type.type(:cron).provider(:crontab) do command: '/bin/false', target: 'nobody', }.each_pair do |field, new_value| - it "should not match a record when #{field} does not match" do + it "does not match a record when #{field} does not match" do record[field] = new_value expect(described_class.match(record, resource[:name] => resource)).to be_falsey end @@ -317,7 +317,7 @@ describe Puppet::Type.type(:cron).provider(:crontab) do command: '/bin/false', target: 'root', }.each_pair do |field, new_value| - it "should not match a record when #{field} does not match" do + it "does not match a record when #{field} does not match" do record_special[field] = new_value expect(described_class.match(record_special, resource_special[:name] => resource_special)).to be_falsey end diff --git a/spec/unit/type/cron_spec.rb b/spec/unit/type/cron_spec.rb index 78deabf..9564d16 100644 --- a/spec/unit/type/cron_spec.rb +++ b/spec/unit/type/cron_spec.rb @@ -21,19 +21,19 @@ describe Puppet::Type.type(:cron), unless: Puppet.features.microsoft_windows? do describe 'when validating attributes' do [:name, :provider].each do |param| - it "should have a #{param} parameter" do + it "has a #{param} parameter" do expect(described_class.attrtype(param)).to eq(:param) end end [:command, :special, :minute, :hour, :weekday, :month, :monthday, :environment, :user, :target].each do |property| - it "should have a #{property} property" do + it "has a #{property} property" do expect(described_class.attrtype(property)).to eq(:property) end end [:command, :minute, :hour, :weekday, :month, :monthday].each do |cronparam| - it "should have #{cronparam} of type CronParam" do + it "has #{cronparam} of type CronParam" do expect(described_class.attrclass(cronparam).ancestors).to include CronParam end end @@ -490,7 +490,7 @@ describe Puppet::Type.type(:cron), unless: Puppet.features.microsoft_windows? do describe 'special' do ['reboot', 'yearly', 'annually', 'monthly', 'weekly', 'daily', 'midnight', 'hourly'].each do |value| - it "should support the value '#{value}'" do + it "supports the value '#{value}'" do expect { described_class.new(name: 'foo', special: value) }.not_to raise_error end end @@ -498,7 +498,7 @@ describe Puppet::Type.type(:cron), unless: Puppet.features.microsoft_windows? do context 'when combined with numeric schedule fields' do context "which are 'absent'" do [['reboot', 'yearly', 'annually', 'monthly', 'weekly', 'daily', 'midnight', 'hourly'], :absent].flatten.each do |value| - it "should accept the value '#{value}' for special" do + it "accepts the value '#{value}' for special" do expect { described_class.new(name: 'foo', minute: :absent, special: value) }.not_to raise_error @@ -507,7 +507,7 @@ describe Puppet::Type.type(:cron), unless: Puppet.features.microsoft_windows? do end context 'which are not absent' do ['reboot', 'yearly', 'annually', 'monthly', 'weekly', 'daily', 'midnight', 'hourly'].each do |value| - it "should not accept the value '#{value}' for special" do + it "does not accept the value '#{value}' for special" do expect { described_class.new(name: 'foo', minute: '1', special: value) }.to raise_error(Puppet::Error, %r{cannot specify both a special schedule and a value}) |