cancan icon indicating copy to clipboard operation
cancan copied to clipboard

RSpec `failure_message_for_should_not` is deprecated.

Open justuswilhelm opened this issue 10 years ago • 7 comments

I am getting this deprecation warning when using Rails 4.0.3, Rspec 3.0.0.beta2 and cancan 1.6.10.

`failure_message_for_should_not` is deprecated. Use `failure_message_when_negated`
instead. Called from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/cancan-
1.6.10/lib/cancan/matchers.rb:11:in `block in <top (required)>'.

justuswilhelm avatar Mar 16 '14 10:03 justuswilhelm

@justuswilhelm CanCan development has been stopped for a while now, please take a look at #994

zamith avatar Mar 25 '14 01:03 zamith

Dear submitter, Since cancan/raynB hasn't been active for more than 6 months and no body else then ryam himself has commit permissions the cancan project is on a stand still. Since cancan has several issues including missing support for rails 4 cancan is moving forward to cancancan. More details on: #994

If your feel that your pull request or bug is still applicable (and hasn't been merged in to cancan) it would be really appreciated if you would resubmit it to cancancan (https://github.com/cancancommunity/cancancan)

We hope to see you on the other side!

xhoy avatar Apr 10 '14 11:04 xhoy

Might be a little late, but for anyone coming from Google: I just ran into the same issue, and installing cancancan didn't solve it for me.

@justuswilhelm If you want to fix this, simply write your own matcher (more info on that here):

RSpec::Matchers.define :be_able_to do |*args|
  match do |ability|
    ability.can?(*args)
  end

  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
end

Note that this uses #failure_message and #failure_message_when_negated instead of the deprecated methods and makes the deprecation warnings disappear.

dchacke avatar Jul 08 '14 00:07 dchacke

Very helpful. Thank you very much!

justuswilhelm avatar Jul 08 '14 08:07 justuswilhelm

I can recommend to switch to https://github.com/CanCanCommunity/cancancan which is community maintained CanCan fork. This issue is fixed there: https://github.com/CanCanCommunity/cancancan/issues/38

vdmgolub avatar Aug 11 '14 11:08 vdmgolub

I can confirm that cancancan just resolved that issue for me with rspec 3.

justin808 avatar Aug 12 '14 06:08 justin808

Has anyone interested?

serg-kovalev avatar Mar 19 '15 09:03 serg-kovalev