File: namespace_mapper_spec.rb

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

RSpec.describe YARD::CodeObjects::NamespaceMapper do
  include YARD::CodeObjects::NamespaceMapper

  describe '#register_separator' do
    it 'should allow separators to be registered' do
      register_separator '!', :test_type

      expect(separators_for_type(:test_type)).to eq ['!']
      expect(types_for_separator('!')).to eq [:test_type]

      unregister_separator_by_type :test_type

      expect(separators_for_type(:test_type)).to be_empty
      expect(types_for_separator('!')).to be_empty
    end
  end

  describe '.on_invalidate' do
    it 'receives a callback when a new separator is added' do
      invalidated = false
      NamespaceMapper.on_invalidate { invalidated = true }

      register_separator '!', :test_type
      expect(invalidated).to be true

      unregister_separator_by_type :test_type
    end
  end
end