← Back to Upcase

Strange new failure mode

(Jon Seidel) #1

I’ve been adding PDF printouts to an existing application, testing as I go. With my latest changes, two examples started failing. After some trial and error I found out that the following (newly added) works:

expect(page).to have_css('input[id="ee_requisition_requisition_number"]', value: 'EB-0001')

while the following (original test) fails:

expect(page).to have_content 'EB-0001'

Any thoughts on why this might be? I could change these tests to pass, but I’d really like to understand what’s going on so I can avoid this in the future.

(Derek Prior) #2

From the Capybara documentation, has_content?:

Checks if the page or current node has the given text content,
ignoring any HTML tags and normalizing whitespace.

The value of the input tag is not content. It is an attribute on the input tag.

(Jon Seidel) #3

Thanks @derekprior; very helpful. That reminded me of a change I made which caused this. FYI… I also found that

expect(page.body).to match(/EB-0001/)

works, which is a little easier to read.