lib/paranoia/rspec.rb in paranoia-2.0.4 vs lib/paranoia/rspec.rb in paranoia-2.0.5
- old
+ new
@@ -2,12 +2,22 @@
# Validate the subject's class did call "acts_as_paranoid"
RSpec::Matchers.define :act_as_paranoid do
match { |subject| subject.class.ancestors.include?(Paranoia) }
- failure_message { "expected #{subject.class} to use `acts_as_paranoid`" }
- failure_message_when_negated { "expected #{subject.class} not to use `acts_as_paranoid`" }
+ failure_message_proc = lambda do
+ "expected #{subject.class} to use `acts_as_paranoid`"
+ end
- # RSpec 2 compatibility:
- alias_method :failure_message_for_should, :failure_message
- alias_method :failure_message_for_should_not, :failure_message_when_negated
+ failure_message_when_negated_proc = lambda do
+ "expected #{subject.class} not to use `acts_as_paranoid`"
+ end
+
+ if respond_to?(:failure_message_when_negated)
+ failure_message(&failure_message_proc)
+ failure_message_when_negated(&failure_message_when_negated_proc)
+ else
+ # RSpec 2 compatibility:
+ failure_message_for_should(&failure_message_proc)
+ failure_message_for_should_not(&failure_message_when_negated_proc)
+ end
end