I use the same step in various placed throughout my cucumber testing. I would like to make a minor change based on whether or not the calling feature has a tag assigned (in this case @javascript).
Is it possible to test for the presence and name of a tag within a step to change the behaviour? (I realise I could just create different steps, but that’s not very DRY is it?)
Pseudo code to explain what I’m after
When /^I sign in as "(.*)\/(.*)"$/ do |email,password|
step %{I go to the sign in page}
step %{I fill in "user_email" with "#{email}"}
step %{I fill in "user_password" with "#{password}"}
if tag && tag == "@javascript"
step %{I follow "LOG IN"}
else
step %{I press "LOG IN"}
end
end
I got around this by using hooks to set variables, which may be useful if your tag isn’t associated with a driver: