summaryrefslogtreecommitdiff
path: root/spec/unit/man_spec.rb
blob: 28a20854379d29edb3ac911038a7dcab1db7bd9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet/face'

describe Puppet::Face[:man, :current] do
  let(:pager) { '/path/to/our/pager' }

  around do |example|
    oldpager = ENV['MANPAGER']
    ENV['MANPAGER'] = pager
    example.run
    ENV['MANPAGER'] = oldpager
  end

  it "exits with 0 when generating man documentation for each available application" do
    Puppet::Util.stubs(:which).with('ronn').returns(nil)
    Puppet::Util.stubs(:which).with(pager).returns(pager)

    Puppet::Application.available_application_names.each do |name|
      next if %w{man face_base indirection_base}.include? name

      klass = Puppet::Application.find('man')
      app = klass.new(Puppet::Util::CommandLine.new('puppet', ['man', name]))

      expect do
        IO.stubs(:popen).with(pager, anything).yields($stdout)

        expect { app.run }.to exit_with(0)
      end.to_not have_printed(/undefined method `gsub'/)
    end
  end
end