Well,
I'd suggest the opposite.

the :memoize functionality is extensively tested in ActiveSupport
more extensively than I'm going to remember to do each time I test its
use in my app.

so if I can do a basic "consequences of being memoized" test, and also
say "as far as rails is concerned, this is memoized"
then I get primary confidence that it works,
i also get secondary confidence that its "memoized", and Rails has
promised me that "memoized" works.

  def something(n)
     return randomly(n)
  end
  memoize :something

  test "something is declared as memoized" do
    assert my_model.memoized_methods.include?(:something)
  end

  test "something is memoized" do
     my_model.stubs(:randomly).returns(1,2,3)
     assert_equal 1, my_model.something(7)
     assert_equal 1, my_model.something(7)
     assert_equal 2, my_model.something(100)
  end

  I can grab those edge cases into my tests without having to think
about them.

On Aug 22, 9:12 am, "Michael Koziarski" <[EMAIL PROTECTED]> wrote:
> >  class Abberation
> >    memoize :some_method
> >  end
>
> > will allow me to spec;
>
> >  Abberation.memoized_methods.should include(:some_method)
>
> > I'd prefer this rather than spec-ing
>
> > Abberation.instance_methods.should include("_unmemoized_some_method")
>
> > (I still don't get why it's not just an
> > "alias_method_chain :some_method, :memoization")
>
> Isn't that testing the *implementation* rather than the intended
> effect?  I think it'd be better to test the memoization by ensuring
> the method doesn't calculate the value twice, rather than asserting
> (shoulding?) the thing is memoized?
>
> --
> Cheers
>
> Koz
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to