Sha256: 914af59c735adf765b27684f361957e50f0e57d7e2dfbf58ce4b9bea5e7a04a4

Contents?: true

Size: 966 Bytes

Versions: 1

Compression:

Stored size: 966 Bytes

Contents

require 'test_helper'

class SchemaDumperTest < Test::Unit::TestCase
  include TestHelper

  def test_dump
    ActiveRecord::Schema.define do
      add_table_comment :sample, "a table comment"
      add_column_comment :sample, :field1, "a \"comment\" \\ that ' needs; escaping''"
      add_column :sample, :field3, :string, :null => false, :comment => "third column comment"
    end
    dest = StringIO.new
    ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, dest)
    dest.rewind
    result = dest.read
    expected = <<EOS
ActiveRecord::Schema.define(:version => 1) do

  create_table "sample", :force => true, :comment => "a table comment" do |t|
    t.string  "field1",                 :comment => "a \"comment\" \\ that ' needs; escaping''"
    t.integer "field2"
    t.string  "field3", :null => false, :comment => "third column comment"
  end

end
EOS
    assert_match /#{Regexp.escape expected}/, result
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
migration_comments-0.1.1 test/schema_dumper_test.rb