Skip to content

Commit

Permalink
Add documentation about World to README
Browse files Browse the repository at this point in the history
  • Loading branch information
jbpros committed Mar 21, 2012
1 parent 92d95b2 commit 9824fdf
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions README.md
Expand Up @@ -122,18 +122,38 @@ Support files let you setup the environment in which steps will be run, and defi
// features/support/world.js

var zombie = require('zombie');
var World = function(callback) {
var World = function World(callback) {
this.browser = new zombie.Browser(); // this.browser will be available in step definitions

this.visit = function(url, callback) {
this.browser.visit(url, callback);
};

callback(); // tell Cucumber we're finished
callback(); // tell Cucumber we're finished and to use 'this' as the world instance
};
exports.World = World;
```

It is possible to tell Cucumber to use another object instance than the constructor:

``` javascript
// features/support/world.js

var zombie = require('zombie');
var WorldConstructor = function WorldConstructor(callback) {
this.browser = new zombie.Browser(); // this.browser will be available in step definitions

var world = {
visit: function(url, callback) {
this.browser.visit(url, callback);
}
};

callback(world); // tell Cucumber we're finished and to use our world object instead of 'this'
};
exports.World = WorldConstructor;
```

#### Step Definitions

Step definitions are the glue between features written in Gherkin and the actual *SUT* (*system under test*). They are written in JavaScript.
Expand Down

0 comments on commit 9824fdf

Please sign in to comment.