Sha256: ccf7dafeda60fe57904fef0faa9cc87b977d0456035909aa2f26f643929936b6

Contents?: true

Size: 1023 Bytes

Versions: 10

Compression:

Stored size: 1023 Bytes

Contents

require_relative "spec_helper"

describe "static_cache_cache plugin" do
  before do
    @db = Sequel.mock
    @db.fetch = [{:id=>1, :name=>'A'}, {:id=>2, :name=>'B'}]
    @c = Class.new(Sequel::Model(@db[:t]))
    def @c.name; 'Foo' end
    @c.columns :id, :name
    @file = "spec/files/static_cache_cache-spec-#{$$}.cache"
  end
  after do
    File.delete(@file) if File.file?(@file)
  end

  it "should allow dumping and loading static cache rows from a cache file" do
    @c.plugin :static_cache_cache, @file
    @db.sqls
    @c.plugin :static_cache
    @db.sqls.must_equal ['SELECT * FROM t']
    @c.all.must_equal [@c.load(:id=>1, :name=>'A'), @c.load(:id=>2, :name=>'B')]

    @c.dump_static_cache_cache

    @db.fetch = []
    c = Class.new(Sequel::Model(@db[:t]))
    def c.name; 'Foo' end
    c.columns :id, :name
    @c.plugin :static_cache_cache, @file
    @db.sqls
    @c.plugin :static_cache
    @db.sqls.must_be_empty
    @c.all.must_equal [@c.load(:id=>1, :name=>'A'), @c.load(:id=>2, :name=>'B')]
  end
end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/static_cache_cache_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/static_cache_cache_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/sequel-5.29.0/spec/extensions/static_cache_cache_spec.rb
sequel-5.29.0 spec/extensions/static_cache_cache_spec.rb
sequel-5.28.0 spec/extensions/static_cache_cache_spec.rb
sequel-5.27.0 spec/extensions/static_cache_cache_spec.rb
tdiary-5.1.0 vendor/bundle/gems/sequel-5.26.0/spec/extensions/static_cache_cache_spec.rb
sequel-5.26.0 spec/extensions/static_cache_cache_spec.rb
sequel-5.25.0 spec/extensions/static_cache_cache_spec.rb
sequel-5.24.0 spec/extensions/static_cache_cache_spec.rb