Episode 9 - The Dashboard - part 1

Vlcsnap-2009-10-15-12h29m49s180

Click on image above for a preview

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.

Tags: cucumber, rspec, controller, model, haml, twitter

Add to cart$5.00
  • Share

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.

Screenshots

  • Vlcsnap-2009-10-15-17h08m25s0
  • Vlcsnap-2009-10-15-17h08m54s0
  • Vlcsnap-2009-10-15-17h09m09s94
  • Vlcsnap-2009-10-15-17h09m28s23
  • Vlcsnap-2009-10-15-17h09m40s0

4 comments

Hi!

You started to check for the sorting order in the search-step “Then I should see the following search results”, but I think, the particular order isn’t spec’d (is it?). Do you have any better ideas for this than doing a regex like

response.should contain(/text1.text2.text3/)

which is a little ugly?
— Frank

In reply to Frank

Hi!

You started to check for the sorting order in the search-step “Then I should see the following search results”, but I think, the particular order isn’t spec’d (is it?). Do you have any better ideas for this than doing a regex like

response.should contain(/text1.text2.text3/)

which is a little ugly?
— Frank

Hi Frank,

You are right, the sorting order is not enforced in the step. The step just checks that the content is there.

To check the sorting order, you could use table diffs (scroll down to “Diffing tables”) recently added to Cucumber.

In reply to Istvan Hoka

Hi Frank,

You are right, the sorting order is not enforced in the step. The step just checks that the content is there.

To check the sorting order, you could use table diffs (scroll down to “Diffing tables”) recently added to Cucumber.

ahh, good hint – that looks promising, thank you!

Great stuff, can’t wait for the next episodes. I love the tempo, gives me time to think about the why and how. Not such a rush like in other screencasts.

Commenting is disabled.