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 spec/handlers/mixin_handler_spec.rb
challah-1.0.0 vendor/bundle/gems/yard-0.8.6.1/spec/handlers/mixin_handler_spec.rb
yard-0.8.6.2 spec/handlers/mixin_handler_spec.rb
challah-1.0.0.beta3 vendor/bundle/gems/yard-0.8.6/spec/handlers/mixin_handler_spec.rb
challah-1.0.0.beta3 vendor/bundle/gems/yard-0.8.6.1/spec/handlers/mixin_handler_spec.rb
challah-1.0.0.beta3 vendor/bundle/gems/yard-0.8.5.2/spec/handlers/mixin_handler_spec.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/yard-0.8.6.1/spec/handlers/mixin_handler_spec.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/yard-0.8.6.1/spec/handlers/mixin_handler_spec.rb
yard-0.8.6.1 spec/handlers/mixin_handler_spec.rb
challah-1.0.0.beta2 vendor/bundle/gems/yard-0.8.5.2/spec/handlers/mixin_handler_spec.rb
challah-1.0.0.beta2 vendor/bundle/gems/yard-0.8.6/spec/handlers/mixin_handler_spec.rb
yard-0.8.6 spec/handlers/mixin_handler_spec.rb
challah-1.0.0.beta vendor/bundle/gems/yard-0.8.5.2/spec/handlers/mixin_handler_spec.rb
challah-1.0.0.beta vendor/bundle/gems/yard-0.8.3/spec/handlers/mixin_handler_spec.rb
yard-0.8.5.2 spec/handlers/mixin_handler_spec.rb
yard-0.8.5.1 spec/handlers/mixin_handler_spec.rb
yard-0.8.5 spec/handlers/mixin_handler_spec.rb
challah-0.9.1.beta.3 vendor/bundle/gems/yard-0.8.3/spec/handlers/mixin_handler_spec.rb
yard-0.8.4.1 spec/handlers/mixin_handler_spec.rb
yard-0.8.4 spec/handlers/mixin_handler_spec.rb