Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

RSpec failure_message_for_should_not is deprecated #1028

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 16 additions & 6 deletions lib/cancan/matchers.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
rspec_module = defined?(RSpec::Core) ? 'RSpec' : 'Spec' # for RSpec 1 compatability
rspec_module = defined?(RSpec::Core) ? 'RSpec' : 'Spec' # for RSpec 1 compatability
Kernel.const_get(rspec_module)::Matchers.define :be_able_to do |*args|
match do |ability|
ability.can?(*args)
end

failure_message_for_should do |ability|
"expected to be able to #{args.map(&:inspect).join(" ")}"
end
if respond_to?(:failure_message) && respond_to?(:failure_message_when_negated)
failure_message do |ability|
"expected to be able to #{args.map(&:inspect).join(" ")}"
end

failure_message_when_negated do |ability|
"expected not to be able to #{args.map(&:inspect).join(" ")}"
end
else
failure_message_for_should do |ability|
"expected to be able to #{args.map(&:inspect).join(" ")}"
end

failure_message_for_should_not do |ability|
"expected not to be able to #{args.map(&:inspect).join(" ")}"
failure_message_for_should_not do |ability|
"expected not to be able to #{args.map(&:inspect).join(" ")}"
end
end
end