How to inject ruby ​​variables into cucumber.feature tests

I have the next cucumber test

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

Examples:
|url|
|"google.com|

      

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

Problem: I want to replace google.com with a ruby ​​variable like <% URL%>. Is it possible to inject ruby ​​code into cucumber tests and evaluate?

+3


source to share


2 answers


I guess you shouldn't be doing this in function steps. If you want a ruby ​​variable, it means you are doing something wrong. Check out some examples around

Link here



Functions must be clear so that everyone can read, especially non-programmers. so you should start mixing code with functions. The code is behind, in the step definition.

0


source


You can do eval

this line if you trust the code in that properties file. But this might be a bad idea for the reasons outlined by @SnakeSanders.



0


source







All Articles