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

before.all executed again for all nested example groups. #91

Open
PhilHarnish opened this issue Dec 24, 2017 · 2 comments
Open

before.all executed again for all nested example groups. #91

PhilHarnish opened this issue Dec 24, 2017 · 2 comments
Labels

Comments

@PhilHarnish
Copy link

before.all seems to be executed for each example group (good) and again for all inner groups (bad?). Perhaps this is even WAI and the "fix" is more clarification in the docs?

This behavior started once I updated:

$ mamba --version
0.8.6
# ^ This version was OK.
$ pip install mamba -U
Collecting mamba
  Downloading mamba-0.9.2.tar.gz
# (...snip...)

Here's a sample test:

from spec.mamba import *

times_called = 0

with description('has before all'):
  with before.all:
    global times_called
    print('Running before.all')
    times_called += 1

  with it('should have run before.all once'):
    expect(times_called).to(equal(1))

  with description('inner description'):
    with it('should have run before.all once'):
      expect(times_called).to(equal(1))  # Fails; times_called == 2.

  with context('inner context'):
    with it('should have run before.all once'):
      expect(times_called).to(equal(1))  # Fails; times_called == 3.
@nestorsalceda
Copy link
Owner

Aye, this is my fault!

Going to fix it!

Thanks for reporting @PhilHarnish !

nestorsalceda added a commit that referenced this issue Jan 26, 2018
nestorsalceda added a commit that referenced this issue Jan 26, 2018
Is same case that #91 but with after_all.

Right now, an *_all hook is going to be executed only if is declared in
example_group. Do not goes up to parent nodes
@nestorsalceda
Copy link
Owner

It's fixed now!

I'm going to prepare a release for next week for closing this issue.

Thanks!

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

No branches or pull requests

2 participants