Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed ruby variables in cucumber.feature tests

Tags:

ruby

cucumber

I have following cucumber test

Scenario Outline: 
  Given site <url> is available
  Then I see all all content

Examples:
|url|
|"google.com|

In the test case is dynamic and is generated in ruby code.

Problem: I want to replace google.com with a ruby variable e.g., <%URL%>. Is that possible to embed ruby code in cucumber tests and evaluate ?

like image 773
amjad Avatar asked Nov 29 '25 02:11

amjad


1 Answers

I think you should not do that on the feature steps. If you need a ruby variable here it means that you are doing something wrong. Check some examples around

Link here

The features should be clear text so anyone can read, specially non-programmers. so that is why you should now start mixing code with features. The code goes behind, in your step definition.

like image 188
Snake Sanders Avatar answered Nov 30 '25 18:11

Snake Sanders