Created
January 16, 2012 20:46
-
-
Save jjgonecrypto/1622961 to your computer and use it in GitHub Desktop.
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
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); | |
}); | |
}; |
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
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 "[email protected]" as the "Email" | |
And I click "Submit" | |
Then I should see "peter" | |
And I should see "[email protected] |
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
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); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)