Sha256: bab4ea3b84f4ac4df5d19031d3b3fd8c8eb4995dd7964faae6eb15284b61d77d

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 KB

Contents

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

describe YARD::Handlers::C::InitHandler do
  it "adds documentation in Init_ClassName() to ClassName" do
    parse(<<-eof)
      // Bar!
      void Init_A() {
        rb_cA = rb_define_class("A", rb_cObject);
      }
    eof
    expect(Registry.at('A').docstring).to eq 'Bar!'
  end

  it "does not add documentation if ClassName is not created in Init" do
    parse(<<-eof)
      // Bar!
      void Init_A() {
      }
    eof
    expect(Registry.at('A')).to be nil
  end

  it "does not overwrite override comment" do
    parse(<<-eof)
      /* Document-class: A
       * Foo!
       */

      // Bar!
      static SWIGEXPORT void Init_A() {
        rb_cA = rb_define_class("A", rb_cObject);
      }
    eof
    expect(Registry.at('A').docstring).to eq 'Foo!'
  end

  it "checks non-Init methods for declarations too" do
    parse(<<-eof)
      void foo(int x, int y, char *name) {
        rb_cB = rb_define_class("B", rb_cObject);
        rb_define_method(rb_cB, "foo", foo_impl, 0);
      }
    eof
    expect(Registry.at('B')).to be_a(CodeObjects::ClassObject)
    expect(Registry.at('B#foo')).to be_a(CodeObjects::MethodObject)
  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/c/init_handler_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/spec/handlers/c/init_handler_spec.rb
yard-0.9.5 spec/handlers/c/init_handler_spec.rb
yard-0.9.4 spec/handlers/c/init_handler_spec.rb
yard-0.9.3 spec/handlers/c/init_handler_spec.rb
yard-0.9.2 spec/handlers/c/init_handler_spec.rb
yard-0.9.1 spec/handlers/c/init_handler_spec.rb
yard-0.9.0 spec/handlers/c/init_handler_spec.rb