if defined?(ActiveRecord)
  RSpec::Matchers::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::MatchArray)
end

if defined?(ActiveRecord::Relation)
  RSpec::Matchers::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::MatchArray)
end

Check to see if the module we're actually working with is loaded (in case only pieces of ActiveRecord are loaded).
Check to see if the module we're actually working with is loaded (in case only pieces of ActiveRecord are loaded).