in elasticsearch-model/spec/elasticsearch/model/importing_spec.rb [34:77]
def importing_mixin
ImportingMixin
end; module_function :importing_mixin
end
end
after(:all) do
remove_classes(DummyImportingModel, DummyImportingAdapter)
end
before do
allow(Elasticsearch::Model::Adapter).to receive(:from_class).with(DummyImportingModel).and_return(DummyImportingAdapter)
DummyImportingModel.__send__ :include, Elasticsearch::Model::Importing
end
context 'when a model includes the Importing module' do
it 'provides importing methods' do
expect(DummyImportingModel.respond_to?(:import)).to be(true)
expect(DummyImportingModel.respond_to?(:__find_in_batches)).to be(true)
end
end
describe '#import' do
before do
allow(DummyImportingModel).to receive(:index_name).and_return('foo')
allow(DummyImportingModel).to receive(:index_exists?).and_return(true)
allow(DummyImportingModel).to receive(:__batch_to_bulk)
allow(client).to receive(:bulk).and_return(response)
end
let(:client) do
double('client')
end
let(:response) do
{ 'items' => [] }
end
context 'when no options are provided' do
before do
expect(DummyImportingModel).to receive(:client).and_return(client)
allow(DummyImportingModel).to receive(:index_exists?).and_return(true)
end