Partial View Rail Testing Autonomously

I am using Test / Unit with a standard 2.1 rail . I would like to be able to check partial views separately from any particular controller / action.

It seemed that ZenTest Test :: Rails :: ViewTestCase would help, but I could not get it to work, like view_test http://www.continuousthinking.com/tags/view_test

Most of the things Google appears to seem completely outdated, so I guess it doesn't actually work with Rails 2.1

Any help on this is much appreciated.

Thanks Roland

+6
ruby ruby-on-rails tdd views testing
source share
3 answers

We use RSpec in our Rails 2.1 project, and we can do these things:

describe "/posts/_form" do before do render :partial => "posts/form" end it "says hello" do response.should match(/hello/i) end it "renders a form" do response.should have_tag("form") end end 

However, I do not know how much of what you can do with the Rails vanilla checker.

+6
source share
+2
source share

Testing a view without a controller code is dangerous. Your tests may pass, but your application may cause an error. Always check real situations, not artificial ones.

-3
source share

All Articles