1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
aasm/spec/spec_helpers/mongoid.rb
Anil Kumar Maurya 7a351ecd8a
Fix mongoid specs by adding require in mongoid specs (#786)
* Try to fix mongoid specs by adding require in mongoid specs

* Disable truffleruby for rails 6.1
2022-07-22 19:46:23 +05:30

27 lines
740 B
Ruby

# encoding: utf-8
begin
require 'mongoid'
require 'rails'
puts "mongoid #{Mongoid::VERSION} gem found, running mongoid specs \e[32m#{'✔'}\e[0m"
if Mongoid::VERSION.to_f <= 5
Mongoid::Config.sessions = {
default: {
database: "mongoid_#{Process.pid}",
hosts: ["#{ENV['MONGODB_HOST'] || 'localhost'}:" \
"#{ENV['MONGODB_PORT'] || 27017}"]
}
}
else
Mongoid::Config.send(:clients=, {
default: {
database: "mongoid_#{Process.pid}",
hosts: ["#{ENV['MONGODB_HOST'] || 'localhost'}:" \
"#{ENV['MONGODB_PORT'] || 27017}"]
}
})
end
rescue LoadError
puts "mongoid gem not found, not running mongoid specs \e[31m#{'✖'}\e[0m"
end