Sha256: d9f2ab8841329ffc2b777b7eb4032ae98cf32a4869e9c0461d1db202bf494215

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require_relative 'test_helper'

describe SparaDisk do
  before do
    @db = SparaDisk.new('test.db')
    @db.clean!
  end

  it '#initialize' do
    @db.must_be_instance_of SparaDisk
  end

  it '#set' do
    @db.set('defined', 'i am not nil').must_equal 'i am not nil'
    @db.get('defined').must_equal 'i am not nil'
  end

  describe SparaDisk do
    before { @db.set('defined', 'i am not nil') }

    it '#get' do
      @db.get('defined').must_equal 'i am not nil'
      @db.get('undefined').must_equal nil
    end

    it '#del' do
      @db.del('defined').must_equal 'i am not nil'
      @db.get('defined').must_equal nil
    end

    it '#keys' do
      @db.keys.must_be_instance_of Array
      @db.keys.must_include 'defined'
      @db.keys.wont_include 'undefined'
    end

    it '#vals' do
      @db.vals.must_be_instance_of Array
      @db.vals.must_include 'i am not nil'
      @db.vals.wont_include nil
    end

    it '#all' do
      @db.all.must_be_instance_of Hash
      @db.all.keys.must_include 'defined'
      @db.all.keys.wont_include 'undefined'
      @db.all.values.must_include 'i am not nil'
      @db.all.values.wont_include nil
    end

    it '#clean!' do
      @db.clean!
      @db.keys.must_be_empty
      @db.vals.must_be_empty
      @db.all.must_equal({})
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spara-0.0.2 test/spara_disk_test.rb