On 16 May 2011, at 16:01, Lille <[email protected]> wrote:

> Thanks!
> 
> So, maybe I automate the creation of the in-memory database with a
> rake task for the test? If not, what do you think?
> 
> I think an issue here is that my modules assuming their parents are AR
> classes. Is that really modular?

Depends on what your code does - if it is inherently very active-recordy stuff 
then that's probably ok. If it is legitimate to include the module in a non 
activerecord class then I'd aim to do that in tests too.

Fred. 
> 
> Lille
> 
> On May 16, 10:47 am, Frederick Cheung <[email protected]>
> wrote:
>> On May 16, 3:37 pm, Lille <[email protected]> wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Hi,
>> 
>>> I'm converting some AR classes into modules and moving their
>>> attributes to whatever AR classes formerly held the association.
>> 
>>> I'm finding it hard to test these modules.
>> 
>>> I think I want to use a tableless AR model in my module tests. I just
>>> define one of these -- with the attributes the module needs -- in the
>>> test file and use it in the test. This works, but not for all AR
>>> methods. In particular, I run into errors when I invoke certain AR
>>> methods that seem to require the presence of a table.
>> 
>>> So, simply put, how do I get a fully functional AR model for use in
>>> testing, without an accompanying migration?
>> 
>> not entirely what you ask, but how about  creating an in memory
>> sqlite3 database and creating tables in there (you don't need a
>> migration file - you can have the table creating stuff in your test's
>> setup) ?
>> 
>> Fred
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Any thoughts?
>> 
>>> Thanks,
>> 
>>> Lille
> 
> -- 
> 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.
> 

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