It would be an easier option to create a separate scenario with the mandatory step. Would be a cleaner implementation.
Anyways, there is a way to get this to work in the same scenario outline.
- Split the examples table into two. Give the first table a
@Mandatory
tag which has the one example ("scope_self").
Scenario Outline:
Given ............
When .............
Then .............
@Mandatory
Examples:
| action |
| "scope_self" |
Examples:
| action |
| "scope_new" |
Setup a variable flag and set it to false.
Create a tagged Before hook for the @Mandatory tag. In this set the flag variable to true.
In the step definition code for the mandatory option check if the flag variable is set to true or false. If true run the remaining code else skip to return.
I am basing this from Java but this should work for you in rspec...