I need to run an external script inside an RSpec test and to do so I need to know port number of the rails server running for the RSpec test.
Asked
Active
Viewed 494 times
0
-
1You mean, feature specs? Which launch an external browser? – Sergio Tulentsev Jul 18 '18 at 16:34
-
No, it's a custom ruby script. – Mahmoud Sultan Jul 18 '18 at 16:35
-
Yeah, yeah, that's not what I was asking. What kind of specs are you talking about? Most of them do not start a rails server at all. – Sergio Tulentsev Jul 18 '18 at 16:36
-
In a controller spec, which specs start a server? – Mahmoud Sultan Jul 18 '18 at 16:41
-
3Controller specs do not start a server. Feature specs (with capybara) do. – Sergio Tulentsev Jul 18 '18 at 16:42
-
Okay, using capybara how can I get the port number? – Mahmoud Sultan Jul 18 '18 at 16:49
-
Get it from the request environment: https://stackoverflow.com/questions/2813290/how-do-i-get-the-host-and-port-in-a-rails-application and pass as script's argument – Sergio Tulentsev Jul 18 '18 at 16:50