even better spy handling
This commit is contained in:
parent
f9ec7cb8ea
commit
14a7e68397
@ -57,21 +57,35 @@ class jasmine.GWT.Scenario extends jasmine.GWT.Background
|
|||||||
|
|
||||||
describe @feature.name, ->
|
describe @feature.name, ->
|
||||||
describe scenarioName, ->
|
describe scenarioName, ->
|
||||||
|
_this.spies_ = []
|
||||||
|
|
||||||
jasmine.GWT.runHook('Before', _this)
|
jasmine.GWT.runHook('Before', _this)
|
||||||
|
|
||||||
for [ type, name, param ] in _statements
|
for index in [ 0..._statements.length ]
|
||||||
|
[ type, name, param ] = _statements[index]
|
||||||
|
|
||||||
_this._type = type
|
_this._type = type
|
||||||
_this._name = name
|
_this._name = name
|
||||||
|
|
||||||
runCode = (param, args = []) ->
|
isLast = (index + 1) == _statements.length
|
||||||
|
|
||||||
|
runCode = (param, isLast, args = []) ->
|
||||||
it "#{type} #{name}", ->
|
it "#{type} #{name}", ->
|
||||||
|
this.spyOn = (args...) ->
|
||||||
|
this.spies_ = _this.spies_
|
||||||
|
jasmine.Spec.prototype.spyOn.apply(this, args)
|
||||||
|
|
||||||
|
this.removeAllSpies = ->
|
||||||
|
if isLast
|
||||||
|
jasmine.Spec.prototype.removeAllSpies.apply(_this)
|
||||||
|
|
||||||
param.apply(_this, args)
|
param.apply(_this, args)
|
||||||
|
|
||||||
args = []
|
args = []
|
||||||
|
|
||||||
if param?
|
if param?
|
||||||
if typeof param == "function"
|
if typeof param == "function"
|
||||||
runCode(param)
|
runCode(param, isLast)
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
args = [ param ]
|
args = [ param ]
|
||||||
@ -83,13 +97,13 @@ class jasmine.GWT.Scenario extends jasmine.GWT.Background
|
|||||||
if match.constructor == RegExp
|
if match.constructor == RegExp
|
||||||
if result = name.match(match)
|
if result = name.match(match)
|
||||||
result.shift()
|
result.shift()
|
||||||
runCode(code, result.concat(args))
|
runCode(code, isLast, result.concat(args))
|
||||||
found = true
|
found = true
|
||||||
|
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
if name == match
|
if name == match
|
||||||
runCode(code)
|
runCode(code, isLast)
|
||||||
found = true
|
found = true
|
||||||
|
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user