While this post is strictly related to ActiveRecord and not Rails in its
entirety I thought this was probably the best place to ask. If not I
apologise and if someone could point me in the right direction that
would be great.
I’m putting together a small stand-alone Ruby project (jruby in fact but
I’m hoping the premise remains the same)
I’ve an alert object which is very straightforward. The <=> method and
to_s methods are overridden but other than
that there’s nothing more to the object as the alerts are inserted into
the database via a completely seperate java process.
The problem arises when unit testing. We want to be able to mock out the
database if possible but because the implementation of the object is, I
guess, done introspectively against the database table so we’ve no model
to work with and the structure depends on the table.
Should we just forgo the introspective nature of the object and
explicitly map attributes on the Alert object to columns in teh
DB so that we can create dummy objects at unit test time or is there a
better way of doing this i.e. mocking out the database?