add support for World, works like it does in cucumber
This commit is contained in:
parent
50881d3d86
commit
e4b2d39b31
@ -5,13 +5,25 @@ jasmine.GWT =
|
||||
else
|
||||
jasmine.GWT.Steps[type] ||= []
|
||||
jasmine.GWT.Steps[type].push([ name, parameter ])
|
||||
|
||||
Hook: (type, code) ->
|
||||
jasmine.GWT.Hooks[type] ||= []
|
||||
jasmine.GWT.Hooks[type].push(code)
|
||||
|
||||
World: (object_or_code) ->
|
||||
if typeof object_or_code != 'function'
|
||||
object_or_code = jasmine.GWT._generateWorldMethods(object_or_code)
|
||||
|
||||
jasmine.GWT.Hook('World', object_or_code)
|
||||
|
||||
runHook: (type, context) ->
|
||||
for code in (jasmine.GWT.Hooks[type] || [])
|
||||
code.apply(context)
|
||||
|
||||
_generateWorldMethods: (object) ->
|
||||
->
|
||||
for method, code of object
|
||||
this[method] = code
|
||||
|
||||
Steps: {}
|
||||
Hooks: {}
|
||||
|
@ -23,6 +23,7 @@ class jasmine.GWT.Scenario extends jasmine.GWT.Background
|
||||
|
||||
it "#{type} #{name}", ->
|
||||
if isFirst
|
||||
jasmine.GWT.runHook('World', _this)
|
||||
jasmine.GWT.runHook('Before', _this)
|
||||
|
||||
this.spyOn = (args...) ->
|
||||
|
@ -26,3 +26,5 @@ jasmine.GWT.globals =
|
||||
Before: (args...) -> jasmine.GWT.Hook('Before', args...)
|
||||
After: (args...) -> jasmine.GWT.Hook('After', args...)
|
||||
|
||||
World: (args...) -> jasmine.GWT.World(args...)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user