tasks/spec.rake in sequel-rails-0.1.8 vs tasks/spec.rake in sequel-rails-0.4.0.pre
- old
+ new
@@ -1,38 +1,72 @@
-spec_defaults = lambda do |spec|
- spec.pattern = 'spec/**/*_spec.rb'
- spec.libs << 'lib' << 'spec'
- spec.spec_opts << '--options' << 'spec/spec.opts'
-end
-
begin
- require 'spec/rake/spectask'
+ require 'rspec/core/rake_task'
- Spec::Rake::SpecTask.new(:spec, &spec_defaults)
-rescue LoadError
- task :spec do
- abort 'rspec is not available. In order to run spec, you must: gem install rspec'
- end
-end
+ desc "Run RSpec code example (default to only PostgreSQL)"
+ RSpec::Core::RakeTask.new('spec')
-begin
- require 'rcov'
- require 'spec/rake/verify_rcov'
+ namespace :spec do
+ def clean_env
+ [
+ "TEST_ADAPTER",
+ "TEST_DATABASE",
+ "TEST_OWNER",
+ "TEST_USERNAME",
+ "TEST_PASSWORD",
+ "TEST_ENCODING",
+ ].each do |name|
+ ENV[name] = nil
+ end
+ end
- Spec::Rake::SpecTask.new(:rcov) do |rcov|
- spec_defaults.call(rcov)
- rcov.rcov = true
- rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
- end
+ desc "Run specs for postgresql adapter"
+ task :postgresql do
+ clean_env
+ Rake::Task["spec"].reenable
+ ENV["TEST_ADAPTER"] = "postgresql"
+ ENV["TEST_ENCODING"] = "unicode"
+ Rake::Task["spec"].invoke
+ end
- RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
- rcov.threshold = 100
+ desc "Run specs for mysql adapter"
+ task :mysql do
+ clean_env
+ Rake::Task["spec"].reenable
+ ENV["TEST_ADAPTER"] = "mysql"
+ ENV["TEST_ENCODING"] = "utf8"
+ Rake::Task["spec"].invoke
+ end
+
+ desc "Run specs for mysql2 adapter"
+ task :mysql2 do
+ clean_env
+ Rake::Task["spec"].reenable
+ ENV["TEST_ADAPTER"] = "mysql2"
+ ENV["TEST_ENCODING"] = "utf8"
+ Rake::Task["spec"].invoke
+ end
+
+ desc "Run specs for sqlite3 adapter"
+ task :sqlite3 do
+ clean_env
+ Rake::Task["spec"].reenable
+ ENV["TEST_ADAPTER"] = "sqlite3"
+ ENV["TEST_DATABASE"] = ":memory:"
+ Rake::Task["spec"].invoke
+ end
+
+ desc "Run specs for all adapters"
+ task :all do
+ Rake::Task["spec:postgresql"].invoke
+ Rake::Task["spec:mysql"].invoke
+ Rake::Task["spec:mysql2"].invoke
+ Rake::Task["spec:sqlite3"].invoke
+ end
end
+
+ task :default => "spec:all"
+
rescue LoadError
- %w[ rcov verify_rcov ].each do |name|
- task name do
- abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
- end
+ task :spec do
+ abort 'rspec is not available. In order to run spec, you must: bundle install'
end
end
-
-task :default => :spec