a little more cleanup
This commit is contained in:
parent
98982e28e5
commit
81673543fe
@ -3,16 +3,14 @@ jasmine.GWT =
|
||||
if scenario = jasmine.GWT.currentScenario_
|
||||
scenario[type](name, parameter)
|
||||
else
|
||||
jasmine.GWT.Steps[type] ||= []
|
||||
jasmine.GWT.Steps[type].push([ name, parameter ])
|
||||
(jasmine.GWT.Steps[type] ||= []).push([ name, parameter ])
|
||||
|
||||
Hook: (type, code) ->
|
||||
jasmine.GWT.Hooks[type] ||= []
|
||||
jasmine.GWT.Hooks[type].push(code)
|
||||
(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)
|
||||
object_or_code = jasmine.GWT.generateWorldMethods(object_or_code)
|
||||
|
||||
jasmine.GWT.Hook('World', object_or_code)
|
||||
|
||||
@ -20,7 +18,7 @@ jasmine.GWT =
|
||||
for code in (jasmine.GWT.Hooks[type] || [])
|
||||
code.apply(context)
|
||||
|
||||
_generateWorldMethods: (object) ->
|
||||
generateWorldMethods: (object) ->
|
||||
->
|
||||
for method, code of object
|
||||
this[method] = code
|
||||
|
@ -28,3 +28,36 @@ describe 'jasmine.GWT', ->
|
||||
|
||||
expect(jasmine.GWT.currentScenario_[type]).toHaveBeenCalledWith(name, parameter)
|
||||
|
||||
describe '.Hook', ->
|
||||
type = 'type'
|
||||
code = 'code'
|
||||
|
||||
beforeEach ->
|
||||
jasmine.GWT.Hooks = {}
|
||||
|
||||
it 'should add the hook', ->
|
||||
jasmine.GWT.Hook(type, code)
|
||||
|
||||
expect(jasmine.GWT.Hooks[type]).toEqual([ code ])
|
||||
|
||||
describe '.World', ->
|
||||
worldMethods = 'worldMethods'
|
||||
|
||||
beforeEach ->
|
||||
spyOn(jasmine.GWT, 'Hook')
|
||||
spyOn(jasmine.GWT, 'generateWorldMethods').andReturn(worldMethods)
|
||||
|
||||
context 'with object', ->
|
||||
object = {}
|
||||
|
||||
it 'should add an object that adds methods to the World', ->
|
||||
jasmine.GWT.World(object)
|
||||
expect(jasmine.GWT.Hook).toHaveBeenCalledWith('World', worldMethods)
|
||||
|
||||
context 'with function', ->
|
||||
func = ->
|
||||
|
||||
it 'should add the function to the queue', ->
|
||||
jasmine.GWT.World(func)
|
||||
expect(jasmine.GWT.Hook).toHaveBeenCalledWith('World', func)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user