Sha256: 9dc8b2dc42e8a125601cdad752875e210baa6b61d2e758e9555c7d7df7838388

Contents?: true

Size: 1.68 KB

Versions: 3

Compression:

Stored size: 1.68 KB

Contents

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

describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}MixinHandler" do
  before(:all) { parse_file :mixin_handler_001, __FILE__ }
  
  it "should handle includes from classes or modules" do
    Registry.at(:X).instance_mixins.should include(P(:A))
    Registry.at(:Y).instance_mixins.should include(P(:A))
  end

  it "should handle includes in class << self" do
    Registry.at(:Y).class_mixins.should include(P(:A))
  end
  
  it "should handle includes for modules that don't yet exist" do
    Registry.at(:X).instance_mixins.should include(P(nil, :NOTEXIST))
  end
  
  it "should set the type of non-existing modules to :module" do
    P(:NOTEXIST).type.should == :module
  end
  
  it "should handle includes with multiple parameters" do
    Registry.at(:X).should_not be_nil
  end
  
  it "should handle complex include statements" do
    P(:Y).instance_mixins.should include(P('B::C'))
    P(:Y).instance_mixins.should include(P(:B))
  end
  
  it "should treat a mixed in Constant by taking its value as the real object name" do
    P(:Y).instance_mixins.should include(Registry.at('B::D'))
  end
  
  it "should avoid including self for unresolved mixins of the same name" do
    P("ABC::DEF::FOO").mixins.should == [P("ABC::FOO")]
    P("ABC::DEF::BAR").mixins.should == [P("ABC::BAR")]
  end
  
  it "should raise undocumentable error if argument is variable" do
    undoc_error "module X; include invalid; end"
    Registry.at('X').mixins.should == []
  end
  
  it "should parse all other arguments before erroring out on undocumentable error" do
    undoc_error "module X; include invalid, Y; end"
    Registry.at('X').mixins.should == [P('Y')]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yard-0.6.4 spec/handlers/mixin_handler_spec.rb
yard-0.6.3 spec/handlers/mixin_handler_spec.rb
yard-0.6.2 spec/handlers/mixin_handler_spec.rb