From 41e5496d2b5dc31fdac4fa5949c126d9b97d1666 Mon Sep 17 00:00:00 2001 From: David Gil Date: Tue, 11 Aug 2015 23:56:16 +0200 Subject: [PATCH] add a couple of tests for the tag limit feature --- spec/features/debates_spec.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index b0c7a3a60..ccbee0a93 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -130,4 +130,37 @@ feature 'Debates' do expect(page).to have_content "Let's..." end + describe 'Limiting tags shown' do + let(:all_tags) { + ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"] + } + let(:debate) { + create :debate, tag_list: all_tags + } + + scenario 'Index page show up to 5 tags per debate' do + debate + visible_tags = ["Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"] + + visit debates_path + + expect(page).to have_selector('.debate', count: 1) + within('.debate') do + visible_tags.each do |tag| + expect(page).to have_content tag + end + expect(page).to have_content '2+' + end + end + + scenario 'Debate#show shows the full tag list' do + visit debate_path(debate) + + within("#debate-#{debate.id}") do + all_tags.each do |tag| + expect(page).to have_content tag + end + end + end + end end