Replacement for AV::TestCase

Hey friends,

here's a replacement for ActionView::TestCase, I called it AV::HelperTest. In the commit I already changed all the existing helper tests, they run fine with the new class. https://github.com/apotonick/rails/commit/f5bf2a06cf30cc621d6d1aef5aedc4659737b271

So, why a replacement?

AV::TestCase has about 300 lines of code trying to fake something which is already there - a clean API for running helper methods in a real view. We no longer need all that code to setup an artificial view context.

My new class is a combination of something I came up with and Yehuda's BlockHelper. It basically adds two new methods #in_view and #assert_rendered, check the docs here: https://github.com/apotonick/rails/commit/f5bf2a06cf30cc621d6d1aef5aedc4659737b271#L0R39

It's a very simplistic approach trying to reduce complexity and combine both the new Rails API with an easy way of running code in a real view.

Let me know what you think of it, Cheers!

Nick

It looks good to me. I've made a few comments on the commit, but other than the questions I asked, it seems good.

Hopefully others can review it too. :slight_smile:

Aaron- thanks! I added comments to answer your questions.

+1 from me on that. I also added my comment.

I forgot to ask. If this is backwards compatible, why not just change the current AV::TestCase? I'd rather not maintain two base class test cases.

Thanks!

Hm, I don't think it's completely backwards-compatible as AV::TestCase does set A LOT of instance variables and stuff which people surely use in their tests. So, these tests would fail.

Yehuda and I agreed that it would be wise to mark AV::TestCase as deprecated instead and encourage people to use the replacement. What do you think?

Nick

Yo- fixed the uninitialized ivar, see here: https://github.com/apotonick/rails/commits/helper-test-squashed

If you really hate the module separation we can remove it. It *is* premature API, right, however, better a soon API than no API at all :wink:

Prost