Skip to content

Commit 9d314d7

Browse files
committed
Changing trunk around to run tests similar to what rails3 branch has.
1 parent e1c79ea commit 9d314d7

File tree

3 files changed

+16
-57
lines changed

3 files changed

+16
-57
lines changed

RUNNING_UNIT_TESTS

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,13 @@ assumes you have a DSN setup that matches the name of the default database names
1111

1212
== Requirements
1313

14-
The following gems need to be installed. Make sure you have gems.github.com as a
15-
source. Info here. http://gems.github.com/
16-
17-
We use echoe for packagemanagement to rubyforge. Not needed really for the tests
18-
but since we need it... you need to install it.
19-
20-
* gem install echoe
21-
* gem install thoughtbot-shoulda -s http://gems.github.com
14+
* gem install shoulda
2215
* gem install mocha
2316

24-
The tests of this adapter depend on the existence of rails checkout. All the tests
25-
defined by rails are re-used. For this to work the following directory structure
26-
is assumed to exist:
27-
28-
#{RAILS_ROOT}/vendor/plugins/adapters/sqlserver
29-
#{RAILS_ROOT}/vendor/rails/activerecord/test
17+
The tests of this adapter depend on the existence of rails checkout. Make sure
18+
to checkout remotes/origin/2-3-stable, then make sure to export RAILS_SOURCE to
19+
the full path of that repo.
3020

3121
Define a user named 'rails' in SQL Server with all privileges granted for the
3222
test databases. Use an empty password for said user.
3323

34-
35-
== Running with Rake
36-
37-
The easiest way to run the unit tests is through Rake. Either run "rake test" which
38-
defaults to ODBC mode or being mode specific using either "rake sqlserver:test:adonet"
39-
or "rake sqlserver:test:odbc". For more information, checkout the full array of rake tasks
40-
with "rake -T"
41-
42-
Rake can be found at http://rake.rubyforge.org
43-
44-
45-
== Running with Autotest
46-
47-
Using autotest is easy, just run "autotest" and the tests will run continually in the
48-
same order as the rake test command. By default autotest will use ODBC connection. If
49-
you want to change this you can edit the autotest/sqlserver.rb file and set odbc_mode
50-
to false.
51-
52-
Lastly, you can run autotest on just the adapter specific tests with "autotest sqlserver".
53-
This will continuously run ONLY the SQL Sever specific behavior tests which are much
54-
quicker to run than the entire active record test suite.
55-
56-
57-
== Running by hand
58-
59-
Unit tests are located in test directory. If you only want to run a single test suite,
60-
you can do so with:
61-
62-
rake test_sqlserver TEST=base_test.rb
63-
64-
That'll run the base suite using the SQLServer-Ruby adapter.
65-

Rakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ namespace :sqlserver do
1212
Rake::TestTask.new(mode) do |t|
1313
t.libs << "test"
1414
t.libs << "test/connections/native_sqlserver#{mode == 'adonet' ? '' : "_#{mode}"}"
15-
t.libs << "../../../rails/activerecord/test/"
16-
t.test_files = (
15+
t.libs << "#{ENV['RAILS_SOURCE']}/activerecord/test"
16+
t.test_files = \
1717
Dir.glob("test/cases/**/*_test_sqlserver.rb").sort +
18-
Dir.glob("../../../rails/activerecord/test/**/*_test.rb").sort )
18+
Dir.glob("#{ENV['RAILS_SOURCE']}/activerecord/test/cases/**/*_test.rb").sort
1919
t.verbose = true
2020
end
2121

test/cases/sqlserver_helper.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
2+
SQLSERVER_TEST_ROOT = File.expand_path(File.join(File.dirname(__FILE__),'..'))
3+
SQLSERVER_ASSETS_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'assets'))
4+
SQLSERVER_FIXTURES_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'fixtures'))
5+
SQLSERVER_MIGRATIONS_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'migrations'))
6+
SQLSERVER_SCHEMA_ROOT = File.expand_path(File.join(SQLSERVER_TEST_ROOT,'schema'))
7+
ACTIVERECORD_TEST_ROOT = File.expand_path(File.join(ENV['RAILS_SOURCE'],'activerecord','test'))
8+
19
require 'rubygems'
210
require 'shoulda'
311
require 'mocha'
412
[ File.expand_path(File.join(File.dirname(__FILE__),'..','..','test')),
513
File.expand_path(File.join(File.dirname(__FILE__),'..','..','test','connections','native_sqlserver_odbc')),
6-
File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','..','..','rails','activerecord','test'))
14+
File.expand_path(File.join(ENV['RAILS_SOURCE'],'activerecord','test'))
715
].each{ |lib| $:.unshift(lib) unless $:.include?(lib) } if ENV['TM_DIRECTORY']
816
require 'cases/helper'
917
require 'models/topic'
1018
require 'active_record/version'
1119

12-
SQLSERVER_TEST_ROOT = File.expand_path(File.join(File.dirname(__FILE__),'..'))
13-
SQLSERVER_ASSETS_ROOT = SQLSERVER_TEST_ROOT + "/assets"
14-
SQLSERVER_FIXTURES_ROOT = SQLSERVER_TEST_ROOT + "/fixtures"
15-
SQLSERVER_MIGRATIONS_ROOT = SQLSERVER_TEST_ROOT + "/migrations"
16-
SQLSERVER_SCHEMA_ROOT = SQLSERVER_TEST_ROOT + "/schema"
17-
ACTIVERECORD_TEST_ROOT = File.expand_path(SQLSERVER_TEST_ROOT + "/../../../../rails/activerecord/test/")
18-
1920
ActiveRecord::Migration.verbose = false
2021

2122
# Defining our classes in one place as well as soem core tests that need coercing date/time types.

0 commit comments

Comments
 (0)