module Deimos::TestHelpers
Include this module in your RSpec spec_helper to stub out external dependencies and add methods to use to test encoding/decoding.
Public Class Methods
full_integration_test!()
click to toggle source
Kafka test config with avro schema registry
# File lib/deimos/test_helpers.rb, line 34 def full_integration_test! Deimos.configure do |deimos_config| deimos_config.producers.backend = :kafka deimos_config.schema.backend = :avro_schema_registry end end
kafka_test!()
click to toggle source
Set the config to the right settings for a kafka test
# File lib/deimos/test_helpers.rb, line 42 def kafka_test! Deimos.configure do |deimos_config| deimos_config.producers.backend = :kafka deimos_config.schema.backend = :avro_validation end end
sent_messages()
click to toggle source
for backwards compatibility @return [Array<Hash>]
# File lib/deimos/test_helpers.rb, line 18 def sent_messages Deimos::Backends::Test.sent_messages end
unit_test!()
click to toggle source
Set the config to the right settings for a unit test
# File lib/deimos/test_helpers.rb, line 23 def unit_test! Deimos.configure do |deimos_config| deimos_config.logger = Logger.new(STDOUT) deimos_config.consumers.reraise_errors = true deimos_config.kafka.seed_brokers ||= ['test_broker'] deimos_config.schema.backend = Deimos.schema_backend_class.mock_backend deimos_config.producers.backend = :test end end
Public Instance Methods
_hash_diff(hash1, hash2)
click to toggle source
get the difference of 2 hashes. @param hash1 [Hash] @param hash2 [Hash]
# File lib/deimos/test_helpers.rb, line 88 def _hash_diff(hash1, hash2) if hash1.nil? || !hash1.is_a?(Hash) hash2 elsif hash2.nil? || !hash2.is_a?(Hash) hash1 else hash1.dup. delete_if { |k, v| hash2[k] == v }. merge!(hash2.dup.delete_if { |k, _v| hash1.key?(k) }) end end
stub_batch_consumer(_klass)
click to toggle source
@deprecated
# File lib/deimos/test_helpers.rb, line 81 def stub_batch_consumer(_klass) warn('Stubbing batch consumers is no longer necessary and this method will be removed in 3.0') end
stub_consumer(_klass)
click to toggle source
@deprecated
# File lib/deimos/test_helpers.rb, line 76 def stub_consumer(_klass) warn('Stubbing consumers is no longer necessary and this method will be removed in 3.0') end
stub_producer(_klass)
click to toggle source
@deprecated
# File lib/deimos/test_helpers.rb, line 71 def stub_producer(_klass) warn('Stubbing producers is no longer necessary and this method will be removed in 3.0') end
stub_producers_and_consumers!()
click to toggle source
@deprecated
# File lib/deimos/test_helpers.rb, line 66 def stub_producers_and_consumers! warn('stub_producers_and_consumers! is no longer necessary and this method will be removed in 3.0') end