0
0

Combine repeated subjects in link details extractor spec (#28941)

This commit is contained in:
Matt Jankowski 2024-01-26 11:31:07 -05:00 committed by GitHub
parent 685eaa04d4
commit 1a30a517d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -46,22 +46,13 @@ RSpec.describe LinkDetailsExtractor do
</html> </html>
HTML HTML
describe '#title' do it 'extracts the expected values from html metadata' do
it 'returns the title from title tag' do expect(subject)
expect(subject.title).to eq 'Man bites dog' .to have_attributes(
end title: eq('Man bites dog'),
end description: eq("A dog's tale"),
language: eq('en')
describe '#description' do )
it 'returns the description from meta tag' do
expect(subject.description).to eq "A dog's tale"
end
end
describe '#language' do
it 'returns the language from lang attribute' do
expect(subject.language).to eq 'en'
end
end end
end end
@ -90,40 +81,16 @@ RSpec.describe LinkDetailsExtractor do
end end
shared_examples 'structured data' do shared_examples 'structured data' do
describe '#title' do it 'extracts the expected values from structured data' do
it 'returns the title from structured data' do expect(subject)
expect(subject.title).to eq 'Man bites dog' .to have_attributes(
end title: eq('Man bites dog'),
end description: eq("A dog's tale"),
published_at: eq('2022-01-31T19:53:00+00:00'),
describe '#description' do author_name: eq('Charlie Brown'),
it 'returns the description from structured data' do provider_name: eq('Pet News'),
expect(subject.description).to eq "A dog's tale" language: eq('en')
end )
end
describe '#published_at' do
it 'returns the publicaton time from structured data' do
expect(subject.published_at).to eq '2022-01-31T19:53:00+00:00'
end
end
describe '#author_name' do
it 'returns the author name from structured data' do
expect(subject.author_name).to eq 'Charlie Brown'
end
end
describe '#provider_name' do
it 'returns the provider name from structured data' do
expect(subject.provider_name).to eq 'Pet News'
end
end
describe '#language' do
it 'returns the language from structured data' do
expect(subject.language).to eq 'en'
end
end end
end end
@ -245,58 +212,19 @@ RSpec.describe LinkDetailsExtractor do
</html> </html>
HTML HTML
describe '#canonical_url' do it 'extracts the expected values from open graph data' do
it 'returns the URL from Open Graph protocol data' do expect(subject)
expect(subject.canonical_url).to eq 'https://example.com/dog.html' .to have_attributes(
end canonical_url: eq('https://example.com/dog.html'),
end title: eq('Man bites dog'),
description: eq("A dog's tale"),
describe '#title' do published_at: eq('2022-01-31T19:53:00+00:00'),
it 'returns the title from Open Graph protocol data' do author_name: eq('Charlie Brown'),
expect(subject.title).to eq 'Man bites dog' language: eq('en'),
end image: eq('https://example.com/snoopy.jpg'),
end image_alt: eq('A good boy'),
provider_name: eq('Pet News')
describe '#description' do )
it 'returns the description from Open Graph protocol data' do
expect(subject.description).to eq "A dog's tale"
end
end
describe '#published_at' do
it 'returns the publicaton time from Open Graph protocol data' do
expect(subject.published_at).to eq '2022-01-31T19:53:00+00:00'
end
end
describe '#author_name' do
it 'returns the author name from Open Graph protocol data' do
expect(subject.author_name).to eq 'Charlie Brown'
end
end
describe '#language' do
it 'returns the language from Open Graph protocol data' do
expect(subject.language).to eq 'en'
end
end
describe '#image' do
it 'returns the image from Open Graph protocol data' do
expect(subject.image).to eq 'https://example.com/snoopy.jpg'
end
end
describe '#image:alt' do
it 'returns the image description from Open Graph protocol data' do
expect(subject.image_alt).to eq 'A good boy'
end
end
describe '#provider_name' do
it 'returns the provider name from Open Graph protocol data' do
expect(subject.provider_name).to eq 'Pet News'
end
end end
end end
end end