Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add World #26

Closed
jbpros opened this issue Sep 5, 2011 · 2 comments
Closed

Add World #26

jbpros opened this issue Sep 5, 2011 · 2 comments
Assignees
Milestone

Comments

@jbpros
Copy link
Member

jbpros commented Sep 5, 2011

See https://github.com/cucumber/cucumber/wiki/A-Whole-New-World and #2 (comment)

var assert = require('assert');

var defineSteps = function() {
  // `this` is set to an object supplying Given, When, Then and the World constructor.

  this.World = function World() { this.cukes = 0; }; // this is optional, would default to
                                                     // an empty constructor; kinda similar to
                                                     // cucumber-ruby's Object instance
  this.World.prototype.cukeUp = function() { this.cukes++; };

  this.When(/^I cuke up$/, function(callback) { 
    // `this` is set to the World object
    this.cukeUp();
    callback();
  });

  this.Then(/^I should have (\d+) cukes in my belly$/, function(expectedCukes, callback) { 
    // `this` is set to the World object
    assert.equal(this.cukes, expectedCukes);
    callback();
  });
};
module.exports = defineSteps;

Comments and suggestions are welcome!

@ghost ghost assigned jbpros Sep 5, 2011
@fernandoacorreia
Copy link
Contributor

looks good to me

@jbpros jbpros closed this as completed in e096ece Oct 12, 2011
@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants