Sha256: 1bdfb710374e60e38cd46043bde79097457c7eb8e87b0861b5207fa799730160
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require 'spec_helper' include Ramdo describe Store do after(:all) do wrapper = Ramdisk::Factory.get wrapper.list.each do |disk| disk.destroy! end end it 'should create a new store and append data to it' do test_data = 'make me sexy' store = Store.new store.data = test_data expect(IO.read(store.file)).to eq(test_data) expect(store.data).to eq(test_data) end it 'should create a new store with a specific file extension' do extension = '.bin' store = Store.new(extension: extension) expect(File.extname(store.file)).to eq(extension) end it 'should create a new store and write data to it' do test_data = 'make me sexy' store = Store.new IO.write(store.file, test_data) expect(IO.read(store.file)).to eq(test_data) expect(store.data).to eq(test_data) end it 'should be able to truncate any data' do store = Store.new store.data = 'Test' store.truncate expect(File.exist?(store.file)).to be_falsey expect(Dir.exist?(store.dir)).to be_falsey end it 'should use existing RAM disk if available' do wrapper = Ramdisk::Factory.get wrapper.list.each { |disk| disk.destroy! } expect(wrapper.list.length).to eq(0) store_1 = Store.new expect(wrapper.list.length).to eq(1) store_2 = Store.new expect(wrapper.list.length).to eq(1) end it 'should allow to define a specific file extension' do store = Store.new(extension: 'png') store.data = 'make me sexy' expect(File.extname(store.file)).to eq('.png') store = Store.new(extension: '.png') store.data = 'make me sexy' expect(File.extname(store.file)).to eq('.png') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ramdo-0.2.1 | spec/store_spec.rb |