spec/ajax/helpers_spec.rb in ajax-0.1.3 vs spec/ajax/helpers_spec.rb in ajax-0.1.4

- old
+ new

@@ -14,10 +14,15 @@ it "should handle no query string" do Ajax.hashed_url_from_traditional('/Beyonce').should == '/#/Beyonce' end + it "should handle special characters" do + Ajax.hashed_url_from_traditional('/beyoncé').should == '/#/beyonc%C3%A9' + Ajax.hashed_url_from_traditional('/red hot').should == '/#/red%20hot' + end + DOMAINS.each do |domain| it "should work for domain #{domain}" do Ajax.hashed_url_from_traditional("http://#{domain}/playlists").should == "http://#{domain}/#/playlists" end end @@ -26,10 +31,15 @@ describe "(URL) hashed_url_from_fragment" do it "should strip double slashes" do Ajax.hashed_url_from_fragment('/Beyonce#/Akon').should == '/#/Akon' Ajax.hashed_url_from_fragment('/Beyonce#Akon').should == '/#/Akon' end + + it "should handle special characters" do + Ajax.hashed_url_from_fragment('/#/beyoncé').should == '/#/beyonc%C3%A9' + Ajax.hashed_url_from_fragment('/#/red hot').should == '/#/red%20hot' + end it "should handle no fragment" do Ajax.hashed_url_from_fragment('/Beyonce').should == '/#/' end @@ -44,19 +54,24 @@ describe "(boolean) url_is_root?" do it "should detect root urls" do Ajax.url_is_root?('/#/Beyonce?query2').should be(true) Ajax.url_is_root?('/').should be(true) + Ajax.url_is_root?('/#/beyoncé'). should be(true) end it "should detect non-root urls" do Ajax.url_is_root?('/Beyonce').should be(false) end it "should support full URLs" do Ajax.is_hashed_url?('http://musicsocial.com.local/#/playlists').should be(true) end + + it "should support special characters" do + Ajax.is_hashed_url?('http://musicsocial.com.local/#/beyoncé').should be(true) + end end describe "(boolean) is_hashed_url?" do it "should return false for fragments that don't start with /" do Ajax.is_hashed_url?('/Beyonce#Akon').should be(false) @@ -86,10 +101,15 @@ Ajax.traditional_url_from_fragment('/Beyonce#/Akon').should == '/Akon' Ajax.traditional_url_from_fragment('/Beyonce#/Akon/').should == '/Akon/' end it "should handle no fragment" do - Ajax.traditional_url_from_fragment('/Beyonce').should == '/' + Ajax.traditional_url_from_fragment('/Beyonce#/beyoncé').should == '/beyonc%C3%A9' + Ajax.traditional_url_from_fragment('/#/red hot').should == '/red%20hot' + end + + it "should handle special characters" do + Ajax.traditional_url_from_fragment('/Beyonce#/Akon').should == '/Akon' end DOMAINS.each do |domain| it "should work for domain #{domain}" do Ajax.traditional_url_from_fragment("http://#{domain}/Beyonce/#playlists").should == "http://#{domain}/playlists"