Several of my unit tests run queries against SphinxSE. Since Rails
creates the test DB by dumping the dev DB schema, my SphinxSE queries
aren't run against the test DB.

There seems to be no way to hook into the test:clone_structure task,
so I thought that I'll just have the appropriate unit tests include
this:

module SphinxTest
  @@index = 'ct_test_index'
  mattr_accessor :index, :host, :port

  self << class
    def included(klass)
       alter_test_table unless
    end

    #MySQL specific
    def alter_test_table
      return unless ActiveRecord::Base.connection.table_exists?
(Query::TABLE_SPHINX)

      create = ActiveRecord::Base.connection.select_value "show create
table #{Query::TABLE_SPHINX}"
      if @@index && md = create.match %r|sphinx://([-.\w]+):(\d+)?/[-
\w]+|
        host = @@host || md[0]
        port = @@port || md[1]

        alter = %|alter table #{Query::TABLE_SPHINX}
connection="sphinx://#{host}:#{port}/#{@@index}"|
        ActiveRecord::Base.connection.execute alter
      end
    end
  end
end

does anyone know of way to do this from outside my unit tests?

On a side note, assuming portability was an issue, there seems to be
know way to get the TableDefinition from the connection. Is this
really the case?

Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to