diff --git a/spec/views/answerbox/_smiles.html.haml_spec.rb b/spec/views/answerbox/_smiles.html.haml_spec.rb new file mode 100644 index 00000000..5530d648 --- /dev/null +++ b/spec/views/answerbox/_smiles.html.haml_spec.rb @@ -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