On 30 Aug 2011, at 19:24, Alex Chaffee wrote:

> ...or grabbing and reassigning $stdout and $stderr, which is what
> "capturing" does.
> 
> The basic idea is that Ruby is *already* decoupled from stdin/out/err
> via its dynamic nature and $globals. I get that by naming the inputs
> explicitly you're ensuring 100% compliance but you should consider
> whether it's worth it. Passing around DI clumps (aka "value objects"
> or "parameter objects" in some circles) can make your code a lot less
> concise, and concision is one of the great joys of Ruby.

Yes, I've done constant reassigning in the past, with before/after blocks to 
control the environment. I wasn't specifically avoiding that here, it's just 
what fell out my my initial design to pass the standard streams in as variables 
from the bin/ command. I'm going to see how it pans out, as I've never been so 
strict about IO before. 


> btw apologies if you already know this, but inside a normal Ruby
> program you should always use $stderr/$stdout/$stdin, not
> STDERR/STDOUT/STDIN since the former are settable and the latter are
> hardcoded to the "real" streams and, as true CONSTANTS, not easy to
> change. For whatever reason I see the caps versions used a lot more
> than the dollar versions, which is a shame.

Actually I didn't know that, so thanks for pointing it out :-)  Although I have 
often been puzzled by the presence of both forms…


Cheers
Ash

-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashmoran

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to