~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to spec/unit/application/doc_spec.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-25 01:00:37 UTC
  • mfrom: (1.1.24 upstream) (3.1.25 sid)
  • Revision ID: james.westby@ubuntu.com-20110725010037-875vuxs10eboqgw3
Tags: 2.7.1-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/puppetmaster-passenger.postinst: Use cacrl instead of hostcrl to
    set the location of the CRL in apache2 configuration. Fix apache2
    configuration on upgrade as well (LP: #641001)
  - move all puppet dependencies to puppet-common since all the code
    actually located in puppet-common.
  - move libagueas from a recommend to a dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env ruby
2
 
 
3
 
require File.dirname(__FILE__) + '/../../spec_helper'
 
1
#!/usr/bin/env rspec
 
2
require 'spec_helper'
4
3
 
5
4
require 'puppet/application/doc'
6
5
require 'puppet/util/reference'
12
11
    @doc.stubs(:puts)
13
12
    @doc.preinit
14
13
    Puppet::Util::Log.stubs(:newdestination)
15
 
    Puppet::Util::Log.stubs(:level=)
16
14
  end
17
15
 
18
16
  it "should ask Puppet::Application to not parse Puppet configuration file" do
108
106
 
109
107
      Puppet::Util::Reference.expects(:reference).with(reference).returns(ref)
110
108
      ref.expects(:doc)
111
 
      @doc.expects(:exit)
112
109
 
113
 
      @doc.handle_list(nil)
 
110
      expect { @doc.handle_list(nil) }.to exit_with 0
114
111
    end
115
112
 
116
113
    it "should add reference to references list with --reference" do
187
184
      before :each do
188
185
        @doc.options.stubs(:[]).returns(false)
189
186
        Puppet.stubs(:parse_config)
190
 
        Puppet::Util::Log.stubs(:level=)
191
187
        Puppet::Util::Log.stubs(:newdestination)
192
188
      end
193
189
 
233
229
 
234
230
      it "should set log level to debug if --debug" do
235
231
        @doc.options.stubs(:[]).with(:debug).returns(true)
236
 
        Puppet::Util::Log.expects(:level=).with(:debug)
237
 
 
238
232
        @doc.setup_rdoc
 
233
        Puppet::Util::Log.level.should == :debug
239
234
      end
240
235
 
241
236
      it "should set log level to info if --verbose" do
242
237
        @doc.options.stubs(:[]).with(:verbose).returns(true)
243
 
        Puppet::Util::Log.expects(:level=).with(:info)
244
 
 
245
238
        @doc.setup_rdoc
 
239
        Puppet::Util::Log.level.should == :info
246
240
      end
247
241
 
248
242
      it "should set log destination to console if --verbose" do
284
278
        Puppet.settings.stubs(:[]=).with(:document_all, false)
285
279
        Puppet.settings.stubs(:setdefaults)
286
280
        Puppet::Util::RDoc.stubs(:rdoc)
287
 
        @doc.stubs(:exit)
288
281
        File.stubs(:expand_path).with('modules').returns('modules')
289
282
        File.stubs(:expand_path).with('manifests').returns('manifests')
290
283
        @doc.command_line.stubs(:args).returns([])
294
287
        @doc.options.expects(:[]).with(:all).returns(true)
295
288
        Puppet.settings.expects(:[]=).with(:document_all, true)
296
289
 
297
 
        @doc.rdoc
 
290
        expect { @doc.rdoc }.to exit_with 0
298
291
      end
299
292
 
300
293
      it "should call Puppet::Util::RDoc.rdoc in full mode" do
301
294
        Puppet::Util::RDoc.expects(:rdoc).with('doc', ['modules','manifests'], nil)
302
 
        @doc.rdoc
 
295
        expect { @doc.rdoc }.to exit_with 0
303
296
      end
304
297
 
305
298
      it "should call Puppet::Util::RDoc.rdoc with a charset if --charset has been provided" do
306
299
        @doc.options.expects(:[]).with(:charset).returns("utf-8")
307
300
        Puppet::Util::RDoc.expects(:rdoc).with('doc', ['modules','manifests'], "utf-8")
308
 
        @doc.rdoc
 
301
        expect { @doc.rdoc }.to exit_with 0
309
302
      end
310
303
 
311
304
      it "should call Puppet::Util::RDoc.rdoc in full mode with outputdir set to doc if no --outputdir" do
312
305
        @doc.options.expects(:[]).with(:outputdir).returns(false)
313
306
        Puppet::Util::RDoc.expects(:rdoc).with('doc', ['modules','manifests'], nil)
314
 
        @doc.rdoc
 
307
        expect { @doc.rdoc }.to exit_with 0
315
308
      end
316
309
 
317
310
      it "should call Puppet::Util::RDoc.manifestdoc in manifest mode" do
318
311
        @doc.manifest = true
319
312
        Puppet::Util::RDoc.expects(:manifestdoc)
320
 
        @doc.rdoc
 
313
        expect { @doc.rdoc }.to exit_with 0
321
314
      end
322
315
 
323
316
      it "should get modulepath and manifestdir values from the environment" do
326
319
 
327
320
        Puppet::Util::RDoc.expects(:rdoc).with('doc', ['envmodules1','envmodules2','envmanifests'], nil)
328
321
 
329
 
        @doc.rdoc
 
322
        expect { @doc.rdoc }.to exit_with 0
330
323
      end
331
324
    end
332
325