Sha256: 4b4d1a7a868c79818797bc4b06779dd14e824e3d1105147d069ac9a354ff84f6

Contents?: true

Size: 1.2 KB

Versions: 21

Compression:

Stored size: 1.2 KB

Contents

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

RSpec.describe YARD::Handlers::C::MixinHandler do
  it "adds includes to modules or classes" do
    parse_init <<-eof
      mFoo = rb_define_module("Foo");
      cBar = rb_define_class("Bar", rb_cObject);
      mBaz = rb_define_module("Baz");
      rb_include_module(cBar, mFoo);
      rb_include_module(mBaz, mFoo);
    eof
    foo = Registry.at('Foo')
    bar = Registry.at('Bar')
    baz = Registry.at('Baz')
    expect(bar.mixins(:instance)).to eq [foo]
    expect(baz.mixins(:instance)).to eq [foo]
  end

  it "adds include as proxy if symbol lookup fails" do
    parse_init <<-eof
      mFoo = rb_define_module("Foo");
      rb_include_module(mFoo, mXYZ);
    eof
    foo = Registry.at('Foo')
    expect(foo.mixins(:instance)).to eq [P('XYZ')]
  end

  it "fails if mixin variable cannot be detected" do
    with_parser(:c) do
      undoc_error <<-eof
        void Init_Foo() {
          VALUE noprefix;

          mFoo = rb_define_module("Foo");
          // YARD doesn't understand this
          noprefix = rb_const_get(rb_cObject, rb_intern("Observable"));

          rb_include_module(mFoo, noprefix);
        }
      eof
    end
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

Version Path
yard-0.9.24 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.23 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.22 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.21 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.20 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.19 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.16 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.15 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.14 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.13 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.12 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.11 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.10 spec/handlers/c/mixin_handler_spec.rb
yard-0.9.9 spec/handlers/c/mixin_handler_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/yard-0.9.8/spec/handlers/c/mixin_handler_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/yard-0.9.8/spec/handlers/c/mixin_handler_spec.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/yard-0.9.8/spec/handlers/c/mixin_handler_spec.rb
yard-0.9.8 spec/handlers/c/mixin_handler_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.7/spec/handlers/c/mixin_handler_spec.rb
yard-0.9.7 spec/handlers/c/mixin_handler_spec.rb