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 four

A TDD example: Part four - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

A TDD example: Part four

- In this movie we'll conclude our Test Driven Development Example. Our first three items are complete, so next we need to add a question about the door number to our user input questions. You'll recall we did that in our init.rb file. In the init.rb file we prompt the user with the thing that we're looking for followed by a colon and then we wait for their input for gets. We use chomp to get rid of any trailing line returns and then we assign that value to a variable, in this case, make. Then we create the new Car, we pass in that value as part of the options hash. So what we want to do is the same thing for door. So we wanna modify this so it asks for the number of doors and use that value when it creates a new car. We punted on writing test for the init.rb file earlier and it's so simple that it seems like tests are unnecessary, but TDD disagrees. You write the test first or else you don't edit the code. The best solution would be to move this input and output to a class and then…

Contents