require 'helper' class TopHatOpenGraphTestCase < Test::Unit::TestCase context "when using the open graph helpers" do setup do @template = ActionView::Base.new end context "site admins when configured" do context "as a string" do should "generate a site admin tag" do @template.opengraph(:admins => '123,124') assert_equal @template.opengraph, '\n' end end context "as an array" do should "generate a site admin tag" do @template.opengraph(:admins => [123, 124]) assert_equal @template.opengraph, '\n' end end end context "app_id when configured" do should "generate an app_id meta tag" do @template.opengraph(:app_id => 'MyApp') assert_equal @template.opengraph, '\n' end end context "additional open graph properties" do should "generate tags" do @template.opengraph do |graph| graph.title 'The Great Gatsby' end assert_equal @template.opengraph, '' end should "allow use of the tag 'type'" do @template.opengraph do |graph| graph.type 'sports_team' end assert_equal @template.opengraph, '' end should "support multiple tags" do @template.opengraph do |graph| graph.title 'Austin Powers: International Man of Mystery' graph.type 'movie' end assert_equal @template.opengraph, '\n\n' end end context "combined usage" do should "generate all tags" do @template.opengraph(:app_id => 'MyApp', :admins => [123, 1234]) do |graph| graph.title 'Rain Man' graph.type 'movie' end assert_equal @template.opengraph, '\n\n\n\n' end should "generate all tags - alternative usage" do @template.opengraph do |graph| graph.title 'Rain Man' graph.type 'movie' end assert_equal @template.opengraph(:app_id => 'MyApp', :admins => [123, 1234]), '\n\n\n\n' end end end end