Aha! I've figured it out. Here's the `isolate' method (from lib/caricature/core_ext/object.rb):
def isolate(name=nil, recorder = Caricature::MethodCallRecorder.new, expectations = Caricature::Expectations.new, &block) iso = Caricature::Isolation.for(self, recorder, expectations) return iso unless name if block if block.arity > 0 @expectation = iso.when_receiving(name, &block) else @expectation = iso.when_receiving(name) instance_eval &block end end iso end The important line to note is the following: iso = Caricature::Isolation.for(self, recorder, expectations) This `isolate' method let's you do stuff like `IHomeRepository.isolate'. The TypeError you are experiencing is due to the fact that you are isolating whatever the implicit `self' happens to be at the time you call `isolate'. If you instead use `IHomeRepository.isolate', or `Caricature::Isolation.for IHomeRepository', it should work just fine. Perhaps Caricature could be tweaked a little so that making this mistake is more obvious (I was stumped too ;P). Cheers, -Charles On Wed, Aug 4, 2010 at 9:47 PM, Charles Strahan <charles.c.stra...@gmail.com > wrote: > It looks like the generated isolation isn't implementing IHomeRepository: > > irb(main):032:0> repo = isolate > FakeMvcProject::Controllers::IHomeRepository > => #<Object805c8b559a854b9ca0269e9b1d7f7643:0x0000482> > irb(main):033:0> repo.GetType.get_interfaces > => [System.ComponentModel.ICustomTypeDescriptor, > IronRuby.Runtime.Calls.IRubyDynamicMetaObjectProvider, > System.Dynamic.IDynamicMetaObjectProvider, > IronRuby.Runtime.IRubyObject, > IronRuby.Runtime.IRubyObjectState, > IronRuby.Runtime.IDuplicable, > System.Runtime.Serialization.ISerializable] > > > I also tried this (notice that IHomeRepository *is* listed): > > irb(main):034:0> class Foo > irb(main):035:1> include IHomeRepository > irb(main):036:1> end > => Foo > irb(main):037:0> Foo.new.GetType.get_interfaces > => [IronRuby.Runtime.IRubyObject, > IronRuby.Runtime.IRubyObjectState, > System.Runtime.Serialization.ISerializable, > IronRuby.Runtime.Calls.IRubyDynamicMetaObjectProvider, > System.Dynamic.IDynamicMetaObjectProvider, > System.ComponentModel.ICustomTypeDescriptor, > IronRuby.Compiler.Generation.IRubyType, > FakeMvcProject.Controllers.IHomeRepository] > > > It looks like this might be a problem with Caricature (perhaps only when > running IR 1.1?). > > > -Charles > > > > On Wed, Aug 4, 2010 at 4:40 PM, Ivan Porto Carrero <i...@flanders.co.nz>wrote: > >> >> >> try doing >> >> ITestService.isolate >> >> or >> >> isolation_for ITestService >> --- >> Met vriendelijke groeten - Best regards - Salutations >> Ivan Porto Carrero >> Author of IronRuby in Action (http://manning.com/carrero) >> Microsoft IronRuby/C# MVP >> >> >> >> On Wed, Aug 4, 2010 at 10:56 PM, Nieve G. <li...@ruby-forum.com> wrote: >> >>> Charles, >>> you can take a look at it here: >>> http://github.com/nieve/IsolationTest >>> >>> I just hope it's not something completely obvious... >>> -- >>> Posted via http://www.ruby-forum.com/. >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core@rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >> >> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core@rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> >
_______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core