Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support :count option on has_content #642

Closed
sobrinho opened this Issue · 9 comments

7 participants

Gabriel Sobrinho Tomas D'Stefano johnlane Jonas Nicklas Douglas Costa Jarl Friis Andrei Botalov
Gabriel Sobrinho

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...

Tomas D'Stefano

+1 for this

Gabriel Sobrinho

@jnicklas would you accept a pull request with this functionality?

johnlane

+1 for this too

Jonas Nicklas
Owner

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.

Douglas Costa

That's ok.

Jarl Friis

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.

Andrei Botalov
Collaborator

@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

Jonas Nicklas
Owner

@abotalov they are supported by has_css.

Jonas Nicklas jnicklas closed this
Gabriel Sobrinho

Thanks! :heart:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.