Add view tests for smiles list partial

This commit is contained in:
Karina Kwiatek 2023-09-14 16:37:11 +01:00
parent 81b271ab03
commit ed664c9580
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
require "rails_helper"
describe "answerbox/_smiles.html.haml", type: :view do
subject(:rendered) do
render partial: "answerbox/smiles", locals: { a: }
end
let(:a) { FactoryBot.create(:answer, user: FactoryBot.create(:user)) }
context "no reactions" do
it "shows an empty list" do
expect(rendered).to match("No one smiled this yet.")
end
end
context "reactions are present" do
let!(:reactions) { FactoryBot.create_list(:smile, 5, parent: a) }
it "shows a list of users" do
html = Nokogiri::HTML.parse(rendered)
selector = %(.smiles a)
reaction_elements = html.css(selector)
expect(reaction_elements.size).to eq(5)
end
end
end