Created
February 18, 2014 18:56
-
-
Save mrinterweb/9077407 to your computer and use it in GitHub Desktop.
Teaspoon test helpers using require.js and CoffeeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module 'routing specs', | |
setup: -> | |
teardown: -> | |
App.reset() | |
require ['testingHelper'], (testingHelper)-> | |
test 'root route', -> | |
testingHelper.routesTo('/', 'index') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#= require requirejs/require | |
#= require application.js.erb | |
#= require support/testing_helpers | |
#= require_self | |
d = document | |
d.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>') | |
App.rootElement = '#ember-testing' | |
App.setupForTesting() | |
App.injectTestHelpers() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define 'testingHelper', -> | |
{ | |
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}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment