ruby on rails - Run the "Before"-tagged hook only once -
i writing cucumber , capybara tests rails application. have tagged of scenarios in different feature files tag "dependent".
i have written hooks.rb file located under support directory. wanted have if
block executed once, if have multiple "dependent" tagged scenarios.
before('@dependent') $dunit ||= true if $dunit puts "hey running " $dunit = false end end
in case statement,
puts "hey running "
...gets executed multiple times when run multiple scenarios multiple feature files "dependent" tag.
how can have puts "hey running "
execute once?
you resetting value of $dunit true every time block starts since false || true == true. if rewrite block below should work
before('@dependent') $dunit ||= false return $dunit if $dunit puts "hey runnig " $dunit = true end
Comments
Post a Comment