keeganwitt / gmock

Automatically exported from code.google.com/p/gmock
6 stars 2 forks source link

Adding a method to GroovyObject should not affect mocking that method #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following test should pass:

    void testAddingAMethodToGroovyObjectShouldNotAffectMockingThatMethod() {
        GroovyObject.metaClass.load = { String key -> "" }

        JavaLoader loader = mock(OnceLoader)
        loader.load("key").returns("value")
        JavaCache cache = new JavaCache(loader)
        play {
            assertEquals "value", cache.load("key")
        }
    }

OnceLoader:

package org.gmock.utils;

public class OnceLoader extends JavaLoader {

    public OnceLoader(String name) {
        super(name);
    }

}

It is a bug of GroovyObjectMethodFilter, we should use reflection to search
for a method instead of meta class.

Original issue reported on code.google.com by JohnnyJianHY on 18 Jan 2009 at 4:38

GoogleCodeExporter commented 9 years ago
You are right about the scenario. It seems quite a rare scenario and I think we 
could
push it to the next release. What do you think?

Original comment by julien.g...@gmail.com on 19 Jan 2009 at 8:29

GoogleCodeExporter commented 9 years ago
Actually I have fix the bug, so we needn't to push to the next release.

Original comment by JohnnyJianHY on 19 Jan 2009 at 8:59

GoogleCodeExporter commented 9 years ago

Original comment by JohnnyJianHY on 19 Jan 2009 at 9:04