diff --git a/README.md b/README.md index 98ce2fc..59c5701 100644 --- a/README.md +++ b/README.md @@ -17,41 +17,6 @@ earlier versions, but I wouldn't know. ### How to use -#### CoffeeScript and ember-cli -There is one thing to note when using CoffeeScript with ember-cli: the syntax for _ES6-modules_. -In ember-cli-apps written in JavaScript, this is a common pattern: - -```js -// app/components/my-component.js -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'div' -}); -``` - -Writing `import` or `export` in a CoffeeScript-file causes an error, so we'll need -to escape these lines with backticks so they run as JavaScript. - -We also need to store the export in a variable to export at the end, we can't export -directly as done above. Please note that the name of this variable does not affect -the name of the component itself - that is based entirely on the file name and placement. - -Here's the above file in CoffeeScript: - -```coffee -# app/components/my-component.coffee -`import Ember from 'ember'` - -MyComponent = Ember.Component.extend - tagName: 'div' - -`export default MyComponent` -``` - -Luckily, all the blueprints included with ember-cli-coffeescript do this for you! Which -leads to… - #### Blueprints Run `ember help generate` to get a list of available blueprints. Use them by running `ember g `. For instance, to generate the above component: @@ -89,19 +54,7 @@ ENV.coffeeOptions = { } ``` -You can set `lint` to `true` to enable linting with the default configurations, but you will probably -want to add a `coffeelint.json` file to the root of your project either way, for instance to turn -off the error for backticks. - -Example `coffeelint.json`: - -```json -{ - "no_backticks": { - "level": "ignore" - } -} -``` +You can set `lint` to `true` to enable linting with the default configurations You can find all the [available options on the website for `coffeelint`](http://www.coffeelint.org/#options). diff --git a/blueprints/acceptance-test/files/tests/acceptance/__name__-test.coffee b/blueprints/acceptance-test/files/tests/acceptance/__name__-test.coffee index 5784531..13993ae 100644 --- a/blueprints/acceptance-test/files/tests/acceptance/__name__-test.coffee +++ b/blueprints/acceptance-test/files/tests/acceptance/__name__-test.coffee @@ -1,6 +1,6 @@ -`import Ember from 'ember'` -`import { module, test } from 'qunit'` -`import startApp from '<%= testFolderRoot %>/tests/helpers/start-app'` +import Ember from 'ember' +import { module, test } from 'qunit' +import startApp from '<%= testFolderRoot %>/tests/helpers/start-app' module 'Acceptance: <%= classifiedModuleName %>', beforeEach: -> diff --git a/blueprints/adapter-test/files/tests/unit/__path__/__test__.coffee b/blueprints/adapter-test/files/tests/unit/__path__/__test__.coffee index 3f9eec6..662585f 100644 --- a/blueprints/adapter-test/files/tests/unit/__path__/__test__.coffee +++ b/blueprints/adapter-test/files/tests/unit/__path__/__test__.coffee @@ -1,4 +1,4 @@ -`import { moduleFor, test } from 'ember-qunit'` +import { moduleFor, test } from 'ember-qunit' moduleFor 'adapter:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { # Specify the other units that are required for this test. diff --git a/blueprints/adapter/files/__root__/__path__/__name__.coffee b/blueprints/adapter/files/__root__/__path__/__name__.coffee index 7b5fe01..d2dea46 100644 --- a/blueprints/adapter/files/__root__/__path__/__name__.coffee +++ b/blueprints/adapter/files/__root__/__path__/__name__.coffee @@ -1,5 +1,5 @@ -`<%= importStatement %>` +<%= importStatement %> <%= classifiedModuleName %>Adapter = <%= baseClass %>.extend() -`export default <%= classifiedModuleName %>Adapter` +export default <%= classifiedModuleName %>Adapter diff --git a/blueprints/addon-import/files/__root__/__path__/__name__.coffee b/blueprints/addon-import/files/__root__/__path__/__name__.coffee index a8d18e0..f9b6ee1 100644 --- a/blueprints/addon-import/files/__root__/__path__/__name__.coffee +++ b/blueprints/addon-import/files/__root__/__path__/__name__.coffee @@ -1 +1 @@ -`export { default } from '<%= modulePath %>'` +export { default } from '<%= modulePath %>' diff --git a/blueprints/component-addon/files/__root__/__path__/__name__.coffee b/blueprints/component-addon/files/__root__/__path__/__name__.coffee index a8d18e0..f9b6ee1 100644 --- a/blueprints/component-addon/files/__root__/__path__/__name__.coffee +++ b/blueprints/component-addon/files/__root__/__path__/__name__.coffee @@ -1 +1 @@ -`export { default } from '<%= modulePath %>'` +export { default } from '<%= modulePath %>' diff --git a/blueprints/component-test/files/tests/__testType__/__path__/__test__.coffee b/blueprints/component-test/files/tests/__testType__/__path__/__test__.coffee index d330751..34293af 100644 --- a/blueprints/component-test/files/tests/__testType__/__path__/__test__.coffee +++ b/blueprints/component-test/files/tests/__testType__/__path__/__test__.coffee @@ -1,4 +1,4 @@ -`import { test, moduleForComponent } from 'ember-qunit'`<%= testImports %> +import { test, moduleForComponent } from 'ember-qunit'<%= testImports %> moduleForComponent '<%= componentPathName %>', '<%= friendlyTestDescription %>', { <%= testOptions %> diff --git a/blueprints/component-test/index.js b/blueprints/component-test/index.js index 9b47bff..666a6da 100644 --- a/blueprints/component-test/index.js +++ b/blueprints/component-test/index.js @@ -30,7 +30,7 @@ module.exports = { var locals = blueprint.locals.apply(blueprint, arguments); var dasherizedModuleName = stringUtils.dasherize(options.entity.name); - var testImports = EOL + "`import hbs from 'htmlbars-inline-precompile'`"; + var testImports = EOL + "import hbs from 'htmlbars-inline-precompile'"; var testOptions = "integration: true"; var testContent = "assert.expect 2" + EOL + EOL + diff --git a/blueprints/component/files/__root__/__path__/__name__.coffee b/blueprints/component/files/__root__/__path__/__name__.coffee index 85c137b..41a8781 100644 --- a/blueprints/component/files/__root__/__path__/__name__.coffee +++ b/blueprints/component/files/__root__/__path__/__name__.coffee @@ -1,5 +1,5 @@ -`import Ember from 'ember'` +import Ember from 'ember' <%= importTemplate %> <%= classifiedModuleName %>Component = Ember.Component.extend(<%=contents%>) -`export default <%= classifiedModuleName %>Component` +export default <%= classifiedModuleName %>Component diff --git a/blueprints/component/index.js b/blueprints/component/index.js index efa1c79..74f0911 100644 --- a/blueprints/component/index.js +++ b/blueprints/component/index.js @@ -39,13 +39,8 @@ module.exports = { newContents = locals.contents + '\n'; } - var newImport = ''; - if (locals.importTemplate) { - newImport = "`" + locals.importTemplate.replace(/;/, '`'); - } - locals.contents = newContents; - locals.importTemplate = newImport; + locals.importTemplate = locals.importTemplate.replace(/;/, ''); return locals; } diff --git a/blueprints/controller-test/files/tests/unit/__path__/__test__.coffee b/blueprints/controller-test/files/tests/unit/__path__/__test__.coffee index 94c6c62..ed141da 100644 --- a/blueprints/controller-test/files/tests/unit/__path__/__test__.coffee +++ b/blueprints/controller-test/files/tests/unit/__path__/__test__.coffee @@ -1,4 +1,4 @@ -`import { moduleFor, test } from 'ember-qunit'` +import { moduleFor, test } from 'ember-qunit' moduleFor 'controller:<%= dasherizedModuleName %>', { # Specify the other units that are required for this test. diff --git a/blueprints/controller/files/__root__/__path__/__name__.coffee b/blueprints/controller/files/__root__/__path__/__name__.coffee index aace91d..6b340fe 100644 --- a/blueprints/controller/files/__root__/__path__/__name__.coffee +++ b/blueprints/controller/files/__root__/__path__/__name__.coffee @@ -1,5 +1,5 @@ -`import Ember from 'ember'` +import Ember from 'ember' <%= classifiedModuleName %>Controller = Ember.Controller.extend() -`export default <%= classifiedModuleName %>Controller` +export default <%= classifiedModuleName %>Controller diff --git a/blueprints/helper-addon/files/__root__/__path__/__name__.coffee b/blueprints/helper-addon/files/__root__/__path__/__name__.coffee index a87da13..100e0d5 100644 --- a/blueprints/helper-addon/files/__root__/__path__/__name__.coffee +++ b/blueprints/helper-addon/files/__root__/__path__/__name__.coffee @@ -1 +1 @@ -`export { default, <%= camelizedModuleName %> } from '<%= modulePath %>'` +export { default, <%= camelizedModuleName %> } from '<%= modulePath %>' diff --git a/blueprints/helper-test/files/tests/unit/helpers/__name__-test.coffee b/blueprints/helper-test/files/tests/unit/helpers/__name__-test.coffee index 30ac441..8e8412d 100644 --- a/blueprints/helper-test/files/tests/unit/helpers/__name__-test.coffee +++ b/blueprints/helper-test/files/tests/unit/helpers/__name__-test.coffee @@ -1,5 +1,5 @@ -`import { <%= camelizedModuleName %> } from '<%= dasherizedModulePrefix %>/helpers/<%= dasherizedModuleName %>'` -`import { module, test } from 'qunit'` +import { <%= camelizedModuleName %> } from '<%= dasherizedModulePrefix %>/helpers/<%= dasherizedModuleName %>' +import { module, test } from 'qunit' module '<%= friendlyTestName %>' diff --git a/blueprints/helper/files/__root__/helpers/__name__.coffee b/blueprints/helper/files/__root__/helpers/__name__.coffee index 307a648..f29565a 100644 --- a/blueprints/helper/files/__root__/helpers/__name__.coffee +++ b/blueprints/helper/files/__root__/helpers/__name__.coffee @@ -1,4 +1,4 @@ -`import Ember from 'ember'` +import Ember from 'ember' # This function receives the params `params, hash` <%= camelizedModuleName %> = (params) -> @@ -6,6 +6,6 @@ <%= classifiedModuleName %>Helper = Ember.Helper.helper <%= camelizedModuleName %> -`export { <%= camelizedModuleName %> }` +export { <%= camelizedModuleName %> } -`export default <%= classifiedModuleName %>Helper` +export default <%= classifiedModuleName %>Helper diff --git a/blueprints/initializer-addon/files/__root__/__path__/__name__.coffee b/blueprints/initializer-addon/files/__root__/__path__/__name__.coffee index a7b812f..c7b0415 100644 --- a/blueprints/initializer-addon/files/__root__/__path__/__name__.coffee +++ b/blueprints/initializer-addon/files/__root__/__path__/__name__.coffee @@ -1 +1 @@ -`export { default, initialize } from '<%= modulePath %>'` +export { default, initialize } from '<%= modulePath %>' diff --git a/blueprints/initializer-test/files/tests/unit/initializers/__name__-test.coffee b/blueprints/initializer-test/files/tests/unit/initializers/__name__-test.coffee index b922c13..39787dd 100644 --- a/blueprints/initializer-test/files/tests/unit/initializers/__name__-test.coffee +++ b/blueprints/initializer-test/files/tests/unit/initializers/__name__-test.coffee @@ -1,6 +1,6 @@ -`import Ember from 'ember'` -`import { initialize } from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>'` -`import { module, test } from 'qunit'` +import Ember from 'ember' +import { initialize } from '<%= dasherizedModulePrefix %>/initializers/<%= dasherizedModuleName %>' +import { module, test } from 'qunit' application = null registry = null diff --git a/blueprints/initializer/files/__root__/initializers/__name__.coffee b/blueprints/initializer/files/__root__/initializers/__name__.coffee index d209163..6305b2a 100644 --- a/blueprints/initializer/files/__root__/initializers/__name__.coffee +++ b/blueprints/initializer/files/__root__/initializers/__name__.coffee @@ -6,5 +6,5 @@ initialize = () -> name: '<%= dasherizedModuleName %>' initialize: initialize -`export {initialize}` -`export default <%= classifiedModuleName %>Initializer` +export {initialize} +export default <%= classifiedModuleName %>Initializer diff --git a/blueprints/mixin-test/files/tests/unit/mixins/__name__-test.coffee b/blueprints/mixin-test/files/tests/unit/mixins/__name__-test.coffee index 4aca172..d2c6015 100644 --- a/blueprints/mixin-test/files/tests/unit/mixins/__name__-test.coffee +++ b/blueprints/mixin-test/files/tests/unit/mixins/__name__-test.coffee @@ -1,6 +1,6 @@ -`import Ember from 'ember'` -`import <%= classifiedModuleName %>Mixin from '../../../mixins/<%= dasherizedModuleName %>'` -`import { module, test } from 'qunit'` +import Ember from 'ember' +import <%= classifiedModuleName %>Mixin from '../../../mixins/<%= dasherizedModuleName %>' +import { module, test } from 'qunit' module '<%= friendlyTestName %>' diff --git a/blueprints/mixin/files/__root__/mixins/__name__.coffee b/blueprints/mixin/files/__root__/mixins/__name__.coffee index 662a503..016027b 100644 --- a/blueprints/mixin/files/__root__/mixins/__name__.coffee +++ b/blueprints/mixin/files/__root__/mixins/__name__.coffee @@ -1,5 +1,5 @@ -`import Ember from 'ember'` +import Ember from 'ember' <%= classifiedModuleName %>Mixin = Ember.Mixin.create() -`export default <%= classifiedModuleName %>Mixin` +export default <%= classifiedModuleName %>Mixin diff --git a/blueprints/model-test/files/tests/unit/__path__/__test__.coffee b/blueprints/model-test/files/tests/unit/__path__/__test__.coffee index ba33f4d..36884a3 100644 --- a/blueprints/model-test/files/tests/unit/__path__/__test__.coffee +++ b/blueprints/model-test/files/tests/unit/__path__/__test__.coffee @@ -1,4 +1,4 @@ -`import { moduleForModel, test } from 'ember-qunit'` +import { moduleForModel, test } from 'ember-qunit' moduleForModel '<%= dasherizedModuleName %>', '<%= friendlyDescription %>', { # Specify the other units that are required for this test. diff --git a/blueprints/model/files/__root__/__path__/__name__.coffee b/blueprints/model/files/__root__/__path__/__name__.coffee index 16b213e..9ffcef1 100644 --- a/blueprints/model/files/__root__/__path__/__name__.coffee +++ b/blueprints/model/files/__root__/__path__/__name__.coffee @@ -1,7 +1,7 @@ -`import DS from 'ember-data'` +import DS from 'ember-data' <%= classifiedModuleName %> = DS.Model.extend { <%= attrs %> } -`export default <%= classifiedModuleName %>` +export default <%= classifiedModuleName %> diff --git a/blueprints/route-addon/files/__root__/__path__/__name__.coffee b/blueprints/route-addon/files/__root__/__path__/__name__.coffee index 6df5eef..c1d6480 100644 --- a/blueprints/route-addon/files/__root__/__path__/__name__.coffee +++ b/blueprints/route-addon/files/__root__/__path__/__name__.coffee @@ -1 +1 @@ -`export { default } from '<%= routeModulePath %>'` +export { default } from '<%= routeModulePath %>' diff --git a/blueprints/route-addon/files/__root__/__templatepath__/__templatename__.coffee b/blueprints/route-addon/files/__root__/__templatepath__/__templatename__.coffee index ad09add..2eaee36 100644 --- a/blueprints/route-addon/files/__root__/__templatepath__/__templatename__.coffee +++ b/blueprints/route-addon/files/__root__/__templatepath__/__templatename__.coffee @@ -1 +1 @@ -`export { default } from '<%= templateModulePath %>'` +export { default } from '<%= templateModulePath %>' diff --git a/blueprints/route-test/qunit-files/tests/unit/__path__/__test__.coffee b/blueprints/route-test/qunit-files/tests/unit/__path__/__test__.coffee index 26f7da2..aede7e1 100644 --- a/blueprints/route-test/qunit-files/tests/unit/__path__/__test__.coffee +++ b/blueprints/route-test/qunit-files/tests/unit/__path__/__test__.coffee @@ -1,4 +1,4 @@ -`import { moduleFor, test } from 'ember-qunit'` +import { moduleFor, test } from 'ember-qunit' moduleFor 'route:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { # Specify the other units that are required for this test. diff --git a/blueprints/route/files/__root__/__path__/__name__.coffee b/blueprints/route/files/__root__/__path__/__name__.coffee index 50edd0a..3e5ec5b 100644 --- a/blueprints/route/files/__root__/__path__/__name__.coffee +++ b/blueprints/route/files/__root__/__path__/__name__.coffee @@ -1,5 +1,5 @@ -`import Ember from 'ember'` +import Ember from 'ember' <%= classifiedModuleName %>Route = Ember.Route.extend() -`export default <%= classifiedModuleName %>Route` +export default <%= classifiedModuleName %>Route diff --git a/blueprints/serializer-test/qunit-files/tests/unit/__path__/__test__.coffee b/blueprints/serializer-test/qunit-files/tests/unit/__path__/__test__.coffee index d1503e9..421c6b4 100644 --- a/blueprints/serializer-test/qunit-files/tests/unit/__path__/__test__.coffee +++ b/blueprints/serializer-test/qunit-files/tests/unit/__path__/__test__.coffee @@ -1,4 +1,4 @@ -`import { moduleForModel, test } from 'ember-qunit'` +import { moduleForModel, test } from 'ember-qunit' moduleForModel '<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', # Specify the other units that are required for this test. diff --git a/blueprints/serializer/files/__root__/__path__/__name__.coffee b/blueprints/serializer/files/__root__/__path__/__name__.coffee index 0e6f405..1443828 100644 --- a/blueprints/serializer/files/__root__/__path__/__name__.coffee +++ b/blueprints/serializer/files/__root__/__path__/__name__.coffee @@ -1,5 +1,5 @@ -`import DS from 'ember-data'` +import DS from 'ember-data' <%= classifiedModuleName %>Serializer = DS.RESTSerializer.extend() -`export default <%= classifiedModuleName %>Serializer` +export default <%= classifiedModuleName %>Serializer diff --git a/blueprints/service-test/qunit-files/tests/unit/services/__name__-test.coffee b/blueprints/service-test/qunit-files/tests/unit/services/__name__-test.coffee index 6d8ff69..1bc0c40 100644 --- a/blueprints/service-test/qunit-files/tests/unit/services/__name__-test.coffee +++ b/blueprints/service-test/qunit-files/tests/unit/services/__name__-test.coffee @@ -1,4 +1,4 @@ -`import { moduleFor, test } from 'ember-qunit'` +import { moduleFor, test } from 'ember-qunit' moduleFor 'service:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { # Specify the other units that are required for this test. diff --git a/blueprints/service/files/__root__/__path__/__name__.coffee b/blueprints/service/files/__root__/__path__/__name__.coffee index 7ad84fa..649c7ff 100644 --- a/blueprints/service/files/__root__/__path__/__name__.coffee +++ b/blueprints/service/files/__root__/__path__/__name__.coffee @@ -1,5 +1,5 @@ -`import Ember from 'ember'` +import Ember from 'ember' <%= classifiedModuleName %>Service = Ember.Service.extend() -`export default <%= classifiedModuleName %>Service` +export default <%= classifiedModuleName %>Service diff --git a/blueprints/test-helper/files/tests/helpers/__name__.coffee b/blueprints/test-helper/files/tests/helpers/__name__.coffee index 304f8fd..b66be90 100644 --- a/blueprints/test-helper/files/tests/helpers/__name__.coffee +++ b/blueprints/test-helper/files/tests/helpers/__name__.coffee @@ -1,5 +1,5 @@ -`import Ember from 'ember'` +import Ember from 'ember' <%= camelizedModuleName %> = (app) -> -`export default Ember.Test.registerAsyncHelper('<%= camelizedModuleName %>', <%= camelizedModuleName %>)` +export default Ember.Test.registerAsyncHelper('<%= camelizedModuleName %>', <%= camelizedModuleName %>) diff --git a/blueprints/transform-test/qunit-files/tests/unit/__path__/__test__.coffee b/blueprints/transform-test/qunit-files/tests/unit/__path__/__test__.coffee index e9e56e1..6006b13 100644 --- a/blueprints/transform-test/qunit-files/tests/unit/__path__/__test__.coffee +++ b/blueprints/transform-test/qunit-files/tests/unit/__path__/__test__.coffee @@ -1,4 +1,4 @@ -`import { moduleFor, test } from 'ember-qunit'` +import { moduleFor, test } from 'ember-qunit' moduleFor 'transform:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { # Specify the other units that are required for this test. diff --git a/blueprints/transform/files/__root__/__path__/__name__.coffee b/blueprints/transform/files/__root__/__path__/__name__.coffee index dd3cc19..cbafb96 100644 --- a/blueprints/transform/files/__root__/__path__/__name__.coffee +++ b/blueprints/transform/files/__root__/__path__/__name__.coffee @@ -1,4 +1,4 @@ -`import DS from 'ember-data'` +import DS from 'ember-data' <%= classifiedModuleName %>Transform = DS.Transform.extend deserialize: (serialized) -> @@ -7,4 +7,4 @@ serialize: (deserialized) -> deserialized -`export default <%= classifiedModuleName %>Transform` +export default <%= classifiedModuleName %>Transform diff --git a/blueprints/util-test/qunit-files/tests/unit/utils/__name__-test.coffee b/blueprints/util-test/qunit-files/tests/unit/utils/__name__-test.coffee index d1545c5..4a84902 100644 --- a/blueprints/util-test/qunit-files/tests/unit/utils/__name__-test.coffee +++ b/blueprints/util-test/qunit-files/tests/unit/utils/__name__-test.coffee @@ -1,5 +1,5 @@ -`import <%= camelizedModuleName %> from '../../../utils/<%= dasherizedModuleName %>'` -`import { module, test } from 'qunit'` +import <%= camelizedModuleName %> from '../../../utils/<%= dasherizedModuleName %>' +import { module, test } from 'qunit' module '<%= friendlyTestName %>' diff --git a/blueprints/util/files/__root__/utils/__name__.coffee b/blueprints/util/files/__root__/utils/__name__.coffee index f4bc4d1..43bc1a0 100644 --- a/blueprints/util/files/__root__/utils/__name__.coffee +++ b/blueprints/util/files/__root__/utils/__name__.coffee @@ -1,4 +1,4 @@ <%= camelizedModuleName %> = () -> true -`export default <%= camelizedModuleName %>` +export default <%= camelizedModuleName %> diff --git a/blueprints/view-test/files/tests/unit/__path__/__test__.coffee b/blueprints/view-test/files/tests/unit/__path__/__test__.coffee index 0ec6667..6c7bb09 100644 --- a/blueprints/view-test/files/tests/unit/__path__/__test__.coffee +++ b/blueprints/view-test/files/tests/unit/__path__/__test__.coffee @@ -1,4 +1,4 @@ -`import { moduleFor, test } from 'ember-qunit'` +import { moduleFor, test } from 'ember-qunit' moduleFor 'view:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>' diff --git a/blueprints/view/files/__root__/__path__/__name__.coffee b/blueprints/view/files/__root__/__path__/__name__.coffee index baffc1a..4e341be 100644 --- a/blueprints/view/files/__root__/__path__/__name__.coffee +++ b/blueprints/view/files/__root__/__path__/__name__.coffee @@ -1,5 +1,5 @@ -`import Ember from 'ember'` +import Ember from 'ember' <%= classifiedModuleName %>View = Ember.View.extend() -`export default <%= classifiedModuleName %>View` +export default <%= classifiedModuleName %>View diff --git a/node-tests/blueprints/acceptance-test-test.js b/node-tests/blueprints/acceptance-test-test.js index 285c34b..15f6ba9 100644 --- a/node-tests/blueprints/acceptance-test-test.js +++ b/node-tests/blueprints/acceptance-test-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy acceptance-test', function() { setupTestHooks(this); @@ -15,15 +16,19 @@ describe('Acceptance: ember generate and destroy acceptance-test', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/acceptance/foo-test.coffee')) - .to.contain("`import Ember from 'ember'`") - .to.contain("`import { module, test } from 'qunit'`") - .to.contain("`import startApp from 'my-app/tests/helpers/start-app'`") + var acceptanceFile = file('tests/acceptance/foo-test.coffee'); + + expect(acceptanceFile) + .to.contain("import Ember from 'ember'") + .to.contain("import { module, test } from 'qunit'") + .to.contain("import startApp from 'my-app/tests/helpers/start-app'") .to.contain("module 'Acceptance: Foo',") .to.contain("test 'visiting /foo', (assert) ->") .to.contain("visit '/foo'") .to.contain("andThen ->") .to.contain("assert.equal currentURL(), '/foo'"); + + expectCoffee(acceptanceFile); })); }); }); diff --git a/node-tests/blueprints/adapter-test.js b/node-tests/blueprints/adapter-test.js index 98d6263..db4f5b9 100644 --- a/node-tests/blueprints/adapter-test.js +++ b/node-tests/blueprints/adapter-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy adapter', function() { setupTestHooks(this); @@ -15,13 +16,21 @@ describe('Acceptance: ember generate and destroy adapter', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/adapters/foo.coffee')) - .to.contain("`import ApplicationAdapter from './application'`") + var adapterFile = file('app/adapters/foo.coffee'); + + expect(adapterFile) + .to.contain("import ApplicationAdapter from './application'") .to.contain("FooAdapter = ApplicationAdapter.extend()") - .to.contain("`export default FooAdapter`"); + .to.contain("export default FooAdapter"); + + expectCoffee(adapterFile); + + var adapterTestFile = file('tests/unit/adapters/foo-test.coffee'); - expect(file('tests/unit/adapters/foo-test.coffee')) + expect(adapterTestFile) .to.contain("moduleFor 'adapter:foo'") + + expectCoffee(adapterTestFile); })); }); @@ -30,9 +39,13 @@ describe('Acceptance: ember generate and destroy adapter', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/unit/adapters/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + var adapterTestFile = file('tests/unit/adapters/foo-test.coffee'); + + expect(adapterTestFile) + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'adapter:foo'") + + expectCoffee(adapterTestFile); })); }); }); diff --git a/node-tests/blueprints/addon-import-test.js b/node-tests/blueprints/addon-import-test.js index fc0a611..c06408b 100644 --- a/node-tests/blueprints/addon-import-test.js +++ b/node-tests/blueprints/addon-import-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy addon-import', function() { setupTestHooks(this); @@ -15,8 +16,12 @@ describe('Acceptance: ember generate and destroy addon-import', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/addon-imports/foo.coffee')) - .to.contain(`export { default } from 'my-app/addon-imports/foo'`); + var importFile = file('app/addon-imports/foo.coffee'); + + expect(importFile) + .to.contain("export { default } from 'my-app/addon-imports/foo'"); + + expectCoffee(importFile); })); }); }); diff --git a/node-tests/blueprints/component-addon-test.js b/node-tests/blueprints/component-addon-test.js index 65f5a78..3afb8ed 100644 --- a/node-tests/blueprints/component-addon-test.js +++ b/node-tests/blueprints/component-addon-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy component-addon', function() { setupTestHooks(this); @@ -15,8 +16,12 @@ describe('Acceptance: ember generate and destroy component-addon', function() { return emberNew({target: 'addon'}) .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/components/foo-bar.coffee')) - .to.contain("`export { default } from 'my-addon/components/foo-bar'`"); + var componentFile = file('app/components/foo-bar.coffee'); + + expect(componentFile) + .to.contain("export { default } from 'my-addon/components/foo-bar'"); + + expectCoffee(componentFile); })); }); }); diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js index a30110e..1aab03f 100644 --- a/node-tests/blueprints/component-test.js +++ b/node-tests/blueprints/component-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy component', function() { setupTestHooks(this); @@ -15,22 +16,30 @@ describe('Acceptance: ember generate and destroy component', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/components/x-foo.coffee')) - .to.contain("`import Ember from 'ember'`") + var componentFile = file('app/components/x-foo.coffee'); + + expect(componentFile) + .to.contain("import Ember from 'ember'") .to.contain('XFooComponent = Ember.Component.extend()') - .to.contain('`export default XFooComponent`') + .to.contain('export default XFooComponent') .to.not.contain('layout'); + expectCoffee(componentFile); + expect(file('app/templates/components/x-foo.hbs')) .to.contain('{{yield}}'); - expect(file('tests/integration/components/x-foo-test.coffee')) - .to.contain("`import { test, moduleForComponent } from 'ember-qunit'`") - .to.contain("`import hbs from 'htmlbars-inline-precompile'`") + var componentTestFile = file('tests/integration/components/x-foo-test.coffee'); + + expect(componentTestFile) + .to.contain("import { test, moduleForComponent } from 'ember-qunit'") + .to.contain("import hbs from 'htmlbars-inline-precompile'") .to.contain("moduleForComponent 'x-foo', 'Integration | Component | x foo'") .to.contain('integration: true') .to.contain('{{x-foo}}') .to.contain('{{#x-foo}}'); + + expectCoffee(componentTestFile); })); }); }); diff --git a/node-tests/blueprints/controller-test.js b/node-tests/blueprints/controller-test.js index fdbf43b..352cbff 100644 --- a/node-tests/blueprints/controller-test.js +++ b/node-tests/blueprints/controller-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy controller', function() { setupTestHooks(this); @@ -15,14 +16,22 @@ describe('Acceptance: ember generate and destroy controller', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/controllers/foo.coffee')) - .to.contain("`import Ember from 'ember'`") + var controllerFile = file('app/controllers/foo.coffee'); + + expect(controllerFile) + .to.contain("import Ember from 'ember'") .to.contain('FooController = Ember.Controller.extend()') - .to.contain("`export default FooController`"); + .to.contain("export default FooController"); + + expectCoffee(controllerFile); - expect(file('tests/unit/controllers/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + var controllerTestFile = file('tests/unit/controllers/foo-test.coffee'); + + expect(controllerTestFile) + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'controller:foo'"); + + expectCoffee(controllerTestFile); })); }); }); diff --git a/node-tests/blueprints/helper-addon-test.js b/node-tests/blueprints/helper-addon-test.js index a403fa7..11e3a82 100644 --- a/node-tests/blueprints/helper-addon-test.js +++ b/node-tests/blueprints/helper-addon-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy helper-addon', function() { setupTestHooks(this); @@ -15,8 +16,12 @@ describe('Acceptance: ember generate and destroy helper-addon', function() { return emberNew({target: 'addon'}) .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/helpers/foo-bar.coffee')) - .to.contain("`export { default, fooBar } from 'my-addon/helpers/foo-bar'`"); + var helperFile = file('app/helpers/foo-bar.coffee'); + + expect(helperFile) + .to.contain("export { default, fooBar } from 'my-addon/helpers/foo-bar'"); + + expectCoffee(helperFile); })); }); }); diff --git a/node-tests/blueprints/helper-test.js b/node-tests/blueprints/helper-test.js index e9145bc..72ae9b9 100644 --- a/node-tests/blueprints/helper-test.js +++ b/node-tests/blueprints/helper-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy helper', function() { setupTestHooks(this); @@ -15,17 +16,25 @@ describe('Acceptance: ember generate and destroy helper', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/helpers/foo-bar.coffee')) - .to.contain("`import Ember from 'ember'`") + var helperFile = file('app/helpers/foo-bar.coffee'); + + expect(helperFile) + .to.contain("import Ember from 'ember'") .to.contain('fooBar = (params) ->') .to.contain('FooBarHelper = Ember.Helper.helper fooBar') - .to.contain("`export { fooBar }`") - .to.contain("`export default FooBarHelper`"); + .to.contain("export { fooBar }") + .to.contain("export default FooBarHelper"); + + expectCoffee(helperFile); - expect(file('tests/unit/helpers/foo-bar-test.coffee')) - .to.contain("`import { fooBar } from 'my-app/helpers/foo-bar'`") + var helperTestFile = file('tests/unit/helpers/foo-bar-test.coffee'); + + expect(helperTestFile) + .to.contain("import { fooBar } from 'my-app/helpers/foo-bar'") .to.contain("module 'Unit | Helper | foo bar'") .to.contain("result = fooBar 42"); + + expectCoffee(helperTestFile); })); }); }); diff --git a/node-tests/blueprints/initializer-addon-test.js b/node-tests/blueprints/initializer-addon-test.js index 79036ff..84500c2 100644 --- a/node-tests/blueprints/initializer-addon-test.js +++ b/node-tests/blueprints/initializer-addon-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy initializer-addon', function() { setupTestHooks(this); @@ -15,8 +16,12 @@ describe('Acceptance: ember generate and destroy initializer-addon', function() return emberNew({ target: 'addon' }) .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/initializers/foo-bar.coffee')) - .to.contain("`export { default, initialize } from 'my-addon/initializers/foo-bar'`"); + var initializerFile = file('app/initializers/foo-bar.coffee'); + + expect(initializerFile) + .to.contain("export { default, initialize } from 'my-addon/initializers/foo-bar'"); + + expectCoffee(initializerFile); })); }); }); diff --git a/node-tests/blueprints/initializer-test.js b/node-tests/blueprints/initializer-test.js index 0f985a1..3fe978d 100644 --- a/node-tests/blueprints/initializer-test.js +++ b/node-tests/blueprints/initializer-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy initializer', function() { setupTestHooks(this); @@ -15,18 +16,26 @@ describe('Acceptance: ember generate and destroy initializer', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { + var initializerFile = file('app/initializers/foo-bar.coffee'); + expect(file('app/initializers/foo-bar.coffee')) .to.contain('initialize = () ->') .to.contain('FooBarInitializer =') .to.contain("name: 'foo-bar'") - .to.contain("`export {initialize}`") - .to.contain("`export default FooBarInitializer`"); + .to.contain("export {initialize}") + .to.contain("export default FooBarInitializer"); + + expectCoffee(initializerFile); - expect(file('tests/unit/initializers/foo-bar-test.coffee')) - .to.contain("`import Ember from 'ember'`") - .to.contain("`import { initialize } from 'my-app/initializers/foo-bar'`") - .to.contain("`import { module, test } from 'qunit'`") + var initializerTestFile = file('tests/unit/initializers/foo-bar-test.coffee'); + + expect(initializerTestFile) + .to.contain("import Ember from 'ember'") + .to.contain("import { initialize } from 'my-app/initializers/foo-bar'") + .to.contain("import { module, test } from 'qunit'") .to.contain("module 'Unit | Initializer | foo bar'"); + + expectCoffee(initializerTestFile); })); }); }); diff --git a/node-tests/blueprints/mixin-test.js b/node-tests/blueprints/mixin-test.js index b1d2af3..c8ea460 100644 --- a/node-tests/blueprints/mixin-test.js +++ b/node-tests/blueprints/mixin-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy mixin', function() { setupTestHooks(this); @@ -15,19 +16,27 @@ describe('Acceptance: ember generate and destroy mixin', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/mixins/foo-bar.coffee')) - .to.contain("`import Ember from 'ember'`") + var mixinFile = file('app/mixins/foo-bar.coffee'); + + expect(mixinFile) + .to.contain("import Ember from 'ember'") .to.contain('FooBarMixin = Ember.Mixin.create()') - .to.contain("`export default FooBarMixin`"); + .to.contain("export default FooBarMixin"); + + expectCoffee(mixinFile); + + var mixinTestFile = file('tests/unit/mixins/foo-bar-test.coffee'); - expect(file('tests/unit/mixins/foo-bar-test.coffee')) - .to.contain("`import Ember from 'ember'`") + expect(mixinTestFile) + .to.contain("import Ember from 'ember'") // TODO: Fix this import - it should be absolute - .to.contain("`import FooBarMixin from '../../../mixins/foo-bar'`") - .to.contain("`import { module, test } from 'qunit'`") + .to.contain("import FooBarMixin from '../../../mixins/foo-bar'") + .to.contain("import { module, test } from 'qunit'") .to.contain("module 'Unit | Mixin | foo bar'") .to.contain('FooBarObject = Ember.Object.extend FooBarMixin') .to.contain('subject = FooBarObject.create()'); + + expectCoffee(mixinTestFile); })); }); @@ -36,13 +45,17 @@ describe('Acceptance: ember generate and destroy mixin', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/unit/mixins/foo-bar-test.coffee')) - .to.contain("`import Ember from 'ember'`") - .to.contain("`import FooBarMixin from '../../../mixins/foo-bar'`") - .to.contain("`import { module, test } from 'qunit'`") + var mixinTestFile = file('tests/unit/mixins/foo-bar-test.coffee'); + + expect(mixinTestFile) + .to.contain("import Ember from 'ember'") + .to.contain("import FooBarMixin from '../../../mixins/foo-bar'") + .to.contain("import { module, test } from 'qunit'") .to.contain("module 'Unit | Mixin | foo bar'") .to.contain('FooBarObject = Ember.Object.extend FooBarMixin') .to.contain('subject = FooBarObject.create()'); + + expectCoffee(mixinTestFile); })); }); }); diff --git a/node-tests/blueprints/model-test.js b/node-tests/blueprints/model-test.js index dc5f4d0..95febe6 100644 --- a/node-tests/blueprints/model-test.js +++ b/node-tests/blueprints/model-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy model', function() { setupTestHooks(this); @@ -15,15 +16,23 @@ describe('Acceptance: ember generate and destroy model', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/models/foo.coffee')) - .to.contain("`import DS from 'ember-data'`") + var modelFile = file('app/models/foo.coffee'); + + expect(modelFile) + .to.contain("import DS from 'ember-data'") .to.contain('Foo = DS.Model.extend {') - .to.contain("`export default Foo`"); + .to.contain("export default Foo"); + + expectCoffee(modelFile); + + var modelTestFile = file('tests/unit/models/foo-test.coffee'); - expect(file('tests/unit/models/foo-test.coffee')) - .to.contain("`import { moduleForModel, test } from 'ember-qunit'`") + expect(modelTestFile) + .to.contain("import { moduleForModel, test } from 'ember-qunit'") .to.contain("moduleForModel 'foo', 'Unit | Model | foo', {") .to.contain("needs: []"); + + expectCoffee(modelTestFile); })); }); @@ -32,8 +41,12 @@ describe('Acceptance: ember generate and destroy model', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/unit/models/foo-test.coffee')) + var modelTestFile = file('tests/unit/models/foo-test.coffee'); + + expect(modelTestFile) .to.contain("moduleForModel 'foo'"); + + expectCoffee(modelTestFile); })); }); }); diff --git a/node-tests/blueprints/resource-test.js b/node-tests/blueprints/resource-test.js index 5cb0e9e..59de39f 100644 --- a/node-tests/blueprints/resource-test.js +++ b/node-tests/blueprints/resource-test.js @@ -18,21 +18,21 @@ describe('Acceptance: ember generate and destroy resource', function() { return emberNew() .then(() => emberGenerateDestroy(args, (_file) => { expect(_file('app/routes/foo.coffee')) - .to.contain("`import Ember from 'ember'`") + .to.contain("import Ember from 'ember'") .to.contain('FooRoute = Ember.Route.extend()') - .to.contain("`export default FooRoute`"); + .to.contain("export default FooRoute"); expect(_file('app/templates/foo.hbs')) .to.contain('{{outlet}}'); expect(_file('tests/unit/routes/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'route:foo'"); expect(_file('app/models/foo.coffee')) - .to.contain("`import DS from 'ember-data'`") + .to.contain("import DS from 'ember-data'") .to.contain('Foo = DS.Model.extend {') - .to.contain("`export default Foo`"); + .to.contain("export default Foo"); expect(_file('tests/unit/models/foo-test.coffee')) .to.contain("moduleForModel 'foo'"); diff --git a/node-tests/blueprints/route-addon-test.js b/node-tests/blueprints/route-addon-test.js index cbad166..cad3619 100644 --- a/node-tests/blueprints/route-addon-test.js +++ b/node-tests/blueprints/route-addon-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy route-addon', function() { setupTestHooks(this); @@ -15,11 +16,19 @@ describe('Acceptance: ember generate and destroy route-addon', function() { return emberNew({ target: 'addon' }) .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/routes/foo.coffee')) - .to.contain("`export { default } from 'my-addon/routes/foo'`"); + var routeFile = file('app/routes/foo.coffee'); - expect(file('app/templates/foo.coffee')) - .to.contain("`export { default } from 'my-addon/templates/foo'`"); + expect(routeFile) + .to.contain("export { default } from 'my-addon/routes/foo'"); + + expectCoffee(routeFile); + + var templateFile = file('app/templates/foo.coffee'); + + expect(templateFile) + .to.contain("export { default } from 'my-addon/templates/foo'"); + + expectCoffee(templateFile); })); }); }); diff --git a/node-tests/blueprints/route-test.js b/node-tests/blueprints/route-test.js index b4fb4ec..716edc7 100644 --- a/node-tests/blueprints/route-test.js +++ b/node-tests/blueprints/route-test.js @@ -8,6 +8,7 @@ var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var chai = require('ember-cli-blueprint-test-helpers/chai'); var expect = chai.expect; var file = chai.file; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy route', function() { setupTestHooks(this); @@ -18,15 +19,15 @@ describe('Acceptance: ember generate and destroy route', function() { return emberNew() .then(() => emberGenerateDestroy(args, (_file) => { expect(_file('app/routes/foo.coffee')) - .to.contain("`import Ember from 'ember'`") + .to.contain("import Ember from 'ember'") .to.contain('FooRoute = Ember.Route.extend()') - .to.contain("`export default FooRoute`"); + .to.contain("export default FooRoute"); expect(_file('app/templates/foo.hbs')) .to.contain('{{outlet}}'); expect(_file('tests/unit/routes/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'route:foo', 'Unit | Route | foo', {"); expect(file('app/router.coffee')) @@ -42,9 +43,13 @@ describe('Acceptance: ember generate and destroy route', function() { return emberNew() .then(() => emberGenerateDestroy(args, (_file) => { - expect(_file('tests/unit/routes/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + var testFile = _file('tests/unit/routes/foo-test.coffee'); + + expect(testFile) + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'route:foo', 'Unit | Route | foo', {"); + + expectCoffee(testFile); })); }); }); diff --git a/node-tests/blueprints/serializer-test.js b/node-tests/blueprints/serializer-test.js index 20ef261..233a685 100644 --- a/node-tests/blueprints/serializer-test.js +++ b/node-tests/blueprints/serializer-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy serializer', function() { setupTestHooks(this); @@ -15,15 +16,23 @@ describe('Acceptance: ember generate and destroy serializer', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/serializers/foo.coffee')) - .to.contain("`import DS from 'ember-data'`") + var serializerFile = file('app/serializers/foo.coffee'); + + expect(serializerFile) + .to.contain("import DS from 'ember-data'") .to.contain('FooSerializer = DS.RESTSerializer.extend()') - .to.contain("`export default FooSerializer`"); + .to.contain("export default FooSerializer"); + + expectCoffee(serializerFile); + + var serializerTestFile = file('tests/unit/serializers/foo-test.coffee'); - expect(file('tests/unit/serializers/foo-test.coffee')) - .to.contain("`import { moduleForModel, test } from 'ember-qunit'`") + expect(serializerTestFile) + .to.contain("import { moduleForModel, test } from 'ember-qunit'") .to.contain("moduleForModel 'foo', 'Unit | Serializer | foo',") .to.contain("needs: ['serializer:foo']"); + + expectCoffee(serializerTestFile); })); }); @@ -32,10 +41,14 @@ describe('Acceptance: ember generate and destroy serializer', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/unit/serializers/foo-test.coffee')) - .to.contain("`import { moduleForModel, test } from 'ember-qunit'`") + var testFile = file('tests/unit/serializers/foo-test.coffee'); + + expect(testFile) + .to.contain("import { moduleForModel, test } from 'ember-qunit'") .to.contain("moduleForModel 'foo', 'Unit | Serializer | foo',") .to.contain("needs: ['serializer:foo']"); + + expectCoffee(testFile); })); }); }); diff --git a/node-tests/blueprints/service-test.js b/node-tests/blueprints/service-test.js index 4fb4b8b..e092bae 100644 --- a/node-tests/blueprints/service-test.js +++ b/node-tests/blueprints/service-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy service', function() { setupTestHooks(this); @@ -15,14 +16,22 @@ describe('Acceptance: ember generate and destroy service', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/services/foo.coffee')) - .to.contain("`import Ember from 'ember'`") + var serviceFile = file('app/services/foo.coffee'); + + expect(serviceFile) + .to.contain("import Ember from 'ember'") .to.contain('FooService = Ember.Service.extend()') - .to.contain("`export default FooService`"); + .to.contain("export default FooService"); + + expectCoffee(serviceFile); + + var serviceTestFile = file('tests/unit/services/foo-test.coffee'); - expect(file('tests/unit/services/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + expect(serviceTestFile) + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'service:foo', 'Unit | Service | foo', {"); + + expectCoffee(serviceTestFile); })); }); @@ -31,9 +40,13 @@ describe('Acceptance: ember generate and destroy service', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/unit/services/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + var serviceTestFile = file('tests/unit/services/foo-test.coffee'); + + expect(serviceTestFile) + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'service:foo', 'Unit | Service | foo', {"); + + expectCoffee(serviceTestFile); })); }); }); diff --git a/node-tests/blueprints/test-helper-test.js b/node-tests/blueprints/test-helper-test.js index 36e200d..54d201c 100644 --- a/node-tests/blueprints/test-helper-test.js +++ b/node-tests/blueprints/test-helper-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy test-helper', function() { setupTestHooks(this); @@ -15,10 +16,14 @@ describe('Acceptance: ember generate and destroy test-helper', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/helpers/foo.coffee')) - .to.contain("`import Ember from 'ember'`") + var testHelperFile = file('tests/helpers/foo.coffee'); + + expect(testHelperFile) + .to.contain("import Ember from 'ember'") .to.contain('foo = (app) ->') - .to.contain("`export default Ember.Test.registerAsyncHelper('foo', foo)`"); + .to.contain("export default Ember.Test.registerAsyncHelper('foo', foo)"); + + expectCoffee(testHelperFile); })); }); }); diff --git a/node-tests/blueprints/transform-test.js b/node-tests/blueprints/transform-test.js index f5aa205..ec70ec4 100644 --- a/node-tests/blueprints/transform-test.js +++ b/node-tests/blueprints/transform-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy transform', function() { setupTestHooks(this); @@ -15,14 +16,22 @@ describe('Acceptance: ember generate and destroy transform', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/transforms/foo.coffee')) - .to.contain("`import DS from 'ember-data'`") + var transformFile = file('app/transforms/foo.coffee'); + + expect(transformFile) + .to.contain("import DS from 'ember-data'") .to.contain('FooTransform = DS.Transform.extend') - .to.contain("`export default FooTransform`"); + .to.contain("export default FooTransform"); + + expectCoffee(transformFile); + + var transformTestFile = file('tests/unit/transforms/foo-test.coffee'); - expect(file('tests/unit/transforms/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + expect(transformTestFile) + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'transform:foo', 'Unit | Transform | foo', {"); + + expectCoffee(transformTestFile); })); }); @@ -31,9 +40,13 @@ describe('Acceptance: ember generate and destroy transform', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/unit/transforms/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + var testFile = file('tests/unit/transforms/foo-test.coffee'); + + expect(testFile) + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'transform:foo', 'Unit | Transform | foo', {"); + + expectCoffee(testFile); })); }); }); diff --git a/node-tests/blueprints/util-test.js b/node-tests/blueprints/util-test.js index 1ddcd74..5ec9dd5 100644 --- a/node-tests/blueprints/util-test.js +++ b/node-tests/blueprints/util-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy util', function() { setupTestHooks(this); @@ -15,16 +16,24 @@ describe('Acceptance: ember generate and destroy util', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/utils/foo-bar.coffee')) + var utilFile = file('app/utils/foo-bar.coffee'); + + expect(utilFile) .to.contain('fooBar = () ->') - .to.contain("`export default fooBar`"); + .to.contain("export default fooBar"); + + expectCoffee(utilFile); + + var utilTestFile = file('tests/unit/utils/foo-bar-test.coffee'); - expect(file('tests/unit/utils/foo-bar-test.coffee')) + expect(utilTestFile) // TODO: This import should use absolute imports - .to.contain("`import fooBar from '../../../utils/foo-bar'`") - .to.contain("`import { module, test } from 'qunit'`") + .to.contain("import fooBar from '../../../utils/foo-bar'") + .to.contain("import { module, test } from 'qunit'") .to.contain("module 'Unit | Utility | foo bar'") .to.contain('result = fooBar()'); + + expectCoffee(utilTestFile); })); }); @@ -33,11 +42,15 @@ describe('Acceptance: ember generate and destroy util', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/unit/utils/foo-bar-test.coffee')) - .to.contain("`import fooBar from '../../../utils/foo-bar'`") - .to.contain("`import { module, test } from 'qunit'`") + var testFile = file('tests/unit/utils/foo-bar-test.coffee'); + + expect(testFile) + .to.contain("import fooBar from '../../../utils/foo-bar'") + .to.contain("import { module, test } from 'qunit'") .to.contain("module 'Unit | Utility | foo bar'") .to.contain('result = fooBar()'); + + expectCoffee(testFile); })); }); }); diff --git a/node-tests/blueprints/view-test.js b/node-tests/blueprints/view-test.js index 85d56a1..8e3bec4 100644 --- a/node-tests/blueprints/view-test.js +++ b/node-tests/blueprints/view-test.js @@ -6,6 +6,7 @@ var emberNew = blueprintHelpers.emberNew; var emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('../helpers/expect-coffee'); describe('Acceptance: ember generate and destroy view', function() { setupTestHooks(this); @@ -15,14 +16,22 @@ describe('Acceptance: ember generate and destroy view', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('app/views/foo.coffee')) - .to.contain("`import Ember from 'ember'`") + var viewFile = file('app/views/foo.coffee'); + + expect(viewFile) + .to.contain("import Ember from 'ember'") .to.contain('FooView = Ember.View.extend()') - .to.contain("`export default FooView`"); + .to.contain("export default FooView"); + + expectCoffee(viewFile); + + var viewTestFile = file('tests/unit/views/foo-test.coffee'); - expect(file('tests/unit/views/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + expect(viewTestFile) + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'view:foo', 'Unit | View | foo'"); + + expectCoffee(viewTestFile); })); }); @@ -31,9 +40,13 @@ describe('Acceptance: ember generate and destroy view', function() { return emberNew() .then(() => emberGenerateDestroy(args, (file) => { - expect(file('tests/unit/views/foo-test.coffee')) - .to.contain("`import { moduleFor, test } from 'ember-qunit'`") + var testFile = file('tests/unit/views/foo-test.coffee'); + + expect(testFile) + .to.contain("import { moduleFor, test } from 'ember-qunit'") .to.contain("moduleFor 'view:foo', 'Unit | View | foo'"); + + expectCoffee(testFile); })); }); }); diff --git a/node-tests/expect-coffee-test.js b/node-tests/expect-coffee-test.js new file mode 100644 index 0000000..c52b395 --- /dev/null +++ b/node-tests/expect-coffee-test.js @@ -0,0 +1,22 @@ +'use strict'; + +var expect = require('ember-cli-blueprint-test-helpers/chai').expect; +var expectCoffee = require('./helpers/expect-coffee'); + +describe('Unit: expect-coffee', function() { + it('throws on invalid coffee-script', function() { + var testFunc = function() { + expectCoffee({ content: 'var x = 1;' }); + } + + expect(testFunc).to.throw(Error); + }); + + it('does not throw on valid coffee-script', function() { + var testFunc = function() { + expectCoffee({ content: 'x = 1' }); + } + + expect(testFunc).to.not.throw(Error); + }); +}); diff --git a/node-tests/helpers/expect-coffee.js b/node-tests/helpers/expect-coffee.js new file mode 100644 index 0000000..3c61e18 --- /dev/null +++ b/node-tests/helpers/expect-coffee.js @@ -0,0 +1,10 @@ +var coffeescript = require('coffee-script'); +var expect = require('ember-cli-blueprint-test-helpers/chai').expect; + +module.exports = function(file) { + var compileFunc = function() { + coffeescript.compile(file.content); + } + + expect(compileFunc).to.not.throw(Error); +} diff --git a/package.json b/package.json index 0fdf52d..762a266 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "license": "MIT", "devDependencies": { "broccoli-asset-rev": "^2.2.0", + "coffee-script": "^1.12.3", "ember-ajax": "0.7.1", "ember-cli": "2.6.2", "ember-cli-app-version": "^1.0.0", @@ -54,7 +55,7 @@ "blueprints" ], "dependencies": { - "broccoli-coffee": "~0.6.0", + "broccoli-coffee": "~0.8.0", "broccoli-persistent-filter": "^1.1.0", "chalk": "^1.0.0", "coffeelint": "^1.6.1", diff --git a/tests/dummy/app/app.coffee b/tests/dummy/app/app.coffee index 8adab3f..d5787b7 100644 --- a/tests/dummy/app/app.coffee +++ b/tests/dummy/app/app.coffee @@ -1,7 +1,7 @@ -`import Ember from 'ember'` -`import Resolver from './resolver'` -`import loadInitializers from 'ember-load-initializers'` -`import config from './config/environment'` +import Ember from 'ember' +import Resolver from './resolver' +import loadInitializers from 'ember-load-initializers' +import config from './config/environment' App = null @@ -14,4 +14,4 @@ App = Ember.Application.extend loadInitializers App, config.modulePrefix -`export default App` +export default App diff --git a/tests/dummy/app/router.coffee b/tests/dummy/app/router.coffee index bb6db84..cfaefca 100644 --- a/tests/dummy/app/router.coffee +++ b/tests/dummy/app/router.coffee @@ -1,9 +1,9 @@ -`import Ember from 'ember'` -`import config from './config/environment'` +import Ember from 'ember' +import config from './config/environment' Router = Ember.Router.extend location: config.locationType Router.map -> -`export default Router` +export default Router diff --git a/tests/dummy/app/routes/index.coffee b/tests/dummy/app/routes/index.coffee index d55fe22..af4965b 100644 --- a/tests/dummy/app/routes/index.coffee +++ b/tests/dummy/app/routes/index.coffee @@ -1,7 +1,7 @@ -`import Ember from 'ember'` +import Ember from 'ember' IndexController = Ember.Route.extend model: -> 'Howdy' -`export default IndexController` +export default IndexController