On Wednesday, October 21, 2015 at 6:09:07 PM UTC-7, Pietro wrote: > > Thanks for the quick reply. Actually, I wanted to split my tests in 2 > separate categories, the first for classes that don't need the database at > all, and the other one for classes that do. > > The methods that I defined on my models are just small convenience methods > so they don't need the database, that's why I thought I could use a mock > database and test them separately. > > Is there really no way around this? I thought I could define the accessors > manually but that doesn't work when using a real database. >
I explained how to work around this in the second paragraph of my original response: "If you want to do this anyway, you can use the schema_caching extension, dump the schema cache in production to a file, and load it in testing right after creating the mock database connection." If for some reason you want to define the accessors manually using def_column_accessor, you can do that as well. You could make this only happen for the mock database: def_column_accessor(:column1, :column2, ...) if db.adapter_scheme == :mock The schema_caching extensions is a better idea IMO, as it is simpler and will setup type casting correctly. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
