Sha256: 2638622bf30e8029e1b547a8bad3da2e4e29c65451bfd4777dc2757e6b431314

Contents?: true

Size: 866 Bytes

Versions: 3

Compression:

Stored size: 866 Bytes

Contents

require 'spec_helper'

describe Rambling::Trie::Serializers::Zip do
  let(:properties) { Rambling::Trie::Configuration::Properties.new }
  let(:serializer) { Rambling::Trie::Serializers::Zip.new properties }

  let(:words) { %w(a few words to validate that load and dump are working) }
  let(:trie) { Rambling::Trie.create { |t| words.each { |w| t << w } } }
  let(:tmp_path) { File.join ::SPEC_ROOT, 'tmp' }

  before do
    properties.tmp_path = tmp_path
  end

  it_behaves_like 'a serializer' do
    let(:filename) { 'trie-root.marshal' }
    let(:filepath) { File.join tmp_path, "#{filename}.zip" }
    let(:content) { trie.root }
    let(:formatted_content) { zip Marshal.dump content }
  end

  def zip content
    io = Zip::OutputStream.write_buffer do |io|
      io.put_next_entry filename
      io.write content
    end
    io.rewind
    io.read
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rambling-trie-1.0.2 spec/lib/rambling/trie/serializers/zip_spec.rb
rambling-trie-1.0.1 spec/lib/rambling/trie/serializers/zip_spec.rb
rambling-trie-1.0.0 spec/lib/rambling/trie/serializers/zip_spec.rb