What unit testing frameworks are used for Rails?
I am reading the book (Pragmatic Programmers Agile Dev. with Rails) which shows how to do unit tests in Rails.
The book showed me the default rails testing suite (a subclass of Test::Unit
). Is this the main testing framework that is used in the Rails community? I use RSpec when doing regular ruby, and I would like to be able to use it in Rails too (if it's not too much of a hassle)?
I would say rspec is the most widely used. It's easy to get it up and running, it's expressive and easy to use. Rails comes with Test::Unit support by default, but I don't see many people using it. And of course there's a myriad of smaller testing frameworks that a small number of people use. But it's mostly rspec.
There are many tools for testing rails and other webapps from many different aspects. But if you are new to testing I highly recommend you start with learning Rails' own testing framework before start using other tools.
Learning, and later mastering, one testing framework makes it easier in the future to understand pros/cons with other framework and make them work in unison.
You could start with testing the following things:
I have seen many failed testing efforts, but I never saw them fail because they choose the wrong tool/framework. They fail because they don't know how to master the tools they use, and learn enough about the basics about testing.
Read more about Rails testing here.
http://guides.rubyonrails.org/testing.html
Yes, rspec is used for Rails too. You can find some other examples listed here (although I didn't try most of them).
Rspec is widely used in rails, and in conjunction with Cucumber, is one of the most widely used solutions today. note that rails 3 is using rspec 2, so look for rspec/rails. check out the pragprog.com book rspec and cucumber, a great resource written by the core teams. http://pragprog.com/titles/achbd/the-rspec-book
http://ruby-toolbox.com/categories/testing_frameworks.html