You can use the tag and filter Before to set the instance variable in World. This is then available to your Transform so that it can perform tag specific conversions. For example, if you want to convert integers when the @hook tag is present:
Transform /(\d+)/ do |num|
if @hook
num.to_i
else
num
end
end
Before('@hook') do
@hook = true
end
A new world is created for each scenario and Before filters are called. So @hook will reset for each scenario.
graza source
share