Sha256: 61c6c3256f8201821046c520ffca0bff28e83c12688b0d9357eb608e3ccd1cde

Contents?: true

Size: 1.58 KB

Versions: 21

Compression:

Stored size: 1.58 KB

Contents

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

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

  it "is able to set visibility to public" do
    expect(Registry.at("Testing#pub").visibility).to eq :public
    expect(Registry.at("Testing#pub2").visibility).to eq :public
  end

  it "is able to set visibility to private" do
    expect(Registry.at("Testing#priv").visibility).to eq :private
  end

  it "is able to set visibility to protected" do
    expect(Registry.at("Testing#prot").visibility).to eq :protected
  end

  it "supports parameters and only set visibility on those methods" do
    expect(Registry.at('Testing#notpriv').visibility).to eq :protected
    expect(Registry.at('Testing#notpriv2').visibility).to eq :protected
    expect(Registry.at('Testing#notpriv?').visibility).to eq :protected
  end

  it "only accepts strings and symbols" do
    expect(Registry.at('Testing#name')).to be nil
    expect(Registry.at('Testing#argument')).to be nil
    expect(Registry.at('Testing#method_call')).to be nil
  end

  it "handles constants passed in as symbols" do
    expect(Registry.at('Testing#Foo').visibility).to eq :private
  end

  it "does not register classes with visibility" do
    expect(Registry.at('Testing::Bar').visibility).to eq :public
    expect(Registry.at('Testing::Baz').visibility).to eq :public
  end

  it "can decorate a method definition" do
    expect(Registry.at('Testing#decpriv').visibility).to eq :private
  end unless LEGACY_PARSER
end

Version data entries

21 entries across 20 versions & 4 rubygems

Version Path
yard-0.9.6 spec/handlers/visibility_handler_spec.rb