Released: Oct 15, 2009, Running time: 55 min
In this episode:
We take the search results that were fetched using Twitter in episode 8 and display them on the dashboard.Add to cart$5.00
Search results are not useful unless you can see them. After creating SearchResult instances from the results returned by Twitter, we want to show them on Brandizzle’s dashboard.
The Dashboard will show a paginated list of search results ordered by date, with latest first.
We cover how to spec and implement displaying a list of results in the proper order and with the correct content.
Cucumber has the “multiline step arguments” feature that lets us easily specify the search results we expect to see on the dashboard.
With more recent versions of Cucumber, like you can see on the multiline step arguments page on the Cucumber wiki, if you scroll down to “Diffing tables”, it is a lot easier to do what we did in this episode. Cucumber actually lets you compare two tables, one that you specify in your feature, and one that you grab from the page, and tell you if they are the same or not.
Named scopes on the SearchResult helps us easily specify the order for our results. Filtering will also go into a named scope later.
We spend some time trying to figure out how to best test for the proper timestamp being shown and it takes a while to discover Ruby’s Time.parse take a human readable string and converts it to a Time instance.
Check out episode 10 to see how we add pagination to our search results by doing BDD.