Skip to content
Permalink
Browse files

fix(server tests): to recognize jasmine-expect matchers when installe…

…d globally
  • Loading branch information
jyounce committed Feb 17, 2016
1 parent 436b2d0 commit 840afbbc00b36ea08055fc99d6f319a49d957561
@@ -5,7 +5,7 @@ module.exports = (config, options) ->

# modules
# =======
rbModules = ['body-parser', 'express', 'q']
rbModules = ['body-parser', 'express', 'jasmine-expect', 'q']
appModules = options.server.node_modules or []

# http proxy
@@ -13,7 +13,7 @@ module.exports = (config) ->
Reporter = require 'jasmine-terminal-reporter'
isType = require "#{config.req.helpers}/isType"
moduleHelp = require "#{config.req.helpers}/module"
jasmineExpect = path.join config.node_modules.rb.src.relPath, 'jasmine-expect', 'index.js'
jasmineExpect = path.join config.node_modules.rb.dist.modules['jasmine-expect'], 'index.js'

# helpers
# =======
@@ -1,6 +1,9 @@
module.exports = (config, gulp) ->
q = require 'q'
q = require 'q'
promiseHelp = require "#{config.req.helpers}/promise"

# tasks
# =====
copyTask = (src, dest) ->
defer = q.defer()
gulp.src src
@@ -9,22 +12,40 @@ module.exports = (config, gulp) ->
defer.resolve()
defer.promise

removeJasmineExpect = ->
return promiseHelp.get() if config.env.is.testServer
rbModules = config.node_modules.rb.modules
for i, module of rbModules
if module is 'jasmine-expect'
rbModules.splice i, 1
break
promiseHelp.get()

copyModules = ->
tasks = []
defer = q.defer()

for appOrRb, v of config.node_modules
continue if appOrRb is 'rb' and config.exclude.default.server.files
for module in v.modules
src = config.glob.node_modules[appOrRb].src[module]
dest = v.dist.modules[module]
do (src, dest) ->
tasks.push ->
copyTask src, dest

tasks.reduce(q.when, q()).done -> defer.resolve()
defer.promise

# API
# ===
api =
runTask: ->
tasks = []
runTask: -> # synchronously
defer = q.defer()

for appOrRb, v of config.node_modules
continue if appOrRb is 'rb' and config.exclude.default.server.files
for module in v.modules
src = config.glob.node_modules[appOrRb].src[module]
dest = v.dist.modules[module]
do (src, dest) ->
tasks.push ->
copyTask src, dest

tasks = [
-> removeJasmineExpect()
-> copyModules()
]
tasks.reduce(q.when, q()).done -> defer.resolve()
defer.promise

@@ -18,6 +18,7 @@ module.exports = (config) ->
src = [
config.dist.rb.server.test.dir
config.dist.app.server.test.dir
config.node_modules.rb.dist.modules['jasmine-expect']
]
cleanTask src

0 comments on commit 840afbb

Please sign in to comment.
You can’t perform that action at this time.