Sha256: fc31ee63de6a84a493dd9244489c21493ac5d03a8cc016c98c145d943173d3e8
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
require 'spec_helper' module Viiite class BDB describe Cached, "#dataset" do let(:folder) { File.join(fixtures_folder, '.cache') } let(:bdb) { Cached.new(delegate, folder) } subject { bdb.dataset(name) } before(:each){ FileUtils.rm_rf(folder) } describe "when the benchmark exists" do let(:delegate){ @delegate ||= Object.new.extend Module.new{ attr_reader :called def benchmark(name) @called = true Alf::Relation[{:name => name}] end alias :dataset :benchmark } } let(:name) { "Array/bench_sort" } let(:cached){ File.join(folder, "Array", "bench_sort.rash") } after{ File.exists?(cached).should be_true FileUtils.rm_rf(cached) } describe 'when the cache file does not exist yet' do before{ File.exists?(cached).should be_false } specify{ subject.to_a.should eq([{:name => 'Array/bench_sort'}]) delegate.called.should be_true } end describe 'when the cache file already exists' do before{ FileUtils.mkdir_p(File.dirname(cached)) File.open(cached, "w") do |io| io << "{:name => 'Array/bench_sort'}" end } specify{ subject.to_a.should eq([{:name => 'Array/bench_sort'}]) delegate.called.should be_false } end end describe "when the benchmark does not exist" do let(:delegate){ Object.new.extend Module.new{ def benchmark(name); raise Alf::NoSuchDatasetError; end alias :dataset :benchmark } } let(:name){ "NotA/Class/bench_non_existing" } specify{ lambda{subject}.should raise_error(Alf::NoSuchDatasetError) } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
viiite-0.2.0 | spec/unit/bdb/cached/test_dataset.rb |