|
|
Symptom: Class inheritable attributes are always the default even if they are changed in
test_helper.
Cause: Because of the nature of class_inheritable_accessor, a class is instantiated before it is
needed. The inheritable attributes which are subsequently passed down the ActiveTest hierarchy
are the default values set when the environment is loaded, before anything is defined in
environment/test.rb or test_helper.rb.
Example:`Test::Unit::TestCase.pre_loaded_fixtures = true` does not propagate to
ActiveTest::Base and its children, including test suites which inherit from Subjects or Base.
Possible Fix #1: Load the ActiveTest framework at the end of test_helper. The problem with this
solution is that it contradicts the idea of a plugin, which is to be loaded with the environment. It
makes ActiveTest too quirky to be used right out of the box because this fix would require extra
setup for people using ActiveTest and an awareness of this particular issue.
Possible Fix #2: Patch ActiveTest::Base to propagate changes to inheritable_attributes manually.
This solution probably causes more problems than it solves. Any later changes to an inheritable
attribute would be overwritten by making Test::Unit::TestCase or ActiveTest::Base master classes,
with their hierarchy only shadow classes.
Possible Fix #3: Disable inheritable_attributes dup'ing in ActiveTest::Base. Like fix #2, a valuable
feature is lost. Also, inheritable attributes will show peculiar behaviour, like cross-children
inheritance and other quirks -- the last thing ActiveTest needs.
Possible Fix #4: Make ActiveTest a gem. This fix follows on from fix #1 and suggests that
ActiveTest is not solely meant for Rails, which is probably a good thing. Instructions for using
ActiveTest in a manner which is different from plugins would, then, not be out of place.
|