Permalink
Browse files

Simplify spec run setup and allow running spec against specific adapt…

…er separately
  • Loading branch information...
1 parent 38995c4 commit 46273f433a4a5e5e7a272759df18e30894489f3a @JonathanTron JonathanTron committed Jan 1, 2013
View
@@ -1,8 +1,8 @@
language: ruby
rvm:
- 1.9.3
-gemfile: gemfiles/Gemfile.ci
env:
- "TEST_ADAPTER=postgresql TEST_OWNER=postgres TEST_USERNAME=postgres"
- - "TEST_ADAPTER=mysql TEST_USERNAME=root"
+ - "TEST_ADAPTER=mysql TEST_USERNAME=root TEST_ENCODING=utf8"
+ - "TEST_ADAPTER=mysql2 TEST_USERNAME=root TEST_ENCODING=utf8"
- "TEST_ADAPTER=sqlite3 TEST_DATABASE=':memory:'"
View
15 Gemfile
@@ -2,4 +2,17 @@ source "http://rubygems.org"
gemspec
-gem "rspec-rails", require: false
+# MRI/Rubinius Adapter Dependencies
+platform :ruby do
+ gem "pg"
+ gem "mysql"
+ gem "mysql2"
+ gem "sqlite3"
+end
+
+# JRuby Adapter Dependencies
+platform :jruby do
+ gem "jdbc-sqlite3"
+ gem "jdbc-mysql"
+ gem "jdbc-postgres"
+end
View
@@ -1,7 +0,0 @@
-source "http://rubygems.org"
-
-gemspec path: "../"
-
-gem "rspec-rails", require: false
-gem "mysql2"
-gem "sqlite3"
View
@@ -23,8 +23,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("railties", ["~> 3.2.0"])
s.add_development_dependency "rake", ">= 0.8.7"
- s.add_development_dependency "rspec-rails", "~> 2.7.0"
+ s.add_development_dependency "rspec", "~> 2.7.0"
s.add_development_dependency "combustion", "~> 0.3.1"
s.add_development_dependency "generator_spec", "~> 0.8.7"
- s.add_development_dependency "pg"
end
@@ -1,7 +1,7 @@
test:
- adapter: <%= ENV["TEST_ADAPTER"] || "postgresql" %>
- database: <%= ENV["TEST_DATABASE"] || "sequel_rails_test" %>
- owner: <%= ENV["TEST_OWNER"] || ENV["USER"] %>
- username: <%= ENV["TEST_USERNAME"] || ENV["USER"] %>
- password: <%= ENV["TEST_PASSWORD"] %>
- encoding: <%= ENV["TEST_ENCODING"] || "unicode" %>
+ adapter: "<%= ENV["TEST_ADAPTER"] || "postgresql" %>"
+ database: "<%= ENV["TEST_DATABASE"] || "sequel_rails_test" %>"
+ owner: "<%= ENV["TEST_OWNER"] || ENV["USER"] %>"
+ username: "<%= ENV["TEST_USERNAME"] || ENV["USER"] %>"
+ password: "<%= ENV["TEST_PASSWORD"] %>"
+ encoding: "<%= ENV["TEST_ENCODING"] || "unicode" %>"
@@ -17,7 +17,7 @@ def set_logger(logger)
User.all
wait
@logger.logged(:debug).should have(1).line
- @logger.logged(:debug).last.should =~ /SELECT \* FROM "users"/
+ @logger.logged(:debug).last.should =~ /SELECT \* FROM ("|`)users("|`)/
end
it "does not log query when logger level is not debug" do
View
@@ -6,8 +6,6 @@
# Combustion initialization has to happend before loading rspec/rails
Combustion.initialize! "sequel_rails"
-require "rspec/rails"
-
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
View
@@ -1,13 +1,72 @@
begin
require 'rspec/core/rake_task'
+ desc "Run RSpec code example (default to only PostgreSQL)"
RSpec::Core::RakeTask.new('spec')
- task :default => :spec
+ 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
+
+ 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
+
+ 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
task :spec do
abort 'rspec is not available. In order to run spec, you must: bundle install'
end
end
-

0 comments on commit 46273f4

Please sign in to comment.