Sha256: 863afafb28c9e3753e399b14088a05e68e7727b2f4f29f44d363c90cffa7c224

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

# frozen_string_literal: true

require_relative 'exponential_backoff'

module RSpec
  module Hive
    module WithHiveConnection
      def self.included(mod)
        mod.before(:all) do
          ExponentialBackoff.retryable(on: Thrift::TransportException) do
            connection
          end
        end

        mod.before(:each) do
          connection.switch_database(DbName.random_name)
        end

        mod.after(:all) do
          hive_connector.stop_connection(connection) if hive_connector && @connection
        end
      end

      def connection
        @connection ||= hive_connector.start_connection
      end

      private

      def hive_connector
        ::RSpec::Hive.connector
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-hive-0.6.3 lib/rspec/hive/with_hive_connection.rb
rspec-hive-0.6.2 lib/rspec/hive/with_hive_connection.rb
rspec-hive-0.6.1 lib/rspec/hive/with_hive_connection.rb
rspec-hive-0.6.0 lib/rspec/hive/with_hive_connection.rb