I think I got it now! The other day I mentioned a problem with assert_responds_to in Ruby as you call into an ObjC controller. Today I had a different experience calling the “respond_to?” method on Object. Or so I thought the experience was different. Here’s what I observed, using autotest sometimes the assertion would pass. In my other example I was wsing the respond_to? message instead but sending this message after actually calling the method on the controller. Here’s what I mean.
def test_my_model_can_request_my_data myModel = MapModel.alloc.init assert mapModel.respond_to?("requestMyData"), "MyModel should define a requestMyData method" assert_not_nil myModel.requestMyData end
def test_my_model_can_request_my_data myModel = MapModel.alloc.init assert_not_nil myModel.requestMyData assert mapModel.respond_to?("requestMyData"), "MyModel should define a requestMyData method" end
It’s as if you have to send the message first before Ruby knows if the message is defined. That was sort of the thing I saw the other day. Adding the comment then removing the comment on an assert over a defined method gave different results. I’m going to try some introspection next, I’m just a little excited on figuring things out.