Skip to content

A koan for creating your own simple mocking framework in Ruby

Notifications You must be signed in to change notification settings

njpearman/MyMocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyMocker

MyMocker contains a koan built with Cucumber and some customised formatting that goes about stepping you through the process of creating a mocking class.

Start by running rake or cucumber from the project root and see how you go!

At the moment, the class can only mock or stub no-argument methods or methods with only one argument.

At certain stages through the koan, you get prompted to run the example features, which actually use the class that you have built in “real world” (contrived..?) situations. The command is:

rake cukoan:examples

The aim of the game

The goal is to show a simple but powerful use of the method_missing paradigm in Ruby, and demonstrate the difference between mocks and stubs.

A bonus goal is to do it in the smallest amount of code possible. I’ve done it in twenty eight lines with sensible whitespace and logic per line, so that is the bar.

About

A koan for creating your own simple mocking framework in Ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages