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

Shared context / global config before hooks called in wrong order #921

Closed
maltoe opened this issue May 29, 2013 · 7 comments
Closed

Shared context / global config before hooks called in wrong order #921

maltoe opened this issue May 29, 2013 · 7 comments

Comments

@maltoe
Copy link

maltoe commented May 29, 2013

Hi all,

we're using shared context with metadata inclusion and were surprised to see that the order of before hooks in that shared context and in the global configure block is mixed up depending on at which level we include the shared context. Is this intended behaviour?

See https://gist.github.com/maltoe/5662305 for an example. We're using rspec 2.13.1.

Regards,
Malte

[reposted from rspec/rspec-dev#41]

@JonRowe
Copy link
Member

JonRowe commented Jun 13, 2013

Hi your gist contains no output so doesn't tell us what you're seeing and what you're expecting. Can you clarify? If you could also try on 2.14.0.rc1 that'd help too.

@cupakromer
Copy link
Member

@JonRowe I've reproduced using Ruby 2.0.0 and RSpec 2.13.1. For me, and what I believe @maltoe is pointing out is that the expected order should be:

  1. RSpec.configure before blocks
  2. Mixed in before blocks

However, with 2.13.1, this doesn't happen:

Outer Describe
spec helper config before all
  Inner Describe with metadata
shared context before all

    Example
Outer Describe with metadata
shared context before all    <== NOT EXPECTED

spec helper config before all
  Inner Describe
    Example

The issue doesn't happen using RSpec 2.14.0.rc1:

Outer Describe
spec helper config before all
  Inner Describe with metadata
shared context before all

    Example
Outer Describe with metadata
spec helper config before all
shared context before all
  Inner Describe

    Example

This seems to only be an issue with the outer most describe.

@maltoe
Copy link
Author

maltoe commented Jun 17, 2013

@cupakromer Exactly. I expect the global Rspec.configure before hook to b executed before the mixed in shared context' one (therefore the instance variable being set). When I include the shared context in a nested describe block, it works as expected, but when I include it in the outer-most describe block, it doesn't.

I just tested the thing again using include_context and it works, so it has to be an issue with including shared contexts using metadata matching?

@maltoe maltoe closed this as completed Jun 17, 2013
@maltoe maltoe reopened this Jun 17, 2013
@maltoe
Copy link
Author

maltoe commented Jun 17, 2013

Sorry wrong button.

@JonRowe
Copy link
Member

JonRowe commented Jun 17, 2013

No it's just an issue with including shared contexts due to the internals of how it works, (ancestry order). Have you tried 2.14.0rc1 ?

@myronmarston
Copy link
Member

This was fixed in #845, which is in 2.14.0.rc1. Closing.

If the fix in 2.14.0.rc1 doesn't work for you, feel free to comment here with an example that doesn't work and we'll be happy to re-open.

@JonRowe
Copy link
Member

JonRowe commented Jun 18, 2013

Ah there's the PR I couldn't find ;)

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

No branches or pull requests

4 participants