Forum: Ruby on Rails RSpec Controllers

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
E4c4a05719644c37f02dc5181de7c8c5?d=identicon&s=25 Seth Buntin (sethtrain)
on 2007-05-16 21:54
Anyone have any suggestions on basic best practices for rspec
controllers?  Or any good examples of some rspec controllers?
83ca41657a99b65d99889abe712ba5e2?d=identicon&s=25 Jason Roelofs (Guest)
on 2007-05-16 22:18
(Received via mailing list)
I actually gave up trying to convert to rSpec for my controller code
the information I normally got through a failed test was chomped.
assert_response. Rspec: response.should be_success => response.success?
which gives me True or False and no more information while
gives me "Response was <400> when you expected <200>". Of course, I
just use the normal assert functions, but that's not all

I've also found that a very important part of functional testing is
sure that my views compile. As rSpec for Rails wants to disconnect the
controller code from the view (in general MVC architectures the right
to do), I no longer know if my views even compile, much less function.
course I put together (right now) selenium tests to make sure my views
actually function, but when it comes to Rails refactoring, it's a very
idea to know if your views compile or not, and rSpec by default keeps
information away from you.  As the whole point of a controller action is
process data in order to render out a response, I'm not a fan of the
view separation.

Of course, I may just be nit-picking, as all of this has a work-around
to it
(#include_views, I think it's called, and using regular assertion

Otherwise rSpec is a great tool that really should be a requirement in

rSpec's web site has some pretty thorough documentation, though I've
found a few blog posts that help out with the Rails side:

(more about models, but a decent reference)

Hope that helps.

E4c4a05719644c37f02dc5181de7c8c5?d=identicon&s=25 Seth Buntin (sethtrain)
on 2007-05-16 23:18
Yeah, I've looked at those on multiple occasions but still need more

> (more about models, but a decent reference)
> Hope that helps.
> Jason
This topic is locked and can not be replied to.