addressable 0.1.2 → 1.0.0

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.
@@ -23,9 +23,9 @@
23
23
 
24
24
  module Addressable
25
25
  module ADDRESSABLE_VERSION #:nodoc:
26
- MAJOR = 0
27
- MINOR = 1
28
- TINY = 2
26
+ MAJOR = 1
27
+ MINOR = 0
28
+ TINY = 0
29
29
 
30
30
  STRING = [MAJOR, MINOR, TINY].join('.')
31
31
  end
data/rakefile CHANGED
@@ -148,22 +148,13 @@ namespace :spec do
148
148
  t.spec_opts = ['--color']
149
149
  end
150
150
 
151
- namespace :heckle do
152
- desc "Heckle the URI class"
153
- Spec::Rake::SpecTask.new(:uri) do |t|
154
- t.spec_files = FileList['spec/addressable/uri_spec.rb']
155
- t.spec_opts = ['--heckle', 'Addressable::URI']
156
- end
151
+ desc "Heckle the URI class"
152
+ Spec::Rake::SpecTask.new(:heckle) do |t|
153
+ heckle_param = 'Addressable::URI'
154
+ heckle_param = ENV['TARGET'] if ENV['TARGET']
155
+ t.spec_files = FileList['spec/addressable/uri_spec.rb']
156
+ t.spec_opts = ['--heckle', heckle_param]
157
157
  end
158
-
159
- # desc "Start up autotest for RSpec"
160
- # task :autospec do
161
- # require 'autotest'
162
- # require 'autotest/growl'
163
- # require 'autotest/redgreen'
164
- # require 'vendor/autospec/lib/autospec'
165
- # Autospec.run
166
- # end
167
158
 
168
159
  desc "Print Specdoc for all specs"
169
160
  Spec::Rake::SpecTask.new(:doc) do |t|
@@ -48,14 +48,6 @@ class ExampleProcessor
48
48
  end
49
49
  end
50
50
 
51
- describe Addressable::URI, "when created from nil components" do
52
- it "should raise an error" do
53
- (lambda do
54
- Addressable::URI.new(nil, nil, nil, nil, nil, nil, nil, nil)
55
- end).should raise_error(Addressable::URI::InvalidURIError)
56
- end
57
- end
58
-
59
51
  describe Addressable::URI, "when created with a non-numeric port number" do
60
52
  it "should raise an error" do
61
53
  (lambda do
@@ -73,6 +65,20 @@ describe Addressable::URI, "when created with a scheme but no hierarchical " +
73
65
  end
74
66
  end
75
67
 
68
+ describe Addressable::URI, "when created from nil components" do
69
+ before do
70
+ @uri = Addressable::URI.new(nil, nil, nil, nil, nil, nil, nil, nil)
71
+ end
72
+
73
+ it "should have an empty path" do
74
+ @uri.path.should == ""
75
+ end
76
+
77
+ it "should be an empty uri" do
78
+ @uri.to_s.should == ""
79
+ end
80
+ end
81
+
76
82
  describe Addressable::URI, "when created from string components" do
77
83
  before do
78
84
  @uri = Addressable::URI.new(
@@ -84,6 +90,15 @@ describe Addressable::URI, "when created from string components" do
84
90
  end
85
91
  end
86
92
 
93
+ describe Addressable::URI, "when created with a nil host but " +
94
+ "non-nil authority components" do
95
+ it "should raise an error" do
96
+ (lambda do
97
+ Addressable::URI.new(nil, "user", "pass", nil, 80, nil, nil, nil)
98
+ end).should raise_error(Addressable::URI::InvalidURIError)
99
+ end
100
+ end
101
+
87
102
  # Section 1.1.2 of RFC 3986
88
103
  describe Addressable::URI, " when parsed from " +
89
104
  "'ftp://ftp.is.co.za/rfc/rfc1808.txt'" do
@@ -312,6 +327,14 @@ describe Addressable::URI, " when parsed from " +
312
327
  @uri.inspect.should include("http://example.com")
313
328
  end
314
329
 
330
+ it "when inspected, should have the correct class name" do
331
+ @uri.inspect.should include("Addressable::URI")
332
+ end
333
+
334
+ it "when inspected, should have the correct object id" do
335
+ @uri.inspect.should include("%#0x" % @uri.object_id)
336
+ end
337
+
315
338
  it "should use the 'http' scheme" do
316
339
  @uri.scheme.should == "http"
317
340
  end
@@ -503,7 +526,7 @@ describe Addressable::URI, " when parsed from " +
503
526
  end
504
527
 
505
528
  it "should correctly convert to a hash" do
506
- @uri.to_h.should == {
529
+ @uri.to_hash.should == {
507
530
  :scheme => "http",
508
531
  :user => nil,
509
532
  :password => nil,
@@ -514,6 +537,10 @@ describe Addressable::URI, " when parsed from " +
514
537
  :fragment => nil
515
538
  }
516
539
  end
540
+
541
+ it "should be identical to its duplicate" do
542
+ @uri.should == @uri.dup
543
+ end
517
544
  end
518
545
 
519
546
  describe Addressable::URI, " when parsed from " +
@@ -562,7 +589,7 @@ describe Addressable::URI, " when parsed from " +
562
589
  end
563
590
 
564
591
  it "should correctly convert to a hash" do
565
- @uri.to_h.should == {
592
+ @uri.to_hash.should == {
566
593
  :scheme => "http",
567
594
  :user => nil,
568
595
  :password => nil,
@@ -573,6 +600,10 @@ describe Addressable::URI, " when parsed from " +
573
600
  :fragment => nil
574
601
  }
575
602
  end
603
+
604
+ it "should be identical to its duplicate" do
605
+ @uri.should == @uri.dup
606
+ end
576
607
  end
577
608
 
578
609
  describe Addressable::URI, " when parsed from " +
@@ -586,7 +617,7 @@ describe Addressable::URI, " when parsed from " +
586
617
  end
587
618
 
588
619
  it "should correctly convert to a hash" do
589
- @uri.to_h.should == {
620
+ @uri.to_hash.should == {
590
621
  :scheme => "http",
591
622
  :user => "",
592
623
  :password => nil,
@@ -597,6 +628,10 @@ describe Addressable::URI, " when parsed from " +
597
628
  :fragment => nil
598
629
  }
599
630
  end
631
+
632
+ it "should be identical to its duplicate" do
633
+ @uri.should == @uri.dup
634
+ end
600
635
  end
601
636
 
602
637
  describe Addressable::URI, " when parsed from " +
@@ -612,6 +647,10 @@ describe Addressable::URI, " when parsed from " +
612
647
  it "should not be considered to be in normal form" do
613
648
  @uri.normalize.should_not be_eql(@uri)
614
649
  end
650
+
651
+ it "should be identical to its duplicate" do
652
+ @uri.should == @uri.dup
653
+ end
615
654
  end
616
655
 
617
656
  describe Addressable::URI, " when parsed from " +
@@ -625,7 +664,7 @@ describe Addressable::URI, " when parsed from " +
625
664
  end
626
665
 
627
666
  it "should correctly convert to a hash" do
628
- @uri.to_h.should == {
667
+ @uri.to_hash.should == {
629
668
  :scheme => "http",
630
669
  :user => "",
631
670
  :password => "",
@@ -636,6 +675,10 @@ describe Addressable::URI, " when parsed from " +
636
675
  :fragment => nil
637
676
  }
638
677
  end
678
+
679
+ it "should be identical to its duplicate" do
680
+ @uri.should == @uri.dup
681
+ end
639
682
  end
640
683
 
641
684
  describe Addressable::URI, " when parsed from " +
@@ -653,6 +696,10 @@ describe Addressable::URI, " when parsed from " +
653
696
  it "should be equivalent to http://example.com/%7esmith/" do
654
697
  @uri.should == Addressable::URI.parse("http://example.com/%7esmith/")
655
698
  end
699
+
700
+ it "should be identical to its duplicate" do
701
+ @uri.should == @uri.dup
702
+ end
656
703
  end
657
704
 
658
705
  describe Addressable::URI, " when parsed from " +
@@ -675,6 +722,10 @@ describe Addressable::URI, " when parsed from " +
675
722
  Addressable::URI.encode(@uri).to_s.should ==
676
723
  "http://example.com/%25C3%2587"
677
724
  end
725
+
726
+ it "should be identical to its duplicate" do
727
+ @uri.should == @uri.dup
728
+ end
678
729
  end
679
730
 
680
731
  describe Addressable::URI, " when parsed from " +
@@ -730,6 +781,10 @@ describe Addressable::URI, " when parsed from " +
730
781
  it "should be considered to be in normal form" do
731
782
  @uri.normalize.should be_eql(@uri)
732
783
  end
784
+
785
+ it "should be identical to its duplicate" do
786
+ @uri.should == @uri.dup
787
+ end
733
788
  end
734
789
 
735
790
  describe Addressable::URI, " when parsed from " +
@@ -801,9 +856,9 @@ describe Addressable::URI, " when parsed from " +
801
856
  end).should_not raise_error
802
857
  end
803
858
 
804
- it "should result in itself when merged with itself" do
805
- @uri.merge(@uri).to_s.should == "http://example.com:80/"
806
- @uri.merge!(@uri).to_s.should == "http://example.com:80/"
859
+ it "should result in itself when joined with itself" do
860
+ @uri.join(@uri).to_s.should == "http://example.com:80/"
861
+ @uri.join!(@uri).to_s.should == "http://example.com:80/"
807
862
  end
808
863
 
809
864
  # Section 6.2.3 of RFC 3986
@@ -825,6 +880,223 @@ describe Addressable::URI, " when parsed from " +
825
880
  it "should be equal to http://EXAMPLE.COM/" do
826
881
  @uri.should == Addressable::URI.parse("http://EXAMPLE.COM/")
827
882
  end
883
+
884
+ it "should correctly convert to a hash" do
885
+ @uri.to_hash.should == {
886
+ :scheme => "http",
887
+ :user => nil,
888
+ :password => nil,
889
+ :host => "example.com",
890
+ :port => 80,
891
+ :path => "/",
892
+ :query => nil,
893
+ :fragment => nil
894
+ }
895
+ end
896
+
897
+ it "should be identical to its duplicate" do
898
+ @uri.should == @uri.dup
899
+ end
900
+ end
901
+
902
+ describe Addressable::URI, " when parsed from " +
903
+ "'http://example.com:8080/'" do
904
+ before do
905
+ @uri = Addressable::URI.parse("http://example.com:8080/")
906
+ end
907
+
908
+ it "should use the 'http' scheme" do
909
+ @uri.scheme.should == "http"
910
+ end
911
+
912
+ it "should have an authority segment of 'example.com:8080'" do
913
+ @uri.authority.should == "example.com:8080"
914
+ end
915
+
916
+ it "should have a host of 'example.com'" do
917
+ @uri.host.should == "example.com"
918
+ end
919
+
920
+ it "should have no username" do
921
+ @uri.user.should == nil
922
+ end
923
+
924
+ it "should have no password" do
925
+ @uri.password.should == nil
926
+ end
927
+
928
+ it "should use port 8080" do
929
+ @uri.port.should == 8080
930
+ end
931
+
932
+ it "should have a path of '/'" do
933
+ @uri.path.should == "/"
934
+ end
935
+
936
+ it "should have no query string" do
937
+ @uri.query.should == nil
938
+ end
939
+
940
+ it "should have no fragment" do
941
+ @uri.fragment.should == nil
942
+ end
943
+
944
+ it "should be considered absolute" do
945
+ @uri.should be_absolute
946
+ end
947
+
948
+ it "should not be considered relative" do
949
+ @uri.should_not be_relative
950
+ end
951
+
952
+ it "should be exactly equal to http://example.com:8080/" do
953
+ @uri.eql?(Addressable::URI.parse(
954
+ "http://example.com:8080/")).should == true
955
+ end
956
+
957
+ it "should have a route of 'http://example.com:8080/' from " +
958
+ "'http://example.com/path/to/'" do
959
+ @uri.route_from("http://example.com/path/to/").should ==
960
+ Addressable::URI.parse("http://example.com:8080/")
961
+ end
962
+
963
+ it "should have a route of 'http://example.com:8080/' from " +
964
+ "'http://example.com:80/path/to/'" do
965
+ @uri.route_from("http://example.com:80/path/to/").should ==
966
+ Addressable::URI.parse("http://example.com:8080/")
967
+ end
968
+
969
+ it "should have a route of '/' from " +
970
+ "'http://example.com:8080/path/to/'" do
971
+ @uri.route_from("http://example.com:8080/path/to/").should ==
972
+ Addressable::URI.parse("/")
973
+ end
974
+
975
+ it "should have a route of 'http://example.com:8080/' from " +
976
+ "'http://user:pass@example.com/path/to/'" do
977
+ @uri.route_from("http://user:pass@example.com/path/to/").should ==
978
+ Addressable::URI.parse("http://example.com:8080/")
979
+ end
980
+
981
+ it "should correctly convert to a hash" do
982
+ @uri.to_hash.should == {
983
+ :scheme => "http",
984
+ :user => nil,
985
+ :password => nil,
986
+ :host => "example.com",
987
+ :port => 8080,
988
+ :path => "/",
989
+ :query => nil,
990
+ :fragment => nil
991
+ }
992
+ end
993
+
994
+ it "should be identical to its duplicate" do
995
+ @uri.should == @uri.dup
996
+ end
997
+ end
998
+
999
+ describe Addressable::URI, " when parsed from " +
1000
+ "'http://example.com/path/to/resource/'" do
1001
+ before do
1002
+ @uri = Addressable::URI.parse("http://example.com/path/to/resource/")
1003
+ end
1004
+
1005
+ it "should use the 'http' scheme" do
1006
+ @uri.scheme.should == "http"
1007
+ end
1008
+
1009
+ it "should have an authority segment of 'example.com'" do
1010
+ @uri.authority.should == "example.com"
1011
+ end
1012
+
1013
+ it "should have a host of 'example.com'" do
1014
+ @uri.host.should == "example.com"
1015
+ end
1016
+
1017
+ it "should have no username" do
1018
+ @uri.user.should == nil
1019
+ end
1020
+
1021
+ it "should have no password" do
1022
+ @uri.password.should == nil
1023
+ end
1024
+
1025
+ it "should use port 80" do
1026
+ @uri.port.should == 80
1027
+ end
1028
+
1029
+ it "should have a path of '/path/to/resource/'" do
1030
+ @uri.path.should == "/path/to/resource/"
1031
+ end
1032
+
1033
+ it "should have no query string" do
1034
+ @uri.query.should == nil
1035
+ end
1036
+
1037
+ it "should have no fragment" do
1038
+ @uri.fragment.should == nil
1039
+ end
1040
+
1041
+ it "should be considered absolute" do
1042
+ @uri.should be_absolute
1043
+ end
1044
+
1045
+ it "should not be considered relative" do
1046
+ @uri.should_not be_relative
1047
+ end
1048
+
1049
+ it "should be exactly equal to http://example.com:8080/" do
1050
+ @uri.eql?(Addressable::URI.parse(
1051
+ "http://example.com/path/to/resource/")).should == true
1052
+ end
1053
+
1054
+ it "should have a route of 'resource/' from " +
1055
+ "'http://example.com/path/to/'" do
1056
+ @uri.route_from("http://example.com/path/to/").should ==
1057
+ Addressable::URI.parse("resource/")
1058
+ end
1059
+
1060
+ it "should have a route of 'resource/' from " +
1061
+ "'http://example.com:80/path/to/'" do
1062
+ @uri.route_from("http://example.com:80/path/to/").should ==
1063
+ Addressable::URI.parse("resource/")
1064
+ end
1065
+
1066
+ it "should have a route of 'http://example.com/path/to/' from " +
1067
+ "'http://example.com:8080/path/to/'" do
1068
+ @uri.route_from("http://example.com:8080/path/to/").should ==
1069
+ Addressable::URI.parse("http://example.com/path/to/resource/")
1070
+ end
1071
+
1072
+ it "should have a route of 'http://example.com/path/to/' from " +
1073
+ "'http://user:pass@example.com/path/to/'" do
1074
+ @uri.route_from("http://user:pass@example.com/path/to/").should ==
1075
+ Addressable::URI.parse("http://example.com/path/to/resource/")
1076
+ end
1077
+
1078
+ it "should have a route of '/path/to/resource/' from " +
1079
+ "'http://example.com/to/resource/'" do
1080
+ @uri.route_from("http://example.com/to/resource/").should ==
1081
+ Addressable::URI.parse("/path/to/resource/")
1082
+ end
1083
+
1084
+ it "should correctly convert to a hash" do
1085
+ @uri.to_hash.should == {
1086
+ :scheme => "http",
1087
+ :user => nil,
1088
+ :password => nil,
1089
+ :host => "example.com",
1090
+ :port => nil,
1091
+ :path => "/path/to/resource/",
1092
+ :query => nil,
1093
+ :fragment => nil
1094
+ }
1095
+ end
1096
+
1097
+ it "should be identical to its duplicate" do
1098
+ @uri.should == @uri.dup
1099
+ end
828
1100
  end
829
1101
 
830
1102
  describe Addressable::URI, "when parsed from " +
@@ -884,10 +1156,10 @@ describe Addressable::URI, "when parsed from " +
884
1156
  it "should raise an error if routing is attempted" do
885
1157
  (lambda do
886
1158
  @uri.route_to("http://example.com/")
887
- end).should raise_error
1159
+ end).should raise_error(ArgumentError, /relative\/path\/to\/resource/)
888
1160
  (lambda do
889
1161
  @uri.route_from("http://example.com/")
890
- end).should raise_error
1162
+ end).should raise_error(ArgumentError, /relative\/path\/to\/resource/)
891
1163
  end
892
1164
 
893
1165
  it "when joined with 'another/relative/path' should be " +
@@ -895,6 +1167,10 @@ describe Addressable::URI, "when parsed from " +
895
1167
  @uri.join('another/relative/path').should ==
896
1168
  Addressable::URI.parse("relative/path/to/another/relative/path")
897
1169
  end
1170
+
1171
+ it "should be identical to its duplicate" do
1172
+ @uri.should == @uri.dup
1173
+ end
898
1174
  end
899
1175
 
900
1176
  describe Addressable::URI, "when parsed from " +
@@ -992,6 +1268,61 @@ describe Addressable::URI, " when parsed from " +
992
1268
  @uri.path.should == "/file.txt"
993
1269
  end
994
1270
 
1271
+ it "should have a basename of 'file.txt'" do
1272
+ @uri.basename.should == "file.txt"
1273
+ end
1274
+
1275
+ it "should have an extname of '.txt'" do
1276
+ @uri.extname.should == ".txt"
1277
+ end
1278
+
1279
+ it "should have no query string" do
1280
+ @uri.query.should == nil
1281
+ end
1282
+
1283
+ it "should have no fragment" do
1284
+ @uri.fragment.should == nil
1285
+ end
1286
+ end
1287
+
1288
+ describe Addressable::URI, " when parsed from " +
1289
+ "'http://example.com/file.txt;parameter'" do
1290
+ before do
1291
+ @uri = Addressable::URI.parse("http://example.com/file.txt;parameter")
1292
+ end
1293
+
1294
+ it "should have a scheme of 'http'" do
1295
+ @uri.scheme.should == "http"
1296
+ end
1297
+
1298
+ it "should have an authority segment of 'example.com'" do
1299
+ @uri.authority.should == "example.com"
1300
+ end
1301
+
1302
+ it "should have a host of 'example.com'" do
1303
+ @uri.host.should == "example.com"
1304
+ end
1305
+
1306
+ it "should have no username" do
1307
+ @uri.user.should == nil
1308
+ end
1309
+
1310
+ it "should have no password" do
1311
+ @uri.password.should == nil
1312
+ end
1313
+
1314
+ it "should use port 80" do
1315
+ @uri.port.should == 80
1316
+ end
1317
+
1318
+ it "should have a path of '/file.txt;parameter'" do
1319
+ @uri.path.should == "/file.txt;parameter"
1320
+ end
1321
+
1322
+ it "should have a basename of 'file.txt'" do
1323
+ @uri.basename.should == "file.txt"
1324
+ end
1325
+
995
1326
  it "should have an extname of '.txt'" do
996
1327
  @uri.extname.should == ".txt"
997
1328
  end
@@ -1213,7 +1544,7 @@ describe Addressable::URI, " when parsed from " +
1213
1544
  it "should have a route of '/path/to/resource?query=x#fragment' " +
1214
1545
  "from 'http://user:pass@example.com/path/'" do
1215
1546
  @uri.route_from("http://user:pass@example.com/path/").should ==
1216
- Addressable::URI.parse("/path/to/resource?query=x#fragment")
1547
+ Addressable::URI.parse("to/resource?query=x#fragment")
1217
1548
  end
1218
1549
 
1219
1550
  it "should have a route of '?query=x#fragment' " +
@@ -1242,6 +1573,14 @@ describe Addressable::URI, " when parsed from " +
1242
1573
  Addressable::URI.parse("http://elsewhere.com/")
1243
1574
  end
1244
1575
 
1576
+ it "should have a route of " +
1577
+ "'http://user:pass@example.com/path/to/resource?query=x#fragment' " +
1578
+ "from 'http://example.com/path/to/'" do
1579
+ @uri.route_from("http://elsewhere.com/path/to/").should ==
1580
+ Addressable::URI.parse(
1581
+ "http://user:pass@example.com/path/to/resource?query=x#fragment")
1582
+ end
1583
+
1245
1584
  it "should have the correct scheme after assignment" do
1246
1585
  @uri.scheme = "ftp"
1247
1586
  @uri.scheme.should == "ftp"
@@ -1307,6 +1646,13 @@ describe Addressable::URI, " when parsed from " +
1307
1646
  "http://user:pass@example.com/newpath/to/resource?query=x#fragment"
1308
1647
  end
1309
1648
 
1649
+ it "should have the correct path after nil assignment" do
1650
+ @uri.path = nil
1651
+ @uri.path.should == ""
1652
+ @uri.to_s.should ==
1653
+ "http://user:pass@example.com?query=x#fragment"
1654
+ end
1655
+
1310
1656
  it "should have the correct query string after assignment" do
1311
1657
  @uri.query = "newquery=x"
1312
1658
  @uri.query.should == "newquery=x"
@@ -1320,6 +1666,10 @@ describe Addressable::URI, " when parsed from " +
1320
1666
  @uri.to_s.should ==
1321
1667
  "http://user:pass@example.com/path/to/resource?query=x#newfragment"
1322
1668
  end
1669
+
1670
+ it "should be identical to its duplicate" do
1671
+ @uri.should == @uri.dup
1672
+ end
1323
1673
  end
1324
1674
 
1325
1675
  describe Addressable::URI, " when parsed from " +
@@ -1605,6 +1955,15 @@ describe Addressable::URI, " when parsed from " +
1605
1955
  it "should have a path of '/'" do
1606
1956
  @uri.path.should == "/"
1607
1957
  end
1958
+
1959
+ it "should raise an error if routing is attempted" do
1960
+ (lambda do
1961
+ @uri.route_to("http://example.com/")
1962
+ end).should raise_error(ArgumentError, /\/\/example.com\//)
1963
+ (lambda do
1964
+ @uri.route_from("http://example.com/")
1965
+ end).should raise_error(ArgumentError, /\/\/example.com\//)
1966
+ end
1608
1967
  end
1609
1968
 
1610
1969
  describe Addressable::URI, " when parsed from " +
@@ -1613,13 +1972,12 @@ describe Addressable::URI, " when parsed from " +
1613
1972
  @uri = Addressable::URI.parse("feed://http://example.com/")
1614
1973
  end
1615
1974
 
1616
- it "should have a path of 'http://example.com/'" do
1617
- @uri.path.should == "http://example.com/"
1975
+ it "should have a host of 'http'" do
1976
+ @uri.host.should == "http"
1618
1977
  end
1619
1978
 
1620
- it "should normalize to 'http://example.com/'" do
1621
- @uri.normalize.to_s.should == "http://example.com/"
1622
- @uri.normalize!.to_s.should == "http://example.com/"
1979
+ it "should have a path of '//example.com/'" do
1980
+ @uri.path.should == "//example.com/"
1623
1981
  end
1624
1982
  end
1625
1983
 
@@ -2520,3 +2878,125 @@ describe Addressable::URI, " when parsed from " +
2520
2878
  }
2521
2879
  end
2522
2880
  end
2881
+
2882
+ describe Addressable::URI, " when given the input " +
2883
+ "'/path/to/resource'" do
2884
+ before do
2885
+ @input = "/path/to/resource"
2886
+ end
2887
+
2888
+ it "should heuristically parse to '/path/to/resource'" do
2889
+ @uri = Addressable::URI.heuristic_parse(@input)
2890
+ @uri.to_s.should == "/path/to/resource"
2891
+ end
2892
+ end
2893
+
2894
+ describe Addressable::URI, " when given the input " +
2895
+ "'relative/path/to/resource'" do
2896
+ before do
2897
+ @input = "relative/path/to/resource"
2898
+ end
2899
+
2900
+ it "should heuristically parse to 'relative/path/to/resource'" do
2901
+ @uri = Addressable::URI.heuristic_parse(@input)
2902
+ @uri.to_s.should == "relative/path/to/resource"
2903
+ end
2904
+ end
2905
+
2906
+ describe Addressable::URI, " when given the input " +
2907
+ "'example.com'" do
2908
+ before do
2909
+ @input = "example.com"
2910
+ end
2911
+
2912
+ it "should heuristically parse to 'http://example.com'" do
2913
+ @uri = Addressable::URI.heuristic_parse(@input)
2914
+ @uri.to_s.should == "http://example.com"
2915
+ end
2916
+ end
2917
+
2918
+ describe Addressable::URI, " when given the input " +
2919
+ "'example.com' and a scheme hint of 'ftp'" do
2920
+ before do
2921
+ @input = "example.com"
2922
+ @hints = {:scheme => 'ftp'}
2923
+ end
2924
+
2925
+ it "should heuristically parse to 'http://example.com'" do
2926
+ @uri = Addressable::URI.heuristic_parse(@input, @hints)
2927
+ @uri.to_s.should == "ftp://example.com"
2928
+ end
2929
+ end
2930
+
2931
+ describe Addressable::URI, " when given the input " +
2932
+ "'example.com:21' and a scheme hint of 'ftp'" do
2933
+ before do
2934
+ @input = "example.com:21"
2935
+ @hints = {:scheme => 'ftp'}
2936
+ end
2937
+
2938
+ it "should heuristically parse to 'http://example.com:21'" do
2939
+ @uri = Addressable::URI.heuristic_parse(@input, @hints)
2940
+ @uri.to_s.should == "ftp://example.com:21"
2941
+ end
2942
+ end
2943
+
2944
+ describe Addressable::URI, " when given the input " +
2945
+ "'example.com/path/to/resource'" do
2946
+ before do
2947
+ @input = "example.com/path/to/resource"
2948
+ end
2949
+
2950
+ it "should heuristically parse to 'http://example.com/path/to/resource'" do
2951
+ @uri = Addressable::URI.heuristic_parse(@input)
2952
+ @uri.to_s.should == "http://example.com/path/to/resource"
2953
+ end
2954
+ end
2955
+
2956
+ describe Addressable::URI, " when given the input " +
2957
+ "'http:///example.com'" do
2958
+ before do
2959
+ @input = "http:///example.com"
2960
+ end
2961
+
2962
+ it "should heuristically parse to 'http://example.com'" do
2963
+ @uri = Addressable::URI.heuristic_parse(@input)
2964
+ @uri.to_s.should == "http://example.com"
2965
+ end
2966
+ end
2967
+
2968
+ describe Addressable::URI, " when given the input " +
2969
+ "'feed:///example.com'" do
2970
+ before do
2971
+ @input = "feed:///example.com"
2972
+ end
2973
+
2974
+ it "should heuristically parse to 'feed://example.com'" do
2975
+ @uri = Addressable::URI.heuristic_parse(@input)
2976
+ @uri.to_s.should == "feed://example.com"
2977
+ end
2978
+ end
2979
+
2980
+ describe Addressable::URI, " when given the input " +
2981
+ "'file://path/to/resource/'" do
2982
+ before do
2983
+ @input = "file://path/to/resource/"
2984
+ end
2985
+
2986
+ it "should heuristically parse to 'file:///path/to/resource/'" do
2987
+ @uri = Addressable::URI.heuristic_parse(@input)
2988
+ @uri.to_s.should == "file:///path/to/resource/"
2989
+ end
2990
+ end
2991
+
2992
+ describe Addressable::URI, " when given the input " +
2993
+ "'feed://http://example.com'" do
2994
+ before do
2995
+ @input = "feed://http://example.com"
2996
+ end
2997
+
2998
+ it "should heuristically parse to 'feed:http://example.com'" do
2999
+ @uri = Addressable::URI.heuristic_parse(@input)
3000
+ @uri.to_s.should == "feed:http://example.com"
3001
+ end
3002
+ end