# Re: Code Review: Fix for File.print misbehavior

**URL:** <https://www.ruby-forum.com/t/re-code-review-fix-for-file-print-misbehavior/168154>\
**Category:** IronRuby\
**Created:** [May 17, 2009, 1:13am UTC](https://www.ruby-forum.com/t/re-code-review-fix-for-file-print-misbehavior/168154 "2009-05-17T01:13:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![raker\_t](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@raker\_t](https://www.ruby-forum.com/u/raker_t)\
**Post date:** [May 17, 2009, 1:13am UTC](https://www.ruby-forum.com/t/re-code-review-fix-for-file-print-misbehavior/168154/1 "2009-05-17T01:13:53Z")

</div>

I would be opposed to making the MSpec runner depend on any more  
stdlibs. I would suggest making a helper that swaps the IOStub with the  
real stdout for the duration of a block.

JD

…there is no try  
Sent from my phone. Please excuse typos and txtspk.

---

<div class="post-metadata">

**Author:** ![raker\_t](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@raker\_t](https://www.ruby-forum.com/u/raker_t)\
**Post date:** [May 17, 2009, 7:27am UTC](https://www.ruby-forum.com/t/re-code-review-fix-for-file-print-misbehavior/168154/2 "2009-05-17T07:27:10Z")

</div>

The “output” matcher from the snippet below swaps stdout with IOStub in  
order to be able to capture the output of the block. Swapping IOStub  
back with real stdout will not work as you will not know what the block  
printed…

```
lambda { $stdout.print(o, o2) }.should 

```

output("#{o.to\_s}#{o2.to\_s}#{$}")

One hybrid way to fix this would be for the “output” matcher to take an  
IO object as a second optional parameter that is used to capture the  
output intead of using IOStub. Then print\_spec.rb could provide a  
StringIO object. Currently, print\_spec.rb is busted and does not test  
what it is supposed to. Taking a dependency on a stdlib (stringio) would  
not be worse thing in this case.

I do not feel strongly about fixing this right now…

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] On Behalf Of Jim D.  
[removed\_email\_address@domain.invalid]  
Sent: Saturday, May 16, 2009 4:05 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] Code Review: Fix for File.print misbehavior

I would be opposed to making the MSpec runner depend on any more  
stdlibs. I would suggest making a helper that swaps the IOStub with the  
real stdout for the duration of a block.

JD

…there is no try  
Sent from my phone. Please excuse typos and txtspk.
