Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
482 views
in Technique[技术] by (71.8m points)

ruby on rails - Cucumber / Capybara -- how to get the host and port of the current execution

I need to download a csv file from my app using Open::URI and to do that I need to give it a fully qualified URI. So whats the best way to get the HOST and more importantly PORT in my cucumber script?

Note I am using Capybara and Selenium

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For capybara < 2.0:

Capybara.current_session.driver.rack_server.host
Capybara.current_session.driver.rack_server.port

Capybara 2.0:

Capybara.current_session.server.host
Capybara.current_session.server.port

FYI, my use case is having clickable links in the mail generated by the integration tests.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...