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

Refactor memoized helpers #937

Merged
merged 2 commits into from
Jun 10, 2013
Merged

Conversation

alindeman
Copy link
Contributor

This is a cleanup of #871 that @JonRowe and I worked on.

It fixes #908 and #817 and is references in (rspec/rspec-rails#738)

We're not 100% thrilled with it, but we could not think of a better way to fix the relevant issues while still allowing super within let.

Thoughts?

@coveralls
Copy link

Coverage Status

Coverage increased (+0%) when pulling ec4056a on alindeman:refactor_memoized_helpers into bbc83ce on rspec:master.

MemoizedHelpers.module_for(example_group).__send__(:define_method, memoized_method_name, &block)

# Apply the memoization. The method has been defined in an ancestor
# module so we can use `super` here to get the value.
Copy link
Member

Choose a reason for hiding this comment

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

The comment about super is inaccurate and a bit confusing now.

@myronmarston
Copy link
Member

I was hoping to find a way to solve this by delaying when the LetDefinitions module gets included in the example group (to ensure it always takes priority), but I think I remember talking through this idea with you, @alindeman and you had said you had tried it, right?

I'm going to try to take a shot at that in the next day or two to see if I can find a solution. If I don't get around to it by Wednesday, I'm fine merging this solution, as this definitely solves the issue.

@JonRowe
Copy link
Member

JonRowe commented Jun 10, 2013

We tried that today @myronmarston but by being after everything else it breaks because things like shared contexts require lets to be before them. E.g. theres a complex relationship with load order, seems that could become brittle and is arguably more complex. Happy to help find a better solution.

@myronmarston
Copy link
Member

@JonRowe -- yep, I just tried it for a while just now, and you're right, there's quite a complex ordering dependency :(.

This PR seems like the best solution to me now, too. I'm glad I tried for a bit, though -- it helped me develop a proper appreciation for the difficulty of this problem!

JonRowe added a commit that referenced this pull request Jun 10, 2013
@JonRowe JonRowe merged commit 3efa3fd into rspec:master Jun 10, 2013
@myronmarston
Copy link
Member

@JonRowe -- can you add a changelog entry for this?

@JonRowe
Copy link
Member

JonRowe commented Jun 10, 2013

Yep, I intend to I'm also going to update the comments as asked.

@JonRowe
Copy link
Member

JonRowe commented Jun 10, 2013

(I figured it was easier to merge this then go from there to do so)

@myronmarston
Copy link
Member

Also, I think we'll want this fix in 2.14 and 2.99 as well...

If we're going to fix up the comments a bit as I suggested above, it'd probably be good to do that before merging this across into those branches.

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.

4 participants