Skip to content

Commit

Permalink
Use mute gem for capturing stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hunt committed Jan 19, 2014
1 parent ff51e7e commit 5731757
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
1 change: 1 addition & 0 deletions hi.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'cane', '~> 2.6.1'
spec.add_development_dependency 'cane-hashcheck', '~> 1.2.0'
spec.add_development_dependency 'coveralls', '~> 0.7.0'
spec.add_development_dependency 'mute', '~> 1.0.0'
spec.add_development_dependency 'pry', '~> 0.9.12.4'
spec.add_development_dependency 'rack-test', '~> 0.6.2'
spec.add_development_dependency 'rake', '~> 10.1.1'
Expand Down
17 changes: 2 additions & 15 deletions spec/hi/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

it 'prints message to standard out' do
stdout = capture_stdout do
stdout = Mute::IO.capture_stdout do
logger.log message
end

Expand All @@ -25,24 +25,11 @@
end

it 'does not print message to standard out' do
stdout = capture_stdout do
stdout = Mute::IO.capture_stdout do
logger.log message
end

expect(stdout).to be_empty
end
end

private

def capture_stdout
captured = StringIO.new
stdout = $stdout
$stdout = captured

yield

$stdout = stdout
captured.string
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'pry'
require 'mute'
require 'coveralls'
Coveralls.wear!

Expand Down

0 comments on commit 5731757

Please sign in to comment.