view_test 0.10.0 released
on August 25, 2007 @ 07:23 PM

view_test 0.10.0 has been released. Install it now:

script/plugin install http://continuous.rubyforge.org/svn/tags/view_test-0.10.0

David Chelimsky 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 format)

1
2
3
4
5
6
7
8
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!


  1. Dustin Tinney 08.26.07 / 02AM

    Hey I installed this last night and ran into issues with Object.metaclass. After requiring metaid.rb it worked fine but maybe you should package that into the plug-in.

  2. Dustin Tinney 08.26.07 / 02AM

    Ah, now I see that you named that as a require in your previous post.

    Wish I would have found that last night. :-)

  3. Zach Moazeni 09.22.07 / 05AM

    Trying to play with the plugin using Rails 1.2.3, getting more than a few errors. Any support for that branch on the radar?

    I tried debugging for a couple hours, and realized it’s going to be a bit more than a simple patch.

    The things I noticed were non-existent view_paths, stack overflows (a circular dependency somewhere), and for some odd reason controller tests were executed with db:migrate and test:views

    -Zach

  4. zdennis 09.22.07 / 15PM

    view_test won’t work with Rails 1.2.3 right now, but it is now on the radar now. ;)