Sha256: 1f1b521c515010cae20cbf5a946b1de23d69049d4d17af7f6f25b46f23e29005

Contents?: true

Size: 1.87 KB

Versions: 8

Compression:

Stored size: 1.87 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}MixinHandler" do
  before(:all) { parse_file :mixin_handler_001, __FILE__ }

  it "handles includes from classes or modules" do
    expect(Registry.at(:X).instance_mixins).to include(P(:A))
    expect(Registry.at(:Y).instance_mixins).to include(P(:A))
  end

  it "handles includes in class << self" do
    expect(Registry.at(:Y).class_mixins).to include(P(:A))
  end

  it "handles includes for modules that don't yet exist" do
    expect(Registry.at(:X).instance_mixins).to include(P(nil, :NOTEXIST))
  end

  it "sets the type of non-existing modules to :module" do
    o = Registry.at(:X).instance_mixins.find {|o| o.name == :NOTEXIST }
    expect(o.type).to eq :module
  end

  it "handles includes with multiple parameters" do
    expect(Registry.at(:X)).not_to be nil
  end

  it "handles complex include statements" do
    expect(P(:Y).instance_mixins).to include(P('B::C'))
    expect(P(:Y).instance_mixins).to include(P(:B))
  end

  it "treats a mixed in Constant by taking its value as the real object name" do
    expect(P(:Y).instance_mixins).to include(Registry.at('B::D'))
  end

  it "adds includes in the correct order when include is given multiple arguments" do
    expect(P(:Z).instance_mixins).to eq [P(:A), P(:B)]
  end

  it "avoids including self for unresolved mixins of the same name" do
    expect(P("ABC::DEF::FOO").mixins).to eq [P("ABC::FOO")]
    expect(P("ABC::DEF::BAR").mixins).to eq [P("ABC::BAR")]
  end

  it "raises undocumentable error if argument is variable" do
    undoc_error "module X; include invalid; end"
    expect(Registry.at('X').mixins).to eq []
  end

  it "parses all other arguments before erroring out on undocumentable error" do
    undoc_error "module X; include invalid, Y; end"
    expect(Registry.at('X').mixins).to eq [P('Y')]
  end
end

Version data entries

8 entries across 7 versions & 2 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/spec/handlers/mixin_handler_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/spec/handlers/mixin_handler_spec.rb
yard-0.9.5 spec/handlers/mixin_handler_spec.rb
yard-0.9.4 spec/handlers/mixin_handler_spec.rb
yard-0.9.3 spec/handlers/mixin_handler_spec.rb
yard-0.9.2 spec/handlers/mixin_handler_spec.rb
yard-0.9.1 spec/handlers/mixin_handler_spec.rb
yard-0.9.0 spec/handlers/mixin_handler_spec.rb