Harry
Harry

Reputation: 115

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.

Upvotes: 5

Views: 505

Answers (2)

ydaniju
ydaniju

Reputation: 400

You can try using ngrok. It makes your local server go live on the internet providing both http and https options. I hope this helps?

Upvotes: 1

Marc Lainez
Marc Lainez

Reputation: 3080

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

Upvotes: 2

Related Questions