-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9a33aa
commit b650a07
Showing
2 changed files
with
106 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,61 @@ | ||
var wrap = function (funk, cb) { | ||
funk.end(function(err){ | ||
if (err == null || err == undefined){ | ||
cb(); | ||
} else { | ||
cb.fail(err); | ||
}; | ||
}); | ||
}; | ||
'use strict'; | ||
|
||
|
||
|
||
function wrap (funk, cb) { | ||
funk.end(function(err){ | ||
if (err === null || err === undefined){ | ||
cb(); | ||
} else { | ||
cb.fail(err); | ||
} | ||
}); | ||
} | ||
|
||
|
||
|
||
module.exports = function (){ | ||
|
||
this.World = require("../support/world").World; | ||
|
||
this.Given(/^I am on the homepage$/, function (callback){ | ||
wrap(this.browser.chain.session().open('/'), callback); | ||
}); | ||
|
||
this.Given(/^I follow "([^"]*)"$/, function (link, callback) { | ||
wrap(this.browser.chain.click("link=" + link), callback); | ||
}) | ||
|
||
this.When(/^I fill in "([^"]*)" with "([^"]*)"$/, function (field, value, callback) { | ||
wrap(this.browser.chain | ||
.fireEvent("//input[@name=\"" + field + "\"]",'focus') | ||
.type("//input[@name=\"" + field + "\"]", value) | ||
.fireEvent("//input[@name=\"" + field + "\"]",'keyup') | ||
.fireEvent("//input[@name=\"" + field + "\"]",'blur') | ||
, callback | ||
); | ||
}); | ||
|
||
this.When(/^I press "([^"]*)"$/, function (name, callback){ | ||
wrap(this.browser.chain | ||
.fireEvent("//button[text()=\"" + name + "\"]",'focus') | ||
.click("//button[text()=\"" + name + "\"]") | ||
, callback); | ||
}); | ||
|
||
this.Then(/^I should see "([^"]*)"$/, function (content, callback){ | ||
wrap(this.browser.chain.assertTextPresent(content), callback); | ||
}); | ||
|
||
// If you need to do something like clean/seed the database, | ||
// put the code here, then callback() when done. | ||
this.Before(function(callback){ | ||
callback(); | ||
}); | ||
|
||
// This will close the selenium browser at the end of the cucumber feature | ||
this.After(function(callback){ | ||
wrap(this.browser.chain.testComplete(), callback); | ||
}); | ||
this.World = require('../support/world').World; | ||
|
||
this.Given(/^I am on the homepage$/, function (callback){ | ||
wrap(this.browser.chain.session().open('/'), callback); | ||
}); | ||
|
||
this.Given(/^I follow "([^"]*)"$/, function (link, callback) { | ||
wrap(this.browser.chain.click('link=' + link), callback); | ||
}); | ||
|
||
this.When(/^I fill in "([^"]*)" with "([^"]*)"$/, function (field, value, callback) { | ||
wrap(this.browser.chain | ||
.fireEvent('//input[@name="' + field + '"]','focus') | ||
.type('//input[@name="' + field + '"]', value) | ||
.fireEvent('//input[@name="' + field + '"]','keyup') | ||
.fireEvent('//input[@name="' + field + '"]','blur'), | ||
callback | ||
); | ||
}); | ||
|
||
this.When(/^I press "([^"]*)"$/, function (name, callback) { | ||
wrap(this.browser.chain | ||
.fireEvent('//button[text()="' + name + '"]','focus') | ||
.click('//button[text()="' + name + '"]'), | ||
callback); | ||
}); | ||
|
||
this.Then(/^I should see "([^"]*)"$/, function (content, callback){ | ||
wrap(this.browser.chain.assertTextPresent(content), callback); | ||
}); | ||
|
||
// If you need to do something like clean/seed the database, | ||
// put the code here, then callback() when done. | ||
this.Before(function(callback){ | ||
callback(); | ||
}); | ||
|
||
// This will close the selenium browser at the end of the cucumber feature | ||
this.After(function(callback){ | ||
wrap(this.browser.chain.testComplete(), 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,58 @@ | ||
process.env["SS_ENV"] = "cucumber"; | ||
'use strict'; | ||
|
||
|
||
|
||
// Set the SocketStream environement | ||
// | ||
process.env.SS_ENV = 'cucumber'; | ||
|
||
|
||
|
||
// Dependencies | ||
// | ||
var selenium = require('../../node_modules/ss-cucumber/node_modules/selenium-launcher'); | ||
var soda = require('../../node_modules/ss-cucumber/node_modules/soda'); | ||
var app = require('../../app'); | ||
|
||
|
||
|
||
// Load the SocketStream app | ||
// | ||
require('../../app'); | ||
|
||
|
||
|
||
var browser = null; | ||
|
||
var World = function(callback){ | ||
|
||
if (browser == null) { | ||
selenium(function(err,selenium){ | ||
browser = soda.createClient({ | ||
host: selenium.host, | ||
port: selenium.port, | ||
url: "http://localhost:3000", | ||
browser: "firefox" | ||
}); | ||
|
||
this.browser = browser; | ||
callback({browser: this.browser}); | ||
process.on('exit', function(){ | ||
selenium.kill(); | ||
}); | ||
}); | ||
|
||
} else { | ||
this.browser = browser; | ||
callback({browser: this.browser}); | ||
} | ||
|
||
|
||
var World = function (callback) { | ||
|
||
if (browser === null) { | ||
|
||
selenium(function(err,selenium){ | ||
browser = soda.createClient({ | ||
host: selenium.host, | ||
port: selenium.port, | ||
url: 'http://localhost:3000', | ||
browser: 'firefox' | ||
}); | ||
|
||
this.browser = browser; | ||
callback({browser: this.browser}); | ||
process.on('exit', function(){ | ||
selenium.kill(); | ||
}); | ||
}); | ||
|
||
} else { | ||
|
||
this.browser = browser; | ||
callback({browser: this.browser}); | ||
|
||
} | ||
|
||
}; | ||
|
||
|
||
|
||
exports.World = World; |