Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Allow enhance() to be called multiple times #2

Open
wants to merge 1 commit into from

2 participants

@Almad

This way, enhance() can be called multiple times, which is useful
when it's done on top of module level.
Otherwise, wrapped method will call itself infinitely.

@Almad Almad Store _enhanced early enough
This way, enhance() can be called multiple times, which is useful
when it's done on top of module level.
Otherwise, wrapped method will call itself infinitely.
7b4dcd4
@lightsofapollo

@Almad Looks good, but is it possible to add a related test for this?

@Almad

I missed the test suite, will try to look into it. This breaks current suite, so it might take a while ,)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 9, 2012
  1. @Almad

    Store _enhanced early enough

    Almad authored
    This way, enhance() can be called multiple times, which is useful
    when it's done on top of module level.
    Otherwise, wrapped method will call itself infinitely.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 5 deletions.
  1. +1 −2  lib/mocha-hooks.js
  2. +5 −3 lib/sinon-mocha.js
View
3  lib/mocha-hooks.js
@@ -40,11 +40,10 @@ MochaHooks = {
beforeEachHook.ctx = suite.ctx;
beforeEachHook.timeout(suite.timeout());
suite._beforeEach.unshift(beforeEachHook);
-
- MochaHooks._enhanced = true;
}
return runSuite.apply(this, arguments);
};
+ MochaHooks._enhanced = true;
},
/**
View
8 lib/sinon-mocha.js
@@ -10,9 +10,11 @@ SinonMocha = {
enhance: function(sinon, mocha){
SinonMocha.sinon = sinon;
- Hooks.enhance(mocha);
- Hooks.beforeEach(SinonMocha.beforeEach);
- Hooks.afterEach(SinonMocha.afterEach);
+ if (!Hooks._enhanced) {
+ Hooks.enhance(mocha);
+ Hooks.beforeEach(SinonMocha.beforeEach);
+ Hooks.afterEach(SinonMocha.afterEach);
+ }
},
beforeEach: function(){
Something went wrong with that request. Please try again.