Commit 1c654a2f by Emil Sågfors

Fix compatibility with RSpec 2

The changes in 40b7af58 were insufficient, this should do the trick.
parent 641ff4a3
......@@ -4,10 +4,20 @@ require 'rspec/expectations'
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment