Sha256: 5ce03359d1fe1c54ce4c608f7d2d940bfc8fcd38a4839129959f706bff462c4f

Contents?: true

Size: 909 Bytes

Versions: 7

Compression:

Stored size: 909 Bytes

Contents

require 'spec_helper'

describe Fuzzily::Migration do
  subject { Class.new(ActiveRecord::Migration).extend(described_class) }

  it 'is a proper migration' do
    subject.ancestors.should include(ActiveRecord::Migration)
  end

  it 'applies cleanly' do
    silence_stream(STDOUT) { subject.up }
  end

  it 'rolls back cleanly' do
    silence_stream(STDOUT) { subject.up ; subject.down }
  end

  it 'has a customizable table name' do
    subject.trigrams_table_name = :foobars
    silence_stream(STDOUT) { subject.up }
    expect {
      ActiveRecord::Base.connection.execute('INSERT INTO foobars (score) VALUES (1)')
    }.to_not raise_error
  end

  it 'results in a functional model' do
    silence_stream(STDOUT) { subject.up }
    model_class = Class.new(ActiveRecord::Base)
    model_class.table_name = 'trigrams'
    model_class.create(:trigram => 'abc')
    model_class.count.should == 1
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fuzzily-0.3.3 spec/fuzzily/migration_spec.rb
fuzzily-0.3.2 spec/fuzzily/migration_spec.rb
fuzzily-0.3.1 spec/fuzzily/migration_spec.rb
fuzzily-0.3.0 spec/fuzzily/migration_spec.rb
fuzzily-0.2.4 spec/fuzzily/migration_spec.rb
fuzzily-0.2.3 spec/fuzzily/migration_spec.rb
fuzzily-0.2.2 spec/fuzzily/migration_spec.rb