Sha256: 5b44348bd1d6e70e33ccc636d47a7bdad982a67732be8bc651a0f4bc7e042e92

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

require "minitest/autorun"
require "sparkey"
require "sparkey/testing"

describe Sparkey do
  include Sparkey::Testing

  before { @filename = random_filename }
  after  { delete(@filename) }

  it "functions as a key value store" do
    sparkey = Sparkey::Store.create(@filename, :compression_snappy, 1000)
    sparkey.put("first", "Michael")
    sparkey.put("second", "Adam")
    sparkey.put("third", "Tanner")
    sparkey.close

    sparkey = Sparkey::Store.open(@filename)

    sparkey.size.must_equal 3

    sparkey.get("first").must_equal("Michael")
    sparkey.delete("second")
    sparkey.flush

    sparkey.size.must_equal 2

    hash = Hash.new
    sparkey.each do |key, value|
      hash[key] = value
    end

    hash.must_equal(
      "first" => "Michael",
      "third" => "Tanner"
    )
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sparkey-1.0.0 spec/sparkey_spec.rb