diff options
author | Kris Bosland <kris.bosland@puppet.com> | 2018-05-21 12:11:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-21 12:11:35 -0700 |
commit | a707d78c4beb2c57e66aecd8b7e91a1c48fdf82d (patch) | |
tree | 6a959ddfb2ca50a0311c6dc75402c375565616fa /spec | |
parent | 35bd7f8e66499d0c70256e47d6248a29870f5aa2 (diff) | |
parent | 733bc4f4b88f3a29f66603561713fb0a18c6c947 (diff) | |
download | puppet-mailalias_core-a707d78c4beb2c57e66aecd8b7e91a1c48fdf82d.tar.gz puppet-mailalias_core-a707d78c4beb2c57e66aecd8b7e91a1c48fdf82d.tar.bz2 |
Merge pull request #7 from melissa/maint/master/1.0.3-release
Maint/master/1.0.3 release
Diffstat (limited to 'spec')
-rw-r--r-- | spec/acceptance/tests/create_spec.rb | 6 | ||||
-rw-r--r-- | spec/acceptance/tests/destroy_spec.rb | 8 | ||||
-rw-r--r-- | spec/acceptance/tests/modify_spec.rb | 9 | ||||
-rw-r--r-- | spec/shared_behaviours/all_parsedfile_providers.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 9 | ||||
-rw-r--r-- | spec/unit/type/mailalias_spec.rb | 4 |
6 files changed, 23 insertions, 15 deletions
diff --git a/spec/acceptance/tests/create_spec.rb b/spec/acceptance/tests/create_spec.rb index 82adfec..80fe8d3 100644 --- a/spec/acceptance/tests/create_spec.rb +++ b/spec/acceptance/tests/create_spec.rb @@ -16,13 +16,13 @@ RSpec.context 'Mailalias: should create an email alias' do end non_windows_agents.each do |agent| - it 'creates a mailalias with puppet' do + it 'creates a mailalias resource' do + # create a mailalias with puppet args = ['ensure=present', 'recipient="foo,bar,baz"'] on(agent, puppet_resource('mailalias', name, args)) - end - it 'verifies the alias exists' do + # verify the alias exists on(agent, 'cat /etc/aliases') do |res| assert_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias not in aliases file') end diff --git a/spec/acceptance/tests/destroy_spec.rb b/spec/acceptance/tests/destroy_spec.rb index 0f805a5..a5cb122 100644 --- a/spec/acceptance/tests/destroy_spec.rb +++ b/spec/acceptance/tests/destroy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -RSpec.context 'should delete an email alias' do +RSpec.context 'Mailalias: should delete an email alias' do name = "pl#{rand(999_999).to_i}" before(:all) do @@ -26,13 +26,13 @@ RSpec.context 'should delete an email alias' do end non_windows_agents.each do |agent| - it 'deletes the aliases database with puppet' do + it 'deletes a mailalias resource' do + # delete the aliases database with puppet args = ['ensure=absent', 'recipient="foo,bar,baz"'] on(agent, puppet_resource('mailalias', name, args)) - end - it 'verifies the alias is absent' do + # verify the alias is absent on(agent, 'cat /etc/aliases') do |res| assert_no_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias was not removed from aliases file') end diff --git a/spec/acceptance/tests/modify_spec.rb b/spec/acceptance/tests/modify_spec.rb index f4ea7bf..24903b6 100644 --- a/spec/acceptance/tests/modify_spec.rb +++ b/spec/acceptance/tests/modify_spec.rb @@ -1,11 +1,10 @@ require 'spec_helper_acceptance' -RSpec.context 'should modify an email alias' do +RSpec.context 'Mailalias: should modify an email alias' do name = "pl#{rand(999_999).to_i}" before(:all) do non_windows_agents.each do |agent| - #------- SETUP -------# # (setup) backup alias file on(agent, 'cp /etc/aliases /tmp/aliases', acceptable_exit_codes: [0, 1]) @@ -27,13 +26,13 @@ RSpec.context 'should modify an email alias' do end non_windows_agents.each do |agent| - it 'modifies the aliases database with puppet' do + it 'modifies an existing mailalias resource' do + # modify the aliases database with puppet args = ['ensure=present', 'recipient="foo,bar,baz,blarvitz"'] on(agent, puppet_resource('mailalias', name, args)) - end - it 'verifies the updated alias is present' do + # verify the updated alias is present on(agent, 'cat /etc/aliases') do |res| assert_match(%r{#{name}:.*foo,bar,baz,blarvitz}, res.stdout, 'updated mailalias not in aliases file') end diff --git a/spec/shared_behaviours/all_parsedfile_providers.rb b/spec/shared_behaviours/all_parsedfile_providers.rb index d697a14..1701fe3 100644 --- a/spec/shared_behaviours/all_parsedfile_providers.rb +++ b/spec/shared_behaviours/all_parsedfile_providers.rb @@ -5,7 +5,7 @@ shared_examples_for 'all parsedfile providers' do |provider, *files| files.flatten.each do |file| it "should rewrite #{file} reasonably unchanged" do - provider.stubs(:default_target).returns(file) + allow(provider).to receive(:default_target).and_return(file) provider.prefetch text = provider.to_file(provider.target_records(file)) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index efd225b..b71d71e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,7 @@ +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -27,4 +31,9 @@ end RSpec.configure do |c| 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 + end end diff --git a/spec/unit/type/mailalias_spec.rb b/spec/unit/type/mailalias_spec.rb index 1fb195e..80b838c 100644 --- a/spec/unit/type/mailalias_spec.rb +++ b/spec/unit/type/mailalias_spec.rb @@ -29,13 +29,13 @@ describe Puppet::Type.type(:mailalias) do it 'tries and set the recipient when it does the sync' do expect(recipient_resource.retrieve_resource[:recipient]).to eq(:absent) - recipient_resource.property(:recipient).expects(:set).with(['yay']) + expect(recipient_resource.property(:recipient)).to receive(:set).with(['yay']) recipient_resource.property(:recipient).sync end it 'tries and set the included file when it does the sync' do expect(file_resource.retrieve_resource[:file]).to eq(:absent) - file_resource.property(:file).expects(:set).with(tmpfile_path) + expect(file_resource.property(:file)).to receive(:set).with(tmpfile_path) file_resource.property(:file).sync end |