Trouble undersatnding "Around" hook

14 views
Skip to first unread message

NaviHan

unread,
Mar 29, 2019, 1:33:14 AM3/29/19
to Watir General
Im trying to understand how the around hooks work

Im sorry if the question is very basic. I cant find the implementation of "Around" in Cucumber API docs as well (checked 

Cucumber::RbSupport::RbDsl

in

Around do |scenario, block|

  puts
"About to run #{scenario.name}"

 
block.call

  puts
"Finished running #{scenario.name}"

end

I was expecting scenario.call instead of block.call

How does the scenario gets passed to block?

NaviHan

unread,
Apr 3, 2019, 7:39:35 PM4/3/19
to Watir General
Hi Titus/Justin

If you could help me here understanding this...

Also what is the order in which the before, after and around hooks run.

I tried printing the order and as per my experimenatation the order is

1. Around
2. Before &
3. After

Some of the articles I read says this order is fluctuating.. Is this true?

Justin Ko

unread,
Apr 4, 2019, 11:09:53 AM4/4/19
to Watir General
Sorry Navi, I'm not too familiar with the inner workings of Cucumber. I abandoned it long ago for RSpec. While people on this mailing list can likely help with how to use Cucumber, understanding the internal workings is likely better suited in Cucumber's mailing list (or whatever they use).

For what I can see, if you want to understand how the Around works, you can start following the code from https://github.com/cucumber/cucumber-ruby/blob/558a89faf615c2e9be674b17061934243cd19d50/lib/cucumber/glue/dsl.rb#L75-L82.

I haven't heard of people complaining about hook orders fluctuating. It would seem pretty useless if their order wasn't consistent. Do you have specific article that says that?

Justin

NaviHan

unread,
Apr 4, 2019, 6:51:03 PM4/4/19
to Watir General
Thanks Justin
I have posted the query in Cukes mailing list.

Cheers
Navi

On Friday, 29 March 2019 16:33:14 UTC+11, NaviHan wrote:
Reply all
Reply to author
Forward
0 new messages