Try to improve Rails 3.x tests working with Ruby 2.2

Not sure it’s worth it but giving it a shot, at least for Rails 3.2.
This commit is contained in:
jonatack 2015-01-08 00:17:33 +01:00
parent b5517bacdb
commit b2821db8e5
3 changed files with 15 additions and 2 deletions

View File

@ -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

View File

@ -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|

View File

@ -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