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