Implementing a Simple Search Without Ajax

In Chapter 14, Bootstrapping Rails, we dabbled a little bit in Capybara’s API. We used the visit(path) method to go to a user’s page, and we verified that messages were displayed on the screen using Capybara’s have_content matcher. Let’s add a feature that will allow users to search for messages. This will expose us to more of the goodness Capybara has to offer.

Start with the code we left off with at the end of the previous chapter and add a new search feature to features/search.feature:

capybara/00/features/search.feature
 
Feature:​ Search​​
 
Scenario:​ Find messages by content​​
 
Given ​a User has posted the following messages:
 
| content |
 
| I am making dinner |
 
| I just woke up |

Get The Cucumber Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.