-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
destroy the subject in teardown #18
destroy the subject in teardown #18
Conversation
I'd like to see the following test near the end of https://github.com/switchfly/ember-test-helpers/blob/master/tests/test-module-test.js: moduleFor('component:x-foo', 'component:x-foo -- created subjects are cleaned up', {
beforeSetup: function() {
setupRegistry();
},
afterTeardown: function() {
var subject = this.cache.subject;
ok(subject.isDestroyed);
}
});
test("subject's created in a test are destroyed", function() {
this.subject();
});
moduleFor('component:x-foo', 'component:x-foo -- uncreated subjects do not error', {
beforeSetup: function() {
setupRegistry();
}
});
test("subject's created in a test are destroyed", function() {
expect(0);
}); |
var subject = this.cache.subject; | ||
|
||
if (subject) { | ||
Ember.run(subject, 'destroy'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible that subject
does not have a destroy
method so you will probably want to do something like:
Ember.run(function() {
Ember.tryInvoke(subject, 'destroy');
});
1aef8eb
to
c068ee6
Compare
c068ee6
to
5454690
Compare
^_^ |
❤️ |
I'm 👍, but I'll give @dgeb a chance to chime in... |
Looks great - thanks @CodeOfficer! |
released in v0.3.4 of ember-test-helpers and v0.2.10 of ember-qunit. |
I'm not sure what there is to test here so I didn't add any tests yet.
Currently the container is destroyed which takes care of destroying any dependencies brought in by
needs
but the subject is never properly town down. This makes sure that happens.