diff --git a/lib/chefspec/matchers/resource_matcher.rb b/lib/chefspec/matchers/resource_matcher.rb index 25b188b9..18b431fc 100644 --- a/lib/chefspec/matchers/resource_matcher.rb +++ b/lib/chefspec/matchers/resource_matcher.rb @@ -40,6 +40,10 @@ def method_missing(m, *args, &block) end end + def respond_to_missing?(m, include_private = false) + m.to_s.match?(/^with_(.+)$/) || super + end + def description %Q{#{@expected_action} #{@resource_name} "#{@expected_identity}"} end diff --git a/spec/unit/matchers/resource_matcher_spec.rb b/spec/unit/matchers/resource_matcher_spec.rb index aec15441..691ffcc4 100644 --- a/spec/unit/matchers/resource_matcher_spec.rb +++ b/spec/unit/matchers/resource_matcher_spec.rb @@ -1,5 +1,15 @@ require "spec_helper" describe ChefSpec::Matchers::ResourceMatcher do - pending + subject { described_class.new(:template, :create, "/etc/foo") } + + describe "#respond_to?" do + it "reports responding to dynamic with_* matcher methods" do + expect(subject).to respond_to(:with_owner) + end + + it "does not report responding to unrelated missing methods" do + expect(subject).not_to respond_to(:nonexistent_method) + end + end end