Sha256: 9cd647419a03e7a695a9fb1a1a9cd94593d7481c26089633be4889e41e78054b

Contents?: true

Size: 911 Bytes

Versions: 6

Compression:

Stored size: 911 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

6 entries across 6 versions & 1 rubygems

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