I would to be able to do that:
page.should have_content '01/01/2011', :count => 3
My assertion should guarantee I have 3 rows in a table on my index page having the same date.
What you think about :count option on has_content?
Have another way to do that?
Currently I'm using:
page.all('td', :text => '01/01/2011').count == 3
But seems fragile...
+1 for this
@jnicklas would you accept a pull request with this functionality?
+1 for this too
If we do this, we need to support all the other options, like maximum, minimum, etc... as well. Also it might be confusing that there are some options we really can't implement on has_content, like visible, that those are supported for some matchers, but not others. The fact that has_content currently does not take any options, works around that a little.
For the count option you would probably also expect
page.should have_content '01/01/2011', :count => 0
to be equivalent to
page.all('td', :text => '01/01/2011').count == 0
However that is not the case for have_xpath or have_css, IMHO that is a bug. I have created a pull request (#833) to make them behave like that. Please comment on that.
@jnicklas Why maximum and minimum must be supported? They aren't supported by has_css so I don't know why they should be supported by has_content.
I don't think it will be bad if the only possible option for has_content will be count
@abotalov they are supported by has_css.