Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing HTTP and HTTPS on Cucumber Ruby

I am trying to fix a bug and the impossibility to reproduce it on my local environment is becoming a problem.

Cucumber might be able to help, but I couldn't find a way to make cucumber work for me. It is specifically about HTTP and HTTPS.

I use 4 different environments. Only production and the one below are HTTPS ones and my bug only happens there exactly because of the protocol/URL generation.

Is there a way to make cucumber work under HTTPS for a specific feature?

I hope it was clear enough, although I think it is still a bit vague.

like image 345
Harry Avatar asked Oct 19 '22 11:10

Harry


1 Answers

You can make capybara use HTTPS inside cucumber tag hooks. For instance:

@https
Scenario: redirect to another location
  Given I am seeing something
  When I do some action
  Then I should be directed to another location

Now the way to make it work is to use cucumber hooks.

# Use HTTPS host for specific scenario
Before('@https') do
  Capybara.app_host = some_https_location
end

# Revert back to HTTP host for future scenarios
After('@https') do
  Capybara.app_host = some_regular_http_location
end
like image 89
Marc Lainez Avatar answered Oct 21 '22 04:10

Marc Lainez