2012-01-11 19:30:10 +00:00
|
|
|
jasmine.GWT =
|
|
|
|
Step: (type, name, parameter) ->
|
|
|
|
if scenario = jasmine.GWT.currentScenario_
|
|
|
|
scenario[type](name, parameter)
|
|
|
|
else
|
2012-01-17 14:09:44 +00:00
|
|
|
(jasmine.GWT.Steps[type] ||= []).push([ name, parameter ])
|
2012-01-12 15:13:58 +00:00
|
|
|
|
2012-01-11 19:30:10 +00:00
|
|
|
Hook: (type, code) ->
|
2012-01-17 14:09:44 +00:00
|
|
|
(jasmine.GWT.Hooks[type] ||= []).push(code)
|
2012-01-11 19:30:10 +00:00
|
|
|
|
2012-01-12 15:13:58 +00:00
|
|
|
World: (object_or_code) ->
|
|
|
|
if typeof object_or_code != 'function'
|
2012-01-17 14:09:44 +00:00
|
|
|
object_or_code = jasmine.GWT.generateWorldMethods(object_or_code)
|
2012-01-12 15:13:58 +00:00
|
|
|
|
|
|
|
jasmine.GWT.Hook('World', object_or_code)
|
|
|
|
|
2012-01-11 19:30:10 +00:00
|
|
|
runHook: (type, context) ->
|
|
|
|
for code in (jasmine.GWT.Hooks[type] || [])
|
|
|
|
code.apply(context)
|
|
|
|
|
2012-01-17 14:09:44 +00:00
|
|
|
generateWorldMethods: (object) ->
|
2012-01-12 15:13:58 +00:00
|
|
|
->
|
|
|
|
for method, code of object
|
|
|
|
this[method] = code
|
|
|
|
|
2012-01-11 19:30:10 +00:00
|
|
|
Steps: {}
|
|
|
|
Hooks: {}
|