Skip to content

Test that generated blueprints are valid CoffeeScript #132

@kimroen

Description

@kimroen

Here's an example of a test for generating and destroying ember g adapter foo:

it('adapter foo', function() {
  var args = ['adapter', 'foo'];

  return emberNew()
    .then(() => emberGenerateDestroy(args, (file) => {
      expect(file('app/adapters/foo.coffee'))
        .to.contain("stuff");
  }));
});

What I want to do is to add a step here after the generator has run (but before it has been destroyed) that compiles the specified file with CoffeeScript and checks that it worked.

This will make sure we keep producing valid CoffeeScript, and should allow us to catch all kinds of bugs.

We could make our own test helper that compiles the specified file and verifies that it doesn't blow up. Something like this (just thinking out loud, this won't work):

it('adapter foo', function() {
  var args = ['adapter', 'foo'];

  return emberNew()
    .then(() => emberGenerateDestroy(args, (file) => {
      adapterFile = file('app/adapters/foo.coffee');
      expect(adapterFile)
        .to.contain("stuff");

      expect(compileCoffee(adapterFile)).to.not.throw(Error);
      // or something more contained like
      compileAndExpectCoffee(adapterFile);
  }));
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions