Sha256: 188377e21c882ea1a2003fbb77276d0192955a6bd90a0169521e1be7107742d2

Contents?: true

Size: 910 Bytes

Versions: 21

Compression:

Stored size: 910 Bytes

Contents

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

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

  it "handles private_constant statement" do
    expect(Registry.at('A::Foo').visibility).to eq :private
    expect(Registry.at('A::B').visibility).to eq :private
    expect(Registry.at('A::C').visibility).to eq :private
  end

  it "makes all other constants public" do
    expect(Registry.at('A::D').visibility).to eq :public
  end

  it "fails if parameter is not String, Symbol or Constant" do
    undoc_error 'class Foo; private_constant x; end'
    undoc_error 'class Foo; X = 1; private_constant X.new("hi"); end'
  end unless LEGACY_PARSER

  it "fails if constant can't be recognized" do
    undoc_error 'class Foo2; private_constant :X end'
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

Version Path
yard-0.9.24 spec/handlers/private_constant_handler_spec.rb
yard-0.9.23 spec/handlers/private_constant_handler_spec.rb
yard-0.9.22 spec/handlers/private_constant_handler_spec.rb
yard-0.9.21 spec/handlers/private_constant_handler_spec.rb
yard-0.9.20 spec/handlers/private_constant_handler_spec.rb
yard-0.9.19 spec/handlers/private_constant_handler_spec.rb
yard-0.9.16 spec/handlers/private_constant_handler_spec.rb
yard-0.9.15 spec/handlers/private_constant_handler_spec.rb
yard-0.9.14 spec/handlers/private_constant_handler_spec.rb
yard-0.9.13 spec/handlers/private_constant_handler_spec.rb
yard-0.9.12 spec/handlers/private_constant_handler_spec.rb
yard-0.9.11 spec/handlers/private_constant_handler_spec.rb
yard-0.9.10 spec/handlers/private_constant_handler_spec.rb
yard-0.9.9 spec/handlers/private_constant_handler_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/yard-0.9.8/spec/handlers/private_constant_handler_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/yard-0.9.8/spec/handlers/private_constant_handler_spec.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/yard-0.9.8/spec/handlers/private_constant_handler_spec.rb
yard-0.9.8 spec/handlers/private_constant_handler_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.7/spec/handlers/private_constant_handler_spec.rb
yard-0.9.7 spec/handlers/private_constant_handler_spec.rb