[MacRuby-devel] macruby rspec mock odd behavior

Gabriel Ayuso gabriel at gabrielayuso.com
Wed May 4 13:16:06 PDT 2011


Hi,

I'm having some strange issue with rspec mocks and hope someone can point out what I'm doing wrong.

I have a Objective C class with the method: buildRequestWithUrl:method:header:body:
I wrote an rspec mock for this class. I'm setting up an expectation as follows:

	@requestBuilder.should_receive(:buildRequestWithUrl)
 		       .with("http://example.com", method:"POST", header:nil, body:anything() )
                       .and_return(nil)

When the class being tested calls the aforementioned method I get the following error:

RuntimeError:
       NSInvalidArgumentException: -[Mock buildRequestWithUrl:method:header:body:]: unrecognized selector sent to instance 0x200373ea0

I set the expectations for another method of the same class called :queryStringForDictionary
In this case the expectation and call do work.  

	@requestBuilder.should_receive(:queryStringForDictionary).and_return( body )

In another project I'm calling the same class from ruby code and there the mocks and expectations do work properly. In this Objective C project they don't. 

Thanks in advance,
Gabriel Ayuso
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110504/e4800f59/attachment-0001.html>


More information about the MacRuby-devel mailing list