From 37bc1e64deb067e6fe8424732bf8b7e0079021be Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 10 Jul 2022 12:44:22 +0200 Subject: [PATCH] Add test for `Exporter#collect_comments` --- spec/lib/exporter_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/lib/exporter_spec.rb b/spec/lib/exporter_spec.rb index 04411964..4f59c252 100644 --- a/spec/lib/exporter_spec.rb +++ b/spec/lib/exporter_spec.rb @@ -145,6 +145,31 @@ RSpec.describe Exporter do 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 let!(:smiles) { FactoryBot.create_list(:smile, 25, user: user) }