-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow World constructor to set explicit World object (close #50)
- Loading branch information
Showing
7 changed files
with
121 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Feature: World constructor callback with object | ||
It is possible for the World constructor function to tell Cucumber | ||
to use another object than itself as the World instance: | ||
|
||
this.World = function WorldConstructor(callback) { | ||
var myCustomWorld = { dance: function() { /* ... */ } }; | ||
callback(myCustomWorld); // tell Cucumber to use myCustomWorld | ||
// as the world object. | ||
}; | ||
|
||
If no parameter is passed to the callback, the WorldConstructor | ||
instance will be used by Cucumber: | ||
|
||
this.World = function WorldConstructor(callback) { | ||
var myCustomWorld = {}; | ||
callback(); // could have been written `callback(this);` | ||
}; | ||
|
||
Scenario: scenario calling function on explicit world instance | ||
Given a custom World constructor calling back with an explicit object | ||
When Cucumber executes a scenario that calls a function on the explicit World object | ||
Then the feature passes | ||
And the explicit World object function should have been called |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters