add image specs

This commit is contained in:
Ben Balter 2017-04-07 16:27:41 -04:00
parent 44d52ca4b7
commit efab796817
No known key found for this signature in database
GPG Key ID: DBB67C246AD356C4
2 changed files with 56 additions and 1 deletions

View File

@ -143,7 +143,7 @@ module Jekyll
return @image if defined?(@image)
image = page["image"]
return unless image
return @image = nil unless image
image = { "path" => image } if image.is_a?(String)
image["path"] ||= image["facebook"] || image["twitter"]

View File

@ -359,6 +359,61 @@ RSpec.describe Jekyll::SeoTag::Drop do
end
context "image" do
let(:page) { make_page({"image" => image })}
context "with image as a string" do
let(:image) { "image.png" }
it "returns a hash" do
expect(subject.image).to be_a(Hash)
end
it "returns the image" do
expect(subject.image["path"]).to eql("/image.png")
end
context "with site.url" do
let(:site) { make_site({"url" => "http://example.com"})}
it "makes the path absolute" do
expect(subject.image["path"]).to eql("http://example.com/image.png")
end
end
context "with a URL-escaped path" do
let(:image) { "some image.png" }
it "URL-escapes the image" do
expect(subject.image["path"]).to eql("/some%20image.png")
end
end
end
context "with image as a hash" do
context "with a path" do
let(:image) { { "path" => "image.png" } }
it "returns the image" do
expect(subject.image["path"]).to eql("/image.png")
end
end
context "with facebook" do
let(:image) { { "facebook" => "image.png" } }
it "returns the image" do
expect(subject.image["path"]).to eql("/image.png")
end
end
context "with twitter" do
let(:image) { { "twitter" => "image.png" } }
it "returns the image" do
expect(subject.image["path"]).to eql("/image.png")
end
end
end
end
context "lang" do