-
-
Save Marak/564998 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 givens = {}; | |
var Given = function (pattern, topicGenerator) { | |
givens[pattern] = topicGenerator; | |
}; | |
var whens = {}; | |
var When = function (pattern, topicGenerator) { | |
whens[pattern] = topicGenerator; | |
}; | |
var thens = {}; | |
var Then = function (pattern, callback) { | |
thens[pattern] = callback; | |
}); | |
Given(/^I have a hello world httpServer$/, function () { | |
return require("http").createServer().listen(8080); | |
}); | |
When(/^I make a request$/, function () { | |
var client = require("http").createClient(8080, "localhost"); | |
var req = client.request("GET", "/"); | |
req.end(); | |
req.on("response", function (res) { | |
res.on("data", function (data) { | |
this.callback(data); | |
}); | |
}); | |
}); | |
Then(/^I should see "(.+)"$/, function (str) { | |
return function (data) { // The callback | |
assert.equal(data, str); | |
}; | |
}); | |
fs.readFile("./httpServer.feature", function (err, data) { | |
data.split("\n"); | |
// Parse out Givens, Whens, Thens | |
// Match via givens, whens, and thens maps defined in step defs | |
// Use mapped values in a vows structure. | |
}); |
This file contains hidden or 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
Given I have a hello world httpServer | |
When I make a request | |
Then I should see "Hello World" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment