Sha256: bbbb3964c373d5bdaf32094f85b159748cc8f2e63ee474267cdb628c991a8487

Contents?: true

Size: 672 Bytes

Versions: 11

Compression:

Stored size: 672 Bytes

Contents

require 'sqlite3'
require 'dbi'
require 'active_record'

module Daru::RSpec
  class Account < ActiveRecord::Base
    self.table_name = 'accounts'
  end
end

shared_context 'with accounts table in sqlite3 database' do
  let(:db_name) do
    'daru_test'
  end

  before do
    # just in case
    FileUtils.rm(db_name) if File.file?(db_name)

    SQLite3::Database.new(db_name).tap do |db|
      db.execute "create table accounts(id integer, name varchar, age integer, primary key(id))"
      db.execute "insert into accounts values(1, 'Homer', 20)"
      db.execute "insert into accounts values(2, 'Marge', 30)"
    end
  end

  after do
    FileUtils.rm(db_name)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
daru-0.3 spec/support/database_helper.rb
daru-0.2.2 spec/support/database_helper.rb
daru-0.2.1 spec/support/database_helper.rb
daru-0.2.0 spec/support/database_helper.rb
daru-0.1.6 spec/support/database_helper.rb
daru-0.1.5 spec/support/database_helper.rb
daru-0.1.4.1 spec/support/database_helper.rb
daru-0.1.4 spec/support/database_helper.rb
daru-0.1.3.1 spec/support/database_helper.rb
daru-0.1.3 spec/support/database_helper.rb
daru-0.1.2 spec/support/database_helper.rb