Permalink
Browse files

primitive phantomjs integration

  • Loading branch information...
1 parent 7328744 commit 53cb29e39cff4a2408603fd60699af6e76cccf44 @lancejpollard lancejpollard committed Sep 15, 2012
View
@@ -2,8 +2,10 @@ language: node_js
node_js:
- 0.8
install: npm install
+# @todo once `make test-client` is working
#before_script:
-# - "export DISPLAY=:99.0"
-# - "sh -e /etc/init.d/xvfb start"
-# - "cake build"
-#script: "cake test[all]"
+# - "cd test/example"
+# - "grunt --config ./grunt.coffee"
+# - "cd ../.."
+# - "node test/example -p 3210"
+# - sleep 3 # give Web server some time to bind to sockets, etc
View
@@ -19,8 +19,14 @@ test-memory:
test-mongodb:
$(CMD) $(SRC) --store mongodb
-test-browser:
- $(shell phantomjs test/client.js) # file://localhost$(DIR)/test/client/index.html
+start-client-test-server:
+ cd test/example
+ grunt --config ./grunt.coffee
+ cd ../..
+ node test/example -p 3210
+
+test-client:
+ phantomjs test/client.coffee http://localhost:3210/?test=model,support,application,store
clean:
rm -rf lib/*
@@ -44,4 +50,4 @@ dist:
publish:
npm publish
-.PHONY: test-memory test-mongodb test test-all check test-browser build dist
+.PHONY: test-memory test-mongodb test test-all check test-client build dist start-client-test-server
View
@@ -171,7 +171,7 @@ module.exports = (grunt) ->
#grunt.loadNpmTasks 'grunt-coffee'
grunt.registerTask 'concat:tests', concatTestsCommand.join(' ')
- grunt.registerTask 'default', 'coffee:all copy:packageJSON build:client copy:clientForTests coffee:tests concat:tests'
+ grunt.registerTask 'default', 'coffee:all copy:packageJSON build:client copy:clientForTests coffee:tests'
grunt.registerTask 'start', 'default watch'
grunt.registerTask 'dist', 'build uploadToGithub'
grunt.registerTask ''
@@ -166,6 +166,7 @@ class Tower.Application extends Tower.Engine
@server.on 'error', (error) ->
if error.errno == 'EADDRINUSE'
console.log(' Try using a different port: `node server -p 3001`')
+ process.exit()
#console.log(error.stack)
@initializeSockets()
@@ -118,7 +118,8 @@ class Tower.NetRoute extends Tower.Class
request.params = params
if controller
- controller = Tower.constant(Tower.namespaced(@controller.className)).create()
+ controller = Tower.constant(Tower.namespaced(controller.className)).create()
+
controller
get: (name) ->
@@ -69,6 +69,7 @@ Tower.SupportObject =
functionName: (fn) ->
return fn.__name__ if fn.__name__
return fn.name if fn.name
+ #return fn.toString() if Ember.Object.detect(fn)
fn.toString().match(/\W*function\s+([\w\$]+)\(/)?[1]
castArray: (object) ->
@@ -7,6 +7,8 @@ describe 'Tower.Controller', ->
Tower.Route.draw ->
@match '/custom', to: 'custom#index'
@match '/custom/:id', to: 'custom#show'
+
+ console.log 'here'
controller = App.CustomController.create()
View
@@ -1,3 +1,56 @@
+# https://github.com/metaskills/mocha-phantomjs
+# https://github.com/kmiyashiro/grunt-mocha
+args = phantom.args
+if args.length < 1 or args.length > 2
+ console.log "Usage: #{phantom.scriptName} <URL> <timeout>"
+ phantom.exit 1
+
+#phantom.viewportSize =
+# width: 800
+# height: 600
+
+page = require('webpage').create()
+
+page.onConsoleMessage = (message) ->
+ console.log(message)
+
+page.open args[0], (status) ->
+ testCompletion = ->
+ page.evaluate ->
+ return true if $('#mocha #stats .progress')
+ false
+
+ printTestResults = ->
+ page.evaluate ->
+ console.log document.body.querySelector(".description").innerText
+ list = document.body.querySelectorAll("div.jasmine_reporter > div.suite.failed")
+ i = 0
+ while i < list.length
+ el = list[i]
+ desc = el.querySelectorAll(".description")
+ console.log ""
+ j = 0
+ while j < desc.length
+ console.log desc[j].innerText
+ ++j
+ ++i
+
+ phantom.exit()
+
+ #waitFor testCompletion, printTestResults
+ setTimeout phantom.exit, 3000
+
+# # A bit of a hack until we can figure this out on Travis
+# tries = 0
+# while tries < 3 && $?.exitstatus === 124
+# tries += 1
+# puts "Timed Out. Trying again..."
+# system(cmd)
+# end
+#
+# success &&= $?.success?
+
+###
exec = require("child_process").exec
forever = require("forever")
Hook = require("hook.io").Hook
@@ -31,4 +84,4 @@ hook.on "design.io-server::tower-test::client::log", (data, callback, event) =>
next()
hook.start()
-
+###
@@ -1,4 +1,5 @@
Tower.Route.draw ->
+ @match "/", to: "application#welcome"
@match "/sign-in", to: "sessions#new", via: "get", as: "login"
# test routes
@@ -44,6 +45,5 @@ Tower.Route.draw ->
@resources 'posts'
@resources 'users'
#@match '/users', via: ['post'], to: 'users#index'
- @match "/", to: "application#welcome"
@resources "posts"
@@ -22,5 +22,4 @@ html ->
javascripts 'tests'
script "App.bootstrap(#{JSON.stringify(@bootstrapData, null, [])})" if @bootstrapData
-
div id: 'mocha', ->
View
@@ -2,7 +2,7 @@
process.env.TOWER_ROOT = __dirname;
require("coffee-script");
-require("../../lib/tower");
+require("../..");
Tower.View.engine = "coffee"
// must run `node server` relative to this test/example folder
View
No changes.

0 comments on commit 53cb29e

Please sign in to comment.