-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Cullen McDermott
committed
May 18, 2016
1 parent
82f79e2
commit 11964e7
Showing
5 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apt_repository 'default_action' | ||
|
||
apt_update 'explicit_action' do | ||
action :periodic | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
apt_update 'update_repo' do | ||
action :update | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'chefspec' | ||
|
||
describe 'apt_update::periodic' do | ||
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) } | ||
|
||
it 'updates apt with default action' do | ||
expect(chef_run).to periodic_apt_update('default_action') | ||
expect(chef_run).to_not periodic_apt_update('not_default_action') | ||
end | ||
|
||
it 'installs a apt_repository with an explicit action' do | ||
expect(chef_run).to periodic_apt_update('explicit_action') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'chefspec' | ||
|
||
describe 'apt_update::update' do | ||
let(:chef_run) { ChefSpec::SoloRunner.converge(described_recipe) } | ||
|
||
it 'updates apt repo' do | ||
expect(chef_run).to update_apt_update('update_repo') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module ChefSpec::API | ||
# @since 3.0.0 | ||
module AptRepositoryMatchers | ||
ChefSpec.define_matcher :apt_update | ||
|
||
# | ||
# Assert that an +apt_update+ resource exists in the Chef run with the | ||
# action +:update+. Given a Chef Recipe that adds "rsyslog" as a repository | ||
# to update. | ||
# apt_repository 'rsyslog' do | ||
# action :update | ||
# end | ||
# | ||
# The Examples section demonstrates the different ways to test an | ||
# +apt_update+ resource with ChefSpec. | ||
# | ||
# @example Assert that an +apt_update+ was run | ||
# expect(chef_run).to update_apt_update('rsyslog') | ||
# @param [String, Regex] resource_name | ||
# the name of the resource to match | ||
# | ||
# @return [ChefSpec::Matchers::ResourceMatcher] | ||
|
||
def update_apt_update(resource_name) | ||
ChefSpec::Matchers::ResourceMatcher.new(:apt_update, :update, | ||
resource_name) | ||
end | ||
|
||
# | ||
# Assert that an +apt_update+ resource exists in the Chef run | ||
# with the action +:periodic+. Given a Chef Recipe that updates "rsyslog" | ||
# as an +apt_update+: periodically | ||
# | ||
# apt_update 'rsyslog' do | ||
# action :periodic | ||
# end | ||
# | ||
# The Examples section demonstrates the different ways to test an | ||
# +apt_update+ resource with ChefSpec. | ||
# | ||
# @example Assert that an +apt_update+ was updated periodically | ||
# expect(chef_run).to periodic_apt_update('rsyslog') | ||
# @param [String, Regex] resource_name | ||
# the name of the resource to match | ||
# | ||
# @return [ChefSpec::Matchers::ResourceMatcher] | ||
|
||
|
||
end | ||
end |