Returning mock objects from factory girl <p>I am using Mocha and Factory_girl in a JRuby rails application. When I call the factory I would like to return the objects with some mocking already done. Here is a code snippet of what I am trying to do.</p> <pre><code>Factory.define :tweet_feed_with_tweets, :parent =&gt; :tweet_feed do |t| t.expects(:pull_tweets).returns([Factory.build(:status),Factory.build(:status)]) end </code></pre> <p>Because I do not want my unit and functional test to actually pull from the twitter API i want to stub the method so it returns what I want. But, this is not working. The object comes back without any stubbing done. Is there a way to actually have stubbing performed on an object created with factory girl before it gets returned to you?</p>