Test Drivenn Development in Rails

Hello everyone I had a few questions I just downloaded rcov and have it up my question is are there any good sites that teach you how to write TDD in rails. or any books that can teach me the fundamentals of TDD in rails

Thanks for all the help

GabrielG1976

You can try out BDD since TDD is old concept now. Rspec helps the developers lot.

http://aaswathaman.blogspot.com/

Imho, in really big projects Rspec might give you a nice headache.

It would be nice if you can elaborate what do you mean by your statement (..big projects.. RSpec.. headache..)

You can try out BDD since TDD is old concept now. Rspec helps the developers lot.

I'd hardly call TDD new. BDD is newer that TDD, but they're both relative newcomers.

Fred

That should of course say 'I'd hardly call TDD old'. D'oh!

Fred

You can try out BDD since TDD is old concept now. Rspec helps the developers lot.

BDD is "consultant-friendly".

BDD can be used as a TDD platform. Either way, we are talking about driving development with executable specifications.

Also, technically, whenever at work we try to do something simple in RSpec, such as set a session variable before activating the target method, we invariably get fragile code. The hooks that Rails adds to Test::Unit::TestCase seem more stable, and our RSpec experiments have decayed over time...

GabrielG1976 wrote:

Hello everyone I had a few questions I just downloaded rcov and have it up my question is are there any good sites that teach you how to write TDD in rails. or any books that can teach me the fundamentals of TDD in rails

Rails is all about the TDD - getting a test (or a "spec") to fail first, then writing code to pass the test, then refactoring.

The most important aspect of this is a TDD-friendly editor. You need to _minimize_ the time between changing code and getting test results. That lets you test one edit at a time, which is best.

(And under Ruby you often only _need_ one edit to achieve a testable change, unlike some other languages.)

Don't hold your breath waiting for such an editor...

Read the /Agile Web Development with Rails/ book, by the Daves. It covers TDD as part of the lifecycle (hence the title "Agile") - not as an afterthought.

rails.vim might be what you are looking for: http://rails.vim.tpope.net/ there are some great shortcuts for quickly switching between a file and its test file

Then you just run autotest (http://nubyonrails.com/articles/autotest- rails) and get instant notification when a test fails.

You can do the same thing in Netbeans 6.1. Shortcut: Shift-Ctrl-T.