Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var User = require('../../models/user');
module.exports = function(){
this.World = require('../support/world').World;
this.When(/^I go to create a new user$/, function(next) {
this.visit('/users/new', next);
});
this.When(/^I enter "([^"]*)" as the "([^"]*)"$/, function(value, field, next) {
this.browser.fill(field, value, next);
});
this.When(/^I click "([^"]*)"$/, function(button, callback) {
this.browser.pressButton(button, callback);
});
};
Scenario: Create a new user
Given I am an administrator
When I go to create a new user
And I enter "peter" as the "Username"
And I enter "peter@example.com" as the "Email"
And I click "Submit"
Then I should see "peter"
And I should see "peter@example.com
var zombie = require('zombie')
, HTML5 = require('html5')
, should = require('should')
, server = require('../../app')
, databaseCleaner = require('database-cleaner')
, dbCleaner = new DatabaseCleaner('mongodb');
exports.World = function MyWorld(callback){
this.browser = new zombie.Browser({runScripts:true, debug:false, htmlParser: HTML5});
this.page = function(path){
return "http://localhost:" + server.address().port + path
};
this.visit = function(path, callback){
this.browser.visit( this.page(path), function(err, browser, status){
callback(err, browser, status);
});
};
this.clean = function(callback){
dbCleaner.clean(mongoose.connection.db, callback);
}
callback(this);
};
@jbpros

This comment has been minimized.

Copy link

jbpros commented Jan 16, 2012

You should export World with exports.World = instead of module.exports = as you are requiring it through the World property of the module in your step definitions.

@justinjmoses

This comment has been minimized.

Copy link
Owner Author

justinjmoses commented Jan 16, 2012

i adjusted it as above, but same problem though.

TypeError: undefined is not a function at CALL_NON_FUNCTION (native) at new MyWorld (/Users/jay/github/tilt/features/support/world.js:25:3) at Object.instantiateNewWorld (/Users/jay/.nvm/v0.4.7/lib/node_modules/cucumber/lib/cucumber/support_code/library.js:30:14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.