Sha256: 50fa3d8f3ad613ff5761fbd98c502667930f81e1fe8216f20b772c233a3979a0

Contents?: true

Size: 1.47 KB

Versions: 21

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

RSpec.describe YARD::Tags::Library do
  def tag(docstring)
    Docstring.new(docstring).tags.first
  end

  describe "#see_tag" do
    it "takes a URL" do
      expect(tag("@see http://example.com").name).to eq "http://example.com"
    end

    it "takes an object path" do
      expect(tag("@see String#reverse").name).to eq "String#reverse"
    end

    it "takes a description after the url/object" do
      tag = tag("@see http://example.com An Example Site")
      expect(tag.name).to eq "http://example.com"
      expect(tag.text).to eq "An Example Site"
    end
  end

  describe ".define_tag" do
    it "allows defining tags with '.' in the name (x.y.z defines method x_y_z)" do
      Tags::Library.define_tag("foo", 'x.y.z')
      Tags::Library.define_tag("foo2", 'x.y.zz', Tags::OverloadTag)
      expect(Tags::Library.instance.method(:x_y_z_tag)).not_to be nil
      expect(Tags::Library.instance.method(:x_y_zz_tag)).not_to be nil
      expect(tag('@x.y.z foo bar').text).to eq 'foo bar'
      expect(tag('@x.y.zz foo(bar)').signature).to eq 'foo(bar)'
    end
  end

  describe "#tag.explain_types" do
    it "can explain tag types" do
      expect(tag("@return [A, B<String>]").explain_types).to eq "an A; a B of (Strings)"
    end

    it "returns nil if no types present" do
      expect(tag("@return").explain_types).to eq nil
    end

    it "returns nil if types are not parseable" do
      expect(tag("@return [$]").explain_types).to eq nil
    end
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

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