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 2010-08-04 23:43
on 2010-08-05 04:48
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 2010-08-05 05:13
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.strahan@gmail.com
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.