Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/chefspec/matchers/resource_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
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
Expand Down Expand Up @@ -77,7 +81,7 @@
" with action :#{@expected_action} to be in Chef run." \
" Other #{@resource_name} resources:" \
"\n\n" \
" " + similar_resources.map(&:to_s).join("\n ") + "\n "

Check failure on line 84 in lib/chefspec/matchers/resource_matcher.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Style/MapJoin: Remove redundant map(&:to_s) before join.
end
end

Expand Down
12 changes: 11 additions & 1 deletion spec/unit/matchers/resource_matcher_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading