require 'test_helper'
class HelperMethodsTest < ActionView::TestCase
include Metamagic::HelperMethods
test "meta tags generation" do
meta title: "My Title",
description: "My description.",
keywords: ["One", "Two", "Three"]
assert_equal %{
My Title\n\n},
metamagic
end
test "default meta tags" do
meta title: "Test Title",
test: "Test tag"
assert_equal %{Test Title\n\n},
metamagic(title: "Default Title", description: "Default description", test: "Default test")
end
test "not adding existing meta tags" do
meta title: "Test Title",
description: "Test description."
meta title: "Second Title",
description: "Second description."
assert_equal %{Test Title\n},
metamagic
end
test "open graph" do
meta title: "Test Title",
og: {
image: {
url: "http://test.com/image.jpg",
type: "image/png"
}
}
assert_equal %{Test Title\n\n},
metamagic
end
test "twitter cards" do
meta title: "Test Title",
twitter: {
card: :summary,
site: "@flickr"
}
assert_equal %{Test Title\n\n},
metamagic
end
test "custom tags" do
Metamagic::Renderer.register_tag_type :custom, ->(key, value) { tag(:custom_tag, one: key, two: value) }
meta title: "Test Title",
custom: {
first: "This is the first",
second: "This is the second"
}
assert_equal %{Test Title\n\n},
metamagic
end
end