Skip to Main Content
Professional Ruby on Rails™
book

Professional Ruby on Rails™

by Noel Rappin
February 2008
Intermediate to advanced content levelIntermediate to advanced
479 pages
14h
English
Wrox
Content preview from Professional Ruby on Rails™

7.5. How to Get RSpec-Like Features

RSpec has many very useful features when compared to standard Test::Unit testing. However, converting to RSpec is not trivial, and using both RSpec and Test::Unit in a program is not recommended (although the newest version of RSpec does allow you to run Test::Unit tests inside RSpec). It's awkward to get tools like rcov, rake, and autotest to run both sets of tests (again, this improved in RSpec 1.1). More importantly, it's very hard for team members to remember when to use RSpec and when to use Test::Unit in a system that attempts to use both.

For some RSpec features, though, there are additional plugins or tools that allow the same or similar functionality to be added to the standard Rails tests. This section briefly discusses a few of those options.

7.5.1. Testing Views

There are at least two separate packages that expand Rails automated test features to include separate tests for controllers and views. The good news is that if you've been playing along so far, you've already downloaded one of them: the ZenTest package that was used in Chapter 4 for its autotest functionality. ZenTest has another facet called Test::Rails. The primary purpose of Test::Rails is to augment the existing Rails tests with controller-only and view-only tests. Sounds like it might be a good match.

7.5.1.1. Test::Rails

As I mentioned, you've already downloaded ZenTest but if you haven't been following along, you can quickly catch up with a gem install ZenTest

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ruby on Rails® Bible

Ruby on Rails® Bible

Timothy Fisher
Rails 4 in Action

Rails 4 in Action

Yehuda Katz, Rebecca Skinner, Stephen Klabnik, Ryan Bigg

Publisher Resources

ISBN: 9780470223888Purchase book