diff options
Diffstat (limited to 'spec/ruby/library/uri')
109 files changed, 611 insertions, 609 deletions
diff --git a/spec/ruby/library/uri/decode_www_form_component_spec.rb b/spec/ruby/library/uri/decode_www_form_component_spec.rb index 04cc634947..075cec1087 100644 --- a/spec/ruby/library/uri/decode_www_form_component_spec.rb +++ b/spec/ruby/library/uri/decode_www_form_component_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI.decode_www_form_component" do diff --git a/spec/ruby/library/uri/decode_www_form_spec.rb b/spec/ruby/library/uri/decode_www_form_spec.rb index d4854a6ece..8dd37e514f 100644 --- a/spec/ruby/library/uri/decode_www_form_spec.rb +++ b/spec/ruby/library/uri/decode_www_form_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI.decode_www_form" do diff --git a/spec/ruby/library/uri/encode_www_form_component_spec.rb b/spec/ruby/library/uri/encode_www_form_component_spec.rb index 753b6d50d0..a0508b207c 100644 --- a/spec/ruby/library/uri/encode_www_form_component_spec.rb +++ b/spec/ruby/library/uri/encode_www_form_component_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI.encode_www_form_component" do diff --git a/spec/ruby/library/uri/encode_www_form_spec.rb b/spec/ruby/library/uri/encode_www_form_spec.rb index b72b928344..7f4aecf89b 100644 --- a/spec/ruby/library/uri/encode_www_form_spec.rb +++ b/spec/ruby/library/uri/encode_www_form_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI.encode_www_form" do diff --git a/spec/ruby/library/uri/eql_spec.rb b/spec/ruby/library/uri/eql_spec.rb index 2bbc5291e9..2bbf8fd40c 100644 --- a/spec/ruby/library/uri/eql_spec.rb +++ b/spec/ruby/library/uri/eql_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../fixtures/normalization', __FILE__) -require File.expand_path('../shared/eql', __FILE__) +require_relative '../../spec_helper' +require_relative 'fixtures/normalization' +require_relative 'shared/eql' require 'uri' describe "URI#eql?" do diff --git a/spec/ruby/library/uri/equality_spec.rb b/spec/ruby/library/uri/equality_spec.rb index 07d48a9583..1c247ce291 100644 --- a/spec/ruby/library/uri/equality_spec.rb +++ b/spec/ruby/library/uri/equality_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../fixtures/normalization', __FILE__) -require File.expand_path('../shared/eql', __FILE__) +require_relative '../../spec_helper' +require_relative 'fixtures/normalization' +require_relative 'shared/eql' require 'uri' describe "URI#==" do diff --git a/spec/ruby/library/uri/escape/decode_spec.rb b/spec/ruby/library/uri/escape/decode_spec.rb index 34d3e787c4..b4ef799411 100644 --- a/spec/ruby/library/uri/escape/decode_spec.rb +++ b/spec/ruby/library/uri/escape/decode_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Escape#decode" do diff --git a/spec/ruby/library/uri/escape/encode_spec.rb b/spec/ruby/library/uri/escape/encode_spec.rb index edde60b3cd..2b61b7c152 100644 --- a/spec/ruby/library/uri/escape/encode_spec.rb +++ b/spec/ruby/library/uri/escape/encode_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Escape#encode" do diff --git a/spec/ruby/library/uri/escape/escape_spec.rb b/spec/ruby/library/uri/escape/escape_spec.rb index 3c6b957b18..dddbc60707 100644 --- a/spec/ruby/library/uri/escape/escape_spec.rb +++ b/spec/ruby/library/uri/escape/escape_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Escape#escape" do diff --git a/spec/ruby/library/uri/escape/unescape_spec.rb b/spec/ruby/library/uri/escape/unescape_spec.rb index 6a7165a0d3..7d574d13c1 100644 --- a/spec/ruby/library/uri/escape/unescape_spec.rb +++ b/spec/ruby/library/uri/escape/unescape_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Escape#unescape" do diff --git a/spec/ruby/library/uri/extract_spec.rb b/spec/ruby/library/uri/extract_spec.rb index 7b660851b6..1294a480f1 100644 --- a/spec/ruby/library/uri/extract_spec.rb +++ b/spec/ruby/library/uri/extract_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI.extract" do diff --git a/spec/ruby/library/uri/ftp/build_spec.rb b/spec/ruby/library/uri/ftp/build_spec.rb index c7765e2868..9e0fb44cf1 100644 --- a/spec/ruby/library/uri/ftp/build_spec.rb +++ b/spec/ruby/library/uri/ftp/build_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::FTP.build" do diff --git a/spec/ruby/library/uri/ftp/merge_spec.rb b/spec/ruby/library/uri/ftp/merge_spec.rb index b766e992ca..7a9997bbac 100644 --- a/spec/ruby/library/uri/ftp/merge_spec.rb +++ b/spec/ruby/library/uri/ftp/merge_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::FTP#merge" do diff --git a/spec/ruby/library/uri/ftp/new2_spec.rb b/spec/ruby/library/uri/ftp/new2_spec.rb index a43916af6a..eb1b149c81 100644 --- a/spec/ruby/library/uri/ftp/new2_spec.rb +++ b/spec/ruby/library/uri/ftp/new2_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::FTP.new2" do diff --git a/spec/ruby/library/uri/ftp/path_spec.rb b/spec/ruby/library/uri/ftp/path_spec.rb index 9e1a00602f..5fec7f11b6 100644 --- a/spec/ruby/library/uri/ftp/path_spec.rb +++ b/spec/ruby/library/uri/ftp/path_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::FTP#path=" do diff --git a/spec/ruby/library/uri/ftp/set_typecode_spec.rb b/spec/ruby/library/uri/ftp/set_typecode_spec.rb index b815bc8740..31067930c0 100644 --- a/spec/ruby/library/uri/ftp/set_typecode_spec.rb +++ b/spec/ruby/library/uri/ftp/set_typecode_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::FTP#set_typecode" do diff --git a/spec/ruby/library/uri/ftp/to_s_spec.rb b/spec/ruby/library/uri/ftp/to_s_spec.rb index e4e2832e86..3b4ff2d906 100644 --- a/spec/ruby/library/uri/ftp/to_s_spec.rb +++ b/spec/ruby/library/uri/ftp/to_s_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' diff --git a/spec/ruby/library/uri/ftp/typecode_spec.rb b/spec/ruby/library/uri/ftp/typecode_spec.rb index b298c2ae98..1f2bb02252 100644 --- a/spec/ruby/library/uri/ftp/typecode_spec.rb +++ b/spec/ruby/library/uri/ftp/typecode_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::FTP#typecode" do diff --git a/spec/ruby/library/uri/generic/absolute_spec.rb b/spec/ruby/library/uri/generic/absolute_spec.rb index 4f6526b827..fe4b48d067 100644 --- a/spec/ruby/library/uri/generic/absolute_spec.rb +++ b/spec/ruby/library/uri/generic/absolute_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#absolute" do diff --git a/spec/ruby/library/uri/generic/build2_spec.rb b/spec/ruby/library/uri/generic/build2_spec.rb index 0b9a6788f6..9abd1d80ef 100644 --- a/spec/ruby/library/uri/generic/build2_spec.rb +++ b/spec/ruby/library/uri/generic/build2_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic.build2" do diff --git a/spec/ruby/library/uri/generic/build_spec.rb b/spec/ruby/library/uri/generic/build_spec.rb index 6fa5d6ac55..50c27674ce 100644 --- a/spec/ruby/library/uri/generic/build_spec.rb +++ b/spec/ruby/library/uri/generic/build_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic.build" do diff --git a/spec/ruby/library/uri/generic/coerce_spec.rb b/spec/ruby/library/uri/generic/coerce_spec.rb index 1b1a040f63..f695e560ac 100644 --- a/spec/ruby/library/uri/generic/coerce_spec.rb +++ b/spec/ruby/library/uri/generic/coerce_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#coerce" do diff --git a/spec/ruby/library/uri/generic/component_ary_spec.rb b/spec/ruby/library/uri/generic/component_ary_spec.rb index 3244073e0e..b39752f8d9 100644 --- a/spec/ruby/library/uri/generic/component_ary_spec.rb +++ b/spec/ruby/library/uri/generic/component_ary_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#component_ary" do diff --git a/spec/ruby/library/uri/generic/component_spec.rb b/spec/ruby/library/uri/generic/component_spec.rb index 6fb83d7796..f92409a0b0 100644 --- a/spec/ruby/library/uri/generic/component_spec.rb +++ b/spec/ruby/library/uri/generic/component_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#component" do diff --git a/spec/ruby/library/uri/generic/default_port_spec.rb b/spec/ruby/library/uri/generic/default_port_spec.rb index d1e0ce2d3f..4e10e34c9d 100644 --- a/spec/ruby/library/uri/generic/default_port_spec.rb +++ b/spec/ruby/library/uri/generic/default_port_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#default_port" do diff --git a/spec/ruby/library/uri/generic/eql_spec.rb b/spec/ruby/library/uri/generic/eql_spec.rb index 65f9204a19..df9987b524 100644 --- a/spec/ruby/library/uri/generic/eql_spec.rb +++ b/spec/ruby/library/uri/generic/eql_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#eql?" do diff --git a/spec/ruby/library/uri/generic/equal_value_spec.rb b/spec/ruby/library/uri/generic/equal_value_spec.rb index f41b202498..bd2feb86d4 100644 --- a/spec/ruby/library/uri/generic/equal_value_spec.rb +++ b/spec/ruby/library/uri/generic/equal_value_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#==" do diff --git a/spec/ruby/library/uri/generic/fragment_spec.rb b/spec/ruby/library/uri/generic/fragment_spec.rb index de6f4e078d..20126b207a 100644 --- a/spec/ruby/library/uri/generic/fragment_spec.rb +++ b/spec/ruby/library/uri/generic/fragment_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#fragment" do diff --git a/spec/ruby/library/uri/generic/hash_spec.rb b/spec/ruby/library/uri/generic/hash_spec.rb index 3410558067..286c1ab38d 100644 --- a/spec/ruby/library/uri/generic/hash_spec.rb +++ b/spec/ruby/library/uri/generic/hash_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#hash" do diff --git a/spec/ruby/library/uri/generic/hierarchical_spec.rb b/spec/ruby/library/uri/generic/hierarchical_spec.rb index 1c90dc4f8f..df9bbae202 100644 --- a/spec/ruby/library/uri/generic/hierarchical_spec.rb +++ b/spec/ruby/library/uri/generic/hierarchical_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#hierarchical?" do diff --git a/spec/ruby/library/uri/generic/host_spec.rb b/spec/ruby/library/uri/generic/host_spec.rb index 6fb6c1c36a..4a5a162512 100644 --- a/spec/ruby/library/uri/generic/host_spec.rb +++ b/spec/ruby/library/uri/generic/host_spec.rb @@ -1,8 +1,11 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#host" do - it "needs to be reviewed for spec completeness" + # https://hackerone.com/reports/156615 + it "returns empty string when host is empty" do + URI.parse('http:////foo.com').host.should == '' + end end describe "URI::Generic#host=" do diff --git a/spec/ruby/library/uri/generic/inspect_spec.rb b/spec/ruby/library/uri/generic/inspect_spec.rb index 696c3308d4..4ff81eef82 100644 --- a/spec/ruby/library/uri/generic/inspect_spec.rb +++ b/spec/ruby/library/uri/generic/inspect_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#inspect" do diff --git a/spec/ruby/library/uri/generic/merge_spec.rb b/spec/ruby/library/uri/generic/merge_spec.rb index 63642197e1..017873cc90 100644 --- a/spec/ruby/library/uri/generic/merge_spec.rb +++ b/spec/ruby/library/uri/generic/merge_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#merge" do diff --git a/spec/ruby/library/uri/generic/minus_spec.rb b/spec/ruby/library/uri/generic/minus_spec.rb index 3426a6068b..ad8f816839 100644 --- a/spec/ruby/library/uri/generic/minus_spec.rb +++ b/spec/ruby/library/uri/generic/minus_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#-" do diff --git a/spec/ruby/library/uri/generic/normalize_spec.rb b/spec/ruby/library/uri/generic/normalize_spec.rb index ac02b644d0..d70a77c044 100644 --- a/spec/ruby/library/uri/generic/normalize_spec.rb +++ b/spec/ruby/library/uri/generic/normalize_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#normalize" do diff --git a/spec/ruby/library/uri/generic/opaque_spec.rb b/spec/ruby/library/uri/generic/opaque_spec.rb index f418c220f2..e6d40da52b 100644 --- a/spec/ruby/library/uri/generic/opaque_spec.rb +++ b/spec/ruby/library/uri/generic/opaque_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#opaque" do diff --git a/spec/ruby/library/uri/generic/password_spec.rb b/spec/ruby/library/uri/generic/password_spec.rb index 087db60fb9..18db503883 100644 --- a/spec/ruby/library/uri/generic/password_spec.rb +++ b/spec/ruby/library/uri/generic/password_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#password" do diff --git a/spec/ruby/library/uri/generic/path_spec.rb b/spec/ruby/library/uri/generic/path_spec.rb index 5ea60b5418..d84975c579 100644 --- a/spec/ruby/library/uri/generic/path_spec.rb +++ b/spec/ruby/library/uri/generic/path_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#path" do diff --git a/spec/ruby/library/uri/generic/plus_spec.rb b/spec/ruby/library/uri/generic/plus_spec.rb index 3d1c031022..e6d2222dac 100644 --- a/spec/ruby/library/uri/generic/plus_spec.rb +++ b/spec/ruby/library/uri/generic/plus_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#+" do diff --git a/spec/ruby/library/uri/generic/port_spec.rb b/spec/ruby/library/uri/generic/port_spec.rb index 148e84ff14..6e5ef01493 100644 --- a/spec/ruby/library/uri/generic/port_spec.rb +++ b/spec/ruby/library/uri/generic/port_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#port" do diff --git a/spec/ruby/library/uri/generic/query_spec.rb b/spec/ruby/library/uri/generic/query_spec.rb index 945fdc06a3..528cc3be02 100644 --- a/spec/ruby/library/uri/generic/query_spec.rb +++ b/spec/ruby/library/uri/generic/query_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#query" do diff --git a/spec/ruby/library/uri/generic/registry_spec.rb b/spec/ruby/library/uri/generic/registry_spec.rb index 6a48b25465..aece265a07 100644 --- a/spec/ruby/library/uri/generic/registry_spec.rb +++ b/spec/ruby/library/uri/generic/registry_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#registry" do diff --git a/spec/ruby/library/uri/generic/relative_spec.rb b/spec/ruby/library/uri/generic/relative_spec.rb index 09730fa4eb..a7de1f306a 100644 --- a/spec/ruby/library/uri/generic/relative_spec.rb +++ b/spec/ruby/library/uri/generic/relative_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#relative?" do diff --git a/spec/ruby/library/uri/generic/route_from_spec.rb b/spec/ruby/library/uri/generic/route_from_spec.rb index 03321cbf0d..fd69816edf 100644 --- a/spec/ruby/library/uri/generic/route_from_spec.rb +++ b/spec/ruby/library/uri/generic/route_from_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#route_from" do diff --git a/spec/ruby/library/uri/generic/route_to_spec.rb b/spec/ruby/library/uri/generic/route_to_spec.rb index a12e1f7649..7ab9aff2e8 100644 --- a/spec/ruby/library/uri/generic/route_to_spec.rb +++ b/spec/ruby/library/uri/generic/route_to_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#route_to" do diff --git a/spec/ruby/library/uri/generic/scheme_spec.rb b/spec/ruby/library/uri/generic/scheme_spec.rb index fa3dfcb8aa..7922a8e977 100644 --- a/spec/ruby/library/uri/generic/scheme_spec.rb +++ b/spec/ruby/library/uri/generic/scheme_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#scheme" do diff --git a/spec/ruby/library/uri/generic/select_spec.rb b/spec/ruby/library/uri/generic/select_spec.rb index 5cc104f5dd..99aef83f99 100644 --- a/spec/ruby/library/uri/generic/select_spec.rb +++ b/spec/ruby/library/uri/generic/select_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#select" do diff --git a/spec/ruby/library/uri/generic/set_fragment_spec.rb b/spec/ruby/library/uri/generic/set_fragment_spec.rb index cebad46585..2476315f08 100644 --- a/spec/ruby/library/uri/generic/set_fragment_spec.rb +++ b/spec/ruby/library/uri/generic/set_fragment_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_fragment" do diff --git a/spec/ruby/library/uri/generic/set_host_spec.rb b/spec/ruby/library/uri/generic/set_host_spec.rb index 357b7a6889..c7f5c6884e 100644 --- a/spec/ruby/library/uri/generic/set_host_spec.rb +++ b/spec/ruby/library/uri/generic/set_host_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_host" do diff --git a/spec/ruby/library/uri/generic/set_opaque_spec.rb b/spec/ruby/library/uri/generic/set_opaque_spec.rb index afd6597675..8a494a7ee2 100644 --- a/spec/ruby/library/uri/generic/set_opaque_spec.rb +++ b/spec/ruby/library/uri/generic/set_opaque_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_opaque" do diff --git a/spec/ruby/library/uri/generic/set_password_spec.rb b/spec/ruby/library/uri/generic/set_password_spec.rb index 15b4fdc37d..93b05fe911 100644 --- a/spec/ruby/library/uri/generic/set_password_spec.rb +++ b/spec/ruby/library/uri/generic/set_password_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_password" do diff --git a/spec/ruby/library/uri/generic/set_path_spec.rb b/spec/ruby/library/uri/generic/set_path_spec.rb index b4366d789c..6d9f59d1a5 100644 --- a/spec/ruby/library/uri/generic/set_path_spec.rb +++ b/spec/ruby/library/uri/generic/set_path_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_path" do diff --git a/spec/ruby/library/uri/generic/set_port_spec.rb b/spec/ruby/library/uri/generic/set_port_spec.rb index aa65bb96e3..2c8a4edd22 100644 --- a/spec/ruby/library/uri/generic/set_port_spec.rb +++ b/spec/ruby/library/uri/generic/set_port_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_port" do diff --git a/spec/ruby/library/uri/generic/set_query_spec.rb b/spec/ruby/library/uri/generic/set_query_spec.rb index b1c25e56ca..3f3453ba8e 100644 --- a/spec/ruby/library/uri/generic/set_query_spec.rb +++ b/spec/ruby/library/uri/generic/set_query_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_query" do diff --git a/spec/ruby/library/uri/generic/set_registry_spec.rb b/spec/ruby/library/uri/generic/set_registry_spec.rb index 602f868ac1..44afe246d1 100644 --- a/spec/ruby/library/uri/generic/set_registry_spec.rb +++ b/spec/ruby/library/uri/generic/set_registry_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_registry" do diff --git a/spec/ruby/library/uri/generic/set_scheme_spec.rb b/spec/ruby/library/uri/generic/set_scheme_spec.rb index e1a94c5b1a..ffa29da446 100644 --- a/spec/ruby/library/uri/generic/set_scheme_spec.rb +++ b/spec/ruby/library/uri/generic/set_scheme_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_scheme" do diff --git a/spec/ruby/library/uri/generic/set_user_spec.rb b/spec/ruby/library/uri/generic/set_user_spec.rb index 36a6ac9e85..9a39e1f4c3 100644 --- a/spec/ruby/library/uri/generic/set_user_spec.rb +++ b/spec/ruby/library/uri/generic/set_user_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_user" do diff --git a/spec/ruby/library/uri/generic/set_userinfo_spec.rb b/spec/ruby/library/uri/generic/set_userinfo_spec.rb index cbe80d9809..76878204d2 100644 --- a/spec/ruby/library/uri/generic/set_userinfo_spec.rb +++ b/spec/ruby/library/uri/generic/set_userinfo_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#set_userinfo" do diff --git a/spec/ruby/library/uri/generic/to_s_spec.rb b/spec/ruby/library/uri/generic/to_s_spec.rb index c0a0f803ef..c436ee3c03 100644 --- a/spec/ruby/library/uri/generic/to_s_spec.rb +++ b/spec/ruby/library/uri/generic/to_s_spec.rb @@ -1,6 +1,9 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#to_s" do - it "needs to be reviewed for spec completeness" + # https://hackerone.com/reports/156615 + it "preserves / characters when host is empty" do + URI('http:///foo.com').to_s.should == 'http:///foo.com' + end end diff --git a/spec/ruby/library/uri/generic/use_registry_spec.rb b/spec/ruby/library/uri/generic/use_registry_spec.rb index 4e7ae6a5cf..bdfe27c048 100644 --- a/spec/ruby/library/uri/generic/use_registry_spec.rb +++ b/spec/ruby/library/uri/generic/use_registry_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic.use_registry" do diff --git a/spec/ruby/library/uri/generic/user_spec.rb b/spec/ruby/library/uri/generic/user_spec.rb index b785ef6879..345412ca29 100644 --- a/spec/ruby/library/uri/generic/user_spec.rb +++ b/spec/ruby/library/uri/generic/user_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#user" do diff --git a/spec/ruby/library/uri/generic/userinfo_spec.rb b/spec/ruby/library/uri/generic/userinfo_spec.rb index 5d0fc50b65..4bf111079c 100644 --- a/spec/ruby/library/uri/generic/userinfo_spec.rb +++ b/spec/ruby/library/uri/generic/userinfo_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Generic#userinfo" do diff --git a/spec/ruby/library/uri/http/build_spec.rb b/spec/ruby/library/uri/http/build_spec.rb index 85103167e0..d34cf83ecf 100644 --- a/spec/ruby/library/uri/http/build_spec.rb +++ b/spec/ruby/library/uri/http/build_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::HTTP.build" do diff --git a/spec/ruby/library/uri/http/request_uri_spec.rb b/spec/ruby/library/uri/http/request_uri_spec.rb index 85d89aba77..7b05147d36 100644 --- a/spec/ruby/library/uri/http/request_uri_spec.rb +++ b/spec/ruby/library/uri/http/request_uri_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::HTTP.request_uri" do diff --git a/spec/ruby/library/uri/join_spec.rb b/spec/ruby/library/uri/join_spec.rb index 3e0dbe7f2b..1777303360 100644 --- a/spec/ruby/library/uri/join_spec.rb +++ b/spec/ruby/library/uri/join_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI.join" do @@ -21,9 +21,9 @@ describe "URI.join" do end it "raises an error if given no argument" do - lambda { + -> { URI.join - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "doesn't create redundant '/'s" do diff --git a/spec/ruby/library/uri/ldap/attributes_spec.rb b/spec/ruby/library/uri/ldap/attributes_spec.rb index 2309de7c62..88e3328bad 100644 --- a/spec/ruby/library/uri/ldap/attributes_spec.rb +++ b/spec/ruby/library/uri/ldap/attributes_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#attributes" do diff --git a/spec/ruby/library/uri/ldap/build_spec.rb b/spec/ruby/library/uri/ldap/build_spec.rb index 99e2611b1f..8d0e312d1a 100644 --- a/spec/ruby/library/uri/ldap/build_spec.rb +++ b/spec/ruby/library/uri/ldap/build_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP.build" do diff --git a/spec/ruby/library/uri/ldap/dn_spec.rb b/spec/ruby/library/uri/ldap/dn_spec.rb index b1371611d3..a5ac02e891 100644 --- a/spec/ruby/library/uri/ldap/dn_spec.rb +++ b/spec/ruby/library/uri/ldap/dn_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#dn" do diff --git a/spec/ruby/library/uri/ldap/extensions_spec.rb b/spec/ruby/library/uri/ldap/extensions_spec.rb index 2d9b09e6a7..473222eb7a 100644 --- a/spec/ruby/library/uri/ldap/extensions_spec.rb +++ b/spec/ruby/library/uri/ldap/extensions_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#extensions" do diff --git a/spec/ruby/library/uri/ldap/filter_spec.rb b/spec/ruby/library/uri/ldap/filter_spec.rb index 1f996339db..d0b7fcc384 100644 --- a/spec/ruby/library/uri/ldap/filter_spec.rb +++ b/spec/ruby/library/uri/ldap/filter_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#filter" do diff --git a/spec/ruby/library/uri/ldap/hierarchical_spec.rb b/spec/ruby/library/uri/ldap/hierarchical_spec.rb index 97c23a7f0c..5471c53d76 100644 --- a/spec/ruby/library/uri/ldap/hierarchical_spec.rb +++ b/spec/ruby/library/uri/ldap/hierarchical_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#hierarchical?" do diff --git a/spec/ruby/library/uri/ldap/scope_spec.rb b/spec/ruby/library/uri/ldap/scope_spec.rb index d4a02e08f0..5ea5581671 100644 --- a/spec/ruby/library/uri/ldap/scope_spec.rb +++ b/spec/ruby/library/uri/ldap/scope_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#scope" do diff --git a/spec/ruby/library/uri/ldap/set_attributes_spec.rb b/spec/ruby/library/uri/ldap/set_attributes_spec.rb index 1bbcb34837..fdaaa8344a 100644 --- a/spec/ruby/library/uri/ldap/set_attributes_spec.rb +++ b/spec/ruby/library/uri/ldap/set_attributes_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#set_attributes" do diff --git a/spec/ruby/library/uri/ldap/set_dn_spec.rb b/spec/ruby/library/uri/ldap/set_dn_spec.rb index abb640b585..c50ee6a98d 100644 --- a/spec/ruby/library/uri/ldap/set_dn_spec.rb +++ b/spec/ruby/library/uri/ldap/set_dn_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#set_dn" do diff --git a/spec/ruby/library/uri/ldap/set_extensions_spec.rb b/spec/ruby/library/uri/ldap/set_extensions_spec.rb index 5cd2077aab..5a39da4607 100644 --- a/spec/ruby/library/uri/ldap/set_extensions_spec.rb +++ b/spec/ruby/library/uri/ldap/set_extensions_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#set_extensions" do diff --git a/spec/ruby/library/uri/ldap/set_filter_spec.rb b/spec/ruby/library/uri/ldap/set_filter_spec.rb index f1b8e5e595..c3ede20bb4 100644 --- a/spec/ruby/library/uri/ldap/set_filter_spec.rb +++ b/spec/ruby/library/uri/ldap/set_filter_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#set_filter" do diff --git a/spec/ruby/library/uri/ldap/set_scope_spec.rb b/spec/ruby/library/uri/ldap/set_scope_spec.rb index 5a0841cfd8..43f3f68f86 100644 --- a/spec/ruby/library/uri/ldap/set_scope_spec.rb +++ b/spec/ruby/library/uri/ldap/set_scope_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::LDAP#set_scope" do diff --git a/spec/ruby/library/uri/mailto/build_spec.rb b/spec/ruby/library/uri/mailto/build_spec.rb index cb57f0c794..081707b1cf 100644 --- a/spec/ruby/library/uri/mailto/build_spec.rb +++ b/spec/ruby/library/uri/mailto/build_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Mailto.build" do @@ -84,15 +84,9 @@ describe "URI::Mailto.build" do end bad.each do |x| - lambda { URI::MailTo.build(x) }.should raise_error(URI::InvalidComponentError) + -> { URI::MailTo.build(x) }.should.raise(URI::InvalidComponentError) end ok.flatten.join("\0").should == ok_all end end - - - -describe "URI::MailTo.build" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/library/uri/mailto/headers_spec.rb b/spec/ruby/library/uri/mailto/headers_spec.rb index 844fdee714..8aefec0e75 100644 --- a/spec/ruby/library/uri/mailto/headers_spec.rb +++ b/spec/ruby/library/uri/mailto/headers_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::MailTo#headers" do diff --git a/spec/ruby/library/uri/mailto/set_headers_spec.rb b/spec/ruby/library/uri/mailto/set_headers_spec.rb index c1384d5dca..b6ce1a694b 100644 --- a/spec/ruby/library/uri/mailto/set_headers_spec.rb +++ b/spec/ruby/library/uri/mailto/set_headers_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::MailTo#set_headers" do diff --git a/spec/ruby/library/uri/mailto/set_to_spec.rb b/spec/ruby/library/uri/mailto/set_to_spec.rb index a8351a2092..eabc47f9a8 100644 --- a/spec/ruby/library/uri/mailto/set_to_spec.rb +++ b/spec/ruby/library/uri/mailto/set_to_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::MailTo#set_to" do diff --git a/spec/ruby/library/uri/mailto/to_mailtext_spec.rb b/spec/ruby/library/uri/mailto/to_mailtext_spec.rb index 4c7a48874f..3763a2d402 100644 --- a/spec/ruby/library/uri/mailto/to_mailtext_spec.rb +++ b/spec/ruby/library/uri/mailto/to_mailtext_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::MailTo#to_mailtext" do diff --git a/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb b/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb index e769f62deb..2843b46848 100644 --- a/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb +++ b/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::MailTo#to_rfc822text" do diff --git a/spec/ruby/library/uri/mailto/to_s_spec.rb b/spec/ruby/library/uri/mailto/to_s_spec.rb index 2709d19d27..746e8356eb 100644 --- a/spec/ruby/library/uri/mailto/to_s_spec.rb +++ b/spec/ruby/library/uri/mailto/to_s_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::MailTo#to_s" do diff --git a/spec/ruby/library/uri/mailto/to_spec.rb b/spec/ruby/library/uri/mailto/to_spec.rb index f30d23dd53..68dfadd359 100644 --- a/spec/ruby/library/uri/mailto/to_spec.rb +++ b/spec/ruby/library/uri/mailto/to_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::MailTo#to" do diff --git a/spec/ruby/library/uri/merge_spec.rb b/spec/ruby/library/uri/merge_spec.rb index c62e80d6b2..e9644a7fd0 100644 --- a/spec/ruby/library/uri/merge_spec.rb +++ b/spec/ruby/library/uri/merge_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI#merge" do diff --git a/spec/ruby/library/uri/normalize_spec.rb b/spec/ruby/library/uri/normalize_spec.rb index 079a9ad61d..3d4451990a 100644 --- a/spec/ruby/library/uri/normalize_spec.rb +++ b/spec/ruby/library/uri/normalize_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../fixtures/normalization', __FILE__) +require_relative '../../spec_helper' +require_relative 'fixtures/normalization' require 'uri' describe "URI#normalize" do diff --git a/spec/ruby/library/uri/parse_spec.rb b/spec/ruby/library/uri/parse_spec.rb index 4aa84ae2ee..f0373fbf5e 100644 --- a/spec/ruby/library/uri/parse_spec.rb +++ b/spec/ruby/library/uri/parse_spec.rb @@ -1,10 +1,10 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../fixtures/classes', __FILE__) +require_relative '../../spec_helper' +require_relative 'fixtures/classes' describe "URI.parse" do it "returns a URI::HTTP object when parsing an HTTP URI" do - URI.parse("http://www.example.com/").should be_kind_of(URI::HTTP) + URI.parse("http://www.example.com/").should.is_a?(URI::HTTP) end it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do @@ -47,7 +47,7 @@ describe "URI.parse" do end it "returns a URI::HTTPS object when parsing an HTTPS URI" do - URI.parse("https://important-intern-net.net").should be_kind_of(URI::HTTPS) + URI.parse("https://important-intern-net.net").should.is_a?(URI::HTTPS) end it "sets the port of a parsed https URI to 443 by default" do @@ -57,7 +57,7 @@ describe "URI.parse" do it "populates the components of a parsed URI::FTP object" do # generic, empty password. url = URI.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i") - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: "anonymous", @@ -69,7 +69,7 @@ describe "URI.parse" do # multidomain, no user or password url = URI.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: nil, @@ -81,7 +81,7 @@ describe "URI.parse" do # empty user url = URI.parse('ftp://:pass@localhost/') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: ":pass", @@ -97,7 +97,7 @@ describe "URI.parse" do #taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like ldap_uris = %w{ ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one ldap://ldap.question.com/o=Question%3f,c=US?mail ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04) ldap:///??sub??bindname=cn=Manager%2co=Foo ldap:///??sub??!bindname=cn=Manager%2co=Foo } ldap_uris.each do |ldap_uri| - URI.parse(ldap_uri).should be_kind_of(URI::LDAP) + URI.parse(ldap_uri).should.is_a?(URI::LDAP) end end @@ -115,7 +115,7 @@ describe "URI.parse" do end it "returns a URI::MailTo object when passed a mailto URI" do - URI.parse("mailto:spam@mailinator.com").should be_kind_of(URI::MailTo) + URI.parse("mailto:spam@mailinator.com").should.is_a?(URI::MailTo) end it "populates the components of a parsed URI::MailTo object" do @@ -145,7 +145,7 @@ describe "URI.parse" do # gopher gopher = URI.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles') - gopher.should be_kind_of(URI::Generic) + gopher.should.is_a?(URI::Generic) URISpec.components(gopher).should == { scheme: "gopher", @@ -161,7 +161,7 @@ describe "URI.parse" do # news news = URI.parse('news:comp.infosystems.www.servers.unix') - news.should be_kind_of(URI::Generic) + news.should.is_a?(URI::Generic) URISpec.components(news).should == { scheme: "news", userinfo: nil, @@ -176,7 +176,7 @@ describe "URI.parse" do # telnet telnet = URI.parse('telnet://melvyl.ucop.edu/') - telnet.should be_kind_of(URI::Generic) + telnet.should.is_a?(URI::Generic) URISpec.components(telnet).should == { scheme: "telnet", userinfo: nil, @@ -191,9 +191,9 @@ describe "URI.parse" do # files file_l = URI.parse('file:///foo/bar.txt') - file_l.should be_kind_of(URI::Generic) + file_l.should.is_a?(URI::Generic) file = URI.parse('file:/foo/bar.txt') - file.should be_kind_of(URI::Generic) + file.should.is_a?(URI::Generic) end it "doesn't raise errors on URIs which has underscore in reg_name" do diff --git a/spec/ruby/library/uri/parser/escape_spec.rb b/spec/ruby/library/uri/parser/escape_spec.rb index 8682e0ebce..66853d9fcb 100644 --- a/spec/ruby/library/uri/parser/escape_spec.rb +++ b/spec/ruby/library/uri/parser/escape_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Parser#escape" do diff --git a/spec/ruby/library/uri/parser/extract_spec.rb b/spec/ruby/library/uri/parser/extract_spec.rb index 5dac947060..f5ecd6ec8e 100644 --- a/spec/ruby/library/uri/parser/extract_spec.rb +++ b/spec/ruby/library/uri/parser/extract_spec.rb @@ -1,7 +1,90 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../../shared/extract', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Parser#extract" do - it_behaves_like :uri_extract, :extract, URI::Parser.new + before :all do + @parser = URI::Parser.new + end + + it "behaves according to its documentation" do + @parser.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.").should == ["http://foo.example.org/bla", "mailto:test@example.com"] + end + + it "treats contiguous URIs as a single URI" do + @parser.extract('http://example.jphttp://example.jp').should == ['http://example.jphttp://example.jp'] + end + + it "treats pretty much anything with a colon as a URI" do + @parser.extract('From: XXX [mailto:xxx@xxx.xxx.xxx]').should == ['From:', 'mailto:xxx@xxx.xxx.xxx]'] + end + + it "wraps a URI string in an array" do + @parser.extract("http://github.com/brixen/rubyspec/tree/master").should == ["http://github.com/brixen/rubyspec/tree/master"] + end + + it "pulls a variety of protocol URIs from a string" do + @parser.extract("this is a string, it has http://rubini.us/ in it").should == ["http://rubini.us/"] + @parser.extract("mailto:spambait@example.com").should == ["mailto:spambait@example.com"] + @parser.extract("ftp://ruby-lang.org/").should == ["ftp://ruby-lang.org/"] + @parser.extract("https://mail.google.com").should == ["https://mail.google.com"] + @parser.extract("anything://example.com/").should == ["anything://example.com/"] + end + + it "pulls all URIs within a string in order into an array when a block is not given" do + @parser.extract("1.3. Example URI + + The following examples illustrate URI that are in common use. + + ftp://ftp.is.co.za/rfc/rfc1808.txt + -- ftp scheme for File Transfer Protocol services + + gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles + -- gopher scheme for Gopher and Gopher+ Protocol services + + http://www.math.uio.no/faq/compression-faq/part1.html + -- http scheme for Hypertext Transfer Protocol services + + mailto:mduerst@ifi.unizh.ch + -- mailto scheme for electronic mail addresses + + news:comp.infosystems.www.servers.unix + -- news scheme for USENET news groups and articles + + telnet://melvyl.ucop.edu/ + -- telnet scheme for interactive services via the TELNET Protocol + ").should == ["ftp://ftp.is.co.za/rfc/rfc1808.txt","gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles","http://www.math.uio.no/faq/compression-faq/part1.html","mailto:mduerst@ifi.unizh.ch","news:comp.infosystems.www.servers.unix","telnet://melvyl.ucop.edu/"] + end + + it "yields each URI in the given string in order to a block, if given, and returns nil" do + results = ["http://foo.example.org/bla", "mailto:test@example.com"] + @parser.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.") {|uri| + uri.should == results.shift + }.should == nil + results.should == [] + end + + it "allows the user to specify a list of acceptable protocols of URIs to scan for" do + @parser.extract("1.3. Example URI + + The following examples illustrate URI that are in common use. + + ftp://ftp.is.co.za/rfc/rfc1808.txt + -- ftp scheme for File Transfer Protocol services + + gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles + -- gopher scheme for Gopher and Gopher+ Protocol services + + http://www.math.uio.no/faq/compression-faq/part1.html + -- http scheme for Hypertext Transfer Protocol services + + mailto:mduerst@ifi.unizh.ch + -- mailto scheme for electronic mail addresses + + news:comp.infosystems.www.servers.unix + -- news scheme for USENET news groups and articles + + telnet://melvyl.ucop.edu/ + -- telnet scheme for interactive services via the TELNET Protocol + ", ["http","ftp","mailto"]).should == ["ftp://ftp.is.co.za/rfc/rfc1808.txt","http://www.math.uio.no/faq/compression-faq/part1.html","mailto:mduerst@ifi.unizh.ch"] + end end diff --git a/spec/ruby/library/uri/parser/inspect_spec.rb b/spec/ruby/library/uri/parser/inspect_spec.rb index 2eaeeeafee..44fbd4077c 100644 --- a/spec/ruby/library/uri/parser/inspect_spec.rb +++ b/spec/ruby/library/uri/parser/inspect_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Parser#split" do diff --git a/spec/ruby/library/uri/parser/join_spec.rb b/spec/ruby/library/uri/parser/join_spec.rb index 1800a16236..0fb29cf00a 100644 --- a/spec/ruby/library/uri/parser/join_spec.rb +++ b/spec/ruby/library/uri/parser/join_spec.rb @@ -1,7 +1,62 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../../shared/join', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Parser#join" do - it_behaves_like :uri_join, :join, URI::Parser.new + before :all do + @parser = URI::Parser.new + end + + it "returns a URI object of the concatenation of a protocol and domain, and a path" do + @parser.join("http://localhost/","main.rbx").should == URI.parse("http://localhost/main.rbx") + end + + it "accepts URI objects" do + @parser.join(URI("http://localhost/"),"main.rbx").should == URI.parse("http://localhost/main.rbx") + @parser.join("http://localhost/",URI("main.rbx")).should == URI.parse("http://localhost/main.rbx") + @parser.join(URI("http://localhost/"),URI("main.rbx")).should == URI.parse("http://localhost/main.rbx") + end + + it "accepts string-like arguments with to_str" do + str = mock('string-like') + str.should_receive(:to_str).and_return("http://ruby-lang.org") + str2 = mock('string-like also') + str2.should_receive(:to_str).and_return("foo/bar") + @parser.join(str, str2).should == URI.parse("http://ruby-lang.org/foo/bar") + end + + it "raises an error if given no argument" do + -> { + @parser.join + }.should.raise(ArgumentError) + end + + it "doesn't create redundant '/'s" do + @parser.join("http://localhost/", "/main.rbx").should == URI.parse("http://localhost/main.rbx") + end + + it "discards arguments given before an absolute uri" do + @parser.join("http://localhost/a/b/c/d", "http://ruby-lang.com/foo", "bar").should == URI.parse("http://ruby-lang.com/bar") + end + + it "resolves .. in paths" do + @parser.join("http://localhost/a/b/c/d", "../../e/f", "g/h/../i").to_s.should == "http://localhost/a/e/g/i" + end end + +# assert_equal(URI.parse('http://foo/bar'), URI.join('http://foo/bar')) +# assert_equal(URI.parse('http://foo/bar'), URI.join('http://foo', 'bar')) +# assert_equal(URI.parse('http://foo/bar/'), URI.join('http://foo', 'bar/')) +# +# assert_equal(URI.parse('http://foo/baz'), URI.join('http://foo', 'bar', 'baz')) +# assert_equal(URI.parse('http://foo/baz'), URI.join('http://foo', 'bar', '/baz')) +# assert_equal(URI.parse('http://foo/baz/'), URI.join('http://foo', 'bar', '/baz/')) +# assert_equal(URI.parse('http://foo/bar/baz'), URI.join('http://foo', 'bar/', 'baz')) +# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar', 'baz', 'hoge')) +# +# assert_equal(URI.parse('http://foo/bar/baz'), URI.join('http://foo', 'bar/baz')) +# assert_equal(URI.parse('http://foo/bar/hoge'), URI.join('http://foo', 'bar/baz', 'hoge')) +# assert_equal(URI.parse('http://foo/bar/baz/hoge'), URI.join('http://foo', 'bar/baz/', 'hoge')) +# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar/baz', '/hoge')) +# assert_equal(URI.parse('http://foo/bar/hoge'), URI.join('http://foo', 'bar/baz', 'hoge')) +# assert_equal(URI.parse('http://foo/bar/baz/hoge'), URI.join('http://foo', 'bar/baz/', 'hoge')) +# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar/baz', '/hoge')) diff --git a/spec/ruby/library/uri/parser/make_regexp_spec.rb b/spec/ruby/library/uri/parser/make_regexp_spec.rb index e27f0d14db..0631d13ee6 100644 --- a/spec/ruby/library/uri/parser/make_regexp_spec.rb +++ b/spec/ruby/library/uri/parser/make_regexp_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Parser#make_regexp" do diff --git a/spec/ruby/library/uri/parser/parse_spec.rb b/spec/ruby/library/uri/parser/parse_spec.rb index 76c1970645..0e6a06ebe5 100644 --- a/spec/ruby/library/uri/parser/parse_spec.rb +++ b/spec/ruby/library/uri/parser/parse_spec.rb @@ -1,7 +1,213 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../../fixtures/classes', __FILE__) -require File.expand_path('../../shared/parse', __FILE__) +require_relative '../../../spec_helper' +require_relative '../fixtures/classes' describe "URI::Parser#parse" do - it_behaves_like :uri_parse, :parse, URI::Parser.new + before :all do + @parser = URI::Parser.new + end + + it "returns a URI::HTTP object when parsing an HTTP URI" do + @parser.parse("http://www.example.com/").should.is_a?(URI::HTTP) + end + + it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do + # general case + URISpec.components(@parser.parse("http://user:pass@example.com/path/?query=val&q2=val2#fragment")).should == { + scheme: "http", + userinfo: "user:pass", + host: "example.com", + port: 80, + path: "/path/", + query: "query=val&q2=val2", + fragment: "fragment" + } + + # multiple paths + URISpec.components(@parser.parse("http://a/b/c/d;p?q")).should == { + scheme: "http", + userinfo: nil, + host: "a", + port: 80, + path: "/b/c/d;p", + query: "q", + fragment: nil + } + + # multi-level domain + URISpec.components(@parser.parse('http://www.math.uio.no/faq/compression-faq/part1.html')).should == { + scheme: "http", + userinfo: nil, + host: "www.math.uio.no", + port: 80, + path: "/faq/compression-faq/part1.html", + query: nil, + fragment: nil + } + end + + it "parses out the port number of a URI, when given" do + @parser.parse("http://example.com:8080/").port.should == 8080 + end + + it "returns a URI::HTTPS object when parsing an HTTPS URI" do + @parser.parse("https://important-intern-net.net").should.is_a?(URI::HTTPS) + end + + it "sets the port of a parsed https URI to 443 by default" do + @parser.parse("https://example.com/").port.should == 443 + end + + it "populates the components of a parsed URI::FTP object" do + # generic, empty password. + url = @parser.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i") + url.should.is_a?(URI::FTP) + URISpec.components(url).should == { + scheme: "ftp", + userinfo: "anonymous", + host: "ruby-lang.org", + port: 21, + path: "pub/ruby/1.8/ruby-1.8.6.tar.bz2", + typecode: "i" + } + + # multidomain, no user or password + url = @parser.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt') + url.should.is_a?(URI::FTP) + URISpec.components(url).should == { + scheme: "ftp", + userinfo: nil, + host: "ftp.is.co.za", + port: 21, + path: "rfc/rfc1808.txt", + typecode: nil + } + + # empty user + url = @parser.parse('ftp://:pass@localhost/') + url.should.is_a?(URI::FTP) + URISpec.components(url).should == { + scheme: "ftp", + userinfo: ":pass", + host: "localhost", + port: 21, + path: "", + typecode: nil + } + url.password.should == "pass" + end + + it "returns a URI::LDAP object when parsing an LDAP URI" do + #taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like + ldap_uris = %w{ ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one ldap://ldap.question.com/o=Question%3f,c=US?mail ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04) ldap:///??sub??bindname=cn=Manager%2co=Foo ldap:///??sub??!bindname=cn=Manager%2co=Foo } + ldap_uris.each do |ldap_uri| + @parser.parse(ldap_uri).should.is_a?(URI::LDAP) + end + end + + it "populates the components of a parsed URI::LDAP object" do + URISpec.components(@parser.parse("ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress?scope?filter?extensions")).should == { + scheme: "ldap", + host: "ldap.itd.umich.edu", + port: 389, + dn: "o=University%20of%20Michigan,c=US", + attributes: "postalAddress", + scope: "scope", + filter: "filter", + extensions: "extensions" + } + end + + it "returns a URI::MailTo object when passed a mailto URI" do + @parser.parse("mailto:spam@mailinator.com").should.is_a?(URI::MailTo) + end + + it "populates the components of a parsed URI::MailTo object" do + URISpec.components(@parser.parse("mailto:spam@mailinator.com?subject=Discounts%20On%20Imported%20methods!!!&body=Exciting%20offer")).should == { + scheme: "mailto", + to: "spam@mailinator.com", + headers: [["subject","Discounts%20On%20Imported%20methods!!!"], + ["body", "Exciting%20offer"]] + } + end + + # TODO + # Test registry + it "does its best to extract components from URI::Generic objects" do + # generic + URISpec.components(URI("scheme://userinfo@host/path?query#fragment")).should == { + scheme: "scheme", + userinfo: "userinfo", + host: "host", + port: nil, + path: "/path", + query: "query", + fragment: "fragment", + registry: nil, + opaque: nil + } + + # gopher + gopher = @parser.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles') + gopher.should.is_a?(URI::Generic) + + URISpec.components(gopher).should == { + scheme: "gopher", + userinfo: nil, + host: "spinaltap.micro.umn.edu", + port: nil, + path: "/00/Weather/California/Los%20Angeles", + query: nil, + fragment: nil, + registry: nil, + opaque: nil + } + + # news + news = @parser.parse('news:comp.infosystems.www.servers.unix') + news.should.is_a?(URI::Generic) + URISpec.components(news).should == { + scheme: "news", + userinfo: nil, + host: nil, + port: nil, + path: nil, + query: nil, + fragment: nil, + registry: nil, + opaque: "comp.infosystems.www.servers.unix" + } + + # telnet + telnet = @parser.parse('telnet://melvyl.ucop.edu/') + telnet.should.is_a?(URI::Generic) + URISpec.components(telnet).should == { + scheme: "telnet", + userinfo: nil, + host: "melvyl.ucop.edu", + port: nil, + path: "/", + query: nil, + fragment: nil, + registry: nil, + opaque: nil + } + + # files + file_l = @parser.parse('file:///foo/bar.txt') + file_l.should.is_a?(URI::Generic) + file = @parser.parse('file:/foo/bar.txt') + file.should.is_a?(URI::Generic) + end + + if URI::DEFAULT_PARSER == URI::RFC2396_Parser + it "raises errors on malformed URIs" do + -> { @parser.parse('http://a_b:80/') }.should.raise(URI::InvalidURIError) + -> { @parser.parse('http://a_b/') }.should.raise(URI::InvalidURIError) + end + elsif URI::DEFAULT_PARSER == URI::RFC3986_Parser + it "does not raise errors on URIs contained underscore" do + -> { @parser.parse('http://a_b:80/') }.should_not.raise(URI::InvalidURIError) + -> { @parser.parse('http://a_b/') }.should_not.raise(URI::InvalidURIError) + end + end end diff --git a/spec/ruby/library/uri/parser/split_spec.rb b/spec/ruby/library/uri/parser/split_spec.rb index 2eaeeeafee..44fbd4077c 100644 --- a/spec/ruby/library/uri/parser/split_spec.rb +++ b/spec/ruby/library/uri/parser/split_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Parser#split" do diff --git a/spec/ruby/library/uri/parser/unescape_spec.rb b/spec/ruby/library/uri/parser/unescape_spec.rb index 8ffc534226..e18d2eb9d3 100644 --- a/spec/ruby/library/uri/parser/unescape_spec.rb +++ b/spec/ruby/library/uri/parser/unescape_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Parser#unescape" do diff --git a/spec/ruby/library/uri/plus_spec.rb b/spec/ruby/library/uri/plus_spec.rb index 45c1aa5e57..51fb5e3750 100644 --- a/spec/ruby/library/uri/plus_spec.rb +++ b/spec/ruby/library/uri/plus_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' #an alias of URI#merge @@ -31,12 +31,12 @@ describe "URI#+" do (URI.parse('http://a/b/c/../../../') + ".").should == URI("http://a/") end - it "doesn't conconicalize the path when adding to the empty string" do + it "doesn't canonicalize the path when adding to the empty string" do (URI.parse('http://a/b/c/../') + "").should == URI("http://a/b/c/../") end it "raises a URI::BadURIError when adding two relative URIs" do - lambda {URI.parse('a/b/c') + "d"}.should raise_error(URI::BadURIError) + -> {URI.parse('a/b/c') + "d"}.should.raise(URI::BadURIError) end #Todo: make more BDD? @@ -47,403 +47,403 @@ describe "URI#+" do # http://a/b/c/d;p?q # g:h = g:h url = @base_url.merge('g:h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g:h' url = @base_url.route_to('g:h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g:h' # http://a/b/c/d;p?q # g = http://a/b/c/g url = @base_url.merge('g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g' url = @base_url.route_to('http://a/b/c/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g' # http://a/b/c/d;p?q # ./g = http://a/b/c/g url = @base_url.merge('./g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g' url = @base_url.route_to('http://a/b/c/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == './g' # ok url.to_s.should == 'g' # http://a/b/c/d;p?q # g/ = http://a/b/c/g/ url = @base_url.merge('g/') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g/' url = @base_url.route_to('http://a/b/c/g/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g/' # http://a/b/c/d;p?q # /g = http://a/g url = @base_url.merge('/g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '/g' # ok url.to_s.should == '../../g' # http://a/b/c/d;p?q # //g = http://g url = @base_url.merge('//g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://g' url = @base_url.route_to('http://g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '//g' # http://a/b/c/d;p?q # ?y = http://a/b/c/?y url = @base_url.merge('?y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/d;p?y' url = @base_url.route_to('http://a/b/c/?y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '?y' # http://a/b/c/d;p?q # g?y = http://a/b/c/g?y url = @base_url.merge('g?y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y' url = @base_url.route_to('http://a/b/c/g?y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y' # http://a/b/c/d;p?q # #s = (current document)#s url = @base_url.merge('#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == @base_url.to_s + '#s' url = @base_url.route_to(@base_url.to_s + '#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '#s' # http://a/b/c/d;p?q # g#s = http://a/b/c/g#s url = @base_url.merge('g#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g#s' url = @base_url.route_to('http://a/b/c/g#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g#s' # http://a/b/c/d;p?q # g?y#s = http://a/b/c/g?y#s url = @base_url.merge('g?y#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y#s' url = @base_url.route_to('http://a/b/c/g?y#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y#s' # http://a/b/c/d;p?q # ;x = http://a/b/c/;x url = @base_url.merge(';x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/;x' url = @base_url.route_to('http://a/b/c/;x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == ';x' # http://a/b/c/d;p?q # g;x = http://a/b/c/g;x url = @base_url.merge('g;x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g;x' url = @base_url.route_to('http://a/b/c/g;x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g;x' # http://a/b/c/d;p?q # g;x?y#s = http://a/b/c/g;x?y#s url = @base_url.merge('g;x?y#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g;x?y#s' url = @base_url.route_to('http://a/b/c/g;x?y#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g;x?y#s' # http://a/b/c/d;p?q # . = http://a/b/c/ url = @base_url.merge('.') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/' url = @base_url.route_to('http://a/b/c/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '.' # ok url.to_s.should == './' # http://a/b/c/d;p?q # ./ = http://a/b/c/ url = @base_url.merge('./') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/' url = @base_url.route_to('http://a/b/c/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == './' # http://a/b/c/d;p?q # .. = http://a/b/ url = @base_url.merge('..') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/' url = @base_url.route_to('http://a/b/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '..' # ok url.to_s.should == '../' # http://a/b/c/d;p?q # ../ = http://a/b/ url = @base_url.merge('../') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/' url = @base_url.route_to('http://a/b/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../' # http://a/b/c/d;p?q # ../g = http://a/b/g url = @base_url.merge('../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/g' url = @base_url.route_to('http://a/b/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../g' # http://a/b/c/d;p?q # ../.. = http://a/ url = @base_url.merge('../..') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/' url = @base_url.route_to('http://a/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '../..' # ok url.to_s.should == '../../' # http://a/b/c/d;p?q # ../../ = http://a/ url = @base_url.merge('../../') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/' url = @base_url.route_to('http://a/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../../' # http://a/b/c/d;p?q # ../../g = http://a/g url = @base_url.merge('../../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../../g' # http://a/b/c/d;p?q # <> = (current document) url = @base_url.merge('') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/d;p?q' url = @base_url.route_to('http://a/b/c/d;p?q') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '' # http://a/b/c/d;p?q # /./g = http://a/./g url = @base_url.merge('/./g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/./g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '/./g' # http://a/b/c/d;p?q # /../g = http://a/../g url = @base_url.merge('/../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/../g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '/../g' # http://a/b/c/d;p?q # g. = http://a/b/c/g. url = @base_url.merge('g.') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g.' url = @base_url.route_to('http://a/b/c/g.') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g.' # http://a/b/c/d;p?q # .g = http://a/b/c/.g url = @base_url.merge('.g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/.g' url = @base_url.route_to('http://a/b/c/.g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '.g' # http://a/b/c/d;p?q # g.. = http://a/b/c/g.. url = @base_url.merge('g..') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g..' url = @base_url.route_to('http://a/b/c/g..') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g..' # http://a/b/c/d;p?q # ..g = http://a/b/c/..g url = @base_url.merge('..g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/..g' url = @base_url.route_to('http://a/b/c/..g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '..g' # http://a/b/c/d;p?q # ../../../g = http://a/../g url = @base_url.merge('../../../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/../g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '../../../g' # ok? yes, it confuses you url.to_s.should == '/../g' # and it is clearly # http://a/b/c/d;p?q # ../../../../g = http://a/../../g url = @base_url.merge('../../../../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/../../g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '../../../../g' # ok? yes, it confuses you url.to_s.should == '/../../g' # and it is clearly # http://a/b/c/d;p?q # ./../g = http://a/b/g url = @base_url.merge('./../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/g' url = @base_url.route_to('http://a/b/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == './../g' # ok url.to_s.should == '../g' # http://a/b/c/d;p?q # ./g/. = http://a/b/c/g/ url = @base_url.merge('./g/.') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g/' url = @base_url.route_to('http://a/b/c/g/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == './g/.' # ok url.to_s.should == 'g/' # http://a/b/c/d;p?q # g/./h = http://a/b/c/g/h url = @base_url.merge('g/./h') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g/h' url = @base_url.route_to('http://a/b/c/g/h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g/./h' # ok url.to_s.should == 'g/h' # http://a/b/c/d;p?q # g/../h = http://a/b/c/h url = @base_url.merge('g/../h') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/h' url = @base_url.route_to('http://a/b/c/h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g/../h' # ok url.to_s.should == 'h' # http://a/b/c/d;p?q # g;x=1/./y = http://a/b/c/g;x=1/y url = @base_url.merge('g;x=1/./y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g;x=1/y' url = @base_url.route_to('http://a/b/c/g;x=1/y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g;x=1/./y' # ok url.to_s.should == 'g;x=1/y' # http://a/b/c/d;p?q # g;x=1/../y = http://a/b/c/y url = @base_url.merge('g;x=1/../y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/y' url = @base_url.route_to('http://a/b/c/y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g;x=1/../y' # ok url.to_s.should == 'y' # http://a/b/c/d;p?q # g?y/./x = http://a/b/c/g?y/./x url = @base_url.merge('g?y/./x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y/./x' url = @base_url.route_to('http://a/b/c/g?y/./x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y/./x' # http://a/b/c/d;p?q # g?y/../x = http://a/b/c/g?y/../x url = @base_url.merge('g?y/../x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y/../x' url = @base_url.route_to('http://a/b/c/g?y/../x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y/../x' # http://a/b/c/d;p?q # g#s/./x = http://a/b/c/g#s/./x url = @base_url.merge('g#s/./x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g#s/./x' url = @base_url.route_to('http://a/b/c/g#s/./x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g#s/./x' # http://a/b/c/d;p?q # g#s/../x = http://a/b/c/g#s/../x url = @base_url.merge('g#s/../x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g#s/../x' url = @base_url.route_to('http://a/b/c/g#s/../x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g#s/../x' # http://a/b/c/d;p?q # http:g = http:g ; for validating parsers # | http://a/b/c/g ; for backwards compatibility url = @base_url.merge('http:g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http:g' url = @base_url.route_to('http:g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'http:g' end end diff --git a/spec/ruby/library/uri/regexp_spec.rb b/spec/ruby/library/uri/regexp_spec.rb index cf63507013..6e8b3df4d0 100644 --- a/spec/ruby/library/uri/regexp_spec.rb +++ b/spec/ruby/library/uri/regexp_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' #I'm more or less ok with these limited tests, as the more extensive extract tests diff --git a/spec/ruby/library/uri/route_from_spec.rb b/spec/ruby/library/uri/route_from_spec.rb index 11a2c44f90..501f455775 100644 --- a/spec/ruby/library/uri/route_from_spec.rb +++ b/spec/ruby/library/uri/route_from_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI#route_from" do diff --git a/spec/ruby/library/uri/route_to_spec.rb b/spec/ruby/library/uri/route_to_spec.rb index 2eb68afdfd..ae9d38d23d 100644 --- a/spec/ruby/library/uri/route_to_spec.rb +++ b/spec/ruby/library/uri/route_to_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI#route_to" do diff --git a/spec/ruby/library/uri/select_spec.rb b/spec/ruby/library/uri/select_spec.rb index 46474757cc..27591f69f2 100644 --- a/spec/ruby/library/uri/select_spec.rb +++ b/spec/ruby/library/uri/select_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI#select" do @@ -15,17 +15,13 @@ describe "URI#select" do end it "raises an ArgumentError if a component is requested that isn't valid under the given scheme" do - [ - lambda {URI("mailto:spam@mailinator.com").select(:path)}, - lambda {URI("http://blog.blag.web").select(:typecode)}, - ].each do |select_lambda| - select_lambda.should raise_error(ArgumentError) - end + -> { URI("mailto:spam@mailinator.com").select(:path) }.should.raise(ArgumentError) + -> { URI("http://blog.blag.web").select(:typecode) }.should.raise(ArgumentError) end it "raises an ArgumentError if given strings rather than symbols" do - lambda { + -> { URI("http://host:8080/path/").select("scheme","host","port",'path') - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/uri/set_component_spec.rb b/spec/ruby/library/uri/set_component_spec.rb index 9b8372108a..15f1ed1f87 100644 --- a/spec/ruby/library/uri/set_component_spec.rb +++ b/spec/ruby/library/uri/set_component_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' #TODO: make this more BDD @@ -6,42 +6,42 @@ describe "URI#select" do it "conforms to the MatzRuby tests" do uri = URI.parse('http://foo:bar@baz') (uri.user = 'oof').should == 'oof' - uri.to_s.should == 'http://oof:bar@baz' - (uri.password = 'rab').should == 'rab' - uri.to_s.should == 'http://oof:rab@baz' - (uri.userinfo = 'foo').should == 'foo' - uri.to_s.should == 'http://foo:rab@baz' - (uri.userinfo = ['foo', 'bar']).should == ['foo', 'bar'] - uri.to_s.should == 'http://foo:bar@baz' - (uri.userinfo = ['foo']).should == ['foo'] - uri.to_s.should == 'http://foo:bar@baz' - (uri.host = 'zab').should == 'zab' - uri.to_s.should == 'http://foo:bar@zab' - (uri.port = 8080).should == 8080 - uri.to_s.should == 'http://foo:bar@zab:8080' - (uri.path = '/').should == '/' - uri.to_s.should == 'http://foo:bar@zab:8080/' - (uri.query = 'a=1').should == 'a=1' - uri.to_s.should == 'http://foo:bar@zab:8080/?a=1' - (uri.fragment = 'b123').should == 'b123' - uri.to_s.should == 'http://foo:bar@zab:8080/?a=1#b123' + version_is(URI::VERSION, "1.0.4") do + uri.to_s.should == 'http://oof@baz' + (uri.password = 'rab').should == 'rab' + uri.to_s.should == 'http://oof:rab@baz' + (uri.userinfo = 'foo').should == 'foo' + uri.to_s.should == 'http://foo@baz' + (uri.userinfo = ['foo', 'bar']).should == ['foo', 'bar'] + uri.to_s.should == 'http://foo:bar@baz' + (uri.userinfo = ['foo']).should == ['foo'] + uri.to_s.should == 'http://foo@baz' + (uri.host = 'zab').should == 'zab' + uri.to_s.should == 'http://zab' + (uri.port = 8080).should == 8080 + uri.to_s.should == 'http://zab:8080' + (uri.path = '/').should == '/' + uri.to_s.should == 'http://zab:8080/' + (uri.query = 'a=1').should == 'a=1' + uri.to_s.should == 'http://zab:8080/?a=1' + (uri.fragment = 'b123').should == 'b123' + uri.to_s.should == 'http://zab:8080/?a=1#b123' + end uri = URI.parse('http://example.com') - lambda { uri.password = 'bar' }.should raise_error(URI::InvalidURIError) + -> { uri.password = 'bar' }.should.raise(URI::InvalidURIError) uri.userinfo = 'foo:bar' uri.to_s.should == 'http://foo:bar@example.com' - lambda { uri.registry = 'bar' }.should raise_error(URI::InvalidURIError) - lambda { uri.opaque = 'bar' }.should raise_error(URI::InvalidURIError) + -> { uri.registry = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.opaque = 'bar' }.should.raise(URI::InvalidURIError) uri = URI.parse('mailto:foo@example.com') - lambda { uri.user = 'bar' }.should raise_error(URI::InvalidURIError) - lambda { uri.password = 'bar' }.should raise_error(URI::InvalidURIError) - lambda { uri.userinfo = ['bar', 'baz'] }.should raise_error(URI::InvalidURIError) - lambda { uri.host = 'bar' }.should raise_error(URI::InvalidURIError) - lambda { uri.port = 'bar' }.should raise_error(URI::InvalidURIError) - lambda { uri.path = 'bar' }.should raise_error(URI::InvalidURIError) - lambda { uri.query = 'bar' }.should raise_error(URI::InvalidURIError) + -> { uri.user = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.password = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.userinfo = ['bar', 'baz'] }.should.raise(URI::InvalidURIError) + -> { uri.host = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.port = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.path = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.query = 'bar' }.should.raise(URI::InvalidURIError) end end - - diff --git a/spec/ruby/library/uri/shared/eql.rb b/spec/ruby/library/uri/shared/eql.rb index 2cc960d39a..978c4aae05 100644 --- a/spec/ruby/library/uri/shared/eql.rb +++ b/spec/ruby/library/uri/shared/eql.rb @@ -3,7 +3,7 @@ describe :uri_eql, shared: true do URISpec::NORMALIZED_FORMS.each do |form| normal_uri = URI(form[:normalized]) form[:different].each do |other| - URI(other).send(@method, normal_uri).should be_false + URI(other).send(@method, normal_uri).should == false end end end @@ -11,7 +11,7 @@ end describe :uri_eql_against_other_types, shared: true do it "returns false for when compared to non-uri objects" do - URI("http://example.com/").send(@method, "http://example.com/").should be_false - URI("http://example.com/").send(@method, nil).should be_false + URI("http://example.com/").send(@method, "http://example.com/").should == false + URI("http://example.com/").send(@method, nil).should == false end end diff --git a/spec/ruby/library/uri/shared/extract.rb b/spec/ruby/library/uri/shared/extract.rb deleted file mode 100644 index efe60ae4b9..0000000000 --- a/spec/ruby/library/uri/shared/extract.rb +++ /dev/null @@ -1,83 +0,0 @@ -describe :uri_extract, shared: true do - it "behaves according to its documentation" do - @object.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.").should == ["http://foo.example.org/bla", "mailto:test@example.com"] - end - - it "treats contiguous URIs as a single URI" do - @object.extract('http://example.jphttp://example.jp').should == ['http://example.jphttp://example.jp'] - end - - it "treats pretty much anything with a colon as a URI" do - @object.extract('From: XXX [mailto:xxx@xxx.xxx.xxx]').should == ['From:', 'mailto:xxx@xxx.xxx.xxx]'] - end - - it "wraps a URI string in an array" do - @object.extract("http://github.com/brixen/rubyspec/tree/master").should == ["http://github.com/brixen/rubyspec/tree/master"] - end - - it "pulls a variety of protocol URIs from a string" do - @object.extract("this is a string, it has http://rubini.us/ in it").should == ["http://rubini.us/"] - @object.extract("mailto:spambait@example.com").should == ["mailto:spambait@example.com"] - @object.extract("ftp://ruby-lang.org/").should == ["ftp://ruby-lang.org/"] - @object.extract("https://mail.google.com").should == ["https://mail.google.com"] - @object.extract("anything://example.com/").should == ["anything://example.com/"] - end - - it "pulls all URIs within a string in order into an array when a block is not given" do - @object.extract("1.3. Example URI - - The following examples illustrate URI that are in common use. - - ftp://ftp.is.co.za/rfc/rfc1808.txt - -- ftp scheme for File Transfer Protocol services - - gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles - -- gopher scheme for Gopher and Gopher+ Protocol services - - http://www.math.uio.no/faq/compression-faq/part1.html - -- http scheme for Hypertext Transfer Protocol services - - mailto:mduerst@ifi.unizh.ch - -- mailto scheme for electronic mail addresses - - news:comp.infosystems.www.servers.unix - -- news scheme for USENET news groups and articles - - telnet://melvyl.ucop.edu/ - -- telnet scheme for interactive services via the TELNET Protocol - ").should == ["ftp://ftp.is.co.za/rfc/rfc1808.txt","gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles","http://www.math.uio.no/faq/compression-faq/part1.html","mailto:mduerst@ifi.unizh.ch","news:comp.infosystems.www.servers.unix","telnet://melvyl.ucop.edu/"] - end - - it "yields each URI in the given string in order to a block, if given, and returns nil" do - results = ["http://foo.example.org/bla", "mailto:test@example.com"] - @object.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.") {|uri| - uri.should == results.shift - }.should == nil - results.should == [] - end - - it "allows the user to specify a list of acceptable protocols of URIs to scan for" do - @object.extract("1.3. Example URI - - The following examples illustrate URI that are in common use. - - ftp://ftp.is.co.za/rfc/rfc1808.txt - -- ftp scheme for File Transfer Protocol services - - gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles - -- gopher scheme for Gopher and Gopher+ Protocol services - - http://www.math.uio.no/faq/compression-faq/part1.html - -- http scheme for Hypertext Transfer Protocol services - - mailto:mduerst@ifi.unizh.ch - -- mailto scheme for electronic mail addresses - - news:comp.infosystems.www.servers.unix - -- news scheme for USENET news groups and articles - - telnet://melvyl.ucop.edu/ - -- telnet scheme for interactive services via the TELNET Protocol - ", ["http","ftp","mailto"]).should == ["ftp://ftp.is.co.za/rfc/rfc1808.txt","http://www.math.uio.no/faq/compression-faq/part1.html","mailto:mduerst@ifi.unizh.ch"] - end -end diff --git a/spec/ruby/library/uri/shared/join.rb b/spec/ruby/library/uri/shared/join.rb deleted file mode 100644 index ff85b57a80..0000000000 --- a/spec/ruby/library/uri/shared/join.rb +++ /dev/null @@ -1,56 +0,0 @@ -describe :uri_join, shared: true do - it "returns a URI object of the concatenation of a protocol and domain, and a path" do - @object.join("http://localhost/","main.rbx").should == URI.parse("http://localhost/main.rbx") - end - - it "accepts URI objects" do - @object.join(URI("http://localhost/"),"main.rbx").should == URI.parse("http://localhost/main.rbx") - @object.join("http://localhost/",URI("main.rbx")).should == URI.parse("http://localhost/main.rbx") - @object.join(URI("http://localhost/"),URI("main.rbx")).should == URI.parse("http://localhost/main.rbx") - end - - it "accepts string-like arguments with to_str" do - str = mock('string-like') - str.should_receive(:to_str).and_return("http://ruby-lang.org") - str2 = mock('string-like also') - str2.should_receive(:to_str).and_return("foo/bar") - @object.join(str, str2).should == URI.parse("http://ruby-lang.org/foo/bar") - end - - it "raises an error if given no argument" do - lambda { - @object.join - }.should raise_error(ArgumentError) - end - - it "doesn't create redundant '/'s" do - @object.join("http://localhost/", "/main.rbx").should == URI.parse("http://localhost/main.rbx") - end - - it "discards arguments given before an absolute uri" do - @object.join("http://localhost/a/b/c/d", "http://ruby-lang.com/foo", "bar").should == URI.parse("http://ruby-lang.com/bar") - end - - it "resolves .. in paths" do - @object.join("http://localhost/a/b/c/d", "../../e/f", "g/h/../i").to_s.should == "http://localhost/a/e/g/i" - end -end - - -# assert_equal(URI.parse('http://foo/bar'), URI.join('http://foo/bar')) -# assert_equal(URI.parse('http://foo/bar'), URI.join('http://foo', 'bar')) -# assert_equal(URI.parse('http://foo/bar/'), URI.join('http://foo', 'bar/')) -# -# assert_equal(URI.parse('http://foo/baz'), URI.join('http://foo', 'bar', 'baz')) -# assert_equal(URI.parse('http://foo/baz'), URI.join('http://foo', 'bar', '/baz')) -# assert_equal(URI.parse('http://foo/baz/'), URI.join('http://foo', 'bar', '/baz/')) -# assert_equal(URI.parse('http://foo/bar/baz'), URI.join('http://foo', 'bar/', 'baz')) -# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar', 'baz', 'hoge')) -# -# assert_equal(URI.parse('http://foo/bar/baz'), URI.join('http://foo', 'bar/baz')) -# assert_equal(URI.parse('http://foo/bar/hoge'), URI.join('http://foo', 'bar/baz', 'hoge')) -# assert_equal(URI.parse('http://foo/bar/baz/hoge'), URI.join('http://foo', 'bar/baz/', 'hoge')) -# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar/baz', '/hoge')) -# assert_equal(URI.parse('http://foo/bar/hoge'), URI.join('http://foo', 'bar/baz', 'hoge')) -# assert_equal(URI.parse('http://foo/bar/baz/hoge'), URI.join('http://foo', 'bar/baz/', 'hoge')) -# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar/baz', '/hoge')) diff --git a/spec/ruby/library/uri/shared/parse.rb b/spec/ruby/library/uri/shared/parse.rb deleted file mode 100644 index 5ecbffcaf2..0000000000 --- a/spec/ruby/library/uri/shared/parse.rb +++ /dev/null @@ -1,199 +0,0 @@ -describe :uri_parse, shared: true do - it "returns a URI::HTTP object when parsing an HTTP URI" do - @object.parse("http://www.example.com/").should be_kind_of(URI::HTTP) - end - - it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do - # general case - URISpec.components(@object.parse("http://user:pass@example.com/path/?query=val&q2=val2#fragment")).should == { - scheme: "http", - userinfo: "user:pass", - host: "example.com", - port: 80, - path: "/path/", - query: "query=val&q2=val2", - fragment: "fragment" - } - - # multiple paths - URISpec.components(@object.parse("http://a/b/c/d;p?q")).should == { - scheme: "http", - userinfo: nil, - host: "a", - port: 80, - path: "/b/c/d;p", - query: "q", - fragment: nil - } - - # multi-level domain - URISpec.components(@object.parse('http://www.math.uio.no/faq/compression-faq/part1.html')).should == { - scheme: "http", - userinfo: nil, - host: "www.math.uio.no", - port: 80, - path: "/faq/compression-faq/part1.html", - query: nil, - fragment: nil - } - end - - it "parses out the port number of a URI, when given" do - @object.parse("http://example.com:8080/").port.should == 8080 - end - - it "returns a URI::HTTPS object when parsing an HTTPS URI" do - @object.parse("https://important-intern-net.net").should be_kind_of(URI::HTTPS) - end - - it "sets the port of a parsed https URI to 443 by default" do - @object.parse("https://example.com/").port.should == 443 - end - - it "populates the components of a parsed URI::FTP object" do - # generic, empty password. - url = @object.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i") - url.should be_kind_of(URI::FTP) - URISpec.components(url).should == { - scheme: "ftp", - userinfo: "anonymous", - host: "ruby-lang.org", - port: 21, - path: "pub/ruby/1.8/ruby-1.8.6.tar.bz2", - typecode: "i" - } - - # multidomain, no user or password - url = @object.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt') - url.should be_kind_of(URI::FTP) - URISpec.components(url).should == { - scheme: "ftp", - userinfo: nil, - host: "ftp.is.co.za", - port: 21, - path: "rfc/rfc1808.txt", - typecode: nil - } - - # empty user - url = @object.parse('ftp://:pass@localhost/') - url.should be_kind_of(URI::FTP) - URISpec.components(url).should == { - scheme: "ftp", - userinfo: ":pass", - host: "localhost", - port: 21, - path: "", - typecode: nil - } - url.password.should == "pass" - end - - it "returns a URI::LDAP object when parsing an LDAP URI" do - #taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like - ldap_uris = %w{ ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one ldap://ldap.question.com/o=Question%3f,c=US?mail ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04) ldap:///??sub??bindname=cn=Manager%2co=Foo ldap:///??sub??!bindname=cn=Manager%2co=Foo } - ldap_uris.each do |ldap_uri| - @object.parse(ldap_uri).should be_kind_of(URI::LDAP) - end - end - - it "populates the components of a parsed URI::LDAP object" do - URISpec.components(@object.parse("ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress?scope?filter?extensions")).should == { - scheme: "ldap", - host: "ldap.itd.umich.edu", - port: 389, - dn: "o=University%20of%20Michigan,c=US", - attributes: "postalAddress", - scope: "scope", - filter: "filter", - extensions: "extensions" - } - end - - it "returns a URI::MailTo object when passed a mailto URI" do - @object.parse("mailto:spam@mailinator.com").should be_kind_of(URI::MailTo) - end - - it "populates the components of a parsed URI::MailTo object" do - URISpec.components(@object.parse("mailto:spam@mailinator.com?subject=Discounts%20On%20Imported%20methods!!!&body=Exciting%20offer")).should == { - scheme: "mailto", - to: "spam@mailinator.com", - headers: [["subject","Discounts%20On%20Imported%20methods!!!"], - ["body", "Exciting%20offer"]] - } - end - - # TODO - # Test registry - it "does its best to extract components from URI::Generic objects" do - # generic - URISpec.components(URI("scheme://userinfo@host/path?query#fragment")).should == { - scheme: "scheme", - userinfo: "userinfo", - host: "host", - port: nil, - path: "/path", - query: "query", - fragment: "fragment", - registry: nil, - opaque: nil - } - - # gopher - gopher = @object.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles') - gopher.should be_kind_of(URI::Generic) - - URISpec.components(gopher).should == { - scheme: "gopher", - userinfo: nil, - host: "spinaltap.micro.umn.edu", - port: nil, - path: "/00/Weather/California/Los%20Angeles", - query: nil, - fragment: nil, - registry: nil, - opaque: nil - } - - # news - news = @object.parse('news:comp.infosystems.www.servers.unix') - news.should be_kind_of(URI::Generic) - URISpec.components(news).should == { - scheme: "news", - userinfo: nil, - host: nil, - port: nil, - path: nil, - query: nil, - fragment: nil, - registry: nil, - opaque: "comp.infosystems.www.servers.unix" - } - - # telnet - telnet = @object.parse('telnet://melvyl.ucop.edu/') - telnet.should be_kind_of(URI::Generic) - URISpec.components(telnet).should == { - scheme: "telnet", - userinfo: nil, - host: "melvyl.ucop.edu", - port: nil, - path: "/", - query: nil, - fragment: nil, - registry: nil, - opaque: nil - } - - # files - file_l = @object.parse('file:///foo/bar.txt') - file_l.should be_kind_of(URI::Generic) - file = @object.parse('file:/foo/bar.txt') - file.should be_kind_of(URI::Generic) - end - - it "raises errors on malformed URIs" do - lambda { @object.parse('http://a_b:80/') }.should raise_error(URI::InvalidURIError) - lambda { @object.parse('http://a_b/') }.should raise_error(URI::InvalidURIError) - end -end diff --git a/spec/ruby/library/uri/split_spec.rb b/spec/ruby/library/uri/split_spec.rb index f0ab6ff35c..9ad37e3b1f 100644 --- a/spec/ruby/library/uri/split_spec.rb +++ b/spec/ruby/library/uri/split_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' describe "URI.split" do diff --git a/spec/ruby/library/uri/uri_spec.rb b/spec/ruby/library/uri/uri_spec.rb index 90936a770f..eab4e7176c 100644 --- a/spec/ruby/library/uri/uri_spec.rb +++ b/spec/ruby/library/uri/uri_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'uri' #the testing is light here as this is an alias for URI.parse @@ -19,11 +19,11 @@ describe "the URI method" do it "returns the argument if it is a URI object" do result = URI.parse("http://ruby-lang.org") - URI(result).should equal(result) + URI(result).should.equal?(result) end #apparently this was a concern? imported from MRI tests it "does not add a URI method to Object instances" do - lambda {Object.new.URI("http://ruby-lang.org/")}.should raise_error(NoMethodError) + -> {Object.new.URI("http://ruby-lang.org/")}.should.raise(NoMethodError) end end diff --git a/spec/ruby/library/uri/util/make_components_hash_spec.rb b/spec/ruby/library/uri/util/make_components_hash_spec.rb index 0f491112e8..6d26b81130 100644 --- a/spec/ruby/library/uri/util/make_components_hash_spec.rb +++ b/spec/ruby/library/uri/util/make_components_hash_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'uri' describe "URI::Util.make_components_hash" do |
