diff --git a/.travis.yml b/.travis.yml index 0a143c549..9f7130527 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,11 @@ +script: spec/ci.sh rvm: - 1.8.7 - ree - 1.9.2 - jruby - rbx +env: + - DB=sqlite3 + - DB=mysql + - DB=postgresql \ No newline at end of file diff --git a/Rakefile b/Rakefile index 791dad628..49f947074 100644 --- a/Rakefile +++ b/Rakefile @@ -11,4 +11,3 @@ RSpec::Core::RakeTask.new do |t| end Bundler::GemHelper.install_tasks - diff --git a/spec/ci.sh b/spec/ci.sh new file mode 100644 index 000000000..3c769d881 --- /dev/null +++ b/spec/ci.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +cp spec/database.yml.example spec/database.yml && bundle install && bundle exec rake prepare_ci_env db:create db:migrate && bundle exec rake spec diff --git a/spec/database.yml.sample b/spec/database.yml.sample index 5487bafc3..8ef808b43 100644 --- a/spec/database.yml.sample +++ b/spec/database.yml.sample @@ -3,7 +3,7 @@ sqlite3: database: acts_as_taggable_on.sqlite3 mysql: - adapter: mysql + adapter: mysql2 hostname: localhost username: root password: diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d4d6d00fd..69d6dcf3a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,14 +30,17 @@ def freq end end -ENV['DB'] ||= 'sqlite3' - +db_name = ENV['DB'] || 'sqlite3' database_yml = File.expand_path('../database.yml', __FILE__) + if File.exists?(database_yml) - active_record_configuration = YAML.load_file(database_yml)[ENV['DB']] + active_record_configuration = YAML.load_file(database_yml) + + ActiveRecord::Base.configurations = active_record_configuration - ActiveRecord::Base.establish_connection(active_record_configuration) + ActiveRecord::Base.establish_connection(db_name) ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log")) + ActiveRecord::Base.default_timezone = :utc ActiveRecord::Base.silence do ActiveRecord::Migration.verbose = false