require 'spec_helper'
describe TopHat::OpenGraphHelper do
before(:each) do
@template = ActionView::Base.new
end
context "site admins when configured" do
context "as a string" do
it "should generate a site admin tag" do
@template.opengraph(:admins => '123,124')
@template.opengraph.should be_dom_equivalent_to('\n')
end
end
context "as an array" do
it "should generate a site admin tag" do
@template.opengraph(:admins => [123, 124])
@template.opengraph.should be_dom_equivalent_to('\n')
end
end
end
context "app_id when configured" do
it "should generate an app_id meta tag" do
@template.opengraph(:app_id => 'MyApp')
@template.opengraph.should be_dom_equivalent_to('\n')
end
end
context "additional open graph properties" do
it "should generate tags" do
@template.opengraph { |graph| graph.title 'The Great Gatsby' }
@template.opengraph.should be_dom_equivalent_to('')
end
it "should allow use of the tag 'type'" do
@template.opengraph { |graph| graph.type 'sports_team' }
@template.opengraph.should be_dom_equivalent_to('')
end
it "should support multiple tags" do
@template.opengraph { |graph|
graph.title 'Austin Powers: International Man of Mystery'
graph.type 'movie'
}
@template.opengraph.should be_dom_equivalent_to('\n\n')
end
end
context "combined usage" do
it "should generate all tags" do
@template.opengraph(:app_id => 'MyApp', :admins => [123, 1234]) { |graph|
graph.title 'Rain Man'
graph.type 'movie'
}
@template.opengraph.should be_dom_equivalent_to('\n\n\n\n')
end
it "should generate all tags - alternative usage" do
@template.opengraph { |graph|
graph.title 'Rain Man'
graph.type 'movie'
}
@template.opengraph(:app_id => 'MyApp', :admins => [123, 1234]).should be_dom_equivalent_to('\n\n\n\n')
end
end
end