I did it like this:
RSpec::Matchers.define :be_accessible do |*attributes|
match do |response|
description { "#{attributes.inspect} be accessible" }
attributes.each do |attribute|
failure_message_for_should { "#{attribute} should be accessible" }
failure_message_for_should_not { "#{attribute} should not be accessible" }
break false unless response.class.accessible_attributes.include?(attribute)
end
end
end
I inverted the loop matchand each. I think thatβs exactly how Rspec expects the block given to the method matchto be executed by the abstract match of Rspec (I think).
|*attributes|, Array.
, should be_accessible(:name, :surname, :description) .
, ,
should respond_to(:name, :surname, :description)
. .