Sha256: e75aa6c4c8bd19653cca3404ac3a15b944f41b7172fe4458adee6c7905828eef

Contents?: true

Size: 1.62 KB

Versions: 18

Compression:

Stored size: 1.62 KB

Contents

require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")

describe "schema_caching extension" do
  before do
    @db = Sequel.mock.extension(:schema_caching)
    @schemas = {'"table"'=>[[:column, {:db_type=>"integer", :default=>"nextval('table_id_seq'::regclass)", :allow_null=>false, :primary_key=>true, :type=>:integer, :ruby_default=>nil}]]}
    @filename = "spec/files/test_schema_#$$.dump" 
    @db.instance_variable_set(:@schemas, @schemas)
  end
  after do
    File.delete(@filename) if File.exist?(@filename)
  end

  it "Database#dump_schema_cache should dump cached schema to the given file" do
    File.exist?(@filename).should == false
    @db.dump_schema_cache(@filename)
    File.exist?(@filename).should == true
    File.size(@filename).should > 0
  end

  it "Database#load_schema_cache should load cached schema from the given file dumped by #dump_schema_cache" do
    @db.dump_schema_cache(@filename)
    db = Sequel::Database.new.extension(:schema_caching)
    db.load_schema_cache(@filename)
    @db.instance_variable_get(:@schemas).should == @schemas
  end

  it "Database#dump_schema_cache? should dump cached schema to the given file unless the file exists" do
    File.open(@filename, 'wb'){|f|}
    File.size(@filename).should == 0
    @db.dump_schema_cache?(@filename)
    File.size(@filename).should == 0
  end

  it "Database#load_schema_cache? should load cached schema from the given file if it exists" do
    db = Sequel::Database.new.extension(:schema_caching)
    File.exist?(@filename).should == false
    db.load_schema_cache?(@filename)
    db.instance_variable_get(:@schemas).should == {}
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
sequel-4.22.0 spec/extensions/schema_caching_spec.rb
sequel-4.21.0 spec/extensions/schema_caching_spec.rb
sequel-4.20.0 spec/extensions/schema_caching_spec.rb
sequel-4.19.0 spec/extensions/schema_caching_spec.rb
sequel-4.18.0 spec/extensions/schema_caching_spec.rb
sequel-4.17.0 spec/extensions/schema_caching_spec.rb
sequel-4.16.0 spec/extensions/schema_caching_spec.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/sequel-4.15.0/spec/extensions/schema_caching_spec.rb
sequel-4.15.0 spec/extensions/schema_caching_spec.rb
sequel-4.14.0 spec/extensions/schema_caching_spec.rb
sequel-4.13.0 spec/extensions/schema_caching_spec.rb
sequel-4.12.0 spec/extensions/schema_caching_spec.rb
sequel-4.11.0 spec/extensions/schema_caching_spec.rb
sequel-4.10.0 spec/extensions/schema_caching_spec.rb
sequel-4.9.0 spec/extensions/schema_caching_spec.rb
sequel-4.8.0 spec/extensions/schema_caching_spec.rb
sequel-4.7.0 spec/extensions/schema_caching_spec.rb
sequel-4.6.0 spec/extensions/schema_caching_spec.rb