matsko
matsko

Reputation: 22193

Best way to test views in a Rails App

I've been using RSpec for testing my Rails application, but I find that testing views, partials and helpers that it isn't fully optimized for that. Can someone suggest a better approach to testing these things?

Upvotes: 2

Views: 1662

Answers (4)

zetetic
zetetic

Reputation: 47548

An alternative to Cucumber is RSpec request specs. The syntax is less natural than Cucumber, but still very readable.

Upvotes: 1

Rimian
Rimian

Reputation: 38418

Yeah. Cucumbers all the way. Also see:

http://pragprog.com/book/hwcuc/the-cucumber-book
http://peepcode.com/products/cucumber

Upvotes: 1

Peter Brown
Peter Brown

Reputation: 51707

Helpers are really easy to test with RSpec, but views and partials can be tricky since you really are doing an integration test. For these I use Cucumber since it allows you to describe the behavior in plain english and then use a nice DSL like Capybara to interact with the application. Much bigger learning curve for Cucumber than RSpec (IMHO), but the payoff has big rewards.

Upvotes: 1

Kevin Sylvestre
Kevin Sylvestre

Reputation: 38032

Many users will pair RSpec with Cucumber. Cucumber provides higher level testing and will allow you to test most aspects of your views efficiently.

Edit:

A few resources:

Upvotes: 2

Related Questions