Close this search box.
Close this search box.

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

Current360 2024 Predictions crystal ball

2024 Predictions

Thanks to everyone who responded to our 2024 Predictions survey last month. While the sample size wasn’t quite the size of a Pew or Nielsen,

Tradition and digital media crown become digital

The King is dead.
Long Live the King.

No we’re not talking about Charles VII or his father Charles VI. Instead, we’re recognizing the passing of the baton after years of shifts from

Contact Us

"*" indicates required fields

I am not a robot
Ed Sharp Current360 headshot

Ed Sharp

Ed brings 15 years of traditional and digital media sales experience to the agency, giving us a perspective most agencies don’t have. When he’s not working or seeking new knowledge, Ed hangs out with his wife, two kids, two dogs, one cat, and a hamster. And yes, the cat and hamster are best friends.

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