Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Rspec and testing

Dear Jason, and the rest of the treehouse team (and other students!)

I am new to RoR but not to coding in general. I am loving so far and find the treehouse tuts awesome. I think Jason is a superb tutor (although.......occasionally slow down!).

My question is open ended - I want opinions.

I am totally new to the whole testing approach. In this set of tutorials almost all the work revolves around testing and crafting good tests. it adds a huge amount of work to the overall project. Now I am guessing that this pays dividends when a project gets very large or complex. Is this correct? Is testing like this a fairly standard thing among good RoR developers? Very keen to learn the right way from the start.

Many thanks


2 Answers

Hi Simon -

When I took Jason Seifer's Ruby on Rails course (Build a TodoList) I was new to both Rails and testing. Initially, I was put-off by the whole "test first, write code, then refactor" approach. I didn't fully appreciate the benefits of test driven development. It felt like a great deal of "overhead" because I was learning Ruby on Rails and Rspec testing at the same time. It was a steep climb.

I read as many resources as I could get my hands on about testing in Rails. One resource that I found helpful, and was recommended to me by a forum member, is "Everyday Rails Testing with RSpec" by Aaron Sumner.

I am currently working on my own Rails app using a test driven approach. I can honestly say that testing is helping me to program better, because it forces me to think more clearly about what I'm trying to do. I've also caught a lot of bugs that may have caused big problems later. I think it's helpful to know what to test, when it's important to test and when it's okay to skip it. I'm still learning, but I think a flexible approach to testing is probably best. I've learned that there are a lot of strongly held opinions about Rails testing. I'm just trying to use testing to help me program better and not be dogmatic about it.



Thanks Ronald. I'm going to check out that rspec resource you suggested.

My opinion is that a robust functional and unit test suite is a crucial part of any production software. There are certainly projects written without adequate test coverage, but I would not want to work on them.

Consider not only what I feel is a clear up-front speed advantage of test-first development (when you consider the QC phases), but as a developer who is new to a project it is a great help to be able to look at well written tests -- they serve as helpful documentation!

There are ongoing debates about the real value of automated testing, but I would ask you to answer two questions as you decide for yourself:

  • Would it be helpful to have a bunch of tests you can run against your application in seconds/minutes whenever you want?
  • Have you ever made changes to your application that have caused new bugs (or old bugs to reappear)?