account_show_page_spec.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'The account show page' do
  4. it 'Has an h-feed with correct number of h-entry objects in it' do
  5. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  6. _status = Fabricate(:status, account: alice, text: 'Hello World')
  7. _status2 = Fabricate(:status, account: alice, text: 'Hello World Again')
  8. _status3 = Fabricate(:status, account: alice, text: 'Are You Still There World?')
  9. get '/@alice'
  10. expect(h_feed_entries.size).to eq(3)
  11. end
  12. it 'has valid opengraph tags' do
  13. alice = Fabricate(:account, username: 'alice', display_name: 'Alice')
  14. _status = Fabricate(:status, account: alice, text: 'Hello World')
  15. get '/@alice'
  16. expect(head_meta_content('og:title')).to match alice.display_name
  17. expect(head_meta_content('og:type')).to eq 'profile'
  18. expect(head_meta_content('og:image')).to match '.+'
  19. expect(head_meta_content('og:url')).to match 'http://.+'
  20. end
  21. def head_meta_content(property)
  22. head_section.meta("[@property='#{property}']")[:content]
  23. end
  24. def head_section
  25. Nokogiri::Slop(response.body).html.head
  26. end
  27. def h_feed_entries
  28. Nokogiri::HTML(response.body).search('.h-feed .h-entry')
  29. end
  30. end