Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 264
Jonathan Avatar asked Jul 22 '11 14:07

Jonathan


People also ask

How do I execute cucumber with a profile?

In a typical project, cucumber --require features features/some/path will suffice. Repetitious usages can be added to user-defined profiles contained in the project’s cucumber.yml file. Use the flag --profile or -p to execute Cucumber with a profile. You can still use other command line arguments alongside --profile or -p , if desired.

What is capybara and how does it work?

First, let’s start with definitions. What is Capybara? On Capybara’s official page it is described as follows: “ Capybara is a library written in the Ruby programming language which makes it easy to simulate how a user interacts with your application.

How do I use environment variables with cucumber-JS?

Cucumber-js does not support configuration of Cucumber with an env file. You can use environment variables in the profile argument list, just as you would normally specify them on the command-line. When running Cucumber, it can sometimes be handy to pass special values to Cucumber for your step definitions to use.

Where can I find cucumber JS in Storra?

If you want to see a bit of cucumber.js, the JavaScript port of Cucumber, you can take a look at the directory storra/features. If you have the Audiobook Collection Manager up and running, you might want to explore the application manually for a minute, to see what functionality it offers (not much, really).


1 Answers

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.

like image 152
Woahdae Avatar answered Sep 21 '22 09:09

Woahdae