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

  module RSpec
    module Rails
      module RelationOperationMatcherHook
        def inherited(subclass)
          RSpec::Matchers::OperatorMatcher.register(subclass, '=~', RSpec::Matchers::BuiltIn::MatchArray)
          super
        end
      end
    end
  end
  ActiveRecord::Relation.extend(RSpec::Rails::RelationOperationMatcherHook)
end

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

Revert "Supports Rails 4 where each model has its own Relation subclass"
Revert "Supports Rails 4 where each model has its own Relation subclass"

This reverts commit 3b28ce7aa0f12a24616007827112e1b5ca85eea3.

* OperatorRegistry now matches on ancestor chain, so this change is no
  longer necessary. See
  https://github.com/rspec/rspec-expectations/commit/e5e5a7475cf1f993b9e1bac8df485df29a544d95.
