List Info

Thread: Test::Unit mocking the db




Test::Unit mocking the db
country flaguser name
Germany
2007-06-28 07:55:44
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
members
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?

Thanks,
Mark.

-- 
Posted via http://www.ruby-forum.com
/.

--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-talkgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )