Sha256: 0f4834e3274682735777e3464c8ccd564ad62d43911fc9fbb9941112e3f87a40

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

require 'turntables'
require 'turntables/db_registry'

# This test to see if simple operations work with the application (so that the
# minimal guarantee of the gem is respected - to at least create the schema
# specified).
describe Turntable do

  def delete_db
    if File.exists? "default.db"
      File.delete("default.db")
    end
  end

  before(:each) do
    @turntable = Turntable.new
    @relpath   = File.expand_path(File.dirname(__FILE__))
    @datapath  = "#{@relpath}/data"
   
    # datapath/ and 
    #   malformed-dir
    #   sql-just-monolithic
    #   sql-just-sequential
    #   sql-seq-and-mono
  end

  after(:each) do 
    DbRegistry.instance.close!
    delete_db
    DbRegistry.instance.open!
  end

  after(:all) do
    delete_db
  end

  it "should raise no errors on a pure sequential repo" do
    @turntable.register("#{@datapath}/sql-just-sequential")
    expect{@turntable.make!}.to_not raise_error
  end

  it "should raise no errors on a pure monolithic repo" do
    @turntable.register("#{@datapath}/sql-just-monolithic")
    expect{@turntable.make!}.to_not raise_error
  end

  it "should raise no errors on a mixed repo" do
    @turntable.register("#{@datapath}/sql-seq-and-mono")
    expect{@turntable.make!}.to_not raise_error
  end

  it "should raise an error on a malformed dir" do
    @turntable.register("#{@datapath}/malformed-dir")
    expect{@turntable.make!}.to raise_error
  end

  it "should raise an error on non existant path" do
    @turntable.register("WARGABLLGABHLGABL")
    expect{@turntable.make!}.to raise_error
  end

  it "should create the database at a *specified* location" do
    db_location = "#{@datapath}/locations/herp.db"
    @turntable.register("#{@datapath}/sql-seq-and-mono")
    @turntable.make_at!(db_location)
    (File.exists? db_location).should be_true
    File.delete(db_location)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
turntables-1.0.3 spec/turntable_spec.rb
turntables-1.0.1 spec/turntable_spec.rb