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

[WIP] fix for RSpec deprecation warning, take III #335

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

afeld
Copy link

@afeld afeld commented Jul 10, 2015

Follow-up to #328, which didn't do the trick unfortunately. Still getting the same error as #327 (comment), because metadata[:parent_example_group] is still being accessed.

@@ -9,6 +9,12 @@ def rspec_summary_args(*args)
[n.new(*args)]
end

# Returns a Hash that throws an error if a key is accessed that isn't set.
def hash_double(attrs)
dbl = Hash.new{|hsh, key| raise "Missing key: #{key.inspect}." }

Choose a reason for hiding this comment

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

Unused block argument - hsh. If it's necessary, use _ or _hsh as an argument name to indicate that it won't be used.
Space missing to the left of {.
Space between { and | missing.

@e2
Copy link
Contributor

e2 commented Jul 10, 2015

Be sure to check out: https://github.com/rspec/rspec-core/blob/master/Changelog.md#300rc1--2014-05-18

quote:

Restructure example group metadata so that the computed keys are exposed directly off of the metadata hash rather than being on a nested :example_group subhash. In addition, the parent example group metadata is now available as [:parent_example_group] rather than [:example_group][:example_group]. Deprecated access via the old key structure is still provided. (Myron Marston)

Ideally, provide the metadata you have that's creating the deprecation.

It's one thing to avoid the deprecation, it's another to get the location properly regardless of the RSpec version - it's best to have an extra spec that demonstrates how to get the deprecation.

From what I understand, accessing :parent_example_group is fine (as opposed to using :example_group).

With this code, :parent_example_group should be used, which should not trigger the deprecation, as is here:

metadata = metadata[:parent_example_group] || metadata[:example_group]

Anyway, I'm a bit confused about the issue. Good specs would help.

@e2
Copy link
Contributor

e2 commented Jul 10, 2015

If you can, extract the example with the deprecation into a repo, and I'll check it out - I don't like the way the implementation iterates to get the location, but I want to reproduce your exact scenario (example, nesting, file, whether you're using shared examples or not) before I change anything.

@e2
Copy link
Contributor

e2 commented Jul 10, 2015

Maybe an update: if you're using RSpec 3.3.x, you shouldn't have the deprecations, because this line should always be true:

until spec_path?(location)

(This means, if you're getting the deprecations, then somehow strangely spec_path? is returning false - which seems wrong).

You can also config.raise_errors_for_deprecations! in your spec/spec_helper.rb to help stop as soon as the error occurs.

@e2
Copy link
Contributor

e2 commented Jul 23, 2015

The deprecation error is likely because of this: #338

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.

3 participants