require "test_helper" class Opengraph::DocumentTest < ActiveSupport::TestCase test "extract opengraph tags using property attribute" do document = Opengraph::Document.new("
") attributes = document.opengraph_attributes assert_equal "https://example.com", attributes[:url] assert_equal "Hey!", attributes[:title] assert_equal "desc..", attributes[:description] assert_equal "https://example.com/image.png", attributes[:image] end test "extract opengraph tags using name attribute" do document = Opengraph::Document.new("") attributes = document.opengraph_attributes assert_equal "https://example.com", attributes[:url] assert_equal "Hey!", attributes[:title] assert_equal "desc..", attributes[:description] assert_equal "https://example.com/image.png", attributes[:image] end test "document containing missing meta encoding tag and non-UTF8 characters" do document = Opengraph::Document.new("") attributes = document.opengraph_attributes assert_equal "https://example.com", attributes[:url] assert_equal "Hey!", attributes[:title] assert_equal "Hello World", attributes[:description] assert_equal "https://example.com/image.png", attributes[:image] end end