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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.