Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Conversation

@myronmarston
Copy link
Member

This is the 2.99 counterpoint to #1361.

/cc @JonRowe

@JonRowe
Copy link
Member

JonRowe commented Mar 4, 2014

Seems legit to me, I liked the detection method ;)

myronmarston added a commit that referenced this pull request Mar 4, 2014
Add deprecation for `described_class` change coming in 3.0.
@myronmarston myronmarston merged commit 73e2a45 into 2-99-maintenance Mar 4, 2014
@myronmarston myronmarston deleted the nested-described-class-deprecation branch March 4, 2014 21:42
@myronmarston
Copy link
Member Author

Thanks for reviewing, @JonRowe.

@jjb
Copy link

jjb commented Jun 3, 2014

This makes 2.99 incompatible with rails 4.0.5, right?

     Failure/Error: Unable to find matching line from backtrace
       --------------------------------------------------------------------------------
       The semantics of `described_class` in a nested `describe <SomeClass>`
       example group are changing in RSpec 3. In RSpec 2.x, `described_class`
       would return the outermost described class (SubscriptionsController).
       In RSpec 3, it will return the innermost described class (SubscriptionsController::ResponseHandler).
       In general, we recommend not describing multiple classes or objects in a
       nested manner as it creates confusion.

       To make your code compatible with RSpec 3, change from `described_class` to a reference
       to `SubscriptionsController::ResponseHandler`, or change the arg of the inner `describe` to a string.
       (Called from /Users/john/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/actionpack-4.0.5/lib/action_controller/test_case.rb:592:in `setup_controller_request_and_response')

@JonRowe
Copy link
Member

JonRowe commented Jun 3, 2014

It shouldn't do, unless you set a class name in an inner describe/context you should never see this message, and even if you're doing that simply changing it to use a string or specifying the subject directly would fix it. Can you gist your spec?

@jjb
Copy link

jjb commented Jun 3, 2014

whoops, you are right -- after looking at my example the problem was obvious right away.

to be honest when i made the comment i was just blindingly going by the error message presented, which pointed to a line in rails 😳

(i blame the excellent detailed guidance in all the other deprecation warnings for making me lazy...)

@myronmarston
Copy link
Member Author

i blame the excellent detailed guidance in all the other deprecation warnings for making me lazy...

Got it. We'll be sure to work hard at providing less detailed guidance when RSpec 4 rolls around in a few years.

@jjb
Copy link

jjb commented Jun 4, 2014

:-D

yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 6, 2021
…cribed-class-deprecation

Add deprecation for `described_class` change coming in 3.0.

---
This commit was imported from rspec/rspec-core@73e2a45.
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 this pull request may close these issues.

3 participants