Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumps rspec to 3.0.0 (release) and fixes deprecation warnings #4

Closed
wants to merge 2 commits into from

Conversation

andypike
Copy link
Contributor

We are using cancan in a rails 4 project. When we upgraded to rspec 3.0.0.beta2 we got a few deprecation warnings from cancan. Upon investigation, cancan seems to be dead but we found that cancancan seemed to be the successor.

To fix the deprecation we bumped rspec to 3.0.0.beta2 and fixed all the deprecation warnings. All the specs pass and I'm currently using this branch in our rails 4 project (everything still green).

I'm not sure what the plan is for cancancan and rspec compatibility, but if you want to move to rspec 3, this is a good starting point for you.

Enjoy.

@bryanrite
Copy link
Member

Thanks @andypike, I'm setting up Appraisal so I can properly test CanCanCan vs multiple versions of Rails, I'll do something similar using this for RSpec as well.

Thanks for your help!

@@ -7,12 +7,12 @@

it "is able to :read anything" do
@ability.can :read, :all
expect(@ability.can?(:read, String)).to be_true
expect(@ability.can?(:read, 123)).to be_true
expect(@ability.can?(:read, String)).to be(true)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use be_truthy/be_falsey instead.
rspec/rspec-expectations#283

What do you think?

@ck3g
Copy link

ck3g commented Jun 4, 2014

As soon as RSpec 3.0 has been released http://rubygems.org/gems/rspec
👍 for this

@bolshakov
Copy link

Rspec 3.0 released

@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
s.files = Dir["{lib,spec}/**/*", "[A-Z]*", "init.rb"] - ["Gemfile.lock"]
s.require_path = "lib"

s.add_development_dependency 'rspec', '~> 2.14'
s.add_development_dependency 'rspec', '~> 3.0.0.beta2'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also could update to '~> 3.0.0'

@jcoyne
Copy link

jcoyne commented Jun 11, 2014

👍

@andypike
Copy link
Contributor Author

I'll update the PR and will push up for you shortly 😄

@andypike
Copy link
Contributor Author

Actually, looking at master some of these changes have already made it in. Not sure if this PR is of much value. Should we close this?

@ck3g
Copy link

ck3g commented Jun 11, 2014

@andypike
Copy link
Contributor Author

OK 😄

I've merged upstream master and bumped rspec to the 3.0.0 release. All specs pass and no deprecation warnings. I've kept the be(true) in place where possible so the specs are more specific. If a spec used to use be_false but returns a falsey value (such as nil) then I've changed these to be_truthy or be_falsey.

Hope this is ok with everyone ✨ ❤️

@andypike andypike changed the title Bumps rspec to 3.0.0.beta2 and fixes deprecation warnings Bumps rspec to 3.0.0 (release) and fixes deprecation warnings Jun 11, 2014
@jcoyne
Copy link

jcoyne commented Jun 11, 2014

@andypike Thanks! 🔆

@bryanrite
Copy link
Member

Thanks so much for this! I haven't had a chance to look this over, but will it support be_able_to matchers for libs still on RSpec < 3 or do we need to add the aliases as was done in #10?

@ersatzryan
Copy link

Any word on this? Anything I can do to help?

@andypike
Copy link
Contributor Author

I haven't had a chance to look at the be_able_to matchers as mentioned above. I can add the same aliases as in #10 if someone can confirm that's all we need. Thanks.

@bryanrite
Copy link
Member

Sorry, I've been in the middle of a move to a new country and have been super busy. I should have time to take a look at this tomorrow, I know its needed by many.

@bryanrite bryanrite mentioned this pull request Jun 24, 2014
@bryanrite
Copy link
Member

Ok, I had to do a bit of tweaking to get backwards compatibility so i've merged this into #85... just waiting on Travis, but all looks good locally with both RSpec 2 and RSpec 3, so I'll merge this and release 1.8.3 today. Let me know if anyone has any issues!

@bryanrite bryanrite closed this Jun 24, 2014
@jcoyne
Copy link

jcoyne commented Jun 24, 2014

I'm getting:

undefined method `failure_message_for_should' for class `RSpec::Matchers::DifferentiateBlockMethodTypes'

when using rspec 2.99.0 and cancancan 1.8.3. It works fine with cancan 1.8.2

when running a test like:

 it { should_not be_able_to(:update, asset) }

@jcoyne
Copy link

jcoyne commented Jun 24, 2014

Perhaps we need to add:

  alias failure_message_for_should failure_message
  alias failure_message_for_should_not failure_message_when_negated

as was done in #10

@bryanrite
Copy link
Member

Bah, I tried with RSpec 2.14 and 3.0, here must be something in their 2.99 'deprecation' release... Lemme have a quick look, and i'll pull 1.8.3

@bryanrite
Copy link
Member

@jcoyne Do you mind testing against: feature/fix_rspec_299?

I've changed the way we detect the custom matcher error method, it works locally for me for RSpec 2.14, 2.99, and 3, but I'd like a second opinion.

@jcoyne
Copy link

jcoyne commented Jun 24, 2014

@bryanrite I tested that branch. It works great. 👏

@bryanrite
Copy link
Member

@jcoyne Thanks! Pushed 1.8.4

coorasse pushed a commit that referenced this pull request Jul 6, 2022
author Remo Fritzsche <remo.fritzsche@sitrox.com> 1612868567 +0100
committer Alessandro Rodi <coorasse@gmail.com> 1657114188 +0200

# This is a combination of 4 commits.
# This is the 1st commit message:

Preserve nil values as extra arguments

# This is the commit message #2:

Fix link (#744)

# This is the commit message #3:

Documentation fixes and improvements

- fix typo, punctuations, and grammar
- fix broken and misformatted links
- fix code sample

# This is the commit message #4:

Format documentation/guides and fix linting issues

The motivation of the changes is to make these documents neater when
reading offline using a text or code editor.

Reading the documentation offline is faster, and the source code is
readily available for further learning.

The changes do not affect the meaning of each documentation or
instruction.

The following changes were made:
- remove extra and trailing spaces
- add new lines to separate the title, explanation, code samples, etc
- fix headings, links
- specify code block language (bash, ruby)

Updated Devise.md as exception is changed

CanCan::Unathorized exception not exists anymore, CanCan::AccessDenied is used. Also added responses for different content types as a recommendation.

Add support for non-hash conditions

Co-authored-by: Juleffel <juleffel@protonmail.com>

Improve ability checks with Hashes

Add Ruby 3.0 and Ruby 3.1 to CI

Drop ActiveRecord4 from CI (#778)
coorasse pushed a commit that referenced this pull request Jul 6, 2022
author Remo Fritzsche <remo.fritzsche@sitrox.com> 1612868567 +0100
committer Alessandro Rodi <coorasse@gmail.com> 1657114188 +0200

# This is a combination of 4 commits.
# This is the 1st commit message:

Preserve nil values as extra arguments

# This is the commit message #2:

Fix link (#744)

# This is the commit message #3:

Documentation fixes and improvements

- fix typo, punctuations, and grammar
- fix broken and misformatted links
- fix code sample

# This is the commit message #4:

Format documentation/guides and fix linting issues

The motivation of the changes is to make these documents neater when
reading offline using a text or code editor.

Reading the documentation offline is faster, and the source code is
readily available for further learning.

The changes do not affect the meaning of each documentation or
instruction.

The following changes were made:
- remove extra and trailing spaces
- add new lines to separate the title, explanation, code samples, etc
- fix headings, links
- specify code block language (bash, ruby)

Updated Devise.md as exception is changed

CanCan::Unathorized exception not exists anymore, CanCan::AccessDenied is used. Also added responses for different content types as a recommendation.

Add support for non-hash conditions

Co-authored-by: Juleffel <juleffel@protonmail.com>

Improve ability checks with Hashes

Add Ruby 3.0 and Ruby 3.1 to CI

Drop ActiveRecord4 from CI (#778)
coorasse pushed a commit that referenced this pull request Jul 6, 2022
author Remo Fritzsche <remo.fritzsche@sitrox.com> 1612868567 +0100
committer Alessandro Rodi <coorasse@gmail.com> 1657114188 +0200

# This is a combination of 4 commits.
# This is the 1st commit message:

Preserve nil values as extra arguments

# This is the commit message #2:

Fix link (#744)

# This is the commit message #3:

Documentation fixes and improvements

- fix typo, punctuations, and grammar
- fix broken and misformatted links
- fix code sample

# This is the commit message #4:

Format documentation/guides and fix linting issues

The motivation of the changes is to make these documents neater when
reading offline using a text or code editor.

Reading the documentation offline is faster, and the source code is
readily available for further learning.

The changes do not affect the meaning of each documentation or
instruction.

The following changes were made:
- remove extra and trailing spaces
- add new lines to separate the title, explanation, code samples, etc
- fix headings, links
- specify code block language (bash, ruby)

Updated Devise.md as exception is changed

CanCan::Unathorized exception not exists anymore, CanCan::AccessDenied is used. Also added responses for different content types as a recommendation.

Add support for non-hash conditions

Co-authored-by: Juleffel <juleffel@protonmail.com>

Improve ability checks with Hashes

Add Ruby 3.0 and Ruby 3.1 to CI

Drop ActiveRecord4 from CI (#778)
coorasse pushed a commit that referenced this pull request Jul 6, 2022
author Remo Fritzsche <remo.fritzsche@sitrox.com> 1612868567 +0100
committer Alessandro Rodi <coorasse@gmail.com> 1657114188 +0200

# This is a combination of 4 commits.
# This is the 1st commit message:

Preserve nil values as extra arguments

# This is the commit message #2:

Fix link (#744)

# This is the commit message #3:

Documentation fixes and improvements

- fix typo, punctuations, and grammar
- fix broken and misformatted links
- fix code sample

# This is the commit message #4:

Format documentation/guides and fix linting issues

The motivation of the changes is to make these documents neater when
reading offline using a text or code editor.

Reading the documentation offline is faster, and the source code is
readily available for further learning.

The changes do not affect the meaning of each documentation or
instruction.

The following changes were made:
- remove extra and trailing spaces
- add new lines to separate the title, explanation, code samples, etc
- fix headings, links
- specify code block language (bash, ruby)

Updated Devise.md as exception is changed

CanCan::Unathorized exception not exists anymore, CanCan::AccessDenied is used. Also added responses for different content types as a recommendation.

Add support for non-hash conditions

Co-authored-by: Juleffel <juleffel@protonmail.com>

Improve ability checks with Hashes

Add Ruby 3.0 and Ruby 3.1 to CI

Drop ActiveRecord4 from CI (#778)
coorasse pushed a commit that referenced this pull request Jul 6, 2022
author Remo Fritzsche <remo.fritzsche@sitrox.com> 1612868567 +0100
committer Alessandro Rodi <coorasse@gmail.com> 1657114188 +0200

# This is a combination of 4 commits.
# This is the 1st commit message:

Preserve nil values as extra arguments

# This is the commit message #2:

Fix link (#744)

# This is the commit message #3:

Documentation fixes and improvements

- fix typo, punctuations, and grammar
- fix broken and misformatted links
- fix code sample

# This is the commit message #4:

Format documentation/guides and fix linting issues

The motivation of the changes is to make these documents neater when
reading offline using a text or code editor.

Reading the documentation offline is faster, and the source code is
readily available for further learning.

The changes do not affect the meaning of each documentation or
instruction.

The following changes were made:
- remove extra and trailing spaces
- add new lines to separate the title, explanation, code samples, etc
- fix headings, links
- specify code block language (bash, ruby)

Updated Devise.md as exception is changed

CanCan::Unathorized exception not exists anymore, CanCan::AccessDenied is used. Also added responses for different content types as a recommendation.

Add support for non-hash conditions

Co-authored-by: Juleffel <juleffel@protonmail.com>

Improve ability checks with Hashes

Add Ruby 3.0 and Ruby 3.1 to CI

Drop ActiveRecord4 from CI (#778)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants