Sha256: 2ae075d984dd35378e5e883859e6e44fb9b680aad6a0e860fc3d6e87c2d7f183

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require_relative './test_helper'

describe SparaDisk do
  before do
    file_name = File.expand_path('../test.db', __FILE__)
    File.delete(file_name) if File.exists?(file_name)
    @db = SparaDisk.new('test.db')
  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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spara-0.0.1 test/spara_disk_test.rb