<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ivan Porto Carrero &#187; caricature</title>
	<atom:link href="http://flanders.co.nz/category/ironruby/caricature/feed/" rel="self" type="application/rss+xml" />
	<link>http://flanders.co.nz</link>
	<description>thoughts.each { &#38;:propagandise }</description>
	<lastBuildDate>Fri, 12 Mar 2010 12:24:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A rant on a talk falling to pieces</title>
		<link>http://flanders.co.nz/2009/07/02/a-rant-on-a-talk-falling-to-pieces/</link>
		<comments>http://flanders.co.nz/2009/07/02/a-rant-on-a-talk-falling-to-pieces/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 13:45:21 +0000</pubDate>
		<dc:creator>Ivan Porto Carrero</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[IronRuby]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[caricature]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[IronRuby MVC]]></category>
		<category><![CDATA[Presentation]]></category>

		<guid isPermaLink="false">http://flanders.co.nz/2009/07/02/a-rant-on-a-talk-falling-to-pieces/</guid>
		<description><![CDATA[Earlier this week I had the pleasure of doing a talk for the Belgian .NET user group.&#160; During this talk I ran in to all kinds of problems. I&#8217;ve done presentations where I was royally underprepared and to avoid that this time I actually started prepping for this talk on time. I was done on [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this week I had the pleasure of doing a talk for the Belgian .NET user group.&#160; During this talk I ran in to all kinds of problems. I&#8217;ve done presentations where I was royally underprepared and to avoid that this time I actually started prepping for this talk on time. I was done on time, was prepared had 5 backups of my presentation and samples. What did I learn from this, if you&#8217;re prepared other things will go wrong.    <br />I&#8217;ll share the story of stuff that can go wrong. </p>
<p>Before starting the rant I have some links to share.</p>
<ul>
<li><a href="http://www.slideshare.net/casualjim/ruby-loves-dot-net" target="_blank">Slides</a> </li>
<li>IronRubyMvc sample – <a href="http://irtodo.koolkraft.net/" target="_blank">live demo</a> – <a href="http://github.com/casualjim/ironrubymvc-sample/tree/master" target="_blank">source</a> </li>
<li>Silverlight sample – <a href="http://samples.koolkraft.net/picture_view/" target="_blank">live demo</a> – <a href="http://samples.koolkraft.net/picture_view.zip" target="_blank">source</a> </li>
<li>IronRubyMVC specs – <a href="http://github.com/casualjim/ironrubymvc/tree" target="_blank">source</a> </li>
<li>Sinatra – <a href="http://samples.koolkraft.net/sinatra.zip" target="_blank">source</a></li>
<li>Metaprogramming &#8211; <a href="http://samples.koolkraft.net/metaprogramming.zip" target="_blank">source</a>&#160;</li>
</ul>
<p>I have a device that I call internet on a stick, which is a vodafone usb 3G modem that I plug in to my system and it gets me on the internet (mistake 1). Since I assumed that that thing would continue to work I made most of my demos internet enabled (mistake 2). For example I have a demo where I go download pics from flickr and then show them with some animations with silverlight.    <br />Before my presentation I changed the fonts, opened all the files I was going to talk about ran all the demos again to make sure they would work and everything went fine.     <br />I unplug the USB device and go into the room to hook up the projector etc. The presentation starts and for the first hour everything went really well (from my perspective at least don&#8217;t know about the people attending).     <br />We have a break and I plug the USB device in, at this point the vodafone program hangs (first time ever I swear). What&#8217;s more I can&#8217;t make it go away at all so I reboot my pc (this is still during the break). </p>
<p>Now I&#8217;m getting a little desperate because it still doesn&#8217;t work. With rebooting I also lost all my carefully opened files earlier (I&#8217;m showing code in about 3 different environments and 2 different OS&#8217;es).    <br />So during the presentation I apologise and try to reboot once more while taking questions from the audience and hoping somebody will try to start a discussion with me. After rebooting I got a message saying my date was set to 2001 which I thought was peculiar but clicked it away.&#160; I boot vmware fusion with windows 7 (this took fairly&#160; long and is a little bit funky as the screen resolution changes a lot during this process).     <br />Ok so far so good, by now I&#8217;ve already skipped the silverlight demo promising that it will be available as a download on my blog and will be moving on to the ironrubymvc sample. To prove I do actually use visual studio at times I wanted to open my demo project in visual studio. I open visual studio only for it to tell me that my trial has expired and I can either upgrade or close the application. Oooooookay this is completely weird because i get my software through my msdn subscription and I had been using it earlier that day. </p>
<p>Moral of the story: Either go vastly underprepared and wing it. Or don&#8217;t rely on the internet and always take at least 2 laptops that have identical configurations but I&#8217;m pretty sure those would or explode in my face or something will fall from the ceiling, building collapses or other mishaps. </p>
<p>Instead of having one demo go bad on me now I&#8217;m probably facing a reinstall of my mac because it lost a bunch of settings, for which I&#8217;m holding the vodafone responsible. At this moment I&#8217;m fairly certain that I should go less prepared and just wing it just out of fear for bigger disasters, people may die. </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c3bf1872-2d44-4a67-91a3-8b41f485f175" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/IronRuby" rel="tag">IronRuby</a>,<a href="http://technorati.com/tags/IronRuby+MVC" rel="tag">IronRuby MVC</a>,<a href="http://technorati.com/tags/caricature" rel="tag">caricature</a>,<a href="http://technorati.com/tags/Presentation" rel="tag">Presentation</a></div>
]]></content:encoded>
			<wfw:commentRss>http://flanders.co.nz/2009/07/02/a-rant-on-a-talk-falling-to-pieces/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting started with Caricature and IronRuby</title>
		<link>http://flanders.co.nz/2009/05/21/getting-started-with-caricature-and-ironruby/</link>
		<comments>http://flanders.co.nz/2009/05/21/getting-started-with-caricature-and-ironruby/#comments</comments>
		<pubDate>Thu, 21 May 2009 13:52:17 +0000</pubDate>
		<dc:creator>Ivan Porto Carrero</dc:creator>
				<category><![CDATA[IronRuby]]></category>
		<category><![CDATA[Mocking]]></category>
		<category><![CDATA[caricature]]></category>

		<guid isPermaLink="false">http://flanders.co.nz/2009/05/21/getting-started-with-caricature-and-ironruby/</guid>
		<description><![CDATA[IronRuby 0.5 was released yesterday. You can download it on codeplex. This post will explain how you setup your ironruby environment to use it for testing existing CLR based assemblies.&#160; We’ll touch installing gems using rake and most importantly writing a test for a CLR based class where we’ll mock out the dependencies.
 
The first [...]]]></description>
			<content:encoded><![CDATA[<p>IronRuby 0.5 was released yesterday. You can download it on <a href="http://ironruby.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=25902#DownloadId=68919" target="_blank">codeplex</a>. This post will explain how you setup your ironruby environment to use it for testing existing CLR based assemblies.&#160; We’ll touch installing gems using rake and most importantly writing a test for a CLR based class where we’ll mock out the dependencies.</p>
<p> <span id="more-351"></span>
<p>The first thing you need to do is download <a href="http://ironruby.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=25902#DownloadId=68919" target="_blank">IronRuby</a>. After downloading you can extract it to a location on your hard drive. I extracted mine to C:\ironruby</p>
<p>Now we need to add the path to ir.exe to our PATH variable so we can use it from the command-line. And that is all there is to it to install ironruby on your machine. Now we need to get the necessary gems onto our system. We’ll need bacon and caricature.</p>
<p>Open a console and type the following:</p>
<p>igem list will show you a list of the gems you have installed on your system.</p>
<p>igem install will fetch and install a gem on your system. To install the gems we’re going to need we need to execute the command</p>
<p>igem install bacon caricature</p>
<p>That will result in the following output:</p>
<pre>

+ C:\tools
» cmd
Microsoft Windows [Version 6.1.7100]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\tools&gt;where ir
C:\ironruby\bin\ir.exe

C:\tools&gt;exit
+ C:\tools
» igem list

*** LOCAL GEMS ***

+ C:\tools
» igem install bacon caricature
Successfully installed bacon-1.1.0
Successfully installed caricature-0.6.0
3 gems installed
Installing ri documentation for bacon-1.1.0...
Installing ri documentation for caricature-0.6.0...
Installing RDoc documentation for bacon-1.1.0...
Installing RDoc documentation for caricature-0.6.0...
</pre>
<p>If you would try to execute ibacon at this point that would work. We’ll need to create 2 small files to get ibacon to work.&#160; In the bin directory of ironruby I created 2 files one called ibacon and the other one is ibacon.bat </p>
<p>ibacon</p>
<pre class="ruby" name="code">

#!C:/ironruby/bin/ir.exe
#
# This file was generated by RubyGems.
#
# The application 'bacon' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = &quot;&gt;= 0&quot;

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1
  ARGV.shift
end

gem 'bacon', version
load 'bacon'
</pre>
<p>ibacon.bat</p>
<pre name="code">

@ECHO OFF

@&quot;ir.exe&quot; &quot;%~dpn0&quot; %*
</pre>
<p>At this point you’re ready to start writing specs with bacon and caricature. Let’s look at an example I wrote for the controller factory for ironruby mvc.</p>
<p>We’re going to test the following C# code.</p>
<pre class="csharp" name="code">

public interface IWeapon{
    int Attack(IWarrior warrior);
    int Damage();
}

public interface IWarrior
{
    int Id { get; }
    string Name { get; set; }
    bool IsKilledBy(IWeapon weapon);
    int Attack(IWarrior target, IWeapon weapon);
    int SurviveAttackWith(IWeapon weapon);
}

public class Sword : IWeapon
{

    public int Attack(IWarrior warrior){
        return warrior.SurviveAttackWith(this);
    }

    public int Damage(){
        return 4;
    }
}
</pre>
<p>I generally create a bacon_helper.rb file where I group my requires and helper functions etc. In the case of this test I have the following in the bacon_helper.rb:</p>
<pre class="ruby" name="code">

# add some search paths to ironruby
# this first one adds the path with the assemblies
# this enables us not to have to specify a path to the assemblies everywhere.
$: &lt;&lt; File.dirname(__FILE__) + &quot;/bin&quot;
# adds the path to the caricature library.
$: &lt;&lt; File.dirname(__FILE__) + &quot;/../lib&quot;

# load the caricature library
require &quot;caricature&quot;
require 'caricature/clr'

# load the bacon library
require 'bacon'

# Add the .NET framework
require 'mscorlib'

# load the assembly with the C# code
load_assembly 'ClrModels'
</pre>
<p>At this point we’re ready to start writing the test. create a file called sword_spec.rb and we’ll add the following content to the file.</p>
<pre class="ruby" name="code">

require File.dirname(__FILE__) + &quot;/bacon_helper.rb&quot;

describe &quot;ClrModels::Sword&quot; do

  before do
    @warrior = Caricature::Isolation.for ClrModels::IWarrior
  end

  it &quot;should call survive_attack on the mock&quot; do
    @warrior.when_receiving(:survive_attack_with).return(5)

    sword = ClrModels::Sword.new
    sword.attack(@warrior).should.equal 5

    @warrior.did_receive?(:survive_attack_with).should.be.successful
  end

  it &quot;should return different results when expectation is defined with arguments&quot; do
    sword1 = ClrModels::Sword.new
    sword2 = ClrModels::Sword.new

    @warrior.when_receiving(:survive_attack_with).return(5)
    @warrior.when_receiving(:survive_attack_with).with(sword2).return(15)

    sword1.attack(@warrior).should.equal 5
    sword2.attack(@warrior).should.equal 15

    @warrior.did_receive?(:survive_attack_with).with(sword2).should.be.successful
  end

end
</pre>
<p>So now we’ve got 2 tests for our Sword class. The only thing that is left to do is to run the specs. You can do that by executing the ibacon command and passing it the file you want to test.</p>
<pre name="code">

+ C:\dev\caricature
(master) » ibacon spec/sword_spec.rb
ClrModels::Sword
- should call survive_attack on the mock
- should return different results when expectation is defined with arguments

2 specifications (5 requirements), 0 failures, 0 errors
</pre>
<p><div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:e7a7ff6b-7e8d-4103-aea9-665298fa5cde" style="float:none; display:inline; margin:0px; padding:0px 0px 0px 0px;">Technorati Tags: <a href="http://technorati.com/tags/ironruby" rel="tag">ironruby</a>,<a href="http://technorati.com/tags/caricature" rel="tag">caricature</a>,<a href="http://technorati.com/tags/mocking" rel="tag">mocking</a></div></p>
]]></content:encoded>
			<wfw:commentRss>http://flanders.co.nz/2009/05/21/getting-started-with-caricature-and-ironruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Caricature ready for beta</title>
		<link>http://flanders.co.nz/2009/05/19/caricature-ready-for-beta/</link>
		<comments>http://flanders.co.nz/2009/05/19/caricature-ready-for-beta/#comments</comments>
		<pubDate>Tue, 19 May 2009 14:06:04 +0000</pubDate>
		<dc:creator>Ivan Porto Carrero</dc:creator>
				<category><![CDATA[IronRuby]]></category>
		<category><![CDATA[Mocking]]></category>
		<category><![CDATA[caricature]]></category>

		<guid isPermaLink="false">http://flanders.co.nz/2009/05/19/caricature-ready-for-beta/</guid>
		<description><![CDATA[The last couple of days I’ve been getting Caricature to a more releasable state. The code got a thorough cleanup and refactor. Caricature now knows how to be a full mocking framework for Ruby classes and CLR classes that only interact with ruby objects. When I apply the 80/20 rule to caricature it’s definitely beta [...]]]></description>
			<content:encoded><![CDATA[<p>The last couple of days I’ve been getting <a href="http://github.com/casualjim/caricature" target="_blank">Caricature</a> to a more releasable state. The code got a thorough cleanup and refactor. Caricature now knows how to be a full mocking framework for Ruby classes and CLR classes that only interact with ruby objects. When I apply the 80/20 rule to caricature it’s definitely beta worthy.</p>
<p>   <span id="more-349"></span>
<p>I’m not a huge fan of the 80/20 rule unless all the features I want are in the 80 part. In that case for me it’s a 100 rule <img src='http://flanders.co.nz/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . </p>
<p>As for the latest changes:</p>
<p>Adding <em><strong>require ‘caricature’</strong></em> only gives you ruby mocking. If you want to use it to mock CLR classes or interact with the CLR you’ll need to add an extra require statement:<em><strong> require ‘caricature/clr’</strong></em>. I’ve done it this way so that I can still add Java and MacRuby support later on.</p>
<p>By default caricature will always give you an instance of an isolation, but there are times that you’ll want to substitute the result of a class method invocation. So the API got expanded with 2 methods, <strong><em>when_class_receives</em></strong> and<strong><em> did_class_receive?</em></strong>&#160; These methods enable you to setup substitutions for class method calls.</p>
<p>I’m still waiting for IronRuby 0.5 to be released to give you a blow-by-blow tutorial on how to setup your environment.</p>
<p>Basically you download the ironruby release from <a href="http://ironruby.codeplex.com/Release/ProjectReleases.aspx" target="_blank">Codeplex</a></p>
<p>Then you make sure the path to ir.exe is in your PATH variable</p>
<p>After that you should be able to do igem list and get an empty result back.</p>
<p>now you need to install bacon you can do that by executing</p>
<p>igem install bacon</p>
<p>next you need the caricature gem</p>
<p>igem install caricature</p>
<p>You will also need rake to be installed to build the cs files included in the sources.</p>
<p>igem install rake</p>
<p>ok now you should be good to to</p>
<pre class="ruby" name="code">

require 'rubygems'
require 'bacon'
require 'caricature'
require 'caricature/clr'

describe "when isolating Ruby classes with class members" do

  before do
    @dagger = Dagger.new
    @soldier = Caricature::Isolation.for(SoldierWithClassMembers)
  end

  it "should work without expectations" do
    result = @dagger.attack @soldier
    result.should.equal nil
    @soldier.did_receive?(:survive_attack_with).with(@dagger).should.be.successful
  end

  it "should work for expectations with an argument constraint" do
    @soldier.when_receiving(:survive_attack_with).with(@dagger).return(5)
    @dagger.attack(@soldier).should.equal 5
    @soldier.did_receive?(:survive_attack_with).with(:any).should.be.successful
  end

end
</pre>
<p>you can get the gem from <a href="http://rubyforge.org/projects/caricature/" target="_blank">rubyforge</a>&#160;</p>
<p>Or from my github account: <a title="http://github.com/casualjim/caricature" href="http://github.com/casualjim/caricature">http://github.com/casualjim/caricature</a></p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5c7b90c5-1c5c-40e2-8aa3-b5a6fa638c0a" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/caricature" rel="tag">caricature</a>,<a href="http://technorati.com/tags/ironruby" rel="tag">ironruby</a>,<a href="http://technorati.com/tags/mocking" rel="tag">mocking</a></div>
]]></content:encoded>
			<wfw:commentRss>http://flanders.co.nz/2009/05/19/caricature-ready-for-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An update on caricature</title>
		<link>http://flanders.co.nz/2009/05/15/an-update-on-caricature/</link>
		<comments>http://flanders.co.nz/2009/05/15/an-update-on-caricature/#comments</comments>
		<pubDate>Fri, 15 May 2009 22:34:46 +0000</pubDate>
		<dc:creator>Ivan Porto Carrero</dc:creator>
				<category><![CDATA[IronRuby]]></category>
		<category><![CDATA[caricature]]></category>

		<guid isPermaLink="false">http://flanders.co.nz/2009/05/15/an-update-on-caricature/</guid>
		<description><![CDATA[Yesterday I explained about caricature but I didn’t have it fully tested yet. Today I’ve written a bunch of integration specs for all the platform combinations Caricature currently supports so you should be able to use Caricature also for plain ruby object mocking in addition to CLR interop mocking.
After having a very brief twitter discussion [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I explained about caricature but I didn’t have it fully tested yet. Today I’ve written a bunch of integration specs for all the platform combinations Caricature currently supports so you should be able to use Caricature also for plain ruby object mocking in addition to CLR interop mocking.</p>
<p>After having a very brief twitter discussion with Scott I decided it would be a good idea to change the name of the methods <em>when\_told\_to</em> and <em>was\_told\_to?</em> . In ruby objects receive messages so the wording now becomes <em>when\_receiving</em> and <em>did\_receive? </em>. I have a problem with the should naming because there is nothing conditional about it. Either you want the method to return something or you want it to return a default value for CLR value types or nil.&#160; And if you’re asserting if a method it called that is deterministic; it is either called or not there is no gray area there. </p>
<pre name="code" class="ruby">

ninja = ClrModels::Ninja.new 

@weapon.when_receiving(:attack).with(ninja).return(5) 

@ninja.attack(ninja, @weapon).should.equal 5 

@weapon.did_receive?(:attack).with(:any).should.be.successful 
</pre>
<p>Before I call it 1.0 I want to at least give ruby objects also the ability to isolate static and sealed methods as well as mocking ruby class methods.&#160; So that for CLR to Ruby interaction you a get the full range of possibilities.</p>
<p>I have also <a href="http://casualjim.github.com/caricature/Caricature.html" target="_blank">set up a site on github</a> that contains the API documentation for Caricature. When IronRuby 0.5 releases I’ll publish a blog post that will talk you through testing your CLR assembly with IronRuby, bacon and Caricature. </p>
<p>For now you can take a look <a href="http://github.com/casualjim/caricature/blob/7ab1d513be74b26c95a1ca34cc1d01f6c850cc43/spec/integration_spec.rb" target="_blank">here</a> for example on how to use Caricature for isolating features.</p>
]]></content:encoded>
			<wfw:commentRss>http://flanders.co.nz/2009/05/15/an-update-on-caricature/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IronRuby just got a mocking framework &#8211; kind of</title>
		<link>http://flanders.co.nz/2009/05/14/ironruby-just-got-a-mocking-framework-kind-of/</link>
		<comments>http://flanders.co.nz/2009/05/14/ironruby-just-got-a-mocking-framework-kind-of/#comments</comments>
		<pubDate>Thu, 14 May 2009 22:31:50 +0000</pubDate>
		<dc:creator>Ivan Porto Carrero</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[IronRuby]]></category>
		<category><![CDATA[caricature]]></category>
		<category><![CDATA[CLR interop]]></category>
		<category><![CDATA[Mocking]]></category>

		<guid isPermaLink="false">http://flanders.co.nz/2009/05/14/ironruby-just-got-a-mocking-framework-kind-of/</guid>
		<description><![CDATA[As I mentioned in a previous post.&#160; I started working on a small mocking framework. It has now progressed far enough to handle the most common mocking tasks.
Below I pasted the output of the integration tests for CLR interop.
when isolating CLR interfaces      - should work without expectations    [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in a previous <a href="http://flanders.co.nz/2009/05/03/mocking-for-ironruby/">post</a>.&#160; I started working on a small mocking framework. It has now progressed far enough to handle the most common mocking tasks.</p>
<p>Below I pasted the output of the integration tests for CLR interop.</p>
<blockquote><p>when isolating CLR interfaces      <br />- should work without expectations       <br />- should work with an expectation with any arguments       <br />- should work with an expectation getting different method call result       <br />- should work for an assertion on a specific argument </p>
<p>when isolating CLR classes      <br />- should work without expectations       <br />- should work with an expectation for any arguments       <br />- should work with an assertion for specific arguments       <br />- should fail for an assertion with wrong arguments </p>
<p>when isolating CLR instances      <br />- should work without expectations       <br />- should work with an expectation for any arguments       <br />- should fail for an assertion for specific arguments       <br />- should allow to delegate the method call to the real instance (partial mock)</p>
</blockquote>
<p>you will need bacon installed to run the specs. you should issue the command <em>igem install bacon</em> for that.</p>
<p>you can then install the caricature gem in ironruby by issueing</p>
<p><em>igem install caricature</em></p>
<p>To use it there are some examples in the file spec/integration_spec.rb </p>
<pre name="code" class="ruby">

require 'rubygems'
require 'bacon'
require 'caricature'

ninja.when_told_to(:survive_attack_with).return(5) 

weapon.attack(ninja).should.equal 5 

ninja.was_told_to?(:survive_attack_with).with(:any).should.be.successful
</pre>
<p>There is a gotcha though, when you use it in a CLR class you&#8217;re bound to CLR rules and it only overrides the methods that are marked as virtual. We also can&#8217;t isolate static or sealed types at the moment.<br />
  </p>
<p>I took the approach of doing away with the terminology of mocking and subbing and instead chose the much clearer Isolation. By default any method returns null or the default value of a value type. You can tell an isolation to return a specific value or raise an error etc.&#160; Later on you can then assert if the method was actually called.&#160; </p>
<p>This fits in better with the way you probably structure your tests. </p>
<p>I hope you like it.</p>
<p>You can find the source in my github account.<br />
  <br /><a href="http://github.com/casualjim/caricature">http://github.com/casualjim/caricature</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flanders.co.nz/2009/05/14/ironruby-just-got-a-mocking-framework-kind-of/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
