Whenever I attempt to run tests against capybara-webkit, it is not able to find the listening port, so it attempts to use 0, which results in the following error:
Failure/Error: visit user_path
Errno::EADDRNOTAVAIL:
The requested address is not valid in its context. - connect(2)
After a significant amount of time spent debugging the functionality of capybara-webkit, I found that the problem is the following line of code (capybara-webkit-1.1.1/lib/capybara/webkit/connection.rb::open_pipe):
_, @pipe_stdout, @pipe_stderr, wait_thr = Open3.popen3(SERVER_PATH)
When that invokes the WebKit server, the WebKit server launches and should output something similar to the following to STDOUT:
Capybara-webkit server started, listening on port: 53467
When I launch the process manually in a console, that is certainly what I see. However, whenever I try to read @pipe_stdout
or @pipe_stderr
all I get is nil
. Even if I wait until the pipe is ready (as seen in the capybara-webkit connection class) for reading using:
IO.select([@pipe_stdout], nil, nil, WEBKIT_SERVER_START_TIMEOUT)
I still see the same problem. I'm pretty much a novice when it comes to Ruby IO classes, etc. I've tried everything that I can think of to test/debug this and get Open3.popen3
to correctly return the same message to STDOUT that I can see in the console to no avail.
Any thoughts or ideas on something else to try? Is there something obvious that I'm missing? I know that most of the Capybara maintainers work on Mac and this all seems to work for them, so maybe this is an issue with how popen3
is working with Windows?