R
Raymond O'Connor
I'd like to chain setup in a unit test, so that it calls a method in a
module BEFORE running through the setup code. I'd like to do it without
having to put super() in the test's setup method.
module MyModule
module InstanceMethods
def setup
puts 'module setup'
end
end
def self.included(base)
base.send :include, InstanceMethods
end
end
class MyUnitTest < Test::Unit::TestCase
include MyModule
def setup
puts 'class setup'
end
end
If this were working when I run a test in MyUnitTest it should print out
module setup
class setup
Unfortunately I can't get it to work. Even with alias_method, I run
into problems it seems because the class setup is defined after the
module is included. Anyone one have any ideas?
Thanks!
module BEFORE running through the setup code. I'd like to do it without
having to put super() in the test's setup method.
module MyModule
module InstanceMethods
def setup
puts 'module setup'
end
end
def self.included(base)
base.send :include, InstanceMethods
end
end
class MyUnitTest < Test::Unit::TestCase
include MyModule
def setup
puts 'class setup'
end
end
If this were working when I run a test in MyUnitTest it should print out
module setup
class setup
Unfortunately I can't get it to work. Even with alias_method, I run
into problems it seems because the class setup is defined after the
module is included. Anyone one have any ideas?
Thanks!