Encapsulate our test suite helper functions inside a module
Background:
Given how Ruby works, all def
:s at the “lowest” level (i.e. outside
any class or method) actually get added into the Object
class (which
all other classes inherit), so we actually add goodies like
wait_until_tor_is_working
to Object
, so "some string".wait_until_tor_is_working
is a perfectly fine way to call it in
our test suite. :) I suppose the right way would be to encapsulate such
functions in a module like this:
module Helpers
def self.wait_until_tor_is_working
[...]
end
end
and then call them as Helpers.wait_until_tor_is_working
. The same
problem exists for the helper functions we define in the various step
definition files (like configured_pidgin_accounts
in pidgin.rb
), so
perhaps all helpers should also be added into the Helpers
module at
the top of each step definitions file (keeping them in the affected file
is imho good for readability); multiple module
statements for the same
module name will just keep on building up the same one.
Hence, if we care about not polluting Object
and risk more collisions
of the kind we experienced in #8966 (closed) (see especially #8966-note_26),
we should do this, or something similar (e.g. put them in a class).
Parent Task: #10237
Original created by @anonym on 9030 (Redmine)