2021-05-26 17:41:35 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe Onebox::Engine::WikimediaOnebox do
|
2021-05-26 17:41:35 +08:00
|
|
|
let(:link) { "https://commons.wikimedia.org/wiki/File:Stones_members_montage2.jpg" }
|
|
|
|
let(:api_link) do
|
|
|
|
"https://en.wikipedia.org/w/api.php?action=query&titles=File:Stones_members_montage2.jpg&prop=imageinfo&iilimit=50&iiprop=timestamp|user|url&iiurlwidth=500&format=json"
|
2023-01-09 19:18:21 +08:00
|
|
|
end
|
2021-05-26 17:41:35 +08:00
|
|
|
let(:html) { described_class.new(link).to_html }
|
|
|
|
|
|
|
|
before { stub_request(:get, api_link).to_return(status: 200, body: onebox_response("wikimedia")) }
|
|
|
|
|
|
|
|
it "has the title" do
|
|
|
|
expect(html).to include("File:Stones members montage2.jpg")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "has the link" do
|
|
|
|
expect(html).to include(link)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "has the image" do
|
|
|
|
expect(html).to include(
|
2023-07-15 02:20:18 +08:00
|
|
|
"https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Stones_members_montage2.jpg/500px-Stones_members_montage2.jpg",
|
2021-05-26 17:41:35 +08:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|