From the course: Ruby: Testing with RSpec

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

A TDD example: Part two

A TDD example: Part two - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

A TDD example: Part two

- In this movie we'll continue our test driven development example. In the last movie we took care of the first bullet using TDD. We're now able to read and write to the doors attribute. Next, new cars should default to having four doors. New instances means that we'll be working with the initialize method. So let's check that out. So before we actually go to the spec file, let's look at our car class, and let's notice that we already have an initialize method. It accepts a hash of options, and then it sets make, year, color, and wheels. It doesn't address doors at all. What I want to point out to you is that we're working with Legacy code here, and test driven development doesn't really tell us how we work with Legacy code. By definition, Legacy code without Legacy test coverage will not be test driven. The code's already done. So we would need to switch back to verification and validation testing in order to get this method covered. For now we're going to bypass it and stick with…

Contents