Sha256: 46da3963311bb7805aad8686fe9e935ffd450481795242c6264a954fabf0e902

Contents?: true

Size: 937 Bytes

Versions: 6

Compression:

Stored size: 937 Bytes

Contents

require 'fuzzily'
require 'pathname'
require 'yaml'

Database = Pathname.new 'test.sqlite3'

# A test model we'll need as a source of trigrams
class Stuff < ActiveRecord::Base ; end
class StuffMigration < ActiveRecord::Migration
  def self.up
    create_table :stuffs do |t|
      t.string :name
      t.string :data
      t.timestamps
    end
  end

  def self.down
    drop_table :stuffs
  end
end

RSpec.configure do |config|
  config.before(:each) do
    # Setup test database
    ActiveRecord::Base.establish_connection(
      :adapter  => 'sqlite3',
      :database => Database.to_s
    )

    def prepare_trigrams_table
      silence_stream(STDOUT) do
        Class.new(ActiveRecord::Migration).extend(Fuzzily::Migration).up
      end
    end

    def prepare_owners_table
      silence_stream(STDOUT) do
        StuffMigration.up
      end
    end

  end

  config.after(:each) do
    Database.delete if Database.exist?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fuzzily-0.2.1 spec/spec_helper.rb
fuzzily-0.2.0 spec/spec_helper.rb
fuzzily-0.1.0 spec/spec_helper.rb
fuzzily-0.0.3 spec/spec_helper.rb
fuzzily-0.0.2 spec/spec_helper.rb
fuzzily-0.0.1 spec/spec_helper.rb