ember testing
after running `generate app foo` you'll also get a basic test for your new ember app. you can run the tests for as specific app with: rake js:dev <app> rake js:dev quizzes Change-Id: I55c53e875c06d44ae553100bf8d73a4ee83ba278 Reviewed-on: https://gerrit.instructure.com/26023 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jason Madsen <jmadsen@instructure.com> Product-Review: Ryan Florence <ryanf@instructure.com> QA-Review: Ryan Florence <ryanf@instructure.com>
This commit is contained in:
parent
5a1fbff086
commit
cc75168558
|
@ -10,7 +10,7 @@ module Canvas
|
|||
JS_ROOT = "#{Rails.root}/public/javascripts"
|
||||
|
||||
def matcher
|
||||
ENV['JS_SPEC_MATCHER'] || '**/*Spec.js'
|
||||
ENV['JS_SPEC_MATCHER'] || '**/*{Spec,.spec}.js'
|
||||
end
|
||||
|
||||
# get all regular canvas (and plugin) bundles
|
||||
|
|
|
@ -2,7 +2,16 @@ require 'timeout'
|
|||
|
||||
namespace :js do
|
||||
|
||||
desc 'run testem as you develop, can use `rake js:dev <ember app name>`'
|
||||
task :dev do
|
||||
app = ARGV[1]
|
||||
if app
|
||||
ENV['JS_SPEC_MATCHER'] = "**/#{app}/**/*.spec.js"
|
||||
unless File.exists?("app/coffeescripts/ember/#{app}")
|
||||
puts "no app found at app/coffeescripts/ember/#{app}"
|
||||
exit
|
||||
end
|
||||
end
|
||||
Rake::Task['js:generate_runner'].invoke
|
||||
exec('testem -f config/testem.yml')
|
||||
end
|
||||
|
|
|
@ -17,7 +17,9 @@ exports.present = function(appName) {
|
|||
exports.templates = [
|
||||
'new_app/config/app.coffee.hbs',
|
||||
'new_app/config/routes.coffee.hbs',
|
||||
'new_app/templates/application.hbs.hbs'
|
||||
'new_app/templates/application.hbs.hbs',
|
||||
'new_app/tests/app.coffee.hbs',
|
||||
'new_app/tests/app.spec.coffee.hbs'
|
||||
];
|
||||
|
||||
exports.savePath = function(template, env) {
|
||||
|
@ -25,7 +27,9 @@ exports.savePath = function(template, env) {
|
|||
return {
|
||||
'new_app/config/app.coffee.hbs': 'app/coffeescripts/ember/'+env.appName+'/config/app.coffee',
|
||||
'new_app/config/routes.coffee.hbs': 'app/coffeescripts/ember/'+env.appName+'/config/routes.coffee',
|
||||
'new_app/templates/application.hbs.hbs': 'app/coffeescripts/ember/'+env.appName+'/templates/'+env.appName+'.hbs'
|
||||
'new_app/templates/application.hbs.hbs': 'app/coffeescripts/ember/'+env.appName+'/templates/'+env.appName+'.hbs',
|
||||
'new_app/tests/app.coffee.hbs': 'app/coffeescripts/ember/'+env.appName+'/tests/app.coffee',
|
||||
'new_app/tests/app.spec.coffee.hbs': 'app/coffeescripts/ember/'+env.appName+'/tests/app.spec.coffee'
|
||||
}[template];
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
define ['../main'], (Application) ->
|
||||
App = Application.create
|
||||
LOG_ACTIVE_GENERATION: yes
|
||||
LOG_MODULE_RESOLVER: yes
|
||||
LOG_TRANSITIONS: yes
|
||||
LOG_TRANSITIONS_INTERNAL: yes
|
||||
LOG_VIEW_LOOKUPS: yes
|
||||
rootElement: '#fixtures'
|
||||
history: 'none'
|
||||
App.setupForTesting()
|
||||
App.injectTestHelpers()
|
||||
App.advanceReadiness()
|
||||
App
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
define ['./app', 'ember'], (App, Ember) ->
|
||||
|
||||
module '{{appName}}', ->
|
||||
setup: ->
|
||||
App.reset()
|
||||
Ember.run(App, App.advanceReadiness)
|
||||
|
||||
test 'says hello', ->
|
||||
visit('/').then ->
|
||||
equal(find('h1').html().trim(), 'HELLO!')
|
||||
|
|
@ -105,9 +105,10 @@
|
|||
var onSpecsLoaded = null;
|
||||
require(<%=
|
||||
Dir[
|
||||
"public/javascripts/#{matcher}",
|
||||
"spec/javascripts/compiled/#{matcher}",
|
||||
"spec/plugins/*/javascripts/compiled/#{matcher}"
|
||||
].map{ |file| file.sub(/\.js$/, '') }.inspect
|
||||
].map{ |file| file.sub(/\.js$/, '').sub(/public\/javascripts\//, '') }.inspect
|
||||
%>, function() {
|
||||
specsLoading = false;
|
||||
if (onSpecsLoaded) onSpecsLoaded();
|
||||
|
|
Loading…
Reference in New Issue