Testing Ruby Interfaces (OOP)

Please do the sample questions if you really want to learn this stuff

We have already outlined in a previous post, what a stub is, and the benefits of unit testing.

In this post we will provide you with simple ‘hello world’ examples of how to: (i) test for duck types, and (ii) basic use of mocks and stubs in your code.

Once the examples are given, it is of paramount importance that you attempt to put it all together, by yourself, to refinforce your understanding of everything. If you don’t do that, then when battle time comes, you will be left forlorn and confused, without a horse nor a sword to assist you in your time of despair. Choose wisely then.

Let’s continue on with the examples introduced in the previous posts. Consider the following:

I hope this hello world example helps you

Written on June 2, 2017