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:
parent
b5517bacdb
commit
b2821db8e5
5
Gemfile
5
Gemfile
|
@ -43,3 +43,8 @@ end
|
||||||
if ENV['DB'] =~ /mongodb/
|
if ENV['DB'] =~ /mongodb/
|
||||||
gem 'mongoid', '~> 4.0.0', require: false
|
gem 'mongoid', '~> 4.0.0', require: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Removed from Ruby 2.2 but needed for testing Rails 3.x.
|
||||||
|
group :test do
|
||||||
|
gem 'test-unit', '~> 3.0'
|
||||||
|
end
|
||||||
|
|
6
Rakefile
6
Rakefile
|
@ -1,11 +1,15 @@
|
||||||
require 'bundler'
|
require 'bundler'
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
|
require 'active_record'
|
||||||
|
|
||||||
Bundler::GemHelper.install_tasks
|
Bundler::GemHelper.install_tasks
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:spec) do |rspec|
|
RSpec::Core::RakeTask.new(:spec) do |rspec|
|
||||||
ENV['SPEC'] = 'spec/ransack/**/*_spec.rb'
|
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
|
end
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:mongoid) do |rspec|
|
RSpec::Core::RakeTask.new(:mongoid) do |rspec|
|
||||||
|
|
|
@ -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
|
describe 'Ransack' do
|
||||||
it 'can be required without errors' do
|
it 'can be required without errors' do
|
||||||
output = `bundle exec ruby -e "require 'ransack'" 2>&1`
|
output = `bundle exec ruby -e "require 'ransack'" 2>&1`
|
||||||
expect(output).to be_empty
|
expect(output).to be_empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue