diff --git a/lib/rspec/rails/matchers/relation_match_array.rb b/lib/rspec/rails/matchers/relation_match_array.rb index 861843b356..419028fb8e 100644 --- a/lib/rspec/rails/matchers/relation_match_array.rb +++ b/lib/rspec/rails/matchers/relation_match_array.rb @@ -1,3 +1,3 @@ -if defined?(ActiveRecord::Relation) +if defined?(ActiveRecord::Relation) && defined?(RSpec::Matchers::BuiltIn::OperatorMatcher) # RSpec 4 removed OperatorMatcher RSpec::Matchers::BuiltIn::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::BuiltIn::ContainExactly) end