diff --git a/.travis.yml b/.travis.yml index 785c6d6..9c6a604 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,12 +12,14 @@ rvm: - 1.9 env: - - RAILS=4-2-stable DB=mongodb + - RAILS=4-2-stable DB=mongoid4 + - RAILS=4-2-stable DB=mongoid5 - RAILS=4-2-stable DB=sqlite3 - RAILS=4-2-stable DB=mysql - RAILS=4-2-stable DB=postgres - - RAILS=4-1-stable DB=mongodb + - RAILS=4-1-stable DB=mongoid4 + - RAILS=4-1-stable DB=mongoid5 - RAILS=4-1-stable DB=sqlite3 - RAILS=4-1-stable DB=mysql - RAILS=4-1-stable DB=postgres @@ -37,7 +39,9 @@ env: matrix: include: - rvm: 2.3.0 - env: RAILS=master DB=mongodb + env: RAILS=master DB=mongoid5 + - rvm: 2.3.0 + env: RAILS=master DB=mongoid4 - rvm: 2.3.0 env: RAILS=master DB=sqlite3 - rvm: 2.3.0 @@ -46,7 +50,9 @@ matrix: env: RAILS=master DB=postgres - rvm: 2.2.4 - env: RAILS=master DB=mongodb + env: RAILS=master DB=mongoid5 + - rvm: 2.2.4 + env: RAILS=master DB=mongoid4 - rvm: 2.2.4 env: RAILS=master DB=sqlite3 - rvm: 2.2.4 @@ -55,7 +61,8 @@ matrix: env: RAILS=master DB=postgres allow_failures: - - env: RAILS=master DB=mongodb + - env: RAILS=master DB=mongoid5 + - env: RAILS=master DB=mongoid4 - env: RAILS=master DB=sqlite3 - env: RAILS=master DB=mysql - env: RAILS=master DB=postgres diff --git a/Gemfile b/Gemfile index 260cb7a..2d050f7 100644 --- a/Gemfile +++ b/Gemfile @@ -42,10 +42,14 @@ else end end -if ENV['DB'] =~ /mongodb/ +if ENV['DB'] =~ /mongoid4/ gem 'mongoid', '~> 4.0.0', require: false end +if ENV['DB'] =~ /mongoid5/ + gem 'mongoid', '~> 5.0.0', require: false +end + # Removed from Ruby 2.2 but needed for testing Rails 3.x. group :test do gem 'test-unit', '~> 3.0' if RUBY_VERSION >= '2.2' diff --git a/Rakefile b/Rakefile index fd8f610..215d944 100644 --- a/Rakefile +++ b/Rakefile @@ -17,7 +17,7 @@ RSpec::Core::RakeTask.new(:mongoid) do |rspec| end task :default do - if ENV['DB'] =~ /mongodb/ + if ENV['DB'] =~ /mongoid/ Rake::Task["mongoid"].invoke else Rake::Task["spec"].invoke diff --git a/spec/mongoid/support/mongoid.yml b/spec/mongoid/support/mongoid.yml index 9995694..dd169b0 100644 --- a/spec/mongoid/support/mongoid.yml +++ b/spec/mongoid/support/mongoid.yml @@ -1,4 +1,9 @@ test: + clients: + default: + database: ransack_mongoid_test + hosts: + - localhost:27017 sessions: default: database: ransack_mongoid_test diff --git a/spec/mongoid/support/schema.rb b/spec/mongoid/support/schema.rb index f4c89a6..6c15768 100644 --- a/spec/mongoid/support/schema.rb +++ b/spec/mongoid/support/schema.rb @@ -1,6 +1,8 @@ require 'mongoid' Mongoid.load!(File.expand_path("../mongoid.yml", __FILE__), :test) +Mongo::Logger.logger.level = Logger::WARN if defined?(Mongo) +Mongoid.purge! class Person include Mongoid::Document diff --git a/spec/mongoid_spec_helper.rb b/spec/mongoid_spec_helper.rb index ac36982..faffc0a 100644 --- a/spec/mongoid_spec_helper.rb +++ b/spec/mongoid_spec_helper.rb @@ -30,9 +30,14 @@ RSpec.configure do |config| config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior' config.before(:suite) do - message = "Running Ransack specs with #{Mongoid.default_session.inspect - }, Mongoid #{Mongoid::VERSION}, Moped #{Moped::VERSION - }, Origin #{Origin::VERSION} and Ruby #{RUBY_VERSION}" + if ENV['DB'] == 'mongoid4' + message = "Running Ransack specs with #{Mongoid.default_session.inspect + }, Mongoid #{Mongoid::VERSION}, Moped #{Moped::VERSION + }, Origin #{Origin::VERSION} and Ruby #{RUBY_VERSION}" + else + message = "Running Ransack specs with #{Mongoid.default_client.inspect + }, Mongoid #{Mongoid::VERSION}, Mongo driver #{Mongo::VERSION}" + end line = '=' * message.length puts line, message, line Schema.create