Sha256: 125d17de849d3f6c90436bd34a18fd59374d5754733b63697acfe0e7c7fc381e

Contents?: true

Size: 1.62 KB

Versions: 21

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

RSpec.describe YARD::Tags::OverloadTag do
  before do
    @tag = Tags::OverloadTag.new(:overload, <<-'eof')
      def bar(a, b = 1, &block)
        Hello world
        @param a [String]
        @return [String]
    eof
  end

  it "parses the first line as a method signature" do
    expect(@tag.signature).to eq "def bar(a, b = 1, &block)"
    expect(@tag.parameters).to eq [['a', nil], ['b', "1"], ['&block', nil]]
  end

  it "parses the rest of the text as a new Docstring" do
    expect(@tag.docstring).to be_instance_of(Docstring)
    expect(@tag.docstring).to eq "Hello world"
  end

  it "sets Docstring's object after #object= is called" do
    m = double(:object)
    @tag.object = m
    expect(@tag.docstring.object).to eq m
  end

  it "responds to #tag, #tags and #has_tag?" do
    @tag.object = double(:object)
    expect(@tag.tags.size).to eq 2
    expect(@tag.tag(:param).name).to eq "a"
    expect(@tag.has_tag?(:return)).to be true
  end

  it "is not a CodeObjects::Base when not hooked up to an object" do
    @tag.object = nil
    expect(@tag.is_a?(CodeObjects::Base)).to be false
  end

  it "is a CodeObjects::Base when hooked up to an object" do
    @tag.object = double(:object)
    expect(@tag.object).to receive(:is_a?).at_least(3).times.with(CodeObjects::Base).and_return(true)
    expect(@tag.is_a?(CodeObjects::Base)).to be true
    expect(@tag.is_a?(CodeObjects::Base)).to be true
    expect(CodeObjects::Base === @tag).to be true
  end

  it "does not parse 'def' out of method name" do
    tag = Tags::OverloadTag.new(:overload, "default")
    expect(tag.signature).to eq "default"
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

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