Skip to content

Instantly share code, notes, and snippets.

@mfeckie
Last active August 29, 2015 13:57
Show Gist options
  • Save mfeckie/9391558 to your computer and use it in GitHub Desktop.
Save mfeckie/9391558 to your computer and use it in GitHub Desktop.
routesTo: (url, route_name)->
visit(url)
andThen ->
current_route = App.__container__.lookup('controller:application').currentRouteName
equal current_route, route_name, "Expected #{route_name}, got: #{current_route}"
({
routesTo: function(url, route_name) {
visit(url);
return andThen(function() {
var current_route;
current_route = App.__container__.lookup('controller:application').currentRouteName;
return equal(current_route, route_name, "Expected " + route_name + ", got: " + current_route);
});
}
});
/* Basically what's happening is coffeescripit is returning an unnamed object with a routesTo function
* This would not make the helper available in the tests.
*/
routesTo = (url, route_name) ->
visit url
andThen ->
current_route = AddressBook.__container__.lookup("controller:application").currentRouteName
equal current_route, route_name, "Expected " + route_name + ", got: " + current_route
return
return
# Note that when it is transpiled from the original, two return keywords are added, which are missing from your version
var routesTo = function (url, route_name) {
visit(url);
andThen(function () {
var current_route = AddressBook.__container__.lookup('controller:application').currentRouteName;
equal(current_route, route_name, 'Expected ' + route_name + ', got: ' + current_route);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment