Handle missing manifest link

This commit is contained in:
2018-06-29 10:39:58 -07:00
parent 26836d68d0
commit 936aa38ff8
3 changed files with 74 additions and 18 deletions

37
spec/fixtures/mastodon-no-manifest.html vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -66,12 +66,36 @@ RSpec.describe Manifique::WebClient do
let(:web_client) { Manifique::WebClient.new(url: "https://kosmos.social") }
subject { web_client.fetch_web_manifest }
subject do
web_client.fetch_website
web_client.fetch_web_manifest
end
it "fetches and returns the manifest" do
expect(subject).to be_kind_of(Hash)
expect(subject["name"]).to eq("kosmos.social")
end
end
context "no link[rel=manifest] element found" do
before do
index_html = File.read(File.join(__dir__, "..", "fixtures", "mastodon-no-manifest.html"));
stub_request(:get, "https://kosmos.social/").
to_return(body: index_html, status: 200, headers: {
"Content-Type": "text/html; charset=utf-8"
})
end
let(:web_client) { Manifique::WebClient.new(url: "https://kosmos.social") }
subject do
web_client.fetch_website
web_client.fetch_web_manifest
end
it "returns false" do
expect(subject).to be(false)
end
end
end
end