suppresing output to console with ruby

Viewed 8445

I am writing some unit tests like the following:

def executing_a_signal
  a_method(a_signal.new, a_model, a_helper);
  assert_equal(new_state, a_model.state)
end

The tests work fine, but the method which runs just before the assertion to execute the logic prints various messages to the console, mainly via puts.

Is there a quick, perhaps built-in, way to suppress that output to the console? I am only interested in the final effect of the method on the model object, and for the sake of keeping the console clean basically, I was hoping to find a way to simply prevent all output to the console without re-writing or commenting out those puts statements just for my tests.

It is definitely not a critical issue, but would very much like to hear any thoughts or ideas (or workaround) on it.

5 Answers
Related