Ruby on Rails Chapter 3: Test Driven Development

Share This Post

Ruby on Rails Blog Series

Welcome back to our Ruby on Rails blog series. In this chapter we create some of the more “static” pages of our sample microbloging application. They aren’t truly static as they have some dynamic elements, but their functionality could mainly be accomplished through HTML.

Test Driven Development (TDD)

We are also introduced to RSpec testing in this chapter, which is used throughout the remainder of the tutorial. RSpec is not the default-testing unit that comes with RoR. We use RSpec to create a testing unit that allows us to define what each section of our code is supposed to do. Run the tests, watch it fail, then alter the code until each test passes.  This allows us to be confident that our code is not only working, but also efficient.

Test driven development also will help you adhere to the DRY (don’t repeat yourself) principle of keeping your code modular. The benefits of this are numerous. By writing the test before you write the code you ensure that once the tests pasts you are delivering all the functionality you originally set out to accomplish — assuming you wrote a complete test. Additionally if you go to extend your application in the future you need only to write the tests for the new functionality. You already know that the base functionality is complete — that is why we wrote the tests. Now you once you get the new functionality tests passing you have extended your application without the fear of breaking what you already had working in the past.

I found Test Driven Development (TDD) to be very rewarding. You write a spec for what behavior you expect, watch it fail, alter the code as necessary and watch it pass. This allows you to always feel as if you are accomplishing tasks and moving forward with your code.

More To Explore

Outdoor Advertising Current360 Hero Image

Advertising in the Great Outdoors.

In the 1920s, a company called Burma Shave — producers of brushless shaving cream — started putting signs up that delighted and educated drivers. These

Paul Rand Current360 Hero Image

Who Influenced the Influencers?

In advertising, pretty much everyone has been influenced by someone else. As we’ve been bringing you stories about ad legends like Bill Bernbach and George

Contact Us

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Chaney Given

Chaney is a talented and accomplished designer and illustrator, who has expanded his skill set to include motion graphics and video editing. With nearly a decade of experience, his client work includes Waterstep, Baptist Health, the Archdiocese of Louisville Catholic Schools, First Harrison Bank, and many more