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. #997

Open
justuswilhelm opened this issue Mar 16, 2014 · 7 comments · May be fixed by #1028
Open

RSpec failure_message_for_should_not is deprecated. #997

justuswilhelm opened this issue Mar 16, 2014 · 7 comments · May be fixed by #1028

Comments

@justuswilhelm
Copy link

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)>'.
@zamith
Copy link

zamith commented Mar 25, 2014

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

@xhoy
Copy link

xhoy commented Apr 10, 2014

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!

@dchacke
Copy link

dchacke commented Jul 8, 2014

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.

@justuswilhelm
Copy link
Author

Very helpful. Thank you very much!

@vdmgolub
Copy link

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

@justin808
Copy link

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

serg-kovalev pushed a commit to serg-kovalev/cancan that referenced this issue Mar 9, 2015
@serg-kovalev
Copy link

Has anyone interested?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants