summaryrefslogtreecommitdiffhomepage
path: root/spec/handlers/c/source/module_handler_spec.rb
blob: 9641eb340c00161ace8a6c1f1ac14a9b90f0903e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require_relative 'spec_helper'

describe YARD::MRuby::Handlers::C::Source::ModuleHandler do
  it "should register modules" do
    parse_init 'mFoo = mrb_define_module(mrb, "Foo");'
    expect(Registry.at('Foo').type).to be :module
  end

  it "should register modules under namespaces" do
    parse_init(<<-eof)
      cBar = mrb_define_module(mrb,"Bar");
      cFoo = mrb_define_module_under(mrb, cBar, "Foo");
    eof

    expect(Registry.at('Bar::Foo').type).to be :module
  end

  it "should remember symbol defined with module" do
    parse_init(<<-eof)
      cXYZ = mrb_define_module(mrb, "Foo");
      mrb_define_method(mrb, cXYZ, "bar", bar, 0);
    eof
    expect(Registry.at('Foo').type).to be :module
    expect(Registry.at('Foo#bar')).not_to be_nil
  end

  it "should associate declaration comments as module docstring" do
    parse_init(<<-eof)
      /* Docstring! */
      mFoo = mrb_define_module(mrb, "Foo");
    eof
    expect(Registry.at('Foo').docstring).not_to be_blank
  end
end