Sha256: 8c45a2292eca015428749778de80aa8f9eec98a7952a9bf91e4bc109c2ccb2f4

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe RSpec::Hive::QueryBuilderHelper do
  let(:connection) { double }
  let(:schema) { double }
  let(:dummy_class) { double }

  before { dummy_class.extend(described_class) }

  describe '#into_hive' do
    context 'when no connection has been defined' do
      it 'raises and error' do
        expect { dummy_class.into_hive(schema) }.
          to raise_error(RSpec::Hive::QueryBuilderHelper::HiveConnectionNotFound).
          with_message('Include WithHiveConnection')
      end
    end

    context 'when RBhive connection has been given' do
      subject { dummy_class.into_hive(schema) }

      let(:dummy_class) { double(connection: connection) }

      before do
        allow(connection).to receive(:is_a?).with(RBHive::TCLIConnection).and_return(true)
      end

      it 'returns a query_builder' do
        is_expected.to be_a_kind_of(RSpec::Hive::QueryBuilder)
      end
    end

    context 'when ConnectionDelegator has been given' do
      subject { dummy_class.into_hive(schema) }

      let(:dummy_class) { double(connection: connection) }

      before do
        allow(connection).to receive(:is_a?).with(RBHive::TCLIConnection).and_return(false)
        allow(connection).to receive(:is_a?).with(RSpec::Hive::ConnectionDelegator).and_return(true)
      end

      it 'returns a query_builder' do
        is_expected.to be_a_kind_of(RSpec::Hive::QueryBuilder)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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