Sha256: f367559d2173ab666e0fcc3b4c48fbd163446c32969d5996f5787b71b93ee97d

Contents?: true

Size: 1.62 KB

Versions: 9

Compression:

Stored size: 1.62 KB

Contents

require 'autotest'
require 'active_support'

class Autotest::Sqlserver < Autotest

  def initialize
    super
    
    odbc_mode = true
    
    clear_mappings
    
    self.libs = [
      "lib",
      "test",
      "test/connections/native_sqlserver#{odbc_mode ? '_odbc' : ''}",
      "../../../rails/activerecord/test/"
    ].join(File::PATH_SEPARATOR)
    
    @test_sqlserver_file_match = %r%^test/cases/.*_test_sqlserver\.rb$%
    
    add_exception %r%^\./(?:autotest)%
    add_exception %r%^\./(.*LICENSE|debug.log|README.*|CHANGELOG.*)$%i
    
    # Any *_test_sqlserver file saved runs that file
    self.add_mapping @test_sqlserver_file_match do |filename, matchs|
      filename
    end
    
    # If any the adapter changes
    # the test directory, ofcourse having _test.rb at the end, will run that test. 
    self.add_mapping(%r%^lib/(.*)\.rb$%) do |filename, matchs|
      files_matching @test_sqlserver_file_match
    end
    
    # If any core file like the test helper, connections, fixtures, migratinos,
    # and other support files, then run all matching *_test_sqlserver files.
    add_mapping %r%^test/(cases/(sqlserver_helper)\.rb|connections|fixtures|migrations|schema/.*)% do
      files_matching @test_sqlserver_file_match
    end
    
  end
  
  # Have to use a custom reorder method since the normal :alpha for Autotest would put the 
  # files with ../ in the path before others.
  def reorder(files_to_test)
    ar_tests, sqlsvr_tests = files_to_test.partition { |k,v| k.starts_with?('../../../') }
    ar_tests.sort! { |a,b| a[0] <=> b[0] }
    sqlsvr_tests.sort! { |a,b| a[0] <=> b[0] }
    sqlsvr_tests + ar_tests
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
activerecord-sqlserver-adapter-2.3.8 autotest/sqlserver.rb
activerecord-sqlserver-adapter-2.3.7 autotest/sqlserver.rb
activerecord-sqlserver-adapter-2.3.6 autotest/sqlserver.rb
activerecord-sqlserver-adapter-2.3.5 autotest/sqlserver.rb
activerecord-sqlserver-adapter-2.3.4 autotest/sqlserver.rb
activerecord-sqlserver-adapter-2.3.3 autotest/sqlserver.rb
activerecord-sqlserver-adapter-2.3.2 autotest/sqlserver.rb
activerecord-sqlserver-adapter-2.3.1 autotest/sqlserver.rb
activerecord-sqlserver-adapter-2.3 autotest/sqlserver.rb