Sha256: ad2a029db3dc1349dfcfd60a23f9cbb90453d5df4c85be3d816c2e42272fb225

Contents?: true

Size: 1.65 KB

Versions: 68

Compression:

Stored size: 1.65 KB

Contents

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

class StringSerializer < YARD::Serializers::Base
  attr_accessor :files, :string
  def initialize(files, string)
    @files = files
    @string = string
  end

  def serialize(object, data)
    files << object
    string << data
  end
end

describe YARD::Templates::Engine.template(:default, :onefile) do
  before do
    Registry.clear
    if defined?(::Encoding)
      @eenc, Encoding.default_external = Encoding.default_external, 'ascii-8bit'
      @ienc, Encoding.default_internal = Encoding.default_internal, 'ascii-8bit'
    end
  end

  after do
    if defined?(::Encoding)
      Encoding.default_internal = @ienc
      Encoding.default_external = @eenc
    end
  end

  def render
    @files = []
    @output = ''
    YARD.parse_string <<-eof
      class A
        # Foo method
        # @return [String]
        def foo; end

        # Bar method
        # @return [Numeric]
        def bar; end
      end
    eof
    readme = CodeObjects::ExtraFileObject.new('README',
      "# This is a code comment\n\n# Top of file\n\n\nclass C; end")
    Templates::Engine.generate Registry.all(:class),
      :serializer => StringSerializer.new(@files, @output),
      :onefile => true, :format => :html, :readme => readme, :files => [readme,
        CodeObjects::ExtraFileObject.new('LICENSE', 'This is a license!')
      ]
  end

  it "should render html" do
    render
    @files.should == ['index.html']
    @output.should include("This is a code comment")
    @output.should include("This is a license!")
    @output.should include("Class: A")
    @output.should include("Foo method")
    @output.should include("Bar method")
  end
end

Version data entries

68 entries across 52 versions & 7 rubygems

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