karafka-testing 2.3.1 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b5e94cc98b3418a25cd549e4e9f4851d22fa819b499b77185afb7ee1e1f10c6
4
- data.tar.gz: 415e32601301d2f07de6c575109c443af8f489c178041e387d6fe1d1530550ca
3
+ metadata.gz: 4932859009198b689571ee03c117e5255efbba52deb34874c689577cd456bf47
4
+ data.tar.gz: a83d1892a15392beb4889d77f642c2368b9a57a07073e9ce6ae4f884ad6ba61c
5
5
  SHA512:
6
- metadata.gz: 17eb73114b43f84c813ad176f8a8913fde8f175f0b41ecbe78bfd3bb20c30259aaab791cd9cb719c1aab9cef0daceed651d7c342201fffd227db495f5d55ce51
7
- data.tar.gz: e42445092d3ab33eb27d1145c9897f94b3758bd57b624935fd8d8fd3f37999d3333caf70b2c713196a672978b478a8dc4a5923aa6924387331c076334e14391f
6
+ metadata.gz: 0c99a0ece8c0ae1e2b46541148236b86ce26f1652c6e3cd82e4d3158ed42797b67019a4ec79db3c21efbc9a8e65e53e7e07cc6effa876190b5377dbd1cf2a8f2
7
+ data.tar.gz: d422ab991a2cfa2796e8dff02d9902c19f3d64e8f6d4d269283468abfbb0c20569f699faeef4f78dac440662ab94fea7da293361a7f824ba5219070358e6c1fa
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Karafka Test gem changelog
2
2
 
3
+ ## 2.3.2 (2024-04-03)
4
+ - [Enhancement] Support `Minitest::Spec`.
5
+
3
6
  ## 2.3.1 (2024-03-07)
4
7
  - [Enhancement] Prevent usage of testing when Karafka is not loaded.
5
8
  - [Enhancement] Prevent usage of testing when Karafka is not initialized.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-testing (2.3.1)
4
+ karafka-testing (2.3.2)
5
5
  karafka (>= 2.3.0, < 2.4.0)
6
6
  waterdrop (>= 2.6.12)
7
7
 
@@ -15,17 +15,7 @@ module Karafka
15
15
  TopicInManyConsumerGroupsError = Class.new(BaseError)
16
16
 
17
17
  # Raised when you requested a topic from a consumer group that does not exist
18
- ConsumerGroupNotFoundError = Class.new(BaseError)
19
-
20
- # Raised when trying to use testing without Karafka app being visible
21
- # If you are seeing this error, then you tried to use testing helpers without Karafka being
22
- # loaded prior to this happening.
23
- KarafkaNotLoadedError = Class.new(BaseError)
24
-
25
- # Raised when there is an attempt to use the testing primitives without Karafka app being
26
- # configured. Prior to initialization process, most of config values are nils, etc and
27
- # mocks will not work.
28
- KarafkaNotInitializedError = Class.new(BaseError)
18
+ ConsumerGroupNotFound = Class.new(BaseError)
29
19
  end
30
20
  end
31
21
  end
@@ -16,19 +16,25 @@ module Karafka
16
16
  # Adds all the needed extra functionalities to the minitest group
17
17
  # @param base [Class] Minitest example group we want to extend
18
18
  def included(base)
19
- base.class_eval do
20
- setup do
21
- Karafka::Testing.ensure_karafka_initialized!
19
+ eval_flow = lambda do
20
+ @karafka = Karafka::Testing::Minitest::Proxy.new(self)
21
+ @_karafka_consumer_messages = []
22
+ @_karafka_consumer_client = Karafka::Testing::SpecConsumerClient.new
23
+ @_karafka_producer_client = Karafka::Testing::SpecProducerClient.new(self)
22
24
 
23
- @karafka = Karafka::Testing::Minitest::Proxy.new(self)
24
- @_karafka_consumer_messages = []
25
- @_karafka_consumer_client = Karafka::Testing::SpecConsumerClient.new
26
- @_karafka_producer_client = Karafka::Testing::SpecProducerClient.new(self)
25
+ @_karafka_consumer_messages.clear
26
+ @_karafka_producer_client.reset
27
27
 
28
- @_karafka_consumer_messages.clear
29
- @_karafka_producer_client.reset
28
+ Karafka.producer.stubs(:client).returns(@_karafka_producer_client)
29
+ end
30
30
 
31
- Karafka.producer.stubs(:client).returns(@_karafka_producer_client)
31
+ if base.to_s == 'Minitest::Spec'
32
+ base.class_eval do
33
+ before(&eval_flow)
34
+ end
35
+ else
36
+ base.class_eval do
37
+ setup(&eval_flow)
32
38
  end
33
39
  end
34
40
  end
@@ -178,7 +184,6 @@ module Karafka
178
184
  rescue Karafka::Errors::TopicNotFoundError
179
185
  nil
180
186
  end
181
- .uniq(&:consumer_group)
182
187
  end
183
188
 
184
189
  # Finds subscription groups from the requested consumer group or selects all if no
@@ -30,8 +30,6 @@ module Karafka
30
30
  base.let(:_karafka_producer_client) { Karafka::Testing::SpecProducerClient.new(self) }
31
31
 
32
32
  base.prepend_before do
33
- Karafka::Testing.ensure_karafka_initialized!
34
-
35
33
  _karafka_consumer_messages.clear
36
34
  _karafka_producer_client.reset
37
35
 
@@ -196,7 +194,6 @@ module Karafka
196
194
  rescue Karafka::Errors::TopicNotFoundError
197
195
  nil
198
196
  end
199
- .uniq(&:consumer_group)
200
197
  end
201
198
 
202
199
  # Finds subscription groups from the requested consumer group or selects all if no
@@ -4,6 +4,6 @@
4
4
  module Karafka
5
5
  module Testing
6
6
  # Current version of gem. It should match Karafka framework version
7
- VERSION = '2.3.1'
7
+ VERSION = '2.3.2'
8
8
  end
9
9
  end
@@ -4,32 +4,5 @@
4
4
  module Karafka
5
5
  # Testing lib module
6
6
  module Testing
7
- class << self
8
- # Makes sure, that we do not use the testing stubs, etc when Karafka app is not loaded
9
- #
10
- # You should never use karafka-testing primitives when framework is not loaded because
11
- # testing lib stubs certain pieces of Karafka that need to be initialized.
12
- def ensure_karafka_loaded!
13
- return if ::Karafka.const_defined?('App', false)
14
-
15
- raise(
16
- Karafka::Testing::Errors::KarafkaNotLoadedError,
17
- 'Make sure to load Karafka framework prior to usage of the testing components.'
18
- )
19
- end
20
-
21
- # If you do not initialize Karafka always within your specs, do not include/use this lib
22
- # in places where Karafka would not be loaded.
23
- def ensure_karafka_initialized!
24
- ensure_karafka_loaded!
25
-
26
- return unless Karafka::App.initializing?
27
-
28
- raise(
29
- Karafka::Testing::Errors::KarafkaNotInitializedError,
30
- 'Make sure to initialize Karafka framework prior to usage of the testing components.'
31
- )
32
- end
33
- end
34
7
  end
35
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka-testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
@@ -35,7 +35,7 @@ cert_chain:
35
35
  AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
36
36
  msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
37
37
  -----END CERTIFICATE-----
38
- date: 2024-03-07 00:00:00.000000000 Z
38
+ date: 2024-04-11 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka
metadata.gz.sig CHANGED
Binary file