require 'spec_helper' require 'flydata/query_based_sync/query_based_sync_context' module Flydata module QueryBasedSync describe ResourceRequester do include_context 'query based sync context' let(:subject_object) { DummyResourceRequester.new(context) } describe '#initialize' do subject { subject_object } before do subject end it { expect(subject.context).to eq(context) } it { expect(subject.instance_variable_get(:@resource_client)).to eq(resource_client) } end describe '#start' do it do expect(table_meta).to receive(:reload).with(resource_client) expect(resource_client).to receive(:close).once expect{|b| subject_object.start(&b)}.to yield_with_args(subject_object) end end describe '#each_response' do let(:table_name) { 'table_1' } let(:returned_responses) { nil } before do allow(subject_object).to receive(:fetch_responses_once).and_return(returned_responses) end context 'when no response' do let(:returned_responses) { [] } it do expect(subject_object.each_response(table_name)).to be_nil end end context 'when returning a response' do let(:returned_responses) { [response] } it do expect{|b| subject_object.each_response(table_name, 0.1, &b)}. to yield_with_args(response) end end end end end end