3

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 ?

amjad
  • 2,876
  • 7
  • 26
  • 43

2 Answers2

1

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.

Community
  • 1
  • 1
Snake Sanders
  • 2,641
  • 2
  • 31
  • 42
0

You can eval this string it if you trust code in this feature file. But it may be a bad idea for the reasons outlined by @SnakeSanders.

Andrei Botalov
  • 20,686
  • 11
  • 89
  • 123