how to test the contents of the p tag


I want to test the contents of the p tag here :

The problem with testing to that level is, sometimes the tag may not be rendered yet. Also, such tests tend to be brittle. You dont want to depend on things that change often, I would probably test that the product.title exists, regardless of what tag its wrapped in.


And how do I test this on a functional test for a controller.


I’m not very familiar with the out of the box Rails Testing framework you are using; I use Rspec. In your current case, it looks like you are getting 0 cause there is not .singleproducts class selector in the code

the p tag is nested inside the

so you would probably need to access it using .productinfo.p