Sha256: 940ecead8c754caf62322d3629163dba87960c199655a2e41e34466f924ab74e

Contents?: true

Size: 1.8 KB

Versions: 5

Compression:

Stored size: 1.8 KB

Contents

require 'test_helper'
require 'jsdoc-toolkit/generator'

context "a JsDocToolkit::Generator" do
  
  context "with valid arguments and generating docs" do
    
    setup do
      output_dir = Pathname(__FILE__).parent + "output"
      output_dir.rmtree if output_dir.exist?
      output_dir.mkdir
      generator = JsDocToolkit::Generator.new
      generator.build(:src_dir => Pathname(__FILE__).parent + "input", :doc_dir => output_dir)
      output_dir
    end
    
    should "have created files in the output dir" do
      topic.entries.size > 2
    end
    
  end # with valid arguments and generating docs
  
  context "with various modes of build failure" do
    setup do
      generator = JsDocToolkit::Generator.new      
    end
    
    should "fail without java in ENV['PATH']" do
      begin
        original_path = ENV['PATH']
        ENV['PATH'] = ""
        topic.build(:src_dir => Pathname("input"), :doc_dir => Pathname("output"))
      ensure
        ENV['PATH'] = original_path
      end
    end.raises(RuntimeError, /java was not found/)
  
    should "fail if src dir does not exist" do
      topic.build(:src_dir => Pathname("bzzzzzzzzzzzt"), :doc_dir => Pathname("output"))    
    end.raises(ArgumentError, /src_dir does not exist/)
  
    should "fail if doc dir does not exist" do
      topic.build(:src_dir => Pathname(__FILE__).parent + "input", :doc_dir => Pathname("bzzzzzzzt"))
    end.raises(ArgumentError, /doc_dir does not exist/)
  
    should "fail if src dir is not specified" do
      topic.build(:doc_dir => Pathname("output"))    
    end.raises(ArgumentError, /src_dir was not specified/)
  
    should "fail if doc dir is not specified" do
      topic.build(:src_dir => Pathname("input"))
    end.raises(ArgumentError, /doc_dir was not specified/)
    
  end # with various modes of build failure
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jsdoc-toolkit-0.1.4 test/generator_test.rb
jsdoc-toolkit-0.1.3 test/generator_test.rb
jsdoc-toolkit-0.1.2 test/generator_test.rb
jsdoc-toolkit-0.1.1 test/generator_test.rb
jsdoc-toolkit-0.1.0 test/generator_test.rb