From 168c1c4b532555365e8dd2a318a3fd463dcd8d85 Mon Sep 17 00:00:00 2001 From: Ian Kronquist Date: Mon, 6 Jul 2015 16:40:30 -0700 Subject: [PATCH] (PDOC-37) Override Yard logger on a per test basis Override Yard logger on a per test basis, not globally. Replace one hack with another slightly less disgusting one. --- spec/unit/puppet/face_spec.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/unit/puppet/face_spec.rb b/spec/unit/puppet/face_spec.rb index 03aad0d..5119c41 100644 --- a/spec/unit/puppet/face_spec.rb +++ b/spec/unit/puppet/face_spec.rb @@ -31,9 +31,25 @@ describe Puppet::Face do end describe "when generating HTML for documentation" do + + # HACK: In these tests we would like to suppress all output from the yard + # logger so we don't clutter up stdout. + # However, we do want the yard logger for other tests so we can + # assert that the right things are logged. To accomplish this, for + # this block of tests we monkeypatch the yard logger to be a generic + # stringio instance which does nothing and then we restore the + # original afterwards. + before(:all) do + @tmp = YARD::Logger.instance.io + YARD::Logger.instance.io = StringIO.new + end + + after(:all) do + YARD::Logger.instance.io = @tmp + end + it "should properly generate HTML for manifest comments" do - YARD::Logger.instance.io = StringIO.new using_module('test') do |tmp| Dir.chdir('test')