-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
[WIP] Update blueprints to take advantage of implicit Ember.run
in beforeEach/afterEach
#81
Conversation
Updates the blueprint to remove unecessary `Ember.run`. Also, extracts the `visit` into its own beforeEach in order to follow the style of having side-effects in setup blocks, and assertions in `it` blocks.
Since you were up, can you change |
}); | ||
|
||
it('can visit /<%= dasherizedModuleName %>', function() { | ||
beforeEach(function() { |
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.
Seems kinda weird to have two beforeEach
blocks (maybe that is super common in mocha-land?)...
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's fairly common to separate setup concerns. In this case, application setup vs page navigation, but what I'd probably do IRL, is either extract the app setup into its own helper, or If I was feeling like a BDD purist that day, I'd introduce a new description coupled with the new setup. E.g.
describe('Acceptance: <%= classifiedModuleName %>', function() {
beforeEach(function() {
this.application = startApp();
});
afterEach(function() {
this.application.destroy();
});
describe("visiting /<%= dasherizedModuleName %>", function() {
beforeEach(function() {
visit('/<%= dasherizedModuleName %>');
});
it("transitions successfully", function() {
expect(currentPath()).to.equal('<%= dasherizedModuleName %>');
});
});
});
I always chafe at the amount of boilerplate in the acceptance tests anyhow, what about introducing a dedicated test helper for acceptance tests, so it could become something like:
describeAcceptance(' <%= classifiedModuleName %>', function() {
beforeEach(function() {
visit('/<%= dasherizedModuleName %>');
});
it("transitions successfully", function() {
expect(currentPath()).to.equal('<%= dasherizedModuleName %>');
});
});
Setting up and tearing down the application would just happen automatically.
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.
There is a proposal in one (or all) of ember-test-helpers, ember-cli, ember-qunit to add moduleForAcceptance
for exactly the reasons that it chafes. If you have time, poke around over there and chime in...
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.
I didn't find anything explicitly mentioning moduleForAcceptance
in terms of a formal proposal over at ember-test-helpers
. Maybe I'm missing something? In any case, I can certainly have a look.
Found this proposal here emberjs/ember-test-helpers#94 which might me what we're looking for |
@cowboyd - I can't recall where we landed on this. Is this waiting on me somehow? |
Closing this as the blueprints have been moved to https://github.com/emberjs/ember.js/tree/master/blueprints/acceptance-test (and https://github.com/ember-cli/ember-cli-legacy-blueprints). In general this change makes sense to me though, so feel free to reopen on the ember.js repo! |
As of ember-mocha v0.8.3,
beforeEach
andafterEach
now happen in the context of anEmber.run
, and so this takes advantage of that.This also changes the
visit
invocation to happen in its ownbeforeEach
to move it in line with the convention that side-effcts happen in beforeEach blocks, and assertions init
blocks. (I find that I very rarely useandThen
)If this looks good, I can change the other test blueprints.