Why You Don't Get Mock Objects

A session at RubyConf 2011

Thursday 29th September, 2011

11:15am to 12:00pm (CST)

Although the Ruby community has embraced TDD like no other community ever has, we have always looked at mock objects with disdain, and perhaps even a little hatred. I've heard conference speakers call them "Wastes of time", "Scams", and even "Testing Heresies". Why would anyone have ever developed these pieces of junk?

In reality though many in the agile community have embraced mock objects within their testing cycles because they have found using these fake objects improves the design of their systems. But why not Rubyists? Most Rubyists don't get mock objects because they don't understand their history or their creators intent. They try to fit them into their current workflow without understanding them, and find them unhelpful and stupid. After all, almost all of the good literature on the subject is written in Java, and we know how frustrating it is to read Java when your used to Ruby.

As such, this talk will attempt to demonstrate in Ruby the usefulness of mock objects, and how to use them to improve the design of your system.

Specifically the following will be covered:

  • Why do we need mock objects (Following the 'Tell, Don't Ask Principle')
  • Why you should only mock objects you own
  • Why you shouldn't use mocks to test boundary objects like external API calls
  • Why you should mock roles, not Objects
  • Why you should only mock your immediate neighbors
  • Why listening to your unit tests will tell you about design problems in your code

About the speaker

This person is speaking at this event.
Gregory Moeck

Software Craftsman currently working in JavaScript and Ruby bio from Twitter

Coverage of this session

Sign in to add slides, notes or videos to this session

RubyConf 2011

United States United States, New Orleans

29th September to 1st October 2011

Tell your friends!


Time 11:15am12:00pm CST

Date Thu 29th September 2011

Short URL


Official session page


View the schedule



See something wrong?

Report an issue with this session