In the following situation, where include_class
is a preference, can I somehow dynamically change the value of include_class
and reload Image
such that it instead includes the new value of include_class
?
module Foo
included do
@test_var = :foo
end
end
module Bar
included do
@test_var = :bar
end
end
Config.include_class = Foo
class Image
include Config.include_class
end
# ... run tests with default configuration for Image, where Image.test_var = :foo
Config.include_class = OtherClass
# ... how can I reload or re-evaluate Image such that Image.test_var = :bar?
Context
I am trying to test whether a configuration option (that is normally set by an initializer) has the correct effects on the application. Because this is part of a test suite the the modules and classes might be loaded before and all configuration changes need to be reset after the test.