Learning ROR testing

Can anyone suggest an advanced resource for learning proper ROR testing? I’ve been writing web apps with ROR for nearly a year now but have been neglecting to write the proper test suites as I’m not sure exactly what requires a test and what doesn’t, which leaves me fearing I’ll spend twice as much time writing tests as actual code.

The RSpec book from pragprog actually spends a bit of time discussing rails testing using both cucumber and rspec, but i would not call it definitive.

Rails Test Prescriptions is quite good, but also not definitive.

A full and proper test suite for a Rails app is difficult in my view after the fact, primarily because so much of code might be written in a way that makes testing it difficult. OTOH, starting in on one at this stage is a great opportunity to go back through your code and refactor it. There are very few cases where refactoring for testability doesn’t also improve cohesiveness, decrease coupling, discovering pieces that would be better provided as gems or services to the app, performance, and if this app is to be used long term, maintainability, and decreasing bit rot.

Have you used mini test? Do you recommend rspec to start? I just want some
comments about. What kind of testing tools do you use?

Thanks in advance :slight_smile:


I use rspec and I do recommend it to start. Also capybara for route and integration testing, and cucumber/gherkin for externally driven testing through cuke/capy with poltergeist/phantomjs. I also use watir for some external test scripts.