script/plugin install http://continuous.rubyforge.org/svn/tags/view_test-0.10.0
“David Chelimsky”:http://blog.davidchelimsky.net/ asked me the other day if view_test allowed you to write view tests without having created your controller yet. I said yes naively. Last night I fired up the MacBook Pro and looked over my specs to see if I had tested that case (I thought I did), but I didn’t so I wrote a failing spec and then implemented it.
You can now create a view test and create the correct app/views/products directory structure and have it work without having to have a ProductsController in existance. (Examples are in “Behaviors”:http://behaviors.rubyforge.org format)
class ProductsShowTest < Rails::ViewTest::TestCase
should "display hello world when rendering products/show.html.erb" do
render :file => "products/show"
assert_select 'hello world'
end
end
So, David, I didn’t lie on purpose, and hopefully this release will redeem my answer! Enjoy!
blog comments powered by Disqus