Running spec tests from ruby code

I’m trying to do some more custom testing with rails and I’m trying to
write a rake task that will perform this testing. What I need the task
to do is load the rails environment, run some MySql scripts and then run
some spec files. However, I’m not sure on how to go about running spec
files from within ruby code.

I’ve posted a question
on stack over flow but haven’t gotten much response. I’ve copied my
current code and error I’m running into below (its also on stack over
flow). Thanks for any help guys.

require “spec/autorun”
require"spec"
require “spec/rake/spectask”
RAILS_ENV = ‘test’

namespace :run_all_tests do
desc “Run all of your tests”

puts “Reseting test database…”
system “mysql --user=root --password=dev <
C:\Brian\Work\Personal\BrianSite\database\BrianSite_test_CreateScript.sql”
puts “Filling database tables with test data…”
system “mysql --user=root --password=dev <
C:\Brian\Work\Personal\BrianSite\database\Fill_Test_Tables.sql”

puts “Starting rails test environment…”
task :run => :environment do
puts “RAILS_ENV is #{RAILS_ENV}”
# Run rspec test files here…
require “spec/models/blog_spec.rb”
end
end

C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:283:in
fi les_to_load’: File or directory not found: run_all_tests:run
(RuntimeError) from
C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options.
rb:275:ineach’ from
C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options.
rb:275:in files_to_load’ from
C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options.
rb:133:inrun_examples’ from
C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner.rb:61:in run’
from C:/Ruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner.rb:45:in
autorun’ from C:/Ruby/bin/rake:19