File: module_handler_spec.rb

package info (click to toggle)
yard 0.9.38-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,736 kB
  • sloc: ruby: 31,680; javascript: 7,658; makefile: 21
file content (35 lines) | stat: -rw-r--r-- 1,012 bytes parent folder | download | duplicates (6)
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
35
# frozen_string_literal: true
require File.dirname(__FILE__) + '/spec_helper'

RSpec.describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ModuleHandler" do
  before(:all) { parse_file :module_handler_001, __FILE__ }

  it "parses a module block" do
    expect(Registry.at(:ModName)).not_to eq nil
    expect(Registry.at("ModName::OtherModName")).not_to eq nil
  end

  it "attaches docstring" do
    expect(Registry.at("ModName::OtherModName").docstring).to eq "Docstring"
  end

  it "handles any formatting" do
    expect(Registry.at(:StressTest)).not_to eq nil
  end

  it "handles complex module names" do
    expect(Registry.at("A::B")).not_to eq nil
  end

  it "handles modules in the form ::ModName" do
    expect(Registry.at("Kernel")).not_to be nil
  end

  it "lists mixins in proper order" do
    expect(Registry.at('D').mixins).to eq [P(:C), P(:B), P(:A)]
  end

  it "creates proper module when constant is in namespace" do
    expect(Registry.at('Q::FOO::A')).not_to be nil
  end
end