Sha256: f90dc184d4047210b959af8500113253ce82f0386426b5f3c2607a3321c54977

Contents?: true

Size: 1.88 KB

Versions: 63

Compression:

Stored size: 1.88 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 "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
    o = Registry.at(:X).instance_mixins.find {|o| o.name == :NOTEXIST }
    o.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 add includes in the correct order when include is given multiple arguments" do
    P(:Z).instance_mixins.should == [P(:A), P(:B)]
  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

63 entries across 49 versions & 7 rubygems

Version Path
yard-0.8.7.6 spec/handlers/mixin_handler_spec.rb
yard-0.8.7.5 spec/handlers/mixin_handler_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
yard-0.8.7.4 spec/handlers/mixin_handler_spec.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/mixin_handler_spec.rb
yard-0.8.7.3 spec/handlers/mixin_handler_spec.rb
yard-0.8.7.2 spec/handlers/mixin_handler_spec.rb
candlepin-api-0.4.0 bundle/ruby/gems/yard-0.8.7/spec/handlers/mixin_handler_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/yard-0.8.7/spec/handlers/mixin_handler_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/yard-0.8.7/spec/handlers/mixin_handler_spec.rb
yard-0.8.7.1 spec/handlers/mixin_handler_spec.rb