Sha256: b65d86dbf09884b8c76b3b7ce48d864384b5d256d99edb451deeab301f56c29f

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe ActiveWrapper::Db do
  
  before(:each) do
    $db, $log, $mail = ActiveWrapper.setup(
      :base => SPEC + '/example_project',
      :env => 'test'
    )
    $db.drop_db
    $db.create_db
  end
  
  it "should establish a connection" do
    $db.disconnect!
    $db.establish_connection
    $db.connected?.should == true
  end

  it "should create a database" do
    $db.current_database.should == 'active_wrapper_test'
  end

  it "should drop a database" do
    $db.drop_db
    $db.current_database.should == nil
  end
  
  it "should migrate a database" do
    $db.migrate
    $db.execute('insert into tests () values ()')
    $db.execute('select * from tests').num_rows.should == 1
  end
  
  it "should migrate reset a database" do
    $db.migrate
    $db.execute('insert into tests () values ()')
    $db.migrate_reset
    $db.execute('select * from tests').num_rows.should == 0
  end
  
  it "should generate a migration" do
    $db.generate_migration 'another_test'
    path = SPEC + "/example_project/db/migrate/002_another_test.rb"
    File.exists?(path).should == true
    FileUtils.rm_f path
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
winton-active_wrapper-0.1.7 spec/active_wrapper/db_spec.rb
winton-active_wrapper-0.1.8 spec/active_wrapper/db_spec.rb
winton-active_wrapper-0.1.9 spec/active_wrapper/db_spec.rb
winton-active_wrapper-0.2.0 spec/active_wrapper/db_spec.rb
active_wrapper-0.2.1 spec/active_wrapper/db_spec.rb
active_wrapper-0.2.0 spec/active_wrapper/db_spec.rb