Skip to content

Commit

Permalink
Mocha support for stubs (#143)
Browse files Browse the repository at this point in the history
* mocha poc

* mocha remarks
  • Loading branch information
mensfeld authored Jun 7, 2023
1 parent b9b4445 commit d5fdba4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Karafka Test gem changelog

## 2.1.1 (Unreleased)
- [Enhancement] Support WaterDrop stubs with Mocha.

## 2.1.0 (2023-05-22)
- Align Karafka expectations to match `2.1.0`.
- [Maintenance] Align Karafka expectations to match `2.1.0`.

## 2.0.11 (2023-04-13)
- Align metadata builder format with Karafka `2.0.40`.
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
karafka-testing (2.1.0)
karafka-testing (2.1.1)
karafka (>= 2.1.0, < 3.0.0)

GEM
Expand Down
6 changes: 5 additions & 1 deletion lib/karafka/testing/rspec/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def included(base)
_karafka_consumer_messages.clear
_karafka_producer_client.reset

allow(Karafka.producer).to receive(:client).and_return(_karafka_producer_client)
if Object.const_defined?('Mocha', false)
Karafka.producer.stubs(:client).returns(_karafka_producer_client)
else
allow(Karafka.producer).to receive(:client).and_return(_karafka_producer_client)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/karafka/testing/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
module Karafka
module Testing
# Current version of gem. It should match Karafka framework version
VERSION = '2.1.0'
VERSION = '2.1.1'
end
end

0 comments on commit d5fdba4

Please sign in to comment.