Sha256: 3f6d222cb21d434a560ed86166968363c1ab4efb101f814ebfc72eb3dd038c52

Contents?: true

Size: 1.61 KB

Versions: 37

Compression:

Stored size: 1.61 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

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 "should parse the first line as a method signature" do
    @tag.signature.should == "def bar(a, b = 1, &block)"
    @tag.parameters.should == [['a', nil], ['b', "1"], ['&block', nil]]
  end

  it "should parse the rest of the text as a new Docstring" do
    @tag.docstring.should be_instance_of(Docstring)
    @tag.docstring.should == "Hello world"
  end

  it "should set Docstring's object after #object= is called" do
    m = mock(:object)
    @tag.object = m
    @tag.docstring.object.should == m
  end

  it "should respond to #tag, #tags and #has_tag?" do
    @tag.object = mock(:object)
    @tag.tags.size.should == 2
    @tag.tag(:param).name.should == "a"
    @tag.has_tag?(:return).should == true
  end

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

  it "should be a CodeObjects::Base when hooked up to an object" do
    @tag.object = mock(:object)
    @tag.object.should_receive(:is_a?).at_least(3).times.with(CodeObjects::Base).and_return(true)
    @tag.is_a?(CodeObjects::Base).should == true
    @tag.kind_of?(CodeObjects::Base).should == true
    (CodeObjects::Base === @tag).should == true
  end

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

Version data entries

37 entries across 31 versions & 6 rubygems

Version Path
yard-0.8.7.6 spec/tags/overload_tag_spec.rb
yard-0.8.7.5 spec/tags/overload_tag_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
yard-0.8.7.4 spec/tags/overload_tag_spec.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/tags/overload_tag_spec.rb
yard-0.8.7.3 spec/tags/overload_tag_spec.rb
yard-0.8.7.2 spec/tags/overload_tag_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/yard-0.8.7/spec/tags/overload_tag_spec.rb
candlepin-api-0.4.0 bundle/ruby/gems/yard-0.8.7/spec/tags/overload_tag_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/yard-0.8.7/spec/tags/overload_tag_spec.rb
yard-0.8.7.1 spec/tags/overload_tag_spec.rb