addressabler 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -0
- data/README.markdown +1 -1
- data/lib/addressabler.rb +2 -1
- data/lib/tlds +3296 -252
- data/spec/addressabler_spec.rb +30 -17
- data/spec/uri_spec.rb +1076 -125
- metadata +68 -66
data/spec/addressabler_spec.rb
CHANGED
@@ -5,20 +5,27 @@ describe Addressabler do
|
|
5
5
|
uri = Addressable::URI.parse("http://www.google.com/path?foo=bar#anchor")
|
6
6
|
uri.should be_instance_of(Addressable::URI)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should get the scheme of a URI" do
|
10
10
|
uri = Addressable::URI.parse("http://www.google.com/path?foo=bar#anchor")
|
11
11
|
uri.scheme.should == "http"
|
12
12
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
|
14
|
+
describe "TLD parsing" do
|
15
|
+
it "returns a TLD" do
|
16
|
+
uri = Addressable::URI.parse("http://www.google.com/path?foo=bar#anchor")
|
17
|
+
uri.tld.should == 'com'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "knows about complex TLDs" do
|
21
|
+
uri = Addressable::URI.parse("http://www.foo.bar.baz.co.uk/gjadgsg#sdgs?adg=f")
|
22
|
+
uri.tld.should == 'co.uk'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "knows about newer TLDs" do
|
26
|
+
uri = Addressable::URI.parse("http://www.bart-blabla.cc")
|
27
|
+
uri.tld.should == 'cc'
|
28
|
+
end
|
22
29
|
end
|
23
30
|
|
24
31
|
it "should support adding keys to the query" do
|
@@ -28,17 +35,23 @@ describe Addressabler do
|
|
28
35
|
uri.to_s.should == "http://www.foo.bar.baz.co.uk/gjadgsg?adg=f&foo=bar"
|
29
36
|
end
|
30
37
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
# TODO: This breaks due to a deprection in Addressable. This test
|
39
|
+
# was probably inappropriate to begin with, as it was testing something
|
40
|
+
# Addressable does, and not something Addressable*r* does.
|
41
|
+
#
|
42
|
+
# This would be a nice feature to have anyway, but alas ... some other
|
43
|
+
# time.
|
44
|
+
#it "should support adding nested values to the query" do
|
45
|
+
#uri = Addressable::URI.parse("http://www.amazon.ca")
|
46
|
+
#uri.query_hash[:foo] = {:bar => :baz}
|
47
|
+
#uri.to_s.should == "http://www.amazon.ca?foo[bar]=baz"
|
48
|
+
#end
|
49
|
+
|
37
50
|
it "should support subdomains" do
|
38
51
|
uri = Addressable::URI.heuristic_parse("i.am.a.subdomain.co.uk")
|
39
52
|
uri.subdomain.should == "i.am.a"
|
40
53
|
end
|
41
|
-
|
54
|
+
|
42
55
|
it "should support domains" do
|
43
56
|
uri = Addressable::URI.heuristic_parse("i.am.a.subdomain.co.uk")
|
44
57
|
uri.domain.should == "subdomain"
|