Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

chef_gem support only if chef supports it.

The chef_gem resource was added in chef 0.10.10. We shouldn't add in the chef_gem matcher
unless the chef version supports it.
  • Loading branch information...
commit f4b56cda70ab99c91aee850a38e34885cf33a09d 1 parent 1f73c73
@jimhopp-lookout jimhopp-lookout authored
View
1  Rakefile
@@ -19,6 +19,7 @@ def register_spec_features(spec_type)
"Run Cucumber features (#{spec_type} support only)") do |t|
t.cucumber_opts = "CS_SPEC_TYPE=#{spec_type} features --format pretty"
t.cucumber_opts << ' -t ~@requires_chef_10' if Chef::VERSION.start_with? '0.9.'
+ t.cucumber_opts << ' -t ~@chefgem' unless defined?(Chef::Resource::ChefGem)
t.cucumber_opts << " -t ~@not_implemented_#{spec_type.downcase}"
end
end
View
1  features/write_examples_for_chef_gem_packages.feature
@@ -1,3 +1,4 @@
+@chefgem
Feature: Write examples for chef gem packages
Express an expectation that a chef gem package will be installed:
View
7 lib/chefspec/matchers/package.rb
@@ -3,7 +3,10 @@
module ChefSpec
module Matchers
- define_resource_matchers([:install, :remove, :upgrade, :purge], [:package, :gem_package, :chef_gem], :package_name)
+ CHEF_GEM_SUPPORTED = defined?(::Chef::Resource::ChefGem)
+ PACKAGE_TYPES = [:package, :gem_package, :chef_gem]
+ PACKAGE_TYPES << :chef_gem if CHEF_GEM_SUPPORTED
+ define_resource_matchers([:install, :remove, :upgrade, :purge], PACKAGE_TYPES, :package_name)
RSpec::Matchers.define :install_package_at_version do |package_name, version|
match do |chef_run|
@@ -25,6 +28,6 @@ module Matchers
resource_type(resource) == 'chef_gem' and resource.package_name == package_name and resource.action.to_s.include? 'install' and resource.version == version
end
end
- end
+ end if CHEF_GEM_SUPPORTED
end
end
View
2  spec/chefspec/matchers/chef_gem_package_spec.rb
@@ -2,7 +2,7 @@
module ChefSpec
module Matchers
- describe :install_chef_gem_at_version do
+ describe :install_chef_gem_at_version, :if => defined?(::Chef::Resource::ChefGem) do
describe "#match" do
let(:matcher) { install_chef_gem_at_version('foo', '1.2.3') }
it "should not match when no resources exist" do
Please sign in to comment.
Something went wrong with that request. Please try again.