2021-05-26 17:41:35 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe Onebox::Engine::WikipediaOnebox do
|
2021-05-26 17:41:35 +08:00
|
|
|
before do
|
|
|
|
@link = "http://en.wikipedia.org/wiki/Billy_Jack"
|
|
|
|
|
|
|
|
stub_request(:get, "https://en.wikipedia.org/wiki/Billy_Jack")
|
|
|
|
.to_return(status: 200, body: onebox_response(described_class.onebox_name))
|
|
|
|
end
|
|
|
|
|
2022-07-28 00:14:14 +08:00
|
|
|
include_context "with engines"
|
2021-05-26 17:41:35 +08:00
|
|
|
it_behaves_like "an engine"
|
|
|
|
|
|
|
|
describe "#to_html" do
|
|
|
|
it "includes article image" do
|
|
|
|
expect(html).to include("Billy_Jack_poster.jpg")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "includes summary" do
|
|
|
|
expect(html).to include("Billy Jack is a 1971 action/drama")
|
|
|
|
end
|
|
|
|
end
|
2021-08-12 04:54:42 +08:00
|
|
|
|
2022-07-28 00:14:14 +08:00
|
|
|
describe "url with section hash" do
|
2021-08-12 04:54:42 +08:00
|
|
|
before do
|
|
|
|
@link = "http://en.wikipedia.org/wiki/Billy_Jack#Soundtrack"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "includes summary" do
|
|
|
|
expect(html).to include("The film score was composed")
|
|
|
|
end
|
|
|
|
end
|
2021-08-12 04:55:50 +08:00
|
|
|
|
2022-07-28 00:14:14 +08:00
|
|
|
describe "url with url-encoded section hash" do
|
2021-08-12 04:55:50 +08:00
|
|
|
before do
|
|
|
|
@link = "https://fr.wikipedia.org/wiki/Th%C3%A9ologie#La_th%C3%A9ologie_selon_Aristote"
|
|
|
|
|
|
|
|
stub_request(:get, "https://fr.wikipedia.org/wiki/Th%C3%A9ologie")
|
|
|
|
.to_return(status: 200, body: onebox_response("wikipedia_url_encoded"))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "includes summary" do
|
|
|
|
expect(html).to include("Le terme est repris par")
|
|
|
|
end
|
|
|
|
end
|
2021-05-26 17:41:35 +08:00
|
|
|
end
|