Integration tests + App as a namespace


#1

I’m in the middle of rewriting Travis CI to the newest router and I would like to also fix our tests. I don’t have any problems with unit tests, which mostly pass, but I’m not really sure how to fix integration tests.

In the previous version Travis was a namespace and the application was created as Travis.app:

Travis = Em.Namespace.create();
Travis.ApplicationController = Em.Controller.extend();
Travis.app = Em.Application.create();

We used such setup in order to allow removing application and recreate it before each of integration tests. The problem is that now container will look for classes on the app object, so on Travis.app not Travis.

The first thing that comes to my mind is to override a method, which creates default container, but buildContainer method is marked as private and I’m not sure how to if it to use Travis namespace by default. I tried with such code:

Travis.app = Em.Application.create({
  buildContainer: function() {
    var container = this.__container__ = Em.Application.buildContainer(Travis);

    return container;
  }
})

but then app does not render default application template.

The other idea is to just copy each property from Travis to Travis.app just after creation, but that’s hacky and I would like to use something better.

Finally, the last thing I can think of is to find a better way of “refreshing” the app, but I can’t think of anything better than destroy + create.


#2

App.reset() might be what you’re looking for. It was added a couple weeks ago https://github.com/emberjs/ember.js/commit/47b1456


#3

Looks like exactly what I need, thanks! I’ll give it a shot today.


#4