Skip to content

Commit 0be07a2

Browse files
committed
Fixing activerecord tests, and adding them as default.
To do this: * Database testing was switched to in-memory, resulting in a substantial performance improvement. * Handling for sub-second date precision was added, as fixtures are all inserted within a second. * All activerecord tests are now wrapped in transactions.
1 parent ba8aa02 commit 0be07a2

File tree

15 files changed

+211
-218
lines changed

15 files changed

+211
-218
lines changed

Rakefile

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require 'rdoc/task'
1414

1515
task :default => ["test"]
1616

17-
task :test => ["test:client", "test:provider"]
17+
task :test => ["test:client", "test:provider", "test:activerecord_provider"]
1818

1919
namespace :test do
2020
Rake::TestTask.new('client') do |t|
@@ -75,40 +75,6 @@ if RUBY_VERSION =~ /^1.8/
7575
end
7676
end
7777

78-
task 'test:activerecord_provider' => :create_database
79-
80-
task :environment do
81-
unless defined? OAI_PATH
82-
OAI_PATH = File.dirname(__FILE__) + '/lib/oai'
83-
$LOAD_PATH << OAI_PATH
84-
$LOAD_PATH << File.dirname(__FILE__) + '/test'
85-
end
86-
end
87-
88-
task :drop_database => :environment do
89-
%w{rubygems active_record yaml}.each { |lib| require lib }
90-
require 'activerecord_provider/database/ar_migration'
91-
require 'activerecord_provider/config/connection'
92-
begin
93-
OAIPMHTables.down
94-
rescue
95-
end
96-
end
97-
98-
task :create_database => :drop_database do
99-
OAIPMHTables.up
100-
end
101-
102-
task :load_fixtures => :create_database do
103-
require 'test/activerecord_provider/models/dc_field'
104-
fixtures = YAML.load_file(
105-
File.join('test', 'activerecord_provider', 'fixtures', 'dc.yml')
106-
)
107-
fixtures.keys.sort.each do |key|
108-
DCField.create(fixtures[key])
109-
end
110-
end
111-
11278
Rake::RDocTask.new('doc') do |rd|
11379
rd.rdoc_files.include("lib/**/*.rb", "README.md")
11480
rd.main = 'README.md'

0 commit comments

Comments
 (0)