I understand that it is possible to decorate methods with before and after hooks in ruby, but is it possible to do it for each line of a given method?
For example, I have an automation test and I want to verify that after each step there no error shown on the page. The error is shown as a red div and is not visible to Ruby as raise
or anything like that, so I have to check for it manually (there are several other use cases as well).
I understand that it might be possible using set_trace_func
. But I think this may bring more problems than benefits since it works over entire call tree (and requires me to filter it myself).
UPDATE (clarification):
I am interested in intercepting all actions (or calls) that are performed within a given method. This means unspecified number of classes is called, so I can't just intercept any given set of classes/methods.