Sha256: 8bacda4c928026a3e8ab48fdb95ac9eb8814f92d81698781c640af9034e7cda5

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

#encoding: utf-8
require 'spec_helper'

describe Executrix::Connection do
  let(:subject) { described_class.new nil, nil, nil, nil }

  {
    login: 0,
    create_job: 3,
    close_job: 1,
    query_batch: 2,
    query_batch_result_id: 2,
    query_batch_result_data: 3,

  }.each do |method_name, num_of_params|
    describe "##{method_name}" do
      it 'should delegate correctly to Http class' do
        Executrix::Http.
          should_receive(method_name).
          and_return({})
        subject.send(method_name, *Array.new(num_of_params))
      end
    end
  end

  describe '#add_query' do
    it 'should delegate correctly to Http class' do
      Executrix::Http.should_receive(:add_batch).
          and_return({})
      subject.add_query(nil, nil)
    end
  end

  describe '#add_batch' do
    it 'should delegate correctly to underlying classes' do
      Executrix::Http.should_receive(:add_batch).
          and_return({})
      Executrix::Helper.should_receive(:records_to_csv).
        and_return('My,Awesome,CSV')
      subject.add_batch(nil, 'non emtpy records')
    end

    it 'should return -1 for nil input' do
      return_code = subject.add_batch(nil, nil)
      expect(return_code).to eq(-1)
    end

    it 'should return -1 for empty input' do
      return_code = subject.add_batch(nil, [])
      expect(return_code).to eq(-1)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
executrix-1.0.0 spec/lib/executrix/connection_spec.rb