Sha256: 4dfbee25f922e4d15e67993aa2c0e30151b11ea6ab5184d615313a3ecd011751

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe RSpec::Hive::QueryBuilder::RowTransformer do
  let(:transformer) { described_class.new(schema, missing_column_strategy) }
  let(:schema) do
    RBHive::TableSchema.new('table_name', nil) do
      column :col1, :string
      column :col2, :string
    end
  end
  let(:column) { schema.instance_variable_get(:@columns).last }
  let(:partition) { double }
  let(:missing_column_strategy) { double }

  describe '#transform' do
    subject(:transformed_rows) { transformer.transform(row) }

    let(:row) { {col1: real_value} }
    let(:real_value) { 'col1' }
    let(:fake_value) { 'lorem' }
    let(:expected_row) { [real_value, fake_value] }

    before { allow(missing_column_strategy).to receive(:missing).with(column).and_return(fake_value) }

    it 'fills missing fields' do
      expect(transformed_rows[1]).to eq(fake_value)
    end

    it 'uses defined fields' do
      expect(transformed_rows[0]).to eq(real_value)
    end

    it 'returns valid Rows' do
      is_expected.to eq(expected_row)
    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/row_transformer_spec.rb
rspec-hive-0.6.2 spec/lib/rspec/hive/query_builder/row_transformer_spec.rb
rspec-hive-0.6.1 spec/lib/rspec/hive/query_builder/row_transformer_spec.rb
rspec-hive-0.6.0 spec/lib/rspec/hive/query_builder/row_transformer_spec.rb