1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

[AR, DM, Mongoid, MongoMapper].each {|orm| run orm specs only if orm is loaded }

This commit is contained in:
Akira Matsuda 2012-05-17 21:08:02 +09:00
parent 53bae068e8
commit 854d04af4b
6 changed files with 547 additions and 533 deletions

View file

@ -1,6 +1,7 @@
require 'spec_helper'
describe Kaminari::ActiveRecordRelationMethods do
if defined? ActiveRecord
describe Kaminari::ActiveRecordRelationMethods do
describe '#total_count' do
before do
@author = User.create! :name => 'author'
@ -25,4 +26,5 @@ describe Kaminari::ActiveRecordRelationMethods do
end
end
end
end
end

View file

@ -1,6 +1,8 @@
require 'spec_helper'
describe 'default per_page' do
if defined? ActiveRecord
describe 'default per_page' do
describe 'AR::Base' do
subject { ActiveRecord::Base }
it { should_not respond_to :paginates_per }
@ -26,4 +28,5 @@ describe 'default per_page' do
after { User.paginates_per nil }
end
end
end
end

View file

@ -1,15 +1,17 @@
require 'spec_helper'
shared_examples_for 'the first page' do
if defined? ActiveRecord
shared_examples_for 'the first page' do
it { should have(25).users }
its('first.name') { should == 'user001' }
end
end
shared_examples_for 'blank page' do
shared_examples_for 'blank page' do
it { should have(0).users }
end
end
describe Kaminari::ActiveRecordExtension do
describe Kaminari::ActiveRecordExtension do
before do
1.upto(100) {|i| User.create! :name => "user#{'%03d' % i}", :age => (i / 10)}
1.upto(100) {|i| GemDefinedModel.create! :name => "user#{'%03d' % i}", :age => (i / 10)}
@ -160,4 +162,5 @@ describe Kaminari::ActiveRecordExtension do
end
end
end
end
end

View file

@ -1,10 +1,9 @@
require 'spec_helper'
require 'dm-core'
require 'dm-migrations'
require 'dm-aggregates'
require 'kaminari/models/data_mapper_extension'
describe Kaminari::DataMapperExtension do
if defined? DataMapper
require 'kaminari/models/data_mapper_extension'
describe Kaminari::DataMapperExtension do
before :all do
DataMapper.setup(:default, 'sqlite::memory:')
@ -180,4 +179,5 @@ describe Kaminari::DataMapperExtension do
its(:num_pages) { should == 10 }
end
end
end
end

View file

@ -1,8 +1,10 @@
require 'spec_helper'
require 'mongo_mapper'
require 'kaminari/models/mongo_mapper_extension'
describe Kaminari::MongoMapperExtension do
if defined? MongoMapper
require 'mongo_mapper'
require 'kaminari/models/mongo_mapper_extension'
describe Kaminari::MongoMapperExtension do
before do
begin
@ -83,4 +85,5 @@ describe Kaminari::MongoMapperExtension do
its(:num_pages) { should == 5 }
it { should skip 10 }
end
end
end

View file

@ -1,8 +1,10 @@
require 'spec_helper'
require 'mongoid'
require 'kaminari/models/mongoid_extension'
describe Kaminari::MongoidExtension do
if defined? Mongoid
require 'mongoid'
require 'kaminari/models/mongoid_extension'
describe Kaminari::MongoidExtension do
before do
begin
@ -142,4 +144,5 @@ describe Kaminari::MongoidExtension do
its(:num_pages) { should == 2 }
end
end
end
end