5

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.

7
  • my bug only happens there exactly - what is your bug? Commented Apr 18, 2016 at 13:54
  • What do you want to use to automate your tests, capybara ? webrat ? Cucumber is "just" the glue between your gherkin scenarios and your test code, it will support the capabilities of the automation library you use behind it. Commented Apr 18, 2016 at 14:10
  • As @Uzbekjon says, the bug is the real thing that'll we would be able to help you nail quickly, and help you setup tests to ensure it doesn't happen again. If you can provide details on what the bug is, we will able able to help. Commented Apr 18, 2016 at 14:12
  • Cucumber does not use http, https, tcp, udp, or any other network protocol. Some other part of your tooling does. Maybe it's Selenium. Once you figure out the right piece, you will find it easier to describe the problem. My suggestion is to always treat it like a defect with happens/should happen, steps to reproduce, errors, stack traces, and code. Commented Apr 19, 2016 at 3:39
  • @Uzbekjon: The user performs an action and, after that, there's a redirect. This redirect is a HTTP or HTTPS, depending on the environment. It works for HTTP environments, but not for HTTPS ones. For some reason it is not generating the URL correctly when HTTPS should be used. Commented Apr 19, 2016 at 6:09

2 Answers 2

2

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I was looking for something of that sort. I will try to put it to test and will give a feedback about it.
It worked for what's intended to work. Thanks. I found this link that might be useful for people using HTTPS and Capybara: cowjumpedoverthecommodore64.blogspot.lu/2013/09/…
1

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?

1 Comment

Thanks for the idea. It will be helpful indeed, but not in this case. Our company policy would not allow that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.