Sha256: 40e8e92afc7e1f9f3ae021e38d3421470817dcfc8accc9c2342bf790ceb87ce2

Contents?: true

Size: 1.33 KB

Versions: 34

Compression:

Stored size: 1.33 KB

Contents

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

instance_eval do
  class YARD::Serializers::YardocSerializer
    public :dump
    public :internal_dump
  end
end

describe YARD::Serializers::YardocSerializer do
  before do
    @serializer = YARD::Serializers::YardocSerializer.new('.yardoc')

    Registry.clear
    @foo = CodeObjects::ClassObject.new(:root, :Foo)
    @bar = CodeObjects::MethodObject.new(@foo, :bar)
  end

  describe '#dump' do
    it "should maintain object equality when loading a dumped object" do
      newfoo = @serializer.internal_dump(@foo)
      newfoo.should equal(@foo)
      newfoo.should == @foo
      @foo.should equal(newfoo)
      @foo.should == newfoo
      newfoo.hash.should == @foo.hash
    end
    
    it "should maintain hash key equality when loading a dumped object" do
      newfoo = @serializer.internal_dump(@foo)
      {@foo => 1}.should have_key(newfoo)
      {newfoo => 1}.should have_key(@foo)
    end
  end
  
  describe '#serialize' do
    it "should accept a hash of codeobjects (and write to root)" do
      data = {:root => Registry.root}
      marshaldata = Marshal.dump(data)
      filemock = mock(:file)
      filemock.should_receive(:write).with(marshaldata)
      File.should_receive(:open!).with('.yardoc/objects/root.dat', 'wb').and_yield(filemock)
      @serializer.serialize(data)
    end
  end
end

Version data entries

34 entries across 34 versions & 4 rubygems

Version Path
nutshell-crm-0.0.5 vendor/bundle/gems/yard-0.7.4/spec/serializers/yardoc_serializer_spec.rb
nutshell-crm-0.0.4 vendor/bundle/gems/yard-0.7.4/spec/serializers/yardoc_serializer_spec.rb
nutshell-crm-0.0.3 vendor/bundle/gems/yard-0.7.4/spec/serializers/yardoc_serializer_spec.rb
nutshell-crm-0.0.2 vendor/bundle/gems/yard-0.7.4/spec/serializers/yardoc_serializer_spec.rb
yard-0.7.4 spec/serializers/yardoc_serializer_spec.rb
yard-0.7.3 spec/serializers/yardoc_serializer_spec.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/yard-0.7.2/spec/serializers/yardoc_serializer_spec.rb
yard-0.7.2 spec/serializers/yardoc_serializer_spec.rb
yard-0.7.1 spec/serializers/yardoc_serializer_spec.rb
yard-0.7.0 spec/serializers/yardoc_serializer_spec.rb
yard-0.6.8 spec/serializers/yardoc_serializer_spec.rb
yard-0.6.7 spec/serializers/yardoc_serializer_spec.rb
yard-0.6.6 spec/serializers/yardoc_serializer_spec.rb
yard-0.6.5 spec/serializers/yardoc_serializer_spec.rb