Sha256: f89d786cc88876edba01e36e73c46ed03259f23e2248b01662178cd64ca2692d

Contents?: true

Size: 911 Bytes

Versions: 4

Compression:

Stored size: 911 Bytes

Contents

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

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

  it "includes modules at class scope" do
    expect(Registry.at(:B).class_mixins).to eq [P(:A)]
    expect(Registry.at(:B).instance_mixins).to be_empty
  end

  it "handles a module extending itself" do
    expect(Registry.at(:C).class_mixins).to eq [P(:C)]
    expect(Registry.at(:C).instance_mixins).to be_empty
  end

  it "extends module with correct namespace" do
    expect(Registry.at('Q::R::S').class_mixins.first.path).to eq 'A'
  end

  it "does not allow extending self if object is a class" do
    undoc_error "class Foo; extend self; end"
  end

  it "adds mixins from extend calls to constants" do
    expect(P('FromConstant').class_mixins).to eq [P('A')]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yard-0.9.24 spec/handlers/extend_handler_spec.rb
yard-0.9.23 spec/handlers/extend_handler_spec.rb
yard-0.9.22 spec/handlers/extend_handler_spec.rb
yard-0.9.21 spec/handlers/extend_handler_spec.rb