Rails port of testing environment

port, rspec, ruby-on-rails

Solution

If using Capybara you can set the port in the spec_helper.rb like so:

Capybara.server_port = 1234

See also: https://github.com/jnicklas/capybara/pull/123

Problem

I'd like to test the HTTP API of our Rails app using Faraday and RSpec. Faraday needs the host url + port. Unfortunately the port of the testing environment does always change. How do I access the current port programmatically in the spec?

Original source

Related problems