A BDD Javascript Library that allows you create behavior style features that execute step definitions to develop and test your javascript in a BDD Style.
Pickle('feature', 'basic_steps', function() {
Scenario('should_see', function() {
Given('I have an empty page');
And('I have a link called say hello')
When('I follow "Say Hello"');
Then('I should see "Hello World"');
});
Scenario('Hello Form', function() {
Given('I have an empty page');
And('I have a simple form');
When('I fill in "Name" with "Joe"');
And('I press "Submit"');
Then('I should see "Hello Joe!"');
});
});
Pickle('step', /^I should see "([^\"]*)"$/, function (a) {
var rx = new RegExp(RegExp().escape(a));
if($("body").html().match(rx) == null) {
return false;
} else {
return true;
}
});
Pickle('step', /^I press "([^\"]*)"$/, function (a) {
var submit = $('input:submit:[value="?"]'.replace(/\?/, a));
if(submit.length > 0) {
submit[0].click();
return true;
} else {
return false;
}
});
JQuery 1.3.2
git clone git://github.com:twilson63/pickle.git
cd pickle
ruby pickle.rb
firefox http://localhost:4567
# Open Firebug and Run
Pickle('run');
or
// Just run a particular feature
Pickle('NameOfFeature');
// Just run a particular step
Pickle('NameOfFeature','NameOfStep');
# In the console