On May 31, 10:10 pm, Maurício Linhares <[email protected]>
wrote:
> Hi Brian,
>
> The problem you're having with testing is due to the fact that your
> plugin is tightly coupled with the source of the data. If the plugin
> itself didn't knew or could delegate the task of loading the data to
> someone else (something like a RolesDataProvider) you could keep the
> dev and production environments using the database as a data-source
> and have the test env use a file to load this data (this could also
> make your tests run faster).
This is good insight. I'll give this some more thought. I'm not
concerned about testing time since it only takes a few seconds to run
all of my unit tests at the moment. But clearly if I put together a
data provider with minimal dependencies I can grab what I need from
any source before my models are defined. This shouldn't be
significantly more work that my existing "plan B", and it has the
advantage that I can switch back to the DB as a source of this
information later on (or even use a combination of the two).
> Also, avoid overriding method_missing, as this leads to many kinds of
> troubles (the first one is that if you override method_missing you
> would also have to override respond_to? to keep tne interface
> consistent). And just eval'ing the methods is also faster.
Good to know. It just sounds like something that's easy to get
wrong. I won't go down this route for something this important to get
right.
> -
> Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br)
> |http://blog.codevader.com/(en)
>
>
>
> On Sun, May 31, 2009 at 8:58 PM, Brian <[email protected]> wrote:
>
> > On May 31, 7:34 pm, Brian <[email protected]> wrote:
> >> I'm writing a role-based security plugin for personal use in my apps.
> >> The plugin will attach some helper methods to my models automatically
> >> (when I run my new class method 'acts_as_a_foo'). Some of these...
>
> > The other thought I had was that I could override missing_method and
> > delay adding the new methods until they are actually used for the
> > first time. This definitely avoids the timing errors, but seems a
> > little strange.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" 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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---