Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force url parameter in visit method with to_s #1298

Closed

Conversation

alexpeachey
Copy link

The visit method takes a url as a parameter and in checking for special cases it performs url.to_s. However if no special cases apply, it does not perform to_s.

As someone who would like to send an arbitrary object capable of producing a url from to_s I feel adding consistency to the treatment of the parameter is beneficial.

@twalpole
Copy link
Member

This changes the current driver api - and therefore isn't going to be considered before v3

@alexpeachey
Copy link
Author

I don't see how this changes the driver api. The docs around the visit method specify it is supposed to receive a string and that it expects a string and in all "special" cases it is forced into a string.

The driver visit method also expects a string and in fact, RackTest, makes a very big assumption that it is a string because it uses URI.parse on it which fails when it isn't a string. In the Selenium driver if it isn't handed a URI it uses URI.parse.

If anything, this change makes the visit method more robust as it ensures the driver does actually get a string instead of only sometimes getting a string.

The entire capybara test suite passes with this change.

@twalpole
Copy link
Member

Yes -- the capybara test suite does pass, however there are other drivers that use capybara -- changing the behavior of parameters currently passed to those drivers isn't going to happen until the next major revision - v3

@twalpole twalpole added this to the Capybara 3.0 milestone Apr 24, 2014
@alexpeachey
Copy link
Author

Ok, thank you. I can understand that even though the contract and documentation on the visit method specify it should be a string, it doesn't mean that people who wrote drivers actually adhered to the documented API and may have just adhered to the behavior of the method.

So changing this on the next major version makes sense.

@abotalov
Copy link
Collaborator

abotalov commented Jul 8, 2014

@twalpole I disagree with you.

Previously Capybara could sent to driver's visit method either String or not String. If user sends parameter of String type, then String will be sent to driver.

After this PR (or #1357) String is sent to driver's visit method (and it was supported previously). So it doesn't invoke any changes neither at driver, nor at user side.

@twalpole
Copy link
Member

twalpole commented Jul 8, 2014

@abotalov I'll go through it again - although alex understood it so I think I explained my reasoning fine above. As you said - previously Capybara could send to drivers visit method either a String or not a String (ie a URI could be passed through untouched, even though undocumented in some cases) and I wasn't willing in a minor version to change that just so the user didn't have to call #to_s on an arbitrary object in case an existing driver was actually using that undocumented "feature". The visit method has since been changed to actually fix a bug - which I consider more justifiable than just for ease of use - and so it may now be fine to revisit this issue. As it is the documentation for the visit method specifies that a String must be passed in, so any pull request for this issue will need to have that documentation updated to show that an ojbect that responds to #to_s would be acceptable as well

@twalpole
Copy link
Member

PR #1357 covers the same issue

@twalpole twalpole closed this Jul 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants