# Unit Testing good study material

**URL:** <https://www.ruby-forum.com/t/unit-testing-good-study-material/189751>\
**Category:** Ruby\
**Created:** [June 7, 2010, 6:40am UTC](https://www.ruby-forum.com/t/unit-testing-good-study-material/189751 "2010-06-07T06:40:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luckydev](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb8c5e/32.png) [@luckydev](https://www.ruby-forum.com/u/luckydev)\
**Post date:** [June 7, 2010, 6:40am UTC](https://www.ruby-forum.com/t/unit-testing-good-study-material/189751/1 "2010-06-07T06:40:56Z")

</div>

I am a beginner in ruby and I have read the “Unit testing” chapter in  
Programming Ruby book. I want to study Unit testing using ruby in much  
more detail.

Can somebody point me towards a good resource for that ?

thanks

---

<div class="post-metadata">

**Author:** ![luckydev](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb8c5e/32.png) [@luckydev](https://www.ruby-forum.com/u/luckydev)\
**Post date:** [June 7, 2010, 1:38pm UTC](https://www.ruby-forum.com/t/unit-testing-good-study-material/189751/2 "2010-06-07T13:38:19Z")

</div>

On Mon, Jun 7, 2010 at 12:40 AM, Lakshmanan Muthukrishnan  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am a beginner in ruby and I have read the “Unit testing” chapter in  
> Programming Ruby book. I want to study Unit testing using ruby in much  
> more detail.
> 
> Can somebody point me towards a good resource for that ?

you might want to google for a few terms related to that like

TDD (or test driven design)  
or  
BDD (behavior driven design)

I’d recommend “The RSpec book” from the Pragmatic Programmers which is  
currently in the last stages of their beta program, which means that  
you can buy the book as a PDF and optionally get the printed book when  
available.

[http://pragprog.com/titles/achbd/the-rspec-book](http://pragprog.com/titles/achbd/the-rspec-book)

As the name implies the book covers rspec rather than test::unit.  
RSpec has become a very popular alternative to test::unit for many  
Rubyists. It also covers Cucumber which is a higher level framework  
for writing user-level specifications/acceptance tests. The pair work  
very well in combination.

There’s also another pragmatic programmers title in beta “Rails Test  
Prescriptions” by Noel Rappin.

[http://pragprog.com/titles/nrtest/rails-test-prescriptions](http://pragprog.com/titles/nrtest/rails-test-prescriptions)

This was a self-published book, which focused more on Test::Unit, but  
included material on RSpec/Cucumber. It’s been picked up as a title  
by the prags, I believe that it’s more focused on Rails than the RSpec  
book, which covers the use of RSpec/Cucumber with Rails apps in the  
context of doing BDD in Ruby, whereas the Rappin book looks like it  
covers the use of RSpec and Cucumber as an extension of the Test::Unit  
based testing framework in Rails.

HTH

–  
Rick DeNatale

Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Github: [rubyredrick (Rick DeNatale) · GitHub](http://github.com/rubyredrick)  
Twitter: @RickDeNatale  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)

---

<div class="post-metadata">

**Author:** ![luckydev](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb8c5e/32.png) [@luckydev](https://www.ruby-forum.com/u/luckydev)\
**Post date:** [June 7, 2010, 7:15pm UTC](https://www.ruby-forum.com/t/unit-testing-good-study-material/189751/3 "2010-06-07T19:15:33Z")

</div>

An oldie but still a goodie is Kent Beck’s Test Driven Development By  
Example. The examples are not in Ruby but they translate well and the  
book as a whole provides a strong foundation for TDD and testing in  
general.

---

<div class="post-metadata">

**Author:** ![luckydev](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb8c5e/32.png) [@luckydev](https://www.ruby-forum.com/u/luckydev)\
**Post date:** [June 7, 2010, 7:16pm UTC](https://www.ruby-forum.com/t/unit-testing-good-study-material/189751/4 "2010-06-07T19:16:43Z")

</div>

On Mon, Jun 7, 2010 at 6:37 AM, Rick DeNatale  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> I’d recommend “The RSpec book” from the Pragmatic Programmers which is  
> currently in the last stages of their beta program, which means that  
> you can buy the book as a PDF and optionally get the printed book when  
> available.

It’s been in the last stages of beta for a really long time now ☹ It’s  
release date has been pushed back at least three times this year  
already.  
There was also supposed to be a book on RSpec by Apress but it seems  
nothing  
ever happened with that (it is alleged to already be released  
[Amazon.com](http://www.amazon.com/Foundations-RSpec-Behavior-driven-Development-Rails/dp/1590599225/ref=sr_1_fkmr1_2?ie=UTF8&qid=1275903384&sr=1-2-fkmr1))  
And Addison-Wesley was supposed to release a book on it back in April,  
but  
that hasn’t happened and the book’s page is now gone from Amazon. Back  
in  
Feb I was asking about these books (  
[Foundations of RSpec - Ruby - Ruby-Forum](http://www.ruby-forum.com/topic/204576)) Noone really had much to say.

I enjoyed your blog about creating your own RSpec book from the beta  
PDF. (  
[http://talklikeaduck.denhaven2.com/2009/09/12/and-now-for-something-completely-different-diy-bookbinding-on-the-cheap](http://talklikeaduck.denhaven2.com/2009/09/12/and-now-for-something-completely-different-diy-bookbinding-on-the-cheap))  
And I have it since my boss pre-ordered. But I have a hard time  
motivating  
myself to try and read something that I feel like is going to be  
deprecated  
soon. I won’t have the time or motivation to read it twice.

@Lakshmana: the first chapter of Ruby Best Practices is about testing  
(Test::Unit) the book is not really aimed at people new to Ruby, but it  
has  
a lot of code examples, and you can download the PDF for free from  
[http://rubybestpractices.com/](http://rubybestpractices.com/) (if you’re satisfied, you can support Open  
Source and the author, by purchasing it  
[O'Reilly Media - Technology and Business Training](http://oreilly.com/catalog/9780596523008/index.html)) Although, I just  
glanced at the Pickaxe’s chapter on unit testing, and I’m not sure  
whether  
RBP has more to offer (still, free to check it out). Still, don’t get  
hung  
up on whether you understand every nut and bolt of everything. The  
Pickaxe’s  
chapter looks like it should be good enough to get started, and it is  
more  
important that you incorrectly start, than that you correctly do not  
start.  
Once you get started, you’ll have a better understanding of the domain,  
which will make it easier to learn from reading other resources later  
down  
the line. In other words, you can begin testing with just a bare minimum  
of  
tools, and you should.

RSpec’s documentation is also pretty good

> **[RSpec documentation](http://rspec.info/documentation/)**

And I feel like I …oughta… mention shoulda, b/c there are a lot of  
Rubyists who like it, but I honestly know next to nothing about it, so  
I’ll  
let someone else fill in those details. Here is their github, though (  
[GitHub - thoughtbot/shoulda: Makes tests easy on the fingers and the eyes](http://github.com/thoughtbot/shoulda)).

I also feel like I should mention that there are two Peepcodes about  
RSpec,  
but a lot of the stuff in them is already deprecated and doesn’t work,  
and  
it’s especially frustrating when learning the unfamiliar, if you don’t  
really know what something does, but it isn’t working, and you aren’t  
sure  
why not, or how big of a deal it is. NOTE: I just went to check it out,  
and  
they now have 4 peepcodes on BDD, including cucumber and mocking. The  
ones I  
watched say they have been updated, but I’m not sure if that was before  
or  
after I tried going through it. ([http://peepcode.com/](http://peepcode.com/))

---

<div class="post-metadata">

**Author:** ![luckydev](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/eb8c5e/32.png) [@luckydev](https://www.ruby-forum.com/u/luckydev)\
**Post date:** [June 7, 2010, 9:29pm UTC](https://www.ruby-forum.com/t/unit-testing-good-study-material/189751/5 "2010-06-07T21:29:36Z")

</div>

On Mon, Jun 7, 2010 at 1:16 PM, Josh C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Mon, Jun 7, 2010 at 6:37 AM, Rick DeNatale [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:
> 
> > I’d recommend “The RSpec book” from the Pragmatic Programmers which is  
> > currently in the last stages of their beta program, which means that  
> > you can buy the book as a PDF and optionally get the printed book when  
> > available.
> 
> It’s been in the last stages of beta for a really long time now ☹ It’s  
> release date has been pushed back at least three times this year already.

It suffers from the same fate as many books for Ruby, which is chasing  
a moving target.

The current delay is that it was decided to delay the release until  
RSpec 2 is released, which is also being coordinated on the release of  
Rails 3.

Even in its current ‘beta’ form it’s quite complete and useful.

–  
Rick DeNatale

Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Github: [rubyredrick (Rick DeNatale) · GitHub](http://github.com/rubyredrick)  
Twitter: @RickDeNatale  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)
