Sha256: eeda958243f22cfe6eecbf0ab0c21b29ee57cc426e88c8f53042c6f492c8a66e

Contents?: true

Size: 1.43 KB

Versions: 21

Compression:

Stored size: 1.43 KB

Contents

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

RSpec.describe YARD::Templates::Engine.template(:default, :constant) do
  describe "fully dressed constant" do
    it "renders text format correctly" do
      YARD.parse_string <<-'eof'
        class YARD::CLI::YRI
          # Default search paths that should be loaded dynamically into YRI. These paths
          # take precedence over all other paths ({SEARCH_PATHS_FILE} and RubyGems
          # paths). To add a path, call:
          #
          #   DEFAULT_SEARCH_PATHS.push("/path/to/.yardoc")
          #
          # @return [Array<String>] a list of extra search paths
          # @since 0.6.0
          DEFAULT_SEARCH_PATHS = []
        end
      eof
      text_equals(Registry.at('YARD::CLI::YRI::DEFAULT_SEARCH_PATHS').format(text_options), :constant001)
    end
  end

  describe "simple constant with no documentation" do
    it "renders text format correctly" do
      # Short constant should show on single line
      YARD.parse_string <<-'eof'
        MYCONST = 'foo'
      eof
      text_equals(Registry.at('MYCONST').format(text_options), :constant002)

      # Long constant should show on multiple lines, indented
      YARD.parse_string <<-'eof'
        MYCONST = [A, B, C, D, E, F, G, H, I, J, K, L,
          M, N, O, P, Q, R, S, T, U, V, W,
          X, Y, Z]
      eof
      text_equals(Registry.at('MYCONST').format(text_options), :constant003)
    end
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

Version Path
yard-0.9.6 spec/templates/constant_spec.rb