Commit df0ad1b5 by John Hawthorn

Merge pull request #197 from lime/rspec2-compat

Fix matcher compatibility with RSpec 2
parents bfde2aac 1c654a2f
......@@ -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