Enable TravisCI, add spec for add_predicate

This commit is contained in:
Ernie Miller 2011-07-17 19:04:00 -04:00
parent 6fa15a20cd
commit 62b7bd2de8
3 changed files with 58 additions and 6 deletions

7
.travis.yml Normal file
View File

@ -0,0 +1,7 @@
rvm:
- 1.8.7
- 1.9.2
- ree
- rbx
- rbx-2.0
- ruby-head

37
Gemfile
View File

@ -1,14 +1,39 @@
source "http://rubygems.org"
gemspec
if ENV['RAILS_VERSION'] == 'release'
gem 'activesupport'
gem 'activerecord'
gem 'actionpack'
gem 'rake'
rails = ENV['RAILS'] || 'master'
arel = ENV['AREL'] || 'master'
arel_opts = case arel
when /\// # A path
{:path => arel}
when /^v/ # A tagged version
{:git => 'git://github.com/rails/arel.git', :tag => arel}
else
gem 'arel', :git => 'git://github.com/rails/arel.git'
git 'git://github.com/rails/rails.git' do
{:git => 'git://github.com/rails/arel.git', :branch => arel}
end
gem 'arel', arel_opts
case rails
when /\// # A path
gem 'activesupport', :path => "#{rails}/activesupport"
gem 'activemodel', :path => "#{rails}/activemodel"
gem 'activerecord', :path => "#{rails}/activerecord"
gem 'actionpack', :path => "#{rails}/activerecord"
when /^v/ # A tagged version
git 'git://github.com/rails/rails.git', :tag => rails do
gem 'activesupport'
gem 'activemodel'
gem 'activerecord'
gem 'actionpack'
end
else
git 'git://github.com/rails/rails.git', :branch => rails do
gem 'activesupport'
gem 'activemodel'
gem 'activerecord'
gem 'actionpack'
end

View File

@ -7,5 +7,25 @@ module Ransack
config.should eq Ransack
end
end
it 'adds predicates' do
Ransack.configure do |config|
config.add_predicate :test_predicate
end
Ransack.predicates.should have_key 'test_predicate'
Ransack.predicates.should have_key 'test_predicate_any'
Ransack.predicates.should have_key 'test_predicate_all'
end
it 'avoids creating compound predicates if :compounds => false' do
Ransack.configure do |config|
config.add_predicate :test_predicate_without_compound, :compounds => false
end
Ransack.predicates.should have_key 'test_predicate_without_compound'
Ransack.predicates.should_not have_key 'test_predicate_without_compound_any'
Ransack.predicates.should_not have_key 'test_predicate_without_compound_all'
end
end
end