Project

mute

0.0
No commit activity in last 3 years
No release in over 3 years
Muting test suites since 2014
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
~> 2.6.1
~> 0.7.0
~> 0.9.12
~> 10.1.1
~> 2.14.1
 Project Readme

Travis CI Coverage Status Code Climate

Muting test suites since 2014

Usage

Tired of seeing garbage printed to the screen during your test suite? Would you like to prove that your fancy custom Logger is actually working? Mute is here to help!

Mute can be used to mute and capture standard out or standard error in your Ruby program. This is most useful in tests where output should be tested, not displayed.

To capture standard out:

require 'mute'

output = Mute::IO.capture_stdout do
  puts 'Hello World!'
end

puts output
  #=> Hello World!

To capture standard error:

require 'mute'

output = Mute::IO.capture_stderr do
  $stderr.puts 'Oops!'
end

puts output
  #=> Oops!

Use it in your test suite to verify output:

require 'mute'

describe MyLogger do
  it 'prints the message to standard out' do
    message = 'Hello World!'

    output = Mute::IO.capture_stdout do
      MyLogger.new.print message
    end

    expect(output).to include message
  end
end

Or just mute stdout completely for the whole test suite:

# spec/spec_helper.rb
require 'mute'

Mute::IO.capture_stdout

Installation

$ gem install mute

Contributing

Please see the Contributing Document

Changelog

Please see the Changelog Document

License

Copyright (C) 2014 Chris Hunt, MIT License