Skip to content
A teachable object for Pharo
Smalltalk HTML
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


A teachable object for Pharo.


Using the small project you can easily create objects responding to specific messages. This is useful for mocking in unit tests and other. The code goes back to an early idea of Ernest Micklei with an implementation for Pharo by Torsten Bergmann (astares).

Quick Start

Metacello new 
	repository: 'github://astares/Pharo-Teachable/src';
	baseline: 'Teachable';


It's an implementation of a Teachable class who's instances can be taught to respond to messages. It's usefull for creating mocks who should behave like other objects (for instance inside of a test case) without actually implementing a real mock class. Here is an example how it can be used:

teachable := Teachable new.
    whenSend: #help return: 'ok';
    whenSend: #doit evaluate: [1 inspect];
    acceptSend: #noDebugger;
    whenSend: #negate: evaluate: [:num | num negated].

After teaching the object we can use it as if it had a normal implementation in a class:

teachable help. "this will return the string 'ok'"
teachable doit. "this will open the inspector on the SmallInteger 1"
teachable noDebugger. "this will accept the send of #noDebugger and return the teachable"
teachable negate: 120 "this will return -120"



Watch the video

You can’t perform that action at this time.