# encoding: utf-8 # require 'spec_helper' describe Mode::Sdk::TableImport do describe '#poll' do it 'polls state until completed' do import = Mode::Sdk::TableImport.new('/some/path') reprs = %w(new enqueued running running failed).map do |state| { 'state' => state } end expect(import).to receive(:fetch_repr).and_return(*reprs) expect { |b| import.poll(0, &b) }.to yield_successive_args(*reprs) end end describe '#fetch_repr' do it 'performs get request' do import = Mode::Sdk::TableImport.new('/some/path') response = double(:response, body: { 'state' => 'enqueued' }) expect(Mode::Sdk::Client).to receive(:get).and_return(response) expect(import.send(:fetch_repr)).to eq('state' => 'enqueued') end end end