From 03a4518635edde14cd3198dfc8e82c2ac23d52b8 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Sun, 2 Feb 2014 14:23:46 -0500 Subject: [PATCH] Add tests for mongoid 4 beta 1 --- .travis.yml | 1 + gemfiles/mongoid_40.gemfile | 14 ++++++++++++++ spec/fake_app/mongoid/config.rb | 2 +- spec/fake_app/mongoid/models.rb | 4 ++++ spec/models/mongoid/mongoid_spec.rb | 2 +- 5 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 gemfiles/mongoid_40.gemfile diff --git a/.travis.yml b/.travis.yml index ba724f8..1e1e0ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ gemfile: - gemfiles/mongoid_24.gemfile - gemfiles/mongoid_30.gemfile - gemfiles/mongoid_31.gemfile + - gemfiles/mongoid_40.gemfile - gemfiles/sinatra_13.gemfile - gemfiles/sinatra_14.gemfile diff --git a/gemfiles/mongoid_40.gemfile b/gemfiles/mongoid_40.gemfile new file mode 100644 index 0000000..b09dc85 --- /dev/null +++ b/gemfiles/mongoid_40.gemfile @@ -0,0 +1,14 @@ +source 'https://rubygems.org' + +gem 'railties', '~> 4.0' +gem "mongoid", "~> 4.0.0.beta1" +gem 'rspec-rails', '>= 2.0' + +platforms :rbx do + gem 'rubysl', '~> 2.0' + gem 'racc' + gem 'rubysl-test-unit' + gem 'rubinius-developer_tools' +end + +gemspec :path => '../' diff --git a/spec/fake_app/mongoid/config.rb b/spec/fake_app/mongoid/config.rb index 287a981..7f96791 100644 --- a/spec/fake_app/mongoid/config.rb +++ b/spec/fake_app/mongoid/config.rb @@ -8,7 +8,7 @@ if RUBY_VERSION >= '1.9.2' end Mongoid.configure do |config| - if Mongoid::VERSION =~ /^3/ + if Mongoid::VERSION > '3.0.0' config.sessions = {:default => {:hosts => ['localhost:27017'], :database => 'kaminari_test'}} else config.master = Mongo::Connection.new.db('kaminari_test') diff --git a/spec/fake_app/mongoid/models.rb b/spec/fake_app/mongoid/models.rb index 7d65da7..8a167fc 100644 --- a/spec/fake_app/mongoid/models.rb +++ b/spec/fake_app/mongoid/models.rb @@ -1,5 +1,9 @@ class User include ::Mongoid::Document + if Mongoid::VERSION > '4.0.0' + include Mongoid::Attributes::Dynamic + end + field :name, :type => String field :age, :type => Integer end diff --git a/spec/models/mongoid/mongoid_spec.rb b/spec/models/mongoid/mongoid_spec.rb index e7e311b..cacc0d1 100644 --- a/spec/models/mongoid/mongoid_spec.rb +++ b/spec/models/mongoid/mongoid_spec.rb @@ -98,7 +98,7 @@ if defined? Mongoid end shared_examples 'complete valid pagination' do - if Mongoid::VERSION =~ /^3/ + if Mongoid::VERSION > '3.0.0' its(:selector) { should == {'salary' => 1} } else its(:selector) { should == {:salary => 1} }