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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Mon, Jan 10, 2011 at 01:32:11PM -0800, Nick Sutterer wrote:> 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,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. :-) -- Aaron Patterson http://tenderlovemaking.com/
Aaron- thanks! I added comments to answer your questions. On 10 Jan., 23:50, Aaron Patterson <aa...@tenderlovemaking.com> wrote:> On Mon, Jan 10, 2011 at 01:32:11PM -0800, Nick Sutterer wrote: > > 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/f5bf2a06cf30cc621d6d1aef5ae... > > > 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/f5bf2a06cf30cc621d6d1aef5ae... > > > 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, > > 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. :-) > > -- > Aaron Pattersonhttp://tenderlovemaking.com/ > > application_pgp-signature_part > < 1 KBAnzeigenHerunterladen-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
+1 from me on that. I also added my comment. On Jan 11, 10:11 am, Nick Sutterer <apoton...@gmail.com> wrote:> Aaron- thanks! I added comments to answer your questions. > > On 10 Jan., 23:50, Aaron Patterson <aa...@tenderlovemaking.com> wrote: > > > > > > > > > On Mon, Jan 10, 2011 at 01:32:11PM -0800, Nick Sutterer wrote: > > > 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/f5bf2a06cf30cc621d6d1aef5ae... > > > > 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/f5bf2a06cf30cc621d6d1aef5ae... > > > > 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, > > > 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. :-) > > > -- > > Aaron Pattersonhttp://tenderlovemaking.com/ > > > application_pgp-signature_part > > < 1 KBAnzeigenHerunterladen-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Mon, Jan 10, 2011 at 01:32:11PM -0800, Nick Sutterer wrote:> 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,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! -- Aaron Patterson http://tenderlovemaking.com/
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 On 12 Jan., 18:13, Aaron Patterson <aa...@tenderlovemaking.com> wrote:> On Mon, Jan 10, 2011 at 01:32:11PM -0800, Nick Sutterer wrote: > > 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/f5bf2a06cf30cc621d6d1aef5ae... > > > 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/f5bf2a06cf30cc621d6d1aef5ae... > > > 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, > > 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! > > -- > Aaron Pattersonhttp://tenderlovemaking.com/ > > application_pgp-signature_part > < 1 KBAnzeigenHerunterladen-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
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 ;-) Prost On 12 Jan., 18:13, Aaron Patterson <aa...@tenderlovemaking.com> wrote:> On Mon, Jan 10, 2011 at 01:32:11PM -0800, Nick Sutterer wrote: > > 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/f5bf2a06cf30cc621d6d1aef5ae... > > > 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/f5bf2a06cf30cc621d6d1aef5ae... > > > 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, > > 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! > > -- > Aaron Pattersonhttp://tenderlovemaking.com/ > > application_pgp-signature_part > < 1 KBAnzeigenHerunterladen-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.