"can't convert Subclass_..." when isolating an interface

Hello all,
I’ve been trying to use caricature to stub my services in my controllers
tests, now when I try to test this code:
public TestController(ITestService service)
{
_service = service;
}

when my interface is:
public interface ITestService
{
string GetContent();
}

like so:
s = isolate ITestService
s.when_receiving(:get_content).return(‘some content’)
c = TestController.new s

I get the above mentioned error (see attachment)

Any ideas what I’m doing wrong?

Hi Nieve,

I don’t see anything that looks wrong. Which version of IronRuby are
you
using?

Let me know and I’ll see if I can reproduce the problem. If I can, I’ll
take a stab at debugging it.

Regards,

-Charles

Hi Charles,
First of all, thanks for the reply.

I’m currently on IronRuby 1.1

Now, I just doubled checked this, and this happens whether I call
isolate the interface or the implementation. Also, I presume that’s
something with my code since Ben H.'s Kona example (that uses the same
code) works on my machine…

I can create a quick project and put it on github so it’ll be easier to
reproduce.

cheers,
~n

Charles S. wrote:

Hi Nieve,

I don’t see anything that looks wrong. Which version of IronRuby are
you
using?

Let me know and I’ll see if I can reproduce the problem. If I can, I’ll
take a stab at debugging it.

Regards,

-Charles

Hi Nieve,

Sure thing. Let me know when you put the sample project up on github
and
I’ll take a look at it.

-Charles

Charles,
you can take a look at it here:
http://github.com/nieve/IsolationTest

I just hope it’s not something completely obvious…

Nieve,

Oh… my… goodness… I’ve never seen ANYONE make that mistake before!

Just kidding :stuck_out_tongue_winking_eye:
I’ll take a look at it a little later, unless someone else beats me to
it.
:wink:

Cheers,
-Charles

I just looked at your sample project

It’s best to require spec before caricature because caricature hooks
into
spec
The IHomeRepository interface is empty. Try adding a method to that and
see
if it still occurs.

you can also add require ‘caricature/aspnet_mvc’

I don’t have a windows machine running atm but I’ll check tomorrow if
this
didn’t help you

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Author of IronRuby in Action (http://manning.com/carrero)
Microsoft IronRuby/C# MVP

try doing

ITestService.isolate

or

isolation_for ITestService

Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Author of IronRuby in Action (http://manning.com/carrero)
Microsoft IronRuby/C# MVP

@Ivan- Many many thanks!! that worked :slight_smile:

I did also try to put require spec before caricature, but that didn’t
help. I left it though like that, since it makes sense.

The one thing I still don’t get is how come in Ben’s Kona example the
isolate Service works and on the same machine, my code doesn’t… am
wondering what could possibly differ, would be interesting to know.

~n

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs