From: Pradeep Gatram Date: 2007-11-26T21:54:14+09:00 Subject: Re: how to ensure signature compliance while mocking in ruby Hi James, Sorry for vanishing for a couple of weeks. I have been using ur suggested approach of 'responds_like'. Although its a good start, it still does not give me complete confidence. All it tells me is whether the method is present or not. It does not guarantee signature compliance. For e.g., referring back to my example... class Bar def method2 param1 end end The above implementation of method2 in Bar will cause FooTest to pass even with responds_like. But the 2 parameter signature is clearly not supported. I agree, an integration test should and will catch this scenario and will fail. But its not possible to write integration tests for every scenario. After all, the expected method call could happen under a convoluted condition. A classic case where, I believe, the unit tests should be able to give me complete guarantee of the state of code. So there does appear to be a need for stricter checking. Leaving the default behaviour as is, maybe introduce a new method like mocked_object.strictly_expects(:blah)... That leads me to another aspect? How about validating the return types :D. Java/C# again gave me that additional safety net of knowing that the return types were correct while I was mocking (at least thats what I remember). Pradeep -- Posted via http://www.ruby-forum.com/.