Re: [Rails-core] Method capture

44 views
Skip to first unread message

Aaron Patterson

unread,
Sep 10, 2012, 12:26:11 PM9/10/12
to rubyonra...@googlegroups.com
On Mon, Sep 10, 2012 at 08:56:12AM -0700, Dmitry Vorotilin wrote:
> Guys I want to ask you about current realization of method capture. There's
> a case in tests where I want to capture output in subprocess, current
> realization cannot do it because it doesn't reopen $std{out,err} and just
> reassign this value. I think that's enough for many cases, do we need
> another realization in reporting.rb? Or I can just place it in the tests.
> It related to https://github.com/rails/rails/pull/7586

Can you check to see if minitest's `capture_io` will solve the problem?

https://github.com/seattlerb/minitest/blob/master/lib/minitest/unit.rb#L447-460

If not, can you write a small example (outside rails) to demonstrate the
problem? This sounds like something we might want to push up to
minitest if possible.

--
Aaron Patterson
http://tenderlovemaking.com/

Dmitry Vorotilin

unread,
Sep 10, 2012, 5:38:21 PM9/10/12
to rubyonra...@googlegroups.com, tende...@ruby-lang.org
Thanks Aaron for reply I write a gist for these cases, here you are https://gist.github.com/3694068

Dmitry Vorotilin

unread,
Sep 10, 2012, 5:41:38 PM9/10/12
to rubyonra...@googlegroups.com, tende...@ruby-lang.org
The new method, captures all descriptors, but I'm not sure about replacement original method.

Gabriel Sobrinho

unread,
Sep 11, 2012, 9:24:59 AM9/11/12
to rubyonra...@googlegroups.com, tende...@ruby-lang.org
Dmitry,

I commented in your gist to use the StringIO instead of Tempfile to avoid IO on disk.

Dmitry Vorotilin

unread,
Sep 11, 2012, 12:41:25 PM9/11/12
to rubyonra...@googlegroups.com, tende...@ruby-lang.org
Thank you, let's discuss it in PR https://github.com/seattlerb/minitest/pull/161
I think it will be more comfortable for us.
Reply all
Reply to author
Forward
0 new messages