@@ -162,10 +162,9 @@ describe("Cucumber.Runtime.AstTreeWalker", function() {
162
162
163
163
describe ( "visitScenario()" , function ( ) {
164
164
var scenario , callback ;
165
- var world ;
166
165
167
166
beforeEach ( function ( ) {
168
- scenario = createSpyWithStubs ( "Scenario AST element" , { acceptVisitor : null } ) ;
167
+ scenario = createSpyWithStubs ( "scenario" ) ;
169
168
callback = createSpy ( "Callback" ) ;
170
169
spyOnStub ( supportCodeLibrary , 'instantiateNewWorld' ) ;
171
170
} ) ;
@@ -177,21 +176,22 @@ describe("Cucumber.Runtime.AstTreeWalker", function() {
177
176
} ) ;
178
177
179
178
describe ( "on world instantiation completion" , function ( ) {
180
- var worldInstantiationCompletionCallback , world , event , payload , hookedUpFunction ;
179
+ var worldInstantiationCompletionCallback ;
180
+ var world , event , payload ;
181
+ var hookedUpScenarioVisit ;
181
182
182
183
beforeEach ( function ( ) {
183
- world = createSpy ( "world instance" ) ;
184
184
treeWalker . visitScenario ( scenario , callback ) ;
185
185
worldInstantiationCompletionCallback = supportCodeLibrary . instantiateNewWorld . mostRecentCall . args [ 0 ] ;
186
-
187
- event = createSpy ( "Event" ) ;
188
- payload = { scenario : scenario } ;
189
- scenarioVisitWithHooks = createSpy ( "scenario visit with hooks" ) ;
190
- spyOn ( Cucumber . Runtime . AstTreeWalker , 'Event' ) . andReturn ( event ) ;
191
- spyOn ( treeWalker , 'broadcastEventAroundUserFunction' ) ;
186
+ world = createSpy ( "world instance" ) ;
187
+ event = createSpy ( "scenario visit event" ) ;
188
+ hookedUpScenarioVisit = createSpy ( "hooked up scenario visit" ) ;
189
+ payload = { scenario : scenario } ;
192
190
spyOn ( treeWalker , 'setWorld' ) ;
193
191
spyOn ( treeWalker , 'witnessNewScenario' ) ;
194
- spyOn ( treeWalker , 'hookUpFunction' ) . andReturn ( scenarioVisitWithHooks ) ;
192
+ spyOn ( Cucumber . Runtime . AstTreeWalker , 'Event' ) . andReturn ( event ) ;
193
+ spyOnStub ( supportCodeLibrary , 'hookUpFunctionWithWorld' ) . andReturn ( hookedUpScenarioVisit ) ;
194
+ spyOn ( treeWalker , 'broadcastEventAroundUserFunction' ) ;
195
195
} ) ;
196
196
197
197
it ( "sets the new World instance" , function ( ) {
@@ -211,28 +211,30 @@ describe("Cucumber.Runtime.AstTreeWalker", function() {
211
211
212
212
it ( "hooks up a function" , function ( ) {
213
213
worldInstantiationCompletionCallback ( world ) ;
214
- expect ( treeWalker . hookUpFunction ) . toHaveBeenCalled ( ) ;
215
- expect ( treeWalker . hookUpFunction ) . toHaveBeenCalledWithAFunctionAsNthParameter ( 1 ) ;
214
+ expect ( supportCodeLibrary . hookUpFunctionWithWorld ) . toHaveBeenCalled ( ) ;
215
+ expect ( supportCodeLibrary . hookUpFunctionWithWorld ) . toHaveBeenCalledWithAFunctionAsNthParameter ( 1 ) ;
216
+ expect ( supportCodeLibrary . hookUpFunctionWithWorld ) . toHaveBeenCalledWithValueAsNthParameter ( world , 2 ) ;
216
217
} ) ;
217
218
218
219
describe ( "hooked up function" , function ( ) {
219
220
var hookedUpFunction , hookedUpFunctionCallback ;
220
221
221
222
beforeEach ( function ( ) {
222
- hookedUpFunctionCallback = createSpy ( "hooked up function callback" ) ;
223
223
worldInstantiationCompletionCallback ( world ) ;
224
- hookedUpFunction = treeWalker . hookUpFunction . mostRecentCall . args [ 0 ] ;
224
+ hookedUpFunction = supportCodeLibrary . hookUpFunctionWithWorld . mostRecentCall . args [ 0 ] ;
225
+ hookedUpFunctionCallback = createSpy ( "hooked up function callback" ) ;
226
+ spyOnStub ( scenario , 'acceptVisitor' ) ;
225
227
} ) ;
226
228
227
- it ( "tells the scenario to accept the tree walker itself as a visitor" , function ( ) {
229
+ it ( "instructs the scenario to accept the tree walker as a visitor" , function ( ) {
228
230
hookedUpFunction ( hookedUpFunctionCallback ) ;
229
231
expect ( scenario . acceptVisitor ) . toHaveBeenCalledWith ( treeWalker , hookedUpFunctionCallback ) ;
230
232
} ) ;
231
233
} ) ;
232
234
233
235
it ( "broadcasts the visit of the scenario" , function ( ) {
234
236
worldInstantiationCompletionCallback ( world ) ;
235
- expect ( treeWalker . broadcastEventAroundUserFunction ) . toHaveBeenCalledWith ( event , scenarioVisitWithHooks , callback ) ;
237
+ expect ( treeWalker . broadcastEventAroundUserFunction ) . toHaveBeenCalledWith ( event , hookedUpScenarioVisit , callback ) ;
236
238
} ) ;
237
239
} ) ;
238
240
} ) ;
0 commit comments