deimos-ruby 1.11.0 → 1.11.1

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: ac454bfdafdeec22f07c9b00386dfcdd687ed1320288384f53f4541eb6037589
4
- data.tar.gz: a012d3b33de492bf84d17c74da545dbd0180377fde07b0e52f8002806e3cc489
3
+ metadata.gz: 4c2fe121d207349905ce908ee4bdb3a2d420a545135c25b47aa4c99e5b5153ef
4
+ data.tar.gz: e28688edca132bd6d67ad4414d5e3616eb2f217274a6c27dd701816520241a76
5
5
  SHA512:
6
- metadata.gz: 6bad789e44e21108e652119640e641f4efa217398d8db89b1b734373f5bdc23cbdd60605828e4f6df9e366bac948512c9ff041222db8fd858605fb5a82e7fea9
7
- data.tar.gz: 218fb6e258b3a7859644ece11feff5e27738cbe85c20830f704128c5e9fa3d50e764b4d178fc58ca31b35de90839cb1411d1cf98bcfe73c601162c8cb5017d83
6
+ metadata.gz: 7ab87d73ff46dcbf415f65579f3a13202f9e7d0e61918672ef0f9e100babbeb4a27bfd1dce791bf5f36d38cea775881bd38ef424df8317cfaf440ce5b44414ed
7
+ data.tar.gz: 252d9a2a0e65a78c3faa5b420a1504230cd7d621714387930b369183724c33936240ec534181df024e6d4b5688ba8bca6bae2e0ca1572487dd1aadaf1960b97d
data/CHANGELOG.md CHANGED
@@ -7,10 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## UNRELEASED
9
9
 
10
- ## 1.11.0 - 2021-08-27
10
+ ## 1.11.1 - 2021-08-27
11
11
 
12
12
  - ### Fixes :wrench:
13
- - Fixed issue where ActiveRecord batch consumption could fail when decoding keys.
13
+ - Fixed issue where ActiveRecord batch consumption would try to decode keys twice.
14
14
 
15
15
  - ### Roadmap :car:
16
16
  - TestHelper does not automatically reset Deimos config before each test. [#120](https://github.com/flipp-oss/deimos/pull/120).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deimos-ruby (1.10.2)
4
+ deimos-ruby (1.11.0)
5
5
  avro_turf (~> 0.11)
6
6
  fig_tree (~> 0.0.2)
7
7
  phobos (>= 1.9, < 3.0)
data/README.md CHANGED
@@ -880,8 +880,7 @@ Also see [deimos.rb](lib/deimos.rb) under `Configure tracing` to see how the tra
880
880
 
881
881
  # Testing
882
882
 
883
- Deimos comes with a test helper class which sets the various backends
884
- to mock versions, and provides useful methods for testing consumers.
883
+ Deimos comes with a test helper class which provides useful methods for testing consumers.
885
884
 
886
885
  In `spec_helper.rb`:
887
886
  ```ruby
@@ -890,7 +889,56 @@ RSpec.configure do |config|
890
889
  end
891
890
  ```
892
891
 
893
- In your test, you now have the following methods available:
892
+ ## Test Configuration
893
+
894
+ ```ruby
895
+ # The following can be added to a rpsec file so that each unit
896
+ # test can have the same settings every time it is run
897
+ around(:each) do |example|
898
+ Deimos::TestHelpers.unit_test!
899
+ example.run
900
+ Deimos.config.reset!
901
+ end
902
+
903
+ # Similarly you can use the Kafka test helper
904
+ around(:each) do |example|
905
+ Deimos::TestHelpers.kafka_test!
906
+ example.run
907
+ Deimos.config.reset!
908
+ end
909
+
910
+ # Kakfa test helper using schema registry
911
+ around(:each) do |example|
912
+ Deimos::TestHelpers.full_integration_test!
913
+ example.run
914
+ Deimos.config.reset!
915
+ end
916
+ ```
917
+
918
+ With the help of these helper methods, rspec examples can be written without having to tinker with Deimos settings.
919
+ This also prevents Deimos setting changes from leaking in to other examples.
920
+
921
+ This does not take away the ability to configure Deimos manually in individual examples. Deimos can still be configured like so:
922
+ ```ruby
923
+ it 'should not fail this random test' do
924
+
925
+ Deimos.configure do |config|
926
+ config.consumers.fatal_error = proc { true }
927
+ config.consumers.reraise_errors = false
928
+ end
929
+ ...
930
+ expect(some_object).to be_truthy
931
+ ...
932
+ Deimos.config.reset!
933
+ end
934
+ ```
935
+ If you are using one of the test helpers in an `around(:each)` block and want to override few settings for one example,
936
+ you can do it like in the example shown above. These settings would only apply to that specific example and the Deimos config should
937
+ reset once the example has finished running.
938
+
939
+ ## Test Usage
940
+
941
+ In your tests, you now have the following methods available:
894
942
  ```ruby
895
943
  # Pass a consumer class (not instance) to validate a payload against it.
896
944
  # This will fail if the payload does not match the schema the consumer
@@ -938,6 +986,8 @@ expect(message).to eq({
938
986
  })
939
987
  ```
940
988
 
989
+ ### Test Utilities
990
+
941
991
  There is also a helper method that will let you test if an existing schema
942
992
  would be compatible with a new version of it. You can use this in your
943
993
  Ruby console but it would likely not be part of your RSpec test:
@@ -947,69 +997,6 @@ require 'deimos/test_helpers'
947
997
  # Can pass a file path, a string or a hash into this:
948
998
  Deimos::TestHelpers.schemas_compatible?(schema1, schema2)
949
999
  ```
950
- ### Test Helpers
951
-
952
- There are helper methods available to configure Deimos for different types of testing scenarios.
953
- Currently there are helpers defined for unit tests and for testing Kafka related code. You can use it as follows:
954
-
955
- ```ruby
956
- # The following can be added to a rpsec file so that each unit
957
- # test can have the same settings every time it is run
958
- around(:each) do |example|
959
- Deimos::TestHelpers.unit_test!
960
- example.run
961
- Deimos.config.reset!
962
- end
963
-
964
- # Similarly you can use the Kafka test helper
965
- around(:each) do |example|
966
- Deimos::TestHelpers.kafka_test!
967
- example.run
968
- Deimos.config.reset!
969
- end
970
-
971
- # Kakfa test helper using schema registry
972
- around(:each) do |example|
973
- Deimos::TestHelpers.full_integration_test!
974
- example.run
975
- Deimos.config.reset!
976
- end
977
- ```
978
-
979
- With the help of these helper methods, rspec examples can be written without having to tinker with Deimos settings.
980
- This also prevents Deimos setting changes from leaking in to other examples.
981
-
982
- This does not take away the ability to configure Deimos manually in individual examples. Deimos can still be configured like so:
983
- ```ruby
984
- it 'should not fail this random test' do
985
-
986
- Deimos.configure do |config|
987
- config.consumers.fatal_error = proc { true }
988
- config.consumers.reraise_errors = false
989
- end
990
- ...
991
- expect(some_object).to be_truthy
992
- ...
993
- Deimos.config.reset!
994
- end
995
- ```
996
- If you are using one of the test helpers in an `around(:each)` block and want to override few settings for one example,
997
- you can do it like in the example shown above. These settings would only apply to that specific example and the Deimos conifg should
998
- reset once the example has finished running.
999
-
1000
-
1001
- ### Integration Test Helpers
1002
-
1003
- When running integration tests, you'll want to override the default test helper settings:
1004
-
1005
- ```ruby
1006
- config.before(:each, :my_integration_metadata) do
1007
- Deimos.configure do
1008
- producers.backend :kafka
1009
- schema.backend :avro_schema_registry
1010
- end
1011
- end
1012
- ```
1013
1000
 
1014
1001
  You can use the `InlineConsumer` class to help with integration testing,
1015
1002
  with a full external Kafka running.
@@ -44,14 +44,12 @@ module Deimos
44
44
  # @param key [String] The encoded key.
45
45
  # @return [Hash] The key attributes.
46
46
  def record_key(key)
47
- decoded_key = decode_key(key)
48
-
49
- if decoded_key.nil?
47
+ if key.nil?
50
48
  {}
51
- elsif decoded_key.is_a?(Hash)
52
- @key_converter.convert(decoded_key)
49
+ elsif key.is_a?(Hash)
50
+ @key_converter.convert(key)
53
51
  else
54
- { @klass.primary_key => decoded_key }
52
+ { @klass.primary_key => key }
55
53
  end
56
54
  end
57
55
 
@@ -10,7 +10,7 @@ module Deimos
10
10
  class AvroSchemaRegistry < AvroBase
11
11
  # @override
12
12
  def decode_payload(payload, schema:)
13
- avro_turf_messaging.decode(payload.to_s, schema_name: schema)
13
+ avro_turf_messaging.decode(payload, schema_name: schema)
14
14
  end
15
15
 
16
16
  # @override
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Deimos
4
- VERSION = '1.11.0'
4
+ VERSION = '1.11.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deimos-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner