Sha256: aaa88f442b69d202a722a316dde113e8b65f9e4292700124993d4ac16444a5d6

Contents?: true

Size: 1.65 KB

Versions: 21

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true
require File.dirname(__FILE__) + '/spec_helper'

RSpec.describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ExceptionHandler" do
  before(:all) { parse_file :exception_handler_001, __FILE__ }

  it "does not document an exception outside of a method" do
    expect(P('Testing').has_tag?(:raise)).to be false
  end

  it "documents a valid raise" do
    expect(P('Testing#mymethod').tag(:raise).types).to eq ['ArgumentError']
  end

  it "only documents non-dynamic raises" do
    expect(P('Testing#mymethod2').tag(:raise)).to be nil
    expect(P('Testing#mymethod6').tag(:raise)).to be nil
    expect(P('Testing#mymethod7').tag(:raise)).to be nil
  end

  it "treats ConstantName.new as a valid exception class" do
    expect(P('Testing#mymethod8').tag(:raise).types).to eq ['ExceptionClass']
  end

  it "does not document a method with an existing @raise tag" do
    expect(P('Testing#mymethod3').tag(:raise).types).to eq ['A']
  end

  it "only documents the first raise message of a method (limitation of exception handler)" do
    expect(P('Testing#mymethod4').tag(:raise).types).to eq ['A']
  end

  it "handles complex class names" do
    expect(P('Testing#mymethod5').tag(:raise).types).to eq ['YARD::Parser::UndocumentableError']
  end

  it "ignores any raise calls on a receiver" do
    expect(P('Testing#mymethod9').tag(:raise)).to be nil
  end

  it "handles raise expressions that are method calls" do
    expect(P('Testing#mymethod10').tag(:raise)).to be nil
    expect(P('Testing#mymethod11').tag(:raise)).to be nil
  end

  it "ignores empty raise call" do
    expect(P('Testing#mymethod12').tag(:raise)).to be nil
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

Version Path
yard-0.9.24 spec/handlers/exception_handler_spec.rb
yard-0.9.23 spec/handlers/exception_handler_spec.rb
yard-0.9.22 spec/handlers/exception_handler_spec.rb
yard-0.9.21 spec/handlers/exception_handler_spec.rb
yard-0.9.20 spec/handlers/exception_handler_spec.rb
yard-0.9.19 spec/handlers/exception_handler_spec.rb
yard-0.9.16 spec/handlers/exception_handler_spec.rb
yard-0.9.15 spec/handlers/exception_handler_spec.rb
yard-0.9.14 spec/handlers/exception_handler_spec.rb
yard-0.9.13 spec/handlers/exception_handler_spec.rb
yard-0.9.12 spec/handlers/exception_handler_spec.rb
yard-0.9.11 spec/handlers/exception_handler_spec.rb
yard-0.9.10 spec/handlers/exception_handler_spec.rb
yard-0.9.9 spec/handlers/exception_handler_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/yard-0.9.8/spec/handlers/exception_handler_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/yard-0.9.8/spec/handlers/exception_handler_spec.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/yard-0.9.8/spec/handlers/exception_handler_spec.rb
yard-0.9.8 spec/handlers/exception_handler_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.7/spec/handlers/exception_handler_spec.rb
yard-0.9.7 spec/handlers/exception_handler_spec.rb