I have no idea what makes the "standard" rails app, but the ones that I've 
worked on have employed many unit-level specs. So, I disagree with the "doesn't 
often have tests that don't hit the database" part. 

Tests that do hit the database are used as well. Frankly, they should be. 

If you're not doing testing at the database level right now I would bet that 
the reason is that it is either: 1. too slow or 2. too hard to set up. 
1. is solved by using an in-memory DB and querying conventions  (or just using 
a really fast production DB technology)
2. is solved by a framework that supports schema migrations. 

The setting-up-is-hard-to-do problem is really an issue only for trying to bolt 
db testing onto an existing system with a monolithic huge database. This 
doesn't often apply to rails projects.

Re: DI/IOC, As far as using constructor injection just to facilitate plugging 
in a  different dependency at test time, I never do that in ruby. It's trivial 
to stub objects and methods, including class-level a.k.a. static ones. "new" is 
a class-level/static method in ruby, so overriding it is the equivalent of 
replacing a constructor and allowing it to return a test double. Also, because 
of this, service-type methods can be class-level/static methods, rather than 
passed into an object. (Which makes more sense IMO)

There are places for the DIP though, they are just isolated to instances where 
there is actually behavior that varies, and you have some different ways of 
achieving your goal. Think: strategy, chain of responsibility, decorator, etc. 

So, basically the same rules apply, you just have fewer enforced 
just-for-testing instances of constructor injection. This is mostly a good 
thing.


On Jan 26, 2011, at 4:44 AM, Bobby Johnson wrote:

> to be fair the database in question is a built for the test run sqlite db by 
> default seeded with known data. DI, IoC are less useful in a language where 
> everything is so easy to redefine.
> 
> On Wed, Jan 26, 2011 at 1:35 AM, Ryan Riley <[email protected]> 
> wrote:
> Yep, all true.
> 
> Sent from my iPhone
> 
> On Jan 26, 2011, at 12:39 AM, Erick Thompson <[email protected]> wrote:
> 
> > Rob Conery's post on WebMatrix had a comment by Rob in response to a
> > by Ian Cooper [1]. The comment exchange is well worth the read
> > (alt.net throwdown!) but what caught my eye the statement that
> > Ruby/Rails/Sinatra doesn't use (or really have) DI, IoC or often have
> > tests that don't hit the database. Not having done much with
> > Ruby/Rails/Sinatra aside from a few small projects to learn the
> > langauge/basic framework and knowing that at least a few people here
> > do use and like these - is this true???
> >
> > Erick
> >
> > [1]
> > http://blog.wekeroad.com/microsoft/someone-hit-their-head#comment-129723733
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Seattle area Alt.Net" 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/altnetseattle?hl=en.
> >
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Seattle area Alt.Net" 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/altnetseattle?hl=en.
> 
> 
> 
> 
> -- 
> "The explanation requiring the fewest assumptions is most likely to be 
> correct." 
> 
> - Occam’s Razor
> http://en.wikipedia.org/wiki/Occam's_Razor
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Seattle area Alt.Net" 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/altnetseattle?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Seattle area Alt.Net" 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/altnetseattle?hl=en.

Reply via email to