Sha256: 6b3ce3f53f9731e8c70147cdf2479b48542b0693b509353ecf03bdf5b6b6bcde

Contents?: true

Size: 1.63 KB

Versions: 44

Compression:

Stored size: 1.63 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

44 entries across 44 versions & 4 rubygems

Version Path
challah-0.6.2 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.6.1 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.6.0 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.5.4 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.5.3 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.5.2 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.5.1 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.5.0 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.4.1 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.4.0 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.3.5 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.3.4 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.3.3 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.3.2 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.3.1 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.3.0 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.2.1 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
challah-0.2.0 vendor/bundle/gems/yard-0.7.5/spec/tags/overload_tag_spec.rb
yard-0.7.5 spec/tags/overload_tag_spec.rb
nutshell-crm-0.0.6.alpha vendor/bundle/gems/yard-0.7.4/spec/tags/overload_tag_spec.rb