Skip to content

Commit

Permalink
[COOK-4154] - Add chefspec matchers.rb file to apt cookbook
Browse files Browse the repository at this point in the history
Signed-off-by: Sean OMeara <someara@opscode.com>
  • Loading branch information
joestump authored and Sean OMeara committed Jan 30, 2014
1 parent 0b7a7d0 commit 0a5e783
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions libraries/matchers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if defined?(ChefSpec)
def add_apt_preference(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:apt_preference, :add, resource_name)
end

def remove_apt_preference(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:apt_preference, :remove, resource_name)
end

def add_apt_repository(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :add, resource_name)
end

def remove_apt_repository(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:apt_repository, :remove, resource_name)
end
end
2 changes: 2 additions & 0 deletions resources/preference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#

actions :add, :remove
default_action :add if defined?(default_action) # Chef > 10.8

# Needed for Chef versions < 0.10.10
def initialize(*args)
super
@action = :add
Expand Down
2 changes: 2 additions & 0 deletions resources/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#

actions :add, :remove
default_action :add if defined?(default_action) # Chef > 10.8

# Needed for Chef versions < 0.10.10
def initialize(*args)
super
@action = :add
Expand Down

0 comments on commit 0a5e783

Please sign in to comment.