account_show_page_spec.rb 716 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'The account show page' do
  4. it 'has valid opengraph tags' do
  5. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  6. _status = Fabricate(:status, account: alice, text: 'Hello World')
  7. get '/@alice'
  8. expect(head_meta_content('og:title')).to match alice.display_name
  9. expect(head_meta_content('og:type')).to eq 'profile'
  10. expect(head_meta_content('og:image')).to match '.+'
  11. expect(head_meta_content('og:url')).to match 'http://.+'
  12. end
  13. def head_meta_content(property)
  14. head_section.meta("[@property='#{property}']")[:content]
  15. end
  16. def head_section
  17. Nokogiri::Slop(response.body).html.head
  18. end
  19. end