Skip to content

Instantly share code, notes, and snippets.

@gmoeck
Created April 15, 2011 18:25
Show Gist options
  • Save gmoeck/922194 to your computer and use it in GitHub Desktop.
Save gmoeck/922194 to your computer and use it in GitHub Desktop.
FakeServer.addResourceType('Item', { type: 'Boat' });
FakeServer.addResource('Item', {title: 'Super Boat' });
FakeServer.registerUrl('/search_for_item', function(resourceStore){
var items = resourceStore.allOfType('Item');
var response = {
items: items
}
return response;
});
// gives '{"items": [ {"type": "Boat", "title": "Super Boat"} ] }'
// designed to be used with the bellow executable user story
Scenario('Searching For An Item', function() {
Given('an auction item that is available for sale', function() {
var itemTitle = 'item';
beforeEach(function() {
Application.server.addResource('Item', {title: itemTitle});
});
When('I am on the homepage of the application', function() {
beforeEach(function() {
Application.statechart.gotoState('started');
});
And('I search for that auction item', function() {
beforeEach(function() {
WebPage.fillIn('#mainSearchWidget .search-field-view input[type="text"]', itemTitle);
WebPage.clickOn('#mainSearchWidget .submit-search');
});
Then('I should see the auction item within the search results', function(page) {
WebPage.within('.search-results', function(page) {
expect(page).toHaveContent(itemTitle);
});
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment