test/addthis_test.rb in jaap3-addthis-0.5.0 vs test/addthis_test.rb in jaap3-addthis-0.7.0

- old
+ new

@@ -16,11 +16,11 @@ end should "provide addthis_email_button" do assert respond_to?(:addthis_email_button) end - + [:addthis_bookmark_button, :addthis_feed_button, :addthis_email_button].each do |m| context "the output of #{m}" do setup do @output = method(m).call("http://example.com") @output_lines = @output.split("\n") @@ -41,14 +41,23 @@ assert_equal "<!-- AddThis Button END -->", @output_lines.last end end end + [:addthis_bookmark_button, :addthis_email_button].each do |m| + context "the output of #{m} with url and title set" do + setup { @output = method(m).call("http://example.com", "It's an \"example\"") } + + should "include title" do + assert_match "'It\\u0027s an \\u0022example\\u0022'", @output + end + end + end + context "a bookmark/share button" do setup { @output = addthis_bookmark_button } - should_set_alt_to Jaap3::Addthis::BOOKMARK_BUTTON_DEFAULTS[:alt] should_set_title_to Jaap3::Addthis::BOOKMARK_BUTTON_DEFAULTS[:title] should_set_href_to "http://www.addthis.com/bookmark.php?v=20" should "set url to [URL]" do assert_match "'[URL]'", @output @@ -60,23 +69,21 @@ end context "a feed button" do setup { @output = addthis_feed_button("http://example.com") } - should_set_alt_to Jaap3::Addthis::FEED_BUTTON_DEFAULTS[:alt] should_set_title_to Jaap3::Addthis::FEED_BUTTON_DEFAULTS[:title] - should_set_href_to "http://www.addthis.com/feed.php?pub=&h1=http://example.com&t1=" + should_set_href_to "http://www.addthis.com/feed.php?pub=&h1=http%3a%2f%2fexample.com&t1=" should "set url to example.com" do assert_match "'http://example.com')", @output end end context "an email button" do setup { @output = addthis_email_button } - should_set_alt_to Jaap3::Addthis::EMAIL_BUTTON_DEFAULTS[:alt] should_set_title_to Jaap3::Addthis::EMAIL_BUTTON_DEFAULTS[:title] should_set_href_to "http://www.addthis.com/bookmark.php" end context "with publisher configured" do @@ -91,11 +98,11 @@ end context "a feed button" do setup { @output = addthis_feed_button("http://example.com") } - should_set_href_to "http://www.addthis.com/feed.php?pub=test_publisher&h1=http://example.com&t1=" + should_set_href_to "http://www.addthis.com/feed.php?pub=test_publisher&h1=http%3a%2f%2fexample.com&t1=" end context "in turn overwritten by options hash" do [:addthis_bookmark_button, :addthis_feed_button, :addthis_email_button].each do |m| context "the output of #{m}" do @@ -106,11 +113,11 @@ end context "a feed button" do setup { @output = addthis_feed_button("http://example.com", :publisher => "another_publisher") } - should_set_href_to "http://www.addthis.com/feed.php?pub=another_publisher&h1=http://example.com&t1=" + should_set_href_to "http://www.addthis.com/feed.php?pub=another_publisher&h1=http%3a%2f%2fexample.com&t1=" end end end context "with altered script_src" do @@ -133,17 +140,16 @@ end end end end - context "when overwriting alt and title" do + context "when overwriting title" do [:addthis_bookmark_button, :addthis_feed_button, :addthis_email_button].each do |m| context "the output of #{m}" do - setup { @output = method(m).call("http://example.com", :alt => "Example", :title => "Example title") } + setup { @output = method(m).call("http://example.com", :title => "Example title") } should_set_title_to "Example title" - should_set_alt_to "Example" end end end context "when setting secure to true" do @@ -210,13 +216,11 @@ :offset_left => 60, :hover_delay => 200 } [:addthis_bookmark_button, :addthis_feed_button, :addthis_email_button].each do |m| context "the output of #{m}" do - setup do - @output = method(m).call("http://example.com", options) - end + setup { @output = method(m).call("http://example.com", options) } options.each_pair do |attribute, value| should_customize attribute, value end end @@ -226,16 +230,39 @@ context "by changing the defaults the output of #{m}" do setup do options.each_pair do |attribute, value| Jaap3::Addthis::DEFAULT_OPTIONS[attribute] = value end - @output = method(m).call("http://example.com", options) + @output = method(m).call("http://example.com") end options.each_pair do |attribute, value| should_customize attribute, value end end end + end + + context "with a custom list of services" do + context "the output of addthis_bookmark_button" do + setup { @output = addthis_bookmark_button(:options => "facebook, email, twitter, more") } + + should_customize :options, "facebook, email, twitter, more" + end + + context "by changing the defaults the output of addthis_bookmark_button" do + setup do + Jaap3::Addthis::DEFAULT_OPTIONS[:options] = "facebook, email, twitter, more" + @output = addthis_bookmark_button + end + + should_customize :options, "facebook, email, twitter, more" + end + end + + context "with a custom language set" do + setup { @output = addthis_bookmark_button(:language => "nl") } + + should_customize :language, "nl" end end \ No newline at end of file