mutant
mutant copied to clipboard
module_function handling in mutant is on instance
Wanted to make note that if module_function is specified in a module, that the specifications in corresponding spec files must use '#bar' and not '.bar':
describe '#bar' do
...
end
as the methods have to kill the mutations on the instance where they are defined rather than on the singleton where the module_function places the aliases.
@tjchambers thanks this is a helpful note since the way module_function
copies methods isn't obvious. Would you be able to share more information about how this test looks? Testing the instance method should be tricky since mixing it into a class or module results in it being a private method.
If @mbj agrees I think documenting the quirkiness of testing a module_function
method might makes sense.
Similar issue for reference: https://github.com/mbj/mutant/issues/121
@backus - on the advice of @mbj I eliminated all module_function
references and was more specific.
So I don't have any specs that require me to handle this issue. If I recall however (it's been a while) after I convert to specifying the instance method it just worked. I think it has to do with the spec matching in mutant when examining the methods under test. I may be incorrect about that. I don't recall it being a private method of the instance, but rather the class? I do not recall anywhere I used it as a mixin, but as a shortcut to adding self. prefix.
Ah alright that made sense. How did you eliminate your module_function
usage specifically? Did you switch to something like extend self
or did you just not need module_function
in the first place?
My recall is I dropped the module_function
and prefixed the method defs with self.
I just encountered this issue. Specifiying the instance method doesn't work. I suppose you have to actually call the method as an instance method.