Skip to content

Commit

Permalink
Fix Mocha compatibility
Browse files Browse the repository at this point in the history
RSpec Mocks happened to load its configuration, use the default syntax
and define `any_instance` on `Class` before Mocha had a chance to in
case `rspec/rails` was required in `spec/spec_helper.rb`.

fixes #2252
  • Loading branch information
pirj committed Jan 9, 2020
1 parent 86a5c1f commit 38efe12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -38,6 +38,7 @@ Bug Fixes:
(Takumi Shotoku, #2188)
* Prevent a `WrongScopeError` being thrown during loading fixtures on Rails
6.1 development version. (Edouard Chin, #2215)
* Fix Mocha mocking support with `should`. (Phil Pirozhkov, #2256)

Breaking Changes:

Expand Down
7 changes: 5 additions & 2 deletions lib/rspec/rails/matchers/have_enqueued_mail.rb
@@ -1,4 +1,7 @@
require "rspec/mocks"
# We require the minimum amount of rspec-mocks possible to avoid
# conflicts with other mocking frameworks.
# See: https://github.com/rspec/rspec-rails/issues/2252
require "rspec/mocks/argument_matchers"
require "rspec/rails/matchers/active_job"

module RSpec
Expand All @@ -11,7 +14,7 @@ module Matchers
class HaveEnqueuedMail < ActiveJob::HaveEnqueuedJob
MAILER_JOB_METHOD = 'deliver_now'.freeze

include RSpec::Mocks::ExampleMethods
include RSpec::Mocks::ArgumentMatchers

def initialize(mailer_class, method_name)
super(nil)
Expand Down

0 comments on commit 38efe12

Please sign in to comment.