Sha256: c0e4714812ec0b4107e99251e5c9d94190bf442bcde0e4989e088e2b9ba0a138

Contents?: true

Size: 1.61 KB

Versions: 30

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

30 entries across 21 versions & 3 rubygems

Version Path
challah-1.0.0.beta vendor/bundle/gems/yard-0.8.3/spec/tags/overload_tag_spec.rb
challah-0.9.1.beta.3 vendor/bundle/gems/yard-0.8.3/spec/tags/overload_tag_spec.rb
challah-0.9.1.beta vendor/bundle/gems/yard-0.8.3/spec/tags/overload_tag_spec.rb
challah-0.9.0 vendor/bundle/gems/yard-0.8.3/spec/tags/overload_tag_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/yard-0.8.3/spec/tags/overload_tag_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/yard-0.8.3/spec/tags/overload_tag_spec.rb
challah-0.8.3 vendor/bundle/gems/yard-0.8.3/spec/tags/overload_tag_spec.rb
challah-0.8.3 vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
yard-0.8.3 spec/tags/overload_tag_spec.rb
challah-0.8.1 vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-0.8.0.pre vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-0.7.1 vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-0.7.0 vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-0.7.0.pre2 vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb
challah-0.7.0.pre vendor/bundle/gems/yard-0.8.2.1/spec/tags/overload_tag_spec.rb