Episode 7 - Search, part 2


Click on image above for a preview

Released: Oct 02, 2009, Running time: 43 min

In this episode:

In this episode we add the ability to remove Search terms from a Brand.

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

Add to cart$5.00
  • Share

In the previous episode we added the ability to create search terms for a Brand. We also need a way to remove these search terms, in case we don’t want them around anymore in case they bring in too much noise, or if they are just not as relevant as we thought.

Watch us add the “delete” action to the “searches” resource.

First, we refactor the “Manage Brand” feature first, as we notice a repeating pattern in our scenarios.

Webrat steps generated by Cucumber are a nice start, but in order to press a specific button on the page, it has to be constrained to a certain DOM element. We add a step to make it easy to find just the button we need for delete. To make this work, our views need to be structured more semantically.

One way to debug Webrat steps is to use “save_and_open_page” to show what Webrat sees when a certain step fails.

Controller specs might get a bit repetitive at this point, but that is no excuse to abandon them — they will provide an important harness for when we have to refactor controller code.

If you are using Textmate and Git, then you might find the Git.tmbundle helpful. Towards the end of the episode you can watch how to use it for easier commits directly from TextMate.


  • Vlcsnap-2009-10-02-07h47m11s0
  • Vlcsnap-2009-10-02-07h47m33s105
  • Vlcsnap-2009-10-02-07h47m43s11
  • Vlcsnap-2009-10-02-07h48m00s215
  • Vlcsnap-2009-10-02-07h48m28s0
  • Vlcsnap-2009-10-02-07h48m41s105
  • Vlcsnap-2009-10-02-07h47m07s224


Having an alias for “rake rcov:all && open coverage/index.html” might be useful.

You guys can use “But” instead of “And”.

For example.

Then I should see “Deleted search term.”
But I should not see “jschoolcraft”

Just a thought: if you guys write a spec for DB columns, you could enforce that more with specing index. I often forget add indexes especially when working with an impossible deadline.

it { should have_index :search_id) }

In reply to takaaki

You guys can use “But” instead of “And”.

For example.

Then I should see “Deleted search term.”
But I should not see “jschoolcraft”

I didn’t know “But” was part of Gerkin syntax.


Commenting is disabled.