I'm using Test/Unit with a standard rails 2.1 project. I would like to be able to test Partial Views in isolation from any particular controller / action.
It seemed as though ZenTest's Test::Rails::ViewTestCase would help, but I couldn't get it working, similarly with view_test http://www.continuousthinking.com/tags/view_test
Most of the stuff Google turns up seems quite out of date, so I'm guessing doesn't really work with Rails 2.1
Any help with this much appreciated.
Thanks, Roland
We're using RSpec in our Rails 2.1 project, and we can do this sort of thing:
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 don't know how much of that you can do with the vanilla Rails testing apparatus.
Found this which may be relevant:
http://broadcast.oreilly.com/2008/10/testing-rails-partials.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With