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

Ensure that setup callback is invoked with the correct context. #12

Merged
merged 1 commit into from
Jan 31, 2015

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Jan 31, 2015

Previously, the setup callback was invoked via invokeSteps (and
therefore was bound to the TestModule instance itself). Now it is
invoked with the same context as the tests themselves.

  • Ensure setup callback is invoked with the test context.
  • Ensure teardown callback is invoked with the test context.
  • Removed beforeTeardown.
  • Added afterTeardown which is invoked with the test-module context.
  • Simplify callback ordering tests.

/cc @dgeb


if (this.callbacks.setup) {
this.setupSteps.push( this.callbacks.setup );
delete this.callbacks.setup;
Copy link
Member

Choose a reason for hiding this comment

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

We want to delete setup from this.callbacks before contextualizeCallbacks is called. Otherwise, setup will get added to cache['setup'].

Perhaps we need another array, something like postSetupSteps, that will be invoked with the proper this.context. And then we should allow invokeSteps to take a context argument, which will be either this or this.context.

I can do this as a separate PR if you like or we can chat on IRC.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe to be clear we should introduce both contextualizedSetupSteps and contextualizedTeardownSteps, both of which will be invoked with the module's context.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, I'll update in a few....

@rwjblue rwjblue force-pushed the ensure-setup-has-the-right-context branch from b487fcc to 463c20d Compare January 31, 2015 22:35
@rwjblue
Copy link
Member Author

rwjblue commented Jan 31, 2015

@dgeb - Updated per conversation in IRC and comments here.

Previously, the `setup` callback was invoked via `invokeSteps` (and
therefore was bound to the `TestModule` instance itself).  Now it is
invoked with the same context as the tests themselves.

* Ensure `setup` callback is invoked with the test context.
* Ensure `teardown` callback is invoked with the test-module context.
* Removed `beforeTeardown`.
* Added `afterTeardown` which is invoked with the test-module context.
* Simplify callback ordering tests.
@rwjblue rwjblue force-pushed the ensure-setup-has-the-right-context branch from 463c20d to b489976 Compare January 31, 2015 22:50
dgeb added a commit that referenced this pull request Jan 31, 2015
Ensure that `setup` callback is invoked with the correct context.
@dgeb dgeb merged commit fcc6dcf into emberjs:master Jan 31, 2015
@dgeb
Copy link
Member

dgeb commented Jan 31, 2015

Many thanks @rwjblue - this is a big improvement!

@rwjblue rwjblue deleted the ensure-setup-has-the-right-context branch January 31, 2015 22:53
@rwjblue
Copy link
Member Author

rwjblue commented Jan 31, 2015

Tagged as 0.3.0.

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.

2 participants