helper.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. require 'rubygems'
  2. require 'test/unit'
  3. require 'shoulda'
  4. require 'active_support/time'
  5. require 'active_record'
  6. require 'active_record/fixtures'
  7. require 'action_view'
  8. require 'meta_search'
  9. FIXTURES_PATH = File.join(File.dirname(__FILE__), 'fixtures')
  10. Time.zone = 'Eastern Time (US & Canada)'
  11. ActiveRecord::Base.establish_connection(
  12. :adapter => defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3',
  13. :database => ':memory:'
  14. )
  15. dep = defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies : ::Dependencies
  16. dep.autoload_paths.unshift FIXTURES_PATH
  17. ActiveRecord::Base.silence do
  18. ActiveRecord::Migration.verbose = false
  19. load File.join(FIXTURES_PATH, 'schema.rb')
  20. end
  21. ActiveRecord::Fixtures.create_fixtures(FIXTURES_PATH, ActiveRecord::Base.connection.tables)
  22. I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'locales', '*.yml')]
  23. $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
  24. $LOAD_PATH.unshift(File.dirname(__FILE__))
  25. class Test::Unit::TestCase
  26. def self.context_a_search_against(name, object, &block)
  27. context "A search against #{name}" do
  28. setup do
  29. @s = object.search
  30. end
  31. merge_block(&block) if block_given?
  32. end
  33. end
  34. end