diff --git a/Gemfile b/Gemfile index 30c36e9..215ec0c 100644 --- a/Gemfile +++ b/Gemfile @@ -43,3 +43,8 @@ end if ENV['DB'] =~ /mongodb/ gem 'mongoid', '~> 4.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' +end diff --git a/Rakefile b/Rakefile index 9d533d6..67cbb18 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,15 @@ require 'bundler' require 'rspec/core/rake_task' +require 'active_record' Bundler::GemHelper.install_tasks RSpec::Core::RakeTask.new(:spec) do |rspec| ENV['SPEC'] = 'spec/ransack/**/*_spec.rb' - rspec.rspec_opts = ['--backtrace'] + if ActiveRecord::VERSION::MAJOR >= 4 || RUBY_VERSION < '2.2' + # Raises `invalid option: --backtrace` with Rails 3.x on Ruby 2.2 + rspec.rspec_opts = ['--backtrace'] + end end RSpec::Core::RakeTask.new(:mongoid) do |rspec| diff --git a/spec/ransack/dependencies_spec.rb b/spec/ransack/dependencies_spec.rb index ca669b9..4cb7261 100644 --- a/spec/ransack/dependencies_spec.rb +++ b/spec/ransack/dependencies_spec.rb @@ -1,8 +1,12 @@ -unless ::ActiveRecord::VERSION::STRING >= '4' +ruby, rails = RUBY_VERSION, ::ActiveRecord::VERSION::STRING.first(3) + +if %w(3.2 4.0 4.1).include?(rails) || (%w(3.0 3.1).include?(rails) && ruby < '2.2') + describe 'Ransack' do it 'can be required without errors' do output = `bundle exec ruby -e "require 'ransack'" 2>&1` expect(output).to be_empty end end + end