Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Automatic string casting for selectors including "with: ..." #1168

Closed
gurix opened this Issue Sep 25, 2013 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

gurix commented Sep 25, 2013

I observed an unexpected behaviour using the test

expect(page).to have_field 'foo_parent_id', with: predecessor.id

that fails. While fiddling around I found out that predecessor.id is in fact of type Moped::BSON::ObjectId

Explicit casing to string solves the problem

expect(page).to have_field 'foo_parent_id', with: predecessor.id.to_s

what in my point of view is not correct rails behaviour, because within such an input field I can just use a string.

Therefore I suggest to use filter(:with) { |node, with| node.value == with.to_s } in https://github.com/jnicklas/capybara/blob/master/lib/capybara/selector.rb?source=cc#L106 or I am totally wrong?

Collaborator

jnicklas commented Sep 25, 2013

Yes, that sounds right to me, we've done similar things for most other places where we take in objects, casting them to strings internally. Care to work up a pull request? (don't forget the tests ;))

@gurix gurix referenced this issue Sep 25, 2013

Merged

fixes #1168 #1169

@jnicklas jnicklas closed this in bdf6192 Oct 20, 2013

jnicklas added a commit that referenced this issue Oct 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment