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).

When loading your application, you could just configure the default
provider to your plugin and generate the methods with all the data
available.

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.

-
Maurício Linhares
http://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.
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to