diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index a50d26f7c..14a5310ba 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -16,7 +16,7 @@ feature 'Account' do expect(page).to have_selector("input[value='Manuela']") expect(page).to have_selector("input[value='Colau']") - expect(page).to have_selector("img.initialjs-avatar[data-name='Manuela Colau'][data-height='100']", count: 1) + expect(page).to have_selector(avatar('Manuela Colau'), count: 1) end scenario "Failed Edit" do diff --git a/spec/features/comments_spec.rb b/spec/features/comments_spec.rb index 3fa2464fb..93547ffd2 100644 --- a/spec/features/comments_spec.rb +++ b/spec/features/comments_spec.rb @@ -17,7 +17,7 @@ feature 'Comments' do expect(page).to have_content comment.user.name expect(page).to have_content time_ago_in_words(comment.created_at) expect(page).to have_content comment.body - expect(page).to have_selector("img.initialjs-avatar[data-name='#{comment.user.name}'][data-height='32']", count: 1) + expect(page).to have_selector(avatar(comment.user.name), count: 1) end end diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index 4a9f8c8f3..87856c457 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -25,7 +25,7 @@ feature 'Debates' do expect(page).to have_content "Debate description" expect(page).to have_content debate.author.name expect(page).to have_content I18n.l(Date.today) - expect(page).to have_selector("img.initialjs-avatar[data-name='#{debate.author.name}'][data-height='32']", count: 1) + expect(page).to have_selector(avatar(debate.author.name), count: 1) within('.social-share-button') do expect(page.all('a').count).to be(3) # Twitter, Facebook, Google+ diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 5e56d2cea..066e32b87 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -56,4 +56,8 @@ module CommonActions SimpleCaptcha::SimpleCaptchaData.first.value end + def avatar(name) + "img.initialjs-avatar[data-name='#{name}']" + end + end