Sha256: 0fb8f020b8f6500ccb548d2e278571786c20d0a9d9f88bb99fbd6a085b721549

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

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

describe YARD::Templates::Helpers::MethodHelper do
  include YARD::Templates::Helpers::BaseHelper
  include YARD::Templates::Helpers::MethodHelper
  
  describe '#format_block' do
    before { YARD::Registry.clear }
    
    it "should show block for method with yield" do
      YARD.parse_string <<-'eof'
        def foo; yield(a, b, c) end
      eof
      format_block(Registry.at('#foo')).should == "{|a, b, c| ... }"
    end
    
    it "should show block for method with @yieldparam tags" do
      YARD.parse_string <<-'eof'
        # @yieldparam _self me!
        def foo; end
      eof
      format_block(Registry.at('#foo')).should == "{|_self| ... }"
    end

    it "should show block for method with @yield but no types" do
      YARD.parse_string <<-'eof'
        # @yield blah
        # @yieldparam a
        def foo; end
        
        # @yield blah
        def foo2; end
      eof
      format_block(Registry.at('#foo')).should == "{|a| ... }"
      format_block(Registry.at('#foo2')).should == "{ ... }"
    end
    
    it "should show block for method with @yield and types" do
      YARD.parse_string <<-'eof'
        # @yield [a, b, c] blah
        # @yieldparam a
        def foo; end
      eof
      format_block(Registry.at('#foo')).should == "{|a, b, c| ... }"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yard-0.5.3 spec/templates/helpers/method_helper_spec.rb
yard-0.5.2 spec/templates/helpers/method_helper_spec.rb
yard-0.5.1p1 spec/templates/helpers/method_helper_spec.rb
yard-0.5.1 spec/templates/helpers/method_helper_spec.rb
yard-0.5.0 spec/templates/helpers/method_helper_spec.rb