Sha256: 292deb3e4e163f1791b9cc07725762aaf106a5875b60f3b69fa0c5f7f2eee58e

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require 'webmock'
require 'webmock/rspec'
require 'avro_turf/test/fake_confluent_schema_registry_server'
require 'rimless'
require 'rimless/rspec/helpers'
require 'rimless/rspec/matchers'

# RSpec 1.x and 2.x compatibility
#
# @see http://bit.ly/2GbAYsU
raise 'No RSPEC_CONFIGURER is defined, webmock is missing?' \
  unless defined?(RSPEC_CONFIGURER)

RSPEC_CONFIGURER.configure do |config|
  config.include Rimless::RSpec::Helpers
  config.include Rimless::RSpec::Matchers

  # Stub all Confluent Schema Registry requests and handle them gracefully with
  # the help of the faked (inlined) Schema Registry server. This allows us to
  # perform the actual Apache Avro message encoding/decoding without the need
  # to have a Schema Registry up and running.
  config.before do
    # Get the Excon connection from the AvroTurf instance
    connection = Rimless.avro.instance_variable_get(:@registry)
                        .instance_variable_get(:@upstream)
                        .instance_variable_get(:@connection)
                        .instance_variable_get(:@data)
    # Enable WebMock on the already instantiated
    # Confluent Schema Registry Excon connection
    connection[:mock] = true
    # Grab all Confluent Schema Registry requests and send
    # them to the faked (inlined) Schema Registry
    stub_request(:any, %r{^http://#{connection[:hostname]}})
      .to_rack(FakeConfluentSchemaRegistryServer)
    # Clear any cached data
    FakeConfluentSchemaRegistryServer.clear
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rimless-0.1.3 lib/rimless/rspec.rb
rimless-0.1.2 lib/rimless/rspec.rb
rimless-0.1.1 lib/rimless/rspec.rb
rimless-0.1.0 lib/rimless/rspec.rb