Add test for `Exporter#collect_comments`

This commit is contained in:
Karina Kwiatek 2022-07-10 12:44:22 +02:00 committed by Karina Kwiatek
parent 75301900b3
commit 37bc1e64de
1 changed files with 25 additions and 0 deletions

View File

@ -145,6 +145,31 @@ RSpec.describe Exporter do
end end
end end
describe "#collect_comments" do
let!(:comments) do
FactoryBot.create_list(:comment,
25,
user: user,
answer: FactoryBot.create(:answer, user: FactoryBot.create(:user)))
end
subject { instance.send(:collect_comments) }
it "collects comments" do
subject
expect(instance.instance_variable_get(:@obj)[:comments]).to eq(comments.map do |c|
{
content: c.content,
created_at: c.reload.created_at,
id: c.id,
answer: instance.send(:process_answer,
c.answer,
include_comments: false)
}
end)
end
end
describe "#collect_smiles" do describe "#collect_smiles" do
let!(:smiles) { FactoryBot.create_list(:smile, 25, user: user) } let!(:smiles) { FactoryBot.create_list(:smile, 25, user: user) }