test/bitly/test_client.rb in bitly-0.3.2 vs test/bitly/test_client.rb in bitly-0.4.0

- old
+ new

@@ -21,11 +21,15 @@ should "return a Bitly::Url" do assert_kind_of Bitly::Url, @url end should "return a short bitly url" do assert_equal "http://bit.ly/15DlK", @url.short_url + assert_equal "http://bit.ly/15DlK", @url.bitly_url end + should "return a short jmp url" do + assert_equal "http://j.mp/15DlK", @url.jmp_url + end should "save the long url" do assert_equal "http://cnn.com", @url.long_url end end context "multiple links" do @@ -71,11 +75,11 @@ end should "save the short url" do assert_equal "http://bit.ly/31IqMl", @url.short_url end end - context "a short url" do + context "a short bitly url" do setup do stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json") @url = @bitly.expand("http://bit.ly/31IqMl") end should "return a Bitly::Url" do @@ -85,11 +89,35 @@ assert_equal "http://cnn.com/", @url.long_url end should "save the hash" do assert_equal "31IqMl", @url.hash end - should "save the short url" do - assert_equal "http://bit.ly/31IqMl", @url.short_url + should "save the bitly url" do + assert_equal "http://bit.ly/31IqMl", @url.bitly_url + end + should "save a jmp url" do + assert_equal "http://j.mp/31IqMl", @url.jmp_url + end + end + context "a short jmp url" do + setup do + stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=31IqMl.*$/,"expand_cnn.json") + @url = @bitly.expand("http://j.mp/31IqMl") + end + should "return a Bitly::Url" do + assert_kind_of Bitly::Url, @url + end + should "return the expanded url" do + assert_equal "http://cnn.com/", @url.long_url + end + should "save the hash" do + assert_equal "31IqMl", @url.hash + end + should "save the bitly url" do + assert_equal "http://bit.ly/31IqMl", @url.bitly_url + end + should "save a jmp url" do + assert_equal "http://j.mp/31IqMl", @url.jmp_url end end context "multiple hashes" do setup do stub_get(/^http:\/\/api.bit.ly\/expand\?.*hash=15DlK.*3j4ir4.*$/,"expand_cnn_and_google.json") \ No newline at end of file