Sha256: d7c65c1e6babe5023e6e179fae352d0502d695c626bdf2069de1754c9b848834

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require_relative 'test_helper'

describe SparaMem do
  before do
    @db = SparaMem.new
    @db.clean!
  end

  it '#initialize' do
    @db.must_be_instance_of SparaMem
  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 SparaMem 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_mem_test.rb