Skip to content

Commit

Permalink
fixing broken specs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Aug 7, 2024
1 parent b669ab0 commit c04033b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions spec/esse/repository/lazy_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@
it 'returns an array of documents that match with the provided ids' do
docs = repo.documents_for_lazy_attribute(:city_names, '2')
expect(docs).to eq([
Esse::HashDocument.new(_id: '2', city_names: 'London')
Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London')
])
end

it 'returns an array of documents that match with the provided LazyDocumentHeader' do
docs = repo.documents_for_lazy_attribute(:city_names, Esse::LazyDocumentHeader.coerce(id: '2'))
header = Esse::LazyDocumentHeader.coerce(id: '2')
docs = repo.documents_for_lazy_attribute(:city_names, header)
expect(docs).to eq([
Esse::HashDocument.new(_id: '2', city_names: 'London')
Esse::LazyDocumentHeader::Document.new(header, source: { city_names: 'London' })
])
end
end
Expand All @@ -107,8 +108,8 @@
Class.new(Esse::Repository) do
lazy_document_attribute :city_names do |docs|
{
Esse::LazyDocumentHeader.coerce(id: '1') => 'Moscow',
Esse::LazyDocumentHeader.coerce(id: '2') => 'London',
Esse::LazyDocumentHeader.new(id: '1') => 'Moscow',
Esse::LazyDocumentHeader.new(id: '2') => 'London',
}
end
end
Expand All @@ -125,21 +126,21 @@
it 'returns an array of documents that match with the provided ids' do
docs = repo.documents_for_lazy_attribute(:city_names, '2')
expect(docs).to eq([
Esse::HashDocument.new(_id: '2', city_names: 'London')
Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London')
])
end

it 'returns an array of documents that match with the provided LazyDocumentHeader' do
docs = repo.documents_for_lazy_attribute(:city_names, Esse::LazyDocumentHeader.coerce(id: '2'))
expect(docs).to eq([
Esse::HashDocument.new(_id: '2', city_names: 'London')
Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London')
])
end

it 'do not include duplicate documents' do
docs = repo.documents_for_lazy_attribute(:city_names, ['2', '2', Esse::LazyDocumentHeader.coerce(id: '2')])
expect(docs).to eq([
Esse::HashDocument.new(_id: '2', city_names: 'London')
Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London')
])
end
end
Expand All @@ -161,9 +162,9 @@
it 'returns an array of documents that match with the provided ids' do
docs = repo.documents_for_lazy_attribute(:city_names, ['2', '3', '4'])
expect(docs).to eq([
Esse::HashDocument.new(_id: '2', city_names: 'London'),
Esse::HashDocument.new(_id: '3', city_names: nil),
Esse::HashDocument.new(_id: '4', city_names: ''),
Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London'),
Esse::LazyDocumentHeader.new(id: '3').to_doc(city_names: nil),
Esse::LazyDocumentHeader.new(id: '4').to_doc(city_names: ''),
])
end
end
Expand Down Expand Up @@ -194,7 +195,7 @@
it 'updates the documents' do
expect(repo.index).to receive(:bulk).with(
update: [
Esse::HashDocument.new(_id: '2', city_names: 'London')
Esse::LazyDocumentHeader.new(id: '2').to_doc(city_names: 'London')
]
)
repo.update_documents_attribute(:city_names, '2')
Expand Down

0 comments on commit c04033b

Please sign in to comment.