mutant
mutant copied to clipboard
mutating methods delegated by forwardable?
IRC Discussion: http://irclog.whitequark.org/mutant/2013-09-29
We talked about classes that look like:
require 'forwardable'
class Foo
delegate :bar => :baz
#or
def_delegator :target, :method, :alias
# snip
end
In particular, mutant presently simple says it can't find the corresponding method body and skips testing the delegated method. It might be good to mangle the incoming/outgoing parts of that delegation to ensure there's test coverage on:
- the API existing on Foo (eg that I can call
Foo#bar
) - the Delegation actually being valid (eg, that delegating #bar => #baz is reasonable)
- that any aliasing is also covered -- ie, that aliasing to some other method won't cause a mutant to survive.
Those points should probably be debated on whether or not it's good to encourage those sorts of tests, I mentioned in IRC a recent Sandi Metz talk on how to write maintainable, flexible tests (from RailsConf 2013), it might be worth looking at when deciding how to proceed.
@jfredett Thx for that detailed summary of our discussion. I'll think/research about this ideas.