Sha256: 3b260615cdddf92d76b0d6570c6dcc43f0a7b557268ca61a2ec5c9cd7441f923

Contents?: true

Size: 1.7 KB

Versions: 12

Compression:

Stored size: 1.7 KB

Contents

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

describe YARD::Server::DocServerSerializer do
  describe '#serialized_path' do
    before do
      Registry.clear
      @serializer = Server::DocServerSerializer.new
    end

    after(:all) { Server::Adapter.shutdown }

    it "should return '/PREFIX/library/toplevel' for root" do
      @serializer.serialized_path(Registry.root).should == "toplevel"
    end

    it "should return /PREFIX/library/Object for Object in a library" do
      @serializer.serialized_path(P('A::B::C')).should == 'A/B/C'
    end

    it "should link to instance method as Class:method" do
      obj = CodeObjects::MethodObject.new(:root, :method)
      @serializer.serialized_path(obj).should == 'toplevel:method'
    end

    it "should link to class method as Class.method" do
      obj = CodeObjects::MethodObject.new(:root, :method, :class)
      @serializer.serialized_path(obj).should == 'toplevel.method'
    end

    it "should link to anchor for constant" do
      obj = CodeObjects::ConstantObject.new(:root, :FOO)
      @serializer.serialized_path(obj).should == 'toplevel#FOO-constant'
    end

    it "should link to anchor for class variable" do
      obj = CodeObjects::ClassVariableObject.new(:root, :@@foo)
      @serializer.serialized_path(obj).should == 'toplevel#@@foo-classvariable'
    end

    it "should link files using file/ prefix" do
      file = CodeObjects::ExtraFileObject.new('a/b/FooBar.md', '')
      @serializer.serialized_path(file).should == 'file/FooBar'
    end

    it "should handle unicode data" do
      file = CodeObjects::ExtraFileObject.new("test\u0160", '')
      @serializer.serialized_path(file).should == 'file/test_C5A0'
    end if defined?(::Encoding)
  end
end

Version data entries

12 entries across 11 versions & 3 rubygems

Version Path
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/server/doc_server_serializer_spec.rb
yard-0.8.7.3 spec/server/doc_server_serializer_spec.rb