summaryrefslogtreecommitdiff
path: root/spec/ruby/library
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library')
-rw-r--r--spec/ruby/library/English/English_spec.rb16
-rw-r--r--spec/ruby/library/base64/decode64_spec.rb4
-rw-r--r--spec/ruby/library/bigdecimal/BigDecimal_spec.rb57
-rw-r--r--spec/ruby/library/bigdecimal/add_spec.rb4
-rw-r--r--spec/ruby/library/bigdecimal/core_spec.rb59
-rw-r--r--spec/ruby/library/bigdecimal/exponent_spec.rb11
-rw-r--r--spec/ruby/library/bigdecimal/remainder_spec.rb28
-rw-r--r--spec/ruby/library/bigdecimal/round_spec.rb12
-rw-r--r--spec/ruby/library/bigdecimal/shared/to_int.rb2
-rw-r--r--spec/ruby/library/bigdecimal/sqrt_spec.rb6
-rw-r--r--spec/ruby/library/bigdecimal/to_r_spec.rb12
-rw-r--r--spec/ruby/library/bigdecimal/to_s_spec.rb27
-rw-r--r--spec/ruby/library/bigdecimal/util_spec.rb6
-rw-r--r--spec/ruby/library/bigmath/log_spec.rb10
-rw-r--r--spec/ruby/library/cgi/cookie/name_spec.rb12
-rw-r--r--spec/ruby/library/cgi/cookie/parse_spec.rb10
-rw-r--r--spec/ruby/library/cgi/escapeURIComponent_spec.rb57
-rw-r--r--spec/ruby/library/cgi/initialize_spec.rb2
-rw-r--r--spec/ruby/library/cmath/math/acos_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/acosh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/asin_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/asinh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/atan2_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/atan_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/atanh_spec.rb20
-rw-r--r--spec/ruby/library/cmath/math/cos_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/cosh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/exp_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/fixtures/classes.rb4
-rw-r--r--spec/ruby/library/cmath/math/log10_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/log_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/shared/acos.rb41
-rw-r--r--spec/ruby/library/cmath/math/shared/acosh.rb37
-rw-r--r--spec/ruby/library/cmath/math/shared/asin.rb47
-rw-r--r--spec/ruby/library/cmath/math/shared/asinh.rb32
-rw-r--r--spec/ruby/library/cmath/math/shared/atan.rb32
-rw-r--r--spec/ruby/library/cmath/math/shared/atan2.rb34
-rw-r--r--spec/ruby/library/cmath/math/shared/atanh.rb30
-rw-r--r--spec/ruby/library/cmath/math/shared/cos.rb30
-rw-r--r--spec/ruby/library/cmath/math/shared/cosh.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/exp.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/log.rb39
-rw-r--r--spec/ruby/library/cmath/math/shared/log10.rb41
-rw-r--r--spec/ruby/library/cmath/math/shared/sin.rb30
-rw-r--r--spec/ruby/library/cmath/math/shared/sinh.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/sqrt.rb34
-rw-r--r--spec/ruby/library/cmath/math/shared/tan.rb28
-rw-r--r--spec/ruby/library/cmath/math/shared/tanh.rb32
-rw-r--r--spec/ruby/library/cmath/math/sin_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/sinh_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/sqrt_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/tan_spec.rb18
-rw-r--r--spec/ruby/library/cmath/math/tanh_spec.rb18
-rw-r--r--spec/ruby/library/conditionvariable/broadcast_spec.rb40
-rw-r--r--spec/ruby/library/conditionvariable/marshal_dump_spec.rb9
-rw-r--r--spec/ruby/library/conditionvariable/signal_spec.rb77
-rw-r--r--spec/ruby/library/conditionvariable/wait_spec.rb175
-rw-r--r--spec/ruby/library/coverage/result_spec.rb287
-rw-r--r--spec/ruby/library/coverage/running_spec.rb20
-rw-r--r--spec/ruby/library/coverage/start_spec.rb87
-rw-r--r--spec/ruby/library/coverage/supported_spec.rb32
-rw-r--r--spec/ruby/library/csv/generate_spec.rb2
-rw-r--r--spec/ruby/library/date/civil_spec.rb7
-rw-r--r--spec/ruby/library/date/deconstruct_keys_spec.rb44
-rw-r--r--spec/ruby/library/date/iso8601_spec.rb26
-rw-r--r--spec/ruby/library/date/new_spec.rb1
-rw-r--r--spec/ruby/library/date/parse_spec.rb12
-rw-r--r--spec/ruby/library/date/shared/new_bang.rb14
-rw-r--r--spec/ruby/library/date/shared/parse.rb4
-rw-r--r--spec/ruby/library/date/shared/parse_eu.rb8
-rw-r--r--spec/ruby/library/date/shared/parse_us.rb8
-rw-r--r--spec/ruby/library/date/shared/valid_jd.rb20
-rw-r--r--spec/ruby/library/date/strftime_spec.rb17
-rw-r--r--spec/ruby/library/datetime/deconstruct_keys_spec.rb46
-rw-r--r--spec/ruby/library/datetime/rfc2822_spec.rb4
-rw-r--r--spec/ruby/library/datetime/strftime_spec.rb17
-rw-r--r--spec/ruby/library/datetime/to_time_spec.rb18
-rw-r--r--spec/ruby/library/delegate/delegate_class/respond_to_missing_spec.rb1
-rw-r--r--spec/ruby/library/delegate/delegator/taint_spec.rb17
-rw-r--r--spec/ruby/library/delegate/delegator/trust_spec.rb16
-rw-r--r--spec/ruby/library/delegate/delegator/untaint_spec.rb18
-rw-r--r--spec/ruby/library/delegate/delegator/untrust_spec.rb17
-rw-r--r--spec/ruby/library/digest/instance/shared/update.rb2
-rw-r--r--spec/ruby/library/digest/md5/shared/sample.rb17
-rw-r--r--spec/ruby/library/drb/start_service_spec.rb47
-rw-r--r--spec/ruby/library/erb/fixtures/classes.rb6
-rw-r--r--spec/ruby/library/erb/new_spec.rb35
-rw-r--r--spec/ruby/library/erb/run_spec.rb2
-rw-r--r--spec/ruby/library/etc/confstr_spec.rb2
-rw-r--r--spec/ruby/library/etc/passwd_spec.rb2
-rw-r--r--spec/ruby/library/etc/sysconf_spec.rb2
-rw-r--r--spec/ruby/library/etc/sysconfdir_spec.rb2
-rw-r--r--spec/ruby/library/etc/systmpdir_spec.rb2
-rw-r--r--spec/ruby/library/etc/uname_spec.rb14
-rw-r--r--spec/ruby/library/expect/expect_spec.rb3
-rw-r--r--spec/ruby/library/fiber/current_spec.rb21
-rw-r--r--spec/ruby/library/fiber/resume_spec.rb23
-rw-r--r--spec/ruby/library/fiber/transfer_spec.rb56
-rw-r--r--spec/ruby/library/fiddle/handle/initialize_spec.rb10
-rw-r--r--spec/ruby/library/io-wait/fixtures/classes.rb12
-rw-r--r--spec/ruby/library/io-wait/wait_readable_spec.rb27
-rw-r--r--spec/ruby/library/io-wait/wait_spec.rb155
-rw-r--r--spec/ruby/library/io-wait/wait_writable_spec.rb20
-rw-r--r--spec/ruby/library/ipaddr/new_spec.rb47
-rw-r--r--spec/ruby/library/logger/device/close_spec.rb15
-rw-r--r--spec/ruby/library/logger/device/write_spec.rb15
-rw-r--r--spec/ruby/library/matrix/antisymmetric_spec.rb53
-rw-r--r--spec/ruby/library/matrix/exponent_spec.rb2
-rw-r--r--spec/ruby/library/matrix/multiply_spec.rb5
-rw-r--r--spec/ruby/library/matrix/unitary_spec.rb7
-rw-r--r--spec/ruby/library/monitor/enter_spec.rb28
-rw-r--r--spec/ruby/library/monitor/exit_spec.rb10
-rw-r--r--spec/ruby/library/monitor/new_cond_spec.rb88
-rw-r--r--spec/ruby/library/monitor/synchronize_spec.rb19
-rw-r--r--spec/ruby/library/monitor/try_enter_spec.rb39
-rw-r--r--spec/ruby/library/net-ftp/FTPError_spec.rb (renamed from spec/ruby/library/net/FTPError_spec.rb)0
-rw-r--r--spec/ruby/library/net-ftp/FTPPermError_spec.rb (renamed from spec/ruby/library/net/FTPPermError_spec.rb)0
-rw-r--r--spec/ruby/library/net-ftp/FTPProtoError_spec.rb (renamed from spec/ruby/library/net/FTPProtoError_spec.rb)0
-rw-r--r--spec/ruby/library/net-ftp/FTPReplyError_spec.rb (renamed from spec/ruby/library/net/FTPReplyError_spec.rb)0
-rw-r--r--spec/ruby/library/net-ftp/FTPTempError_spec.rb (renamed from spec/ruby/library/net/FTPTempError_spec.rb)0
-rw-r--r--spec/ruby/library/net-ftp/abort_spec.rb (renamed from spec/ruby/library/net/ftp/abort_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/acct_spec.rb (renamed from spec/ruby/library/net/ftp/acct_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/binary_spec.rb (renamed from spec/ruby/library/net/ftp/binary_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/chdir_spec.rb (renamed from spec/ruby/library/net/ftp/chdir_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/close_spec.rb (renamed from spec/ruby/library/net/ftp/close_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/closed_spec.rb (renamed from spec/ruby/library/net/ftp/closed_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/connect_spec.rb (renamed from spec/ruby/library/net/ftp/connect_spec.rb)12
-rw-r--r--spec/ruby/library/net-ftp/debug_mode_spec.rb (renamed from spec/ruby/library/net/ftp/debug_mode_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/default_passive_spec.rb (renamed from spec/ruby/library/net/ftp/default_passive_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/delete_spec.rb (renamed from spec/ruby/library/net/ftp/delete_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/dir_spec.rb (renamed from spec/ruby/library/net/ftp/dir_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/fixtures/default_passive.rb (renamed from spec/ruby/library/net/ftp/fixtures/default_passive.rb)0
-rw-r--r--spec/ruby/library/net-ftp/fixtures/passive.rb (renamed from spec/ruby/library/net/ftp/fixtures/passive.rb)0
-rw-r--r--spec/ruby/library/net-ftp/fixtures/putbinaryfile (renamed from spec/ruby/library/net/ftp/fixtures/putbinaryfile)0
-rw-r--r--spec/ruby/library/net-ftp/fixtures/puttextfile (renamed from spec/ruby/library/net/ftp/fixtures/puttextfile)0
-rw-r--r--spec/ruby/library/net-ftp/fixtures/server.rb (renamed from spec/ruby/library/net/ftp/fixtures/server.rb)0
-rw-r--r--spec/ruby/library/net-ftp/get_spec.rb (renamed from spec/ruby/library/net/ftp/get_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/getbinaryfile_spec.rb (renamed from spec/ruby/library/net/ftp/getbinaryfile_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/getdir_spec.rb (renamed from spec/ruby/library/net/ftp/getdir_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/gettextfile_spec.rb (renamed from spec/ruby/library/net/ftp/gettextfile_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/help_spec.rb (renamed from spec/ruby/library/net/ftp/help_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/initialize_spec.rb (renamed from spec/ruby/library/net/ftp/initialize_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/last_response_code_spec.rb (renamed from spec/ruby/library/net/ftp/last_response_code_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/last_response_spec.rb (renamed from spec/ruby/library/net/ftp/last_response_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/lastresp_spec.rb (renamed from spec/ruby/library/net/ftp/lastresp_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/list_spec.rb (renamed from spec/ruby/library/net/ftp/list_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/login_spec.rb (renamed from spec/ruby/library/net/ftp/login_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/ls_spec.rb (renamed from spec/ruby/library/net/ftp/ls_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/mdtm_spec.rb (renamed from spec/ruby/library/net/ftp/mdtm_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/mkdir_spec.rb (renamed from spec/ruby/library/net/ftp/mkdir_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/mtime_spec.rb (renamed from spec/ruby/library/net/ftp/mtime_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/nlst_spec.rb (renamed from spec/ruby/library/net/ftp/nlst_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/noop_spec.rb (renamed from spec/ruby/library/net/ftp/noop_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/open_spec.rb (renamed from spec/ruby/library/net/ftp/open_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/passive_spec.rb (renamed from spec/ruby/library/net/ftp/passive_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/put_spec.rb (renamed from spec/ruby/library/net/ftp/put_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/putbinaryfile_spec.rb (renamed from spec/ruby/library/net/ftp/putbinaryfile_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/puttextfile_spec.rb (renamed from spec/ruby/library/net/ftp/puttextfile_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/pwd_spec.rb (renamed from spec/ruby/library/net/ftp/pwd_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/quit_spec.rb (renamed from spec/ruby/library/net/ftp/quit_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/rename_spec.rb (renamed from spec/ruby/library/net/ftp/rename_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/resume_spec.rb (renamed from spec/ruby/library/net/ftp/resume_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/retrbinary_spec.rb (renamed from spec/ruby/library/net/ftp/retrbinary_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/retrlines_spec.rb (renamed from spec/ruby/library/net/ftp/retrlines_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/return_code_spec.rb (renamed from spec/ruby/library/net/ftp/return_code_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/rmdir_spec.rb (renamed from spec/ruby/library/net/ftp/rmdir_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/sendcmd_spec.rb (renamed from spec/ruby/library/net/ftp/sendcmd_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/set_socket_spec.rb (renamed from spec/ruby/library/net/ftp/set_socket_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/shared/getbinaryfile.rb (renamed from spec/ruby/library/net/ftp/shared/getbinaryfile.rb)4
-rw-r--r--spec/ruby/library/net-ftp/shared/gettextfile.rb (renamed from spec/ruby/library/net/ftp/shared/gettextfile.rb)2
-rw-r--r--spec/ruby/library/net-ftp/shared/last_response_code.rb (renamed from spec/ruby/library/net/ftp/shared/last_response_code.rb)0
-rw-r--r--spec/ruby/library/net-ftp/shared/list.rb (renamed from spec/ruby/library/net/ftp/shared/list.rb)0
-rw-r--r--spec/ruby/library/net-ftp/shared/putbinaryfile.rb (renamed from spec/ruby/library/net/ftp/shared/putbinaryfile.rb)4
-rw-r--r--spec/ruby/library/net-ftp/shared/puttextfile.rb (renamed from spec/ruby/library/net/ftp/shared/puttextfile.rb)6
-rw-r--r--spec/ruby/library/net-ftp/shared/pwd.rb (renamed from spec/ruby/library/net/ftp/shared/pwd.rb)0
-rw-r--r--spec/ruby/library/net-ftp/site_spec.rb (renamed from spec/ruby/library/net/ftp/site_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/size_spec.rb (renamed from spec/ruby/library/net/ftp/size_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/spec_helper.rb (renamed from spec/ruby/library/net/ftp/spec_helper.rb)0
-rw-r--r--spec/ruby/library/net-ftp/status_spec.rb (renamed from spec/ruby/library/net/ftp/status_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/storbinary_spec.rb (renamed from spec/ruby/library/net/ftp/storbinary_spec.rb)5
-rw-r--r--spec/ruby/library/net-ftp/storlines_spec.rb (renamed from spec/ruby/library/net/ftp/storlines_spec.rb)5
-rw-r--r--spec/ruby/library/net-ftp/system_spec.rb (renamed from spec/ruby/library/net/ftp/system_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/voidcmd_spec.rb (renamed from spec/ruby/library/net/ftp/voidcmd_spec.rb)2
-rw-r--r--spec/ruby/library/net-ftp/welcome_spec.rb (renamed from spec/ruby/library/net/ftp/welcome_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/HTTPBadResponse_spec.rb (renamed from spec/ruby/library/net/http/HTTPBadResponse_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/HTTPClientExcepton_spec.rb12
-rw-r--r--spec/ruby/library/net-http/HTTPError_spec.rb (renamed from spec/ruby/library/net/http/HTTPError_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/HTTPFatalError_spec.rb (renamed from spec/ruby/library/net/http/HTTPFatalError_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/HTTPHeaderSyntaxError_spec.rb (renamed from spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/HTTPRetriableError_spec.rb (renamed from spec/ruby/library/net/http/HTTPRetriableError_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/HTTPServerException_spec.rb12
-rw-r--r--spec/ruby/library/net-http/http/Proxy_spec.rb (renamed from spec/ruby/library/net/http/http/Proxy_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/active_spec.rb (renamed from spec/ruby/library/net/http/http/active_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/address_spec.rb (renamed from spec/ruby/library/net/http/http/address_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/close_on_empty_response_spec.rb (renamed from spec/ruby/library/net/http/http/close_on_empty_response_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/copy_spec.rb (renamed from spec/ruby/library/net/http/http/copy_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/default_port_spec.rb (renamed from spec/ruby/library/net/http/http/default_port_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/delete_spec.rb (renamed from spec/ruby/library/net/http/http/delete_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/finish_spec.rb (renamed from spec/ruby/library/net/http/http/finish_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/fixtures/http_server.rb123
-rw-r--r--spec/ruby/library/net-http/http/get2_spec.rb (renamed from spec/ruby/library/net/http/http/get2_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/get_print_spec.rb (renamed from spec/ruby/library/net/http/http/get_print_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/get_response_spec.rb (renamed from spec/ruby/library/net/http/http/get_response_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/get_spec.rb (renamed from spec/ruby/library/net/http/http/get_spec.rb)19
-rw-r--r--spec/ruby/library/net-http/http/head2_spec.rb (renamed from spec/ruby/library/net/http/http/head2_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/head_spec.rb (renamed from spec/ruby/library/net/http/http/head_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/http_default_port_spec.rb (renamed from spec/ruby/library/net/http/http/http_default_port_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/https_default_port_spec.rb (renamed from spec/ruby/library/net/http/http/https_default_port_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/initialize_spec.rb (renamed from spec/ruby/library/net/http/http/initialize_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/inspect_spec.rb (renamed from spec/ruby/library/net/http/http/inspect_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/is_version_1_1_spec.rb (renamed from spec/ruby/library/net/http/http/is_version_1_1_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/is_version_1_2_spec.rb (renamed from spec/ruby/library/net/http/http/is_version_1_2_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/lock_spec.rb (renamed from spec/ruby/library/net/http/http/lock_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/mkcol_spec.rb (renamed from spec/ruby/library/net/http/http/mkcol_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/move_spec.rb (renamed from spec/ruby/library/net/http/http/move_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/new_spec.rb (renamed from spec/ruby/library/net/http/http/new_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/newobj_spec.rb (renamed from spec/ruby/library/net/http/http/newobj_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/open_timeout_spec.rb (renamed from spec/ruby/library/net/http/http/open_timeout_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/options_spec.rb (renamed from spec/ruby/library/net/http/http/options_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/port_spec.rb (renamed from spec/ruby/library/net/http/http/port_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/post2_spec.rb (renamed from spec/ruby/library/net/http/http/post2_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/post_form_spec.rb (renamed from spec/ruby/library/net/http/http/post_form_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/post_spec.rb (renamed from spec/ruby/library/net/http/http/post_spec.rb)6
-rw-r--r--spec/ruby/library/net-http/http/propfind_spec.rb (renamed from spec/ruby/library/net/http/http/propfind_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/proppatch_spec.rb (renamed from spec/ruby/library/net/http/http/proppatch_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/proxy_address_spec.rb (renamed from spec/ruby/library/net/http/http/proxy_address_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/proxy_class_spec.rb (renamed from spec/ruby/library/net/http/http/proxy_class_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/proxy_pass_spec.rb (renamed from spec/ruby/library/net/http/http/proxy_pass_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/proxy_port_spec.rb (renamed from spec/ruby/library/net/http/http/proxy_port_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/proxy_user_spec.rb (renamed from spec/ruby/library/net/http/http/proxy_user_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/put2_spec.rb (renamed from spec/ruby/library/net/http/http/put2_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/put_spec.rb (renamed from spec/ruby/library/net/http/http/put_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/read_timeout_spec.rb (renamed from spec/ruby/library/net/http/http/read_timeout_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/request_get_spec.rb (renamed from spec/ruby/library/net/http/http/request_get_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/request_head_spec.rb (renamed from spec/ruby/library/net/http/http/request_head_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/request_post_spec.rb (renamed from spec/ruby/library/net/http/http/request_post_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/request_put_spec.rb (renamed from spec/ruby/library/net/http/http/request_put_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/request_spec.rb (renamed from spec/ruby/library/net/http/http/request_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/request_types_spec.rb (renamed from spec/ruby/library/net/http/http/request_types_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/send_request_spec.rb (renamed from spec/ruby/library/net/http/http/send_request_spec.rb)4
-rw-r--r--spec/ruby/library/net-http/http/set_debug_output_spec.rb (renamed from spec/ruby/library/net/http/http/set_debug_output_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/shared/request_get.rb (renamed from spec/ruby/library/net/http/http/shared/request_get.rb)0
-rw-r--r--spec/ruby/library/net-http/http/shared/request_head.rb (renamed from spec/ruby/library/net/http/http/shared/request_head.rb)0
-rw-r--r--spec/ruby/library/net-http/http/shared/request_post.rb (renamed from spec/ruby/library/net/http/http/shared/request_post.rb)0
-rw-r--r--spec/ruby/library/net-http/http/shared/request_put.rb (renamed from spec/ruby/library/net/http/http/shared/request_put.rb)0
-rw-r--r--spec/ruby/library/net-http/http/shared/started.rb (renamed from spec/ruby/library/net/http/http/shared/started.rb)0
-rw-r--r--spec/ruby/library/net-http/http/shared/version_1_1.rb (renamed from spec/ruby/library/net/http/http/shared/version_1_1.rb)0
-rw-r--r--spec/ruby/library/net-http/http/shared/version_1_2.rb (renamed from spec/ruby/library/net/http/http/shared/version_1_2.rb)0
-rw-r--r--spec/ruby/library/net-http/http/socket_type_spec.rb (renamed from spec/ruby/library/net/http/http/socket_type_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/start_spec.rb (renamed from spec/ruby/library/net/http/http/start_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/started_spec.rb (renamed from spec/ruby/library/net/http/http/started_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/trace_spec.rb (renamed from spec/ruby/library/net/http/http/trace_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/unlock_spec.rb (renamed from spec/ruby/library/net/http/http/unlock_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/use_ssl_spec.rb (renamed from spec/ruby/library/net/http/http/use_ssl_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/version_1_1_spec.rb (renamed from spec/ruby/library/net/http/http/version_1_1_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/http/version_1_2_spec.rb (renamed from spec/ruby/library/net/http/http/version_1_2_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpexceptions/fixtures/classes.rb (renamed from spec/ruby/library/net/http/httpexceptions/fixtures/classes.rb)0
-rw-r--r--spec/ruby/library/net-http/httpexceptions/initialize_spec.rb (renamed from spec/ruby/library/net/http/httpexceptions/initialize_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpexceptions/response_spec.rb (renamed from spec/ruby/library/net/http/httpexceptions/response_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/body_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/body_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb)4
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/inspect_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/method_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/method_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/path_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/path_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/request_body_permitted_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/response_body_permitted_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpgenericrequest/set_body_internal_spec.rb (renamed from spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/add_field_spec.rb (renamed from spec/ruby/library/net/http/httpheader/add_field_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/basic_auth_spec.rb (renamed from spec/ruby/library/net/http/httpheader/basic_auth_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/canonical_each_spec.rb (renamed from spec/ruby/library/net/http/httpheader/canonical_each_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/chunked_spec.rb (renamed from spec/ruby/library/net/http/httpheader/chunked_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/content_length_spec.rb (renamed from spec/ruby/library/net/http/httpheader/content_length_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/content_range_spec.rb (renamed from spec/ruby/library/net/http/httpheader/content_range_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/content_type_spec.rb (renamed from spec/ruby/library/net/http/httpheader/content_type_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/delete_spec.rb (renamed from spec/ruby/library/net/http/httpheader/delete_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/each_capitalized_name_spec.rb (renamed from spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/each_capitalized_spec.rb (renamed from spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/each_header_spec.rb (renamed from spec/ruby/library/net/http/httpheader/each_header_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/each_key_spec.rb (renamed from spec/ruby/library/net/http/httpheader/each_key_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/each_name_spec.rb (renamed from spec/ruby/library/net/http/httpheader/each_name_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/each_spec.rb (renamed from spec/ruby/library/net/http/httpheader/each_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/each_value_spec.rb (renamed from spec/ruby/library/net/http/httpheader/each_value_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/element_reference_spec.rb (renamed from spec/ruby/library/net/http/httpheader/element_reference_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/element_set_spec.rb (renamed from spec/ruby/library/net/http/httpheader/element_set_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/fetch_spec.rb (renamed from spec/ruby/library/net/http/httpheader/fetch_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/fixtures/classes.rb (renamed from spec/ruby/library/net/http/httpheader/fixtures/classes.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/form_data_spec.rb (renamed from spec/ruby/library/net/http/httpheader/form_data_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/get_fields_spec.rb (renamed from spec/ruby/library/net/http/httpheader/get_fields_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/initialize_http_header_spec.rb (renamed from spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/key_spec.rb (renamed from spec/ruby/library/net/http/httpheader/key_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/length_spec.rb (renamed from spec/ruby/library/net/http/httpheader/length_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/main_type_spec.rb (renamed from spec/ruby/library/net/http/httpheader/main_type_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/proxy_basic_auth_spec.rb (renamed from spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/range_length_spec.rb (renamed from spec/ruby/library/net/http/httpheader/range_length_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/range_spec.rb (renamed from spec/ruby/library/net/http/httpheader/range_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/set_content_type_spec.rb (renamed from spec/ruby/library/net/http/httpheader/set_content_type_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/set_form_data_spec.rb (renamed from spec/ruby/library/net/http/httpheader/set_form_data_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/set_range_spec.rb (renamed from spec/ruby/library/net/http/httpheader/set_range_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/each_capitalized.rb (renamed from spec/ruby/library/net/http/httpheader/shared/each_capitalized.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/each_header.rb (renamed from spec/ruby/library/net/http/httpheader/shared/each_header.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/each_name.rb (renamed from spec/ruby/library/net/http/httpheader/shared/each_name.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/set_content_type.rb (renamed from spec/ruby/library/net/http/httpheader/shared/set_content_type.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/set_form_data.rb (renamed from spec/ruby/library/net/http/httpheader/shared/set_form_data.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/set_range.rb (renamed from spec/ruby/library/net/http/httpheader/shared/set_range.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/shared/size.rb (renamed from spec/ruby/library/net/http/httpheader/shared/size.rb)0
-rw-r--r--spec/ruby/library/net-http/httpheader/size_spec.rb (renamed from spec/ruby/library/net/http/httpheader/size_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/sub_type_spec.rb (renamed from spec/ruby/library/net/http/httpheader/sub_type_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/to_hash_spec.rb (renamed from spec/ruby/library/net/http/httpheader/to_hash_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpheader/type_params_spec.rb (renamed from spec/ruby/library/net/http/httpheader/type_params_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httprequest/initialize_spec.rb (renamed from spec/ruby/library/net/http/httprequest/initialize_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/body_permitted_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/body_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/body_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/code_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/code_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/code_type_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/code_type_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/entity_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/entity_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/error_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/error_spec.rb)9
-rw-r--r--spec/ruby/library/net-http/httpresponse/error_type_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/error_type_spec.rb)9
-rw-r--r--spec/ruby/library/net-http/httpresponse/exception_type_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/exception_type_spec.rb)9
-rw-r--r--spec/ruby/library/net-http/httpresponse/header_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/header_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/http_version_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/http_version_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/initialize_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/initialize_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/inspect_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/inspect_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/message_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/message_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/msg_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/msg_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/read_body_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/read_body_spec.rb)15
-rw-r--r--spec/ruby/library/net-http/httpresponse/read_header_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/read_header_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/read_new_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/read_new_spec.rb)3
-rw-r--r--spec/ruby/library/net-http/httpresponse/reading_body_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/reading_body_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/response_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/response_spec.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/shared/body.rb (renamed from spec/ruby/library/net/http/httpresponse/shared/body.rb)2
-rw-r--r--spec/ruby/library/net-http/httpresponse/value_spec.rb (renamed from spec/ruby/library/net/http/httpresponse/value_spec.rb)9
-rw-r--r--spec/ruby/library/net/http/HTTPClientExcepton_spec.rb14
-rw-r--r--spec/ruby/library/net/http/HTTPServerException_spec.rb26
-rw-r--r--spec/ruby/library/net/http/http/fixtures/http_server.rb109
-rw-r--r--spec/ruby/library/objectspace/dump_all_spec.rb112
-rw-r--r--spec/ruby/library/objectspace/dump_spec.rb70
-rw-r--r--spec/ruby/library/objectspace/fixtures/trace.rb6
-rw-r--r--spec/ruby/library/objectspace/memsize_of_all_spec.rb22
-rw-r--r--spec/ruby/library/objectspace/memsize_of_spec.rb2
-rw-r--r--spec/ruby/library/objectspace/reachable_objects_from_spec.rb2
-rw-r--r--spec/ruby/library/objectspace/trace_object_allocations_spec.rb149
-rw-r--r--spec/ruby/library/objectspace/trace_spec.rb15
-rw-r--r--spec/ruby/library/openssl/config/freeze_spec.rb22
-rw-r--r--spec/ruby/library/openssl/digest/append_spec.rb6
-rw-r--r--spec/ruby/library/openssl/digest/block_length_spec.rb44
-rw-r--r--spec/ruby/library/openssl/digest/digest_length_spec.rb44
-rw-r--r--spec/ruby/library/openssl/digest/digest_spec.rb (renamed from spec/ruby/library/openssl/digest_spec.rb)13
-rw-r--r--spec/ruby/library/openssl/digest/initialize_spec.rb141
-rw-r--r--spec/ruby/library/openssl/digest/name_spec.rb16
-rw-r--r--spec/ruby/library/openssl/digest/reset_spec.rb36
-rw-r--r--spec/ruby/library/openssl/digest/shared/update.rb123
-rw-r--r--spec/ruby/library/openssl/digest/update_spec.rb6
-rw-r--r--spec/ruby/library/openssl/fixed_length_secure_compare_spec.rb42
-rw-r--r--spec/ruby/library/openssl/kdf/pbkdf2_hmac_spec.rb168
-rw-r--r--spec/ruby/library/openssl/kdf/scrypt_spec.rb209
-rw-r--r--spec/ruby/library/openssl/random/shared/random_bytes.rb2
-rw-r--r--spec/ruby/library/openssl/secure_compare_spec.rb38
-rw-r--r--spec/ruby/library/openssl/x509/store/verify_spec.rb78
-rw-r--r--spec/ruby/library/openstruct/method_missing_spec.rb8
-rw-r--r--spec/ruby/library/openstruct/to_h_spec.rb60
-rw-r--r--spec/ruby/library/pathname/birthtime_spec.rb16
-rw-r--r--spec/ruby/library/pathname/glob_spec.rb53
-rw-r--r--spec/ruby/library/pathname/new_spec.rb7
-rw-r--r--spec/ruby/library/pathname/pathname_spec.rb19
-rw-r--r--spec/ruby/library/pathname/relative_path_from_spec.rb4
-rw-r--r--spec/ruby/library/pp/pp_spec.rb7
-rw-r--r--spec/ruby/library/rbconfig/rbconfig_spec.rb19
-rw-r--r--spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb19
-rw-r--r--spec/ruby/library/rbconfig/unicode_version_spec.rb25
-rw-r--r--spec/ruby/library/readline/history/delete_at_spec.rb9
-rw-r--r--spec/ruby/library/readline/history/each_spec.rb8
-rw-r--r--spec/ruby/library/readline/history/element_reference_spec.rb7
-rw-r--r--spec/ruby/library/readline/history/pop_spec.rb9
-rw-r--r--spec/ruby/library/readline/history/shift_spec.rb9
-rw-r--r--spec/ruby/library/readline/readline_spec.rb7
-rw-r--r--spec/ruby/library/rexml/attribute/clone_spec.rb14
-rw-r--r--spec/ruby/library/rexml/attribute/element_spec.rb26
-rw-r--r--spec/ruby/library/rexml/attribute/equal_value_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/hash_spec.rb16
-rw-r--r--spec/ruby/library/rexml/attribute/initialize_spec.rb32
-rw-r--r--spec/ruby/library/rexml/attribute/inspect_spec.rb22
-rw-r--r--spec/ruby/library/rexml/attribute/namespace_spec.rb27
-rw-r--r--spec/ruby/library/rexml/attribute/node_type_spec.rb13
-rw-r--r--spec/ruby/library/rexml/attribute/prefix_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/remove_spec.rb23
-rw-r--r--spec/ruby/library/rexml/attribute/to_s_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/to_string_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/value_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/write_spec.rb26
-rw-r--r--spec/ruby/library/rexml/attribute/xpath_spec.rb22
-rw-r--r--spec/ruby/library/rexml/attributes/add_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/append_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/delete_all_spec.rb34
-rw-r--r--spec/ruby/library/rexml/attributes/delete_spec.rb30
-rw-r--r--spec/ruby/library/rexml/attributes/each_attribute_spec.rb25
-rw-r--r--spec/ruby/library/rexml/attributes/each_spec.rb26
-rw-r--r--spec/ruby/library/rexml/attributes/element_reference_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attributes/element_set_spec.rb28
-rw-r--r--spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attributes/get_attribute_spec.rb32
-rw-r--r--spec/ruby/library/rexml/attributes/initialize_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attributes/length_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/namespaces_spec.rb9
-rw-r--r--spec/ruby/library/rexml/attributes/prefixes_spec.rb27
-rw-r--r--spec/ruby/library/rexml/attributes/shared/add.rb17
-rw-r--r--spec/ruby/library/rexml/attributes/shared/length.rb13
-rw-r--r--spec/ruby/library/rexml/attributes/size_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/to_a_spec.rb22
-rw-r--r--spec/ruby/library/rexml/cdata/clone_spec.rb13
-rw-r--r--spec/ruby/library/rexml/cdata/initialize_spec.rb27
-rw-r--r--spec/ruby/library/rexml/cdata/shared/to_s.rb11
-rw-r--r--spec/ruby/library/rexml/cdata/to_s_spec.rb10
-rw-r--r--spec/ruby/library/rexml/cdata/value_spec.rb10
-rw-r--r--spec/ruby/library/rexml/document/add_element_spec.rb34
-rw-r--r--spec/ruby/library/rexml/document/add_spec.rb60
-rw-r--r--spec/ruby/library/rexml/document/clone_spec.rb23
-rw-r--r--spec/ruby/library/rexml/document/doctype_spec.rb18
-rw-r--r--spec/ruby/library/rexml/document/encoding_spec.rb25
-rw-r--r--spec/ruby/library/rexml/document/expanded_name_spec.rb19
-rw-r--r--spec/ruby/library/rexml/document/new_spec.rb39
-rw-r--r--spec/ruby/library/rexml/document/node_type_spec.rb11
-rw-r--r--spec/ruby/library/rexml/document/root_spec.rb15
-rw-r--r--spec/ruby/library/rexml/document/stand_alone_spec.rb22
-rw-r--r--spec/ruby/library/rexml/document/version_spec.rb17
-rw-r--r--spec/ruby/library/rexml/document/write_spec.rb38
-rw-r--r--spec/ruby/library/rexml/document/xml_decl_spec.rb18
-rw-r--r--spec/ruby/library/rexml/element/add_attribute_spec.rb44
-rw-r--r--spec/ruby/library/rexml/element/add_attributes_spec.rb25
-rw-r--r--spec/ruby/library/rexml/element/add_element_spec.rb41
-rw-r--r--spec/ruby/library/rexml/element/add_namespace_spec.rb26
-rw-r--r--spec/ruby/library/rexml/element/add_text_spec.rb27
-rw-r--r--spec/ruby/library/rexml/element/attribute_spec.rb20
-rw-r--r--spec/ruby/library/rexml/element/attributes_spec.rb22
-rw-r--r--spec/ruby/library/rexml/element/cdatas_spec.rb27
-rw-r--r--spec/ruby/library/rexml/element/clone_spec.rb32
-rw-r--r--spec/ruby/library/rexml/element/comments_spec.rb23
-rw-r--r--spec/ruby/library/rexml/element/delete_attribute_spec.rb42
-rw-r--r--spec/ruby/library/rexml/element/delete_element_spec.rb52
-rw-r--r--spec/ruby/library/rexml/element/delete_namespace_spec.rb28
-rw-r--r--spec/ruby/library/rexml/element/document_spec.rb19
-rw-r--r--spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb38
-rw-r--r--spec/ruby/library/rexml/element/each_element_with_text_spec.rb34
-rw-r--r--spec/ruby/library/rexml/element/element_reference_spec.rb23
-rw-r--r--spec/ruby/library/rexml/element/get_text_spec.rb21
-rw-r--r--spec/ruby/library/rexml/element/has_attributes_spec.rb20
-rw-r--r--spec/ruby/library/rexml/element/has_elements_spec.rb21
-rw-r--r--spec/ruby/library/rexml/element/has_text_spec.rb19
-rw-r--r--spec/ruby/library/rexml/element/inspect_spec.rb30
-rw-r--r--spec/ruby/library/rexml/element/instructions_spec.rb24
-rw-r--r--spec/ruby/library/rexml/element/namespace_spec.rb30
-rw-r--r--spec/ruby/library/rexml/element/namespaces_spec.rb35
-rw-r--r--spec/ruby/library/rexml/element/new_spec.rb38
-rw-r--r--spec/ruby/library/rexml/element/next_element_spec.rb22
-rw-r--r--spec/ruby/library/rexml/element/node_type_spec.rb11
-rw-r--r--spec/ruby/library/rexml/element/prefixes_spec.rb26
-rw-r--r--spec/ruby/library/rexml/element/previous_element_spec.rb23
-rw-r--r--spec/ruby/library/rexml/element/raw_spec.rb27
-rw-r--r--spec/ruby/library/rexml/element/root_spec.rb31
-rw-r--r--spec/ruby/library/rexml/element/text_spec.rb49
-rw-r--r--spec/ruby/library/rexml/element/texts_spec.rb19
-rw-r--r--spec/ruby/library/rexml/element/whitespace_spec.rb26
-rw-r--r--spec/ruby/library/rexml/node/each_recursive_spec.rb24
-rw-r--r--spec/ruby/library/rexml/node/find_first_recursive_spec.rb28
-rw-r--r--spec/ruby/library/rexml/node/index_in_parent_spec.rb18
-rw-r--r--spec/ruby/library/rexml/node/next_sibling_node_spec.rb24
-rw-r--r--spec/ruby/library/rexml/node/parent_spec.rb23
-rw-r--r--spec/ruby/library/rexml/node/previous_sibling_node_spec.rb24
-rw-r--r--spec/ruby/library/rexml/shared/each_element.rb36
-rw-r--r--spec/ruby/library/rexml/shared/elements_to_a.rb34
-rw-r--r--spec/ruby/library/rexml/text/append_spec.rb13
-rw-r--r--spec/ruby/library/rexml/text/clone_spec.rb13
-rw-r--r--spec/ruby/library/rexml/text/comparison_spec.rb28
-rw-r--r--spec/ruby/library/rexml/text/empty_spec.rb15
-rw-r--r--spec/ruby/library/rexml/text/indent_text_spec.rb26
-rw-r--r--spec/ruby/library/rexml/text/inspect_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/new_spec.rb51
-rw-r--r--spec/ruby/library/rexml/text/node_type_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/normalize_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/read_with_substitution_spec.rb15
-rw-r--r--spec/ruby/library/rexml/text/to_s_spec.rb20
-rw-r--r--spec/ruby/library/rexml/text/unnormalize_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/value_spec.rb40
-rw-r--r--spec/ruby/library/rexml/text/wrap_spec.rb23
-rw-r--r--spec/ruby/library/rexml/text/write_with_substitution_spec.rb36
-rw-r--r--spec/ruby/library/rubygems/gem/load_path_insert_index_spec.rb10
-rw-r--r--spec/ruby/library/scanf/io/block_scanf_spec.rb10
-rw-r--r--spec/ruby/library/scanf/io/fixtures/date.txt4
-rw-r--r--spec/ruby/library/scanf/io/fixtures/helloworld.txt1
-rw-r--r--spec/ruby/library/scanf/io/scanf_spec.rb38
-rw-r--r--spec/ruby/library/scanf/io/shared/block_scanf.rb28
-rw-r--r--spec/ruby/library/scanf/string/block_scanf_spec.rb10
-rw-r--r--spec/ruby/library/scanf/string/scanf_spec.rb56
-rw-r--r--spec/ruby/library/scanf/string/shared/block_scanf.rb25
-rw-r--r--spec/ruby/library/set/compare_by_identity_spec.rb2
-rw-r--r--spec/ruby/library/set/comparison_spec.rb27
-rw-r--r--spec/ruby/library/set/divide_spec.rb35
-rw-r--r--spec/ruby/library/set/each_spec.rb1
-rw-r--r--spec/ruby/library/set/enumerable/to_set_spec.rb8
-rw-r--r--spec/ruby/library/set/filter_spec.rb6
-rw-r--r--spec/ruby/library/set/flatten_spec.rb9
-rw-r--r--spec/ruby/library/set/initialize_clone_spec.rb16
-rw-r--r--spec/ruby/library/set/join_spec.rb29
-rw-r--r--spec/ruby/library/set/pretty_print_spec.rb20
-rw-r--r--spec/ruby/library/set/proper_subset_spec.rb9
-rw-r--r--spec/ruby/library/set/set_spec.rb12
-rw-r--r--spec/ruby/library/set/shared/inspect.rb20
-rw-r--r--spec/ruby/library/set/sortedset/add_spec.rb42
-rw-r--r--spec/ruby/library/set/sortedset/append_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/case_equality_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/classify_spec.rb30
-rw-r--r--spec/ruby/library/set/sortedset/clear_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/collect_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/constructor_spec.rb18
-rw-r--r--spec/ruby/library/set/sortedset/delete_if_spec.rb41
-rw-r--r--spec/ruby/library/set/sortedset/delete_spec.rb40
-rw-r--r--spec/ruby/library/set/sortedset/difference_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/divide_spec.rb37
-rw-r--r--spec/ruby/library/set/sortedset/each_spec.rb29
-rw-r--r--spec/ruby/library/set/sortedset/empty_spec.rb13
-rw-r--r--spec/ruby/library/set/sortedset/eql_spec.rb19
-rw-r--r--spec/ruby/library/set/sortedset/equal_value_spec.rb16
-rw-r--r--spec/ruby/library/set/sortedset/exclusion_spec.rb21
-rw-r--r--spec/ruby/library/set/sortedset/filter_spec.rb12
-rw-r--r--spec/ruby/library/set/sortedset/flatten_merge_spec.rb11
-rw-r--r--spec/ruby/library/set/sortedset/flatten_spec.rb47
-rw-r--r--spec/ruby/library/set/sortedset/hash_spec.rb16
-rw-r--r--spec/ruby/library/set/sortedset/include_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/initialize_spec.rb33
-rw-r--r--spec/ruby/library/set/sortedset/inspect_spec.rb13
-rw-r--r--spec/ruby/library/set/sortedset/intersection_spec.rb14
-rw-r--r--spec/ruby/library/set/sortedset/keep_if_spec.rb34
-rw-r--r--spec/ruby/library/set/sortedset/length_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/map_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/member_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/merge_spec.rb22
-rw-r--r--spec/ruby/library/set/sortedset/minus_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/plus_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb13
-rw-r--r--spec/ruby/library/set/sortedset/pretty_print_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/proper_subset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/proper_superset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/reject_spec.rb45
-rw-r--r--spec/ruby/library/set/sortedset/replace_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/select_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/shared/add.rb14
-rw-r--r--spec/ruby/library/set/sortedset/shared/collect.rb20
-rw-r--r--spec/ruby/library/set/sortedset/shared/difference.rb15
-rw-r--r--spec/ruby/library/set/sortedset/shared/include.rb7
-rw-r--r--spec/ruby/library/set/sortedset/shared/intersection.rb15
-rw-r--r--spec/ruby/library/set/sortedset/shared/length.rb6
-rw-r--r--spec/ruby/library/set/sortedset/shared/select.rb35
-rw-r--r--spec/ruby/library/set/sortedset/shared/union.rb15
-rw-r--r--spec/ruby/library/set/sortedset/size_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/sortedset_spec.rb12
-rw-r--r--spec/ruby/library/set/sortedset/subset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/subtract_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/superset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/to_a_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/union_spec.rb14
-rw-r--r--spec/ruby/library/set/subset_spec.rb9
-rw-r--r--spec/ruby/library/set/to_s_spec.rb1
-rw-r--r--spec/ruby/library/shellwords/shellwords_spec.rb15
-rw-r--r--spec/ruby/library/socket/addrinfo/initialize_spec.rb2
-rw-r--r--spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb4
-rw-r--r--spec/ruby/library/socket/basicsocket/local_address_spec.rb10
-rw-r--r--spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb32
-rw-r--r--spec/ruby/library/socket/basicsocket/read_spec.rb47
-rw-r--r--spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb23
-rw-r--r--spec/ruby/library/socket/basicsocket/recv_spec.rb21
-rw-r--r--spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb15
-rw-r--r--spec/ruby/library/socket/basicsocket/remote_address_spec.rb10
-rw-r--r--spec/ruby/library/socket/basicsocket/send_spec.rb8
-rw-r--r--spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb7
-rw-r--r--spec/ruby/library/socket/basicsocket/shutdown_spec.rb20
-rw-r--r--spec/ruby/library/socket/fixtures/classes.rb6
-rw-r--r--spec/ruby/library/socket/ipsocket/getaddress_spec.rb2
-rw-r--r--spec/ruby/library/socket/shared/address.rb249
-rw-r--r--spec/ruby/library/socket/shared/pack_sockaddr.rb10
-rw-r--r--spec/ruby/library/socket/shared/partially_closable_sockets.rb2
-rw-r--r--spec/ruby/library/socket/socket/accept_nonblock_spec.rb3
-rw-r--r--spec/ruby/library/socket/socket/bind_spec.rb4
-rw-r--r--spec/ruby/library/socket/socket/getnameinfo_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/new_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/pair_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/socketpair_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpserver/accept_spec.rb15
-rw-r--r--spec/ruby/library/socket/tcpserver/new_spec.rb6
-rw-r--r--spec/ruby/library/socket/tcpsocket/initialize_spec.rb39
-rw-r--r--spec/ruby/library/socket/tcpsocket/new_spec.rb5
-rw-r--r--spec/ruby/library/socket/tcpsocket/open_spec.rb1
-rw-r--r--spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpsocket/shared/new.rb27
-rw-r--r--spec/ruby/library/socket/udpsocket/initialize_spec.rb13
-rw-r--r--spec/ruby/library/socket/udpsocket/new_spec.rb6
-rw-r--r--spec/ruby/library/socket/udpsocket/send_spec.rb2
-rw-r--r--spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixserver/accept_spec.rb13
-rw-r--r--spec/ruby/library/socket/unixserver/for_fd_spec.rb4
-rw-r--r--spec/ruby/library/socket/unixserver/new_spec.rb12
-rw-r--r--spec/ruby/library/socket/unixserver/open_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixserver/shared/new.rb26
-rw-r--r--spec/ruby/library/socket/unixsocket/addr_spec.rb5
-rw-r--r--spec/ruby/library/socket/unixsocket/initialize_spec.rb10
-rw-r--r--spec/ruby/library/socket/unixsocket/inspect_spec.rb4
-rw-r--r--spec/ruby/library/socket/unixsocket/local_address_spec.rb2
-rw-r--r--spec/ruby/library/socket/unixsocket/new_spec.rb12
-rw-r--r--spec/ruby/library/socket/unixsocket/open_spec.rb10
-rw-r--r--spec/ruby/library/socket/unixsocket/pair_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixsocket/partially_closable_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixsocket/path_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixsocket/peeraddr_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixsocket/recv_io_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixsocket/recvfrom_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixsocket/send_io_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixsocket/shared/new.rb28
-rw-r--r--spec/ruby/library/stringio/append_spec.rb22
-rw-r--r--spec/ruby/library/stringio/binmode_spec.rb2
-rw-r--r--spec/ruby/library/stringio/bytes_spec.rb29
-rw-r--r--spec/ruby/library/stringio/chars_spec.rb29
-rw-r--r--spec/ruby/library/stringio/close_read_spec.rb4
-rw-r--r--spec/ruby/library/stringio/close_write_spec.rb6
-rw-r--r--spec/ruby/library/stringio/closed_read_spec.rb2
-rw-r--r--spec/ruby/library/stringio/closed_spec.rb4
-rw-r--r--spec/ruby/library/stringio/closed_write_spec.rb2
-rw-r--r--spec/ruby/library/stringio/codepoints_spec.rb19
-rw-r--r--spec/ruby/library/stringio/each_line_spec.rb4
-rw-r--r--spec/ruby/library/stringio/each_spec.rb8
-rw-r--r--spec/ruby/library/stringio/flush_spec.rb2
-rw-r--r--spec/ruby/library/stringio/fsync_spec.rb2
-rw-r--r--spec/ruby/library/stringio/gets_spec.rb6
-rw-r--r--spec/ruby/library/stringio/initialize_spec.rb152
-rw-r--r--spec/ruby/library/stringio/lines_spec.rb53
-rw-r--r--spec/ruby/library/stringio/new_spec.rb10
-rw-r--r--spec/ruby/library/stringio/open_spec.rb68
-rw-r--r--spec/ruby/library/stringio/print_spec.rb8
-rw-r--r--spec/ruby/library/stringio/printf_spec.rb33
-rw-r--r--spec/ruby/library/stringio/putc_spec.rb25
-rw-r--r--spec/ruby/library/stringio/puts_spec.rb22
-rw-r--r--spec/ruby/library/stringio/read_nonblock_spec.rb13
-rw-r--r--spec/ruby/library/stringio/read_spec.rb2
-rw-r--r--spec/ruby/library/stringio/readline_spec.rb22
-rw-r--r--spec/ruby/library/stringio/readlines_spec.rb20
-rw-r--r--spec/ruby/library/stringio/readpartial_spec.rb6
-rw-r--r--spec/ruby/library/stringio/reopen_spec.rb85
-rw-r--r--spec/ruby/library/stringio/set_encoding_spec.rb8
-rw-r--r--spec/ruby/library/stringio/shared/codepoints.rb2
-rw-r--r--spec/ruby/library/stringio/shared/each.rb60
-rw-r--r--spec/ruby/library/stringio/shared/each_byte.rb2
-rw-r--r--spec/ruby/library/stringio/shared/each_char.rb2
-rw-r--r--spec/ruby/library/stringio/shared/getc.rb2
-rw-r--r--spec/ruby/library/stringio/shared/isatty.rb2
-rw-r--r--spec/ruby/library/stringio/shared/read.rb18
-rw-r--r--spec/ruby/library/stringio/shared/readchar.rb2
-rw-r--r--spec/ruby/library/stringio/shared/sysread.rb2
-rw-r--r--spec/ruby/library/stringio/shared/write.rb74
-rw-r--r--spec/ruby/library/stringio/truncate_spec.rb20
-rw-r--r--spec/ruby/library/stringio/ungetbyte_spec.rb38
-rw-r--r--spec/ruby/library/stringio/ungetc_spec.rb10
-rw-r--r--spec/ruby/library/stringio/write_nonblock_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/check_spec.rb9
-rw-r--r--spec/ruby/library/stringscanner/check_until_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/exist_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/getch_spec.rb2
-rw-r--r--spec/ruby/library/stringscanner/matched_size_spec.rb21
-rw-r--r--spec/ruby/library/stringscanner/scan_spec.rb44
-rw-r--r--spec/ruby/library/stringscanner/scan_until_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/search_full_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/shared/concat.rb2
-rw-r--r--spec/ruby/library/stringscanner/shared/extract_range.rb13
-rw-r--r--spec/ruby/library/stringscanner/shared/extract_range_matched.rb11
-rw-r--r--spec/ruby/library/stringscanner/shared/matched_size.rb21
-rw-r--r--spec/ruby/library/stringscanner/shared/peek.rb10
-rw-r--r--spec/ruby/library/stringscanner/size_spec.rb17
-rw-r--r--spec/ruby/library/stringscanner/skip_until_spec.rb6
-rw-r--r--spec/ruby/library/stringscanner/string_spec.rb2
-rw-r--r--spec/ruby/library/time/to_datetime_spec.rb19
-rw-r--r--spec/ruby/library/uri/generic/host_spec.rb7
-rw-r--r--spec/ruby/library/uri/generic/to_s_spec.rb7
-rw-r--r--spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/_invoke_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/codepage_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/connect_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/const_load_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/constants_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/create_guid_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/invoke_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/locale_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/new_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_method_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/setproperty_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_event/new_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/event_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/name_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/new_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/params_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/visible_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/default_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/input_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/name_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/optional_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/retval_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/guid_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/name_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/new_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/progid_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/progids_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/variables_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/visible_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/name_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/value_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb1
-rw-r--r--spec/ruby/library/yaml/dump_spec.rb14
-rw-r--r--spec/ruby/library/yaml/dump_stream_spec.rb3
-rw-r--r--spec/ruby/library/yaml/fixtures/common.rb10
-rw-r--r--spec/ruby/library/yaml/fixtures/strings.rb56
-rw-r--r--spec/ruby/library/yaml/load_file_spec.rb13
-rw-r--r--spec/ruby/library/yaml/load_spec.rb135
-rw-r--r--spec/ruby/library/yaml/load_stream_spec.rb3
-rw-r--r--spec/ruby/library/yaml/parse_file_spec.rb8
-rw-r--r--spec/ruby/library/yaml/parse_spec.rb7
-rw-r--r--spec/ruby/library/yaml/shared/each_document.rb5
-rw-r--r--spec/ruby/library/yaml/shared/load.rb138
-rw-r--r--spec/ruby/library/yaml/to_yaml_spec.rb32
-rw-r--r--spec/ruby/library/yaml/unsafe_load_spec.rb9
-rw-r--r--spec/ruby/library/zlib/crc_table_spec.rb143
-rw-r--r--spec/ruby/library/zlib/deflate/deflate_spec.rb9
-rw-r--r--spec/ruby/library/zlib/deflate/new_spec.rb1
-rw-r--r--spec/ruby/library/zlib/deflate/params_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_line_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/mtime_spec.rb11
-rw-r--r--spec/ruby/library/zlib/gzipreader/new_spec.rb1
-rw-r--r--spec/ruby/library/zlib/inflate/finish_spec.rb1
-rw-r--r--spec/ruby/library/zlib/inflate/inflate_spec.rb15
-rw-r--r--spec/ruby/library/zlib/inflate/new_spec.rb1
779 files changed, 5152 insertions, 7009 deletions
diff --git a/spec/ruby/library/English/English_spec.rb b/spec/ruby/library/English/English_spec.rb
index 480602d5e5..4d615d1e25 100644
--- a/spec/ruby/library/English/English_spec.rb
+++ b/spec/ruby/library/English/English_spec.rb
@@ -130,13 +130,15 @@ describe "English" do
$LAST_MATCH_INFO.should == $~
end
- it "aliases $IGNORECASE to $=" do
- $VERBOSE, verbose = nil, $VERBOSE
- begin
- $IGNORECASE.should_not be_nil
- $IGNORECASE.should == $=
- ensure
- $VERBOSE = verbose
+ ruby_version_is ""..."3.3" do
+ it "aliases $IGNORECASE to $=" do
+ $VERBOSE, verbose = nil, $VERBOSE
+ begin
+ $IGNORECASE.should_not be_nil
+ $IGNORECASE.should == $=
+ ensure
+ $VERBOSE = verbose
+ end
end
end
diff --git a/spec/ruby/library/base64/decode64_spec.rb b/spec/ruby/library/base64/decode64_spec.rb
index f6cd26d788..6dd33dddfe 100644
--- a/spec/ruby/library/base64/decode64_spec.rb
+++ b/spec/ruby/library/base64/decode64_spec.rb
@@ -22,4 +22,8 @@ describe "Base64#decode64" do
it "returns a binary encoded string" do
Base64.decode64("SEk=").encoding.should == Encoding::BINARY
end
+
+ it "decodes without padding suffix ==" do
+ Base64.decode64("eyJrZXkiOnsibiI6InR0dCJ9fQ").should == "{\"key\":{\"n\":\"ttt\"}}"
+ end
end
diff --git a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
index d56c0a664b..43a779b420 100644
--- a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
+++ b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
@@ -56,22 +56,11 @@ describe "Kernel#BigDecimal" do
BigDecimal(initial).should == BigDecimal("123")
end
- ruby_version_is ""..."2.6" do
- it "ignores trailing garbage" do
- BigDecimal("123E45ruby").should == BigDecimal("123E45")
- BigDecimal("123x45").should == BigDecimal("123")
- BigDecimal("123.4%E5").should == BigDecimal("123.4")
- BigDecimal("1E2E3E4E5E").should == BigDecimal("100")
- end
- end
-
- ruby_version_is "2.6" do
- it "does not ignores trailing garbage" do
- -> { BigDecimal("123E45ruby") }.should raise_error(ArgumentError)
- -> { BigDecimal("123x45") }.should raise_error(ArgumentError)
- -> { BigDecimal("123.4%E5") }.should raise_error(ArgumentError)
- -> { BigDecimal("1E2E3E4E5E") }.should raise_error(ArgumentError)
- end
+ it "does not ignores trailing garbage" do
+ -> { BigDecimal("123E45ruby") }.should raise_error(ArgumentError)
+ -> { BigDecimal("123x45") }.should raise_error(ArgumentError)
+ -> { BigDecimal("123.4%E5") }.should raise_error(ArgumentError)
+ -> { BigDecimal("1E2E3E4E5E") }.should raise_error(ArgumentError)
end
it "raises ArgumentError for invalid strings" do
@@ -83,24 +72,12 @@ describe "Kernel#BigDecimal" do
BigDecimal(".123").should == BigDecimal("0.123")
end
- ruby_version_is ""..."2.6" do
- it "allows for underscores in all parts" do
- reference = BigDecimal("12345.67E89")
-
- BigDecimal("12_345.67E89").should == reference
- BigDecimal("1_2_3_4_5_._6____7_E89").should == reference
- BigDecimal("12345_.67E_8__9_").should == reference
- end
- end
-
- ruby_version_is "2.6" do
- it "process underscores as Float()" do
- reference = BigDecimal("12345.67E89")
+ it "process underscores as Float()" do
+ reference = BigDecimal("12345.67E89")
- BigDecimal("12_345.67E89").should == reference
- -> { BigDecimal("1_2_3_4_5_._6____7_E89") }.should raise_error(ArgumentError)
- -> { BigDecimal("12345_.67E_8__9_") }.should raise_error(ArgumentError)
- end
+ BigDecimal("12_345.67E89").should == reference
+ -> { BigDecimal("1_2_3_4_5_._6____7_E89") }.should raise_error(ArgumentError)
+ -> { BigDecimal("12345_.67E_8__9_") }.should raise_error(ArgumentError)
end
it "accepts NaN and [+-]Infinity" do
@@ -116,14 +93,12 @@ describe "Kernel#BigDecimal" do
neg_inf.should < 0
end
- ruby_version_is "2.6" do
- describe "with exception: false" do
- it "returns nil for invalid strings" do
- BigDecimal("invalid", exception: false).should be_nil
- BigDecimal("0invalid", exception: false).should be_nil
- BigDecimal("invalid0", exception: false).should be_nil
- BigDecimal("0.", exception: false).should be_nil
- end
+ describe "with exception: false" do
+ it "returns nil for invalid strings" do
+ BigDecimal("invalid", exception: false).should be_nil
+ BigDecimal("0invalid", exception: false).should be_nil
+ BigDecimal("invalid0", exception: false).should be_nil
+ BigDecimal("0.", exception: false).should be_nil
end
end
diff --git a/spec/ruby/library/bigdecimal/add_spec.rb b/spec/ruby/library/bigdecimal/add_spec.rb
index bea8b8f764..542713011d 100644
--- a/spec/ruby/library/bigdecimal/add_spec.rb
+++ b/spec/ruby/library/bigdecimal/add_spec.rb
@@ -24,7 +24,7 @@ describe "BigDecimal#add" do
end
it "returns a + b with given precision" do
- # documentation states, that precision ist optional, but it ain't,
+ # documentation states that precision is optional, but it ain't,
@two.add(@one, 1).should == @three
@one .add(@two, 1).should == @three
@one.add(@one_minus, 1).should == @zero
@@ -60,7 +60,7 @@ describe "BigDecimal#add" do
end
# TODO:
-# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17374
+# https://blade.ruby-lang.org/ruby-core/17374
#
# This doesn't work on MRI and looks like a bug to me:
# one can use BigDecimal + Float, but not Bigdecimal.add(Float)
diff --git a/spec/ruby/library/bigdecimal/core_spec.rb b/spec/ruby/library/bigdecimal/core_spec.rb
new file mode 100644
index 0000000000..acee4dcf56
--- /dev/null
+++ b/spec/ruby/library/bigdecimal/core_spec.rb
@@ -0,0 +1,59 @@
+require_relative '../../spec_helper'
+require 'bigdecimal'
+
+describe "Core extension by bigdecimal" do
+ context "Integer#coerce" do
+ it "produces Floats" do
+ x, y = 3.coerce(BigDecimal("3.4"))
+ x.class.should == Float
+ x.should == 3.4
+ y.class.should == Float
+ y.should == 3.0
+ end
+ end
+
+ describe "Time.at passed BigDecimal" do
+ it "doesn't round input value" do
+ Time.at(BigDecimal('1.1')).to_f.should == 1.1
+ end
+ end
+
+ describe "BigDecimal#log" do
+ it "handles high-precision Rational arguments" do
+ result = BigDecimal('0.22314354220170971436137296411949880462556361100856391620766259404746040597133837784E0')
+ r = Rational(1_234_567_890, 987_654_321)
+ BigMath.log(r, 50).should == result
+ end
+ end
+
+ describe "Rational#coerce" do
+ it "returns the passed argument, self as Float, when given a Float" do
+ result = Rational(3, 4).coerce(1.0)
+ result.should == [1.0, 0.75]
+ result.first.is_a?(Float).should be_true
+ result.last.is_a?(Float).should be_true
+ end
+
+ it "returns the passed argument, self as Rational, when given an Integer" do
+ result = Rational(3, 4).coerce(10)
+ result.should == [Rational(10, 1), Rational(3, 4)]
+ result.first.is_a?(Rational).should be_true
+ result.last.is_a?(Rational).should be_true
+ end
+
+ it "coerces to Rational, when given a Complex" do
+ Rational(3, 4).coerce(Complex(5)).should == [Rational(5, 1), Rational(3, 4)]
+ Rational(12, 4).coerce(Complex(5, 1)).should == [Complex(5, 1), Complex(3)]
+ end
+
+ it "returns [argument, self] when given a Rational" do
+ Rational(3, 7).coerce(Rational(9, 2)).should == [Rational(9, 2), Rational(3, 7)]
+ end
+
+ it "raises an error when passed a BigDecimal" do
+ -> {
+ Rational(500, 3).coerce(BigDecimal('166.666666666'))
+ }.should raise_error(TypeError, /BigDecimal can't be coerced into Rational/)
+ end
+ end
+end
diff --git a/spec/ruby/library/bigdecimal/exponent_spec.rb b/spec/ruby/library/bigdecimal/exponent_spec.rb
index f63c4e5798..8877147955 100644
--- a/spec/ruby/library/bigdecimal/exponent_spec.rb
+++ b/spec/ruby/library/bigdecimal/exponent_spec.rb
@@ -18,17 +18,6 @@ describe "BigDecimal#exponent" do
BigDecimal("1234567E10").exponent.should == 17
end
-# commenting this spec out after discussion with Defiler, since it seems to be an MRI bug, not a real feature
-=begin
- platform_is wordsize: 32 do
- # TODO: write specs for both 32 and 64 bit
- it "returns 0 if exponent can't be represented as Integer" do
- BigDecimal("2E1000000000000000").exponent.should == 0
- BigDecimal("-5E-999999999999999").exponent.should == 0
- end
- end
-=end
-
it "returns 0 if self is 0" do
BigDecimal("0").exponent.should == 0
BigDecimal("+0").exponent.should == 0
diff --git a/spec/ruby/library/bigdecimal/remainder_spec.rb b/spec/ruby/library/bigdecimal/remainder_spec.rb
index 1866f665cd..bac5f37ba9 100644
--- a/spec/ruby/library/bigdecimal/remainder_spec.rb
+++ b/spec/ruby/library/bigdecimal/remainder_spec.rb
@@ -54,21 +54,23 @@ describe "BigDecimal#remainder" do
@nan.remainder(@infinity).should.nan?
end
- it "returns NaN if Infinity is involved" do
- @infinity.remainder(@infinity).should.nan?
- @infinity.remainder(@one).should.nan?
- @infinity.remainder(@mixed).should.nan?
- @infinity.remainder(@one_minus).should.nan?
- @infinity.remainder(@frac_1).should.nan?
- @one.remainder(@infinity).should.nan?
+ version_is BigDecimal::VERSION, ""..."3.1.4" do #ruby_version_is ""..."3.3" do
+ it "returns NaN if Infinity is involved" do
+ @infinity.remainder(@infinity).should.nan?
+ @infinity.remainder(@one).should.nan?
+ @infinity.remainder(@mixed).should.nan?
+ @infinity.remainder(@one_minus).should.nan?
+ @infinity.remainder(@frac_1).should.nan?
+ @one.remainder(@infinity).should.nan?
- @infinity_minus.remainder(@infinity_minus).should.nan?
- @infinity_minus.remainder(@one).should.nan?
- @one.remainder(@infinity_minus).should.nan?
- @frac_2.remainder(@infinity_minus).should.nan?
+ @infinity_minus.remainder(@infinity_minus).should.nan?
+ @infinity_minus.remainder(@one).should.nan?
+ @one.remainder(@infinity_minus).should.nan?
+ @frac_2.remainder(@infinity_minus).should.nan?
- @infinity.remainder(@infinity_minus).should.nan?
- @infinity_minus.remainder(@infinity).should.nan?
+ @infinity.remainder(@infinity_minus).should.nan?
+ @infinity_minus.remainder(@infinity).should.nan?
+ end
end
it "coerces arguments to BigDecimal if possible" do
diff --git a/spec/ruby/library/bigdecimal/round_spec.rb b/spec/ruby/library/bigdecimal/round_spec.rb
index 501a1a7342..fba52df65d 100644
--- a/spec/ruby/library/bigdecimal/round_spec.rb
+++ b/spec/ruby/library/bigdecimal/round_spec.rb
@@ -228,7 +228,15 @@ describe "BigDecimal#round" do
-> { BigDecimal('-Infinity').round(2) }.should_not raise_error(FloatDomainError)
end
- it "raise for a non-existent round mode" do
- -> { @p1_50.round(0, :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode")
+ version_is BigDecimal::VERSION, ''...'3.1.3' do #ruby_version_is ''...'3.2' do
+ it 'raise for a non-existent round mode' do
+ -> { @p1_50.round(0, :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode")
+ end
+ end
+
+ version_is BigDecimal::VERSION, '3.1.3' do #ruby_version_is '3.2' do
+ it 'raise for a non-existent round mode' do
+ -> { @p1_50.round(0, :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode (nonsense)")
+ end
end
end
diff --git a/spec/ruby/library/bigdecimal/shared/to_int.rb b/spec/ruby/library/bigdecimal/shared/to_int.rb
index 0f16251612..44b6a3c7b2 100644
--- a/spec/ruby/library/bigdecimal/shared/to_int.rb
+++ b/spec/ruby/library/bigdecimal/shared/to_int.rb
@@ -1,6 +1,6 @@
require 'bigdecimal'
-describe :bigdecimal_to_int , shared: true do
+describe :bigdecimal_to_int, shared: true do
it "raises FloatDomainError if BigDecimal is infinity or NaN" do
-> { BigDecimal("Infinity").send(@method) }.should raise_error(FloatDomainError)
-> { BigDecimal("NaN").send(@method) }.should raise_error(FloatDomainError)
diff --git a/spec/ruby/library/bigdecimal/sqrt_spec.rb b/spec/ruby/library/bigdecimal/sqrt_spec.rb
index d149003b9f..8fd1ec0f39 100644
--- a/spec/ruby/library/bigdecimal/sqrt_spec.rb
+++ b/spec/ruby/library/bigdecimal/sqrt_spec.rb
@@ -36,8 +36,10 @@ describe "BigDecimal#sqrt" do
BigDecimal('121').sqrt(5).should be_close(11, 0.00001)
end
- it "returns square root of 0.9E-99999 with desired precision" do
- @frac_2.sqrt(1).to_s.should =~ /\A0\.3E-49999\z/i
+ platform_is_not wordsize: 32 do # fails on i686
+ it "returns square root of 0.9E-99999 with desired precision" do
+ @frac_2.sqrt(1).to_s.should =~ /\A0\.3E-49999\z/i
+ end
end
it "raises ArgumentError when no argument is given" do
diff --git a/spec/ruby/library/bigdecimal/to_r_spec.rb b/spec/ruby/library/bigdecimal/to_r_spec.rb
index 91d2b33993..c350beff08 100644
--- a/spec/ruby/library/bigdecimal/to_r_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_r_spec.rb
@@ -13,4 +13,16 @@ describe "BigDecimal#to_r" do
r.denominator.should eql(1000000000000000000000000)
end
+ it "returns a Rational from a BigDecimal with an exponent" do
+ r = BigDecimal("1E2").to_r
+ r.numerator.should eql(100)
+ r.denominator.should eql(1)
+ end
+
+ it "returns a Rational from a negative BigDecimal with an exponent" do
+ r = BigDecimal("-1E2").to_r
+ r.numerator.should eql(-100)
+ r.denominator.should eql(1)
+ end
+
end
diff --git a/spec/ruby/library/bigdecimal/to_s_spec.rb b/spec/ruby/library/bigdecimal/to_s_spec.rb
index 4f1054d38e..ba9f960eb3 100644
--- a/spec/ruby/library/bigdecimal/to_s_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_s_spec.rb
@@ -39,20 +39,25 @@ describe "BigDecimal#to_s" do
@bigneg.to_s("+").should_not =~ /^\+.*/
end
- it "inserts a space every n chars, if integer n is supplied" do
+ it "inserts a space every n chars to fraction part, if integer n is supplied" do
re =\
- /\A0\.314 159 265 358 979 323 846 264 338 327 950 288 419 716 939 937E1\z/i
+ /\A0\.314 159 265 358 979 323 846 264 338 327 950 288 419 716 939 937E1\z/i
@bigdec.to_s(3).should =~ re
str1 = '-123.45678 90123 45678 9'
BigDecimal("-123.45678901234567890").to_s('5F').should == str1
- BigDecimal('1000010').to_s('5F').should == "10000 10.0"
# trailing zeroes removed
BigDecimal("1.00000000000").to_s('1F').should == "1.0"
# 0 is treated as no spaces
BigDecimal("1.2345").to_s('0F').should == "1.2345"
end
+ version_is BigDecimal::VERSION, "3.1.5" do #ruby_version_is '3.3' do
+ it "inserts a space every n chars to integer part, if integer n is supplied" do
+ BigDecimal('1000010').to_s('5F').should == "10 00010.0"
+ end
+ end
+
it "can return a leading space for values > 0" do
@bigdec.to_s(" F").should =~ /\ .*/
@bigneg.to_s(" F").should_not =~ /\ .*/
@@ -83,15 +88,13 @@ describe "BigDecimal#to_s" do
end
end
- ruby_version_is "3.0" do
- it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do
- Encoding.default_internal = nil
- BigDecimal('1.23').to_s.encoding.should equal(Encoding::US_ASCII)
- end
+ it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do
+ Encoding.default_internal = nil
+ BigDecimal('1.23').to_s.encoding.should equal(Encoding::US_ASCII)
+ end
- it "returns a String in US-ASCII encoding when Encoding.default_internal is not nil" do
- Encoding.default_internal = Encoding::IBM437
- BigDecimal('1.23').to_s.encoding.should equal(Encoding::US_ASCII)
- end
+ it "returns a String in US-ASCII encoding when Encoding.default_internal is not nil" do
+ Encoding.default_internal = Encoding::IBM437
+ BigDecimal('1.23').to_s.encoding.should equal(Encoding::US_ASCII)
end
end
diff --git a/spec/ruby/library/bigdecimal/util_spec.rb b/spec/ruby/library/bigdecimal/util_spec.rb
index f41e131144..fc67fcf200 100644
--- a/spec/ruby/library/bigdecimal/util_spec.rb
+++ b/spec/ruby/library/bigdecimal/util_spec.rb
@@ -27,10 +27,8 @@ describe "BigDecimal's util method definitions" do
Rational(22, 7).to_d(3).should == BigDecimal(3.14, 3)
end
- ruby_version_is "2.6" do
- it "should define #to_d on nil" do
- nil.to_d.should == BigDecimal(0)
- end
+ it "should define #to_d on nil" do
+ nil.to_d.should == BigDecimal(0)
end
end
diff --git a/spec/ruby/library/bigmath/log_spec.rb b/spec/ruby/library/bigmath/log_spec.rb
deleted file mode 100644
index 2ffbf8b6b9..0000000000
--- a/spec/ruby/library/bigmath/log_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../spec_helper'
-require 'bigdecimal'
-
-describe "BigDecimal#log" do
- it "handles high-precision Rational arguments" do
- result = BigDecimal('0.22314354220170971436137296411949880462556361100856391620766259404746040597133837784E0')
- r = Rational(1_234_567_890, 987_654_321)
- BigMath.log(r, 50).should == result
- end
-end
diff --git a/spec/ruby/library/cgi/cookie/name_spec.rb b/spec/ruby/library/cgi/cookie/name_spec.rb
index 14226824c8..326a43ade3 100644
--- a/spec/ruby/library/cgi/cookie/name_spec.rb
+++ b/spec/ruby/library/cgi/cookie/name_spec.rb
@@ -6,18 +6,18 @@ describe "CGI::Cookie#name" do
cookie = CGI::Cookie.new("test-cookie")
cookie.name.should == "test-cookie"
- cookie = CGI::Cookie.new("name" => "another cookie")
- cookie.name.should == "another cookie"
+ cookie = CGI::Cookie.new("name" => "another-cookie")
+ cookie.name.should == "another-cookie"
end
end
describe "CGI::Cookie#name=" do
it "sets self's expiration date" do
cookie = CGI::Cookie.new("test-cookie")
- cookie.name = "another name"
- cookie.name.should == "another name"
+ cookie.name = "another-name"
+ cookie.name.should == "another-name"
- cookie.name = "and one more"
- cookie.name.should == "and one more"
+ cookie.name = "and-one-more"
+ cookie.name.should == "and-one-more"
end
end
diff --git a/spec/ruby/library/cgi/cookie/parse_spec.rb b/spec/ruby/library/cgi/cookie/parse_spec.rb
index 90d2c3d148..d484c7bad9 100644
--- a/spec/ruby/library/cgi/cookie/parse_spec.rb
+++ b/spec/ruby/library/cgi/cookie/parse_spec.rb
@@ -6,16 +6,16 @@ describe "CGI::Cookie.parse" do
expected = { "test-cookie" => ["one", "two", "three"] }
CGI::Cookie.parse("test-cookie=one&two&three").should == expected
- expected = { "second cookie" => ["three", "four"], "first cookie" => ["one", "two"] }
- CGI::Cookie.parse("first cookie=one&two;second cookie=three&four").should == expected
+ expected = { "second-cookie" => ["three", "four"], "first-cookie" => ["one", "two"] }
+ CGI::Cookie.parse("first-cookie=one&two;second-cookie=three&four").should == expected
end
it "does not use , for cookie separators" do
expected = {
- "first cookie" => ["one", "two"],
- "second cookie" => ["three", "four,third_cookie=five", "six"]
+ "first-cookie" => ["one", "two"],
+ "second-cookie" => ["three", "four,third_cookie=five", "six"]
}
- CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected
+ CGI::Cookie.parse("first-cookie=one&two;second-cookie=three&four,third_cookie=five&six").should == expected
end
it "unescapes the Cookie values" do
diff --git a/spec/ruby/library/cgi/escapeURIComponent_spec.rb b/spec/ruby/library/cgi/escapeURIComponent_spec.rb
new file mode 100644
index 0000000000..f05795a2f5
--- /dev/null
+++ b/spec/ruby/library/cgi/escapeURIComponent_spec.rb
@@ -0,0 +1,57 @@
+require_relative '../../spec_helper'
+require 'cgi'
+
+ruby_version_is "3.2" do
+ describe "CGI.escapeURIComponent" do
+ it "escapes whitespace" do
+ string = "&<>\" \xE3\x82\x86\xE3\x82\x93\xE3\x82\x86\xE3\x82\x93"
+ CGI.escapeURIComponent(string).should == '%26%3C%3E%22%20%E3%82%86%E3%82%93%E3%82%86%E3%82%93'
+ end
+
+ it "does not escape with unreserved characters" do
+ string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"
+ CGI.escapeURIComponent(string).should == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"
+ end
+
+ it "supports String with invalid encoding" do
+ string = "\xC0\<\<".dup.force_encoding("UTF-8")
+ CGI.escapeURIComponent(string).should == "%C0%3C%3C"
+ end
+
+ it "processes String bytes one by one, not characters" do
+ CGI.escapeURIComponent("β").should == "%CE%B2" # "β" bytes representation is CE B2
+ end
+
+ it "raises a TypeError with nil" do
+ -> {
+ CGI.escapeURIComponent(nil)
+ }.should raise_error(TypeError, 'no implicit conversion of nil into String')
+ end
+
+ it "encodes empty string" do
+ CGI.escapeURIComponent("").should == ""
+ end
+
+ it "encodes single whitespace" do
+ CGI.escapeURIComponent(" ").should == "%20"
+ end
+
+ it "encodes double whitespace" do
+ CGI.escapeURIComponent(" ").should == "%20%20"
+ end
+
+ it "preserves encoding" do
+ string = "whatever".encode("ASCII-8BIT")
+ CGI.escapeURIComponent(string).encoding.should == Encoding::ASCII_8BIT
+ end
+
+ it "uses implicit type conversion to String" do
+ object = Object.new
+ def object.to_str
+ "a b"
+ end
+
+ CGI.escapeURIComponent(object).should == "a%20b"
+ end
+ end
+end
diff --git a/spec/ruby/library/cgi/initialize_spec.rb b/spec/ruby/library/cgi/initialize_spec.rb
index f794f157f0..61bc971d49 100644
--- a/spec/ruby/library/cgi/initialize_spec.rb
+++ b/spec/ruby/library/cgi/initialize_spec.rb
@@ -29,8 +29,8 @@ describe "CGI#initialize when passed no arguments" do
it "does not extend self with any of the other HTML modules" do
@cgi.send(:initialize)
- @cgi.should_not be_kind_of(CGI::Html3)
@cgi.should_not be_kind_of(CGI::HtmlExtension)
+ @cgi.should_not be_kind_of(CGI::Html3)
@cgi.should_not be_kind_of(CGI::Html4)
@cgi.should_not be_kind_of(CGI::Html4Tr)
@cgi.should_not be_kind_of(CGI::Html4Fr)
diff --git a/spec/ruby/library/cmath/math/acos_spec.rb b/spec/ruby/library/cmath/math/acos_spec.rb
deleted file mode 100644
index 2e9104f835..0000000000
--- a/spec/ruby/library/cmath/math/acos_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/acos'
-
- describe "Math#acos" do
- it_behaves_like :complex_math_acos, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:acos)
- end
- end
-
- describe "Math.acos" do
- it_behaves_like :complex_math_acos, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/acosh_spec.rb b/spec/ruby/library/cmath/math/acosh_spec.rb
deleted file mode 100644
index 809112f6c0..0000000000
--- a/spec/ruby/library/cmath/math/acosh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/acosh'
-
- describe "Math#acosh" do
- it_behaves_like :complex_math_acosh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:acosh)
- end
- end
-
- describe "Math.acosh" do
- it_behaves_like :complex_math_acosh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/asin_spec.rb b/spec/ruby/library/cmath/math/asin_spec.rb
deleted file mode 100644
index 4ac588ebd2..0000000000
--- a/spec/ruby/library/cmath/math/asin_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/asin'
-
- describe "Math#asin" do
- it_behaves_like :complex_math_asin, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:asin)
- end
- end
-
- describe "Math.asin" do
- it_behaves_like :complex_math_asin, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/asinh_spec.rb b/spec/ruby/library/cmath/math/asinh_spec.rb
deleted file mode 100644
index 7d8b397a04..0000000000
--- a/spec/ruby/library/cmath/math/asinh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/asinh'
-
- describe "Math#asinh" do
- it_behaves_like :complex_math_asinh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:asinh)
- end
- end
-
- describe "Math.asinh" do
- it_behaves_like :complex_math_asinh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/atan2_spec.rb b/spec/ruby/library/cmath/math/atan2_spec.rb
deleted file mode 100644
index 1a9b7d7607..0000000000
--- a/spec/ruby/library/cmath/math/atan2_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/atan2'
-
- describe "Math#atan2" do
- it_behaves_like :complex_math_atan2, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:atan2)
- end
- end
-
- describe "Math.atan2" do
- it_behaves_like :complex_math_atan2, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/atan_spec.rb b/spec/ruby/library/cmath/math/atan_spec.rb
deleted file mode 100644
index b0171081a6..0000000000
--- a/spec/ruby/library/cmath/math/atan_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/atan'
-
- describe "Math#atan" do
- it_behaves_like :complex_math_atan, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:atan)
- end
- end
-
- describe "Math.atan" do
- it_behaves_like :complex_math_atan, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/atanh_spec.rb b/spec/ruby/library/cmath/math/atanh_spec.rb
deleted file mode 100644
index 6b22c6c9e4..0000000000
--- a/spec/ruby/library/cmath/math/atanh_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative '../../../fixtures/math/common'
- require_relative '../../../shared/math/atanh'
- require_relative 'shared/atanh'
-
- describe "Math#atanh" do
- it_behaves_like :math_atanh_base, :atanh, IncludesMath.new
- it_behaves_like :complex_math_atanh_complex, :atanh, IncludesMath.new
-
- it_behaves_like :math_atanh_private, :atanh, IncludesMath.new
- end
-
- describe "Math.atanh" do
- it_behaves_like :math_atanh_base, :atanh, CMath
- it_behaves_like :complex_math_atanh_complex, :atanh, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/cos_spec.rb b/spec/ruby/library/cmath/math/cos_spec.rb
deleted file mode 100644
index 3f097bcb3b..0000000000
--- a/spec/ruby/library/cmath/math/cos_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/cos'
-
- describe "Math#cos" do
- it_behaves_like :complex_math_cos, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:cos)
- end
- end
-
- describe "Math.cos" do
- it_behaves_like :complex_math_cos, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/cosh_spec.rb b/spec/ruby/library/cmath/math/cosh_spec.rb
deleted file mode 100644
index 197f899981..0000000000
--- a/spec/ruby/library/cmath/math/cosh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/cosh'
-
- describe "Math#cosh" do
- it_behaves_like :complex_math_cosh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:cosh)
- end
- end
-
- describe "Math.cosh" do
- it_behaves_like :complex_math_cosh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/exp_spec.rb b/spec/ruby/library/cmath/math/exp_spec.rb
deleted file mode 100644
index eef2ec3129..0000000000
--- a/spec/ruby/library/cmath/math/exp_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/exp'
-
- describe "Math#exp" do
- it_behaves_like :complex_math_exp, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:exp)
- end
- end
-
- describe "Math.exp" do
- it_behaves_like :complex_math_exp, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/fixtures/classes.rb b/spec/ruby/library/cmath/math/fixtures/classes.rb
deleted file mode 100644
index 443c1a9ace..0000000000
--- a/spec/ruby/library/cmath/math/fixtures/classes.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'cmath'
-class IncludesMath
- include CMath
-end
diff --git a/spec/ruby/library/cmath/math/log10_spec.rb b/spec/ruby/library/cmath/math/log10_spec.rb
deleted file mode 100644
index 603bbb1457..0000000000
--- a/spec/ruby/library/cmath/math/log10_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/log10'
-
- describe "Math#log10" do
- it_behaves_like :complex_math_log10, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:log10)
- end
- end
-
- describe "Math.log10" do
- it_behaves_like :complex_math_log10, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/log_spec.rb b/spec/ruby/library/cmath/math/log_spec.rb
deleted file mode 100644
index b4da781323..0000000000
--- a/spec/ruby/library/cmath/math/log_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/log'
-
- describe "Math#log" do
- it_behaves_like :complex_math_log, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:log)
- end
- end
-
- describe "Math.log" do
- it_behaves_like :complex_math_log, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/acos.rb b/spec/ruby/library/cmath/math/shared/acos.rb
deleted file mode 100644
index 65637fa838..0000000000
--- a/spec/ruby/library/cmath/math/shared/acos.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_acos, shared: true do
- it "returns the arccosine of the passed argument" do
- @object.send(:acos, 1).should be_close(0.0, TOLERANCE)
- @object.send(:acos, 0).should be_close(1.5707963267949, TOLERANCE)
- @object.send(:acos, -1).should be_close(Math::PI,TOLERANCE)
- end
-
- it "returns the arccosine for Complex numbers" do
- @object.send(:acos, Complex(3, 4)).should be_close(Complex(0.93681246115572, -2.30550903124348), TOLERANCE)
- end
-
- it "returns the arccosine for numbers greater than 1.0 as a Complex number" do
- @object.send(:acos, 1.0001).should be_close(Complex(0.0, 0.0141420177752494), TOLERANCE)
- end
-
- it "returns the arccosine for numbers less than -1.0 as a Complex number" do
- @object.send(:acos, -1.0001).should be_close(Complex(3.14159265358979, -0.0141420177752495), TOLERANCE)
- end
-end
-
-describe :complex_math_acos_bang, shared: true do
- it "returns the arccosine of the argument" do
- @object.send(:acos!, 1).should be_close(0.0, TOLERANCE)
- @object.send(:acos!, 0).should be_close(1.5707963267949, TOLERANCE)
- @object.send(:acos!, -1).should be_close(Math::PI,TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:acos!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-
- it "raises an Errno::EDOM for numbers greater than 1.0" do
- -> { @object.send(:acos!, 1.0001) }.should raise_error(Errno::EDOM)
- end
-
- it "raises an Errno::EDOM for numbers less than -1.0" do
- -> { @object.send(:acos!, -1.0001) }.should raise_error(Errno::EDOM)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/acosh.rb b/spec/ruby/library/cmath/math/shared/acosh.rb
deleted file mode 100644
index 285b0b823f..0000000000
--- a/spec/ruby/library/cmath/math/shared/acosh.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_acosh, shared: true do
- it "returns the principle value of the inverse hyperbolic cosine of the argument" do
- @object.send(:acosh, 14.2).should be_close(3.345146999647, TOLERANCE)
- @object.send(:acosh, 1.0).should be_close(0.0, TOLERANCE)
- end
-
- it "returns the principle value of the inverse hyperbolic cosine for numbers less than 1.0 as a Complex number" do
- @object.send(:acosh, 1.0 - TOLERANCE).should be_close(Complex(0.0, 0.00774598605746135), TOLERANCE)
- @object.send(:acosh, 0).should be_close(Complex(0.0, 1.5707963267949), TOLERANCE)
- @object.send(:acosh, -1.0).should be_close(Complex(0.0, 3.14159265358979), TOLERANCE)
- end
-
- it "returns the principle value of the inverse hyperbolic cosine for Complex numbers" do
- @object.send(:acosh, Complex(3, 4))
- @object.send(:acosh, Complex(3, 4)).imaginary.should be_close(0.93681246115572, TOLERANCE)
- @object.send(:acosh, Complex(3, 4)).real.should be_close(2.305509031243477, TOLERANCE)
- end
-end
-
-describe :complex_math_acosh_bang, shared: true do
- it "returns the principle value of the inverse hyperbolic cosine of the argument" do
- @object.send(:acosh!, 14.2).should be_close(3.345146999647, TOLERANCE)
- @object.send(:acosh!, 1.0).should be_close(0.0, TOLERANCE)
- end
-
- it "raises Errno::EDOM for numbers less than 1.0" do
- -> { @object.send(:acosh!, 1.0 - TOLERANCE) }.should raise_error(Errno::EDOM)
- -> { @object.send(:acosh!, 0) }.should raise_error(Errno::EDOM)
- -> { @object.send(:acosh!, -1.0) }.should raise_error(Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:acosh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/asin.rb b/spec/ruby/library/cmath/math/shared/asin.rb
deleted file mode 100644
index 91fed7aa06..0000000000
--- a/spec/ruby/library/cmath/math/shared/asin.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_asin, shared: true do
- it "returns the arcsine of the argument" do
- @object.send(:asin, 1).should be_close(Math::PI/2, TOLERANCE)
- @object.send(:asin, 0).should be_close(0.0, TOLERANCE)
- @object.send(:asin, -1).should be_close(-Math::PI/2, TOLERANCE)
- @object.send(:asin, 0.25).should be_close(0.252680255142079, TOLERANCE)
- @object.send(:asin, 0.50).should be_close(0.523598775598299, TOLERANCE)
- @object.send(:asin, 0.75).should be_close(0.8480620789814816,TOLERANCE)
- end
-
- it "returns the arcsine for Complex numbers" do
- @object.send(:asin, Complex(3, 4)).should be_close(Complex(0.633983865639174, 2.30550903124347), TOLERANCE)
- end
-
- it "returns a Complex number when the argument is greater than 1.0" do
- @object.send(:asin, 1.0001).should be_close(Complex(1.5707963267949, -0.0141420177752494), TOLERANCE)
- end
-
- it "returns a Complex number when the argument is less than -1.0" do
- @object.send(:asin, -1.0001).should be_close(Complex(-1.5707963267949, 0.0141420177752494), TOLERANCE)
- end
-end
-
-describe :complex_math_asin_bang, shared: true do
- it "returns the arcsine of the argument" do
- @object.send(:asin!, 1).should be_close(Math::PI/2, TOLERANCE)
- @object.send(:asin!, 0).should be_close(0.0, TOLERANCE)
- @object.send(:asin!, -1).should be_close(-Math::PI/2, TOLERANCE)
- @object.send(:asin!, 0.25).should be_close(0.252680255142079, TOLERANCE)
- @object.send(:asin!, 0.50).should be_close(0.523598775598299, TOLERANCE)
- @object.send(:asin!, 0.75).should be_close(0.8480620789814816,TOLERANCE)
- end
-
- it "raises an Errno::EDOM if the argument is greater than 1.0" do
- -> { @object.send(:asin!, 1.0001) }.should raise_error( Errno::EDOM)
- end
-
- it "raises an Errno::EDOM if the argument is less than -1.0" do
- -> { @object.send(:asin!, -1.0001) }.should raise_error( Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:asin!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/asinh.rb b/spec/ruby/library/cmath/math/shared/asinh.rb
deleted file mode 100644
index b4ddd3a22e..0000000000
--- a/spec/ruby/library/cmath/math/shared/asinh.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_asinh, shared: true do
- it "returns the inverse hyperbolic sin of the argument" do
- @object.send(:asinh, 1.5).should be_close(1.19476321728711, TOLERANCE)
- @object.send(:asinh, -2.97).should be_close(-1.8089166921397, TOLERANCE)
- @object.send(:asinh, 0.0).should == 0.0
- @object.send(:asinh, -0.0).should == -0.0
- @object.send(:asinh, 1.05367e-08).should be_close(1.05367e-08, TOLERANCE)
- @object.send(:asinh, -1.05367e-08).should be_close(-1.05367e-08, TOLERANCE)
- end
-
- it "returns the inverse hyperbolic sin for Complex numbers" do
- @object.send(:asinh, Complex(3, 4)).should be_close(Complex(2.29991404087927, 0.917616853351479), TOLERANCE)
- @object.send(:asinh, Complex(3.5, -4)).should be_close(Complex(2.36263337274419, -0.843166327537659), TOLERANCE)
- end
-end
-
-describe :complex_math_asinh_bang, shared: true do
- it "returns the inverse hyperbolic sin of the argument" do
- @object.send(:asinh!, 1.5).should be_close(1.19476321728711, TOLERANCE)
- @object.send(:asinh!, -2.97).should be_close(-1.8089166921397, TOLERANCE)
- @object.send(:asinh!, 0.0).should == 0.0
- @object.send(:asinh!, -0.0).should == -0.0
- @object.send(:asinh!, 1.05367e-08).should be_close(1.05367e-08, TOLERANCE)
- @object.send(:asinh!, -1.05367e-08).should be_close(-1.05367e-08, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:asinh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/atan.rb b/spec/ruby/library/cmath/math/shared/atan.rb
deleted file mode 100644
index 63a496e841..0000000000
--- a/spec/ruby/library/cmath/math/shared/atan.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_atan, shared: true do
- it "returns the arctangent of the argument" do
- @object.send(:atan, 1).should be_close(Math::PI/4, TOLERANCE)
- @object.send(:atan, 0).should be_close(0.0, TOLERANCE)
- @object.send(:atan, -1).should be_close(-Math::PI/4, TOLERANCE)
- @object.send(:atan, 0.25).should be_close(0.244978663126864, TOLERANCE)
- @object.send(:atan, 0.50).should be_close(0.463647609000806, TOLERANCE)
- @object.send(:atan, 0.75).should be_close(0.643501108793284, TOLERANCE)
- end
-
- it "returns the arctangent for Complex numbers" do
- @object.send(:atan, Complex(3, 4)).should be_close(Complex(1.44830699523146, 0.158997191679999), TOLERANCE)
- @object.send(:atan, Complex(3.5, -4)).should be_close(Complex(1.44507428165589, -0.140323762363786), TOLERANCE)
- end
-end
-
-describe :complex_math_atan_bang, shared: true do
- it "returns the arctangent of the argument" do
- @object.send(:atan!, 1).should be_close(Math::PI/4, TOLERANCE)
- @object.send(:atan!, 0).should be_close(0.0, TOLERANCE)
- @object.send(:atan!, -1).should be_close(-Math::PI/4, TOLERANCE)
- @object.send(:atan!, 0.25).should be_close(0.244978663126864, TOLERANCE)
- @object.send(:atan!, 0.50).should be_close(0.463647609000806, TOLERANCE)
- @object.send(:atan!, 0.75).should be_close(0.643501108793284, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:atan!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/atan2.rb b/spec/ruby/library/cmath/math/shared/atan2.rb
deleted file mode 100644
index 6d89423924..0000000000
--- a/spec/ruby/library/cmath/math/shared/atan2.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_atan2, shared: true do
- it "returns the arc tangent of the passed arguments" do
- @object.send(:atan2, 4.2, 0.3).should be_close(1.49948886200961, TOLERANCE)
- @object.send(:atan2, 0.0, 1.0).should be_close(0.0, TOLERANCE)
- @object.send(:atan2, -9.1, 3.2).should be_close(-1.23265379809025, TOLERANCE)
- @object.send(:atan2, 7.22, -3.3).should be_close(1.99950888779256, TOLERANCE)
- end
-
- it "returns the arc tangent for two Complex numbers" do
- CMath.atan2(Complex(3, 4), Complex(3.5, -4)).should be_close(Complex(-0.641757436698881, 1.10829873031207), TOLERANCE)
- end
-
- it "returns the arc tangent for Complex and real numbers" do
- CMath.atan2(Complex(3, 4), -7).should be_close(Complex(2.61576754731561, -0.494290673139855), TOLERANCE)
- CMath.atan2(5, Complex(3.5, -4)).should be_close(Complex(0.739102348493673, 0.487821626522923), TOLERANCE)
- end
-end
-
-describe :complex_math_atan2_bang, shared: true do
- it "returns the arc tangent of the passed arguments" do
- @object.send(:atan2!, 4.2, 0.3).should be_close(1.49948886200961, TOLERANCE)
- @object.send(:atan2!, 0.0, 1.0).should be_close(0.0, TOLERANCE)
- @object.send(:atan2!, -9.1, 3.2).should be_close(-1.23265379809025, TOLERANCE)
- @object.send(:atan2!, 7.22, -3.3).should be_close(1.99950888779256, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:atan2!, Complex(4, 5), Complex(4, 5)) }.should raise_error(TypeError)
- -> { @object.send(:atan2!, 4, Complex(4, 5)) }.should raise_error(TypeError)
- -> { @object.send(:atan2!, Complex(4, 5), 5) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/atanh.rb b/spec/ruby/library/cmath/math/shared/atanh.rb
deleted file mode 100644
index ae80e61bec..0000000000
--- a/spec/ruby/library/cmath/math/shared/atanh.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_atanh_complex, shared: true do
- it "returns the inverse hyperbolic tangent as a Complex number for arguments greater than 1.0" do
- value = Complex(18.36840028483855, 1.5707963267948966)
- @object.send(@method, 1.0 + Float::EPSILON).should be_close(value, TOLERANCE)
-
- value = Complex(0.100335347731076, 1.5707963267949)
- @object.send(@method, 10).should be_close(value, TOLERANCE)
- end
-
- it "returns the inverse hyperbolic tangent as a Complex number for arguments greater than 1.0" do
- value = Complex(-18.36840028483855, 1.5707963267948966)
- @object.send(@method, -1.0 - Float::EPSILON).should be_close(value, TOLERANCE)
-
- value = Complex(0.100335347731076, 1.5707963267949)
- @object.send(@method, 10).should be_close(value, TOLERANCE)
- end
-
- it "returns the inverse hyperbolic tangent for Complex numbers" do
- value = Complex(0.117500907311434, 1.40992104959658)
- @object.send(@method, Complex(3, 4)).should be_close(value, TOLERANCE)
- end
-end
-
-describe :complex_math_atanh_no_complex, shared: true do
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:atanh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/cos.rb b/spec/ruby/library/cmath/math/shared/cos.rb
deleted file mode 100644
index 31cb5ab1e5..0000000000
--- a/spec/ruby/library/cmath/math/shared/cos.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_cos, shared: true do
- it "returns the cosine of the argument expressed in radians" do
- @object.send(:cos, CMath::PI).should be_close(-1.0, TOLERANCE)
- @object.send(:cos, 0).should be_close(1.0, TOLERANCE)
- @object.send(:cos, CMath::PI/2).should be_close(0.0, TOLERANCE)
- @object.send(:cos, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
- @object.send(:cos, 2*Math::PI).should be_close(1.0, TOLERANCE)
- end
-
- it "returns the cosine for Complex numbers" do
- @object.send(:cos, Complex(0, CMath::PI)).should be_close(Complex(11.5919532755215, 0.0), TOLERANCE)
- @object.send(:cos, Complex(3, 4)).should be_close(Complex(-27.0349456030742, -3.85115333481178), TOLERANCE)
- end
-end
-
-describe :complex_math_cos_bang, shared: true do
- it "returns the cosine of the argument expressed in radians" do
- @object.send(:cos!, CMath::PI).should be_close(-1.0, TOLERANCE)
- @object.send(:cos!, 0).should be_close(1.0, TOLERANCE)
- @object.send(:cos!, CMath::PI/2).should be_close(0.0, TOLERANCE)
- @object.send(:cos!, 3*Math::PI/2).should be_close(0.0, TOLERANCE)
- @object.send(:cos!, 2*Math::PI).should be_close(1.0, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:cos!, Complex(3, 4)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/cosh.rb b/spec/ruby/library/cmath/math/shared/cosh.rb
deleted file mode 100644
index 7cf561c985..0000000000
--- a/spec/ruby/library/cmath/math/shared/cosh.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_cosh, shared: true do
- it "returns the hyperbolic cosine of the passed argument" do
- @object.send(:cosh, 0.0).should == 1.0
- @object.send(:cosh, -0.0).should == 1.0
- @object.send(:cosh, 1.5).should be_close(2.35240961524325, TOLERANCE)
- @object.send(:cosh, -2.99).should be_close(9.96798496414416, TOLERANCE)
- end
-
- it "returns the hyperbolic cosine for Complex numbers" do
- @object.send(:cosh, Complex(0, CMath::PI)).should be_close(Complex(-1.0, 0.0), TOLERANCE)
- @object.send(:cosh, Complex(3, 4)).should be_close(Complex(-6.58066304055116, -7.58155274274654), TOLERANCE)
- end
-end
-
-describe :complex_math_cosh_bang, shared: true do
- it "returns the hyperbolic cosine of the passed argument" do
- @object.send(:cosh!, 0.0).should == 1.0
- @object.send(:cosh!, -0.0).should == 1.0
- @object.send(:cosh!, 1.5).should be_close(2.35240961524325, TOLERANCE)
- @object.send(:cosh!, -2.99).should be_close(9.96798496414416, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:cosh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/exp.rb b/spec/ruby/library/cmath/math/shared/exp.rb
deleted file mode 100644
index 6715ac63d3..0000000000
--- a/spec/ruby/library/cmath/math/shared/exp.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_exp, shared: true do
- it "returns the base-e exponential of the passed argument" do
- @object.send(:exp, 0.0).should == 1.0
- @object.send(:exp, -0.0).should == 1.0
- @object.send(:exp, -1.8).should be_close(0.165298888221587, TOLERANCE)
- @object.send(:exp, 1.25).should be_close(3.49034295746184, TOLERANCE)
- end
-
- it "returns the base-e exponential for Complex numbers" do
- @object.send(:exp, Complex(0, 0)).should == Complex(1.0, 0.0)
- @object.send(:exp, Complex(1, 3)).should be_close(Complex(-2.69107861381979, 0.383603953541131), TOLERANCE)
- end
-end
-
-describe :complex_math_exp_bang, shared: true do
- it "returns the base-e exponential of the passed argument" do
- @object.send(:exp!, 0.0).should == 1.0
- @object.send(:exp!, -0.0).should == 1.0
- @object.send(:exp!, -1.8).should be_close(0.165298888221587, TOLERANCE)
- @object.send(:exp!, 1.25).should be_close(3.49034295746184, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:exp!, Complex(1, 3)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/log.rb b/spec/ruby/library/cmath/math/shared/log.rb
deleted file mode 100644
index 4b23e8c5f2..0000000000
--- a/spec/ruby/library/cmath/math/shared/log.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_log, shared: true do
- it "returns the natural logarithm of the passed argument" do
- @object.send(:log, 0.0001).should be_close(-9.21034037197618, TOLERANCE)
- @object.send(:log, 0.000000000001e-15).should be_close(-62.1697975108392, TOLERANCE)
- @object.send(:log, 1).should be_close(0.0, TOLERANCE)
- @object.send(:log, 10).should be_close( 2.30258509299405, TOLERANCE)
- @object.send(:log, 10e15).should be_close(36.8413614879047, TOLERANCE)
- end
-
- it "returns the natural logarithm for Complex numbers" do
- @object.send(:log, Complex(3, 4)).should be_close(Complex(1.6094379124341, 0.927295218001612), TOLERANCE)
- @object.send(:log, Complex(-3, 4)).should be_close(Complex(1.6094379124341, 2.21429743558818), TOLERANCE)
- end
-
- it "returns the natural logarithm for negative numbers as a Complex number" do
- @object.send(:log, -10).should be_close(Complex(2.30258509299405, 3.14159265358979), TOLERANCE)
- @object.send(:log, -20).should be_close(Complex(2.99573227355399, 3.14159265358979), TOLERANCE)
- end
-end
-
-describe :complex_math_log_bang, shared: true do
- it "returns the natural logarithm of the argument" do
- @object.send(:log!, 0.0001).should be_close(-9.21034037197618, TOLERANCE)
- @object.send(:log!, 0.000000000001e-15).should be_close(-62.1697975108392, TOLERANCE)
- @object.send(:log!, 1).should be_close(0.0, TOLERANCE)
- @object.send(:log!, 10).should be_close( 2.30258509299405, TOLERANCE)
- @object.send(:log!, 10e15).should be_close(36.8413614879047, TOLERANCE)
- end
-
- it "raises an Errno::EDOM if the argument is less than 0" do
- -> { @object.send(:log!, -10) }.should raise_error(Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:log!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/log10.rb b/spec/ruby/library/cmath/math/shared/log10.rb
deleted file mode 100644
index f49934d958..0000000000
--- a/spec/ruby/library/cmath/math/shared/log10.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_log10, shared: true do
- it "returns the base-10 logarithm of the passed argument" do
- @object.send(:log10, 0.0001).should be_close(-4.0, TOLERANCE)
- @object.send(:log10, 0.000000000001e-15).should be_close(-27.0, TOLERANCE)
- @object.send(:log10, 1).should be_close(0.0, TOLERANCE)
- @object.send(:log10, 10).should be_close(1.0, TOLERANCE)
- @object.send(:log10, 10e15).should be_close(16.0, TOLERANCE)
- end
-
- it "returns the base-10 logarithm for Complex numbers" do
- @object.send(:log10, Complex(3, 4)).should be_close(Complex(0.698970004336019, 0.402719196273373), TOLERANCE)
- @object.send(:log10, Complex(-3, 4)).should be_close(Complex(0.698970004336019, 0.961657157568468), TOLERANCE)
- end
-
- # BUG: does not work correctly, because Math#log10
- # does not check for negative values
- #it "returns the base-10 logarithm for negative numbers as a Complex number" do
- # @object.send(:log10, -10).should be_close(Complex(2.30258509299405, 3.14159265358979), TOLERANCE)
- # @object.send(:log10, -20).should be_close(Complex(2.99573227355399, 3.14159265358979), TOLERANCE)
- #end
-end
-
-describe :complex_math_log10_bang, shared: true do
- it "returns the base-10 logarithm of the argument" do
- @object.send(:log10!, 0.0001).should be_close(-4.0, TOLERANCE)
- @object.send(:log10!, 0.000000000001e-15).should be_close(-27.0, TOLERANCE)
- @object.send(:log10!, 1).should be_close(0.0, TOLERANCE)
- @object.send(:log10!, 10).should be_close(1.0, TOLERANCE)
- @object.send(:log10!, 10e15).should be_close(16.0, TOLERANCE)
- end
-
- it "raises an Errno::EDOM when the passed argument is negative" do
- -> { @object.send(:log10!, -10) }.should raise_error(Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:log10!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/sin.rb b/spec/ruby/library/cmath/math/shared/sin.rb
deleted file mode 100644
index 1cb1b29cda..0000000000
--- a/spec/ruby/library/cmath/math/shared/sin.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_sin, shared: true do
- it "returns the sine of the passed argument expressed in radians" do
- @object.send(:sin, CMath::PI).should be_close(0.0, TOLERANCE)
- @object.send(:sin, 0).should be_close(0.0, TOLERANCE)
- @object.send(:sin, CMath::PI/2).should be_close(1.0, TOLERANCE)
- @object.send(:sin, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
- @object.send(:sin, 2*Math::PI).should be_close(0.0, TOLERANCE)
- end
-
- it "returns the sine for Complex numbers" do
- @object.send(:sin, Complex(0, CMath::PI)).should be_close(Complex(0.0, 11.5487393572577), TOLERANCE)
- @object.send(:sin, Complex(3, 4)).should be_close(Complex(3.85373803791938, -27.0168132580039), TOLERANCE)
- end
-end
-
-describe :complex_math_sin_bang, shared: true do
- it "returns the sine of the passed argument expressed in radians" do
- @object.send(:sin!, CMath::PI).should be_close(0.0, TOLERANCE)
- @object.send(:sin!, 0).should be_close(0.0, TOLERANCE)
- @object.send(:sin!, CMath::PI/2).should be_close(1.0, TOLERANCE)
- @object.send(:sin!, 3*Math::PI/2).should be_close(-1.0, TOLERANCE)
- @object.send(:sin!, 2*Math::PI).should be_close(0.0, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:sin!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/sinh.rb b/spec/ruby/library/cmath/math/shared/sinh.rb
deleted file mode 100644
index de80a376da..0000000000
--- a/spec/ruby/library/cmath/math/shared/sinh.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_sinh, shared: true do
- it "returns the hyperbolic sin of the argument" do
- @object.send(:sinh, 0.0).should == 0.0
- @object.send(:sinh, -0.0).should == 0.0
- @object.send(:sinh, 1.5).should be_close(2.12927945509482, TOLERANCE)
- @object.send(:sinh, -2.8).should be_close(-8.19191835423591, TOLERANCE)
- end
-
- it "returns the hyperbolic sin for Complex numbers" do
- @object.send(:sinh, Complex(0, CMath::PI)).should be_close(Complex(-0.0, 1.22464679914735e-16), TOLERANCE)
- @object.send(:sinh, Complex(3, 4)).should be_close(Complex(-6.548120040911, -7.61923172032141), TOLERANCE)
- end
-end
-
-describe :complex_math_sinh_bang, shared: true do
- it "returns the hyperbolic sin of the argument" do
- @object.send(:sinh!, 0.0).should == 0.0
- @object.send(:sinh!, -0.0).should == 0.0
- @object.send(:sinh!, 1.5).should be_close(2.12927945509482, TOLERANCE)
- @object.send(:sinh!, -2.8).should be_close(-8.19191835423591, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:sinh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/sqrt.rb b/spec/ruby/library/cmath/math/shared/sqrt.rb
deleted file mode 100644
index 23b1ba48ff..0000000000
--- a/spec/ruby/library/cmath/math/shared/sqrt.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_sqrt, shared: true do
- it "returns the square root for positive numbers" do
- @object.send(:sqrt, 4).should == 2
- @object.send(:sqrt, 19.36).should == 4.4
- end
-
- it "returns the square root for negative numbers" do
- @object.send(:sqrt, -4).should == Complex(0, 2.0)
- @object.send(:sqrt, -19.36).should == Complex(0, 4.4)
- end
-
- it "returns the square root for Complex numbers" do
- @object.send(:sqrt, Complex(4, 5)).should be_close(Complex(2.2806933416653, 1.09615788950152), TOLERANCE)
- @object.send(:sqrt, Complex(4, -5)).should be_close(Complex(2.2806933416653, -1.09615788950152), TOLERANCE)
- end
-end
-
-describe :complex_math_sqrt_bang, shared: true do
- it "returns the square root for positive numbers" do
- @object.send(:sqrt!, 4).should == 2
- @object.send(:sqrt!, 19.36).should == 4.4
- end
-
- it "raises Errno::EDOM when the passed argument is negative" do
- -> { @object.send(:sqrt!, -4) }.should raise_error(Errno::EDOM)
- -> { @object.send(:sqrt!, -19.36) }.should raise_error(Errno::EDOM)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:sqrt!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/tan.rb b/spec/ruby/library/cmath/math/shared/tan.rb
deleted file mode 100644
index 9022c84fc9..0000000000
--- a/spec/ruby/library/cmath/math/shared/tan.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_tan, shared: true do
- it "returns the tangent of the argument" do
- @object.send(:tan, 0.0).should == 0.0
- @object.send(:tan, -0.0).should == -0.0
- @object.send(:tan, 4.22).should be_close(1.86406937682395, TOLERANCE)
- @object.send(:tan, -9.65).should be_close(-0.229109052606441, TOLERANCE)
- end
-
- it "returns the tangent for Complex numbers" do
- @object.send(:tan, Complex(0, CMath::PI)).should be_close(Complex(0.0, 0.99627207622075), TOLERANCE)
- @object.send(:tan, Complex(3, 4)).should be_close(Complex(-0.000187346204629452, 0.999355987381473), TOLERANCE)
- end
-end
-
-describe :complex_math_tan_bang, shared: true do
- it "returns the tangent of the argument" do
- @object.send(:tan!, 0.0).should == 0.0
- @object.send(:tan!, -0.0).should == -0.0
- @object.send(:tan!, 4.22).should be_close(1.86406937682395, TOLERANCE)
- @object.send(:tan!, -9.65).should be_close(-0.229109052606441, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:tan!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/shared/tanh.rb b/spec/ruby/library/cmath/math/shared/tanh.rb
deleted file mode 100644
index f2c9a5abb1..0000000000
--- a/spec/ruby/library/cmath/math/shared/tanh.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../fixtures/classes'
-
-describe :complex_math_tanh, shared: true do
- it "returns the hyperbolic tangent of the argument" do
- @object.send(:tanh, 0.0).should == 0.0
- @object.send(:tanh, -0.0).should == -0.0
- @object.send(:tanh, infinity_value).should == 1.0
- @object.send(:tanh, -infinity_value).should == -1.0
- @object.send(:tanh, 2.5).should be_close(0.98661429815143, TOLERANCE)
- @object.send(:tanh, -4.892).should be_close(-0.999887314427707, TOLERANCE)
- end
-
- it "returns the hyperbolic tangent for Complex numbers" do
- @object.send(:tanh, Complex(0, CMath::PI)).should be_close(Complex(0.0, -1.22464679914735e-16), TOLERANCE)
- @object.send(:tanh, Complex(3, 4)).should be_close(Complex(1.00070953606723, 0.00490825806749599), TOLERANCE)
- end
-end
-
-describe :complex_math_tanh_bang, shared: true do
- it "returns the hyperbolic tangent of the argument" do
- @object.send(:tanh!, 0.0).should == 0.0
- @object.send(:tanh!, -0.0).should == -0.0
- @object.send(:tanh!, infinity_value).should == 1.0
- @object.send(:tanh!, -infinity_value).should == -1.0
- @object.send(:tanh!, 2.5).should be_close(0.98661429815143, TOLERANCE)
- @object.send(:tanh!, -4.892).should be_close(-0.999887314427707, TOLERANCE)
- end
-
- it "raises a TypeError when passed a Complex number" do
- -> { @object.send(:tanh!, Complex(4, 5)) }.should raise_error(TypeError)
- end
-end
diff --git a/spec/ruby/library/cmath/math/sin_spec.rb b/spec/ruby/library/cmath/math/sin_spec.rb
deleted file mode 100644
index b7a219fbbd..0000000000
--- a/spec/ruby/library/cmath/math/sin_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/sin'
-
- describe "Math#sin" do
- it_behaves_like :complex_math_sin, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:sin)
- end
- end
-
- describe "Math.sin" do
- it_behaves_like :complex_math_sin, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/sinh_spec.rb b/spec/ruby/library/cmath/math/sinh_spec.rb
deleted file mode 100644
index c6e6a3baf4..0000000000
--- a/spec/ruby/library/cmath/math/sinh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/sinh'
-
- describe "Math#sinh" do
- it_behaves_like :complex_math_sinh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:sinh)
- end
- end
-
- describe "Math.sinh" do
- it_behaves_like :complex_math_sinh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/sqrt_spec.rb b/spec/ruby/library/cmath/math/sqrt_spec.rb
deleted file mode 100644
index 421824f99c..0000000000
--- a/spec/ruby/library/cmath/math/sqrt_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/sqrt'
-
- describe "Math#sqrt" do
- it_behaves_like :complex_math_sqrt, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:sqrt)
- end
- end
-
- describe "Math.sqrt" do
- it_behaves_like :complex_math_sqrt, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/tan_spec.rb b/spec/ruby/library/cmath/math/tan_spec.rb
deleted file mode 100644
index e2acdd8091..0000000000
--- a/spec/ruby/library/cmath/math/tan_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/tan'
-
- describe "Math#tan" do
- it_behaves_like :complex_math_tan, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:tan)
- end
- end
-
- describe "Math.tan" do
- it_behaves_like :complex_math_tan, :_, CMath
- end
-end
diff --git a/spec/ruby/library/cmath/math/tanh_spec.rb b/spec/ruby/library/cmath/math/tanh_spec.rb
deleted file mode 100644
index 94da20cd51..0000000000
--- a/spec/ruby/library/cmath/math/tanh_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require 'complex'
- require_relative 'shared/tanh'
-
- describe "Math#tanh" do
- it_behaves_like :complex_math_tanh, :_, IncludesMath.new
-
- it "is a private instance method" do
- IncludesMath.should have_private_instance_method(:tanh)
- end
- end
-
- describe "Math.tanh" do
- it_behaves_like :complex_math_tanh, :_, CMath
- end
-end
diff --git a/spec/ruby/library/conditionvariable/broadcast_spec.rb b/spec/ruby/library/conditionvariable/broadcast_spec.rb
deleted file mode 100644
index d88159df23..0000000000
--- a/spec/ruby/library/conditionvariable/broadcast_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require_relative '../../spec_helper'
-require 'thread'
-
-describe "ConditionVariable#broadcast" do
- it "releases all threads waiting in line for this resource" do
- m = Mutex.new
- cv = ConditionVariable.new
- threads = []
- r1 = []
- r2 = []
-
- # large number to attempt to cause race conditions
- 100.times do |i|
- threads << Thread.new(i) do |tid|
- m.synchronize do
- r1 << tid
- cv.wait(m)
- r2 << tid
- end
- end
- end
-
- # wait for all threads to acquire the mutex the first time
- Thread.pass until m.synchronize { r1.size == threads.size }
- # wait until all threads are sleeping (ie waiting)
- Thread.pass until threads.all?(&:stop?)
-
- r2.should be_empty
- m.synchronize do
- cv.broadcast
- end
-
- threads.each {|t| t.join }
-
- # ensure that all threads that enter cv.wait are released
- r2.sort.should == r1.sort
- # note that order is not specified as broadcast results in a race
- # condition on regaining the lock m
- end
-end
diff --git a/spec/ruby/library/conditionvariable/marshal_dump_spec.rb b/spec/ruby/library/conditionvariable/marshal_dump_spec.rb
deleted file mode 100644
index f951a13e28..0000000000
--- a/spec/ruby/library/conditionvariable/marshal_dump_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../spec_helper'
-require 'thread'
-
-describe "ConditionVariable#marshal_dump" do
- it "raises a TypeError" do
- cv = ConditionVariable.new
- -> { cv.marshal_dump }.should raise_error(TypeError, /can't dump/)
- end
-end
diff --git a/spec/ruby/library/conditionvariable/signal_spec.rb b/spec/ruby/library/conditionvariable/signal_spec.rb
deleted file mode 100644
index 86383073f1..0000000000
--- a/spec/ruby/library/conditionvariable/signal_spec.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-require_relative '../../spec_helper'
-require 'thread'
-
-describe "ConditionVariable#signal" do
- it "releases the first thread waiting in line for this resource" do
- m = Mutex.new
- cv = ConditionVariable.new
- threads = []
- r1 = []
- r2 = []
-
- # large number to attempt to cause race conditions
- 100.times do |i|
- threads << Thread.new(i) do |tid|
- m.synchronize do
- r1 << tid
- cv.wait(m)
- r2 << tid
- end
- end
- end
-
- # wait for all threads to acquire the mutex the first time
- Thread.pass until m.synchronize { r1.size == threads.size }
- # wait until all threads are sleeping (ie waiting)
- Thread.pass until threads.all?(&:stop?)
-
- r2.should be_empty
- 100.times do |i|
- m.synchronize do
- cv.signal
- end
- Thread.pass until r2.size == i+1
- end
-
- threads.each {|t| t.join }
-
- # ensure that all the threads that went into the cv.wait are
- # released in the same order
- r2.should == r1
- end
-
- it "allows control to be passed between a pair of threads" do
- m = Mutex.new
- cv = ConditionVariable.new
- repeats = 100
- in_synchronize = false
-
- t1 = Thread.new do
- m.synchronize do
- in_synchronize = true
- repeats.times do
- cv.wait(m)
- cv.signal
- end
- end
- end
-
- # Make sure t1 is waiting for a signal before launching t2.
- Thread.pass until in_synchronize
- Thread.pass until t1.stop?
-
- t2 = Thread.new do
- m.synchronize do
- repeats.times do
- cv.signal
- cv.wait(m)
- end
- end
- end
-
- # Check that both threads terminated without exception
- t1.join
- t2.join
- m.should_not.locked?
- end
-end
diff --git a/spec/ruby/library/conditionvariable/wait_spec.rb b/spec/ruby/library/conditionvariable/wait_spec.rb
deleted file mode 100644
index 9a68c2b5a1..0000000000
--- a/spec/ruby/library/conditionvariable/wait_spec.rb
+++ /dev/null
@@ -1,175 +0,0 @@
-require_relative '../../spec_helper'
-require 'thread'
-
-describe "ConditionVariable#wait" do
- it "calls #sleep on the given object" do
- o = Object.new
- o.should_receive(:sleep).with(1234)
-
- cv = ConditionVariable.new
-
- cv.wait(o, 1234)
- end
-
- it "can be woken up by ConditionVariable#signal" do
- m = Mutex.new
- cv = ConditionVariable.new
- in_synchronize = false
-
- th = Thread.new do
- m.synchronize do
- in_synchronize = true
- cv.wait(m)
- end
- :success
- end
-
- # wait for m to acquire the mutex
- Thread.pass until in_synchronize
- # wait until th is sleeping (ie waiting)
- Thread.pass until th.stop?
-
- m.synchronize { cv.signal }
- th.value.should == :success
- end
-
- it "can be interrupted by Thread#run" do
- m = Mutex.new
- cv = ConditionVariable.new
- in_synchronize = false
-
- th = Thread.new do
- m.synchronize do
- in_synchronize = true
- cv.wait(m)
- end
- :success
- end
-
- # wait for m to acquire the mutex
- Thread.pass until in_synchronize
- # wait until th is sleeping (ie waiting)
- Thread.pass until th.stop?
-
- th.run
- th.value.should == :success
- end
-
- it "can be interrupted by Thread#wakeup" do
- m = Mutex.new
- cv = ConditionVariable.new
- in_synchronize = false
-
- th = Thread.new do
- m.synchronize do
- in_synchronize = true
- cv.wait(m)
- end
- :success
- end
-
- # wait for m to acquire the mutex
- Thread.pass until in_synchronize
- # wait until th is sleeping (ie waiting)
- Thread.pass until th.stop?
-
- th.wakeup
- th.value.should == :success
- end
-
- it "reacquires the lock even if the thread is killed" do
- m = Mutex.new
- cv = ConditionVariable.new
- in_synchronize = false
- owned = nil
-
- th = Thread.new do
- m.synchronize do
- in_synchronize = true
- begin
- cv.wait(m)
- ensure
- owned = m.owned?
- $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned
- end
- end
- end
-
- # wait for m to acquire the mutex
- Thread.pass until in_synchronize
- # wait until th is sleeping (ie waiting)
- Thread.pass until th.stop?
-
- th.kill
- th.join
-
- owned.should == true
- end
-
- it "reacquires the lock even if the thread is killed after being signaled" do
- m = Mutex.new
- cv = ConditionVariable.new
- in_synchronize = false
- owned = nil
-
- th = Thread.new do
- m.synchronize do
- in_synchronize = true
- begin
- cv.wait(m)
- ensure
- owned = m.owned?
- $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned
- end
- end
- end
-
- # wait for m to acquire the mutex
- Thread.pass until in_synchronize
- # wait until th is sleeping (ie waiting)
- Thread.pass until th.stop?
-
- m.synchronize {
- cv.signal
- # Wait that the thread is blocked on acquiring the Mutex
- sleep 0.001
- # Kill the thread, yet the thread should first acquire the Mutex before going on
- th.kill
- }
-
- th.join
- owned.should == true
- end
-
- it "supports multiple Threads waiting on the same ConditionVariable and Mutex" do
- m = Mutex.new
- cv = ConditionVariable.new
- n_threads = 4
- events = []
-
- threads = n_threads.times.map {
- Thread.new {
- m.synchronize {
- events << :t_in_synchronize
- cv.wait(m)
- }
- }
- }
-
- Thread.pass until m.synchronize { events.size } == n_threads
- Thread.pass until threads.any?(&:stop?)
- m.synchronize do
- threads.each { |t|
- # Cause interactions with the waiting threads.
- # On TruffleRuby, this causes a safepoint which has interesting
- # interactions with the ConditionVariable.
- bt = t.backtrace
- bt.should be_kind_of(Array)
- bt.size.should >= 2
- }
- end
-
- cv.broadcast
- threads.each(&:join)
- end
-end
diff --git a/spec/ruby/library/coverage/result_spec.rb b/spec/ruby/library/coverage/result_spec.rb
index 6cf5be1346..33276778e8 100644
--- a/spec/ruby/library/coverage/result_spec.rb
+++ b/spec/ruby/library/coverage/result_spec.rb
@@ -8,10 +8,16 @@ describe 'Coverage.result' do
@eval_code_file = fixture __FILE__, 'eval_code.rb'
end
+ before :each do
+ Coverage.running?.should == false
+ end
+
after :each do
$LOADED_FEATURES.delete(@class_file)
$LOADED_FEATURES.delete(@config_file)
$LOADED_FEATURES.delete(@eval_code_file)
+
+ Coverage.result if Coverage.running?
end
it 'gives the covered files as a hash with arrays of count or nil' do
@@ -26,6 +32,41 @@ describe 'Coverage.result' do
}
end
+ ruby_version_is "3.2" do
+ it 'returns results for each mode separately when enabled :all modes' do
+ Coverage.start(:all)
+ require @class_file.chomp('.rb')
+ result = Coverage.result
+
+ result.should == {
+ @class_file => {
+ lines: [
+ nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
+ ],
+ branches: {},
+ methods: {
+ [SomeClass, :some_method, 6, 2, 11, 5] => 0
+ }
+ }
+ }
+ end
+
+ it 'returns results for each mode separately when enabled any mode explicitly' do
+ Coverage.start(lines: true)
+ require @class_file.chomp('.rb')
+ result = Coverage.result
+
+ result.should == {
+ @class_file =>
+ {
+ lines: [
+ nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
+ ]
+ }
+ }
+ end
+ end
+
it 'no requires/loads should give empty hash' do
Coverage.start
result = Coverage.result
@@ -65,12 +106,14 @@ describe 'Coverage.result' do
result.should == {}
end
- it 'second Coverage.start does nothing' do
- Coverage.start
- require @config_file.chomp('.rb')
- result = Coverage.result
+ ruby_version_is ''...'3.1' do
+ it 'second Coverage.start does nothing' do
+ Coverage.start
+ require @config_file.chomp('.rb')
+ result = Coverage.result
- result.should == { @config_file => [1, 1, 1] }
+ result.should == { @config_file => [1, 1, 1] }
+ end
end
it 'does not include the file starting coverage since it is not tracked' do
@@ -78,15 +121,237 @@ describe 'Coverage.result' do
Coverage.result.should_not include(@config_file)
end
- it 'returns the correct results when eval is used' do
- Coverage.start
- require @eval_code_file.chomp('.rb')
- result = Coverage.result
+ ruby_version_is '3.1'...'3.2' do
+ it 'returns the correct results when eval is used' do
+ Coverage.start
+ require @eval_code_file.chomp('.rb')
+ result = Coverage.result
- result.should == {
+ result.should == {
@eval_code_file => [
- 1, nil, 1, nil, 1, nil, nil, nil, nil, nil, 1
+ 1, nil, 1, nil, 1, nil, nil, nil, nil, nil, 1
]
+ }
+ end
+ end
+
+ ruby_version_is '3.2' do
+ it 'returns the correct results when eval coverage is enabled' do
+ Coverage.supported?(:eval).should == true
+
+ Coverage.start(lines: true, eval: true)
+ require @eval_code_file.chomp('.rb')
+ result = Coverage.result
+
+ result.should == {
+ @eval_code_file => {
+ lines: [1, nil, 1, nil, 1, 1, nil, nil, nil, nil, 1]
+ }
+ }
+ end
+
+ it 'returns the correct results when eval coverage is disabled' do
+ Coverage.supported?(:eval).should == true
+
+ Coverage.start(lines: true, eval: false)
+ require @eval_code_file.chomp('.rb')
+ result = Coverage.result
+
+ result.should == {
+ @eval_code_file => {
+ lines: [1, nil, 1, nil, 1, nil, nil, nil, nil, nil, 1]
+ }
+ }
+ end
+ end
+
+ it "disables coverage measurement when stop option is not specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result
+ Coverage.running?.should == false
+ end
+
+ it "disables coverage measurement when stop: true option is specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ -> {
+ Coverage.result(stop: true)
+ }.should complain(/warning: stop implies clear/)
+
+ Coverage.running?.should == false
+ end
+
+ it "does not disable coverage measurement when stop: false option is specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result(stop: false)
+ Coverage.running?.should == true
+ end
+
+ it "does not disable coverage measurement when stop option is not specified but clear: true specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result(clear: true)
+ Coverage.running?.should == true
+ end
+
+ it "does not disable coverage measurement when stop option is not specified but clear: false specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result(clear: false)
+ Coverage.running?.should == true
+ end
+
+ it "disables coverage measurement when stop: true and clear: true specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result(stop: true, clear: true)
+ Coverage.running?.should == false
+ end
+
+ it "disables coverage measurement when stop: true and clear: false specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ -> {
+ Coverage.result(stop: true, clear: false)
+ }.should complain(/warning: stop implies clear/)
+
+ Coverage.running?.should == false
+ end
+
+ it "does not disable coverage measurement when stop: false and clear: true specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result(stop: false, clear: true)
+ Coverage.running?.should == true
+ end
+
+ it "does not disable coverage measurement when stop: false and clear: false specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result(stop: false, clear: false)
+ Coverage.running?.should == true
+ end
+
+ it "resets counters (remove them) when stop: true specified but clear option is not specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ -> {
+ Coverage.result(stop: true) # clears counters
+ }.should complain(/warning: stop implies clear/)
+
+ Coverage.start
+ Coverage.peek_result.should == {}
+ end
+
+ it "resets counters (remove them) when stop: true and clear: true specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result(stop: true, clear: true) # clears counters
+
+ Coverage.start
+ Coverage.peek_result.should == {}
+ end
+
+ it "resets counters (remove them) when stop: true and clear: false specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ -> {
+ Coverage.result(stop: true, clear: false) # clears counters
+ }.should complain(/warning: stop implies clear/)
+
+ Coverage.start
+ Coverage.peek_result.should == {}
+ end
+
+ it "resets counters (remove them) when both stop and clear options are not specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result # clears counters
+
+ Coverage.start
+ Coverage.peek_result.should == {}
+ end
+
+ it "clears counters (sets 0 values) when stop is not specified but clear: true specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result(clear: true) # clears counters
+
+ Coverage.peek_result.should == {
+ @class_file => [
+ nil, nil, 0, nil, nil, 0, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
+ ]
}
end
+
+ it "does not clear counters when stop is not specified but clear: false specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ result = Coverage.result(clear: false) # doesn't clear counters
+ result.should == {
+ @class_file => [
+ nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
+ ]
+ }
+
+ Coverage.peek_result.should == result
+ end
+
+ it "does not clear counters when stop: false and clear is not specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ result = Coverage.result(stop: false) # doesn't clear counters
+ result.should == {
+ @class_file => [
+ nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
+ ]
+ }
+
+ Coverage.peek_result.should == result
+ end
+
+ it "clears counters (sets 0 values) when stop: false and clear: true specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ Coverage.result(stop: false, clear: true) # clears counters
+
+ Coverage.peek_result.should == {
+ @class_file => [
+ nil, nil, 0, nil, nil, 0, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
+ ]
+ }
+ end
+
+ it "does not clear counters when stop: false and clear: false specified" do
+ Coverage.start
+ require @class_file.chomp('.rb')
+
+ result = Coverage.result(stop: false, clear: false) # doesn't clear counters
+ result.should == {
+ @class_file => [
+ nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil
+ ]
+ }
+
+ Coverage.peek_result.should == result
+ end
end
diff --git a/spec/ruby/library/coverage/running_spec.rb b/spec/ruby/library/coverage/running_spec.rb
new file mode 100644
index 0000000000..e9cc7ada5a
--- /dev/null
+++ b/spec/ruby/library/coverage/running_spec.rb
@@ -0,0 +1,20 @@
+require_relative '../../spec_helper'
+require 'coverage'
+
+describe 'Coverage.running?' do
+ it "returns false if coverage is not started" do
+ Coverage.running?.should == false
+ end
+
+ it "returns true if coverage is started" do
+ Coverage.start
+ Coverage.running?.should == true
+ Coverage.result
+ end
+
+ it "returns false if coverage was started and stopped" do
+ Coverage.start
+ Coverage.result
+ Coverage.running?.should == false
+ end
+end
diff --git a/spec/ruby/library/coverage/start_spec.rb b/spec/ruby/library/coverage/start_spec.rb
index ddfad8b47c..7fccf2d5cf 100644
--- a/spec/ruby/library/coverage/start_spec.rb
+++ b/spec/ruby/library/coverage/start_spec.rb
@@ -2,5 +2,90 @@ require_relative '../../spec_helper'
require 'coverage'
describe 'Coverage.start' do
- it 'needs to be reviewed for spec completeness'
+ before :each do
+ Coverage.should_not.running?
+ end
+
+ after :each do
+ Coverage.result(stop: true, clear: true) if Coverage.running?
+ end
+
+ it "enables the coverage measurement" do
+ Coverage.start
+ Coverage.should.running?
+ end
+
+ it "returns nil" do
+ Coverage.start.should == nil
+ end
+
+ ruby_version_is '3.1' do
+ it 'raises error when repeated Coverage.start call happens' do
+ Coverage.start
+
+ -> {
+ Coverage.start
+ }.should raise_error(RuntimeError, 'coverage measurement is already setup')
+ end
+ end
+
+ ruby_version_is '3.2' do
+ it "accepts :all optional argument" do
+ Coverage.start(:all)
+ Coverage.should.running?
+ end
+
+ it "accepts lines: optional keyword argument" do
+ Coverage.start(lines: true)
+ Coverage.should.running?
+ end
+
+ it "accepts branches: optional keyword argument" do
+ Coverage.start(branches: true)
+ Coverage.should.running?
+ end
+
+ it "accepts methods: optional keyword argument" do
+ Coverage.start(methods: true)
+ Coverage.should.running?
+ end
+
+ it "accepts eval: optional keyword argument" do
+ Coverage.start(eval: true)
+ Coverage.should.running?
+ end
+
+ it "accepts oneshot_lines: optional keyword argument" do
+ Coverage.start(oneshot_lines: true)
+ Coverage.should.running?
+ end
+
+ it "ignores unknown keyword arguments" do
+ Coverage.start(foo: true)
+ Coverage.should.running?
+ end
+
+ it "expects a Hash if not passed :all" do
+ -> {
+ Coverage.start(42)
+ }.should raise_error(TypeError, "no implicit conversion of Integer into Hash")
+ end
+
+ it "does not accept both lines: and oneshot_lines: keyword arguments" do
+ -> {
+ Coverage.start(lines: true, oneshot_lines: true)
+ }.should raise_error(RuntimeError, "cannot enable lines and oneshot_lines simultaneously")
+ end
+
+ it "enables the coverage measurement if passed options with `false` value" do
+ Coverage.start(lines: false, branches: false, methods: false, eval: false, oneshot_lines: false)
+ Coverage.should.running?
+ end
+
+ it "measures coverage within eval" do
+ Coverage.start(lines: true, eval: true)
+ eval("Object.new\n"*3, binding, "test.rb", 1)
+ Coverage.result["test.rb"].should == {lines: [1, 1, 1]}
+ end
+ end
end
diff --git a/spec/ruby/library/coverage/supported_spec.rb b/spec/ruby/library/coverage/supported_spec.rb
new file mode 100644
index 0000000000..78b3784ee0
--- /dev/null
+++ b/spec/ruby/library/coverage/supported_spec.rb
@@ -0,0 +1,32 @@
+require_relative '../../spec_helper'
+require 'coverage'
+
+describe "Coverage.supported?" do
+ ruby_version_is "3.2" do
+ it "returns true or false if coverage measurement is supported for the given mode" do
+ [true, false].should.include?(Coverage.supported?(:lines))
+ [true, false].should.include?(Coverage.supported?(:branches))
+ [true, false].should.include?(Coverage.supported?(:methods))
+ [true, false].should.include?(Coverage.supported?(:eval))
+ end
+
+ it "returns false for not existing modes" do
+ Coverage.supported?(:foo).should == false
+ Coverage.supported?(:bar).should == false
+ end
+
+ it "raise TypeError if argument is not Symbol" do
+ -> {
+ Coverage.supported?("lines")
+ }.should raise_error(TypeError, "wrong argument type String (expected Symbol)")
+
+ -> {
+ Coverage.supported?([])
+ }.should raise_error(TypeError, "wrong argument type Array (expected Symbol)")
+
+ -> {
+ Coverage.supported?(1)
+ }.should raise_error(TypeError, "wrong argument type Integer (expected Symbol)")
+ end
+ end
+end
diff --git a/spec/ruby/library/csv/generate_spec.rb b/spec/ruby/library/csv/generate_spec.rb
index 0a1e3d9604..b45e2eb95b 100644
--- a/spec/ruby/library/csv/generate_spec.rb
+++ b/spec/ruby/library/csv/generate_spec.rb
@@ -21,7 +21,7 @@ describe "CSV.generate" do
end
it "appends and returns the argument itself" do
- str = ""
+ str = +""
csv_str = CSV.generate(str) do |csv|
csv.add_row [1, 2, 3]
csv << [4, 5, 6]
diff --git a/spec/ruby/library/date/civil_spec.rb b/spec/ruby/library/date/civil_spec.rb
index f3537c2f84..1c780fce56 100644
--- a/spec/ruby/library/date/civil_spec.rb
+++ b/spec/ruby/library/date/civil_spec.rb
@@ -2,11 +2,6 @@ require_relative '../../spec_helper'
require_relative 'shared/civil'
require 'date'
-describe "Date#civil" do
- it_behaves_like :date_civil, :civil
-end
-
-
describe "Date.civil" do
- it "needs to be reviewed for spec completeness"
+ it_behaves_like :date_civil, :civil
end
diff --git a/spec/ruby/library/date/deconstruct_keys_spec.rb b/spec/ruby/library/date/deconstruct_keys_spec.rb
new file mode 100644
index 0000000000..92579e35c7
--- /dev/null
+++ b/spec/ruby/library/date/deconstruct_keys_spec.rb
@@ -0,0 +1,44 @@
+require_relative '../../spec_helper'
+require 'date'
+date_version = defined?(Date::VERSION) ? Date::VERSION : '3.1.0'
+
+version_is date_version, "3.3" do #ruby_version_is "3.2" do
+ describe "Date#deconstruct_keys" do
+ it "returns whole hash for nil as an argument" do
+ d = Date.new(2022, 10, 5)
+ d.deconstruct_keys(nil).should == { year: 2022, month: 10, day: 5, yday: 278, wday: 3 }
+ end
+
+ it "returns only specified keys" do
+ d = Date.new(2022, 10, 5)
+ d.deconstruct_keys([:year, :month]).should == { year: 2022, month: 10 }
+ end
+
+ it "requires one argument" do
+ -> {
+ Date.new(2022, 10, 5).deconstruct_keys
+ }.should raise_error(ArgumentError)
+ end
+
+ it "it raises error when argument is neither nil nor array" do
+ d = Date.new(2022, 10, 5)
+
+ -> { d.deconstruct_keys(1) }.should raise_error(TypeError, "wrong argument type Integer (expected Array or nil)")
+ -> { d.deconstruct_keys("asd") }.should raise_error(TypeError, "wrong argument type String (expected Array or nil)")
+ -> { d.deconstruct_keys(:x) }.should raise_error(TypeError, "wrong argument type Symbol (expected Array or nil)")
+ -> { d.deconstruct_keys({}) }.should raise_error(TypeError, "wrong argument type Hash (expected Array or nil)")
+ end
+
+ it "returns {} when passed []" do
+ Date.new(2022, 10, 5).deconstruct_keys([]).should == {}
+ end
+
+ it "ignores non-Symbol keys" do
+ Date.new(2022, 10, 5).deconstruct_keys(['year', []]).should == {}
+ end
+
+ it "ignores not existing Symbol keys" do
+ Date.new(2022, 10, 5).deconstruct_keys([:year, :a]).should == { year: 2022 }
+ end
+ end
+end
diff --git a/spec/ruby/library/date/iso8601_spec.rb b/spec/ruby/library/date/iso8601_spec.rb
index 2c698db514..af66845a6b 100644
--- a/spec/ruby/library/date/iso8601_spec.rb
+++ b/spec/ruby/library/date/iso8601_spec.rb
@@ -17,18 +17,21 @@ describe "Date.iso8601" do
d.should == Date.civil(-4712, 1, 1)
end
- it "parses a Symbol into a Date object" do
- d = Date.iso8601(:'2015-10-15')
- d.should == Date.civil(2015, 10, 15)
- end
-
it "parses a StringSubclass into a Date object" do
d = Date.iso8601(Class.new(String).new("-4712-01-01"))
d.should == Date.civil(-4712, 1, 1)
end
- it "raises an ArgumentError when passed a Symbol without a valid Date" do
- -> { Date.iso8601(:test) }.should raise_error(ArgumentError)
+ it "raises a Date::Error if the argument is a invalid Date" do
+ -> {
+ Date.iso8601('invalid')
+ }.should raise_error(Date::Error, "invalid date")
+ end
+
+ it "raises a Date::Error when passed a nil" do
+ -> {
+ Date.iso8601(nil)
+ }.should raise_error(Date::Error, "invalid date")
end
it "raises a TypeError when passed an Object" do
@@ -41,4 +44,13 @@ describe "Date._iso8601" do
h = Date._iso8601('invalid')
h.should == {}
end
+
+ it "returns an empty hash if the argument is nil" do
+ h = Date._iso8601(nil)
+ h.should == {}
+ end
+
+ it "raises a TypeError when passed an Object" do
+ -> { Date._iso8601(Object.new) }.should raise_error(TypeError)
+ end
end
diff --git a/spec/ruby/library/date/new_spec.rb b/spec/ruby/library/date/new_spec.rb
index 18120118c0..cb64cabce6 100644
--- a/spec/ruby/library/date/new_spec.rb
+++ b/spec/ruby/library/date/new_spec.rb
@@ -1,7 +1,6 @@
require 'date'
require_relative '../../spec_helper'
require_relative 'shared/civil'
-require_relative 'shared/new_bang'
describe "Date.new" do
it_behaves_like :date_civil, :new
diff --git a/spec/ruby/library/date/parse_spec.rb b/spec/ruby/library/date/parse_spec.rb
index ef72ba3f4e..5ef4f6e9b5 100644
--- a/spec/ruby/library/date/parse_spec.rb
+++ b/spec/ruby/library/date/parse_spec.rb
@@ -67,7 +67,7 @@ describe "Date#parse" do
it "raises a TypeError trying to parse non-String-like object" do
-> { Date.parse(1) }.should raise_error(TypeError)
- -> { Date.parse(:invalid) }.should raise_error(TypeError)
+ -> { Date.parse([]) }.should raise_error(TypeError)
end
it "coerces using to_str" do
@@ -93,7 +93,7 @@ describe "Date#parse with '.' separator" do
@sep = '.'
end
- it_should_behave_like "date_parse"
+ it_should_behave_like :date_parse
end
describe "Date#parse with '/' separator" do
@@ -101,7 +101,7 @@ describe "Date#parse with '/' separator" do
@sep = '/'
end
- it_should_behave_like "date_parse"
+ it_should_behave_like :date_parse
end
describe "Date#parse with ' ' separator" do
@@ -109,7 +109,7 @@ describe "Date#parse with ' ' separator" do
@sep = ' '
end
- it_should_behave_like "date_parse"
+ it_should_behave_like :date_parse
end
describe "Date#parse with '/' separator US-style" do
@@ -117,7 +117,7 @@ describe "Date#parse with '/' separator US-style" do
@sep = '/'
end
- it_should_behave_like "date_parse_us"
+ it_should_behave_like :date_parse_us
end
describe "Date#parse with '-' separator EU-style" do
@@ -125,7 +125,7 @@ describe "Date#parse with '-' separator EU-style" do
@sep = '-'
end
- it_should_behave_like "date_parse_eu"
+ it_should_behave_like :date_parse_eu
end
describe "Date#parse(.)" do
diff --git a/spec/ruby/library/date/shared/new_bang.rb b/spec/ruby/library/date/shared/new_bang.rb
deleted file mode 100644
index 90f1b432f0..0000000000
--- a/spec/ruby/library/date/shared/new_bang.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-describe :date_new_bang, shared: true do
-
- it "returns a new Date object set to Astronomical Julian Day 0 if no arguments passed" do
- d = Date.send(@method)
- d.ajd.should == 0
- end
-
- it "accepts astronomical julian day number, offset as a fraction of a day and returns a new Date object" do
- d = Date.send(@method, 10, 0.5)
- d.ajd.should == 10
- d.jd.should == 11
- end
-
-end
diff --git a/spec/ruby/library/date/shared/parse.rb b/spec/ruby/library/date/shared/parse.rb
index 1015285e04..40af908386 100644
--- a/spec/ruby/library/date/shared/parse.rb
+++ b/spec/ruby/library/date/shared/parse.rb
@@ -13,7 +13,7 @@ describe :date_parse, shared: true do
d.day.should == 23
end
- it "can parse a 'mmm DD YYYY' string into a Date object" do
+ it "can parse a 'DD mmm YYYY' string into a Date object" do
d = Date.parse("23#{@sep}feb#{@sep}2008")
d.year.should == 2008
d.month.should == 2
@@ -42,7 +42,7 @@ describe :date_parse, shared: true do
d.should == Date.civil(2005, 11, 5)
end
- it "can parse a year, day and month name into a Date object" do
+ it "can parse a day, month name and year into a Date object" do
d = Date.parse("5th#{@sep}november#{@sep}2005")
d.should == Date.civil(2005, 11, 5)
end
diff --git a/spec/ruby/library/date/shared/parse_eu.rb b/spec/ruby/library/date/shared/parse_eu.rb
index ecb15e3c0e..3819524a57 100644
--- a/spec/ruby/library/date/shared/parse_eu.rb
+++ b/spec/ruby/library/date/shared/parse_eu.rb
@@ -7,28 +7,28 @@ describe :date_parse_eu, shared: true do
d.day.should == 1
end
- it "can parse a MM-DD-YYYY string into a Date object" do
+ it "can parse a DD-MM-YYYY string into a Date object" do
d = Date.parse("10#{@sep}01#{@sep}2007")
d.year.should == 2007
d.month.should == 1
d.day.should == 10
end
- it "can parse a MM-DD-YY string into a Date object" do
+ it "can parse a YY-MM-DD string into a Date object" do
d = Date.parse("10#{@sep}01#{@sep}07")
d.year.should == 2010
d.month.should == 1
d.day.should == 7
end
- it "can parse a MM-DD-YY string into a Date object NOT using the year digits as 20XX" do
+ it "can parse a YY-MM-DD string into a Date object NOT using the year digits as 20XX" do
d = Date.parse("10#{@sep}01#{@sep}07", false)
d.year.should == 10
d.month.should == 1
d.day.should == 7
end
- it "can parse a MM-DD-YY string into a Date object using the year digits as 20XX" do
+ it "can parse a YY-MM-DD string into a Date object using the year digits as 20XX" do
d = Date.parse("10#{@sep}01#{@sep}07", true)
d.year.should == 2010
d.month.should == 1
diff --git a/spec/ruby/library/date/shared/parse_us.rb b/spec/ruby/library/date/shared/parse_us.rb
index 7be62b1af1..17e2fc96c1 100644
--- a/spec/ruby/library/date/shared/parse_us.rb
+++ b/spec/ruby/library/date/shared/parse_us.rb
@@ -6,28 +6,28 @@ describe :date_parse_us, shared: true do
d.day.should == 1
end
- it "parses a MM#{@sep}DD#{@sep}YYYY string into a Date object" do
+ it "parses a DD#{@sep}MM#{@sep}YYYY string into a Date object" do
d = Date.parse("10#{@sep}01#{@sep}2007")
d.year.should == 2007
d.month.should == 1
d.day.should == 10
end
- it "parses a MM#{@sep}DD#{@sep}YY string into a Date object" do
+ it "parses a YY#{@sep}MM#{@sep}DD string into a Date object" do
d = Date.parse("10#{@sep}01#{@sep}07")
d.year.should == 2010
d.month.should == 1
d.day.should == 7
end
- it "parses a MM#{@sep}DD#{@sep}YY string into a Date object NOT using the year digits as 20XX" do
+ it "parses a YY#{@sep}MM#{@sep}DD string into a Date object NOT using the year digits as 20XX" do
d = Date.parse("10#{@sep}01#{@sep}07", false)
d.year.should == 10
d.month.should == 1
d.day.should == 7
end
- it "parses a MM#{@sep}DD#{@sep}YY string into a Date object using the year digits as 20XX" do
+ it "parses a YY#{@sep}MM#{@sep}DD string into a Date object using the year digits as 20XX" do
d = Date.parse("10#{@sep}01#{@sep}07", true)
d.year.should == 2010
d.month.should == 1
diff --git a/spec/ruby/library/date/shared/valid_jd.rb b/spec/ruby/library/date/shared/valid_jd.rb
index f6ca3f579d..e474dfb450 100644
--- a/spec/ruby/library/date/shared/valid_jd.rb
+++ b/spec/ruby/library/date/shared/valid_jd.rb
@@ -10,23 +10,11 @@ describe :date_valid_jd?, shared: true do
Date.send(@method, nil).should be_false
end
- ruby_version_is ''...'2.7' do
- it "returns true if passed symbol" do
- Date.send(@method, :number).should be_true
- end
-
- it "returns true if passed false" do
- Date.send(@method, false).should be_true
- end
+ it "returns false if passed symbol" do
+ Date.send(@method, :number).should be_false
end
- ruby_version_is '2.7' do
- it "returns false if passed symbol" do
- Date.send(@method, :number).should be_false
- end
-
- it "returns false if passed false" do
- Date.send(@method, false).should be_false
- end
+ it "returns false if passed false" do
+ Date.send(@method, false).should be_false
end
end
diff --git a/spec/ruby/library/date/strftime_spec.rb b/spec/ruby/library/date/strftime_spec.rb
index 9d298e42e6..b5232a2073 100644
--- a/spec/ruby/library/date/strftime_spec.rb
+++ b/spec/ruby/library/date/strftime_spec.rb
@@ -1,5 +1,7 @@
+require_relative "../../spec_helper"
require 'date'
require_relative '../../shared/time/strftime_for_date'
+date_version = defined?(Date::VERSION) ? Date::VERSION : '3.1.0'
describe "Date#strftime" do
before :all do
@@ -22,9 +24,18 @@ describe "Date#strftime" do
end
# %v is %e-%b-%Y for Date/DateTime
- it "should be able to show the commercial week" do
- @date.strftime("%v").should == " 9-Apr-2000"
- @date.strftime("%v").should == @date.strftime('%e-%b-%Y')
+ version_is date_version, ""..."3.2" do #ruby_version_is ""..."3.1" do
+ it "should be able to show the commercial week" do
+ @date.strftime("%v").should == " 9-Apr-2000"
+ @date.strftime("%v").should == @date.strftime('%e-%b-%Y')
+ end
+ end
+
+ version_is date_version, "3.2" do #ruby_version_is "3.1" do
+ it "should be able to show the commercial week" do
+ @date.strftime("%v").should == " 9-APR-2000"
+ @date.strftime("%v").should != @date.strftime('%e-%b-%Y')
+ end
end
# additional conversion specifiers only in Date/DateTime
diff --git a/spec/ruby/library/datetime/deconstruct_keys_spec.rb b/spec/ruby/library/datetime/deconstruct_keys_spec.rb
new file mode 100644
index 0000000000..77ceaa51c4
--- /dev/null
+++ b/spec/ruby/library/datetime/deconstruct_keys_spec.rb
@@ -0,0 +1,46 @@
+require_relative '../../spec_helper'
+require 'date'
+date_version = defined?(Date::VERSION) ? Date::VERSION : '3.1.0'
+
+version_is date_version, "3.3" do #ruby_version_is "3.2" do
+ describe "DateTime#deconstruct_keys" do
+ it "returns whole hash for nil as an argument" do
+ d = DateTime.new(2022, 10, 5, 13, 30)
+ res = { year: 2022, month: 10, day: 5, yday: 278, wday: 3, hour: 13,
+ min: 30, sec: 0, sec_fraction: (0/1), zone: "+00:00" }
+ d.deconstruct_keys(nil).should == res
+ end
+
+ it "returns only specified keys" do
+ d = DateTime.new(2022, 10, 5, 13, 39)
+ d.deconstruct_keys([:zone, :hour]).should == { zone: "+00:00", hour: 13 }
+ end
+
+ it "requires one argument" do
+ -> {
+ DateTime.new(2022, 10, 5, 13, 30).deconstruct_keys
+ }.should raise_error(ArgumentError)
+ end
+
+ it "it raises error when argument is neither nil nor array" do
+ d = DateTime.new(2022, 10, 5, 13, 30)
+
+ -> { d.deconstruct_keys(1) }.should raise_error(TypeError, "wrong argument type Integer (expected Array or nil)")
+ -> { d.deconstruct_keys("asd") }.should raise_error(TypeError, "wrong argument type String (expected Array or nil)")
+ -> { d.deconstruct_keys(:x) }.should raise_error(TypeError, "wrong argument type Symbol (expected Array or nil)")
+ -> { d.deconstruct_keys({}) }.should raise_error(TypeError, "wrong argument type Hash (expected Array or nil)")
+ end
+
+ it "returns {} when passed []" do
+ DateTime.new(2022, 10, 5, 13, 30).deconstruct_keys([]).should == {}
+ end
+
+ it "ignores non-Symbol keys" do
+ DateTime.new(2022, 10, 5, 13, 30).deconstruct_keys(['year', []]).should == {}
+ end
+
+ it "ignores not existing Symbol keys" do
+ DateTime.new(2022, 10, 5, 13, 30).deconstruct_keys([:year, :a]).should == { year: 2022 }
+ end
+ end
+end
diff --git a/spec/ruby/library/datetime/rfc2822_spec.rb b/spec/ruby/library/datetime/rfc2822_spec.rb
index 70bfca60b4..83f7fa8d5b 100644
--- a/spec/ruby/library/datetime/rfc2822_spec.rb
+++ b/spec/ruby/library/datetime/rfc2822_spec.rb
@@ -3,4 +3,8 @@ require 'date'
describe "DateTime.rfc2822" do
it "needs to be reviewed for spec completeness"
+
+ it "raises DateError if passed nil" do
+ -> { DateTime.rfc2822(nil) }.should raise_error(Date::Error, "invalid date")
+ end
end
diff --git a/spec/ruby/library/datetime/strftime_spec.rb b/spec/ruby/library/datetime/strftime_spec.rb
index 1c925f92eb..abb0838e8e 100644
--- a/spec/ruby/library/datetime/strftime_spec.rb
+++ b/spec/ruby/library/datetime/strftime_spec.rb
@@ -1,6 +1,8 @@
+require_relative '../../spec_helper'
require 'date'
require_relative '../../shared/time/strftime_for_date'
require_relative '../../shared/time/strftime_for_time'
+date_version = defined?(Date::VERSION) ? Date::VERSION : '3.1.0'
describe "DateTime#strftime" do
before :all do
@@ -32,9 +34,18 @@ describe "DateTime#strftime" do
end
# %v is %e-%b-%Y for Date/DateTime
- it "should be able to show the commercial week" do
- @time.strftime("%v").should == " 3-Feb-2001"
- @time.strftime("%v").should == @time.strftime('%e-%b-%Y')
+ version_is date_version, ""..."3.2" do #ruby_version_is ""..."3.1" do
+ it "should be able to show the commercial week" do
+ @time.strftime("%v").should == " 3-Feb-2001"
+ @time.strftime("%v").should == @time.strftime('%e-%b-%Y')
+ end
+ end
+
+ version_is date_version, "3.2" do #ruby_version_is "3.1" do
+ it "should be able to show the commercial week" do
+ @time.strftime("%v").should == " 3-FEB-2001"
+ @time.strftime("%v").should != @time.strftime('%e-%b-%Y')
+ end
end
# additional conversion specifiers only in Date/DateTime
diff --git a/spec/ruby/library/datetime/to_time_spec.rb b/spec/ruby/library/datetime/to_time_spec.rb
index a11b6e30e1..09e6192e7f 100644
--- a/spec/ruby/library/datetime/to_time_spec.rb
+++ b/spec/ruby/library/datetime/to_time_spec.rb
@@ -1,5 +1,6 @@
require_relative '../../spec_helper'
require 'date'
+date_version = defined?(Date::VERSION) ? Date::VERSION : '3.1.0'
describe "DateTime#to_time" do
it "yields a new Time object" do
@@ -7,10 +8,10 @@ describe "DateTime#to_time" do
end
it "returns a Time representing the same instant" do
- datetime = DateTime.civil(3, 12, 31, 23, 58, 59)
+ datetime = DateTime.civil(2012, 12, 31, 23, 58, 59)
time = datetime.to_time.utc
- time.year.should == 3
+ time.year.should == 2012
time.month.should == 12
time.day.should == 31
time.hour.should == 23
@@ -18,6 +19,19 @@ describe "DateTime#to_time" do
time.sec.should == 59
end
+ version_is date_version, '3.2.3' do #ruby_version_is "3.2" do
+ it "returns a Time representing the same instant before Gregorian" do
+ datetime = DateTime.civil(1582, 10, 4, 23, 58, 59)
+ time = datetime.to_time.utc
+ time.year.should == 1582
+ time.month.should == 10
+ time.day.should == 14
+ time.hour.should == 23
+ time.min.should == 58
+ time.sec.should == 59
+ end
+ end
+
it "preserves the same time regardless of local time or zone" do
date = DateTime.new(2012, 12, 24, 12, 23, 00, '+03:00')
diff --git a/spec/ruby/library/delegate/delegate_class/respond_to_missing_spec.rb b/spec/ruby/library/delegate/delegate_class/respond_to_missing_spec.rb
index 729cfc96c6..3975e5208b 100644
--- a/spec/ruby/library/delegate/delegate_class/respond_to_missing_spec.rb
+++ b/spec/ruby/library/delegate/delegate_class/respond_to_missing_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require 'delegate'
describe "DelegateClass#respond_to_missing?" do
diff --git a/spec/ruby/library/delegate/delegator/taint_spec.rb b/spec/ruby/library/delegate/delegator/taint_spec.rb
index b875b5a6b8..6bf13bb73d 100644
--- a/spec/ruby/library/delegate/delegator/taint_spec.rb
+++ b/spec/ruby/library/delegate/delegator/taint_spec.rb
@@ -5,21 +5,4 @@ describe "Delegator#taint" do
before :each do
@delegate = DelegateSpecs::Delegator.new("")
end
-
- ruby_version_is ''...'2.7' do
- it "returns self" do
- @delegate.taint.equal?(@delegate).should be_true
- end
-
- it "taints the delegator" do
- @delegate.__setobj__(nil)
- @delegate.taint
- @delegate.tainted?.should be_true
- end
-
- it "taints the delegated object" do
- @delegate.taint
- @delegate.__getobj__.tainted?.should be_true
- end
- end
end
diff --git a/spec/ruby/library/delegate/delegator/trust_spec.rb b/spec/ruby/library/delegate/delegator/trust_spec.rb
index 492f02e27f..f1b81814c5 100644
--- a/spec/ruby/library/delegate/delegator/trust_spec.rb
+++ b/spec/ruby/library/delegate/delegator/trust_spec.rb
@@ -5,20 +5,4 @@ describe "Delegator#trust" do
before :each do
@delegate = DelegateSpecs::Delegator.new([])
end
-
- ruby_version_is ''...'2.7' do
- it "returns self" do
- @delegate.trust.equal?(@delegate).should be_true
- end
-
- it "trusts the delegator" do
- @delegate.trust
- @delegate.untrusted?.should be_false
- end
-
- it "trusts the delegated object" do
- @delegate.trust
- @delegate.__getobj__.untrusted?.should be_false
- end
- end
end
diff --git a/spec/ruby/library/delegate/delegator/untaint_spec.rb b/spec/ruby/library/delegate/delegator/untaint_spec.rb
index 3f8f7721a9..4051fd2629 100644
--- a/spec/ruby/library/delegate/delegator/untaint_spec.rb
+++ b/spec/ruby/library/delegate/delegator/untaint_spec.rb
@@ -5,22 +5,4 @@ describe "Delegator#untaint" do
before :each do
@delegate = -> { DelegateSpecs::Delegator.new("") }.call
end
-
- ruby_version_is ''...'2.7' do
- it "returns self" do
- @delegate.untaint.equal?(@delegate).should be_true
- end
-
- it "untaints the delegator" do
- @delegate.untaint
- @delegate.tainted?.should be_false
- # No additional meaningful test; that it does or not taint
- # "for real" the delegator has no consequence
- end
-
- it "untaints the delegated object" do
- @delegate.untaint
- @delegate.__getobj__.tainted?.should be_false
- end
- end
end
diff --git a/spec/ruby/library/delegate/delegator/untrust_spec.rb b/spec/ruby/library/delegate/delegator/untrust_spec.rb
index acc91b099a..4f7fa1e582 100644
--- a/spec/ruby/library/delegate/delegator/untrust_spec.rb
+++ b/spec/ruby/library/delegate/delegator/untrust_spec.rb
@@ -5,21 +5,4 @@ describe "Delegator#untrust" do
before :each do
@delegate = DelegateSpecs::Delegator.new("")
end
-
- ruby_version_is ''...'2.7' do
- it "returns self" do
- @delegate.untrust.equal?(@delegate).should be_true
- end
-
- it "untrusts the delegator" do
- @delegate.__setobj__(nil)
- @delegate.untrust
- @delegate.untrusted?.should be_true
- end
-
- it "untrusts the delegated object" do
- @delegate.untrust
- @delegate.__getobj__.untrusted?.should be_true
- end
- end
end
diff --git a/spec/ruby/library/digest/instance/shared/update.rb b/spec/ruby/library/digest/instance/shared/update.rb
index dccc8f80df..17779e54a4 100644
--- a/spec/ruby/library/digest/instance/shared/update.rb
+++ b/spec/ruby/library/digest/instance/shared/update.rb
@@ -3,6 +3,6 @@ describe :digest_instance_update, shared: true do
c = Class.new do
include Digest::Instance
end
- -> { c.new.update("test") }.should raise_error(RuntimeError)
+ -> { c.new.send(@method, "test") }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/library/digest/md5/shared/sample.rb b/spec/ruby/library/digest/md5/shared/sample.rb
deleted file mode 100644
index 2bb4f658b1..0000000000
--- a/spec/ruby/library/digest/md5/shared/sample.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# -*- encoding: binary -*-
-
-require 'digest/md5'
-
-module MD5Constants
-
- Contents = "Ipsum is simply dummy text of the printing and typesetting industry. \nLorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \nIt has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. \nIt was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
-
- Klass = ::Digest::MD5
- BlockLength = 64
- DigestLength = 16
- BlankDigest = "\324\035\214\331\217\000\262\004\351\200\t\230\354\370B~"
- Digest = "\2473\267qw\276\364\343\345\320\304\350\313\314\217n"
- BlankHexdigest = "d41d8cd98f00b204e9800998ecf8427e"
- Hexdigest = "a733b77177bef4e3e5d0c4e8cbcc8f6e"
-
-end
diff --git a/spec/ruby/library/drb/start_service_spec.rb b/spec/ruby/library/drb/start_service_spec.rb
index 016c8b2cff..57a8cf6e15 100644
--- a/spec/ruby/library/drb/start_service_spec.rb
+++ b/spec/ruby/library/drb/start_service_spec.rb
@@ -1,28 +1,33 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/test_server'
-require 'drb'
-describe "DRb.start_service" do
- before :each do
- @server = DRb.start_service("druby://localhost:0", TestServer.new)
- end
+# This does not work yet when run in CRuby via make test-spec:
+# Gem::MissingSpecError: Could not find 'ruby2_keywords' (>= 0) among 28 total gem(s)
+guard_not -> { MSpecScript.instance_variable_defined?(:@testing_ruby) } do
+ require_relative 'fixtures/test_server'
+ require 'drb'
- after :each do
- DRb.stop_service if @server
- end
+ describe "DRb.start_service" do
+ before :each do
+ @server = DRb.start_service("druby://localhost:0", TestServer.new)
+ end
- it "runs a basic remote call" do
- DRb.current_server.should == @server
- obj = DRbObject.new(nil, @server.uri)
- obj.add(1,2,3).should == 6
- end
+ after :each do
+ DRb.stop_service if @server
+ end
+
+ it "runs a basic remote call" do
+ DRb.current_server.should == @server
+ obj = DRbObject.new(nil, @server.uri)
+ obj.add(1,2,3).should == 6
+ end
- it "runs a basic remote call passing a block" do
- DRb.current_server.should == @server
- obj = DRbObject.new(nil, @server.uri)
- obj.add_yield(2) do |i|
- i.should == 2
- i+1
- end.should == 4
+ it "runs a basic remote call passing a block" do
+ DRb.current_server.should == @server
+ obj = DRbObject.new(nil, @server.uri)
+ obj.add_yield(2) do |i|
+ i.should == 2
+ i+1
+ end.should == 4
+ end
end
end
diff --git a/spec/ruby/library/erb/fixtures/classes.rb b/spec/ruby/library/erb/fixtures/classes.rb
index 03da889941..e07a6ed68d 100644
--- a/spec/ruby/library/erb/fixtures/classes.rb
+++ b/spec/ruby/library/erb/fixtures/classes.rb
@@ -1,9 +1,5 @@
module ERBSpecs
def self.new_erb(input, trim_mode: nil)
- if ruby_version_is "2.6"
- ERB.new(input, trim_mode: trim_mode)
- else
- ERB.new(input, nil, trim_mode)
- end
+ ERB.new(input, trim_mode: trim_mode)
end
end
diff --git a/spec/ruby/library/erb/new_spec.rb b/spec/ruby/library/erb/new_spec.rb
index 3bb870dd3f..a5aeeaeed1 100644
--- a/spec/ruby/library/erb/new_spec.rb
+++ b/spec/ruby/library/erb/new_spec.rb
@@ -36,12 +36,10 @@ END
end
end
- ruby_version_is "2.6" do
- it "warns invalid trim_mode" do
- -> do
- ERBSpecs.new_erb(@eruby_str, trim_mode: '')
- end.should complain(/Invalid ERB trim mode/)
- end
+ it "warns invalid trim_mode" do
+ -> do
+ ERBSpecs.new_erb(@eruby_str, trim_mode: '')
+ end.should complain(/Invalid ERB trim mode/)
end
it "removes '\n' when trim_mode is 1 or '>'" do
@@ -120,13 +118,8 @@ END
it "changes '_erbout' variable name in the produced source" do
input = @eruby_str
- if RUBY_VERSION >= '2.6'
- match_erbout = ERB.new(input, trim_mode: nil).src
- match_buf = ERB.new(input, trim_mode: nil, eoutvar: 'buf').src
- else
- match_erbout = ERB.new(input, nil, nil).src
- match_buf = ERB.new(input, nil, nil, 'buf').src
- end
+ match_erbout = ERB.new(input, trim_mode: nil).src
+ match_buf = ERB.new(input, trim_mode: nil, eoutvar: 'buf').src
match_erbout.gsub("_erbout", "buf").should == match_buf
end
@@ -145,4 +138,20 @@ END
ERB.new(@eruby_str).result
->{ ERB.new("<%= list %>").result }.should raise_error(NameError)
end
+
+ describe "warning about arguments" do
+ version_is ERB.version, "2.2.1" do #ruby_version_is "3.1" do
+ it "warns when passed safe_level and later arguments" do
+ -> {
+ ERB.new(@eruby_str, nil, '%')
+ }.should complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./)
+ end
+
+ it "does not warn when passed arguments as keyword argument" do
+ -> {
+ ERB.new(@eruby_str, trim_mode: '%')
+ }.should_not complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./)
+ end
+ end
+ end
end
diff --git a/spec/ruby/library/erb/run_spec.rb b/spec/ruby/library/erb/run_spec.rb
index 8c07442d8f..602e53ab38 100644
--- a/spec/ruby/library/erb/run_spec.rb
+++ b/spec/ruby/library/erb/run_spec.rb
@@ -6,7 +6,7 @@ describe "ERB#run" do
# lambda { ... }.should output
def _steal_stdout
orig = $stdout
- s = ''
+ s = +''
def s.write(arg); self << arg.to_s; end
$stdout = s
begin
diff --git a/spec/ruby/library/etc/confstr_spec.rb b/spec/ruby/library/etc/confstr_spec.rb
index 41a970a918..5b43461150 100644
--- a/spec/ruby/library/etc/confstr_spec.rb
+++ b/spec/ruby/library/etc/confstr_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'etc'
platform_is_not :windows, :android do
diff --git a/spec/ruby/library/etc/passwd_spec.rb b/spec/ruby/library/etc/passwd_spec.rb
index d61dada451..7157fd3f2e 100644
--- a/spec/ruby/library/etc/passwd_spec.rb
+++ b/spec/ruby/library/etc/passwd_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'etc'
platform_is_not :windows do
diff --git a/spec/ruby/library/etc/sysconf_spec.rb b/spec/ruby/library/etc/sysconf_spec.rb
index e7d59d1b22..1f2c7a770f 100644
--- a/spec/ruby/library/etc/sysconf_spec.rb
+++ b/spec/ruby/library/etc/sysconf_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'etc'
platform_is_not :windows do
diff --git a/spec/ruby/library/etc/sysconfdir_spec.rb b/spec/ruby/library/etc/sysconfdir_spec.rb
index d54299c513..8538faa65b 100644
--- a/spec/ruby/library/etc/sysconfdir_spec.rb
+++ b/spec/ruby/library/etc/sysconfdir_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'etc'
describe "Etc.sysconfdir" do
diff --git a/spec/ruby/library/etc/systmpdir_spec.rb b/spec/ruby/library/etc/systmpdir_spec.rb
index 99c82903f8..5b007aa9f9 100644
--- a/spec/ruby/library/etc/systmpdir_spec.rb
+++ b/spec/ruby/library/etc/systmpdir_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
require 'etc'
describe "Etc.systmpdir" do
diff --git a/spec/ruby/library/etc/uname_spec.rb b/spec/ruby/library/etc/uname_spec.rb
new file mode 100644
index 0000000000..a42558f593
--- /dev/null
+++ b/spec/ruby/library/etc/uname_spec.rb
@@ -0,0 +1,14 @@
+require_relative '../../spec_helper'
+require 'etc'
+
+describe "Etc.uname" do
+ it "returns a Hash with the documented keys" do
+ uname = Etc.uname
+ uname.should be_kind_of(Hash)
+ uname.should.key?(:sysname)
+ uname.should.key?(:nodename)
+ uname.should.key?(:release)
+ uname.should.key?(:version)
+ uname.should.key?(:machine)
+ end
+end
diff --git a/spec/ruby/library/expect/expect_spec.rb b/spec/ruby/library/expect/expect_spec.rb
index a7041d42ee..76ea3d5451 100644
--- a/spec/ruby/library/expect/expect_spec.rb
+++ b/spec/ruby/library/expect/expect_spec.rb
@@ -1,5 +1,6 @@
+require_relative '../../spec_helper'
+
platform_is_not :windows do
- require_relative '../../spec_helper'
require 'expect'
describe "IO#expect" do
diff --git a/spec/ruby/library/fiber/current_spec.rb b/spec/ruby/library/fiber/current_spec.rb
index e67d7d050a..1467a88d0d 100644
--- a/spec/ruby/library/fiber/current_spec.rb
+++ b/spec/ruby/library/fiber/current_spec.rb
@@ -3,6 +3,12 @@ require_relative '../../spec_helper'
require 'fiber'
describe "Fiber.current" do
+ ruby_version_is "3.1" do
+ it "is available without an extra require" do
+ ruby_exe("print Fiber.current.class", options: '--disable-gems --disable-did-you-mean').should == "Fiber"
+ end
+ end
+
it "returns the root Fiber when called outside of a Fiber" do
root = Fiber.current
root.should be_an_instance_of(Fiber)
@@ -42,22 +48,11 @@ describe "Fiber.current" do
fiber3 = Fiber.new do
states << :fiber3
fiber2.transfer
- ruby_version_is '3.0' do
- states << :fiber3_terminated
- end
- ruby_version_is '' ... '3.0' do
- flunk
- end
+ states << :fiber3_terminated
end
fiber3.resume
- ruby_version_is "" ... "3.0" do
- states.should == [:fiber3, :fiber2, :fiber]
- end
-
- ruby_version_is "3.0" do
- states.should == [:fiber3, :fiber2, :fiber, :fiber3_terminated]
- end
+ states.should == [:fiber3, :fiber2, :fiber, :fiber3_terminated]
end
end
diff --git a/spec/ruby/library/fiber/resume_spec.rb b/spec/ruby/library/fiber/resume_spec.rb
index 39d14bdda0..fd69d3ba99 100644
--- a/spec/ruby/library/fiber/resume_spec.rb
+++ b/spec/ruby/library/fiber/resume_spec.rb
@@ -3,21 +3,16 @@ require_relative '../../spec_helper'
require 'fiber'
describe "Fiber#resume" do
- ruby_version_is '' ... '3.0' do
- it "raises a FiberError if the Fiber has transferred control to another Fiber" do
- fiber1 = Fiber.new { true }
- fiber2 = Fiber.new { fiber1.transfer; Fiber.yield }
- fiber2.resume
- -> { fiber2.resume }.should raise_error(FiberError)
- end
+ it "can work with Fiber#transfer" do
+ fiber1 = Fiber.new { true }
+ fiber2 = Fiber.new { fiber1.transfer; Fiber.yield 10 ; Fiber.yield 20; raise }
+ fiber2.resume.should == 10
+ fiber2.resume.should == 20
end
- ruby_version_is '3.0' do
- it "can work with Fiber#transfer" do
- fiber1 = Fiber.new { true }
- fiber2 = Fiber.new { fiber1.transfer; Fiber.yield 10 ; Fiber.yield 20; raise }
- fiber2.resume.should == 10
- fiber2.resume.should == 20
- end
+ it "raises a FiberError if the Fiber attempts to resume a resuming fiber" do
+ root_fiber = Fiber.current
+ fiber1 = Fiber.new { root_fiber.resume }
+ -> { fiber1.resume }.should raise_error(FiberError, /attempt to resume a resuming fiber/)
end
end
diff --git a/spec/ruby/library/fiber/transfer_spec.rb b/spec/ruby/library/fiber/transfer_spec.rb
index 7af548da1a..e20d51352e 100644
--- a/spec/ruby/library/fiber/transfer_spec.rb
+++ b/spec/ruby/library/fiber/transfer_spec.rb
@@ -11,13 +11,7 @@ describe "Fiber#transfer" do
it "transfers control from one Fiber to another when called from a Fiber" do
fiber1 = Fiber.new { :fiber1 }
fiber2 = Fiber.new { fiber1.transfer; :fiber2 }
-
- ruby_version_is '' ... '3.0' do
- fiber2.resume.should == :fiber1
- end
- ruby_version_is '3.0' do
- fiber2.resume.should == :fiber2
- end
+ fiber2.resume.should == :fiber2
end
it "returns to the root Fiber when finished" do
@@ -40,24 +34,12 @@ describe "Fiber#transfer" do
states.should == [:start, :end]
end
- ruby_version_is '' ... '3.0' do
- it "can transfer control to a Fiber that has transferred to another Fiber" do
- states = []
- fiber1 = Fiber.new { states << :fiber1 }
- fiber2 = Fiber.new { states << :fiber2_start; fiber1.transfer; states << :fiber2_end}
- fiber2.resume.should == [:fiber2_start, :fiber1]
- fiber2.transfer.should == [:fiber2_start, :fiber1, :fiber2_end]
- end
- end
-
- ruby_version_is '3.0' do
- it "can not transfer control to a Fiber that has suspended by Fiber.yield" do
- states = []
- fiber1 = Fiber.new { states << :fiber1 }
- fiber2 = Fiber.new { states << :fiber2_start; Fiber.yield fiber1.transfer; states << :fiber2_end}
- fiber2.resume.should == [:fiber2_start, :fiber1]
- -> { fiber2.transfer }.should raise_error(FiberError)
- end
+ it "can not transfer control to a Fiber that has suspended by Fiber.yield" do
+ states = []
+ fiber1 = Fiber.new { states << :fiber1 }
+ fiber2 = Fiber.new { states << :fiber2_start; Fiber.yield fiber1.transfer; states << :fiber2_end}
+ fiber2.resume.should == [:fiber2_start, :fiber1]
+ -> { fiber2.transfer }.should raise_error(FiberError)
end
it "raises a FiberError when transferring to a Fiber which resumes itself" do
@@ -101,28 +83,4 @@ describe "Fiber#transfer" do
thread.join
states.should == [0, 1, 2, 3]
end
-
- ruby_version_is "" ... "3.0" do
- it "runs until Fiber.yield" do
- obj = mock('obj')
- obj.should_not_receive(:do)
- fiber = Fiber.new { 1 + 2; Fiber.yield; obj.do }
- fiber.transfer
- end
-
- it "resumes from the last call to Fiber.yield on subsequent invocations" do
- fiber = Fiber.new { Fiber.yield :first; :second }
- fiber.transfer.should == :first
- fiber.transfer.should == :second
- end
-
- it "sets the block parameters to its arguments on the first invocation" do
- first = mock('first')
- first.should_receive(:arg).with(:first).twice
-
- fiber = Fiber.new { |arg| first.arg arg; Fiber.yield; first.arg arg; }
- fiber.transfer :first
- fiber.transfer :second
- end
- end
end
diff --git a/spec/ruby/library/fiddle/handle/initialize_spec.rb b/spec/ruby/library/fiddle/handle/initialize_spec.rb
new file mode 100644
index 0000000000..51c2470efd
--- /dev/null
+++ b/spec/ruby/library/fiddle/handle/initialize_spec.rb
@@ -0,0 +1,10 @@
+require_relative '../../../spec_helper'
+require 'fiddle'
+
+describe "Fiddle::Handle#initialize" do
+ it "raises Fiddle::DLError if the library cannot be found" do
+ -> {
+ Fiddle::Handle.new("doesnotexist.doesnotexist")
+ }.should raise_error(Fiddle::DLError)
+ end
+end
diff --git a/spec/ruby/library/io-wait/fixtures/classes.rb b/spec/ruby/library/io-wait/fixtures/classes.rb
new file mode 100644
index 0000000000..837c7edd06
--- /dev/null
+++ b/spec/ruby/library/io-wait/fixtures/classes.rb
@@ -0,0 +1,12 @@
+module IOWaitSpec
+ def self.exhaust_write_buffer(io)
+ written = 0
+ buf = " " * 4096
+
+ begin
+ written += io.write_nonblock(buf)
+ rescue Errno::EAGAIN, Errno::EWOULDBLOCK
+ return written
+ end while true
+ end
+end
diff --git a/spec/ruby/library/io-wait/wait_readable_spec.rb b/spec/ruby/library/io-wait/wait_readable_spec.rb
new file mode 100644
index 0000000000..06ffbda5c8
--- /dev/null
+++ b/spec/ruby/library/io-wait/wait_readable_spec.rb
@@ -0,0 +1,27 @@
+require_relative '../../spec_helper'
+
+ruby_version_is ''...'3.2' do
+ require 'io/wait'
+end
+
+describe "IO#wait_readable" do
+ before :each do
+ @io = File.new(__FILE__ )
+ end
+
+ after :each do
+ @io.close
+ end
+
+ it "waits for the IO to become readable with no timeout" do
+ @io.wait_readable.should == @io
+ end
+
+ it "waits for the IO to become readable with the given timeout" do
+ @io.wait_readable(1).should == @io
+ end
+
+ it "waits for the IO to become readable with the given large timeout" do
+ @io.wait_readable(365 * 24 * 60 * 60).should == @io
+ end
+end
diff --git a/spec/ruby/library/io-wait/wait_spec.rb b/spec/ruby/library/io-wait/wait_spec.rb
new file mode 100644
index 0000000000..fc07c6a8d9
--- /dev/null
+++ b/spec/ruby/library/io-wait/wait_spec.rb
@@ -0,0 +1,155 @@
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
+
+ruby_version_is ''...'3.2' do
+ require 'io/wait'
+end
+
+describe "IO#wait" do
+ before :each do
+ @io = File.new(__FILE__ )
+
+ if /mswin|mingw/ =~ RUBY_PLATFORM
+ require 'socket'
+ @r, @w = Socket.pair(Socket::AF_INET, Socket::SOCK_STREAM, 0)
+ else
+ @r, @w = IO.pipe
+ end
+ end
+
+ after :each do
+ @io.close unless @io.closed?
+
+ @r.close unless @r.closed?
+ @w.close unless @w.closed?
+ end
+
+ context "[events, timeout] passed" do
+ ruby_version_is ""..."3.2" do
+ it "returns self when the READABLE event is ready during the timeout" do
+ @w.write('data to read')
+ @r.wait(IO::READABLE, 2).should.equal?(@r)
+ end
+
+ it "returns self when the WRITABLE event is ready during the timeout" do
+ @w.wait(IO::WRITABLE, 0).should.equal?(@w)
+ end
+ end
+
+ ruby_version_is "3.2" do
+ it "returns events mask when the READABLE event is ready during the timeout" do
+ @w.write('data to read')
+ @r.wait(IO::READABLE, 2).should == IO::READABLE
+ end
+
+ it "returns events mask when the WRITABLE event is ready during the timeout" do
+ @w.wait(IO::WRITABLE, 0).should == IO::WRITABLE
+ end
+ end
+
+ it "waits for the READABLE event to be ready" do
+ @r.wait(IO::READABLE, 0).should == nil
+
+ @w.write('data to read')
+ @r.wait(IO::READABLE, 0).should_not == nil
+ end
+
+ it "waits for the WRITABLE event to be ready" do
+ written_bytes = IOWaitSpec.exhaust_write_buffer(@w)
+ @w.wait(IO::WRITABLE, 0).should == nil
+
+ @r.read(written_bytes)
+ @w.wait(IO::WRITABLE, 0).should_not == nil
+ end
+
+ it "returns nil when the READABLE event is not ready during the timeout" do
+ @w.wait(IO::READABLE, 0).should == nil
+ end
+
+ it "returns nil when the WRITABLE event is not ready during the timeout" do
+ IOWaitSpec.exhaust_write_buffer(@w)
+ @w.wait(IO::WRITABLE, 0).should == nil
+ end
+
+ it "raises IOError when io is closed (closed stream (IOError))" do
+ @io.close
+ -> { @io.wait(IO::READABLE, 0) }.should raise_error(IOError, "closed stream")
+ end
+
+ ruby_version_is "3.2" do
+ it "raises ArgumentError when events is not positive" do
+ -> { @w.wait(0, 0) }.should raise_error(ArgumentError, "Events must be positive integer!")
+ -> { @w.wait(-1, 0) }.should raise_error(ArgumentError, "Events must be positive integer!")
+ end
+ end
+
+ it "changes thread status to 'sleep' when waits for READABLE event" do
+ t = Thread.new { @r.wait(IO::READABLE, 10) }
+ sleep 1
+ t.status.should == 'sleep'
+ t.kill
+ t.join # Thread#kill doesn't wait for the thread to end
+ end
+
+ it "changes thread status to 'sleep' when waits for WRITABLE event" do
+ written_bytes = IOWaitSpec.exhaust_write_buffer(@w)
+
+ t = Thread.new { @w.wait(IO::WRITABLE, 10) }
+ sleep 1
+ t.status.should == 'sleep'
+ t.kill
+ t.join # Thread#kill doesn't wait for the thread to end
+ end
+ end
+
+ context "[timeout, mode] passed" do
+ it "accepts :r, :read, :readable mode to check READABLE event" do
+ @io.wait(0, :r).should == @io
+ @io.wait(0, :read).should == @io
+ @io.wait(0, :readable).should == @io
+ end
+
+ it "accepts :w, :write, :writable mode to check WRITABLE event" do
+ @io.wait(0, :w).should == @io
+ @io.wait(0, :write).should == @io
+ @io.wait(0, :writable).should == @io
+ end
+
+ it "accepts :rw, :read_write, :readable_writable mode to check READABLE and WRITABLE events" do
+ @io.wait(0, :rw).should == @io
+ @io.wait(0, :read_write).should == @io
+ @io.wait(0, :readable_writable).should == @io
+ end
+
+ it "accepts a list of modes" do
+ @io.wait(0, :r, :w, :rw).should == @io
+ end
+
+ # It works at least since 2.7 but by some reason may fail on 3.1
+ ruby_version_is "3.2" do
+ it "accepts timeout and mode in any order" do
+ @io.wait(0, :r).should == @io
+ @io.wait(:r, 0).should == @io
+ @io.wait(:r, 0, :w).should == @io
+ end
+ end
+
+ it "raises ArgumentError when passed wrong Symbol value as mode argument" do
+ -> { @io.wait(0, :wrong) }.should raise_error(ArgumentError, "unsupported mode: wrong")
+ end
+
+ # It works since 3.0 but by some reason may fail on 3.1
+ ruby_version_is "3.2" do
+ it "raises ArgumentError when several Integer arguments passed" do
+ -> { @w.wait(0, 10, :r) }.should raise_error(ArgumentError, "timeout given more than once")
+ end
+ end
+
+ ruby_version_is "3.2" do
+ it "raises IOError when io is closed (closed stream (IOError))" do
+ @io.close
+ -> { @io.wait(0, :r) }.should raise_error(IOError, "closed stream")
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/io-wait/wait_writable_spec.rb b/spec/ruby/library/io-wait/wait_writable_spec.rb
new file mode 100644
index 0000000000..8c44780d39
--- /dev/null
+++ b/spec/ruby/library/io-wait/wait_writable_spec.rb
@@ -0,0 +1,20 @@
+require_relative '../../spec_helper'
+
+ruby_version_is ''...'3.2' do
+ require 'io/wait'
+end
+
+describe "IO#wait_writable" do
+ it "waits for the IO to become writable with no timeout" do
+ STDOUT.wait_writable.should == STDOUT
+ end
+
+ it "waits for the IO to become writable with the given timeout" do
+ STDOUT.wait_writable(1).should == STDOUT
+ end
+
+ it "waits for the IO to become writable with the given large timeout" do
+ # Represents one year and is larger than a 32-bit int
+ STDOUT.wait_writable(365 * 24 * 60 * 60).should == STDOUT
+ end
+end
diff --git a/spec/ruby/library/ipaddr/new_spec.rb b/spec/ruby/library/ipaddr/new_spec.rb
index 3148d6e39c..714c1e2f1a 100644
--- a/spec/ruby/library/ipaddr/new_spec.rb
+++ b/spec/ruby/library/ipaddr/new_spec.rb
@@ -77,17 +77,40 @@ describe "IPAddr#new" do
a.family.should == Socket::AF_INET6
end
- it "raises on incorrect IPAddr strings" do
- [
- ["fe80::1%fxp0"],
- ["::1/255.255.255.0"],
- [IPAddr.new("::1").to_i],
- ["::ffff:192.168.1.2/120", Socket::AF_INET],
- ["[192.168.1.2]/120"],
- ].each { |args|
- ->{
- IPAddr.new(*args)
- }.should raise_error(ArgumentError)
- }
+ ipaddr_version = if defined?(IPAddr::VERSION) #ruby_version_is ""..."3.1" do
+ IPAddr::VERSION
+ else
+ "1.2.2"
+ end
+
+ version_is ipaddr_version, ""..."1.2.3" do #ruby_version_is ""..."3.1" do
+ it "raises on incorrect IPAddr strings" do
+ [
+ ["fe80::1%fxp0"],
+ ["::1/255.255.255.0"],
+ [IPAddr.new("::1").to_i],
+ ["::ffff:192.168.1.2/120", Socket::AF_INET],
+ ["[192.168.1.2]/120"],
+ ].each { |args|
+ ->{
+ IPAddr.new(*args)
+ }.should raise_error(ArgumentError)
+ }
+ end
+ end
+
+ version_is ipaddr_version, "1.2.3" do #ruby_version_is "3.1" do
+ it "raises on incorrect IPAddr strings" do
+ [
+ ["::1/255.255.255.0"],
+ [IPAddr.new("::1").to_i],
+ ["::ffff:192.168.1.2/120", Socket::AF_INET],
+ ["[192.168.1.2]/120"],
+ ].each { |args|
+ ->{
+ IPAddr.new(*args)
+ }.should raise_error(ArgumentError)
+ }
+ end
end
end
diff --git a/spec/ruby/library/logger/device/close_spec.rb b/spec/ruby/library/logger/device/close_spec.rb
index d7d107fcce..1db5d582a7 100644
--- a/spec/ruby/library/logger/device/close_spec.rb
+++ b/spec/ruby/library/logger/device/close_spec.rb
@@ -15,17 +15,8 @@ describe "Logger::LogDevice#close" do
rm_r @file_path
end
- ruby_version_is ""..."2.7" do
- it "closes the LogDevice's stream" do
- @device.close
- -> { @device.write("Test") }.should complain(/\Alog writing failed\./)
- end
- end
-
- ruby_version_is "2.7" do
- it "closes the LogDevice's stream" do
- @device.close
- -> { @device.write("Test") }.should complain(/\Alog shifting failed\./)
- end
+ it "closes the LogDevice's stream" do
+ @device.close
+ -> { @device.write("Test") }.should complain(/\Alog shifting failed\./)
end
end
diff --git a/spec/ruby/library/logger/device/write_spec.rb b/spec/ruby/library/logger/device/write_spec.rb
index 5506bb2c38..87ecf2ad6a 100644
--- a/spec/ruby/library/logger/device/write_spec.rb
+++ b/spec/ruby/library/logger/device/write_spec.rb
@@ -35,17 +35,8 @@ describe "Logger::LogDevice#write" do
rm_r path
end
- ruby_version_is ""..."2.7" do
- it "fails if the device is already closed" do
- @device.close
- -> { @device.write "foo" }.should complain(/\Alog writing failed\./)
- end
- end
-
- ruby_version_is "2.7" do
- it "fails if the device is already closed" do
- @device.close
- -> { @device.write "foo" }.should complain(/\Alog shifting failed\./)
- end
+ it "fails if the device is already closed" do
+ @device.close
+ -> { @device.write "foo" }.should complain(/\Alog shifting failed\./)
end
end
diff --git a/spec/ruby/library/matrix/antisymmetric_spec.rb b/spec/ruby/library/matrix/antisymmetric_spec.rb
index 3eb0f8b726..200df703cb 100644
--- a/spec/ruby/library/matrix/antisymmetric_spec.rb
+++ b/spec/ruby/library/matrix/antisymmetric_spec.rb
@@ -1,37 +1,36 @@
require_relative '../../spec_helper'
+
require 'matrix'
-ruby_version_is "2.6" do
- describe "Matrix#antisymmetric?" do
- it "returns true for an antisymmetric Matrix" do
- Matrix[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric?.should be_true
- end
+describe "Matrix#antisymmetric?" do
+ it "returns true for an antisymmetric Matrix" do
+ Matrix[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric?.should be_true
+ end
- it "returns true for a 0x0 empty matrix" do
- Matrix.empty.antisymmetric?.should be_true
- end
+ it "returns true for a 0x0 empty matrix" do
+ Matrix.empty.antisymmetric?.should be_true
+ end
- it "returns false for non-antisymmetric matrices" do
- [
- Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
- Matrix[[1, -2, 3], [2, 0, 6], [-3, -6, 0]], # wrong diagonal element
- Matrix[[0, 2, -3], [2, 0, 6], [-3, 6, 0]] # only signs wrong
- ].each do |matrix|
- matrix.antisymmetric?.should be_false
- end
+ it "returns false for non-antisymmetric matrices" do
+ [
+ Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
+ Matrix[[1, -2, 3], [2, 0, 6], [-3, -6, 0]], # wrong diagonal element
+ Matrix[[0, 2, -3], [2, 0, 6], [-3, 6, 0]] # only signs wrong
+ ].each do |matrix|
+ matrix.antisymmetric?.should be_false
end
+ end
- it "raises an error for rectangular matrices" do
- [
- Matrix[[0], [0]],
- Matrix[[0, 0]],
- Matrix.empty(0, 2),
- Matrix.empty(2, 0),
- ].each do |rectangular_matrix|
- -> {
- rectangular_matrix.antisymmetric?
- }.should raise_error(Matrix::ErrDimensionMismatch)
- end
+ it "raises an error for rectangular matrices" do
+ [
+ Matrix[[0], [0]],
+ Matrix[[0, 0]],
+ Matrix.empty(0, 2),
+ Matrix.empty(2, 0),
+ ].each do |rectangular_matrix|
+ -> {
+ rectangular_matrix.antisymmetric?
+ }.should raise_error(Matrix::ErrDimensionMismatch)
end
end
end
diff --git a/spec/ruby/library/matrix/exponent_spec.rb b/spec/ruby/library/matrix/exponent_spec.rb
index a05826ab72..b76e18b4cd 100644
--- a/spec/ruby/library/matrix/exponent_spec.rb
+++ b/spec/ruby/library/matrix/exponent_spec.rb
@@ -34,7 +34,7 @@ describe "Matrix#**" do
end
end
- ruby_version_is '3.0.2' do # https://bugs.ruby-lang.org/issues/17521
+ ruby_version_is '3.1.0' do # https://bugs.ruby-lang.org/issues/17521
describe "that is 0" do
it "returns the identity for square matrices" do
m = Matrix[ [1, 1], [1, 1] ]
diff --git a/spec/ruby/library/matrix/multiply_spec.rb b/spec/ruby/library/matrix/multiply_spec.rb
index 585f268931..206868af92 100644
--- a/spec/ruby/library/matrix/multiply_spec.rb
+++ b/spec/ruby/library/matrix/multiply_spec.rb
@@ -1,4 +1,5 @@
require_relative '../../spec_helper'
+
require_relative 'fixtures/classes'
require 'matrix'
@@ -22,8 +23,8 @@ describe "Matrix#*" do
it "returns the result of multiplying the elements of self and a Bignum" do
(@a * bignum_value).should == Matrix[
- [9223372036854775808, 18446744073709551616],
- [27670116110564327424, 36893488147419103232]
+ [18446744073709551616, 36893488147419103232],
+ [55340232221128654848, 73786976294838206464]
]
end
diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb
index af4b2bb442..c214ee9b2f 100644
--- a/spec/ruby/library/matrix/unitary_spec.rb
+++ b/spec/ruby/library/matrix/unitary_spec.rb
@@ -1,4 +1,5 @@
require_relative '../../spec_helper'
+
require 'matrix'
describe "Matrix.unitary?" do
@@ -12,10 +13,8 @@ describe "Matrix.unitary?" do
Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].should.unitary?
end
- version_is((Matrix::const_defined?(:VERSION) ? Matrix::VERSION : "0.1.0"), "0.3.0") do
- it "returns true for unitary matrices with a Complex and a negative #imag" do
- Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].should.unitary?
- end
+ it "returns true for unitary matrices with a Complex and a negative #imag" do
+ Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].should.unitary?
end
it "raises an error for rectangular matrices" do
diff --git a/spec/ruby/library/monitor/enter_spec.rb b/spec/ruby/library/monitor/enter_spec.rb
new file mode 100644
index 0000000000..f523c42087
--- /dev/null
+++ b/spec/ruby/library/monitor/enter_spec.rb
@@ -0,0 +1,28 @@
+require_relative '../../spec_helper'
+require 'monitor'
+
+describe "Monitor#enter" do
+ it "acquires the monitor" do
+ monitor = Monitor.new
+ 10.times do
+ wait_q = Queue.new
+ continue_q = Queue.new
+
+ thread = Thread.new do
+ begin
+ monitor.enter
+ wait_q << true
+ continue_q.pop
+ ensure
+ monitor.exit
+ end
+ end
+
+ wait_q.pop
+ monitor.mon_locked?.should == true
+ continue_q << true
+ thread.join
+ monitor.mon_locked?.should == false
+ end
+ end
+end
diff --git a/spec/ruby/library/monitor/exit_spec.rb b/spec/ruby/library/monitor/exit_spec.rb
new file mode 100644
index 0000000000..952ad9525d
--- /dev/null
+++ b/spec/ruby/library/monitor/exit_spec.rb
@@ -0,0 +1,10 @@
+require_relative '../../spec_helper'
+require 'monitor'
+
+describe "Monitor#exit" do
+ it "raises ThreadError when monitor is not entered" do
+ m = Monitor.new
+
+ -> { m.exit }.should raise_error(ThreadError)
+ end
+end
diff --git a/spec/ruby/library/monitor/new_cond_spec.rb b/spec/ruby/library/monitor/new_cond_spec.rb
new file mode 100644
index 0000000000..ec25d3f8a2
--- /dev/null
+++ b/spec/ruby/library/monitor/new_cond_spec.rb
@@ -0,0 +1,88 @@
+require_relative '../../spec_helper'
+require 'monitor'
+
+describe "Monitor#new_cond" do
+ it "creates a MonitorMixin::ConditionVariable" do
+ m = Monitor.new
+ c = m.new_cond
+ c.class.should == MonitorMixin::ConditionVariable
+ end
+
+ it 'returns a condition variable which can be waited on by a thread holding the monitor' do
+ m = Monitor.new
+ c = m.new_cond
+
+ 10.times do
+
+ wait_q = Queue.new
+ thread = Thread.new do
+ m.synchronize do
+ wait_q << true
+ c.wait
+ end
+ :done
+ end
+
+ wait_q.pop
+
+ # Synchronize can't happen until the other thread is waiting.
+ m.synchronize { c.signal }
+
+ thread.join
+ thread.value.should == :done
+ end
+ end
+
+ it 'returns a condition variable which can be waited on by a thread holding the monitor inside multiple synchronize blocks' do
+ m = Monitor.new
+ c = m.new_cond
+
+ 10.times do
+
+ wait_q = Queue.new
+ thread = Thread.new do
+ m.synchronize do
+ m.synchronize do
+ wait_q << true
+ c.wait
+ end
+ end
+ :done
+ end
+
+ wait_q.pop
+
+ #No need to wait here as we cannot synchronize until the other thread is waiting.
+ m.synchronize { c.signal }
+
+ thread.join
+ thread.value.should == :done
+ end
+ end
+
+ it 'returns a condition variable which can be signalled by a thread holding the monitor inside multiple synchronize blocks' do
+ m = Monitor.new
+ c = m.new_cond
+
+ 10.times do
+
+ wait_q = Queue.new
+ thread = Thread.new do
+ m.synchronize do
+ wait_q << true
+ c.wait
+ end
+ :done
+ end
+
+ wait_q.pop
+
+ # Synchronize can't happen until the other thread is waiting.
+ m.synchronize { m.synchronize { c.signal } }
+
+ thread.join
+ thread.value.should == :done
+ end
+ end
+
+end
diff --git a/spec/ruby/library/monitor/synchronize_spec.rb b/spec/ruby/library/monitor/synchronize_spec.rb
index d851b98d6c..d78393eb3a 100644
--- a/spec/ruby/library/monitor/synchronize_spec.rb
+++ b/spec/ruby/library/monitor/synchronize_spec.rb
@@ -7,24 +7,35 @@ describe "Monitor#synchronize" do
monitor = Monitor.new
10.times do
- locked = false
+ wait_q = Queue.new
+ continue_q = Queue.new
thread = Thread.new do
begin
monitor.synchronize do
- locked = true
+ wait_q << true
# Do not wait here, we are trying to interrupt the ensure part of #synchronize
end
- sleep # wait for exception if it did not happen yet
+ continue_q.pop
rescue exc_class
monitor.should_not.mon_locked?
:ok
end
end
- Thread.pass until locked
+ wait_q.pop
thread.raise exc_class, "interrupt"
+ continue_q << true
thread.value.should == :ok
end
end
+
+ it "raises a LocalJumpError if not passed a block" do
+ -> { Monitor.new.synchronize }.should raise_error(LocalJumpError)
+ end
+
+ it "raises a thread error if the monitor is not owned on exiting the block" do
+ monitor = Monitor.new
+ -> { monitor.synchronize { monitor.exit } }.should raise_error(ThreadError)
+ end
end
diff --git a/spec/ruby/library/monitor/try_enter_spec.rb b/spec/ruby/library/monitor/try_enter_spec.rb
new file mode 100644
index 0000000000..04b878f720
--- /dev/null
+++ b/spec/ruby/library/monitor/try_enter_spec.rb
@@ -0,0 +1,39 @@
+require_relative '../../spec_helper'
+require 'monitor'
+
+describe "Monitor#try_enter" do
+ it "will acquire a monitor not held by another thread" do
+ monitor = Monitor.new
+ 10.times do
+
+ thread = Thread.new do
+ val = monitor.try_enter
+ monitor.exit if val
+ val
+ end
+
+ thread.join
+ thread.value.should == true
+ end
+ end
+
+ it "will not acquire a monitor already held by another thread" do
+ monitor = Monitor.new
+ 10.times do
+ monitor.enter
+ begin
+ thread = Thread.new do
+ val = monitor.try_enter
+ monitor.exit if val
+ val
+ end
+
+ thread.join
+ thread.value.should == false
+ ensure
+ monitor.exit
+ end
+ monitor.mon_locked?.should == false
+ end
+ end
+end
diff --git a/spec/ruby/library/net/FTPError_spec.rb b/spec/ruby/library/net-ftp/FTPError_spec.rb
index 0c31b65dcc..0c31b65dcc 100644
--- a/spec/ruby/library/net/FTPError_spec.rb
+++ b/spec/ruby/library/net-ftp/FTPError_spec.rb
diff --git a/spec/ruby/library/net/FTPPermError_spec.rb b/spec/ruby/library/net-ftp/FTPPermError_spec.rb
index b43e12c503..b43e12c503 100644
--- a/spec/ruby/library/net/FTPPermError_spec.rb
+++ b/spec/ruby/library/net-ftp/FTPPermError_spec.rb
diff --git a/spec/ruby/library/net/FTPProtoError_spec.rb b/spec/ruby/library/net-ftp/FTPProtoError_spec.rb
index e7abbc0dd8..e7abbc0dd8 100644
--- a/spec/ruby/library/net/FTPProtoError_spec.rb
+++ b/spec/ruby/library/net-ftp/FTPProtoError_spec.rb
diff --git a/spec/ruby/library/net/FTPReplyError_spec.rb b/spec/ruby/library/net-ftp/FTPReplyError_spec.rb
index fcc7501fc1..fcc7501fc1 100644
--- a/spec/ruby/library/net/FTPReplyError_spec.rb
+++ b/spec/ruby/library/net-ftp/FTPReplyError_spec.rb
diff --git a/spec/ruby/library/net/FTPTempError_spec.rb b/spec/ruby/library/net-ftp/FTPTempError_spec.rb
index f4b045dfb5..f4b045dfb5 100644
--- a/spec/ruby/library/net/FTPTempError_spec.rb
+++ b/spec/ruby/library/net-ftp/FTPTempError_spec.rb
diff --git a/spec/ruby/library/net/ftp/abort_spec.rb b/spec/ruby/library/net-ftp/abort_spec.rb
index 57651468d8..335d056512 100644
--- a/spec/ruby/library/net/ftp/abort_spec.rb
+++ b/spec/ruby/library/net-ftp/abort_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/acct_spec.rb b/spec/ruby/library/net-ftp/acct_spec.rb
index d8068dc81e..ab093448a2 100644
--- a/spec/ruby/library/net/ftp/acct_spec.rb
+++ b/spec/ruby/library/net-ftp/acct_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/binary_spec.rb b/spec/ruby/library/net-ftp/binary_spec.rb
index 60e312a673..1e0585b795 100644
--- a/spec/ruby/library/net/ftp/binary_spec.rb
+++ b/spec/ruby/library/net-ftp/binary_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#binary" do
diff --git a/spec/ruby/library/net/ftp/chdir_spec.rb b/spec/ruby/library/net-ftp/chdir_spec.rb
index 4c10fa78b4..cc129b5e42 100644
--- a/spec/ruby/library/net/ftp/chdir_spec.rb
+++ b/spec/ruby/library/net-ftp/chdir_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/close_spec.rb b/spec/ruby/library/net-ftp/close_spec.rb
index 95c72b29ed..183f14a84b 100644
--- a/spec/ruby/library/net/ftp/close_spec.rb
+++ b/spec/ruby/library/net-ftp/close_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#close" do
diff --git a/spec/ruby/library/net/ftp/closed_spec.rb b/spec/ruby/library/net-ftp/closed_spec.rb
index 1f3e69b0c1..84001cdc0f 100644
--- a/spec/ruby/library/net/ftp/closed_spec.rb
+++ b/spec/ruby/library/net-ftp/closed_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#closed?" do
diff --git a/spec/ruby/library/net/ftp/connect_spec.rb b/spec/ruby/library/net-ftp/connect_spec.rb
index 9ee9bcd2c6..4330d430b4 100644
--- a/spec/ruby/library/net/ftp/connect_spec.rb
+++ b/spec/ruby/library/net-ftp/connect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
@@ -26,10 +26,12 @@ describe "Net::FTP#connect" do
@ftp.connect(@server.hostname, @server.server_port).should be_nil
end
- it "prints a small debug line when in debug mode" do
- @ftp.debug_mode = true
- -> { @ftp.connect(@server.hostname, @server.server_port) }.should output(/#{"connect: "}#{@server.hostname}#{", "}#{@server.server_port}#{"\\nget: 220 Dummy FTP Server ready!"}/)
- @ftp.debug_mode = false
+ ruby_version_is ""..."3.1" do
+ it "prints a small debug line when in debug mode" do
+ @ftp.debug_mode = true
+ -> { @ftp.connect(@server.hostname, @server.server_port) }.should output(/connect: #{@server.hostname}, #{@server.server_port}\nget: 220 Dummy FTP Server ready!/)
+ @ftp.debug_mode = false
+ end
end
it "does not raise any error when the response code is 220" do
diff --git a/spec/ruby/library/net/ftp/debug_mode_spec.rb b/spec/ruby/library/net-ftp/debug_mode_spec.rb
index f49da55ed1..f2ef53c089 100644
--- a/spec/ruby/library/net/ftp/debug_mode_spec.rb
+++ b/spec/ruby/library/net-ftp/debug_mode_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#debug_mode" do
diff --git a/spec/ruby/library/net/ftp/default_passive_spec.rb b/spec/ruby/library/net-ftp/default_passive_spec.rb
index 30eb8f9da2..3f14f6187e 100644
--- a/spec/ruby/library/net/ftp/default_passive_spec.rb
+++ b/spec/ruby/library/net-ftp/default_passive_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#default_passive" do
diff --git a/spec/ruby/library/net/ftp/delete_spec.rb b/spec/ruby/library/net-ftp/delete_spec.rb
index cf8f9332e2..bfb7da1ffe 100644
--- a/spec/ruby/library/net/ftp/delete_spec.rb
+++ b/spec/ruby/library/net-ftp/delete_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/dir_spec.rb b/spec/ruby/library/net-ftp/dir_spec.rb
index 47ac7b8d9b..894f03dd7b 100644
--- a/spec/ruby/library/net/ftp/dir_spec.rb
+++ b/spec/ruby/library/net-ftp/dir_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
require_relative 'shared/list'
diff --git a/spec/ruby/library/net/ftp/fixtures/default_passive.rb b/spec/ruby/library/net-ftp/fixtures/default_passive.rb
index b6995d6f34..b6995d6f34 100644
--- a/spec/ruby/library/net/ftp/fixtures/default_passive.rb
+++ b/spec/ruby/library/net-ftp/fixtures/default_passive.rb
diff --git a/spec/ruby/library/net/ftp/fixtures/passive.rb b/spec/ruby/library/net-ftp/fixtures/passive.rb
index 6b5cde82df..6b5cde82df 100644
--- a/spec/ruby/library/net/ftp/fixtures/passive.rb
+++ b/spec/ruby/library/net-ftp/fixtures/passive.rb
diff --git a/spec/ruby/library/net/ftp/fixtures/putbinaryfile b/spec/ruby/library/net-ftp/fixtures/putbinaryfile
index f3130c6e43..f3130c6e43 100644
--- a/spec/ruby/library/net/ftp/fixtures/putbinaryfile
+++ b/spec/ruby/library/net-ftp/fixtures/putbinaryfile
diff --git a/spec/ruby/library/net/ftp/fixtures/puttextfile b/spec/ruby/library/net-ftp/fixtures/puttextfile
index b4f3b2b62d..b4f3b2b62d 100644
--- a/spec/ruby/library/net/ftp/fixtures/puttextfile
+++ b/spec/ruby/library/net-ftp/fixtures/puttextfile
diff --git a/spec/ruby/library/net/ftp/fixtures/server.rb b/spec/ruby/library/net-ftp/fixtures/server.rb
index ecbed591d5..ecbed591d5 100644
--- a/spec/ruby/library/net/ftp/fixtures/server.rb
+++ b/spec/ruby/library/net-ftp/fixtures/server.rb
diff --git a/spec/ruby/library/net/ftp/get_spec.rb b/spec/ruby/library/net-ftp/get_spec.rb
index c4672b55a5..1bc1bd744b 100644
--- a/spec/ruby/library/net/ftp/get_spec.rb
+++ b/spec/ruby/library/net-ftp/get_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
require_relative 'shared/gettextfile'
diff --git a/spec/ruby/library/net/ftp/getbinaryfile_spec.rb b/spec/ruby/library/net-ftp/getbinaryfile_spec.rb
index 155851b53c..e9898fccc7 100644
--- a/spec/ruby/library/net/ftp/getbinaryfile_spec.rb
+++ b/spec/ruby/library/net-ftp/getbinaryfile_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
require_relative 'shared/getbinaryfile'
diff --git a/spec/ruby/library/net/ftp/getdir_spec.rb b/spec/ruby/library/net-ftp/getdir_spec.rb
index eea35ac130..756d6a23af 100644
--- a/spec/ruby/library/net/ftp/getdir_spec.rb
+++ b/spec/ruby/library/net-ftp/getdir_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'shared/pwd'
diff --git a/spec/ruby/library/net/ftp/gettextfile_spec.rb b/spec/ruby/library/net-ftp/gettextfile_spec.rb
index 79395ae009..cdd1b4c797 100644
--- a/spec/ruby/library/net/ftp/gettextfile_spec.rb
+++ b/spec/ruby/library/net-ftp/gettextfile_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
require_relative 'shared/gettextfile'
diff --git a/spec/ruby/library/net/ftp/help_spec.rb b/spec/ruby/library/net-ftp/help_spec.rb
index d2e9fe7ee8..c562be50b2 100644
--- a/spec/ruby/library/net/ftp/help_spec.rb
+++ b/spec/ruby/library/net-ftp/help_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/initialize_spec.rb b/spec/ruby/library/net-ftp/initialize_spec.rb
index a2f64ddb1b..4d775e8dc1 100644
--- a/spec/ruby/library/net/ftp/initialize_spec.rb
+++ b/spec/ruby/library/net-ftp/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#initialize" do
diff --git a/spec/ruby/library/net/ftp/last_response_code_spec.rb b/spec/ruby/library/net-ftp/last_response_code_spec.rb
index 3eb20f7ad8..c17c28f0f8 100644
--- a/spec/ruby/library/net/ftp/last_response_code_spec.rb
+++ b/spec/ruby/library/net-ftp/last_response_code_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'shared/last_response_code'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/last_response_spec.rb b/spec/ruby/library/net-ftp/last_response_spec.rb
index ada665d59c..c9d9d70f35 100644
--- a/spec/ruby/library/net/ftp/last_response_spec.rb
+++ b/spec/ruby/library/net-ftp/last_response_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/lastresp_spec.rb b/spec/ruby/library/net-ftp/lastresp_spec.rb
index 273e216e8b..e0c1b862a0 100644
--- a/spec/ruby/library/net/ftp/lastresp_spec.rb
+++ b/spec/ruby/library/net-ftp/lastresp_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'shared/last_response_code'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/list_spec.rb b/spec/ruby/library/net-ftp/list_spec.rb
index 6175172923..6cb1bbc4b8 100644
--- a/spec/ruby/library/net/ftp/list_spec.rb
+++ b/spec/ruby/library/net-ftp/list_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
require_relative 'shared/list'
diff --git a/spec/ruby/library/net/ftp/login_spec.rb b/spec/ruby/library/net-ftp/login_spec.rb
index 46736851ee..0de2f5cc63 100644
--- a/spec/ruby/library/net/ftp/login_spec.rb
+++ b/spec/ruby/library/net-ftp/login_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/ls_spec.rb b/spec/ruby/library/net-ftp/ls_spec.rb
index e729eb9481..acd7e9e523 100644
--- a/spec/ruby/library/net/ftp/ls_spec.rb
+++ b/spec/ruby/library/net-ftp/ls_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
require_relative 'shared/list'
diff --git a/spec/ruby/library/net/ftp/mdtm_spec.rb b/spec/ruby/library/net-ftp/mdtm_spec.rb
index b74cf8d3c7..a504507c84 100644
--- a/spec/ruby/library/net/ftp/mdtm_spec.rb
+++ b/spec/ruby/library/net-ftp/mdtm_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/mkdir_spec.rb b/spec/ruby/library/net-ftp/mkdir_spec.rb
index 7dc45b5711..8cc6ae785e 100644
--- a/spec/ruby/library/net/ftp/mkdir_spec.rb
+++ b/spec/ruby/library/net-ftp/mkdir_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/mtime_spec.rb b/spec/ruby/library/net-ftp/mtime_spec.rb
index 0f6cc1ba20..9dde1278a8 100644
--- a/spec/ruby/library/net/ftp/mtime_spec.rb
+++ b/spec/ruby/library/net-ftp/mtime_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/nlst_spec.rb b/spec/ruby/library/net-ftp/nlst_spec.rb
index 34384fb8c4..2f22543af6 100644
--- a/spec/ruby/library/net/ftp/nlst_spec.rb
+++ b/spec/ruby/library/net-ftp/nlst_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/noop_spec.rb b/spec/ruby/library/net-ftp/noop_spec.rb
index 070750ced7..4743a39ef6 100644
--- a/spec/ruby/library/net/ftp/noop_spec.rb
+++ b/spec/ruby/library/net-ftp/noop_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/open_spec.rb b/spec/ruby/library/net-ftp/open_spec.rb
index 7be02ff373..e59496dc3c 100644
--- a/spec/ruby/library/net/ftp/open_spec.rb
+++ b/spec/ruby/library/net-ftp/open_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP.open" do
diff --git a/spec/ruby/library/net/ftp/passive_spec.rb b/spec/ruby/library/net-ftp/passive_spec.rb
index e8db030cbd..97659f1b68 100644
--- a/spec/ruby/library/net/ftp/passive_spec.rb
+++ b/spec/ruby/library/net-ftp/passive_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#passive" do
diff --git a/spec/ruby/library/net/ftp/put_spec.rb b/spec/ruby/library/net-ftp/put_spec.rb
index f1f85b5d05..6d40d3d5b9 100644
--- a/spec/ruby/library/net/ftp/put_spec.rb
+++ b/spec/ruby/library/net-ftp/put_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
require_relative 'shared/puttextfile'
diff --git a/spec/ruby/library/net/ftp/putbinaryfile_spec.rb b/spec/ruby/library/net-ftp/putbinaryfile_spec.rb
index cb1c7bef5a..d0398229e5 100644
--- a/spec/ruby/library/net/ftp/putbinaryfile_spec.rb
+++ b/spec/ruby/library/net-ftp/putbinaryfile_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
require_relative 'shared/putbinaryfile'
diff --git a/spec/ruby/library/net/ftp/puttextfile_spec.rb b/spec/ruby/library/net-ftp/puttextfile_spec.rb
index 00a930afd7..b8bcac33df 100644
--- a/spec/ruby/library/net/ftp/puttextfile_spec.rb
+++ b/spec/ruby/library/net-ftp/puttextfile_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
require_relative 'shared/puttextfile'
diff --git a/spec/ruby/library/net/ftp/pwd_spec.rb b/spec/ruby/library/net-ftp/pwd_spec.rb
index a3998cc730..992e2c4ed2 100644
--- a/spec/ruby/library/net/ftp/pwd_spec.rb
+++ b/spec/ruby/library/net-ftp/pwd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/quit_spec.rb b/spec/ruby/library/net-ftp/quit_spec.rb
index 8e3cb28b90..c5352ceada 100644
--- a/spec/ruby/library/net/ftp/quit_spec.rb
+++ b/spec/ruby/library/net-ftp/quit_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/rename_spec.rb b/spec/ruby/library/net-ftp/rename_spec.rb
index 376b203ac9..48f81b7deb 100644
--- a/spec/ruby/library/net/ftp/rename_spec.rb
+++ b/spec/ruby/library/net-ftp/rename_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/resume_spec.rb b/spec/ruby/library/net-ftp/resume_spec.rb
index 51b1cff2a4..6592fc5bb0 100644
--- a/spec/ruby/library/net/ftp/resume_spec.rb
+++ b/spec/ruby/library/net-ftp/resume_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#resume" do
diff --git a/spec/ruby/library/net/ftp/retrbinary_spec.rb b/spec/ruby/library/net-ftp/retrbinary_spec.rb
index 30e2484af5..de024208aa 100644
--- a/spec/ruby/library/net/ftp/retrbinary_spec.rb
+++ b/spec/ruby/library/net-ftp/retrbinary_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/retrlines_spec.rb b/spec/ruby/library/net-ftp/retrlines_spec.rb
index 546df3844e..866ecb5f40 100644
--- a/spec/ruby/library/net/ftp/retrlines_spec.rb
+++ b/spec/ruby/library/net-ftp/retrlines_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/return_code_spec.rb b/spec/ruby/library/net-ftp/return_code_spec.rb
index e4b98c8031..35a6232f7e 100644
--- a/spec/ruby/library/net/ftp/return_code_spec.rb
+++ b/spec/ruby/library/net-ftp/return_code_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#return_code" do
diff --git a/spec/ruby/library/net/ftp/rmdir_spec.rb b/spec/ruby/library/net-ftp/rmdir_spec.rb
index 0515897998..400874d60d 100644
--- a/spec/ruby/library/net/ftp/rmdir_spec.rb
+++ b/spec/ruby/library/net-ftp/rmdir_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/sendcmd_spec.rb b/spec/ruby/library/net-ftp/sendcmd_spec.rb
index dafa36e032..c50b373869 100644
--- a/spec/ruby/library/net/ftp/sendcmd_spec.rb
+++ b/spec/ruby/library/net-ftp/sendcmd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/set_socket_spec.rb b/spec/ruby/library/net-ftp/set_socket_spec.rb
index 7ca3bbbe27..8182dd8b33 100644
--- a/spec/ruby/library/net/ftp/set_socket_spec.rb
+++ b/spec/ruby/library/net-ftp/set_socket_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
describe "Net::FTP#set_socket" do
diff --git a/spec/ruby/library/net/ftp/shared/getbinaryfile.rb b/spec/ruby/library/net-ftp/shared/getbinaryfile.rb
index f324f5b85d..ceec8e7cd5 100644
--- a/spec/ruby/library/net/ftp/shared/getbinaryfile.rb
+++ b/spec/ruby/library/net-ftp/shared/getbinaryfile.rb
@@ -1,6 +1,6 @@
-describe :net_ftp_getbinaryfile, shared: :true do
+describe :net_ftp_getbinaryfile, shared: true do
before :each do
- @fixture_file = File.dirname(__FILE__) + "/../fixtures/getbinaryfile"
+ @fixture_file = __dir__ + "/../fixtures/getbinaryfile"
@tmp_file = tmp("getbinaryfile")
@server = NetFTPSpecs::DummyFTP.new
diff --git a/spec/ruby/library/net/ftp/shared/gettextfile.rb b/spec/ruby/library/net-ftp/shared/gettextfile.rb
index 82bec2a4a7..7fe14f7dfb 100644
--- a/spec/ruby/library/net/ftp/shared/gettextfile.rb
+++ b/spec/ruby/library/net-ftp/shared/gettextfile.rb
@@ -1,4 +1,4 @@
-describe :net_ftp_gettextfile, shared: :true do
+describe :net_ftp_gettextfile, shared: true do
before :each do
@tmp_file = tmp("gettextfile")
diff --git a/spec/ruby/library/net/ftp/shared/last_response_code.rb b/spec/ruby/library/net-ftp/shared/last_response_code.rb
index 4fe53677db..4fe53677db 100644
--- a/spec/ruby/library/net/ftp/shared/last_response_code.rb
+++ b/spec/ruby/library/net-ftp/shared/last_response_code.rb
diff --git a/spec/ruby/library/net/ftp/shared/list.rb b/spec/ruby/library/net-ftp/shared/list.rb
index adc3fa59c1..adc3fa59c1 100644
--- a/spec/ruby/library/net/ftp/shared/list.rb
+++ b/spec/ruby/library/net-ftp/shared/list.rb
diff --git a/spec/ruby/library/net/ftp/shared/putbinaryfile.rb b/spec/ruby/library/net-ftp/shared/putbinaryfile.rb
index 1163a1cfea..45f53adc2a 100644
--- a/spec/ruby/library/net/ftp/shared/putbinaryfile.rb
+++ b/spec/ruby/library/net-ftp/shared/putbinaryfile.rb
@@ -1,9 +1,9 @@
-describe :net_ftp_putbinaryfile, shared: :true do
+describe :net_ftp_putbinaryfile, shared: true do
before :each do
@server = NetFTPSpecs::DummyFTP.new
@server.serve_once
- @local_fixture_file = File.dirname(__FILE__) + "/../fixtures/putbinaryfile"
+ @local_fixture_file = __dir__ + "/../fixtures/putbinaryfile"
@remote_tmp_file = tmp("binaryfile", false)
@ftp = Net::FTP.new
diff --git a/spec/ruby/library/net/ftp/shared/puttextfile.rb b/spec/ruby/library/net-ftp/shared/puttextfile.rb
index 50e8de28e6..4722439674 100644
--- a/spec/ruby/library/net/ftp/shared/puttextfile.rb
+++ b/spec/ruby/library/net-ftp/shared/puttextfile.rb
@@ -3,7 +3,7 @@ describe :net_ftp_puttextfile, shared: true do
@server = NetFTPSpecs::DummyFTP.new
@server.serve_once
- @local_fixture_file = File.dirname(__FILE__) + "/../fixtures/puttextfile"
+ @local_fixture_file = __dir__ + "/../fixtures/puttextfile"
@remote_tmp_file = tmp("textfile", false)
@ftp = Net::FTP.new
@@ -27,8 +27,8 @@ describe :net_ftp_puttextfile, shared: true do
it "sends the contents of the passed local_file, using \\r\\n as the newline separator" do
@ftp.send(@method, @local_fixture_file, "text")
- remote_lines = open(@remote_tmp_file, "rb") {|f| f.read }
- local_lines = open(@local_fixture_file, "rb") {|f| f.read }
+ remote_lines = File.binread(@remote_tmp_file)
+ local_lines = File.binread(@local_fixture_file)
remote_lines.should_not == local_lines
remote_lines.should == local_lines.gsub("\n", "\r\n")
diff --git a/spec/ruby/library/net/ftp/shared/pwd.rb b/spec/ruby/library/net-ftp/shared/pwd.rb
index 951d020f2d..951d020f2d 100644
--- a/spec/ruby/library/net/ftp/shared/pwd.rb
+++ b/spec/ruby/library/net-ftp/shared/pwd.rb
diff --git a/spec/ruby/library/net/ftp/site_spec.rb b/spec/ruby/library/net-ftp/site_spec.rb
index 4d6a9b4a0c..c3e589a920 100644
--- a/spec/ruby/library/net/ftp/site_spec.rb
+++ b/spec/ruby/library/net-ftp/site_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/size_spec.rb b/spec/ruby/library/net-ftp/size_spec.rb
index 17615079e9..0cf2e24477 100644
--- a/spec/ruby/library/net/ftp/size_spec.rb
+++ b/spec/ruby/library/net-ftp/size_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/spec_helper.rb b/spec/ruby/library/net-ftp/spec_helper.rb
index c87d16218b..c87d16218b 100644
--- a/spec/ruby/library/net/ftp/spec_helper.rb
+++ b/spec/ruby/library/net-ftp/spec_helper.rb
diff --git a/spec/ruby/library/net/ftp/status_spec.rb b/spec/ruby/library/net-ftp/status_spec.rb
index 6e3840bf93..9d9f86c381 100644
--- a/spec/ruby/library/net/ftp/status_spec.rb
+++ b/spec/ruby/library/net-ftp/status_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/storbinary_spec.rb b/spec/ruby/library/net-ftp/storbinary_spec.rb
index eb65db1e8d..aa4c51f2e8 100644
--- a/spec/ruby/library/net/ftp/storbinary_spec.rb
+++ b/spec/ruby/library/net-ftp/storbinary_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
+
require_relative 'spec_helper'
require_relative 'fixtures/server'
@@ -7,7 +8,7 @@ describe "Net::FTP#storbinary" do
@server = NetFTPSpecs::DummyFTP.new
@server.serve_once
- @local_fixture_file = File.dirname(__FILE__) + "/fixtures/putbinaryfile"
+ @local_fixture_file = __dir__ + "/fixtures/putbinaryfile"
@tmp_file = tmp("binaryfile", false)
@ftp = Net::FTP.new
diff --git a/spec/ruby/library/net/ftp/storlines_spec.rb b/spec/ruby/library/net-ftp/storlines_spec.rb
index 4affa37eee..dc6830da7b 100644
--- a/spec/ruby/library/net/ftp/storlines_spec.rb
+++ b/spec/ruby/library/net-ftp/storlines_spec.rb
@@ -1,4 +1,5 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
+
require_relative 'spec_helper'
require_relative 'fixtures/server'
@@ -7,7 +8,7 @@ describe "Net::FTP#storlines" do
@server = NetFTPSpecs::DummyFTP.new
@server.serve_once
- @local_fixture_file = File.dirname(__FILE__) + "/fixtures/puttextfile"
+ @local_fixture_file = __dir__ + "/fixtures/puttextfile"
@tmp_file = tmp("textfile", false)
@ftp = Net::FTP.new
diff --git a/spec/ruby/library/net/ftp/system_spec.rb b/spec/ruby/library/net-ftp/system_spec.rb
index 749258622d..2b7f0d2560 100644
--- a/spec/ruby/library/net/ftp/system_spec.rb
+++ b/spec/ruby/library/net-ftp/system_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/voidcmd_spec.rb b/spec/ruby/library/net-ftp/voidcmd_spec.rb
index 3673c7fd5b..f2536fe697 100644
--- a/spec/ruby/library/net/ftp/voidcmd_spec.rb
+++ b/spec/ruby/library/net-ftp/voidcmd_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/ftp/welcome_spec.rb b/spec/ruby/library/net-ftp/welcome_spec.rb
index a0d7483949..4279127ce3 100644
--- a/spec/ruby/library/net/ftp/welcome_spec.rb
+++ b/spec/ruby/library/net-ftp/welcome_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'
diff --git a/spec/ruby/library/net/http/HTTPBadResponse_spec.rb b/spec/ruby/library/net-http/HTTPBadResponse_spec.rb
index be644968f5..8f2e8ccfaf 100644
--- a/spec/ruby/library/net/http/HTTPBadResponse_spec.rb
+++ b/spec/ruby/library/net-http/HTTPBadResponse_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require 'net/http'
describe "Net::HTTPBadResponse" do
diff --git a/spec/ruby/library/net-http/HTTPClientExcepton_spec.rb b/spec/ruby/library/net-http/HTTPClientExcepton_spec.rb
new file mode 100644
index 0000000000..2992e6596f
--- /dev/null
+++ b/spec/ruby/library/net-http/HTTPClientExcepton_spec.rb
@@ -0,0 +1,12 @@
+require_relative '../../spec_helper'
+require 'net/http'
+
+describe "Net::HTTPClientException" do
+ it "is a subclass of Net::ProtoServerError" do
+ Net::HTTPClientException.should < Net::ProtoServerError
+ end
+
+ it "includes the Net::HTTPExceptions module" do
+ Net::HTTPClientException.should < Net::HTTPExceptions
+ end
+end
diff --git a/spec/ruby/library/net/http/HTTPError_spec.rb b/spec/ruby/library/net-http/HTTPError_spec.rb
index ab5f491bb7..7f79eef8cf 100644
--- a/spec/ruby/library/net/http/HTTPError_spec.rb
+++ b/spec/ruby/library/net-http/HTTPError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require 'net/http'
describe "Net::HTTPError" do
diff --git a/spec/ruby/library/net/http/HTTPFatalError_spec.rb b/spec/ruby/library/net-http/HTTPFatalError_spec.rb
index 6ab36bff6c..0113b9da2d 100644
--- a/spec/ruby/library/net/http/HTTPFatalError_spec.rb
+++ b/spec/ruby/library/net-http/HTTPFatalError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require 'net/http'
describe "Net::HTTPFatalError" do
diff --git a/spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb b/spec/ruby/library/net-http/HTTPHeaderSyntaxError_spec.rb
index 38e9454f99..b3b73ff46f 100644
--- a/spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb
+++ b/spec/ruby/library/net-http/HTTPHeaderSyntaxError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require 'net/http'
describe "Net::HTTPHeaderSyntaxError" do
diff --git a/spec/ruby/library/net/http/HTTPRetriableError_spec.rb b/spec/ruby/library/net-http/HTTPRetriableError_spec.rb
index 3a4bb9146c..677731fb68 100644
--- a/spec/ruby/library/net/http/HTTPRetriableError_spec.rb
+++ b/spec/ruby/library/net-http/HTTPRetriableError_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../spec_helper'
+require_relative '../../spec_helper'
require 'net/http'
describe "Net::HTTPRetriableError" do
diff --git a/spec/ruby/library/net-http/HTTPServerException_spec.rb b/spec/ruby/library/net-http/HTTPServerException_spec.rb
new file mode 100644
index 0000000000..5e0a833fee
--- /dev/null
+++ b/spec/ruby/library/net-http/HTTPServerException_spec.rb
@@ -0,0 +1,12 @@
+require_relative '../../spec_helper'
+require 'net/http'
+
+describe "Net::HTTPServerException" do
+ it "is a subclass of Net::ProtoServerError and is warned as deprecated" do
+ -> { Net::HTTPServerException.should < Net::ProtoServerError }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
+ end
+
+ it "includes the Net::HTTPExceptions module and is warned as deprecated" do
+ -> { Net::HTTPServerException.should < Net::HTTPExceptions }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
+ end
+end
diff --git a/spec/ruby/library/net/http/http/Proxy_spec.rb b/spec/ruby/library/net-http/http/Proxy_spec.rb
index f85ccc0ee9..a1a04fa00b 100644
--- a/spec/ruby/library/net/http/http/Proxy_spec.rb
+++ b/spec/ruby/library/net-http/http/Proxy_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.Proxy" do
diff --git a/spec/ruby/library/net/http/http/active_spec.rb b/spec/ruby/library/net-http/http/active_spec.rb
index ef657243ba..c260274594 100644
--- a/spec/ruby/library/net/http/http/active_spec.rb
+++ b/spec/ruby/library/net-http/http/active_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/started'
diff --git a/spec/ruby/library/net/http/http/address_spec.rb b/spec/ruby/library/net-http/http/address_spec.rb
index 5fce76d767..7c5b82a8f9 100644
--- a/spec/ruby/library/net/http/http/address_spec.rb
+++ b/spec/ruby/library/net-http/http/address_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP#address" do
diff --git a/spec/ruby/library/net/http/http/close_on_empty_response_spec.rb b/spec/ruby/library/net-http/http/close_on_empty_response_spec.rb
index a97b7b6c43..9cc756befb 100644
--- a/spec/ruby/library/net/http/http/close_on_empty_response_spec.rb
+++ b/spec/ruby/library/net-http/http/close_on_empty_response_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP#close_on_empty_response" do
diff --git a/spec/ruby/library/net/http/http/copy_spec.rb b/spec/ruby/library/net-http/http/copy_spec.rb
index 5ebfdc334e..fba96c0f11 100644
--- a/spec/ruby/library/net/http/http/copy_spec.rb
+++ b/spec/ruby/library/net-http/http/copy_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/default_port_spec.rb b/spec/ruby/library/net-http/http/default_port_spec.rb
index 30db18efae..95b7316a0c 100644
--- a/spec/ruby/library/net/http/http/default_port_spec.rb
+++ b/spec/ruby/library/net-http/http/default_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.default_port" do
diff --git a/spec/ruby/library/net/http/http/delete_spec.rb b/spec/ruby/library/net-http/http/delete_spec.rb
index 160c653115..d73aa5b375 100644
--- a/spec/ruby/library/net/http/http/delete_spec.rb
+++ b/spec/ruby/library/net-http/http/delete_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/finish_spec.rb b/spec/ruby/library/net-http/http/finish_spec.rb
index f98bc7be13..d4aa00dffe 100644
--- a/spec/ruby/library/net/http/http/finish_spec.rb
+++ b/spec/ruby/library/net-http/http/finish_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net-http/http/fixtures/http_server.rb b/spec/ruby/library/net-http/http/fixtures/http_server.rb
new file mode 100644
index 0000000000..c1cedbfa76
--- /dev/null
+++ b/spec/ruby/library/net-http/http/fixtures/http_server.rb
@@ -0,0 +1,123 @@
+require 'socket'
+
+module NetHTTPSpecs
+ class NullWriter
+ def <<(s) end
+ def puts(*args) end
+ def print(*args) end
+ def printf(*args) end
+ end
+
+ class SmallHTTPServer
+ def initialize(bind_address)
+ @server = TCPServer.new(bind_address, 0)
+ @thread = Thread.new {
+ Thread.current.abort_on_exception = true
+ listen
+ }
+ end
+
+ def ip
+ @server.addr[3]
+ end
+
+ def port
+ @server.addr[1]
+ end
+
+ def listen
+ until @server.closed?
+ client = @server.accept
+ handle_client(client)
+ end
+ end
+
+ def handle_client(client)
+ begin
+ until client.closed?
+ request = client.gets("\r\n\r\n")
+ break unless request
+ if request == "CLOSE"
+ @server.close
+ break
+ end
+ handle_request(client, request)
+ end
+ ensure
+ client.close
+ end
+ end
+
+ def parse_request(request)
+ request, *headers = request.chomp.lines.map { |line| line.chomp }
+ request_method, request_uri, _http_version = request.split
+ headers = headers.map { |line| line.split(': ', 2) }.to_h
+ [request_method, request_uri, headers]
+ end
+
+ def handle_request(client, request)
+ request_method, request_uri, headers = parse_request(request)
+
+ if headers.include? 'Content-Length'
+ request_body_size = Integer(headers['Content-Length'])
+ request_body = client.read(request_body_size)
+ end
+
+ case request_uri
+ when '/'
+ raise request_method unless request_method == 'GET'
+ reply(client, "This is the index page.", request_method)
+ when '/request'
+ reply(client, "Request type: #{request_method}", request_method)
+ when '/request/body'
+ reply(client, request_body, request_method)
+ when '/request/header'
+ reply(client, headers.inspect, request_method)
+ when '/request/basic_auth'
+ reply(client, "username: \npassword: ", request_method)
+ else
+ raise request_uri
+ end
+ end
+
+ def reply(client, body, request_method)
+ client.print "HTTP/1.1 200 OK\r\n"
+ if request_method == 'HEAD'
+ client.close
+ else
+ client.print "Content-Type: text/plain\r\n"
+ client.print "Content-Length: #{body.bytesize}\r\n"
+ client.print "\r\n"
+ client.print body
+ end
+ end
+
+ def close
+ TCPSocket.open(ip, port) do |socket|
+ socket.write "CLOSE"
+ end
+ @thread.join
+ end
+ end
+
+ @server = nil
+
+ class << self
+ def port
+ raise "server not started" unless @server
+ @server.port
+ end
+
+ def start_server
+ bind_address = platform_is(:windows) ? "localhost" : "127.0.0.1"
+ @server = SmallHTTPServer.new(bind_address)
+ end
+
+ def stop_server
+ if @server
+ @server.close
+ @server = nil
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/net/http/http/get2_spec.rb b/spec/ruby/library/net-http/http/get2_spec.rb
index 519e4c2599..57c05ec64b 100644
--- a/spec/ruby/library/net/http/http/get2_spec.rb
+++ b/spec/ruby/library/net-http/http/get2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/request_get'
diff --git a/spec/ruby/library/net/http/http/get_print_spec.rb b/spec/ruby/library/net-http/http/get_print_spec.rb
index f59dd68c81..3c24ce44ea 100644
--- a/spec/ruby/library/net/http/http/get_print_spec.rb
+++ b/spec/ruby/library/net-http/http/get_print_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/get_response_spec.rb b/spec/ruby/library/net-http/http/get_response_spec.rb
index 941b35e773..7133ef8101 100644
--- a/spec/ruby/library/net/http/http/get_response_spec.rb
+++ b/spec/ruby/library/net-http/http/get_response_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/get_spec.rb b/spec/ruby/library/net-http/http/get_spec.rb
index 0948006fca..e64a61c52c 100644
--- a/spec/ruby/library/net/http/http/get_spec.rb
+++ b/spec/ruby/library/net-http/http/get_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
@@ -30,6 +30,7 @@ describe "Net::HTTP.get" do
describe "when reading gzipped contents" do
def start_threads
require 'zlib'
+ require 'stringio'
server = nil
server_thread = Thread.new do
@@ -79,15 +80,13 @@ describe "Net::HTTP.get" do
end
end
- ruby_version_is "3.0" do # https://bugs.ruby-lang.org/issues/13882#note-6
- it "lets the kill Thread exception goes through and does not replace it with Zlib::BufError" do
- socket, client_thread = start_threads
- begin
- client_thread.kill
- client_thread.value.should == nil
- ensure
- socket.close
- end
+ it "lets the kill Thread exception goes through and does not replace it with Zlib::BufError" do
+ socket, client_thread = start_threads
+ begin
+ client_thread.kill
+ client_thread.value.should == nil
+ ensure
+ socket.close
end
end
end
diff --git a/spec/ruby/library/net/http/http/head2_spec.rb b/spec/ruby/library/net-http/http/head2_spec.rb
index 6958204ee1..84cfff33d7 100644
--- a/spec/ruby/library/net/http/http/head2_spec.rb
+++ b/spec/ruby/library/net-http/http/head2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/request_head'
diff --git a/spec/ruby/library/net/http/http/head_spec.rb b/spec/ruby/library/net-http/http/head_spec.rb
index 925a8e6043..64621fa87b 100644
--- a/spec/ruby/library/net/http/http/head_spec.rb
+++ b/spec/ruby/library/net-http/http/head_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/http_default_port_spec.rb b/spec/ruby/library/net-http/http/http_default_port_spec.rb
index cf7f73e630..3b17bcd0a5 100644
--- a/spec/ruby/library/net/http/http/http_default_port_spec.rb
+++ b/spec/ruby/library/net-http/http/http_default_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.http_default_port" do
diff --git a/spec/ruby/library/net/http/http/https_default_port_spec.rb b/spec/ruby/library/net-http/http/https_default_port_spec.rb
index fbf0bd1abc..8c24e1d97c 100644
--- a/spec/ruby/library/net/http/http/https_default_port_spec.rb
+++ b/spec/ruby/library/net-http/http/https_default_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.https_default_port" do
diff --git a/spec/ruby/library/net/http/http/initialize_spec.rb b/spec/ruby/library/net-http/http/initialize_spec.rb
index 7683713a0e..78aa01e1aa 100644
--- a/spec/ruby/library/net/http/http/initialize_spec.rb
+++ b/spec/ruby/library/net-http/http/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP#initialize" do
diff --git a/spec/ruby/library/net/http/http/inspect_spec.rb b/spec/ruby/library/net-http/http/inspect_spec.rb
index b1e799ca34..b8f650809e 100644
--- a/spec/ruby/library/net/http/http/inspect_spec.rb
+++ b/spec/ruby/library/net-http/http/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/is_version_1_1_spec.rb b/spec/ruby/library/net-http/http/is_version_1_1_spec.rb
index f37695b777..bdb343f9e0 100644
--- a/spec/ruby/library/net/http/http/is_version_1_1_spec.rb
+++ b/spec/ruby/library/net-http/http/is_version_1_1_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'shared/version_1_1'
diff --git a/spec/ruby/library/net/http/http/is_version_1_2_spec.rb b/spec/ruby/library/net-http/http/is_version_1_2_spec.rb
index 82dbdc87aa..555bb205dd 100644
--- a/spec/ruby/library/net/http/http/is_version_1_2_spec.rb
+++ b/spec/ruby/library/net-http/http/is_version_1_2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'shared/version_1_2'
diff --git a/spec/ruby/library/net/http/http/lock_spec.rb b/spec/ruby/library/net-http/http/lock_spec.rb
index bb76607a8b..aa1f944196 100644
--- a/spec/ruby/library/net/http/http/lock_spec.rb
+++ b/spec/ruby/library/net-http/http/lock_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/mkcol_spec.rb b/spec/ruby/library/net-http/http/mkcol_spec.rb
index 33017625e2..f8009f9059 100644
--- a/spec/ruby/library/net/http/http/mkcol_spec.rb
+++ b/spec/ruby/library/net-http/http/mkcol_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/move_spec.rb b/spec/ruby/library/net-http/http/move_spec.rb
index 4d6b828150..ae43016a2c 100644
--- a/spec/ruby/library/net/http/http/move_spec.rb
+++ b/spec/ruby/library/net-http/http/move_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/new_spec.rb b/spec/ruby/library/net-http/http/new_spec.rb
index 491d1d01fd..1ec6bbd0c0 100644
--- a/spec/ruby/library/net/http/http/new_spec.rb
+++ b/spec/ruby/library/net-http/http/new_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.new" do
diff --git a/spec/ruby/library/net/http/http/newobj_spec.rb b/spec/ruby/library/net-http/http/newobj_spec.rb
index b261dcc5db..e19b30fca9 100644
--- a/spec/ruby/library/net/http/http/newobj_spec.rb
+++ b/spec/ruby/library/net-http/http/newobj_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.newobj" do
diff --git a/spec/ruby/library/net/http/http/open_timeout_spec.rb b/spec/ruby/library/net-http/http/open_timeout_spec.rb
index 44b33615e6..0d93752271 100644
--- a/spec/ruby/library/net/http/http/open_timeout_spec.rb
+++ b/spec/ruby/library/net-http/http/open_timeout_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP#open_timeout" do
diff --git a/spec/ruby/library/net/http/http/options_spec.rb b/spec/ruby/library/net-http/http/options_spec.rb
index d798e69197..3d9887a557 100644
--- a/spec/ruby/library/net/http/http/options_spec.rb
+++ b/spec/ruby/library/net-http/http/options_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/port_spec.rb b/spec/ruby/library/net-http/http/port_spec.rb
index 7de295ca75..0984d5e6ce 100644
--- a/spec/ruby/library/net/http/http/port_spec.rb
+++ b/spec/ruby/library/net-http/http/port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP#port" do
diff --git a/spec/ruby/library/net/http/http/post2_spec.rb b/spec/ruby/library/net-http/http/post2_spec.rb
index ccc95068fb..abc998709f 100644
--- a/spec/ruby/library/net/http/http/post2_spec.rb
+++ b/spec/ruby/library/net-http/http/post2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/request_post'
diff --git a/spec/ruby/library/net/http/http/post_form_spec.rb b/spec/ruby/library/net-http/http/post_form_spec.rb
index 891e05e7af..de64a25bae 100644
--- a/spec/ruby/library/net/http/http/post_form_spec.rb
+++ b/spec/ruby/library/net-http/http/post_form_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/post_spec.rb b/spec/ruby/library/net-http/http/post_spec.rb
index 9f20a03c85..d7d94fec4a 100644
--- a/spec/ruby/library/net/http/http/post_spec.rb
+++ b/spec/ruby/library/net-http/http/post_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require 'uri'
require_relative 'fixtures/http_server'
@@ -27,7 +27,7 @@ describe "Net::HTTP.post" do
it "sends Content-Type: application/x-www-form-urlencoded by default" do
response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test")
- response.body.should include('"content-type"=>["application/x-www-form-urlencoded"]')
+ response.body.should include('"Content-Type"=>"application/x-www-form-urlencoded"')
end
it "does not support HTTP Basic Auth" do
@@ -60,7 +60,7 @@ describe "Net::HTTP#post" do
describe "when passed a block" do
it "yields fragments of the response body to the passed block" do
- str = ""
+ str = +""
@http.post("/request", "test=test") do |res|
str << res
end
diff --git a/spec/ruby/library/net/http/http/propfind_spec.rb b/spec/ruby/library/net-http/http/propfind_spec.rb
index 5240171618..f3742d1b1a 100644
--- a/spec/ruby/library/net/http/http/propfind_spec.rb
+++ b/spec/ruby/library/net-http/http/propfind_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/proppatch_spec.rb b/spec/ruby/library/net-http/http/proppatch_spec.rb
index 7a761a9f23..0163d24d46 100644
--- a/spec/ruby/library/net/http/http/proppatch_spec.rb
+++ b/spec/ruby/library/net-http/http/proppatch_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/proxy_address_spec.rb b/spec/ruby/library/net-http/http/proxy_address_spec.rb
index 8d152b8d44..5b5efb7ac0 100644
--- a/spec/ruby/library/net/http/http/proxy_address_spec.rb
+++ b/spec/ruby/library/net-http/http/proxy_address_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.proxy_address" do
diff --git a/spec/ruby/library/net/http/http/proxy_class_spec.rb b/spec/ruby/library/net-http/http/proxy_class_spec.rb
index 2d32a39f01..00975aef4e 100644
--- a/spec/ruby/library/net/http/http/proxy_class_spec.rb
+++ b/spec/ruby/library/net-http/http/proxy_class_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.proxy_class?" do
diff --git a/spec/ruby/library/net/http/http/proxy_pass_spec.rb b/spec/ruby/library/net-http/http/proxy_pass_spec.rb
index 94a0034544..4e393a53ff 100644
--- a/spec/ruby/library/net/http/http/proxy_pass_spec.rb
+++ b/spec/ruby/library/net-http/http/proxy_pass_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.proxy_pass" do
diff --git a/spec/ruby/library/net/http/http/proxy_port_spec.rb b/spec/ruby/library/net-http/http/proxy_port_spec.rb
index 339f7ee850..d7d37f3927 100644
--- a/spec/ruby/library/net/http/http/proxy_port_spec.rb
+++ b/spec/ruby/library/net-http/http/proxy_port_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.proxy_port" do
diff --git a/spec/ruby/library/net/http/http/proxy_user_spec.rb b/spec/ruby/library/net-http/http/proxy_user_spec.rb
index 01fda400e9..ef7654425d 100644
--- a/spec/ruby/library/net/http/http/proxy_user_spec.rb
+++ b/spec/ruby/library/net-http/http/proxy_user_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.proxy_user" do
diff --git a/spec/ruby/library/net/http/http/put2_spec.rb b/spec/ruby/library/net-http/http/put2_spec.rb
index 99329a5fd9..7b03a39d0b 100644
--- a/spec/ruby/library/net/http/http/put2_spec.rb
+++ b/spec/ruby/library/net-http/http/put2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/request_put'
diff --git a/spec/ruby/library/net/http/http/put_spec.rb b/spec/ruby/library/net-http/http/put_spec.rb
index 3ca0d0963e..75f3c243d4 100644
--- a/spec/ruby/library/net/http/http/put_spec.rb
+++ b/spec/ruby/library/net-http/http/put_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/read_timeout_spec.rb b/spec/ruby/library/net-http/http/read_timeout_spec.rb
index e23ee76025..7a0d2f1d72 100644
--- a/spec/ruby/library/net/http/http/read_timeout_spec.rb
+++ b/spec/ruby/library/net-http/http/read_timeout_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP#read_timeout" do
diff --git a/spec/ruby/library/net/http/http/request_get_spec.rb b/spec/ruby/library/net-http/http/request_get_spec.rb
index 9932ef0beb..98025a14a1 100644
--- a/spec/ruby/library/net/http/http/request_get_spec.rb
+++ b/spec/ruby/library/net-http/http/request_get_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/request_get'
diff --git a/spec/ruby/library/net/http/http/request_head_spec.rb b/spec/ruby/library/net-http/http/request_head_spec.rb
index 788101c951..8f514d4eee 100644
--- a/spec/ruby/library/net/http/http/request_head_spec.rb
+++ b/spec/ruby/library/net-http/http/request_head_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/request_head'
diff --git a/spec/ruby/library/net/http/http/request_post_spec.rb b/spec/ruby/library/net-http/http/request_post_spec.rb
index 7ac67cf95d..719bd5a7ee 100644
--- a/spec/ruby/library/net/http/http/request_post_spec.rb
+++ b/spec/ruby/library/net-http/http/request_post_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/request_post'
diff --git a/spec/ruby/library/net/http/http/request_put_spec.rb b/spec/ruby/library/net-http/http/request_put_spec.rb
index 110ac43ca6..9fcf3a98d6 100644
--- a/spec/ruby/library/net/http/http/request_put_spec.rb
+++ b/spec/ruby/library/net-http/http/request_put_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/request_put'
diff --git a/spec/ruby/library/net/http/http/request_spec.rb b/spec/ruby/library/net-http/http/request_spec.rb
index e63dde9c8d..356e605b3b 100644
--- a/spec/ruby/library/net/http/http/request_spec.rb
+++ b/spec/ruby/library/net-http/http/request_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/request_types_spec.rb b/spec/ruby/library/net-http/http/request_types_spec.rb
index 99d754d3d1..53aef1ee58 100644
--- a/spec/ruby/library/net/http/http/request_types_spec.rb
+++ b/spec/ruby/library/net-http/http/request_types_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP::Get" do
diff --git a/spec/ruby/library/net/http/http/send_request_spec.rb b/spec/ruby/library/net-http/http/send_request_spec.rb
index 47b3eef5b9..e82b2a96a1 100644
--- a/spec/ruby/library/net/http/http/send_request_spec.rb
+++ b/spec/ruby/library/net-http/http/send_request_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
@@ -54,7 +54,7 @@ describe "Net::HTTP#send_request" do
@methods.each do |method|
response = @http.send_request(method, "/request/header", "test=test", "referer" => referer)
- response.body.should include('"referer"=>["' + referer + '"]')
+ response.body.should include('"Referer"=>"' + referer + '"')
end
end
end
diff --git a/spec/ruby/library/net/http/http/set_debug_output_spec.rb b/spec/ruby/library/net-http/http/set_debug_output_spec.rb
index 94b6f4499d..5ceecb39fb 100644
--- a/spec/ruby/library/net/http/http/set_debug_output_spec.rb
+++ b/spec/ruby/library/net-http/http/set_debug_output_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require "stringio"
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/shared/request_get.rb b/spec/ruby/library/net-http/http/shared/request_get.rb
index d25f32049b..d25f32049b 100644
--- a/spec/ruby/library/net/http/http/shared/request_get.rb
+++ b/spec/ruby/library/net-http/http/shared/request_get.rb
diff --git a/spec/ruby/library/net/http/http/shared/request_head.rb b/spec/ruby/library/net-http/http/shared/request_head.rb
index 78b555884b..78b555884b 100644
--- a/spec/ruby/library/net/http/http/shared/request_head.rb
+++ b/spec/ruby/library/net-http/http/shared/request_head.rb
diff --git a/spec/ruby/library/net/http/http/shared/request_post.rb b/spec/ruby/library/net-http/http/shared/request_post.rb
index e832411c48..e832411c48 100644
--- a/spec/ruby/library/net/http/http/shared/request_post.rb
+++ b/spec/ruby/library/net-http/http/shared/request_post.rb
diff --git a/spec/ruby/library/net/http/http/shared/request_put.rb b/spec/ruby/library/net-http/http/shared/request_put.rb
index 3b902f4957..3b902f4957 100644
--- a/spec/ruby/library/net/http/http/shared/request_put.rb
+++ b/spec/ruby/library/net-http/http/shared/request_put.rb
diff --git a/spec/ruby/library/net/http/http/shared/started.rb b/spec/ruby/library/net-http/http/shared/started.rb
index 9ff6272c31..9ff6272c31 100644
--- a/spec/ruby/library/net/http/http/shared/started.rb
+++ b/spec/ruby/library/net-http/http/shared/started.rb
diff --git a/spec/ruby/library/net/http/http/shared/version_1_1.rb b/spec/ruby/library/net-http/http/shared/version_1_1.rb
index db3d6a986d..db3d6a986d 100644
--- a/spec/ruby/library/net/http/http/shared/version_1_1.rb
+++ b/spec/ruby/library/net-http/http/shared/version_1_1.rb
diff --git a/spec/ruby/library/net/http/http/shared/version_1_2.rb b/spec/ruby/library/net-http/http/shared/version_1_2.rb
index b044182c60..b044182c60 100644
--- a/spec/ruby/library/net/http/http/shared/version_1_2.rb
+++ b/spec/ruby/library/net-http/http/shared/version_1_2.rb
diff --git a/spec/ruby/library/net/http/http/socket_type_spec.rb b/spec/ruby/library/net-http/http/socket_type_spec.rb
index 5c844ddf94..f6826777b0 100644
--- a/spec/ruby/library/net/http/http/socket_type_spec.rb
+++ b/spec/ruby/library/net-http/http/socket_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP.socket_type" do
diff --git a/spec/ruby/library/net/http/http/start_spec.rb b/spec/ruby/library/net-http/http/start_spec.rb
index a2768eed18..0ce3e79269 100644
--- a/spec/ruby/library/net/http/http/start_spec.rb
+++ b/spec/ruby/library/net-http/http/start_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/started_spec.rb b/spec/ruby/library/net-http/http/started_spec.rb
index ea441ed16a..cbb82ceefa 100644
--- a/spec/ruby/library/net/http/http/started_spec.rb
+++ b/spec/ruby/library/net-http/http/started_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
require_relative 'shared/started'
diff --git a/spec/ruby/library/net/http/http/trace_spec.rb b/spec/ruby/library/net-http/http/trace_spec.rb
index 94a1bf6655..9809d537c5 100644
--- a/spec/ruby/library/net/http/http/trace_spec.rb
+++ b/spec/ruby/library/net-http/http/trace_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/unlock_spec.rb b/spec/ruby/library/net-http/http/unlock_spec.rb
index a4f1b7a1d1..adf0b49f65 100644
--- a/spec/ruby/library/net/http/http/unlock_spec.rb
+++ b/spec/ruby/library/net-http/http/unlock_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/http_server'
diff --git a/spec/ruby/library/net/http/http/use_ssl_spec.rb b/spec/ruby/library/net-http/http/use_ssl_spec.rb
index be1ec7fa25..912a62a8ba 100644
--- a/spec/ruby/library/net/http/http/use_ssl_spec.rb
+++ b/spec/ruby/library/net-http/http/use_ssl_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTP#use_ssl?" do
diff --git a/spec/ruby/library/net/http/http/version_1_1_spec.rb b/spec/ruby/library/net-http/http/version_1_1_spec.rb
index 1c069e9ea6..34a4ac8a6b 100644
--- a/spec/ruby/library/net/http/http/version_1_1_spec.rb
+++ b/spec/ruby/library/net-http/http/version_1_1_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'shared/version_1_1'
diff --git a/spec/ruby/library/net/http/http/version_1_2_spec.rb b/spec/ruby/library/net-http/http/version_1_2_spec.rb
index 4e601462c9..e994511aea 100644
--- a/spec/ruby/library/net/http/http/version_1_2_spec.rb
+++ b/spec/ruby/library/net-http/http/version_1_2_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'shared/version_1_2'
diff --git a/spec/ruby/library/net/http/httpexceptions/fixtures/classes.rb b/spec/ruby/library/net-http/httpexceptions/fixtures/classes.rb
index abe8855eff..abe8855eff 100644
--- a/spec/ruby/library/net/http/httpexceptions/fixtures/classes.rb
+++ b/spec/ruby/library/net-http/httpexceptions/fixtures/classes.rb
diff --git a/spec/ruby/library/net/http/httpexceptions/initialize_spec.rb b/spec/ruby/library/net-http/httpexceptions/initialize_spec.rb
index 8e3fd8cc02..5316cca69d 100644
--- a/spec/ruby/library/net/http/httpexceptions/initialize_spec.rb
+++ b/spec/ruby/library/net-http/httpexceptions/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpexceptions/response_spec.rb b/spec/ruby/library/net-http/httpexceptions/response_spec.rb
index 205b2bc212..d718b1ae21 100644
--- a/spec/ruby/library/net/http/httpexceptions/response_spec.rb
+++ b/spec/ruby/library/net-http/httpexceptions/response_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb
index 7d081939b8..6c886499ca 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPGenericRequest#body_exist?" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/body_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb
index a215895b57..5f7315f303 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/body_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require "stringio"
diff --git a/spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb
index c2a60e6836..dea1c8c883 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require "stringio"
diff --git a/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb
index da5b1a63be..7de03d7da0 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb
@@ -1,10 +1,10 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require "stringio"
describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do
before :each do
- @socket = StringIO.new("")
+ @socket = StringIO.new(+"")
@buffered_socket = Net::BufferedIO.new(@socket)
end
diff --git a/spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/inspect_spec.rb
index 36240949c3..d03b6e6953 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPGenericRequest#inspect" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/method_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/method_spec.rb
index 3f7c2cbf2b..794bd328cd 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/method_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/method_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPGenericRequest#method" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/path_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/path_spec.rb
index fc4cf9af53..a9fac3f67e 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/path_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/path_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPGenericRequest#path" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/request_body_permitted_spec.rb
index 50cd1ff637..1713b59baf 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/request_body_permitted_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPGenericRequest#request_body_permitted?" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/response_body_permitted_spec.rb
index 0c4165d0ab..2f0751c344 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/response_body_permitted_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPGenericRequest#response_body_permitted?" do
diff --git a/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/set_body_internal_spec.rb
index 7494c69173..358aa6cde3 100644
--- a/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb
+++ b/spec/ruby/library/net-http/httpgenericrequest/set_body_internal_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPGenericRequest#set_body_internal when passed string" do
diff --git a/spec/ruby/library/net/http/httpheader/add_field_spec.rb b/spec/ruby/library/net-http/httpheader/add_field_spec.rb
index 882d5ac5bb..8cd3d33517 100644
--- a/spec/ruby/library/net/http/httpheader/add_field_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/add_field_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/basic_auth_spec.rb b/spec/ruby/library/net-http/httpheader/basic_auth_spec.rb
index fa2a710fe1..db7ca84d13 100644
--- a/spec/ruby/library/net/http/httpheader/basic_auth_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/basic_auth_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/canonical_each_spec.rb b/spec/ruby/library/net-http/httpheader/canonical_each_spec.rb
index 0dddd3049b..64a5cae89e 100644
--- a/spec/ruby/library/net/http/httpheader/canonical_each_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/canonical_each_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/each_capitalized'
diff --git a/spec/ruby/library/net/http/httpheader/chunked_spec.rb b/spec/ruby/library/net-http/httpheader/chunked_spec.rb
index 96b758981b..b32a0aab38 100644
--- a/spec/ruby/library/net/http/httpheader/chunked_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/chunked_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/content_length_spec.rb b/spec/ruby/library/net-http/httpheader/content_length_spec.rb
index e344817e82..f05c5f8d8b 100644
--- a/spec/ruby/library/net/http/httpheader/content_length_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/content_length_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/content_range_spec.rb b/spec/ruby/library/net-http/httpheader/content_range_spec.rb
index ba75f9a9a1..09737141a5 100644
--- a/spec/ruby/library/net/http/httpheader/content_range_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/content_range_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/content_type_spec.rb b/spec/ruby/library/net-http/httpheader/content_type_spec.rb
index 1f8b4ba326..a6e1ae1093 100644
--- a/spec/ruby/library/net/http/httpheader/content_type_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/content_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/set_content_type'
diff --git a/spec/ruby/library/net/http/httpheader/delete_spec.rb b/spec/ruby/library/net-http/httpheader/delete_spec.rb
index 603ae198de..8d929dbd86 100644
--- a/spec/ruby/library/net/http/httpheader/delete_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/delete_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb b/spec/ruby/library/net-http/httpheader/each_capitalized_name_spec.rb
index 1af2c6939c..27713577f9 100644
--- a/spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/each_capitalized_name_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb b/spec/ruby/library/net-http/httpheader/each_capitalized_spec.rb
index 961a2d051f..1e853995ea 100644
--- a/spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/each_capitalized_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/each_capitalized'
diff --git a/spec/ruby/library/net/http/httpheader/each_header_spec.rb b/spec/ruby/library/net-http/httpheader/each_header_spec.rb
index 19634a001b..869feebacf 100644
--- a/spec/ruby/library/net/http/httpheader/each_header_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/each_header_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/each_header'
diff --git a/spec/ruby/library/net/http/httpheader/each_key_spec.rb b/spec/ruby/library/net-http/httpheader/each_key_spec.rb
index ebb17d2eac..1ad145629f 100644
--- a/spec/ruby/library/net/http/httpheader/each_key_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/each_key_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/each_name'
diff --git a/spec/ruby/library/net/http/httpheader/each_name_spec.rb b/spec/ruby/library/net-http/httpheader/each_name_spec.rb
index f4533ebcfb..f819bd989d 100644
--- a/spec/ruby/library/net/http/httpheader/each_name_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/each_name_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/each_name'
diff --git a/spec/ruby/library/net/http/httpheader/each_spec.rb b/spec/ruby/library/net-http/httpheader/each_spec.rb
index 7ba8434f75..ff37249d0a 100644
--- a/spec/ruby/library/net/http/httpheader/each_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/each_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/each_header'
diff --git a/spec/ruby/library/net/http/httpheader/each_value_spec.rb b/spec/ruby/library/net-http/httpheader/each_value_spec.rb
index 3224de7703..b71df58c65 100644
--- a/spec/ruby/library/net/http/httpheader/each_value_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/each_value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/element_reference_spec.rb b/spec/ruby/library/net-http/httpheader/element_reference_spec.rb
index 4a35e20d20..1003c41af9 100644
--- a/spec/ruby/library/net/http/httpheader/element_reference_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/element_reference_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/element_set_spec.rb b/spec/ruby/library/net-http/httpheader/element_set_spec.rb
index e9ad64fafc..376df2f977 100644
--- a/spec/ruby/library/net/http/httpheader/element_set_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/element_set_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/fetch_spec.rb b/spec/ruby/library/net-http/httpheader/fetch_spec.rb
index ea15679acb..58c69c0377 100644
--- a/spec/ruby/library/net/http/httpheader/fetch_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/fetch_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/fixtures/classes.rb b/spec/ruby/library/net-http/httpheader/fixtures/classes.rb
index b5ec6abd75..b5ec6abd75 100644
--- a/spec/ruby/library/net/http/httpheader/fixtures/classes.rb
+++ b/spec/ruby/library/net-http/httpheader/fixtures/classes.rb
diff --git a/spec/ruby/library/net/http/httpheader/form_data_spec.rb b/spec/ruby/library/net-http/httpheader/form_data_spec.rb
index 9b29a03159..acd913f53a 100644
--- a/spec/ruby/library/net/http/httpheader/form_data_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/form_data_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/set_form_data'
diff --git a/spec/ruby/library/net/http/httpheader/get_fields_spec.rb b/spec/ruby/library/net-http/httpheader/get_fields_spec.rb
index 1b623bf2a3..0278bcede2 100644
--- a/spec/ruby/library/net/http/httpheader/get_fields_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/get_fields_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb b/spec/ruby/library/net-http/httpheader/initialize_http_header_spec.rb
index efc5e7d0b2..f9e6d208e5 100644
--- a/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/initialize_http_header_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/key_spec.rb b/spec/ruby/library/net-http/httpheader/key_spec.rb
index 9099024229..2b7aeb9c2a 100644
--- a/spec/ruby/library/net/http/httpheader/key_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/key_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/length_spec.rb b/spec/ruby/library/net-http/httpheader/length_spec.rb
index 0d1da149f4..57e32742e4 100644
--- a/spec/ruby/library/net/http/httpheader/length_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/length_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/size'
diff --git a/spec/ruby/library/net/http/httpheader/main_type_spec.rb b/spec/ruby/library/net-http/httpheader/main_type_spec.rb
index 3e18de6b5b..4dd551d8f4 100644
--- a/spec/ruby/library/net/http/httpheader/main_type_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/main_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb b/spec/ruby/library/net-http/httpheader/proxy_basic_auth_spec.rb
index 8b576ee164..d9f6afc5a7 100644
--- a/spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/proxy_basic_auth_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/range_length_spec.rb b/spec/ruby/library/net-http/httpheader/range_length_spec.rb
index b8fce4f690..77323ac872 100644
--- a/spec/ruby/library/net/http/httpheader/range_length_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/range_length_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/range_spec.rb b/spec/ruby/library/net-http/httpheader/range_spec.rb
index 005177f6be..2de80a825e 100644
--- a/spec/ruby/library/net/http/httpheader/range_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/range_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/set_range'
diff --git a/spec/ruby/library/net/http/httpheader/set_content_type_spec.rb b/spec/ruby/library/net-http/httpheader/set_content_type_spec.rb
index 125f7a7e0d..7ec4f90b8e 100644
--- a/spec/ruby/library/net/http/httpheader/set_content_type_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/set_content_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/set_content_type'
diff --git a/spec/ruby/library/net/http/httpheader/set_form_data_spec.rb b/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb
index 14c66ae01c..7aac19f045 100644
--- a/spec/ruby/library/net/http/httpheader/set_form_data_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/set_form_data_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/set_form_data'
diff --git a/spec/ruby/library/net/http/httpheader/set_range_spec.rb b/spec/ruby/library/net-http/httpheader/set_range_spec.rb
index 85b9c50422..0f98de55e6 100644
--- a/spec/ruby/library/net/http/httpheader/set_range_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/set_range_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/set_range'
diff --git a/spec/ruby/library/net/http/httpheader/shared/each_capitalized.rb b/spec/ruby/library/net-http/httpheader/shared/each_capitalized.rb
index 3bac409876..3bac409876 100644
--- a/spec/ruby/library/net/http/httpheader/shared/each_capitalized.rb
+++ b/spec/ruby/library/net-http/httpheader/shared/each_capitalized.rb
diff --git a/spec/ruby/library/net/http/httpheader/shared/each_header.rb b/spec/ruby/library/net-http/httpheader/shared/each_header.rb
index 6bf3a6ddfe..6bf3a6ddfe 100644
--- a/spec/ruby/library/net/http/httpheader/shared/each_header.rb
+++ b/spec/ruby/library/net-http/httpheader/shared/each_header.rb
diff --git a/spec/ruby/library/net/http/httpheader/shared/each_name.rb b/spec/ruby/library/net-http/httpheader/shared/each_name.rb
index efc6a09dfd..efc6a09dfd 100644
--- a/spec/ruby/library/net/http/httpheader/shared/each_name.rb
+++ b/spec/ruby/library/net-http/httpheader/shared/each_name.rb
diff --git a/spec/ruby/library/net/http/httpheader/shared/set_content_type.rb b/spec/ruby/library/net-http/httpheader/shared/set_content_type.rb
index b7359bdca6..b7359bdca6 100644
--- a/spec/ruby/library/net/http/httpheader/shared/set_content_type.rb
+++ b/spec/ruby/library/net-http/httpheader/shared/set_content_type.rb
diff --git a/spec/ruby/library/net/http/httpheader/shared/set_form_data.rb b/spec/ruby/library/net-http/httpheader/shared/set_form_data.rb
index db20b18803..db20b18803 100644
--- a/spec/ruby/library/net/http/httpheader/shared/set_form_data.rb
+++ b/spec/ruby/library/net-http/httpheader/shared/set_form_data.rb
diff --git a/spec/ruby/library/net/http/httpheader/shared/set_range.rb b/spec/ruby/library/net-http/httpheader/shared/set_range.rb
index 87f51d46f3..87f51d46f3 100644
--- a/spec/ruby/library/net/http/httpheader/shared/set_range.rb
+++ b/spec/ruby/library/net-http/httpheader/shared/set_range.rb
diff --git a/spec/ruby/library/net/http/httpheader/shared/size.rb b/spec/ruby/library/net-http/httpheader/shared/size.rb
index e2b1e4c22b..e2b1e4c22b 100644
--- a/spec/ruby/library/net/http/httpheader/shared/size.rb
+++ b/spec/ruby/library/net-http/httpheader/shared/size.rb
diff --git a/spec/ruby/library/net/http/httpheader/size_spec.rb b/spec/ruby/library/net-http/httpheader/size_spec.rb
index a7d78f96e0..210060ce21 100644
--- a/spec/ruby/library/net/http/httpheader/size_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/size_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
require_relative 'shared/size'
diff --git a/spec/ruby/library/net/http/httpheader/sub_type_spec.rb b/spec/ruby/library/net-http/httpheader/sub_type_spec.rb
index 3c73ca0027..b39b57fe8d 100644
--- a/spec/ruby/library/net/http/httpheader/sub_type_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/sub_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/to_hash_spec.rb b/spec/ruby/library/net-http/httpheader/to_hash_spec.rb
index 8c1d36c30a..3cebc519a6 100644
--- a/spec/ruby/library/net/http/httpheader/to_hash_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/to_hash_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httpheader/type_params_spec.rb b/spec/ruby/library/net-http/httpheader/type_params_spec.rb
index e77be7ea85..ac97e2b48c 100644
--- a/spec/ruby/library/net/http/httpheader/type_params_spec.rb
+++ b/spec/ruby/library/net-http/httpheader/type_params_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'fixtures/classes'
diff --git a/spec/ruby/library/net/http/httprequest/initialize_spec.rb b/spec/ruby/library/net-http/httprequest/initialize_spec.rb
index 88e9fb1c77..d009a00ed2 100644
--- a/spec/ruby/library/net/http/httprequest/initialize_spec.rb
+++ b/spec/ruby/library/net-http/httprequest/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
module NetHTTPRequestSpecs
diff --git a/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb b/spec/ruby/library/net-http/httpresponse/body_permitted_spec.rb
index 8ade46689f..68965de4a1 100644
--- a/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/body_permitted_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse.body_permitted?" do
diff --git a/spec/ruby/library/net/http/httpresponse/body_spec.rb b/spec/ruby/library/net-http/httpresponse/body_spec.rb
index 79569441f1..ddfcd834c4 100644
--- a/spec/ruby/library/net/http/httpresponse/body_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/body_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'shared/body'
diff --git a/spec/ruby/library/net/http/httpresponse/code_spec.rb b/spec/ruby/library/net-http/httpresponse/code_spec.rb
index 114277cb43..699062ad97 100644
--- a/spec/ruby/library/net/http/httpresponse/code_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/code_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#code" do
diff --git a/spec/ruby/library/net/http/httpresponse/code_type_spec.rb b/spec/ruby/library/net-http/httpresponse/code_type_spec.rb
index fa2d572e9a..beb661cbbe 100644
--- a/spec/ruby/library/net/http/httpresponse/code_type_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/code_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#code_type" do
diff --git a/spec/ruby/library/net/http/httpresponse/entity_spec.rb b/spec/ruby/library/net-http/httpresponse/entity_spec.rb
index f1639042c1..ca8c4b29c0 100644
--- a/spec/ruby/library/net/http/httpresponse/entity_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/entity_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require_relative 'shared/body'
diff --git a/spec/ruby/library/net/http/httpresponse/error_spec.rb b/spec/ruby/library/net-http/httpresponse/error_spec.rb
index d2b2f53d89..6ced90fa23 100644
--- a/spec/ruby/library/net/http/httpresponse/error_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/error_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#error!" do
@@ -16,12 +16,7 @@ describe "Net::HTTPResponse#error!" do
-> { res.error! }.should raise_error(Net::HTTPRetriableError)
res = Net::HTTPClientError.new("1.0", "4xx", "test response")
- ruby_version_is ""..."2.6" do
- -> { res.error! }.should raise_error(Net::HTTPServerException)
- end
- ruby_version_is "2.6" do
- -> { res.error! }.should raise_error(Net::HTTPClientException)
- end
+ -> { res.error! }.should raise_error(Net::HTTPClientException)
res = Net::HTTPServerError.new("1.0", "5xx", "test response")
-> { res.error! }.should raise_error(Net::HTTPFatalError)
diff --git a/spec/ruby/library/net/http/httpresponse/error_type_spec.rb b/spec/ruby/library/net-http/httpresponse/error_type_spec.rb
index 6705f8b1aa..3969621a5e 100644
--- a/spec/ruby/library/net/http/httpresponse/error_type_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/error_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#error_type" do
@@ -16,12 +16,7 @@ describe "Net::HTTPResponse#error_type" do
res.error_type.should == Net::HTTPRetriableError
res = Net::HTTPClientError.new("1.0", "4xx", "test response")
- ruby_version_is ""..."2.6" do
- res.error_type.should == Net::HTTPServerException
- end
- ruby_version_is "2.6" do
- res.error_type.should == Net::HTTPClientException
- end
+ res.error_type.should == Net::HTTPClientException
res = Net::HTTPServerError.new("1.0", "5xx", "test response")
res.error_type.should == Net::HTTPFatalError
diff --git a/spec/ruby/library/net/http/httpresponse/exception_type_spec.rb b/spec/ruby/library/net-http/httpresponse/exception_type_spec.rb
index c0812cd322..dd2761a744 100644
--- a/spec/ruby/library/net/http/httpresponse/exception_type_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/exception_type_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse.exception_type" do
@@ -7,12 +7,7 @@ describe "Net::HTTPResponse.exception_type" do
Net::HTTPInformation.exception_type.should == Net::HTTPError
Net::HTTPSuccess.exception_type.should == Net::HTTPError
Net::HTTPRedirection.exception_type.should == Net::HTTPRetriableError
- ruby_version_is ""..."2.6" do
- Net::HTTPClientError.exception_type.should == Net::HTTPServerException
- end
- ruby_version_is "2.6" do
- Net::HTTPClientError.exception_type.should == Net::HTTPClientException
- end
+ Net::HTTPClientError.exception_type.should == Net::HTTPClientException
Net::HTTPServerError.exception_type.should == Net::HTTPFatalError
end
end
diff --git a/spec/ruby/library/net/http/httpresponse/header_spec.rb b/spec/ruby/library/net-http/httpresponse/header_spec.rb
index a9615feda8..a403dbd2c3 100644
--- a/spec/ruby/library/net/http/httpresponse/header_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/header_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#header" do
diff --git a/spec/ruby/library/net/http/httpresponse/http_version_spec.rb b/spec/ruby/library/net-http/httpresponse/http_version_spec.rb
index db85696d77..a3e413a360 100644
--- a/spec/ruby/library/net/http/httpresponse/http_version_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/http_version_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#http_version" do
diff --git a/spec/ruby/library/net/http/httpresponse/initialize_spec.rb b/spec/ruby/library/net-http/httpresponse/initialize_spec.rb
index eb77e2e277..673c11a245 100644
--- a/spec/ruby/library/net/http/httpresponse/initialize_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/initialize_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#initialize when passed http_version, response_code, response_message" do
diff --git a/spec/ruby/library/net/http/httpresponse/inspect_spec.rb b/spec/ruby/library/net-http/httpresponse/inspect_spec.rb
index 1e1a2c7cc7..43071ec8cd 100644
--- a/spec/ruby/library/net/http/httpresponse/inspect_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/inspect_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require "stringio"
diff --git a/spec/ruby/library/net/http/httpresponse/message_spec.rb b/spec/ruby/library/net-http/httpresponse/message_spec.rb
index ae8e3678a1..5ba73bb449 100644
--- a/spec/ruby/library/net/http/httpresponse/message_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/message_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#message" do
diff --git a/spec/ruby/library/net/http/httpresponse/msg_spec.rb b/spec/ruby/library/net-http/httpresponse/msg_spec.rb
index 0e5e7eb4aa..04f5836d7a 100644
--- a/spec/ruby/library/net/http/httpresponse/msg_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/msg_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#msg" do
diff --git a/spec/ruby/library/net/http/httpresponse/read_body_spec.rb b/spec/ruby/library/net-http/httpresponse/read_body_spec.rb
index 99d8e5fa88..4530a26bfc 100644
--- a/spec/ruby/library/net/http/httpresponse/read_body_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/read_body_spec.rb
@@ -1,5 +1,6 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
+require 'stringio'
describe "Net::HTTPResponse#read_body" do
before :each do
@@ -24,7 +25,7 @@ describe "Net::HTTPResponse#read_body" do
describe "when passed a buffer" do
it "reads the body to the passed buffer" do
@res.reading_body(@socket, true) do
- buffer = ""
+ buffer = +""
@res.read_body(buffer)
buffer.should == "test body"
end
@@ -32,15 +33,15 @@ describe "Net::HTTPResponse#read_body" do
it "returns the passed buffer" do
@res.reading_body(@socket, true) do
- buffer = ""
+ buffer = +""
@res.read_body(buffer).should equal(buffer)
end
end
it "raises an IOError if called a second time" do
@res.reading_body(@socket, true) do
- @res.read_body("")
- -> { @res.read_body("") }.should raise_error(IOError)
+ @res.read_body(+"")
+ -> { @res.read_body(+"") }.should raise_error(IOError)
end
end
end
@@ -50,7 +51,7 @@ describe "Net::HTTPResponse#read_body" do
@res.reading_body(@socket, true) do
yielded = false
- buffer = ""
+ buffer = +""
@res.read_body do |body|
yielded = true
buffer << body
@@ -78,7 +79,7 @@ describe "Net::HTTPResponse#read_body" do
describe "when passed buffer and block" do
it "raises an ArgumentError" do
@res.reading_body(@socket, true) do
- -> { @res.read_body("") {} }.should raise_error(ArgumentError)
+ -> { @res.read_body(+"") {} }.should raise_error(ArgumentError)
end
end
end
diff --git a/spec/ruby/library/net/http/httpresponse/read_header_spec.rb b/spec/ruby/library/net-http/httpresponse/read_header_spec.rb
index 6af8c6bd6a..3ea4ee834b 100644
--- a/spec/ruby/library/net/http/httpresponse/read_header_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/read_header_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#read_header" do
diff --git a/spec/ruby/library/net/http/httpresponse/read_new_spec.rb b/spec/ruby/library/net-http/httpresponse/read_new_spec.rb
index 73c7ddc100..82f7a47ce8 100644
--- a/spec/ruby/library/net/http/httpresponse/read_new_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/read_new_spec.rb
@@ -1,5 +1,6 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
+require 'stringio'
describe "Net::HTTPResponse.read_new" do
it "creates a HTTPResponse object based on the response read from the passed socket" do
diff --git a/spec/ruby/library/net/http/httpresponse/reading_body_spec.rb b/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb
index ebdab891e1..637a2806f8 100644
--- a/spec/ruby/library/net/http/httpresponse/reading_body_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
require "stringio"
diff --git a/spec/ruby/library/net/http/httpresponse/response_spec.rb b/spec/ruby/library/net-http/httpresponse/response_spec.rb
index f6035f3695..caa0ca2d19 100644
--- a/spec/ruby/library/net/http/httpresponse/response_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/response_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#response" do
diff --git a/spec/ruby/library/net/http/httpresponse/shared/body.rb b/spec/ruby/library/net-http/httpresponse/shared/body.rb
index 91d5fe6375..618e3936fb 100644
--- a/spec/ruby/library/net/http/httpresponse/shared/body.rb
+++ b/spec/ruby/library/net-http/httpresponse/shared/body.rb
@@ -1,3 +1,5 @@
+require 'stringio'
+
describe :net_httpresponse_body, shared: true do
before :each do
@res = Net::HTTPUnknownResponse.new("1.0", "???", "test response")
diff --git a/spec/ruby/library/net/http/httpresponse/value_spec.rb b/spec/ruby/library/net-http/httpresponse/value_spec.rb
index 4a5930d4e5..2df8beaa10 100644
--- a/spec/ruby/library/net/http/httpresponse/value_spec.rb
+++ b/spec/ruby/library/net-http/httpresponse/value_spec.rb
@@ -1,4 +1,4 @@
-require_relative '../../../../spec_helper'
+require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPResponse#value" do
@@ -16,12 +16,7 @@ describe "Net::HTTPResponse#value" do
-> { res.value }.should raise_error(Net::HTTPRetriableError)
res = Net::HTTPClientError.new("1.0", "4xx", "test response")
- ruby_version_is ""..."2.6" do
- -> { res.value }.should raise_error(Net::HTTPServerException)
- end
- ruby_version_is "2.6" do
- -> { res.value }.should raise_error(Net::HTTPClientException)
- end
+ -> { res.value }.should raise_error(Net::HTTPClientException)
res = Net::HTTPServerError.new("1.0", "5xx", "test response")
-> { res.value }.should raise_error(Net::HTTPFatalError)
diff --git a/spec/ruby/library/net/http/HTTPClientExcepton_spec.rb b/spec/ruby/library/net/http/HTTPClientExcepton_spec.rb
deleted file mode 100644
index 08347464ec..0000000000
--- a/spec/ruby/library/net/http/HTTPClientExcepton_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative '../../../spec_helper'
-require 'net/http'
-
-ruby_version_is "2.6" do
- describe "Net::HTTPClientException" do
- it "is a subclass of Net::ProtoServerError" do
- Net::HTTPClientException.should < Net::ProtoServerError
- end
-
- it "includes the Net::HTTPExceptions module" do
- Net::HTTPClientException.should < Net::HTTPExceptions
- end
- end
-end
diff --git a/spec/ruby/library/net/http/HTTPServerException_spec.rb b/spec/ruby/library/net/http/HTTPServerException_spec.rb
deleted file mode 100644
index 87841ab499..0000000000
--- a/spec/ruby/library/net/http/HTTPServerException_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-require 'net/http'
-
-ruby_version_is ""..."2.6" do
- describe "Net::HTTPServerException" do
- it "is a subclass of Net::ProtoServerError" do
- Net::HTTPServerException.should < Net::ProtoServerError
- end
-
- it "includes the Net::HTTPExceptions module" do
- Net::HTTPServerException.should < Net::HTTPExceptions
- end
- end
-end
-
-ruby_version_is "2.6" do
- describe "Net::HTTPServerException" do
- it "is a subclass of Net::ProtoServerError and is warned as deprecated" do
- -> { Net::HTTPServerException.should < Net::ProtoServerError }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
- end
-
- it "includes the Net::HTTPExceptions module and is warned as deprecated" do
- -> { Net::HTTPServerException.should < Net::HTTPExceptions }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
- end
- end
-end
diff --git a/spec/ruby/library/net/http/http/fixtures/http_server.rb b/spec/ruby/library/net/http/http/fixtures/http_server.rb
deleted file mode 100644
index aeb0babda1..0000000000
--- a/spec/ruby/library/net/http/http/fixtures/http_server.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-require 'webrick'
-require 'webrick/httpservlet/abstract'
-
-module NetHTTPSpecs
- class NullWriter
- def <<(s) end
- def puts(*args) end
- def print(*args) end
- def printf(*args) end
- end
-
- class SpecServlet < WEBrick::HTTPServlet::AbstractServlet
- def handle(req, res)
- reply(req, res)
- end
-
- %w{ do_GET do_HEAD do_POST do_PUT do_PROPPATCH do_LOCK do_UNLOCK
- do_OPTIONS do_PROPFIND do_DELETE do_MOVE do_COPY
- do_MKCOL do_TRACE }.each do |method|
- alias_method method.to_sym, :handle
- end
- end
-
- class RequestServlet < SpecServlet
- def reply(req, res)
- res.content_type = "text/plain"
- res.body = "Request type: #{req.request_method}"
- end
- end
-
- class RequestBodyServlet < SpecServlet
- def reply(req, res)
- res.content_type = "text/plain"
- res.body = req.body
- end
- end
-
- class RequestHeaderServlet < SpecServlet
- def reply(req, res)
- res.content_type = "text/plain"
- res.body = req.header.inspect
- end
- end
-
- class RequestBasicAuthServlet < SpecServlet
- def reply(req, res)
- res.content_type = "text/plain"
-
- WEBrick::HTTPAuth.basic_auth(req, res, "realm") do |user, pass|
- res.body = "username: #{user}\npassword: #{pass}"
- true
- end
- end
- end
-
- @server = nil
- @server_thread = nil
-
- class << self
- def port
- raise "server not started" unless @server
- @server.config[:Port]
- end
-
- def start_server
- server_config = {
- BindAddress: "127.0.0.1",
- Port: 0,
- Logger: WEBrick::Log.new(NullWriter.new),
- AccessLog: [],
- ServerType: Thread
- }
-
- @server = WEBrick::HTTPServer.new(server_config)
-
- @server.mount_proc('/') do |req, res|
- res.content_type = "text/plain"
- res.body = "This is the index page."
- end
- @server.mount('/request', RequestServlet)
- @server.mount("/request/body", RequestBodyServlet)
- @server.mount("/request/header", RequestHeaderServlet)
- @server.mount("/request/basic_auth", RequestBasicAuthServlet)
-
- @server_thread = @server.start
- end
-
- def stop_server
- if @server
- begin
- @server.shutdown
- rescue Errno::EPIPE, Errno::EBADF
- # Because WEBrick is not thread-safe and only catches IOError
-
- # EBADF can happen because WEBrick @server_thread concurrently closes the shutdown pipe
- # once @status = :Shutdown, while the current thread does write_nonblock("\0").
- # On MRI this EBADF is replaced by IOError due to the GIL around both #close and #write_nonblock.
- end
- @server = nil
- end
- if @server_thread
- @server_thread.join
- @server_thread = nil
- end
- timeout = WEBrick::Utils::TimeoutHandler
- timeout.terminate if timeout.respond_to?(:terminate)
- end
- end
-end
diff --git a/spec/ruby/library/objectspace/dump_all_spec.rb b/spec/ruby/library/objectspace/dump_all_spec.rb
new file mode 100644
index 0000000000..e9b449a905
--- /dev/null
+++ b/spec/ruby/library/objectspace/dump_all_spec.rb
@@ -0,0 +1,112 @@
+require_relative '../../spec_helper'
+require 'objspace'
+
+describe "ObjectSpace.dump_all" do
+ it "dumps Ruby heap to string when passed output: :string" do
+ stdout = ruby_exe(<<~RUBY, options: "-robjspace")
+ string = "abc"
+ dump = ObjectSpace.dump_all(output: :string)
+ puts dump.class
+ puts dump.include?('"value":"abc"')
+ RUBY
+
+ stdout.should == "String\ntrue\n"
+ end
+
+ it "dumps Ruby heap to a temporary file when passed output: :file" do
+ stdout = ruby_exe(<<~RUBY, options: "-robjspace")
+ string = "abc"
+ file = ObjectSpace.dump_all(output: :file)
+
+ begin
+ file.flush
+ file.rewind
+ content = file.read
+
+ puts file.class
+ puts content.include?('"value":"abc"')
+ ensure
+ file.close
+ File.unlink file.path
+ end
+ RUBY
+
+ stdout.should == "File\ntrue\n"
+ end
+
+ it "dumps Ruby heap to a temporary file when :output not specified" do
+ stdout = ruby_exe(<<~RUBY, options: "-robjspace")
+ string = "abc"
+ file = ObjectSpace.dump_all
+
+ begin
+ file.flush
+ file.rewind
+ content = file.read
+
+ puts file.class
+ puts content.include?('"value":"abc"')
+ ensure
+ file.close
+ File.unlink file.path
+ end
+ RUBY
+
+ stdout.should == "File\ntrue\n"
+ end
+
+ it "dumps Ruby heap to a temporary file when passed output: :nil" do
+ stdout = ruby_exe(<<~RUBY, options: "-robjspace")
+ string = "abc"
+ file = ObjectSpace.dump_all(output: nil)
+
+ begin
+ file.flush
+ file.rewind
+ content = file.read
+
+ puts file.class
+ puts content.include?('"value":"abc"')
+ ensure
+ file.close
+ File.unlink file.path
+ end
+ RUBY
+
+ stdout.should == "File\ntrue\n"
+ end
+
+ it "dumps Ruby heap to stdout when passed output: :stdout" do
+ stdout = ruby_exe(<<~RUBY, options: "-robjspace")
+ string = "abc"
+ ObjectSpace.dump_all(output: :stdout)
+ RUBY
+
+ stdout.should include('"value":"abc"')
+ end
+
+ it "dumps Ruby heap to provided IO when passed output: IO" do
+ stdout = ruby_exe(<<~RUBY, options: "-robjspace -rtempfile")
+ string = "abc"
+ io = Tempfile.create("object_space_dump_all")
+
+ begin
+ result = ObjectSpace.dump_all(output: io)
+ io.rewind
+ content = io.read
+
+ puts result.equal?(io)
+ puts content.include?('"value":"abc"')
+ ensure
+ io.close
+ File.unlink io.path
+ end
+ RUBY
+
+ stdout.should == "true\ntrue\n"
+ end
+
+ it "raises ArgumentError when passed not supported :output value" do
+ -> { ObjectSpace.dump_all(output: Object.new) }.should raise_error(ArgumentError, /wrong output option/)
+ end
+end
diff --git a/spec/ruby/library/objectspace/dump_spec.rb b/spec/ruby/library/objectspace/dump_spec.rb
new file mode 100644
index 0000000000..e22ee3df1e
--- /dev/null
+++ b/spec/ruby/library/objectspace/dump_spec.rb
@@ -0,0 +1,70 @@
+require_relative '../../spec_helper'
+require 'objspace'
+
+describe "ObjectSpace.dump" do
+ it "dumps the content of object as JSON" do
+ require 'json'
+ string = ObjectSpace.dump("abc")
+ dump = JSON.parse(string)
+
+ dump['type'].should == "STRING"
+ dump['value'].should == "abc"
+ end
+
+ it "dumps to string when passed output: :string" do
+ string = ObjectSpace.dump("abc", output: :string)
+ string.should be_kind_of(String)
+ string.should include('"value":"abc"')
+ end
+
+ it "dumps to string when :output not specified" do
+ string = ObjectSpace.dump("abc")
+ string.should be_kind_of(String)
+ string.should include('"value":"abc"')
+ end
+
+ it "dumps to a temporary file when passed output: :file" do
+ file = ObjectSpace.dump("abc", output: :file)
+ file.should be_kind_of(File)
+
+ file.rewind
+ content = file.read
+ content.should include('"value":"abc"')
+ ensure
+ file.close
+ File.unlink file.path
+ end
+
+ it "dumps to a temporary file when passed output: :nil" do
+ file = ObjectSpace.dump("abc", output: nil)
+ file.should be_kind_of(File)
+
+ file.rewind
+ file.read.should include('"value":"abc"')
+ ensure
+ file.close
+ File.unlink file.path
+ end
+
+ it "dumps to stdout when passed output: :stdout" do
+ stdout = ruby_exe('ObjectSpace.dump("abc", output: :stdout)', options: "-robjspace").chomp
+ stdout.should include('"value":"abc"')
+ end
+
+ it "dumps to provided IO when passed output: IO" do
+ filename = tmp("io_read.txt")
+ io = File.open(filename, "w+")
+ result = ObjectSpace.dump("abc", output: io)
+ result.should.equal? io
+
+ io.rewind
+ io.read.should include('"value":"abc"')
+ ensure
+ io.close
+ rm_r filename
+ end
+
+ it "raises ArgumentError when passed not supported :output value" do
+ -> { ObjectSpace.dump("abc", output: Object.new) }.should raise_error(ArgumentError, /wrong output option/)
+ end
+end
diff --git a/spec/ruby/library/objectspace/fixtures/trace.rb b/spec/ruby/library/objectspace/fixtures/trace.rb
new file mode 100644
index 0000000000..e53a7a0cac
--- /dev/null
+++ b/spec/ruby/library/objectspace/fixtures/trace.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: false
+require "objspace/trace"
+a = "foo"
+b = "b" + "a" + "r"
+c = 42
+p a, b, c
diff --git a/spec/ruby/library/objectspace/memsize_of_all_spec.rb b/spec/ruby/library/objectspace/memsize_of_all_spec.rb
new file mode 100644
index 0000000000..c5a48165ce
--- /dev/null
+++ b/spec/ruby/library/objectspace/memsize_of_all_spec.rb
@@ -0,0 +1,22 @@
+require_relative '../../spec_helper'
+require 'objspace'
+
+describe "ObjectSpace.memsize_of_all" do
+ it "returns a non-zero Integer for all objects" do
+ ObjectSpace.memsize_of_all.should be_kind_of(Integer)
+ ObjectSpace.memsize_of_all.should > 0
+ end
+
+ it "returns a non-zero Integer for Class" do
+ ObjectSpace.memsize_of_all(Class).should be_kind_of(Integer)
+ ObjectSpace.memsize_of_all(Class).should > 0
+ end
+
+ it "increases when a new object is allocated" do
+ c = Class.new
+ before = ObjectSpace.memsize_of_all(c)
+ o = c.new
+ after = ObjectSpace.memsize_of_all(c)
+ after.should > before
+ end
+end
diff --git a/spec/ruby/library/objectspace/memsize_of_spec.rb b/spec/ruby/library/objectspace/memsize_of_spec.rb
index 36d845824d..eefafbb334 100644
--- a/spec/ruby/library/objectspace/memsize_of_spec.rb
+++ b/spec/ruby/library/objectspace/memsize_of_spec.rb
@@ -16,7 +16,7 @@ describe "ObjectSpace.memsize_of" do
ObjectSpace.memsize_of(:abc).should == 0
end
- it "returns an Integer for an Object" do
+ it "returns a positive Integer for an Object" do
obj = Object.new
ObjectSpace.memsize_of(obj).should be_kind_of(Integer)
ObjectSpace.memsize_of(obj).should > 0
diff --git a/spec/ruby/library/objectspace/reachable_objects_from_spec.rb b/spec/ruby/library/objectspace/reachable_objects_from_spec.rb
index 7e70bc8569..dee5961663 100644
--- a/spec/ruby/library/objectspace/reachable_objects_from_spec.rb
+++ b/spec/ruby/library/objectspace/reachable_objects_from_spec.rb
@@ -38,7 +38,6 @@ describe "ObjectSpace.reachable_objects_from" do
end
it "finds an object stored in a Queue" do
- require 'thread'
o = Object.new
q = Queue.new
q << o
@@ -49,7 +48,6 @@ describe "ObjectSpace.reachable_objects_from" do
end
it "finds an object stored in a SizedQueue" do
- require 'thread'
o = Object.new
q = SizedQueue.new(3)
q << o
diff --git a/spec/ruby/library/objectspace/trace_object_allocations_spec.rb b/spec/ruby/library/objectspace/trace_object_allocations_spec.rb
new file mode 100644
index 0000000000..612430e067
--- /dev/null
+++ b/spec/ruby/library/objectspace/trace_object_allocations_spec.rb
@@ -0,0 +1,149 @@
+require_relative '../../spec_helper'
+require 'objspace'
+
+describe "ObjectSpace.trace_object_allocations" do
+ it "runs a block" do
+ ScratchPad.clear
+ ObjectSpace.trace_object_allocations do
+ ScratchPad.record :a
+ end
+ ScratchPad.recorded.should == :a
+ end
+
+ it "records info for allocation_class_path" do
+ ObjectSpace.trace_object_allocations do
+ o = Object.new
+ ObjectSpace.allocation_class_path(o).should == "Class"
+ a = [1, 2, 3]
+ ObjectSpace.allocation_class_path(a).should == nil
+ end
+ end
+
+ it "records info for allocation_generation" do
+ ObjectSpace.trace_object_allocations do
+ o = Object.new
+ ObjectSpace.allocation_generation(o).should.kind_of?(Integer)
+ a = [1, 2, 3]
+ ObjectSpace.allocation_generation(a).should.kind_of?(Integer)
+ end
+ end
+
+ it "records info for allocation_method_id" do
+ ObjectSpace.trace_object_allocations do
+ o = Object.new
+ ObjectSpace.allocation_method_id(o).should == :new
+ a = [1, 2, 3]
+ ObjectSpace.allocation_method_id(a).should == nil
+ end
+ end
+
+ it "records info for allocation_sourcefile" do
+ ObjectSpace.trace_object_allocations do
+ o = Object.new
+ ObjectSpace.allocation_sourcefile(o).should == __FILE__
+ a = [1, 2, 3]
+ ObjectSpace.allocation_sourcefile(a).should == __FILE__
+ end
+ end
+
+ it "records info for allocation_sourceline" do
+ ObjectSpace.trace_object_allocations do
+ o = Object.new
+ ObjectSpace.allocation_sourceline(o).should == __LINE__ - 1
+ a = [1, 2, 3]
+ ObjectSpace.allocation_sourceline(a).should == __LINE__ - 1
+ end
+ end
+
+ it "can be cleared using trace_object_allocations_clear" do
+ ObjectSpace.trace_object_allocations do
+ o = Object.new
+ ObjectSpace.allocation_class_path(o).should == "Class"
+ ObjectSpace.trace_object_allocations_clear
+ ObjectSpace.allocation_class_path(o).should be_nil
+ end
+ end
+
+ it "does not clears allocation data after returning" do
+ o = nil
+ ObjectSpace.trace_object_allocations do
+ o = Object.new
+ end
+ ObjectSpace.allocation_class_path(o).should == "Class"
+ end
+
+ it "can be used without a block using trace_object_allocations_start and _stop" do
+ ObjectSpace.trace_object_allocations_start
+ begin
+ o = Object.new
+ ObjectSpace.allocation_class_path(o).should == "Class"
+ a = [1, 2, 3]
+ ObjectSpace.allocation_class_path(a).should == nil
+ ensure
+ ObjectSpace.trace_object_allocations_stop
+ end
+ end
+
+ it "does not clears allocation data after trace_object_allocations_stop" do
+ ObjectSpace.trace_object_allocations_start
+ begin
+ o = Object.new
+ ensure
+ ObjectSpace.trace_object_allocations_stop
+ end
+ ObjectSpace.allocation_class_path(o).should == "Class"
+ end
+
+ it "can be nested" do
+ ObjectSpace.trace_object_allocations do
+ ObjectSpace.trace_object_allocations do
+ o = Object.new
+ ObjectSpace.allocation_class_path(o).should == "Class"
+ end
+ end
+ end
+
+ it "can be nested without a block using trace_object_allocations_start and _stop" do
+ ObjectSpace.trace_object_allocations_start
+ begin
+ ObjectSpace.trace_object_allocations_start
+ begin
+ o = Object.new
+ ObjectSpace.allocation_class_path(o).should == "Class"
+ ensure
+ ObjectSpace.trace_object_allocations_stop
+ end
+ ensure
+ ObjectSpace.trace_object_allocations_stop
+ end
+ end
+
+ it "can be nested with more _stop than _start" do
+ ObjectSpace.trace_object_allocations_start
+ begin
+ o = Object.new
+ ObjectSpace.allocation_class_path(o).should == "Class"
+ ObjectSpace.trace_object_allocations_stop
+ ensure
+ ObjectSpace.trace_object_allocations_stop
+ end
+ end
+
+ it "returns nil for class_path, generation, method_id, sourcefile, and sourceline for immutable objects" do
+ ObjectSpace.trace_object_allocations_start
+ begin
+ one = nil
+ two = 42
+ three = :foo
+ [one, two, three].each do |i|
+ ObjectSpace.allocation_class_path(i).should == nil
+ ObjectSpace.allocation_generation(i).should == nil
+ ObjectSpace.allocation_method_id(i).should == nil
+ ObjectSpace.allocation_sourcefile(i).should == nil
+ ObjectSpace.allocation_sourceline(i).should == nil
+ end
+ ensure
+ ObjectSpace.trace_object_allocations_stop
+ end
+ end
+end
diff --git a/spec/ruby/library/objectspace/trace_spec.rb b/spec/ruby/library/objectspace/trace_spec.rb
new file mode 100644
index 0000000000..532c282ce4
--- /dev/null
+++ b/spec/ruby/library/objectspace/trace_spec.rb
@@ -0,0 +1,15 @@
+require_relative '../../spec_helper'
+
+ruby_version_is "3.1" do
+ describe 'require "objspace/trace"' do
+ it "shows object allocation sites" do
+ file = fixture(__FILE__ , "trace.rb")
+ ruby_exe(file, args: "2>&1").lines(chomp: true).should == [
+ "objspace/trace is enabled",
+ "\"foo\" @ #{file}:3",
+ "\"bar\" @ #{file}:4",
+ "42"
+ ]
+ end
+ end
+end
diff --git a/spec/ruby/library/openssl/config/freeze_spec.rb b/spec/ruby/library/openssl/config/freeze_spec.rb
deleted file mode 100644
index c814341b86..0000000000
--- a/spec/ruby/library/openssl/config/freeze_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative '../shared/constants'
-
-require 'openssl'
-
-version_is(OpenSSL::VERSION, ""..."2.2") do
- describe "OpenSSL::Config#freeze" do
- it "needs to be reviewed for completeness"
-
- it "freezes" do
- c = OpenSSL::Config.new
- -> {
- c['foo'] = [ ['key', 'value'] ]
- }.should_not raise_error
- c.freeze
- c.frozen?.should be_true
- -> {
- c['foo'] = [ ['key', 'value'] ]
- }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/library/openssl/digest/append_spec.rb b/spec/ruby/library/openssl/digest/append_spec.rb
new file mode 100644
index 0000000000..08802b7253
--- /dev/null
+++ b/spec/ruby/library/openssl/digest/append_spec.rb
@@ -0,0 +1,6 @@
+require_relative '../../../spec_helper'
+require_relative 'shared/update'
+
+describe "OpenSSL::Digest#<<" do
+ it_behaves_like :openssl_digest_update, :<<
+end
diff --git a/spec/ruby/library/openssl/digest/block_length_spec.rb b/spec/ruby/library/openssl/digest/block_length_spec.rb
new file mode 100644
index 0000000000..444ed9d20d
--- /dev/null
+++ b/spec/ruby/library/openssl/digest/block_length_spec.rb
@@ -0,0 +1,44 @@
+require_relative '../../../spec_helper'
+require_relative '../../../library/digest/sha1/shared/constants'
+require_relative '../../../library/digest/sha256/shared/constants'
+require_relative '../../../library/digest/sha384/shared/constants'
+require_relative '../../../library/digest/sha512/shared/constants'
+require 'openssl'
+
+describe "OpenSSL::Digest#block_length" do
+ context "when the digest object is created via a name argument" do
+ it "returns a SHA1 block length" do
+ OpenSSL::Digest.new('sha1').block_length.should == SHA1Constants::BlockLength
+ end
+
+ it "returns a SHA256 block length" do
+ OpenSSL::Digest.new('sha256').block_length.should == SHA256Constants::BlockLength
+ end
+
+ it "returns a SHA384 block length" do
+ OpenSSL::Digest.new('sha384').block_length.should == SHA384Constants::BlockLength
+ end
+
+ it "returns a SHA512 block length" do
+ OpenSSL::Digest.new('sha512').block_length.should == SHA512Constants::BlockLength
+ end
+ end
+
+ context "when the digest object is created via a subclass" do
+ it "returns a SHA1 block length" do
+ OpenSSL::Digest::SHA1.new.block_length.should == SHA1Constants::BlockLength
+ end
+
+ it "returns a SHA256 block length" do
+ OpenSSL::Digest::SHA256.new.block_length.should == SHA256Constants::BlockLength
+ end
+
+ it "returns a SHA384 block length" do
+ OpenSSL::Digest::SHA384.new.block_length.should == SHA384Constants::BlockLength
+ end
+
+ it "returns a SHA512 block length" do
+ OpenSSL::Digest::SHA512.new.block_length.should == SHA512Constants::BlockLength
+ end
+ end
+end
diff --git a/spec/ruby/library/openssl/digest/digest_length_spec.rb b/spec/ruby/library/openssl/digest/digest_length_spec.rb
new file mode 100644
index 0000000000..37d1cba9a7
--- /dev/null
+++ b/spec/ruby/library/openssl/digest/digest_length_spec.rb
@@ -0,0 +1,44 @@
+require_relative '../../../spec_helper'
+require_relative '../../../library/digest/sha1/shared/constants'
+require_relative '../../../library/digest/sha256/shared/constants'
+require_relative '../../../library/digest/sha384/shared/constants'
+require_relative '../../../library/digest/sha512/shared/constants'
+require 'openssl'
+
+describe "OpenSSL::Digest#digest_length" do
+ context "when the digest object is created via a name argument" do
+ it "returns a SHA1 digest length" do
+ OpenSSL::Digest.new('sha1').digest_length.should == SHA1Constants::DigestLength
+ end
+
+ it "returns a SHA256 digest length" do
+ OpenSSL::Digest.new('sha256').digest_length.should == SHA256Constants::DigestLength
+ end
+
+ it "returns a SHA384 digest length" do
+ OpenSSL::Digest.new('sha384').digest_length.should == SHA384Constants::DigestLength
+ end
+
+ it "returns a SHA512 digest length" do
+ OpenSSL::Digest.new('sha512').digest_length.should == SHA512Constants::DigestLength
+ end
+ end
+
+ context "when the digest object is created via a subclass" do
+ it "returns a SHA1 digest length" do
+ OpenSSL::Digest::SHA1.new.digest_length.should == SHA1Constants::DigestLength
+ end
+
+ it "returns a SHA256 digest length" do
+ OpenSSL::Digest::SHA256.new.digest_length.should == SHA256Constants::DigestLength
+ end
+
+ it "returns a SHA384 digest length" do
+ OpenSSL::Digest::SHA384.new.digest_length.should == SHA384Constants::DigestLength
+ end
+
+ it "returns a SHA512 digest length" do
+ OpenSSL::Digest::SHA512.new.digest_length.should == SHA512Constants::DigestLength
+ end
+ end
+end
diff --git a/spec/ruby/library/openssl/digest_spec.rb b/spec/ruby/library/openssl/digest/digest_spec.rb
index b8e82d073f..cf27d01b6d 100644
--- a/spec/ruby/library/openssl/digest_spec.rb
+++ b/spec/ruby/library/openssl/digest/digest_spec.rb
@@ -1,12 +1,11 @@
-require_relative '../../spec_helper'
-require_relative '../../library/digest/sha1/shared/constants'
-require_relative '../../library/digest/sha256/shared/constants'
-require_relative '../../library/digest/sha384/shared/constants'
-require_relative '../../library/digest/sha512/shared/constants'
+require_relative '../../../spec_helper'
+require_relative '../../../library/digest/sha1/shared/constants'
+require_relative '../../../library/digest/sha256/shared/constants'
+require_relative '../../../library/digest/sha384/shared/constants'
+require_relative '../../../library/digest/sha512/shared/constants'
require 'openssl'
-describe "OpenSSL::Digest" do
-
+describe "OpenSSL::Digest class methods" do
describe ".digest" do
it "returns a SHA1 digest" do
OpenSSL::Digest.digest('sha1', SHA1Constants::Contents).should == SHA1Constants::Digest
diff --git a/spec/ruby/library/openssl/digest/initialize_spec.rb b/spec/ruby/library/openssl/digest/initialize_spec.rb
new file mode 100644
index 0000000000..1cd0409c4d
--- /dev/null
+++ b/spec/ruby/library/openssl/digest/initialize_spec.rb
@@ -0,0 +1,141 @@
+require_relative '../../../spec_helper'
+require_relative '../../../library/digest/sha1/shared/constants'
+require_relative '../../../library/digest/sha256/shared/constants'
+require_relative '../../../library/digest/sha384/shared/constants'
+require_relative '../../../library/digest/sha512/shared/constants'
+require 'openssl'
+
+describe "OpenSSL::Digest#initialize" do
+ describe "can be called with a digest name" do
+ it "returns a SHA1 object" do
+ OpenSSL::Digest.new("sha1").name.should == "SHA1"
+ end
+
+ it "returns a SHA256 object" do
+ OpenSSL::Digest.new("sha256").name.should == "SHA256"
+ end
+
+ it "returns a SHA384 object" do
+ OpenSSL::Digest.new("sha384").name.should == "SHA384"
+ end
+
+ it "returns a SHA512 object" do
+ OpenSSL::Digest.new("sha512").name.should == "SHA512"
+ end
+
+ it "throws an error when called with an unknown digest" do
+ -> { OpenSSL::Digest.new("wd40") }.should raise_error(RuntimeError, /Unsupported digest algorithm \(wd40\)/)
+ end
+
+ it "cannot be called with a symbol" do
+ -> { OpenSSL::Digest.new(:SHA1) }.should raise_error(TypeError, /wrong argument type Symbol/)
+ end
+
+ it "does not call #to_str on the argument" do
+ name = mock("digest name")
+ name.should_not_receive(:to_str)
+ -> { OpenSSL::Digest.new(name) }.should raise_error(TypeError, /wrong argument type/)
+ end
+ end
+
+ describe "can be called with a digest object" do
+ it "returns a SHA1 object" do
+ OpenSSL::Digest.new(OpenSSL::Digest::SHA1.new).name.should == "SHA1"
+ end
+
+ it "returns a SHA256 object" do
+ OpenSSL::Digest.new(OpenSSL::Digest::SHA256.new).name.should == "SHA256"
+ end
+
+ it "returns a SHA384 object" do
+ OpenSSL::Digest.new(OpenSSL::Digest::SHA384.new).name.should == "SHA384"
+ end
+
+ it "returns a SHA512 object" do
+ OpenSSL::Digest.new(OpenSSL::Digest::SHA512.new).name.should == "SHA512"
+ end
+
+ it "ignores the state of the digest object" do
+ sha1 = OpenSSL::Digest.new('sha1', SHA1Constants::Contents)
+ OpenSSL::Digest.new(sha1).digest.should == SHA1Constants::BlankDigest
+ end
+ end
+
+ it "cannot be called with a digest class" do
+ -> { OpenSSL::Digest.new(OpenSSL::Digest::SHA1) }.should raise_error(TypeError, /wrong argument type Class/)
+ end
+
+ context "when called without an initial String argument" do
+ it "returns a SHA1 digest" do
+ OpenSSL::Digest.new("sha1").digest.should == SHA1Constants::BlankDigest
+ end
+
+ it "returns a SHA256 digest" do
+ OpenSSL::Digest.new("sha256").digest.should == SHA256Constants::BlankDigest
+ end
+
+ it "returns a SHA384 digest" do
+ OpenSSL::Digest.new("sha384").digest.should == SHA384Constants::BlankDigest
+ end
+
+ it "returns a SHA512 digest" do
+ OpenSSL::Digest.new("sha512").digest.should == SHA512Constants::BlankDigest
+ end
+ end
+
+ context "when called with an initial String argument" do
+ it "returns a SHA1 digest of that argument" do
+ OpenSSL::Digest.new("sha1", SHA1Constants::Contents).digest.should == SHA1Constants::Digest
+ end
+
+ it "returns a SHA256 digest of that argument" do
+ OpenSSL::Digest.new("sha256", SHA256Constants::Contents).digest.should == SHA256Constants::Digest
+ end
+
+ it "returns a SHA384 digest of that argument" do
+ OpenSSL::Digest.new("sha384", SHA384Constants::Contents).digest.should == SHA384Constants::Digest
+ end
+
+ it "returns a SHA512 digest of that argument" do
+ OpenSSL::Digest.new("sha512", SHA512Constants::Contents).digest.should == SHA512Constants::Digest
+ end
+ end
+
+ context "can be called on subclasses" do
+ describe "can be called without an initial String argument on subclasses" do
+ it "returns a SHA1 digest" do
+ OpenSSL::Digest::SHA1.new.digest.should == SHA1Constants::BlankDigest
+ end
+
+ it "returns a SHA256 digest" do
+ OpenSSL::Digest::SHA256.new.digest.should == SHA256Constants::BlankDigest
+ end
+
+ it "returns a SHA384 digest" do
+ OpenSSL::Digest::SHA384.new.digest.should == SHA384Constants::BlankDigest
+ end
+
+ it "returns a SHA512 digest" do
+ OpenSSL::Digest::SHA512.new.digest.should == SHA512Constants::BlankDigest
+ end
+ end
+
+ describe "can be called with an initial String argument on subclasses" do
+ it "returns a SHA1 digest" do
+ OpenSSL::Digest::SHA1.new(SHA1Constants::Contents).digest.should == SHA1Constants::Digest
+ end
+
+ it "returns a SHA256 digest" do
+ OpenSSL::Digest::SHA256.new(SHA256Constants::Contents).digest.should == SHA256Constants::Digest
+ end
+
+ it "returns a SHA384 digest" do
+ OpenSSL::Digest::SHA384.new(SHA384Constants::Contents).digest.should == SHA384Constants::Digest
+ end
+
+ it "returns a SHA512 digest" do
+ OpenSSL::Digest::SHA512.new(SHA512Constants::Contents).digest.should == SHA512Constants::Digest
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/openssl/digest/name_spec.rb b/spec/ruby/library/openssl/digest/name_spec.rb
new file mode 100644
index 0000000000..b379f35c1c
--- /dev/null
+++ b/spec/ruby/library/openssl/digest/name_spec.rb
@@ -0,0 +1,16 @@
+require_relative '../../../spec_helper'
+require 'openssl'
+
+describe "OpenSSL::Digest#name" do
+ it "returns the name of digest" do
+ OpenSSL::Digest.new('SHA1').name.should == 'SHA1'
+ end
+
+ it "converts the name to the internal representation of OpenSSL" do
+ OpenSSL::Digest.new('sha1').name.should == 'SHA1'
+ end
+
+ it "works on subclasses too" do
+ OpenSSL::Digest::SHA1.new.name.should == 'SHA1'
+ end
+end
diff --git a/spec/ruby/library/openssl/digest/reset_spec.rb b/spec/ruby/library/openssl/digest/reset_spec.rb
new file mode 100644
index 0000000000..c19bf46633
--- /dev/null
+++ b/spec/ruby/library/openssl/digest/reset_spec.rb
@@ -0,0 +1,36 @@
+require_relative '../../../spec_helper'
+require_relative '../../../library/digest/sha1/shared/constants'
+require_relative '../../../library/digest/sha256/shared/constants'
+require_relative '../../../library/digest/sha384/shared/constants'
+require_relative '../../../library/digest/sha512/shared/constants'
+require 'openssl'
+
+describe "OpenSSL::Digest#reset" do
+ it "works for a SHA1 digest" do
+ digest = OpenSSL::Digest.new('sha1', SHA1Constants::Contents)
+ digest.reset
+ digest.update(SHA1Constants::Contents)
+ digest.digest.should == SHA1Constants::Digest
+ end
+
+ it "works for a SHA256 digest" do
+ digest = OpenSSL::Digest.new('sha256', SHA256Constants::Contents)
+ digest.reset
+ digest.update(SHA256Constants::Contents)
+ digest.digest.should == SHA256Constants::Digest
+ end
+
+ it "works for a SHA384 digest" do
+ digest = OpenSSL::Digest.new('sha384', SHA384Constants::Contents)
+ digest.reset
+ digest.update(SHA384Constants::Contents)
+ digest.digest.should == SHA384Constants::Digest
+ end
+
+ it "works for a SHA512 digest" do
+ digest = OpenSSL::Digest.new('sha512', SHA512Constants::Contents)
+ digest.reset
+ digest.update(SHA512Constants::Contents)
+ digest.digest.should == SHA512Constants::Digest
+ end
+end
diff --git a/spec/ruby/library/openssl/digest/shared/update.rb b/spec/ruby/library/openssl/digest/shared/update.rb
new file mode 100644
index 0000000000..e5ff9dcb16
--- /dev/null
+++ b/spec/ruby/library/openssl/digest/shared/update.rb
@@ -0,0 +1,123 @@
+require_relative '../../../../library/digest/sha1/shared/constants'
+require_relative '../../../../library/digest/sha256/shared/constants'
+require_relative '../../../../library/digest/sha384/shared/constants'
+require_relative '../../../../library/digest/sha512/shared/constants'
+require 'openssl'
+
+describe :openssl_digest_update, shared: true do
+ context "when given input as a single string" do
+ it "returns a SHA1 digest" do
+ digest = OpenSSL::Digest.new('sha1')
+ digest.send(@method, SHA1Constants::Contents)
+ digest.digest.should == SHA1Constants::Digest
+ end
+
+ it "returns a SHA256 digest" do
+ digest = OpenSSL::Digest.new('sha256')
+ digest.send(@method, SHA256Constants::Contents)
+ digest.digest.should == SHA256Constants::Digest
+ end
+
+ it "returns a SHA384 digest" do
+ digest = OpenSSL::Digest.new('sha384')
+ digest.send(@method, SHA384Constants::Contents)
+ digest.digest.should == SHA384Constants::Digest
+ end
+
+ it "returns a SHA512 digest" do
+ digest = OpenSSL::Digest.new('sha512')
+ digest.send(@method, SHA512Constants::Contents)
+ digest.digest.should == SHA512Constants::Digest
+ end
+ end
+
+ context "when given input as multiple smaller substrings" do
+ it "returns a SHA1 digest" do
+ digest = OpenSSL::Digest.new('sha1')
+ SHA1Constants::Contents.each_char { |b| digest.send(@method, b) }
+ digest.digest.should == SHA1Constants::Digest
+ end
+
+ it "returns a SHA256 digest" do
+ digest = OpenSSL::Digest.new('sha256')
+ SHA256Constants::Contents.each_char { |b| digest.send(@method, b) }
+ digest.digest.should == SHA256Constants::Digest
+ end
+
+ it "returns a SHA384 digest" do
+ digest = OpenSSL::Digest.new('sha384')
+ SHA384Constants::Contents.each_char { |b| digest.send(@method, b) }
+ digest.digest.should == SHA384Constants::Digest
+ end
+
+ it "returns a SHA512 digest" do
+ digest = OpenSSL::Digest.new('sha512')
+ SHA512Constants::Contents.each_char { |b| digest.send(@method, b) }
+ digest.digest.should == SHA512Constants::Digest
+ end
+ end
+
+ context "when input is not a String and responds to #to_str" do
+ it "returns a SHA1 digest" do
+ str = mock('str')
+ str.should_receive(:to_str).and_return(SHA1Constants::Contents)
+ digest = OpenSSL::Digest.new('sha1')
+ digest.send(@method, str)
+ digest.digest.should == SHA1Constants::Digest
+ end
+
+ it "returns a SHA256 digest" do
+ str = mock('str')
+ str.should_receive(:to_str).and_return(SHA256Constants::Contents)
+ digest = OpenSSL::Digest.new('sha256')
+ digest.send(@method, str)
+ digest.digest.should == SHA256Constants::Digest
+ end
+
+ it "returns a SHA384 digest" do
+ str = mock('str')
+ str.should_receive(:to_str).and_return(SHA384Constants::Contents)
+ digest = OpenSSL::Digest.new('sha384')
+ digest.send(@method, str)
+ digest.digest.should == SHA384Constants::Digest
+ end
+
+ it "returns a SHA512 digest" do
+ str = mock('str')
+ str.should_receive(:to_str).and_return(SHA512Constants::Contents)
+ digest = OpenSSL::Digest.new('sha512')
+ digest.send(@method, str)
+ digest.digest.should == SHA512Constants::Digest
+ end
+ end
+
+ context "when input is not a String and does not respond to #to_str" do
+ it "raises a TypeError with SHA1" do
+ digest = OpenSSL::Digest.new('sha1')
+ -> {
+ digest.send(@method, Object.new)
+ }.should raise_error(TypeError, 'no implicit conversion of Object into String')
+ end
+
+ it "raises a TypeError with SHA256" do
+ digest = OpenSSL::Digest.new('sha256')
+ -> {
+ digest.send(@method, Object.new)
+ }.should raise_error(TypeError, 'no implicit conversion of Object into String')
+ end
+
+ it "raises a TypeError with SHA384" do
+ digest = OpenSSL::Digest.new('sha384')
+ -> {
+ digest.send(@method, Object.new)
+ }.should raise_error(TypeError, 'no implicit conversion of Object into String')
+ end
+
+ it "raises a TypeError with SHA512" do
+ digest = OpenSSL::Digest.new('sha512')
+ -> {
+ digest.send(@method, Object.new)
+ }.should raise_error(TypeError, 'no implicit conversion of Object into String')
+ end
+ end
+end
diff --git a/spec/ruby/library/openssl/digest/update_spec.rb b/spec/ruby/library/openssl/digest/update_spec.rb
new file mode 100644
index 0000000000..3a90b06c6b
--- /dev/null
+++ b/spec/ruby/library/openssl/digest/update_spec.rb
@@ -0,0 +1,6 @@
+require_relative '../../../spec_helper'
+require_relative 'shared/update'
+
+describe "OpenSSL::Digest#update" do
+ it_behaves_like :openssl_digest_update, :update
+end
diff --git a/spec/ruby/library/openssl/fixed_length_secure_compare_spec.rb b/spec/ruby/library/openssl/fixed_length_secure_compare_spec.rb
new file mode 100644
index 0000000000..5a2ca168b5
--- /dev/null
+++ b/spec/ruby/library/openssl/fixed_length_secure_compare_spec.rb
@@ -0,0 +1,42 @@
+require_relative '../../spec_helper'
+require 'openssl'
+
+describe "OpenSSL.fixed_length_secure_compare" do
+ it "returns true for two strings with the same content" do
+ input1 = "the quick brown fox jumps over the lazy dog"
+ input2 = "the quick brown fox jumps over the lazy dog"
+ OpenSSL.fixed_length_secure_compare(input1, input2).should be_true
+ end
+
+ it "returns false for two strings of equal size with different content" do
+ input1 = "the quick brown fox jumps over the lazy dog"
+ input2 = "the lazy dog jumps over the quick brown fox"
+ OpenSSL.fixed_length_secure_compare(input1, input2).should be_false
+ end
+
+ it "converts both arguments to strings using #to_str" do
+ input1 = mock("input1")
+ input1.should_receive(:to_str).and_return("the quick brown fox jumps over the lazy dog")
+ input2 = mock("input2")
+ input2.should_receive(:to_str).and_return("the quick brown fox jumps over the lazy dog")
+ OpenSSL.fixed_length_secure_compare(input1, input2).should be_true
+ end
+
+ it "does not accept arguments that are not string and cannot be coerced into strings" do
+ -> {
+ OpenSSL.fixed_length_secure_compare("input1", :input2)
+ }.should raise_error(TypeError, 'no implicit conversion of Symbol into String')
+
+ -> {
+ OpenSSL.fixed_length_secure_compare(Object.new, "input2")
+ }.should raise_error(TypeError, 'no implicit conversion of Object into String')
+ end
+
+ it "raises an ArgumentError for two strings of different size" do
+ input1 = "the quick brown fox jumps over the lazy dog"
+ input2 = "the quick brown fox"
+ -> {
+ OpenSSL.fixed_length_secure_compare(input1, input2)
+ }.should raise_error(ArgumentError, 'inputs must be of equal length')
+ end
+end
diff --git a/spec/ruby/library/openssl/kdf/pbkdf2_hmac_spec.rb b/spec/ruby/library/openssl/kdf/pbkdf2_hmac_spec.rb
new file mode 100644
index 0000000000..40f8597275
--- /dev/null
+++ b/spec/ruby/library/openssl/kdf/pbkdf2_hmac_spec.rb
@@ -0,0 +1,168 @@
+require_relative '../../../spec_helper'
+require 'openssl'
+
+describe "OpenSSL::KDF.pbkdf2_hmac" do
+ before :each do
+ @defaults = {
+ salt: "\x00".b * 16,
+ iterations: 20_000,
+ length: 16,
+ hash: "sha1"
+ }
+ end
+
+ it "creates the same value with the same input" do
+ key = OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults)
+ key.should == "!\x99+\xF0^\xD0\x8BM\x158\xC4\xAC\x9C\xF1\xF0\xE0".b
+ end
+
+ it "supports nullbytes embedded in the password" do
+ key = OpenSSL::KDF.pbkdf2_hmac("sec\x00ret".b, **@defaults)
+ key.should == "\xB9\x7F\xB0\xC2\th\xC8<\x86\xF3\x94Ij7\xEF\xF1".b
+ end
+
+ it "coerces the password into a String using #to_str" do
+ pass = mock("pass")
+ pass.should_receive(:to_str).and_return("secret")
+ key = OpenSSL::KDF.pbkdf2_hmac(pass, **@defaults)
+ key.should == "!\x99+\xF0^\xD0\x8BM\x158\xC4\xAC\x9C\xF1\xF0\xE0".b
+ end
+
+ it "coerces the salt into a String using #to_str" do
+ salt = mock("salt")
+ salt.should_receive(:to_str).and_return("\x00".b * 16)
+ key = OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, salt: salt)
+ key.should == "!\x99+\xF0^\xD0\x8BM\x158\xC4\xAC\x9C\xF1\xF0\xE0".b
+ end
+
+ it "coerces the iterations into an Integer using #to_int" do
+ iterations = mock("iterations")
+ iterations.should_receive(:to_int).and_return(20_000)
+ key = OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, iterations: iterations)
+ key.should == "!\x99+\xF0^\xD0\x8BM\x158\xC4\xAC\x9C\xF1\xF0\xE0".b
+ end
+
+ it "coerces the length into an Integer using #to_int" do
+ length = mock("length")
+ length.should_receive(:to_int).and_return(16)
+ key = OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, length: length)
+ key.should == "!\x99+\xF0^\xD0\x8BM\x158\xC4\xAC\x9C\xF1\xF0\xE0".b
+ end
+
+ it "accepts a OpenSSL::Digest object as hash" do
+ hash = OpenSSL::Digest.new("sha1")
+ key = OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, hash: hash)
+ key.should == "!\x99+\xF0^\xD0\x8BM\x158\xC4\xAC\x9C\xF1\xF0\xE0".b
+ end
+
+ it "accepts an empty password" do
+ key = OpenSSL::KDF.pbkdf2_hmac("", **@defaults)
+ key.should == "k\x9F-\xB1\xF7\x9A\v\xA1(C\xF9\x85!P\xEF\x8C".b
+ end
+
+ it "accepts an empty salt" do
+ key = OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, salt: "")
+ key.should == "\xD5f\xE5\xEA\xF91\x1D\xD3evD\xED\xDB\xE80\x80".b
+ end
+
+ it "accepts an empty length" do
+ key = OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, length: 0)
+ key.should.empty?
+ end
+
+ it "accepts an arbitrary length" do
+ key = OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, length: 19)
+ key.should == "!\x99+\xF0^\xD0\x8BM\x158\xC4\xAC\x9C\xF1\xF0\xE0\xCF\xBB\x7F".b
+ end
+
+ it "accepts any hash function known to OpenSSL" do
+ key = OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, hash: "sha512")
+ key.should == "N\x12}D\xCE\x99\xDBC\x8E\xEC\xAAr\xEA1\xDF\xFF".b
+ end
+
+ it "raises a TypeError when password is not a String and does not respond to #to_str" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac(Object.new, **@defaults)
+ }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ end
+
+ it "raises a TypeError when salt is not a String and does not respond to #to_str" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, salt: Object.new)
+ }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ end
+
+ it "raises a TypeError when iterations is not an Integer and does not respond to #to_int" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, iterations: Object.new)
+ }.should raise_error(TypeError, "no implicit conversion of Object into Integer")
+ end
+
+ it "raises a TypeError when length is not an Integer and does not respond to #to_int" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, length: Object.new)
+ }.should raise_error(TypeError, "no implicit conversion of Object into Integer")
+ end
+
+ it "raises a TypeError when hash is neither a String nor an OpenSSL::Digest" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, hash: Object.new)
+ }.should raise_error(TypeError, "wrong argument type Object (expected OpenSSL/Digest)")
+ end
+
+ it "raises a TypeError when hash is neither a String nor an OpenSSL::Digest, it does not try to call #to_str" do
+ hash = mock("hash")
+ hash.should_not_receive(:to_str)
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, hash: hash)
+ }.should raise_error(TypeError, "wrong argument type MockObject (expected OpenSSL/Digest)")
+ end
+
+ it "raises a RuntimeError for unknown digest algorithms" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, hash: "wd40")
+ }.should raise_error(RuntimeError, /Unsupported digest algorithm \(wd40\)/)
+ end
+
+ it "treats salt as a required keyword" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults.except(:salt))
+ }.should raise_error(ArgumentError, 'missing keyword: :salt')
+ end
+
+ it "treats iterations as a required keyword" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults.except(:iterations))
+ }.should raise_error(ArgumentError, 'missing keyword: :iterations')
+ end
+
+ it "treats length as a required keyword" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults.except(:length))
+ }.should raise_error(ArgumentError, 'missing keyword: :length')
+ end
+
+ it "treats hash as a required keyword" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults.except(:hash))
+ }.should raise_error(ArgumentError, 'missing keyword: :hash')
+ end
+
+ it "treats all keywords as required" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret")
+ }.should raise_error(ArgumentError, 'missing keywords: :salt, :iterations, :length, :hash')
+ end
+
+ guard -> { OpenSSL::OPENSSL_VERSION_NUMBER >= 0x30000000 } do
+ it "raises an OpenSSL::KDF::KDFError for 0 or less iterations" do
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, iterations: 0)
+ }.should raise_error(OpenSSL::KDF::KDFError, "PKCS5_PBKDF2_HMAC: invalid iteration count")
+
+ -> {
+ OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, iterations: -1)
+ }.should raise_error(OpenSSL::KDF::KDFError, /PKCS5_PBKDF2_HMAC/)
+ end
+ end
+end
diff --git a/spec/ruby/library/openssl/kdf/scrypt_spec.rb b/spec/ruby/library/openssl/kdf/scrypt_spec.rb
new file mode 100644
index 0000000000..5dc9f2f281
--- /dev/null
+++ b/spec/ruby/library/openssl/kdf/scrypt_spec.rb
@@ -0,0 +1,209 @@
+require_relative '../../../spec_helper'
+require 'openssl'
+
+guard -> { OpenSSL::KDF.respond_to?(:scrypt) } do
+ describe "OpenSSL::KDF.scrypt" do
+ before :each do
+ @defaults = {
+ salt: "\x00".b * 16,
+ N: 2**14,
+ r: 8,
+ p: 1,
+ length: 32
+ }
+ end
+
+ it "creates the same value with the same input" do
+ key = OpenSSL::KDF.scrypt("secret", **@defaults)
+ key.should == "h\xB2k\xDF]\xDA\xE1.-(\xCF\xAC\x91D\x8F\xC2a\x9C\x9D\x17}\xF2\x84T\xD4)\xC2>\xFE\x93\xE3\xF4".b
+ end
+
+ it "supports nullbytes embedded into the password" do
+ key = OpenSSL::KDF.scrypt("sec\x00ret".b, **@defaults)
+ key.should == "\xF9\xA4\xA0\xF1p\xF4\xF0\xCAT\xB4v\xEB\r7\x88N\xF7\x15]Ns\xFCwt4a\xC9\xC6\xA7\x13\x81&".b
+ end
+
+ it "coerces the password into a String using #to_str" do
+ pass = mock("pass")
+ pass.should_receive(:to_str).and_return("secret")
+ key = OpenSSL::KDF.scrypt(pass, **@defaults)
+ key.should == "h\xB2k\xDF]\xDA\xE1.-(\xCF\xAC\x91D\x8F\xC2a\x9C\x9D\x17}\xF2\x84T\xD4)\xC2>\xFE\x93\xE3\xF4".b
+ end
+
+ it "coerces the salt into a String using #to_str" do
+ salt = mock("salt")
+ salt.should_receive(:to_str).and_return("\x00".b * 16)
+ key = OpenSSL::KDF.scrypt("secret", **@defaults, salt: salt)
+ key.should == "h\xB2k\xDF]\xDA\xE1.-(\xCF\xAC\x91D\x8F\xC2a\x9C\x9D\x17}\xF2\x84T\xD4)\xC2>\xFE\x93\xE3\xF4".b
+ end
+
+ it "coerces the N into an Integer using #to_int" do
+ n = mock("N")
+ n.should_receive(:to_int).and_return(2**14)
+ key = OpenSSL::KDF.scrypt("secret", **@defaults, N: n)
+ key.should == "h\xB2k\xDF]\xDA\xE1.-(\xCF\xAC\x91D\x8F\xC2a\x9C\x9D\x17}\xF2\x84T\xD4)\xC2>\xFE\x93\xE3\xF4".b
+ end
+
+ it "coerces the r into an Integer using #to_int" do
+ r = mock("r")
+ r.should_receive(:to_int).and_return(8)
+ key = OpenSSL::KDF.scrypt("secret", **@defaults, r: r)
+ key.should == "h\xB2k\xDF]\xDA\xE1.-(\xCF\xAC\x91D\x8F\xC2a\x9C\x9D\x17}\xF2\x84T\xD4)\xC2>\xFE\x93\xE3\xF4".b
+ end
+
+ it "coerces the p into an Integer using #to_int" do
+ p = mock("p")
+ p.should_receive(:to_int).and_return(1)
+ key = OpenSSL::KDF.scrypt("secret", **@defaults, p: p)
+ key.should == "h\xB2k\xDF]\xDA\xE1.-(\xCF\xAC\x91D\x8F\xC2a\x9C\x9D\x17}\xF2\x84T\xD4)\xC2>\xFE\x93\xE3\xF4".b
+ end
+
+ it "coerces the length into an Integer using #to_int" do
+ length = mock("length")
+ length.should_receive(:to_int).and_return(32)
+ key = OpenSSL::KDF.scrypt("secret", **@defaults, length: length)
+ key.should == "h\xB2k\xDF]\xDA\xE1.-(\xCF\xAC\x91D\x8F\xC2a\x9C\x9D\x17}\xF2\x84T\xD4)\xC2>\xFE\x93\xE3\xF4".b
+ end
+
+ it "accepts an empty password" do
+ key = OpenSSL::KDF.scrypt("", **@defaults)
+ key.should == "\xAA\xFC\xF5^E\x94v\xFFk\xE6\xF0vR\xE7\x13\xA7\xF5\x15'\x9A\xE4C\x9Dn\x18F_E\xD2\v\e\xB3".b
+ end
+
+ it "accepts an empty salt" do
+ key = OpenSSL::KDF.scrypt("secret", **@defaults, salt: "")
+ key.should == "\x96\xACDl\xCB3/aN\xB0F\x8A#\xD7\x92\xD2O\x1E\v\xBB\xCE\xC0\xAA\xB9\x0F]\xB09\xEA8\xDD\e".b
+ end
+
+ it "accepts a zero length" do
+ key = OpenSSL::KDF.scrypt("secret", **@defaults, length: 0)
+ key.should.empty?
+ end
+
+ it "accepts an arbitrary length" do
+ key = OpenSSL::KDF.scrypt("secret", **@defaults, length: 19)
+ key.should == "h\xB2k\xDF]\xDA\xE1.-(\xCF\xAC\x91D\x8F\xC2a\x9C\x9D".b
+ end
+
+ it "raises a TypeError when password is not a String and does not respond to #to_str" do
+ -> {
+ OpenSSL::KDF.scrypt(Object.new, **@defaults)
+ }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ end
+
+ it "raises a TypeError when salt is not a String and does not respond to #to_str" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, salt: Object.new)
+ }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ end
+
+ it "raises a TypeError when N is not an Integer and does not respond to #to_int" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, N: Object.new)
+ }.should raise_error(TypeError, "no implicit conversion of Object into Integer")
+ end
+
+ it "raises a TypeError when r is not an Integer and does not respond to #to_int" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, r: Object.new)
+ }.should raise_error(TypeError, "no implicit conversion of Object into Integer")
+ end
+
+ it "raises a TypeError when p is not an Integer and does not respond to #to_int" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, p: Object.new)
+ }.should raise_error(TypeError, "no implicit conversion of Object into Integer")
+ end
+
+ it "raises a TypeError when length is not an Integer and does not respond to #to_int" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, length: Object.new)
+ }.should raise_error(TypeError, "no implicit conversion of Object into Integer")
+ end
+
+ it "treats salt as a required keyword" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults.except(:salt))
+ }.should raise_error(ArgumentError, 'missing keyword: :salt')
+ end
+
+ it "treats N as a required keyword" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults.except(:N))
+ }.should raise_error(ArgumentError, 'missing keyword: :N')
+ end
+
+ it "treats r as a required keyword" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults.except(:r))
+ }.should raise_error(ArgumentError, 'missing keyword: :r')
+ end
+
+ it "treats p as a required keyword" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults.except(:p))
+ }.should raise_error(ArgumentError, 'missing keyword: :p')
+ end
+
+ it "treats length as a required keyword" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults.except(:length))
+ }.should raise_error(ArgumentError, 'missing keyword: :length')
+ end
+
+ it "treats all keywords as required" do
+ -> {
+ OpenSSL::KDF.scrypt("secret")
+ }.should raise_error(ArgumentError, 'missing keywords: :salt, :N, :r, :p, :length')
+ end
+
+ it "requires N to be a power of 2" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, N: 2**14 - 1)
+ }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/)
+ end
+
+ it "requires N to be at least 2" do
+ key = OpenSSL::KDF.scrypt("secret", **@defaults, N: 2)
+ key.should == "\x06A$a\xA9!\xBE\x01\x85\xA7\x18\xBCEa\x82\xC5\xFEl\x93\xAB\xBD\xF7\x8B\x84\v\xFC\eN\xEBQ\xE6\xD2".b
+
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, N: 1)
+ }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/)
+
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, N: 0)
+ }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/)
+
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, N: -1)
+ }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/)
+ end
+
+ it "requires r to be positive" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, r: 0)
+ }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/)
+
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, r: -1)
+ }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/)
+ end
+
+ it "requires p to be positive" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, p: 0)
+ }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/)
+
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, p: -1)
+ }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/)
+ end
+
+ it "requires length to be not negative" do
+ -> {
+ OpenSSL::KDF.scrypt("secret", **@defaults, length: -1)
+ }.should raise_error(ArgumentError, "negative string size (or size too big)")
+ end
+ end
+end
diff --git a/spec/ruby/library/openssl/random/shared/random_bytes.rb b/spec/ruby/library/openssl/random/shared/random_bytes.rb
index 037f10d409..f97ccd9974 100644
--- a/spec/ruby/library/openssl/random/shared/random_bytes.rb
+++ b/spec/ruby/library/openssl/random/shared/random_bytes.rb
@@ -1,7 +1,7 @@
require_relative '../../../../spec_helper'
require 'openssl'
-describe :openssl_random_bytes, shared: true do |cmd|
+describe :openssl_random_bytes, shared: true do
it "generates a random binary string of specified length" do
(1..64).each do |idx|
bytes = OpenSSL::Random.send(@method, idx)
diff --git a/spec/ruby/library/openssl/secure_compare_spec.rb b/spec/ruby/library/openssl/secure_compare_spec.rb
new file mode 100644
index 0000000000..cec48e01e7
--- /dev/null
+++ b/spec/ruby/library/openssl/secure_compare_spec.rb
@@ -0,0 +1,38 @@
+require_relative '../../spec_helper'
+require 'openssl'
+
+describe "OpenSSL.secure_compare" do
+ it "returns true for two strings with the same content" do
+ input1 = "the quick brown fox jumps over the lazy dog"
+ input2 = "the quick brown fox jumps over the lazy dog"
+ OpenSSL.secure_compare(input1, input2).should be_true
+ end
+
+ it "returns false for two strings with different content" do
+ input1 = "the quick brown fox jumps over the lazy dog"
+ input2 = "the lazy dog jumps over the quick brown fox"
+ OpenSSL.secure_compare(input1, input2).should be_false
+ end
+
+ it "converts both arguments to strings using #to_str, but adds equality check for the original objects" do
+ input1 = mock("input1")
+ input1.should_receive(:to_str).and_return("the quick brown fox jumps over the lazy dog")
+ input2 = mock("input2")
+ input2.should_receive(:to_str).and_return("the quick brown fox jumps over the lazy dog")
+ OpenSSL.secure_compare(input1, input2).should be_false
+
+ input = mock("input")
+ input.should_receive(:to_str).twice.and_return("the quick brown fox jumps over the lazy dog")
+ OpenSSL.secure_compare(input, input).should be_true
+ end
+
+ it "does not accept arguments that are not string and cannot be coerced into strings" do
+ -> {
+ OpenSSL.secure_compare("input1", :input2)
+ }.should raise_error(TypeError, 'no implicit conversion of Symbol into String')
+
+ -> {
+ OpenSSL.secure_compare(Object.new, "input2")
+ }.should raise_error(TypeError, 'no implicit conversion of Object into String')
+ end
+end
diff --git a/spec/ruby/library/openssl/x509/store/verify_spec.rb b/spec/ruby/library/openssl/x509/store/verify_spec.rb
new file mode 100644
index 0000000000..6a6a53d992
--- /dev/null
+++ b/spec/ruby/library/openssl/x509/store/verify_spec.rb
@@ -0,0 +1,78 @@
+require_relative '../../../../spec_helper'
+require 'openssl'
+
+describe "OpenSSL::X509::Store#verify" do
+ it "returns true for valid certificate" do
+ key = OpenSSL::PKey::RSA.new 2048
+ cert = OpenSSL::X509::Certificate.new
+ cert.version = 2
+ cert.serial = 1
+ cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=truffleruby/CN=TruffleRuby CA"
+ cert.issuer = cert.subject
+ cert.public_key = key.public_key
+ cert.not_before = Time.now - 10
+ cert.not_after = cert.not_before + 365 * 24 * 60 * 60
+ cert.sign key, OpenSSL::Digest.new('SHA256')
+ store = OpenSSL::X509::Store.new
+ store.add_cert(cert)
+ [store.verify(cert), store.error, store.error_string].should == [true, 0, "ok"]
+ end
+
+ it "returns false for an expired certificate" do
+ key = OpenSSL::PKey::RSA.new 2048
+ cert = OpenSSL::X509::Certificate.new
+ cert.version = 2
+ cert.serial = 1
+ cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=truffleruby/CN=TruffleRuby CA"
+ cert.issuer = cert.subject
+ cert.public_key = key.public_key
+ cert.not_before = Time.now - 10
+ cert.not_after = Time.now - 5
+ cert.sign key, OpenSSL::Digest.new('SHA256')
+ store = OpenSSL::X509::Store.new
+ store.add_cert(cert)
+ store.verify(cert).should == false
+ end
+
+ it "returns false for an expired root certificate" do
+ root_key = OpenSSL::PKey::RSA.new 2048
+ root_cert = OpenSSL::X509::Certificate.new
+ root_cert.version = 2
+ root_cert.serial = 1
+ root_cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=truffleruby/CN=TruffleRuby CA"
+ root_cert.issuer = root_cert.subject
+ root_cert.public_key = root_key.public_key
+ root_cert.not_before = Time.now - 10
+ root_cert.not_after = Time.now - 5
+ ef = OpenSSL::X509::ExtensionFactory.new
+ ef.subject_certificate = root_cert
+ ef.issuer_certificate = root_cert
+ root_cert.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true))
+ root_cert.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true))
+ root_cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
+ root_cert.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false))
+ root_cert.sign(root_key, OpenSSL::Digest.new('SHA256'))
+
+
+ key = OpenSSL::PKey::RSA.new 2048
+ cert = OpenSSL::X509::Certificate.new
+ cert.version = 2
+ cert.serial = 2
+ cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=truffleruby/CN=TruffleRuby certificate"
+ cert.issuer = root_cert.subject
+ cert.public_key = key.public_key
+ cert.not_before = Time.now
+ cert.not_after = cert.not_before + 1 * 365 * 24 * 60 * 60
+ ef = OpenSSL::X509::ExtensionFactory.new
+ ef.subject_certificate = cert
+ ef.issuer_certificate = root_cert
+ cert.add_extension(ef.create_extension("keyUsage","digitalSignature", true))
+ cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
+ cert.sign(root_key, OpenSSL::Digest.new('SHA256'))
+
+ store = OpenSSL::X509::Store.new
+ store.add_cert(root_cert)
+ store.add_cert(cert)
+ store.verify(cert).should == false
+ end
+end
diff --git a/spec/ruby/library/openstruct/method_missing_spec.rb b/spec/ruby/library/openstruct/method_missing_spec.rb
index 212db015a9..89f83d07b3 100644
--- a/spec/ruby/library/openstruct/method_missing_spec.rb
+++ b/spec/ruby/library/openstruct/method_missing_spec.rb
@@ -17,10 +17,8 @@ describe "OpenStruct#method_missing when passed additional arguments" do
-> { os.test(1, 2, 3) }.should raise_error(NoMethodError)
end
- ruby_version_is "2.7" do
- it "raises an ArgumentError when the key exists" do
- os = OpenStruct.new(test: 20)
- -> { os.test(1, 2, 3) }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError when the key exists" do
+ os = OpenStruct.new(test: 20)
+ -> { os.test(1, 2, 3) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/openstruct/to_h_spec.rb b/spec/ruby/library/openstruct/to_h_spec.rb
index ebdec16174..6c272bcc71 100644
--- a/spec/ruby/library/openstruct/to_h_spec.rb
+++ b/spec/ruby/library/openstruct/to_h_spec.rb
@@ -27,44 +27,42 @@ describe "OpenStruct#to_h" do
@os.age.should == 70
end
- ruby_version_is "2.6" do
- context "with block" do
- it "converts [key, value] pairs returned by the block to a hash" do
- h = @os.to_h { |k, v| [k.to_s, v*2] }
- h.should == { "name" => "John SmithJohn Smith", "age" => 140, "pension" => 600 }
- end
+ context "with block" do
+ it "converts [key, value] pairs returned by the block to a hash" do
+ h = @os.to_h { |k, v| [k.to_s, v*2] }
+ h.should == { "name" => "John SmithJohn Smith", "age" => 140, "pension" => 600 }
+ end
- it "raises ArgumentError if block returns longer or shorter array" do
- -> do
- @os.to_h { |k, v| [k.to_s, v*2, 1] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
+ it "raises ArgumentError if block returns longer or shorter array" do
+ -> do
+ @os.to_h { |k, v| [k.to_s, v*2, 1] }
+ end.should raise_error(ArgumentError, /element has wrong array length/)
- -> do
- @os.to_h { |k, v| [k] }
- end.should raise_error(ArgumentError, /element has wrong array length/)
- end
+ -> do
+ @os.to_h { |k, v| [k] }
+ end.should raise_error(ArgumentError, /element has wrong array length/)
+ end
- it "raises TypeError if block returns something other than Array" do
- -> do
- @os.to_h { |k, v| "not-array" }
- end.should raise_error(TypeError, /wrong element type String/)
- end
+ it "raises TypeError if block returns something other than Array" do
+ -> do
+ @os.to_h { |k, v| "not-array" }
+ end.should raise_error(TypeError, /wrong element type String/)
+ end
- it "coerces returned pair to Array with #to_ary" do
- x = mock('x')
- x.stub!(:to_ary).and_return([:b, 'b'])
+ it "coerces returned pair to Array with #to_ary" do
+ x = mock('x')
+ x.stub!(:to_ary).and_return([:b, 'b'])
- @os.to_h { |k| x }.should == { :b => 'b' }
- end
+ @os.to_h { |k| x }.should == { :b => 'b' }
+ end
- it "does not coerce returned pair to Array with #to_a" do
- x = mock('x')
- x.stub!(:to_a).and_return([:b, 'b'])
+ it "does not coerce returned pair to Array with #to_a" do
+ x = mock('x')
+ x.stub!(:to_a).and_return([:b, 'b'])
- -> do
- @os.to_h { |k| x }
- end.should raise_error(TypeError, /wrong element type MockObject/)
- end
+ -> do
+ @os.to_h { |k| x }
+ end.should raise_error(TypeError, /wrong element type MockObject/)
end
end
end
diff --git a/spec/ruby/library/pathname/birthtime_spec.rb b/spec/ruby/library/pathname/birthtime_spec.rb
new file mode 100644
index 0000000000..109c112303
--- /dev/null
+++ b/spec/ruby/library/pathname/birthtime_spec.rb
@@ -0,0 +1,16 @@
+require_relative '../../spec_helper'
+require 'pathname'
+
+describe "Pathname#birthtime" do
+ platform_is :windows, :darwin, :freebsd, :netbsd do
+ it "returns the birth time for self" do
+ Pathname.new(__FILE__).birthtime.should be_kind_of(Time)
+ end
+ end
+
+ platform_is :openbsd do
+ it "raises an NotImplementedError" do
+ -> { Pathname.new(__FILE__).birthtime }.should raise_error(NotImplementedError)
+ end
+ end
+end
diff --git a/spec/ruby/library/pathname/glob_spec.rb b/spec/ruby/library/pathname/glob_spec.rb
index f6dfd6cd58..ced810fa90 100644
--- a/spec/ruby/library/pathname/glob_spec.rb
+++ b/spec/ruby/library/pathname/glob_spec.rb
@@ -40,18 +40,45 @@ describe 'Pathname.glob' do
}.should raise_error(ArgumentError, /unknown keyword: :?foo/)
end
- ruby_version_is ''...'2.7' do
- it 'raises an ArgumentError when supplied a flag and :base keyword argument' do
- -> {
- Pathname.glob(@dir + 'lib/*i*.rb', File::FNM_DOTMATCH, base: 'lib')
- }.should raise_error(ArgumentError, 'wrong number of arguments (given 3, expected 1..2)')
- end
- end
-
- ruby_version_is "2.7" do
- it "does not raise an ArgumentError when supplied a flag and :base keyword argument" do
- expected = [Pathname.new('ipaddr.rb'), Pathname.new('irb.rb'), Pathname.new('.hidden.rb')].sort
- Pathname.glob('*i*.rb', File::FNM_DOTMATCH, base: @dir + 'lib').sort.should == expected
- end
+ it "does not raise an ArgumentError when supplied a flag and :base keyword argument" do
+ expected = [Pathname.new('ipaddr.rb'), Pathname.new('irb.rb'), Pathname.new('.hidden.rb')].sort
+ Pathname.glob('*i*.rb', File::FNM_DOTMATCH, base: @dir + 'lib').sort.should == expected
+ end
+end
+
+
+describe 'Pathname#glob' do
+ before :all do
+ @dir = tmp('pathname_glob') + '/'
+ @file_1 = @dir + 'lib/ipaddr.rb'
+ @file_2 = @dir + 'lib/irb.rb'
+ @file_3 = @dir + 'lib/.hidden.rb'
+
+ touch @file_1
+ touch @file_2
+ touch @file_3
+ end
+
+ after :all do
+ rm_r @dir[0...-1]
+ end
+
+ it 'returns [] for no match' do
+ Pathname.new(@dir).glob('lib/*.js').should == []
+ end
+
+ it 'returns matching file paths' do
+ Pathname.new(@dir).glob('lib/*i*.rb').sort.should == [Pathname.new(@file_1), Pathname.new(@file_2)].sort
+ end
+
+ it 'yields matching file paths to block' do
+ ary = []
+ Pathname.new(@dir).glob('lib/*i*.rb') { |p| ary << p }.should be_nil
+ ary.sort.should == [Pathname.new(@file_1), Pathname.new(@file_2)].sort
+ end
+
+ it 'returns matching file paths when a flag is provided' do
+ expected = [Pathname.new(@file_1), Pathname.new(@file_2), Pathname.new(@file_3)].sort
+ Pathname.new(@dir).glob('lib/*i*.rb', File::FNM_DOTMATCH).sort.should == expected
end
end
diff --git a/spec/ruby/library/pathname/new_spec.rb b/spec/ruby/library/pathname/new_spec.rb
index 760fd8638f..36226ed515 100644
--- a/spec/ruby/library/pathname/new_spec.rb
+++ b/spec/ruby/library/pathname/new_spec.rb
@@ -10,13 +10,6 @@ describe "Pathname.new" do
-> { Pathname.new("\0")}.should raise_error(ArgumentError)
end
- ruby_version_is ''...'2.7' do
- it "is tainted if path is tainted" do
- path = '/usr/local/bin'.taint
- Pathname.new(path).should.tainted?
- end
- end
-
it "raises a TypeError if not passed a String type" do
-> { Pathname.new(nil) }.should raise_error(TypeError)
-> { Pathname.new(0) }.should raise_error(TypeError)
diff --git a/spec/ruby/library/pathname/pathname_spec.rb b/spec/ruby/library/pathname/pathname_spec.rb
index 7d63fe86e3..0fb2881468 100644
--- a/spec/ruby/library/pathname/pathname_spec.rb
+++ b/spec/ruby/library/pathname/pathname_spec.rb
@@ -10,21 +10,10 @@ describe "Kernel#Pathname" do
Kernel.should have_method(:Pathname)
end
- ruby_version_is ''...'2.7' do
- it "returns a new pathname when called with a pathname argument" do
- path = Pathname('foo')
- new_path = Pathname(path)
+ it "returns same argument when called with a pathname argument" do
+ path = Pathname('foo')
+ new_path = Pathname(path)
- path.should_not.equal?(new_path)
- end
- end
-
- ruby_version_is '2.7' do
- it "returns same argument when called with a pathname argument" do
- path = Pathname('foo')
- new_path = Pathname(path)
-
- path.should.equal?(new_path)
- end
+ path.should.equal?(new_path)
end
end
diff --git a/spec/ruby/library/pathname/relative_path_from_spec.rb b/spec/ruby/library/pathname/relative_path_from_spec.rb
index abe9c80a45..133a149849 100644
--- a/spec/ruby/library/pathname/relative_path_from_spec.rb
+++ b/spec/ruby/library/pathname/relative_path_from_spec.rb
@@ -48,4 +48,8 @@ describe "Pathname#relative_path_from" do
relative_path_str('..', '..').should == '.'
relative_path_str('..', '.').should == '..'
end
+
+ it 'converts string argument to Pathname' do
+ Pathname.new('/usr/bin/ls').relative_path_from('/usr').to_s.should == 'bin/ls'
+ end
end
diff --git a/spec/ruby/library/pp/pp_spec.rb b/spec/ruby/library/pp/pp_spec.rb
index 06b22601d8..243478efd9 100644
--- a/spec/ruby/library/pp/pp_spec.rb
+++ b/spec/ruby/library/pp/pp_spec.rb
@@ -20,4 +20,11 @@ describe "PP.pp" do
other_out.to_s.should == "[1, 2, 3]\n"
end
+
+ it 'correctly prints a Hash' do
+ hash = { 'key' => 42 }
+ -> {
+ PP.pp hash
+ }.should output('{"key"=>42}' + "\n")
+ end
end
diff --git a/spec/ruby/library/rbconfig/rbconfig_spec.rb b/spec/ruby/library/rbconfig/rbconfig_spec.rb
index b3b8f32edb..b90cc90970 100644
--- a/spec/ruby/library/rbconfig/rbconfig_spec.rb
+++ b/spec/ruby/library/rbconfig/rbconfig_spec.rb
@@ -22,6 +22,12 @@ describe 'RbConfig::CONFIG' do
File.directory?(archdir).should == true
File.should.exist?("#{archdir}/etc.#{RbConfig::CONFIG['DLEXT']}")
end
+
+ it "['sitelibdir'] is set and is part of $LOAD_PATH" do
+ sitelibdir = RbConfig::CONFIG['sitelibdir']
+ sitelibdir.should be_kind_of String
+ $LOAD_PATH.map{|path| File.realpath(path) rescue path }.should.include? sitelibdir
+ end
end
it "contains no frozen strings even with --enable-frozen-string-literal" do
@@ -36,7 +42,18 @@ describe 'RbConfig::CONFIG' do
RUBY
end
- guard -> {RbConfig::TOPDIR} do
+ platform_is_not :windows do
+ it "['LIBRUBY'] is the same as LIBRUBY_SO if and only if ENABLE_SHARED" do
+ case RbConfig::CONFIG['ENABLE_SHARED']
+ when 'yes'
+ RbConfig::CONFIG['LIBRUBY'].should == RbConfig::CONFIG['LIBRUBY_SO']
+ when 'no'
+ RbConfig::CONFIG['LIBRUBY'].should_not == RbConfig::CONFIG['LIBRUBY_SO']
+ end
+ end
+ end
+
+ guard -> { RbConfig::TOPDIR } do
it "libdir/LIBRUBY_SO is the path to libruby and it exists if and only if ENABLE_SHARED" do
libdirname = RbConfig::CONFIG['LIBPATHENV'] == 'PATH' ? 'bindir' :
RbConfig::CONFIG['libdirname']
diff --git a/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb b/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb
index d3df8b7313..3dc9900127 100644
--- a/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb
+++ b/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb
@@ -2,21 +2,22 @@ require_relative '../../spec_helper'
require 'rbconfig'
describe "RbConfig::CONFIG['UNICODE_EMOJI_VERSION']" do
- ruby_version_is "2.6"..."2.6.2" do
- it "is 11.0 for Ruby 2.6.0 and 2.6.1" do
- RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "11.0"
+ ruby_version_is ""..."3.1" do
+ it "is 12.1" do
+ RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "12.1"
end
end
- ruby_version_is "2.6.2"..."2.7" do
- it "is 12.0 for Ruby 2.6.2+" do
- RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "12.0"
+ ruby_version_is "3.1"..."3.2" do
+ it "is 13.1" do
+ RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "13.1"
end
end
- ruby_version_is "2.7" do
- it "is 12.1 for Ruby 2.7" do
- RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "12.1"
+ # Caution: ruby_version_is means is_or_later
+ ruby_version_is "3.2" do
+ it "is 15.0" do
+ RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "15.0"
end
end
end
diff --git a/spec/ruby/library/rbconfig/unicode_version_spec.rb b/spec/ruby/library/rbconfig/unicode_version_spec.rb
index 65bd70c242..458f13bf03 100644
--- a/spec/ruby/library/rbconfig/unicode_version_spec.rb
+++ b/spec/ruby/library/rbconfig/unicode_version_spec.rb
@@ -2,27 +2,22 @@ require_relative '../../spec_helper'
require 'rbconfig'
describe "RbConfig::CONFIG['UNICODE_VERSION']" do
- ruby_version_is "2.5"..."2.6" do
- it "is 10.0.0 for Ruby 2.5" do
- RbConfig::CONFIG['UNICODE_VERSION'].should == "10.0.0"
- end
- end
-
- ruby_version_is "2.6"..."2.6.2" do
- it "is 11.0.0 for Ruby 2.6.0 and 2.6.1" do
- RbConfig::CONFIG['UNICODE_VERSION'].should == "11.0.0"
+ ruby_version_is ""..."3.1" do
+ it "is 12.1.0" do
+ RbConfig::CONFIG['UNICODE_VERSION'].should == "12.1.0"
end
end
- ruby_version_is "2.6.2"..."2.6.3" do
- it "is 12.0.0 for Ruby 2.6.2" do
- RbConfig::CONFIG['UNICODE_VERSION'].should == "12.0.0"
+ ruby_version_is "3.1"..."3.2" do
+ it "is 13.0.0" do
+ RbConfig::CONFIG['UNICODE_VERSION'].should == "13.0.0"
end
end
- ruby_version_is "2.6.3" do
- it "is 12.1.0 for Ruby 2.6.3+ and Ruby 2.7" do
- RbConfig::CONFIG['UNICODE_VERSION'].should == "12.1.0"
+ # Caution: ruby_version_is means is_or_later
+ ruby_version_is "3.2" do
+ it "is 15.0.0" do
+ RbConfig::CONFIG['UNICODE_VERSION'].should == "15.0.0"
end
end
end
diff --git a/spec/ruby/library/readline/history/delete_at_spec.rb b/spec/ruby/library/readline/history/delete_at_spec.rb
index c95a6a865e..3bd577e75c 100644
--- a/spec/ruby/library/readline/history/delete_at_spec.rb
+++ b/spec/ruby/library/readline/history/delete_at_spec.rb
@@ -34,14 +34,5 @@ with_feature :readline do
-> { Readline::HISTORY.delete_at(10) }.should raise_error(IndexError)
-> { Readline::HISTORY.delete_at(-10) }.should raise_error(IndexError)
end
-
- ruby_version_is ''...'2.7' do
- it "taints the returned strings" do
- Readline::HISTORY.push("1", "2", "3")
- Readline::HISTORY.delete_at(0).tainted?.should be_true
- Readline::HISTORY.delete_at(0).tainted?.should be_true
- Readline::HISTORY.delete_at(0).tainted?.should be_true
- end
- end
end
end
diff --git a/spec/ruby/library/readline/history/each_spec.rb b/spec/ruby/library/readline/history/each_spec.rb
index 23387bfc98..aa48dd46df 100644
--- a/spec/ruby/library/readline/history/each_spec.rb
+++ b/spec/ruby/library/readline/history/each_spec.rb
@@ -19,13 +19,5 @@ with_feature :readline do
end
result.should == ["1", "2", "3"]
end
-
- ruby_version_is ''...'2.7' do
- it "yields tainted Objects" do
- Readline::HISTORY.each do |x|
- x.tainted?.should be_true
- end
- end
- end
end
end
diff --git a/spec/ruby/library/readline/history/element_reference_spec.rb b/spec/ruby/library/readline/history/element_reference_spec.rb
index dfa5367cad..0a74f3d62d 100644
--- a/spec/ruby/library/readline/history/element_reference_spec.rb
+++ b/spec/ruby/library/readline/history/element_reference_spec.rb
@@ -12,13 +12,6 @@ with_feature :readline do
Readline::HISTORY.pop
end
- ruby_version_is ''...'2.7' do
- it "returns tainted objects" do
- Readline::HISTORY[0].tainted?.should be_true
- Readline::HISTORY[1].tainted?.should be_true
- end
- end
-
it "returns the history item at the passed index" do
Readline::HISTORY[0].should == "1"
Readline::HISTORY[1].should == "2"
diff --git a/spec/ruby/library/readline/history/pop_spec.rb b/spec/ruby/library/readline/history/pop_spec.rb
index e17be666d8..156a8a06f8 100644
--- a/spec/ruby/library/readline/history/pop_spec.rb
+++ b/spec/ruby/library/readline/history/pop_spec.rb
@@ -19,14 +19,5 @@ with_feature :readline do
Readline::HISTORY.pop.should == "1"
Readline::HISTORY.size.should == 0
end
-
- ruby_version_is ''...'2.7' do
- it "taints the returned strings" do
- Readline::HISTORY.push("1", "2", "3")
- Readline::HISTORY.pop.tainted?.should be_true
- Readline::HISTORY.pop.tainted?.should be_true
- Readline::HISTORY.pop.tainted?.should be_true
- end
- end
end
end
diff --git a/spec/ruby/library/readline/history/shift_spec.rb b/spec/ruby/library/readline/history/shift_spec.rb
index ccd90193fd..9aad7d5399 100644
--- a/spec/ruby/library/readline/history/shift_spec.rb
+++ b/spec/ruby/library/readline/history/shift_spec.rb
@@ -19,14 +19,5 @@ with_feature :readline do
Readline::HISTORY.shift.should == "3"
Readline::HISTORY.size.should == 0
end
-
- ruby_version_is ''...'2.7' do
- it "taints the returned strings" do
- Readline::HISTORY.push("1", "2", "3")
- Readline::HISTORY.shift.tainted?.should be_true
- Readline::HISTORY.shift.tainted?.should be_true
- Readline::HISTORY.shift.tainted?.should be_true
- end
- end
end
end
diff --git a/spec/ruby/library/readline/readline_spec.rb b/spec/ruby/library/readline/readline_spec.rb
index 24d2cbbe86..6e349ad543 100644
--- a/spec/ruby/library/readline/readline_spec.rb
+++ b/spec/ruby/library/readline/readline_spec.rb
@@ -21,13 +21,6 @@ with_feature :readline do
ruby_exe('File.write ARGV[0], Readline.readline', @options)
File.read(@out).should == "test"
end
-
- ruby_version_is ''...'2.7' do
- it "taints the returned strings" do
- ruby_exe('File.write ARGV[0], Readline.readline.tainted?', @options)
- File.read(@out).should == "true"
- end
- end
end
end
end
diff --git a/spec/ruby/library/rexml/attribute/clone_spec.rb b/spec/ruby/library/rexml/attribute/clone_spec.rb
deleted file mode 100644
index 5c86468d45..0000000000
--- a/spec/ruby/library/rexml/attribute/clone_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#clone" do
- it "returns a copy of this Attribute" do
- orig = REXML::Attribute.new("name", "value&&")
- orig.should == orig.clone
- orig.clone.to_s.should == orig.to_s
- orig.clone.to_string.should == orig.to_string
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/element_spec.rb b/spec/ruby/library/rexml/attribute/element_spec.rb
deleted file mode 100644
index 0e4ce46a4f..0000000000
--- a/spec/ruby/library/rexml/attribute/element_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#element" do
- it "returns the parent element" do
- e = REXML::Element.new "root"
-
- REXML::Attribute.new("name", "value", e).element.should == e
- REXML::Attribute.new("name", "default_constructor").element.should == nil
- end
- end
-
- describe "REXML::Attribute#element=" do
- it "sets the parent element" do
- e = REXML::Element.new "root"
- f = REXML::Element.new "temp"
- a = REXML::Attribute.new("name", "value", e)
- a.element.should == e
-
- a.element = f
- a.element.should == f
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/equal_value_spec.rb b/spec/ruby/library/rexml/attribute/equal_value_spec.rb
deleted file mode 100644
index 1498bae624..0000000000
--- a/spec/ruby/library/rexml/attribute/equal_value_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#==" do
- it "returns true if other has equal name and value" do
- a1 = REXML::Attribute.new("foo", "bar")
- a1.should == a1.clone
-
- a2 = REXML::Attribute.new("foo", "bar")
- a1.should == a2
-
- a3 = REXML::Attribute.new("foo", "bla")
- a1.should_not == a3
-
- a4 = REXML::Attribute.new("baz", "bar")
- a1.should_not == a4
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/hash_spec.rb b/spec/ruby/library/rexml/attribute/hash_spec.rb
deleted file mode 100644
index 7e0cbcc1ea..0000000000
--- a/spec/ruby/library/rexml/attribute/hash_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#hash" do
- # These are not really complete, any idea on how to make them more
- # "testable" will be appreciated.
- it "returns a hashcode made of the name and value of self" do
- a = REXML::Attribute.new("name", "value")
- a.hash.should be_kind_of(Numeric)
- b = REXML::Attribute.new(a)
- a.hash.should == b.hash
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/initialize_spec.rb b/spec/ruby/library/rexml/attribute/initialize_spec.rb
deleted file mode 100644
index 35b87b0733..0000000000
--- a/spec/ruby/library/rexml/attribute/initialize_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#initialize" do
- before :each do
- @e = REXML::Element.new "root"
- @name = REXML::Attribute.new("name", "Nicko")
- @e.add_attribute @name
- end
-
- it "receives two strings for name and value" do
- @e.attributes["name"].should == "Nicko"
- @e.add_attribute REXML::Attribute.new("last_name", nil)
- @e.attributes["last_name"].should == ""
- end
-
- it "receives an Attribute and clones it" do
- copy = REXML::Attribute.new(@name)
- copy.should == @name
- end
-
- it "receives a parent node" do
- last_name = REXML::Attribute.new("last_name", "McBrain", @e)
- last_name.element.should == @e
-
- last_name = REXML::Attribute.new(@name, @e)
- last_name.element.should == @e
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/inspect_spec.rb b/spec/ruby/library/rexml/attribute/inspect_spec.rb
deleted file mode 100644
index ee5236b98e..0000000000
--- a/spec/ruby/library/rexml/attribute/inspect_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#inspect" do
- it "returns the name and value as a string" do
- a = REXML::Attribute.new("my_name", "my_value")
- a.inspect.should == "my_name='my_value'"
- end
-
- it "accepts attributes with no value" do
- a = REXML::Attribute.new("my_name")
- a.inspect.should == "my_name=''"
- end
-
- it "does not escape text" do
- a = REXML::Attribute.new("name", "<>")
- a.inspect.should == "name='<>'"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/namespace_spec.rb b/spec/ruby/library/rexml/attribute/namespace_spec.rb
deleted file mode 100644
index 645b3cd1b1..0000000000
--- a/spec/ruby/library/rexml/attribute/namespace_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#namespace" do
- it "returns the namespace url" do
- e = REXML::Element.new("root")
- e.add_attribute REXML::Attribute.new("xmlns:ns", "http://some_uri")
- e.namespace("ns").should == "http://some_uri"
- end
-
- it "returns nil if namespace is not defined" do
- e = REXML::Element.new("root")
- e.add_attribute REXML::Attribute.new("test", "value")
- e.namespace("test").should == nil
- e.namespace("ns").should == nil
- end
-
- it "defaults arg to nil" do
- e = REXML::Element.new("root")
- e.add_attribute REXML::Attribute.new("xmlns:ns", "http://some_uri")
- e.namespace.should == ""
- e.namespace("ns").should == "http://some_uri"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/node_type_spec.rb b/spec/ruby/library/rexml/attribute/node_type_spec.rb
deleted file mode 100644
index da055ae8f0..0000000000
--- a/spec/ruby/library/rexml/attribute/node_type_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#node_type" do
- it "always returns :attribute" do
- attr = REXML::Attribute.new("foo", "bar")
- attr.node_type.should == :attribute
- REXML::Attribute.new(attr).node_type.should == :attribute
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/prefix_spec.rb b/spec/ruby/library/rexml/attribute/prefix_spec.rb
deleted file mode 100644
index 87bff4822b..0000000000
--- a/spec/ruby/library/rexml/attribute/prefix_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#prefix" do
- it "returns the namespace of the Attribute" do
- ans = REXML::Attribute.new("ns:someattr", "some_value")
- out = REXML::Attribute.new("out:something", "some_other_value")
-
- ans.prefix.should == "ns"
- out.prefix.should == "out"
- end
-
- it "returns an empty string for Attributes with no prefixes" do
- attr = REXML::Attribute.new("foo", "bar")
-
- attr.prefix.should == ""
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/remove_spec.rb b/spec/ruby/library/rexml/attribute/remove_spec.rb
deleted file mode 100644
index 5f928b1286..0000000000
--- a/spec/ruby/library/rexml/attribute/remove_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#remove" do
- before :each do
- @e = REXML::Element.new "Root"
- @attr = REXML::Attribute.new("foo", "bar")
- end
-
- it "deletes this Attribute from parent" do
- @e.add_attribute(@attr)
- @e.attributes["foo"].should_not == nil
- @attr.remove
- @e.attributes["foo"].should == nil
- end
-
- it "does not anything if element has no parent" do
- -> {@attr.remove}.should_not raise_error(Exception)
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/to_s_spec.rb b/spec/ruby/library/rexml/attribute/to_s_spec.rb
deleted file mode 100644
index e362cee8f1..0000000000
--- a/spec/ruby/library/rexml/attribute/to_s_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#to_s" do
- it "returns the value of the Attribute" do
- REXML::Attribute.new("name", "some_value").to_s.should == "some_value"
- end
-
- it "returns the escaped value if it was created from Attribute" do
- orig = REXML::Attribute.new("name", "<&>")
- copy = REXML::Attribute.new(orig)
- copy.to_s.should == "&lt;&amp;&gt;"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/to_string_spec.rb b/spec/ruby/library/rexml/attribute/to_string_spec.rb
deleted file mode 100644
index a9d249f5bb..0000000000
--- a/spec/ruby/library/rexml/attribute/to_string_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#to_string" do
- it "returns the attribute as XML" do
- attr = REXML::Attribute.new("name", "value")
- attr_empty = REXML::Attribute.new("name")
- attr_ns = REXML::Attribute.new("xmlns:ns", "http://uri")
-
- attr.to_string.should == "name='value'"
- attr_empty.to_string.should == "name=''"
- attr_ns.to_string.should == "xmlns:ns='http://uri'"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/value_spec.rb b/spec/ruby/library/rexml/attribute/value_spec.rb
deleted file mode 100644
index 77071f6f70..0000000000
--- a/spec/ruby/library/rexml/attribute/value_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#value" do
- it "returns the value of the Attribute unnormalized" do
- attr = REXML::Attribute.new("name", "value")
- attr_ents = REXML::Attribute.new("name", "<&>")
- attr_empty = REXML::Attribute.new("name")
-
- attr.value.should == "value"
- attr_ents.value.should == "<&>"
- attr_empty.value.should == ""
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/write_spec.rb b/spec/ruby/library/rexml/attribute/write_spec.rb
deleted file mode 100644
index 0012b3cc77..0000000000
--- a/spec/ruby/library/rexml/attribute/write_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#write" do
- before :each do
- @attr = REXML::Attribute.new("name", "Charlotte")
- @s = ""
- end
-
- it "writes the name and value to output" do
- @attr.write(@s)
- @s.should == "name='Charlotte'"
- end
-
- it "currently ignores the second argument" do
- @attr.write(@s, 3)
- @s.should == "name='Charlotte'"
-
- @s = ""
- @attr.write(@s, "foo")
- @s.should == "name='Charlotte'"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attribute/xpath_spec.rb b/spec/ruby/library/rexml/attribute/xpath_spec.rb
deleted file mode 100644
index 0a09046b01..0000000000
--- a/spec/ruby/library/rexml/attribute/xpath_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attribute#xpath" do
-
- before :each do
- @e = REXML::Element.new "root"
- @attr = REXML::Attribute.new("year", "1989")
- end
-
- it "returns the path for Attribute" do
- @e.add_attribute @attr
- @attr.xpath.should == "root/@year"
- end
-
- it "raises an error if attribute has no parent" do
- -> { @attr.xpath }.should raise_error(Exception)
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/add_spec.rb b/spec/ruby/library/rexml/attributes/add_spec.rb
deleted file mode 100644
index e24e9fabbc..0000000000
--- a/spec/ruby/library/rexml/attributes/add_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require_relative 'shared/add'
- require 'rexml/document'
-
- describe "REXML::Attributes#add" do
- it_behaves_like :rexml_attribute_add, :add
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/append_spec.rb b/spec/ruby/library/rexml/attributes/append_spec.rb
deleted file mode 100644
index f96a727f47..0000000000
--- a/spec/ruby/library/rexml/attributes/append_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require_relative 'shared/add'
- require 'rexml/document'
-
- describe "REXML::Attributes#<<" do
- it_behaves_like :rexml_attribute_add, :<<
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/delete_all_spec.rb b/spec/ruby/library/rexml/attributes/delete_all_spec.rb
deleted file mode 100644
index 707baa235b..0000000000
--- a/spec/ruby/library/rexml/attributes/delete_all_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#delete_all" do
- before :each do
- @e = REXML::Element.new("root")
- end
-
- it "deletes all attributes that match name" do
- uri = REXML::Attribute.new("uri", "http://something")
- @e.attributes << uri
- @e.attributes.delete_all("uri")
- @e.attributes.should be_empty
- @e.attributes["uri"].should == nil
- end
-
- it "deletes all attributes that match name with a namespace" do
- ns_uri = REXML::Attribute.new("xmlns:uri", "http://something_here_too")
- @e.attributes << ns_uri
- @e.attributes.delete_all("xmlns:uri")
- @e.attributes.should be_empty
- @e.attributes["xmlns:uri"].should == nil
- end
-
- it "returns the removed attribute" do
- uri = REXML::Attribute.new("uri", "http://something_here_too")
- @e.attributes << uri
- attrs = @e.attributes.delete_all("uri")
- attrs.first.should == uri
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/delete_spec.rb b/spec/ruby/library/rexml/attributes/delete_spec.rb
deleted file mode 100644
index 723fa70751..0000000000
--- a/spec/ruby/library/rexml/attributes/delete_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#delete" do
- before :each do
- @e = REXML::Element.new("root")
- @name = REXML::Attribute.new("name", "Pepe")
- end
-
- it "takes an attribute name and deletes the attribute" do
- @e.attributes.delete("name")
- @e.attributes["name"].should be_nil
- @e.attributes.should be_empty
- end
-
- it "takes an Attribute and deletes it" do
- @e.attributes.delete(@name)
- @e.attributes["name"].should be_nil
- @e.attributes.should be_empty
- end
-
- it "returns the element with the attribute removed" do
- ret_val = @e.attributes.delete(@name)
- ret_val.should == @e
- ret_val.attributes.should be_empty
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/each_attribute_spec.rb b/spec/ruby/library/rexml/attributes/each_attribute_spec.rb
deleted file mode 100644
index 692cf4f943..0000000000
--- a/spec/ruby/library/rexml/attributes/each_attribute_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#each_attribute" do
- it "iterates over the attributes yielding actual Attribute objects" do
- e = REXML::Element.new("root")
- name = REXML::Attribute.new("name", "Joe")
- ns_uri = REXML::Attribute.new("xmlns:ns", "http://some_uri")
- e.add_attribute name
- e.add_attribute ns_uri
-
- attributes = []
-
- e.attributes.each_attribute do |attr|
- attributes << attr
- end
-
- attributes = attributes.sort_by {|a| a.name }
- attributes.first.should == name
- attributes.last.should == ns_uri
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/each_spec.rb b/spec/ruby/library/rexml/attributes/each_spec.rb
deleted file mode 100644
index 49add3b77b..0000000000
--- a/spec/ruby/library/rexml/attributes/each_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#each" do
- before :each do
- @e = REXML::Element.new("root")
- @name = REXML::Attribute.new("name", "Joe")
- @ns_uri = REXML::Attribute.new("xmlns:ns", "http://some_uri")
- @e.add_attribute @name
- @e.add_attribute @ns_uri
- end
-
- it "iterates over the attributes yielding expanded-name/value" do
- attributes = []
- @e.attributes.each do |attr|
- attr.should be_kind_of(Array)
- attributes << attr
- end
- attributes = attributes.sort_by {|a| a.first }
- attributes.first.should == ["name", "Joe"]
- attributes.last.should == ["xmlns:ns", "http://some_uri"]
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/element_reference_spec.rb b/spec/ruby/library/rexml/attributes/element_reference_spec.rb
deleted file mode 100644
index 0d089eaab2..0000000000
--- a/spec/ruby/library/rexml/attributes/element_reference_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#[]" do
- before :each do
- @e = REXML::Element.new("root")
- @lang = REXML::Attribute.new("language", "english")
- @e.attributes << @lang
- end
-
- it "returns the value of an attribute" do
- @e.attributes["language"].should == "english"
- end
-
- it "returns nil if the attribute does not exist" do
- @e.attributes["chunky bacon"].should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/element_set_spec.rb b/spec/ruby/library/rexml/attributes/element_set_spec.rb
deleted file mode 100644
index 834ad682a6..0000000000
--- a/spec/ruby/library/rexml/attributes/element_set_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#[]=" do
- before :each do
- @e = REXML::Element.new("song")
- @name = REXML::Attribute.new("name", "Holy Smoke!")
- @e.attributes << @name
- end
-
- it "sets an attribute" do
- @e.attributes["author"] = "_why's foxes"
- @e.attributes["author"].should == "_why's foxes"
- end
-
- it "overwrites an existing attribute" do
- @e.attributes["name"] = "Chunky Bacon"
- @e.attributes["name"].should == "Chunky Bacon"
- end
-
- it "deletes an attribute is value is nil" do
- @e.attributes["name"] = nil
- @e.attributes.length.should == 0
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb b/spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb
deleted file mode 100644
index 1109ff519c..0000000000
--- a/spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#get_attribute_ns" do
- it "returns an attribute by name and namespace" do
- e = REXML::Element.new("root")
- attr = REXML::Attribute.new("xmlns:ns", "http://some_url")
- e.attributes << attr
- attr.prefix.should == "xmlns"
- # This might be a bug in Attribute, commenting until those specs
- # are ready
- # e.attributes.get_attribute_ns(attr.prefix, "name").should == "http://some_url"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/get_attribute_spec.rb b/spec/ruby/library/rexml/attributes/get_attribute_spec.rb
deleted file mode 100644
index cc94191729..0000000000
--- a/spec/ruby/library/rexml/attributes/get_attribute_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#get_attribute" do
- before :each do
- @e = REXML::Element.new("root")
- @name = REXML::Attribute.new("name", "Dave")
- @e.attributes << @name
- end
-
- it "fetches an attributes" do
- @e.attributes.get_attribute("name").should == @name
- end
-
- it "fetches an namespaced attribute" do
- ns_name = REXML::Attribute.new("im:name", "Murray")
- @e.attributes << ns_name
- @e.attributes.get_attribute("name").should == @name
- @e.attributes.get_attribute("im:name").should == ns_name
- end
-
- it "returns an Attribute" do
- @e.attributes.get_attribute("name").should be_kind_of(REXML::Attribute)
- end
-
- it "returns nil if it attribute does not exist" do
- @e.attributes.get_attribute("fake").should be_nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/initialize_spec.rb b/spec/ruby/library/rexml/attributes/initialize_spec.rb
deleted file mode 100644
index 42ec742e60..0000000000
--- a/spec/ruby/library/rexml/attributes/initialize_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#initialize" do
- it "is auto initialized by Element" do
- e = REXML::Element.new "root"
- e.attributes.should be_kind_of(REXML::Attributes)
-
- e.attributes << REXML::Attribute.new("name", "Paul")
- e.attributes["name"].should == "Paul"
- end
-
- it "receives a parent node" do
- e = REXML::Element.new "root"
- e.attributes << REXML::Attribute.new("name", "Vic")
- e.attributes["name"].should == "Vic"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/length_spec.rb b/spec/ruby/library/rexml/attributes/length_spec.rb
deleted file mode 100644
index 81733b4a96..0000000000
--- a/spec/ruby/library/rexml/attributes/length_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require_relative 'shared/length'
- require 'rexml/document'
-
- describe "REXML::Attributes#length" do
- it_behaves_like :rexml_attribute_length, :length
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/namespaces_spec.rb b/spec/ruby/library/rexml/attributes/namespaces_spec.rb
deleted file mode 100644
index b88346854f..0000000000
--- a/spec/ruby/library/rexml/attributes/namespaces_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#namespaces" do
- it "needs to be reviewed for spec completeness"
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/prefixes_spec.rb b/spec/ruby/library/rexml/attributes/prefixes_spec.rb
deleted file mode 100644
index 574b7ffbaf..0000000000
--- a/spec/ruby/library/rexml/attributes/prefixes_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#prefixes" do
- before :each do
- @e = REXML::Element.new("root")
- a1 = REXML::Attribute.new("xmlns:a", "bar")
- a2 = REXML::Attribute.new("xmlns:b", "bla")
- a3 = REXML::Attribute.new("xmlns:c", "baz")
- @e.attributes << a1
- @e.attributes << a2
- @e.attributes << a3
-
- @e.attributes << REXML::Attribute.new("xmlns", "foo")
- end
-
- it "returns an array with the prefixes of each attribute" do
- @e.attributes.prefixes.sort.should == ["a", "b", "c"]
- end
-
- it "does not include the default namespace" do
- @e.attributes.prefixes.include?("xmlns").should == false
- end
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/shared/add.rb b/spec/ruby/library/rexml/attributes/shared/add.rb
deleted file mode 100644
index 872f149f45..0000000000
--- a/spec/ruby/library/rexml/attributes/shared/add.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-describe :rexml_attribute_add, shared: true do
- before :each do
- @e = REXML::Element.new("root")
- @attr = REXML::Attributes.new(@e)
- @name = REXML::Attribute.new("name", "Joe")
- end
-
- it "adds an attribute" do
- @attr.send(@method, @name)
- @attr["name"].should == "Joe"
- end
-
- it "replaces an existing attribute" do
- @attr.send(@method, REXML::Attribute.new("name", "Bruce"))
- @attr["name"].should == "Bruce"
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/shared/length.rb b/spec/ruby/library/rexml/attributes/shared/length.rb
deleted file mode 100644
index 7848f9bf33..0000000000
--- a/spec/ruby/library/rexml/attributes/shared/length.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../../../spec_helper'
-require 'rexml/document'
-
-describe :rexml_attribute_length, shared: true do
- it "returns the number of attributes" do
- e = REXML::Element.new("root")
- e.attributes.send(@method).should == 0
-
- e.attributes << REXML::Attribute.new("name", "John")
- e.attributes << REXML::Attribute.new("another_name", "Leo")
- e.attributes.send(@method).should == 2
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/size_spec.rb b/spec/ruby/library/rexml/attributes/size_spec.rb
deleted file mode 100644
index 13ef08f644..0000000000
--- a/spec/ruby/library/rexml/attributes/size_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require_relative 'shared/length'
- require 'rexml/document'
-
- describe "REXML::Attributes#size" do
- it_behaves_like :rexml_attribute_length, :size
- end
-end
diff --git a/spec/ruby/library/rexml/attributes/to_a_spec.rb b/spec/ruby/library/rexml/attributes/to_a_spec.rb
deleted file mode 100644
index 902cd86a29..0000000000
--- a/spec/ruby/library/rexml/attributes/to_a_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Attributes#to_a" do
- it "returns an array with the attributes" do
- e = REXML::Element.new("root")
- name = REXML::Attribute.new("name", "Dave")
- last = REXML::Attribute.new("last_name", "Murray")
-
- e.attributes << name
- e.attributes << last
-
- e.attributes.to_a.sort{|a,b|a.to_s<=>b.to_s}.should == [name, last]
- end
-
- it "returns an empty array if it has no attributes" do
- REXML::Element.new("root").attributes.to_a.should == []
- end
- end
-end
diff --git a/spec/ruby/library/rexml/cdata/clone_spec.rb b/spec/ruby/library/rexml/cdata/clone_spec.rb
deleted file mode 100644
index abe1a0b062..0000000000
--- a/spec/ruby/library/rexml/cdata/clone_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::CData#clone" do
- it "makes a copy of itself" do
- c = REXML::CData.new("some text")
- c.clone.to_s.should == c.to_s
- c.clone.should == c
- end
- end
-end
diff --git a/spec/ruby/library/rexml/cdata/initialize_spec.rb b/spec/ruby/library/rexml/cdata/initialize_spec.rb
deleted file mode 100644
index 1393d97f4a..0000000000
--- a/spec/ruby/library/rexml/cdata/initialize_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::CData#initialize" do
- it "creates a new CData object" do
- c = REXML::CData.new("some text")
- c.should be_kind_of(REXML::CData)
- c.should be_kind_of(REXML::Text)
- end
-
- it "respects whitespace if whitespace is true" do
- c = REXML::CData.new("whitespace test", true)
- c1 = REXML::CData.new("whitespace test", false)
-
- c.to_s.should == "whitespace test"
- c1.to_s.should == "whitespace test"
- end
-
- it "receives parent as third argument" do
- e = REXML::Element.new("root")
- REXML::CData.new("test", true, e)
- e.to_s.should == "<root><![CDATA[test]]></root>"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/cdata/shared/to_s.rb b/spec/ruby/library/rexml/cdata/shared/to_s.rb
deleted file mode 100644
index f8c4951c95..0000000000
--- a/spec/ruby/library/rexml/cdata/shared/to_s.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-describe :rexml_cdata_to_s, shared: true do
- it "returns the contents of the CData" do
- c = REXML::CData.new("some text")
- c.send(@method).should == "some text"
- end
-
- it "does not escape text" do
- c1 = REXML::CData.new("some& text\n")
- c1.send(@method).should == "some& text\n"
- end
-end
diff --git a/spec/ruby/library/rexml/cdata/to_s_spec.rb b/spec/ruby/library/rexml/cdata/to_s_spec.rb
deleted file mode 100644
index a5c061f116..0000000000
--- a/spec/ruby/library/rexml/cdata/to_s_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require_relative 'shared/to_s'
- require 'rexml/document'
-
- describe "REXML::CData#to_s" do
- it_behaves_like :rexml_cdata_to_s, :to_s
- end
-end
diff --git a/spec/ruby/library/rexml/cdata/value_spec.rb b/spec/ruby/library/rexml/cdata/value_spec.rb
deleted file mode 100644
index 9f36226976..0000000000
--- a/spec/ruby/library/rexml/cdata/value_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require_relative 'shared/to_s'
- require 'rexml/document'
-
- describe "REXML::CData#value" do
- it_behaves_like :rexml_cdata_to_s, :value
- end
-end
diff --git a/spec/ruby/library/rexml/document/add_element_spec.rb b/spec/ruby/library/rexml/document/add_element_spec.rb
deleted file mode 100644
index 29dec0b24e..0000000000
--- a/spec/ruby/library/rexml/document/add_element_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Document#add_element" do
- it "adds arg1 with attributes arg2 as root node" do
- d = REXML::Document.new
- e = REXML::Element.new("root")
- d.add_element e
- d.root.should == e
- end
-
- it "sets arg2 as arg1's attributes" do
- d = REXML::Document.new
- e = REXML::Element.new("root")
- attr = {"foo" => "bar"}
- d.add_element(e,attr)
- d.root.attributes["foo"].should == attr["foo"]
- end
-
- it "accepts a node name as arg1 and adds it as root" do
- d = REXML::Document.new
- d.add_element "foo"
- d.root.name.should == "foo"
- end
-
- it "sets arg1's context to the root's context" do
- d = REXML::Document.new("", {"foo" => "bar"})
- d.add_element "foo"
- d.root.context.should == d.context
- end
- end
-end
diff --git a/spec/ruby/library/rexml/document/add_spec.rb b/spec/ruby/library/rexml/document/add_spec.rb
deleted file mode 100644
index 8666d3dbf9..0000000000
--- a/spec/ruby/library/rexml/document/add_spec.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- # This spec defines Document#add and Document#<<
-
- describe :rexml_document_add, shared: true do
- before :each do
- @doc = REXML::Document.new("<root/>")
- @decl = REXML::XMLDecl.new("1.0")
- end
-
- it "sets document's XML declaration" do
- @doc.send(@method, @decl)
- @doc.xml_decl.should == @decl
- end
-
- it "inserts XML declaration as first node" do
- @doc.send(@method, @decl)
- @doc.children[0].version.should == "1.0"
- end
-
- it "overwrites existing XML declaration" do
- @doc.send(@method, @decl)
- @doc.send(@method, REXML::XMLDecl.new("2.0"))
- @doc.xml_decl.version.should == "2.0"
- end
-
- it "sets document DocType" do
- @doc.send(@method, REXML::DocType.new("transitional"))
- @doc.doctype.name.should == "transitional"
- end
-
- it "overwrites existing DocType" do
- @doc.send(@method, REXML::DocType.new("transitional"))
- @doc.send(@method, REXML::DocType.new("strict"))
- @doc.doctype.name.should == "strict"
- end
-
- it "adds root node unless it exists" do
- d = REXML::Document.new("")
- elem = REXML::Element.new "root"
- d.send(@method, elem)
- d.root.should == elem
- end
-
- it "refuses to add second root" do
- -> { @doc.send(@method, REXML::Element.new("foo")) }.should raise_error(RuntimeError)
- end
- end
-
- describe "REXML::Document#add" do
- it_behaves_like :rexml_document_add, :add
- end
-
- describe "REXML::Document#<<" do
- it_behaves_like :rexml_document_add, :<<
- end
-end
diff --git a/spec/ruby/library/rexml/document/clone_spec.rb b/spec/ruby/library/rexml/document/clone_spec.rb
deleted file mode 100644
index 137fe8a073..0000000000
--- a/spec/ruby/library/rexml/document/clone_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- # According to the MRI documentation (http://www.ruby-doc.org/stdlib/libdoc/rexml/rdoc/index.html),
- # clone's behavior "should be obvious". Apparently "obvious" means cloning
- # only the attributes and the context of the document, not its children.
- describe "REXML::Document#clone" do
- it "clones document attributes" do
- d = REXML::Document.new("foo")
- d.attributes["foo"] = "bar"
- e = d.clone
- e.attributes.should == d.attributes
- end
-
- it "clones document context" do
- d = REXML::Document.new("foo", {"foo" => "bar"})
- e = d.clone
- e.context.should == d.context
- end
- end
-end
diff --git a/spec/ruby/library/rexml/document/doctype_spec.rb b/spec/ruby/library/rexml/document/doctype_spec.rb
deleted file mode 100644
index e1b7ba4916..0000000000
--- a/spec/ruby/library/rexml/document/doctype_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Document#doctype" do
- it "returns the doctype" do
- d = REXML::Document.new
- dt = REXML::DocType.new("foo")
- d.add dt
- d.doctype.should == dt
- end
-
- it "returns nil if there's no doctype" do
- REXML::Document.new.doctype.should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/document/encoding_spec.rb b/spec/ruby/library/rexml/document/encoding_spec.rb
deleted file mode 100644
index 2cc947f06a..0000000000
--- a/spec/ruby/library/rexml/document/encoding_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Document#encoding" do
- before :each do
- @doc = REXML::Document.new
- end
-
- it "returns encoding from XML declaration" do
- @doc.add REXML::XMLDecl.new(nil, "UTF-16", nil)
- @doc.encoding.should == "UTF-16"
- end
-
- it "returns encoding from XML declaration (for UTF-16 as well)" do
- @doc.add REXML::XMLDecl.new("1.0", "UTF-8", nil)
- @doc.encoding.should == "UTF-8"
- end
-
- it "uses UTF-8 as default encoding" do
- @doc.encoding.should == "UTF-8"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/document/expanded_name_spec.rb b/spec/ruby/library/rexml/document/expanded_name_spec.rb
deleted file mode 100644
index 9d1025b5e0..0000000000
--- a/spec/ruby/library/rexml/document/expanded_name_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe :document_expanded_name, shared: true do
- it "returns an empty string for root" do # root nodes have no expanded name
- REXML::Document.new.send(@method).should == ""
- end
- end
-
- describe "REXML::Document#expanded_name" do
- it_behaves_like :document_expanded_name, :expanded_name
- end
-
- describe "REXML::Document#name" do
- it_behaves_like :document_expanded_name, :name
- end
-end
diff --git a/spec/ruby/library/rexml/document/new_spec.rb b/spec/ruby/library/rexml/document/new_spec.rb
deleted file mode 100644
index 4e24b6f5a1..0000000000
--- a/spec/ruby/library/rexml/document/new_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Document#new" do
-
- it "initializes context of {} unless specified" do
- d = REXML::Document.new("<foo />")
- d.context.should == {}
- end
-
- it "has empty attributes if source is nil" do
- d = REXML::Document.new(nil)
- d.elements.should be_empty
- end
-
- it "can use other document context" do
- s = REXML::Document.new("")
- d = REXML::Document.new(s)
- d.context.should == s.context
- end
-
- it "clones source attributes" do
- s = REXML::Document.new("<root />")
- s.attributes["some_attr"] = "some_val"
- d = REXML::Document.new(s)
- d.attributes.should == s.attributes
- end
-
- it "raises an error if source is not a Document, String or IO" do
- -> {REXML::Document.new(3)}.should raise_error(RuntimeError)
- end
-
- it "does not perform XML validation" do
- REXML::Document.new("Invalid document").should be_kind_of(REXML::Document)
- end
- end
-end
diff --git a/spec/ruby/library/rexml/document/node_type_spec.rb b/spec/ruby/library/rexml/document/node_type_spec.rb
deleted file mode 100644
index b6d7e7a7da..0000000000
--- a/spec/ruby/library/rexml/document/node_type_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Document#node_type" do
- it "returns :document" do
- REXML::Document.new.node_type.should == :document
- end
- end
-end
diff --git a/spec/ruby/library/rexml/document/root_spec.rb b/spec/ruby/library/rexml/document/root_spec.rb
deleted file mode 100644
index 1a584a720b..0000000000
--- a/spec/ruby/library/rexml/document/root_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Document#root" do
- it "returns document root tag name" do
- REXML::Document.new("<foo/>").root.name.should == "foo"
- end
-
- it "returns nil if there is not root" do
- REXML::Document.new.root.should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/document/stand_alone_spec.rb b/spec/ruby/library/rexml/document/stand_alone_spec.rb
deleted file mode 100644
index e1c721e782..0000000000
--- a/spec/ruby/library/rexml/document/stand_alone_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Document#stand_alone?" do
- it "returns the XMLDecl standalone value" do
- d = REXML::Document.new
- decl = REXML::XMLDecl.new("1.0", "UTF-8", "yes")
- d.add decl
- d.stand_alone?.should == "yes"
- end
-
- # According to the docs this should return the default XMLDecl but that
- # will carry some more problems when printing the document. Currently, it
- # returns nil. See http://www.ruby-forum.com/topic/146812#650061
- it "returns the default value when no XML declaration present" do
- REXML::Document.new.stand_alone?.should == nil
- end
-
- end
-end
diff --git a/spec/ruby/library/rexml/document/version_spec.rb b/spec/ruby/library/rexml/document/version_spec.rb
deleted file mode 100644
index 4f6b40551b..0000000000
--- a/spec/ruby/library/rexml/document/version_spec.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Document#version" do
- it "returns XML version from declaration" do
- d = REXML::Document.new
- d.add REXML::XMLDecl.new("1.1")
- d.version.should == "1.1"
- end
-
- it "returns the default version when declaration is not present" do
- REXML::Document.new.version.should == REXML::XMLDecl::DEFAULT_VERSION
- end
- end
-end
diff --git a/spec/ruby/library/rexml/document/write_spec.rb b/spec/ruby/library/rexml/document/write_spec.rb
deleted file mode 100644
index 00c22141b3..0000000000
--- a/spec/ruby/library/rexml/document/write_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
- require 'rexml/formatters/transitive'
-
- # Maybe this can be cleaned
- describe "REXML::Document#write" do
- before :each do
- @d = REXML::Document.new
- city = REXML::Element.new "Springfield"
- street = REXML::Element.new "EvergreenTerrace"
- address = REXML::Element.new "House742"
- @d << city << street << address
- @str = ""
- end
-
- it "returns document source as string" do
- @d.write(@str)
- @str.should == "<Springfield><EvergreenTerrace><House742/></EvergreenTerrace></Springfield>"
- end
-
- it "returns document indented" do
- @d.write(@str, 2)
- @str.should =~ /\s*<Springfield>\s*<EvergreenTerrace>\s*<House742\/>\s*<\/EvergreenTerrace>\s*<\/Springfield>/
- end
-
- it "returns document with transitive support" do
- @d.write(@str, 2, true)
- @str.should =~ /\s*<Springfield\s*><EvergreenTerrace\s*><House742\s*\/><\/EvergreenTerrace\s*><\/Springfield\s*>/
- end
-
- it "returns document with support for IE" do
- @d.write(@str, -1, false, true)
- @str.should == "<Springfield><EvergreenTerrace><House742 /></EvergreenTerrace></Springfield>"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/document/xml_decl_spec.rb b/spec/ruby/library/rexml/document/xml_decl_spec.rb
deleted file mode 100644
index 8ac47510b0..0000000000
--- a/spec/ruby/library/rexml/document/xml_decl_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Document#xml_decl" do
- it "returns XML declaration of the document" do
- d = REXML::Document.new
- decl = REXML::XMLDecl.new("1.0", "UTF-16", "yes")
- d.add decl
- d.xml_decl.should == decl
- end
-
- it "returns default XML declaration unless present" do
- REXML::Document.new.xml_decl.should == REXML::XMLDecl.new
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/add_attribute_spec.rb b/spec/ruby/library/rexml/element/add_attribute_spec.rb
deleted file mode 100644
index 64f2ec84a3..0000000000
--- a/spec/ruby/library/rexml/element/add_attribute_spec.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#add_attribute" do
- before :each do
- @person = REXML::Element.new "person"
- @person.attributes["name"] = "Bill"
- end
-
- it "adds a new attribute" do
- @person.add_attribute("age", "17")
- @person.attributes["age"].should == "17"
- end
-
- it "overwrites an existing attribute" do
- @person.add_attribute("name", "Bill")
- @person.attributes["name"].should == "Bill"
- end
-
- it "accepts a pair of strings" do
- @person.add_attribute("male", "true")
- @person.attributes["male"].should == "true"
- end
-
- it "accepts an Attribute for key" do
- attr = REXML::Attribute.new("male", "true")
- @person.add_attribute attr
- @person.attributes["male"].should == "true"
- end
-
- it "ignores value if key is an Attribute" do
- attr = REXML::Attribute.new("male", "true")
- @person.add_attribute(attr, "false")
- @person.attributes["male"].should == "true"
- end
-
- it "returns the attribute added" do
- attr = REXML::Attribute.new("name", "Tony")
- @person.add_attribute(attr).should == attr
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/add_attributes_spec.rb b/spec/ruby/library/rexml/element/add_attributes_spec.rb
deleted file mode 100644
index f331803dd8..0000000000
--- a/spec/ruby/library/rexml/element/add_attributes_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#add_attributes" do
- before :each do
- @person = REXML::Element.new "person"
- @person.attributes["name"] = "Bill"
- end
-
- it "adds multiple attributes from a hash" do
- @person.add_attributes({"name" => "Joe", "age" => "27"})
- @person.attributes["name"].should == "Joe"
- @person.attributes["age"].should == "27"
- end
-
- it "adds multiple attributes from an array" do
- attrs = { "name" => "Joe", "age" => "27"}
- @person.add_attributes attrs.to_a
- @person.attributes["name"].should == "Joe"
- @person.attributes["age"].should == "27"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/add_element_spec.rb b/spec/ruby/library/rexml/element/add_element_spec.rb
deleted file mode 100644
index 8ba023f2c7..0000000000
--- a/spec/ruby/library/rexml/element/add_element_spec.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#add_element" do
- before :each do
- @root = REXML::Element.new("root")
- end
-
- it "adds a child without attributes" do
- name = REXML::Element.new("name")
- @root.add_element name
- @root.elements["name"].name.should == name.name
- @root.elements["name"].attributes.should == name.attributes
- @root.elements["name"].context.should == name.context
- end
-
- it "adds a child with attributes" do
- person = REXML::Element.new("person")
- @root.add_element(person, {"name" => "Madonna"})
- @root.elements["person"].name.should == person.name
- @root.elements["person"].attributes.should == person.attributes
- @root.elements["person"].context.should == person.context
- end
-
- it "adds a child with name" do
- @root.add_element "name"
- @root.elements["name"].name.should == "name"
- @root.elements["name"].attributes.should == {}
- @root.elements["name"].context.should == nil
- end
-
- it "returns the added child" do
- name = @root.add_element "name"
- @root.elements["name"].name.should == name.name
- @root.elements["name"].attributes.should == name.attributes
- @root.elements["name"].context.should == name.context
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/add_namespace_spec.rb b/spec/ruby/library/rexml/element/add_namespace_spec.rb
deleted file mode 100644
index 44b074bac7..0000000000
--- a/spec/ruby/library/rexml/element/add_namespace_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#add_namespace" do
- before :each do
- @elem = REXML::Element.new("person")
- end
-
- it "adds a namespace to element" do
- @elem.add_namespace("foo", "bar")
- @elem.namespace("foo").should == "bar"
- end
-
- it "accepts a prefix string as prefix" do
- @elem.add_namespace("xmlns:foo", "bar")
- @elem.namespace("foo").should == "bar"
- end
-
- it "uses prefix as URI if uri is nil" do
- @elem.add_namespace("some_uri", nil)
- @elem.namespace.should == "some_uri"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/add_text_spec.rb b/spec/ruby/library/rexml/element/add_text_spec.rb
deleted file mode 100644
index 3a0531ad42..0000000000
--- a/spec/ruby/library/rexml/element/add_text_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#add_text" do
- before :each do
- @name = REXML::Element.new "Name"
- end
-
- it "adds text to an element" do
- @name.add_text "Ringo"
- @name.to_s.should == "<Name>Ringo</Name>"
- end
-
- it "accepts a Text" do
- @name.add_text(REXML::Text.new("Ringo"))
- @name.to_s.should == "<Name>Ringo</Name>"
- end
-
- it "joins the new text with the old one" do
- @name.add_text "Ringo"
- @name.add_text " Starr"
- @name.to_s.should == "<Name>Ringo Starr</Name>"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/attribute_spec.rb b/spec/ruby/library/rexml/element/attribute_spec.rb
deleted file mode 100644
index b223d3440c..0000000000
--- a/spec/ruby/library/rexml/element/attribute_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#attribute" do
- it "returns an attribute by name" do
- person = REXML::Element.new "Person"
- attribute = REXML::Attribute.new("drink", "coffee")
- person.add_attribute(attribute)
- person.attribute("drink").should == attribute
- end
-
- it "supports attributes inside namespaces" do
- e = REXML::Element.new("element")
- e.add_attributes({"xmlns:ns" => "http://some_uri"})
- e.attribute("ns", "ns").to_s.should == "http://some_uri"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/attributes_spec.rb b/spec/ruby/library/rexml/element/attributes_spec.rb
deleted file mode 100644
index 92bcecc40a..0000000000
--- a/spec/ruby/library/rexml/element/attributes_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#attributes" do
- it "returns element's Attributes" do
- p = REXML::Element.new "Person"
-
- name = REXML::Attribute.new("name", "John")
- attrs = REXML::Attributes.new(p)
- attrs.add name
-
- p.add_attribute name
- p.attributes.should == attrs
- end
-
- it "returns an empty hash if element has no attributes" do
- REXML::Element.new("Person").attributes.should == {}
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/cdatas_spec.rb b/spec/ruby/library/rexml/element/cdatas_spec.rb
deleted file mode 100644
index 988b2cb422..0000000000
--- a/spec/ruby/library/rexml/element/cdatas_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#cdatas" do
- before :each do
- @e = REXML::Element.new("Root")
- end
-
- it "returns the array of children cdatas" do
- c = REXML::CData.new("Primary")
- d = REXML::CData.new("Secondary")
- @e << c
- @e << d
- @e.cdatas.should == [c, d]
- end
-
- it "freezes the returned array" do
- @e.cdatas.should.frozen?
- end
-
- it "returns an empty array if element has no cdata" do
- @e.cdatas.should == []
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/clone_spec.rb b/spec/ruby/library/rexml/element/clone_spec.rb
deleted file mode 100644
index 490e43181f..0000000000
--- a/spec/ruby/library/rexml/element/clone_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#clone" do
- before :each do
- @e = REXML::Element.new "a"
- end
- it "creates a copy of element" do
- @e.clone.to_s.should == @e.to_s
- end
-
- it "copies the attributes" do
- @e.add_attribute("foo", "bar")
- @e.clone.to_s.should == @e.to_s
- end
-
- it "does not copy the text" do
- @e.add_text "some text..."
- @e.clone.to_s.should_not == @e
- @e.clone.to_s.should == "<a/>"
- end
-
- it "does not copy the child elements" do
- b = REXML::Element.new "b"
- @e << b
- @e.clone.should_not == @e
- @e.clone.to_s.should == "<a/>"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/comments_spec.rb b/spec/ruby/library/rexml/element/comments_spec.rb
deleted file mode 100644
index 84ab9a7469..0000000000
--- a/spec/ruby/library/rexml/element/comments_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#comments" do
- before :each do
- @e = REXML::Element.new "root"
- @c1 = REXML::Comment.new "this is a comment"
- @c2 = REXML::Comment.new "this is another comment"
- @e << @c1
- @e << @c2
- end
-
- it "returns the array of comments" do
- @e.comments.should == [@c1, @c2]
- end
-
- it "returns a frozen object" do
- @e.comments.should.frozen?
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/delete_attribute_spec.rb b/spec/ruby/library/rexml/element/delete_attribute_spec.rb
deleted file mode 100644
index e2ba81eb0d..0000000000
--- a/spec/ruby/library/rexml/element/delete_attribute_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#delete_attribute" do
- before :each do
- @e = REXML::Element.new("Person")
- @attr = REXML::Attribute.new("name", "Sean")
- @e.add_attribute(@attr)
- end
-
- it "deletes an attribute from the element" do
- @e.delete_attribute("name")
- @e.attributes["name"].should be_nil
- end
-
- # Bug was filled with a patch in Ruby's tracker #20298
- quarantine! do
- it "receives an Attribute" do
- @e.add_attribute(@attr)
- @e.delete_attribute(@attr)
- @e.attributes["name"].should be_nil
- end
- end
-
- # Docs say that it returns the removed attribute but then examples
- # show it returns the element with the attribute removed.
- # Also fixed in #20298
- it "returns the element with the attribute removed" do
- elem = @e.delete_attribute("name")
- elem.attributes.should be_empty
- elem.to_s.should eql("<Person/>")
- end
-
- it "returns nil if the attribute does not exist" do
- @e.delete_attribute("name")
- at = @e.delete_attribute("name")
- at.should be_nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/delete_element_spec.rb b/spec/ruby/library/rexml/element/delete_element_spec.rb
deleted file mode 100644
index c0b486a6f7..0000000000
--- a/spec/ruby/library/rexml/element/delete_element_spec.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#delete_element" do
- before :each do
- @root = REXML::Element.new("root")
- end
-
- it "deletes the child element" do
- node = REXML::Element.new("some_node")
- @root.add_element node
- @root.delete_element node
- @root.elements.size.should == 0
- end
-
- it "deletes a child via XPath" do
- @root.add_element "some_node"
- @root.delete_element "some_node"
- @root.elements.size.should == 0
- end
-
- it "deletes the child at index" do
- @root.add_element "some_node"
- @root.delete_element 1
- @root.elements.size.should == 0
- end
-
- # According to the docs this should return the deleted element
- # but it won't if it's an Element.
- it "deletes Element and returns it" do
- node = REXML::Element.new("some_node")
- @root.add_element node
- del_node = @root.delete_element node
- del_node.should == node
- end
-
- # Note how passing the string will return the removed element
- # but passing the Element as above won't.
- it "deletes an element and returns it" do
- node = REXML::Element.new("some_node")
- @root.add_element node
- del_node = @root.delete_element "some_node"
- del_node.should == node
- end
-
- it "returns nil unless element exists" do
- @root.delete_element("something").should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/delete_namespace_spec.rb b/spec/ruby/library/rexml/element/delete_namespace_spec.rb
deleted file mode 100644
index a7763d51e8..0000000000
--- a/spec/ruby/library/rexml/element/delete_namespace_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#delete_namespace" do
-
- before :each do
- @doc = REXML::Document.new "<a xmlns:foo='bar' xmlns='twiddle'/>"
- end
-
- it "deletes a namespace from the element" do
- @doc.root.delete_namespace 'foo'
- @doc.root.namespace("foo").should be_nil
- @doc.root.to_s.should == "<a xmlns='twiddle'/>"
- end
-
- it "deletes default namespace when called with no args" do
- @doc.root.delete_namespace
- @doc.root.namespace.should be_empty
- @doc.root.to_s.should == "<a xmlns:foo='bar'/>"
- end
-
- it "returns the element" do
- @doc.root.delete_namespace.should == @doc.root
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/document_spec.rb b/spec/ruby/library/rexml/element/document_spec.rb
deleted file mode 100644
index 754f27d8a0..0000000000
--- a/spec/ruby/library/rexml/element/document_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#document" do
-
- it "returns the element's document" do
- d = REXML::Document.new("<root><elem/></root>")
- d << REXML::XMLDecl.new
- d.root.document.should == d
- d.root.document.to_s.should == d.to_s
- end
-
- it "returns nil if it belongs to no document" do
- REXML::Element.new("standalone").document.should be_nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb b/spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb
deleted file mode 100644
index f2d779e577..0000000000
--- a/spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#each_element_with_attributes" do
- before :each do
- @document = REXML::Element.new("people")
- @father = REXML::Element.new("Person")
- @father.attributes["name"] = "Joe"
- @son = REXML::Element.new("Child")
- @son.attributes["name"] = "Fred"
- @document.root << @father
- @document.root << @son
- @childs = []
- end
-
- it "returns childs with attribute" do
- @document.each_element_with_attribute("name") { |elem| @childs << elem }
- @childs[0].should == @father
- @childs[1].should == @son
- end
-
- it "takes attribute value as second argument" do
- @document.each_element_with_attribute("name", "Fred"){ |elem| elem.should == @son }
- end
-
- it "takes max number of childs as third argument" do
- @document.each_element_with_attribute("name", nil, 1) { |elem| @childs << elem }
- @childs.size.should == 1
- @childs[0].should == @father
- end
-
- it "takes XPath filter as fourth argument" do
- @document.each_element_with_attribute("name", nil, 0, "Child"){ |elem| elem.should == @son}
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/each_element_with_text_spec.rb b/spec/ruby/library/rexml/element/each_element_with_text_spec.rb
deleted file mode 100644
index 8f9d062c99..0000000000
--- a/spec/ruby/library/rexml/element/each_element_with_text_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#each_element_with_text" do
- before :each do
- @document = REXML::Element.new("people")
-
- @joe = REXML::Element.new("Person")
- @joe.text = "Joe"
- @fred = REXML::Element.new("Person")
- @fred.text = "Fred"
- @another = REXML::Element.new("AnotherPerson")
- @another.text = "Fred"
- @document.root << @joe
- @document.root << @fred
- @document.root << @another
- @childs = []
- end
-
- it "returns childs with text" do
- @document.each_element_with_text("Joe"){|c| c.should == @joe}
- end
-
- it "takes max as second argument" do
- @document.each_element_with_text("Fred", 1){ |c| c.should == @fred}
- end
-
- it "takes XPath filter as third argument" do
- @document.each_element_with_text("Fred", 0, "Person"){ |c| c.should == @fred}
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/element_reference_spec.rb b/spec/ruby/library/rexml/element/element_reference_spec.rb
deleted file mode 100644
index 9e5d371ce4..0000000000
--- a/spec/ruby/library/rexml/element/element_reference_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#[]" do
-
- before :each do
- @doc = REXML::Document.new("<root foo='bar'></root>")
- @child = REXML::Element.new("child")
- @doc.root.add_element @child
- end
-
- it "return attribute value if argument is string or symbol" do
- @doc.root[:foo].should == 'bar'
- @doc.root['foo'].should == 'bar'
- end
-
- it "return nth element if argument is int" do
- @doc.root[0].should == @child
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/get_text_spec.rb b/spec/ruby/library/rexml/element/get_text_spec.rb
deleted file mode 100644
index 0fa8d7cb3f..0000000000
--- a/spec/ruby/library/rexml/element/get_text_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#get_text" do
- before :each do
- @doc = REXML::Document.new "<p>some text<b>this is bold!</b> more text</p>"
- end
-
- it "returns the first text child node" do
- @doc.root.get_text.value.should == "some text"
- @doc.root.get_text.should be_kind_of(REXML::Text)
- end
-
- it "returns text from an element matching path" do
- @doc.root.get_text("b").value.should == "this is bold!"
- @doc.root.get_text("b").should be_kind_of(REXML::Text)
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/has_attributes_spec.rb b/spec/ruby/library/rexml/element/has_attributes_spec.rb
deleted file mode 100644
index af3ce8ce1b..0000000000
--- a/spec/ruby/library/rexml/element/has_attributes_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#has_attributes?" do
- before :each do
- @e = REXML::Element.new("test_elem")
- end
-
- it "returns true when element has any attributes" do
- @e.add_attribute("name", "Joe")
- @e.has_attributes?.should be_true
- end
-
- it "returns false if element has no attributes" do
- @e.has_attributes?.should be_false
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/has_elements_spec.rb b/spec/ruby/library/rexml/element/has_elements_spec.rb
deleted file mode 100644
index 04c7fe01a5..0000000000
--- a/spec/ruby/library/rexml/element/has_elements_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#has_elements?" do
- before :each do
- @e = REXML::Element.new("root")
- end
-
- it "returns true if element has child elements" do
- child = REXML::Element.new("child")
- @e << child
- @e.has_elements?.should be_true
- end
-
- it "returns false if element doesn't have child elements" do
- @e.has_elements?.should be_false
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/has_text_spec.rb b/spec/ruby/library/rexml/element/has_text_spec.rb
deleted file mode 100644
index de19fe0763..0000000000
--- a/spec/ruby/library/rexml/element/has_text_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#has_text?" do
-
- it "returns true if element has a Text child" do
- e = REXML::Element.new("Person")
- e.text = "My text"
- e.has_text?.should be_true
- end
-
- it "returns false if it has no Text childs" do
- e = REXML::Element.new("Person")
- e.has_text?.should be_false
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/inspect_spec.rb b/spec/ruby/library/rexml/element/inspect_spec.rb
deleted file mode 100644
index ec16c136ee..0000000000
--- a/spec/ruby/library/rexml/element/inspect_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#inspect" do
-
- before :each do
- @name = REXML::Element.new "name"
- end
-
- it "returns the node as a string" do
- @name.inspect.should == "<name/>"
- end
-
- it "inserts '...' if the node has children" do
- e = REXML::Element.new "last_name"
- @name << e
- @name.inspect.should == "<name> ... </>"
- # This might make more sense but differs from MRI's default behavior
- # @name.inspect.should == "<name> ... </name>"
- end
-
- it "inserts the attributes in the string" do
- @name.add_attribute "language"
- @name.attributes["language"] = "english"
- @name.inspect.should == "<name language='english'/>"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/instructions_spec.rb b/spec/ruby/library/rexml/element/instructions_spec.rb
deleted file mode 100644
index 11f1396df0..0000000000
--- a/spec/ruby/library/rexml/element/instructions_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#instructions" do
- before :each do
- @elem = REXML::Element.new("root")
- end
- it "returns the Instruction children nodes" do
- inst = REXML::Instruction.new("xml-stylesheet", "href='headlines.css'")
- @elem << inst
- @elem.instructions.first.should == inst
- end
-
- it "returns an empty array if it has no Instruction children" do
- @elem.instructions.should be_empty
- end
-
- it "freezes the returned array" do
- @elem.instructions.frozen?.should be_true
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/namespace_spec.rb b/spec/ruby/library/rexml/element/namespace_spec.rb
deleted file mode 100644
index 28966289c5..0000000000
--- a/spec/ruby/library/rexml/element/namespace_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#namespace" do
- before :each do
- @doc = REXML::Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
- @elem = @doc.elements["//b"]
- end
-
- it "returns the default namespace" do
- @elem.namespace.should == "1"
- end
-
- it "accepts a namespace prefix" do
- @elem.namespace("y").should == "2"
- @doc.elements["//c"].namespace("z").should == "3"
- end
-
- it "returns an empty String if default namespace is not defined" do
- e = REXML::Document.new("<a/>")
- e.root.namespace.should be_empty
- end
-
- it "returns nil if namespace is not defined" do
- @elem.namespace("z").should be_nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/namespaces_spec.rb b/spec/ruby/library/rexml/element/namespaces_spec.rb
deleted file mode 100644
index 4544540173..0000000000
--- a/spec/ruby/library/rexml/element/namespaces_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#namespaces" do
- before :each do
- doc = REXML::Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
- @elem = doc.elements["//c"]
- end
-
- it "returns a hash of the namespaces" do
- ns = {"y"=>"2", "z"=>"3", "xmlns"=>"1"}
- @elem.namespaces.keys.sort.should == ns.keys.sort
- @elem.namespaces.values.sort.should == ns.values.sort
- end
-
- it "returns an empty hash if no namespaces exist" do
- e = REXML::Element.new "element"
- e.namespaces.kind_of?(Hash).should == true
- e.namespaces.should be_empty
- end
-
- it "uses namespace prefixes as keys" do
- prefixes = ["y", "z", "xmlns"]
- @elem.namespaces.keys.sort.should == prefixes.sort
- end
-
- it "uses namespace values as the hash values" do
- values = ["2", "3", "1"]
- @elem.namespaces.values.sort.should == values.sort
- end
-
- end
-end
diff --git a/spec/ruby/library/rexml/element/new_spec.rb b/spec/ruby/library/rexml/element/new_spec.rb
deleted file mode 100644
index c6ab289476..0000000000
--- a/spec/ruby/library/rexml/element/new_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#new" do
-
- it "creates element from tag name" do
- REXML::Element.new("foo").name.should == "foo"
- end
-
- it "creates element with default attributes" do
- e = REXML::Element.new
- e.name.should == REXML::Element::UNDEFINED
- e.context.should == nil
- e.parent.should == nil
- end
-
- it "creates element from another element" do
- e = REXML::Element.new "foo"
- f = REXML::Element.new e
- e.name.should == f.name
- e.context.should == f.context
- e.parent.should == f.parent
- end
-
- it "takes parent as second argument" do
- parent = REXML::Element.new "foo"
- child = REXML::Element.new "bar", parent
- child.parent.should == parent
- end
-
- it "takes context as third argument" do
- context = {"some_key" => "some_value"}
- REXML::Element.new("foo", nil, context).context.should == context
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/next_element_spec.rb b/spec/ruby/library/rexml/element/next_element_spec.rb
deleted file mode 100644
index 46d8f74760..0000000000
--- a/spec/ruby/library/rexml/element/next_element_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#next_element" do
- before :each do
- @a = REXML::Element.new "a"
- @b = REXML::Element.new "b"
- @c = REXML::Element.new "c"
- @a.root << @b
- @a.root << @c
- end
- it "returns next existing element" do
- @a.elements["b"].next_element.should == @c
- end
-
- it "returns nil on last element" do
- @a.elements["c"].next_element.should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/node_type_spec.rb b/spec/ruby/library/rexml/element/node_type_spec.rb
deleted file mode 100644
index a39c2deca5..0000000000
--- a/spec/ruby/library/rexml/element/node_type_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#node_type" do
- it "returns :element" do
- REXML::Element.new("MyElem").node_type.should == :element
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/prefixes_spec.rb b/spec/ruby/library/rexml/element/prefixes_spec.rb
deleted file mode 100644
index ea4caab4bc..0000000000
--- a/spec/ruby/library/rexml/element/prefixes_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#prefixes" do
- before :each do
- doc = REXML::Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
- @elem = doc.elements["//c"]
- end
-
- it "returns an array of the prefixes of the namespaces" do
- @elem.prefixes.should == ["y", "z"]
- end
-
- it "does not include the default namespace" do
- @elem.prefixes.include?("xmlns").should == false
- end
-
- it "returns an empty array if no namespace was defined" do
- doc = REXML::Document.new "<root><something/></root>"
- root = doc.elements["//root"]
- root.prefixes.should == []
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/previous_element_spec.rb b/spec/ruby/library/rexml/element/previous_element_spec.rb
deleted file mode 100644
index a43b1ddd10..0000000000
--- a/spec/ruby/library/rexml/element/previous_element_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#previous_element" do
- before :each do
- @a = REXML::Element.new "a"
- @b = REXML::Element.new "b"
- @c = REXML::Element.new "c"
- @a.root << @b
- @a.root << @c
- end
-
- it "returns previous element" do
- @a.elements["c"].previous_element.should == @b
- end
-
- it "returns nil on first element" do
- @a.elements["b"].previous_element.should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/raw_spec.rb b/spec/ruby/library/rexml/element/raw_spec.rb
deleted file mode 100644
index 200a99d194..0000000000
--- a/spec/ruby/library/rexml/element/raw_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#raw" do
- it "returns true if raw mode is set to all" do
- REXML::Element.new("MyElem", nil, {raw: :all}).raw.should == true
- end
-
- it "returns true if raw mode is set to expanded_name" do
- REXML::Element.new("MyElem", nil, {raw: "MyElem"}).raw.should == true
- end
-
- it "returns false if raw mode is not set" do
- REXML::Element.new("MyElem", nil, {raw: ""}).raw.should == false
- end
-
- it "returns false if raw is not :all or expanded_name" do
- REXML::Element.new("MyElem", nil, {raw: "Something"}).raw.should == false
- end
-
- it "returns nil if context is not set" do
- REXML::Element.new("MyElem").raw.should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/root_spec.rb b/spec/ruby/library/rexml/element/root_spec.rb
deleted file mode 100644
index 52aa4571b9..0000000000
--- a/spec/ruby/library/rexml/element/root_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#root" do
- before :each do
- @doc = REXML::Document.new
- @root = REXML::Element.new "root"
- @node = REXML::Element.new "node"
- @doc << @root << @node
- end
-
- it "returns first child on documents" do
- @doc.root.should == @root
- end
-
- it "returns self on root nodes" do
- @root.root.should == @root
- end
-
- it "returns parent's root on child nodes" do
- @node.root.should == @root
- end
-
- it "returns self on standalone nodes" do
- e = REXML::Element.new "Elem" # Note that it doesn't have a parent node
- e.root.should == e
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/text_spec.rb b/spec/ruby/library/rexml/element/text_spec.rb
deleted file mode 100644
index 3234bba153..0000000000
--- a/spec/ruby/library/rexml/element/text_spec.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#text" do
- before :each do
- @e = REXML::Element.new "name"
- @e.text = "John"
- end
-
- it "returns the text node of element" do
- @e.text.should == "John"
- end
-
- it "returns the text node value" do
- t = REXML::Text.new "Joe"
- @e.text = t
- @e.text.should == "Joe"
- @e.text.should_not == t
- end
-
- it "returns nil if no text is attached" do
- elem = REXML::Element.new "name"
- elem.text.should == nil
- end
- end
-
- describe "REXML::Element#text=" do
- before :each do
- @e = REXML::Element.new "name"
- @e.text = "John"
- end
-
- it "sets the text node" do
- @e.to_s.should == "<name>John</name>"
- end
-
- it "replaces existing text" do
- @e.text = "Joe"
- @e.to_s.should == "<name>Joe</name>"
- end
-
- it "receives nil as an argument" do
- @e.text = nil
- @e.to_s.should == "<name/>"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/texts_spec.rb b/spec/ruby/library/rexml/element/texts_spec.rb
deleted file mode 100644
index 2d374d5e66..0000000000
--- a/spec/ruby/library/rexml/element/texts_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#texts" do
-
- it "returns an array of the Text children" do
- e = REXML::Element.new("root")
- e.add_text "First"
- e.add_text "Second"
- e.texts.should == ["FirstSecond"]
- end
-
- it "returns an empty array if it has no Text children" do
- REXML::Element.new("root").texts.should == []
- end
- end
-end
diff --git a/spec/ruby/library/rexml/element/whitespace_spec.rb b/spec/ruby/library/rexml/element/whitespace_spec.rb
deleted file mode 100644
index f455067922..0000000000
--- a/spec/ruby/library/rexml/element/whitespace_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Element#whitespace" do
- it "returns true if whitespace is respected in the element" do
- e = REXML::Element.new("root")
- e.whitespace.should be_true
-
- e = REXML::Element.new("root", nil, respect_whitespace: :all)
- e.whitespace.should be_true
-
- e = REXML::Element.new("root", nil, respect_whitespace: ["root"])
- e.whitespace.should be_true
- end
-
- it "returns false if whitespace is ignored inside element" do
- e = REXML::Element.new("root", nil, compress_whitespace: :all)
- e.whitespace.should be_false
-
- e = REXML::Element.new("root", nil, compress_whitespace: ["root"])
- e.whitespace.should be_false
- end
- end
-end
diff --git a/spec/ruby/library/rexml/node/each_recursive_spec.rb b/spec/ruby/library/rexml/node/each_recursive_spec.rb
deleted file mode 100644
index da347b1389..0000000000
--- a/spec/ruby/library/rexml/node/each_recursive_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Node#each_recursive" do
- before :each do
- @doc = REXML::Document.new
- @doc << REXML::XMLDecl.new
- @root = REXML::Element.new "root"
- @child1 = REXML::Element.new "child1"
- @child2 = REXML::Element.new "child2"
- @root << @child1
- @root << @child2
- @doc << @root
- end
-
- it "visits all subnodes of self" do
- nodes = []
- @doc.each_recursive { |node| nodes << node}
- nodes.should == [@root, @child1, @child2]
- end
- end
-end
diff --git a/spec/ruby/library/rexml/node/find_first_recursive_spec.rb b/spec/ruby/library/rexml/node/find_first_recursive_spec.rb
deleted file mode 100644
index 2a4f1097ae..0000000000
--- a/spec/ruby/library/rexml/node/find_first_recursive_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Node#find_first_recursive" do
- before :each do
- @e = REXML::Element.new("root")
- @node1 = REXML::Element.new("node")
- @node2 = REXML::Element.new("another node")
- @subnode = REXML::Element.new("another node")
- @node1 << @subnode
- @e << @node1
- @e << @node2
- end
-
- it "finds the first element that matches block" do
- found = @e.find_first_recursive { |n| n.to_s == "<node><another node/></node>"}
- found.should == @node1
- end
-
- it "visits the nodes in preorder" do
- found = @e.find_first_recursive { |n| n.to_s == "<another node/>"}
- found.should == @subnode
- found.should_not == @node2
- end
- end
-end
diff --git a/spec/ruby/library/rexml/node/index_in_parent_spec.rb b/spec/ruby/library/rexml/node/index_in_parent_spec.rb
deleted file mode 100644
index 55909f86d6..0000000000
--- a/spec/ruby/library/rexml/node/index_in_parent_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Node#index_in_parent" do
- it "returns the index (starting from 1) of self in parent" do
- e = REXML::Element.new("root")
- node1 = REXML::Element.new("node")
- node2 = REXML::Element.new("another node")
- e << node1
- e << node2
-
- node1.index_in_parent.should == 1
- node2.index_in_parent.should == 2
- end
- end
-end
diff --git a/spec/ruby/library/rexml/node/next_sibling_node_spec.rb b/spec/ruby/library/rexml/node/next_sibling_node_spec.rb
deleted file mode 100644
index 7aae861d75..0000000000
--- a/spec/ruby/library/rexml/node/next_sibling_node_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Node#next_sibling_node" do
- before :each do
- @e = REXML::Element.new("root")
- @node1 = REXML::Element.new("node")
- @node2 = REXML::Element.new("another node")
- @e << @node1
- @e << @node2
- end
-
- it "returns the next child node in parent" do
- @node1.next_sibling_node.should == @node2
- end
-
- it "returns nil if there are no more child nodes next" do
- @node2.next_sibling_node.should == nil
- @e.next_sibling_node.should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/node/parent_spec.rb b/spec/ruby/library/rexml/node/parent_spec.rb
deleted file mode 100644
index 07425e8f36..0000000000
--- a/spec/ruby/library/rexml/node/parent_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Node#parent?" do
- it "returns true for Elements" do
- e = REXML::Element.new("foo")
- e.should.parent?
- end
-
- it "returns true for Documents" do
- e = REXML::Document.new
- e.should.parent?
- end
-
- # This includes attributes, CDatas and declarations.
- it "returns false for Texts" do
- e = REXML::Text.new("foo")
- e.should_not.parent?
- end
- end
-end
diff --git a/spec/ruby/library/rexml/node/previous_sibling_node_spec.rb b/spec/ruby/library/rexml/node/previous_sibling_node_spec.rb
deleted file mode 100644
index 11263968a7..0000000000
--- a/spec/ruby/library/rexml/node/previous_sibling_node_spec.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Node#previous_sibling_node" do
- before :each do
- @e = REXML::Element.new("root")
- @node1 = REXML::Element.new("node")
- @node2 = REXML::Element.new("another node")
- @e << @node1
- @e << @node2
- end
-
- it "returns the previous child node in parent" do
- @node2.previous_sibling_node.should == @node1
- end
-
- it "returns nil if there are no more child nodes before" do
- @node1.previous_sibling_node.should == nil
- @e.previous_sibling_node.should == nil
- end
- end
-end
diff --git a/spec/ruby/library/rexml/shared/each_element.rb b/spec/ruby/library/rexml/shared/each_element.rb
deleted file mode 100644
index 2e0871161d..0000000000
--- a/spec/ruby/library/rexml/shared/each_element.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require 'rexml/document'
-require_relative '../../../spec_helper'
-
-describe :rexml_each_element, shared: true do
- before :each do
- @e = REXML::Element.new "root"
- s1 = REXML::Element.new "node1"
- s2 = REXML::Element.new "node2"
- s3 = REXML::Element.new "node3"
- s4 = REXML::Element.new "sub_node"
- @e << s1
- @e << s2
- @e << s3
- @e << s4
- end
-
- it "iterates through element" do
- str = ""
- @e.send(@method) { |elem| str << elem.name << " " }
- str.should == "node1 node2 node3 sub_node "
- end
-
- it "iterates through element filtering with XPath" do
- str = ""
- @e.send(@method, "/*"){ |e| str << e.name << " "}
- str.should == "node1 node2 node3 sub_node "
- end
-end
-
-describe "REXML::Element#each_element" do
- it_behaves_like :rexml_each_element, :each_element
-end
-
-describe "REXML::Elements#each" do
- it_behaves_like :rexml_each_element, :each
-end
diff --git a/spec/ruby/library/rexml/shared/elements_to_a.rb b/spec/ruby/library/rexml/shared/elements_to_a.rb
deleted file mode 100644
index 388250d8b3..0000000000
--- a/spec/ruby/library/rexml/shared/elements_to_a.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require 'rexml/document'
-require_relative '../../../spec_helper'
-
-describe :rexml_elements_to_a, shared: true do
- before :each do
- @e = REXML::Element.new "root"
- @first = REXML::Element.new("FirstChild")
- @second = REXML::Element.new("SecondChild")
- @e << @first
- @e << @second
- end
-
- it "returns elements that match xpath" do
- @e.elements.send(@method, "FirstChild").first.should == @first
- end
-
- # According to the docs REXML::Element#get_elements is an alias for
- # REXML::Elements.to_a. Implementation wise there's a difference, get_elements
- # always needs the first param (even if it's nil).
- # A patch was submitted:
- # http://rubyforge.org/tracker/index.php?func=detail&aid=19354&group_id=426&atid=1698
- it "returns all childs if xpath is nil" do
- @e.elements.send(@method).should == [@first, @second]
- end
-
-end
-
-describe "REXML::REXML::Elements#to_a" do
- it_behaves_like :rexml_elements_to_a, :to_a
-end
-
-describe "REXML::REXML::Element#get_elements" do
- it_behaves_like :rexml_elements_to_a, :get_elements
-end
diff --git a/spec/ruby/library/rexml/text/append_spec.rb b/spec/ruby/library/rexml/text/append_spec.rb
deleted file mode 100644
index 5e7a5bae7c..0000000000
--- a/spec/ruby/library/rexml/text/append_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#<<" do
- it "appends a string to this text node" do
- text = REXML::Text.new("foo")
- text << "bar"
- text.should == "foobar"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/clone_spec.rb b/spec/ruby/library/rexml/text/clone_spec.rb
deleted file mode 100644
index 7801782ff5..0000000000
--- a/spec/ruby/library/rexml/text/clone_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#clone" do
- it "creates a copy of this node" do
- text = REXML::Text.new("foo")
- text.clone.should == "foo"
- text.clone.should == text
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/comparison_spec.rb b/spec/ruby/library/rexml/text/comparison_spec.rb
deleted file mode 100644
index 119dd050a6..0000000000
--- a/spec/ruby/library/rexml/text/comparison_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#<=>" do
- before :each do
- @first = REXML::Text.new("abc")
- @last = REXML::Text.new("def")
- end
-
- it "returns -1 if lvalue is less than rvalue" do
- val = @first <=> @last
- val.should == -1
- end
-
- it "returns -1 if lvalue is greater than rvalue" do
- val = @last <=> @first
- val.should == 1
- end
-
- it "returns 0 if both values are equal" do
- tmp = REXML::Text.new("tmp")
- val = tmp <=> tmp
- val.should == 0
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/empty_spec.rb b/spec/ruby/library/rexml/text/empty_spec.rb
deleted file mode 100644
index 4c9c899bcb..0000000000
--- a/spec/ruby/library/rexml/text/empty_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#empty?" do
- it "returns true if the text is empty" do
- REXML::Text.new("").should.empty?
- end
-
- it "returns false if the text is not empty" do
- REXML::Text.new("some_text").should_not.empty?
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/indent_text_spec.rb b/spec/ruby/library/rexml/text/indent_text_spec.rb
deleted file mode 100644
index 73065c37da..0000000000
--- a/spec/ruby/library/rexml/text/indent_text_spec.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#indent_text" do
- before :each do
- @t = REXML::Text.new("")
- end
- it "indents a string with default parameters" do
- @t.indent_text("foo").should == "\tfoo"
- end
-
- it "accepts a custom indentation level as second argument" do
- @t.indent_text("foo", 2, "\t", true).should == "\t\tfoo"
- end
-
- it "accepts a custom separator as third argument" do
- @t.indent_text("foo", 1, "\n", true).should == "\nfoo"
- end
-
- it "accepts a fourth parameter to skip the first line" do
- @t.indent_text("foo", 1, "\t", false).should == "foo"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/inspect_spec.rb b/spec/ruby/library/rexml/text/inspect_spec.rb
deleted file mode 100644
index af389890ee..0000000000
--- a/spec/ruby/library/rexml/text/inspect_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#inspect" do
- it "inspects the string attribute as a string" do
- REXML::Text.new("a text").inspect.should == "a text".inspect
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/new_spec.rb b/spec/ruby/library/rexml/text/new_spec.rb
deleted file mode 100644
index 8b33da9294..0000000000
--- a/spec/ruby/library/rexml/text/new_spec.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text.new" do
-
- it "creates a Text child node with no parent" do
- t = REXML::Text.new("test")
- t.should be_kind_of(REXML::Child)
- t.should == "test"
- t.parent.should == nil
- end
-
- it "respects whitespace if second argument is true" do
- t = REXML::Text.new("testing whitespace", true)
- t.should == "testing whitespace"
- t = REXML::Text.new(" ", true)
- t.should == " "
- end
-
- it "receives a parent as third argument" do
- e = REXML::Element.new("root")
- t = REXML::Text.new("test", false, e)
- t.parent.should == e
- e.to_s.should == "<root>test</root>"
- end
-
- it "expects escaped text if raw is true" do
- t = REXML::Text.new("&lt;&amp;&gt;", false, nil, true)
- t.should == "&lt;&amp;&gt;"
-
- ->{ REXML::Text.new("<&>", false, nil, true)}.should raise_error(Exception)
- end
-
- it "uses raw value of the parent if raw is nil" do
- e1 = REXML::Element.new("root", nil, { raw: :all})
- -> {REXML::Text.new("<&>", false, e1)}.should raise_error(Exception)
-
- e2 = REXML::Element.new("root", nil, { raw: []})
- e2.raw.should be_false
- t1 = REXML::Text.new("<&>", false, e2)
- t1.should == "&lt;&amp;&gt;"
- end
-
- it "escapes the values if raw is false" do
- t = REXML::Text.new("<&>", false, nil, false)
- t.should == "&lt;&amp;&gt;"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/node_type_spec.rb b/spec/ruby/library/rexml/text/node_type_spec.rb
deleted file mode 100644
index f44a1ede3e..0000000000
--- a/spec/ruby/library/rexml/text/node_type_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#node_type" do
- it "returns :text" do
- REXML::Text.new("test").node_type.should == :text
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/normalize_spec.rb b/spec/ruby/library/rexml/text/normalize_spec.rb
deleted file mode 100644
index cde11ec3c9..0000000000
--- a/spec/ruby/library/rexml/text/normalize_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text.normalize" do
- it "escapes a string with <, >, &, ' and \" " do
- REXML::Text.normalize("< > & \" '").should == "&lt; &gt; &amp; &quot; &apos;"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/read_with_substitution_spec.rb b/spec/ruby/library/rexml/text/read_with_substitution_spec.rb
deleted file mode 100644
index 7ff26f4d53..0000000000
--- a/spec/ruby/library/rexml/text/read_with_substitution_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text.read_with_substitution" do
- it "reads a text and escapes entities" do
- REXML::Text.read_with_substitution("&lt; &gt; &amp; &quot; &apos;").should == "< > & \" '"
- end
-
- it "accepts an regex for invalid expressions and raises an error if text matches" do
- -> {REXML::Text.read_with_substitution("this is illegal", /illegal/)}.should raise_error(Exception)
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/to_s_spec.rb b/spec/ruby/library/rexml/text/to_s_spec.rb
deleted file mode 100644
index e67632c9a1..0000000000
--- a/spec/ruby/library/rexml/text/to_s_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#to_s" do
- it "returns the string of this Text node" do
- u = REXML::Text.new("sean russell", false, nil, true)
- u.to_s.should == "sean russell"
-
- t = REXML::Text.new("some test text")
- t.to_s.should == "some test text"
- end
-
- it "escapes the text" do
- t = REXML::Text.new("& < >")
- t.to_s.should == "&amp; &lt; &gt;"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/unnormalize_spec.rb b/spec/ruby/library/rexml/text/unnormalize_spec.rb
deleted file mode 100644
index 7b507194d0..0000000000
--- a/spec/ruby/library/rexml/text/unnormalize_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text.unnormalize" do
- it "unescapes a string with the values defined in SETUTITSBUS" do
- REXML::Text.unnormalize("&lt; &gt; &amp; &quot; &apos;").should == "< > & \" '"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/value_spec.rb b/spec/ruby/library/rexml/text/value_spec.rb
deleted file mode 100644
index 53d40c765f..0000000000
--- a/spec/ruby/library/rexml/text/value_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#value" do
- it "returns the text value of this node" do
- REXML::Text.new("test").value.should == "test"
- end
-
- it "does not escape entities" do
- REXML::Text.new("& \"").value.should == "& \""
- end
-
- it "follows the respect_whitespace attribute" do
- REXML::Text.new("test bar", false).value.should == "test bar"
- REXML::Text.new("test bar", true).value.should == "test bar"
- end
-
- it "ignores the raw attribute" do
- REXML::Text.new("sean russell", false, nil, true).value.should == "sean russell"
- end
- end
-
- describe "REXML::Text#value=" do
- before :each do
- @t = REXML::Text.new("new")
- end
-
- it "sets the text of the node" do
- @t.value = "another text"
- @t.to_s.should == "another text"
- end
-
- it "escapes entities" do
- @t.value = "<a>"
- @t.to_s.should == "&lt;a&gt;"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/wrap_spec.rb b/spec/ruby/library/rexml/text/wrap_spec.rb
deleted file mode 100644
index 331a8439e2..0000000000
--- a/spec/ruby/library/rexml/text/wrap_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#wrap" do
- before :each do
- @t = REXML::Text.new("abc def")
- end
-
- it "wraps the text at width" do
- @t.wrap("abc def", 3, false).should == "abc\ndef"
- end
-
- it "returns the string if width is greater than the size of the string" do
- @t.wrap("abc def", 10, false).should == "abc def"
- end
-
- it "takes a newline at the beginning option as the third parameter" do
- @t.wrap("abc def", 3, true).should == "\nabc\ndef"
- end
- end
-end
diff --git a/spec/ruby/library/rexml/text/write_with_substitution_spec.rb b/spec/ruby/library/rexml/text/write_with_substitution_spec.rb
deleted file mode 100644
index 840f141e3d..0000000000
--- a/spec/ruby/library/rexml/text/write_with_substitution_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'3.0' do
- require 'rexml/document'
-
- describe "REXML::Text#write_with_substitution" do
- before :each do
- @t = REXML::Text.new("test")
- @f = tmp("rexml_spec")
- @file = File.open(@f, "w+")
- end
-
- after :each do
- @file.close
- rm_r @f
- end
-
- it "writes out the input to a String" do
- s = ""
- @t.write_with_substitution(s, "some text")
- s.should == "some text"
- end
-
- it "writes out the input to an IO" do
- @t.write_with_substitution(@file, "some text")
- @file.rewind
- @file.gets.should == "some text"
- end
-
- it "escapes characters" do
- @t.write_with_substitution(@file, "& < >")
- @file.rewind
- @file.gets.should == "&amp; &lt; &gt;"
- end
- end
-end
diff --git a/spec/ruby/library/rubygems/gem/load_path_insert_index_spec.rb b/spec/ruby/library/rubygems/gem/load_path_insert_index_spec.rb
new file mode 100644
index 0000000000..9b37eaa43c
--- /dev/null
+++ b/spec/ruby/library/rubygems/gem/load_path_insert_index_spec.rb
@@ -0,0 +1,10 @@
+require_relative '../../../spec_helper'
+require 'rubygems'
+
+describe "Gem.load_path_insert_index" do
+ guard -> { RbConfig::TOPDIR } do
+ it "is set for an installed Ruby" do
+ Gem.load_path_insert_index.should be_kind_of Integer
+ end
+ end
+end
diff --git a/spec/ruby/library/scanf/io/block_scanf_spec.rb b/spec/ruby/library/scanf/io/block_scanf_spec.rb
deleted file mode 100644
index b9cc1b507e..0000000000
--- a/spec/ruby/library/scanf/io/block_scanf_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require_relative 'shared/block_scanf'
- require 'scanf'
-
- describe "IO#block_scanf" do
- it_behaves_like :scanf_io_block_scanf, :block_scanf
- end
-end
diff --git a/spec/ruby/library/scanf/io/fixtures/date.txt b/spec/ruby/library/scanf/io/fixtures/date.txt
deleted file mode 100644
index a1bd635c0c..0000000000
--- a/spec/ruby/library/scanf/io/fixtures/date.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Beethoven 1770
-Bach 1685
-Handel 1685
-
diff --git a/spec/ruby/library/scanf/io/fixtures/helloworld.txt b/spec/ruby/library/scanf/io/fixtures/helloworld.txt
deleted file mode 100644
index 3b18e512db..0000000000
--- a/spec/ruby/library/scanf/io/fixtures/helloworld.txt
+++ /dev/null
@@ -1 +0,0 @@
-hello world
diff --git a/spec/ruby/library/scanf/io/scanf_spec.rb b/spec/ruby/library/scanf/io/scanf_spec.rb
deleted file mode 100644
index 6a3e6d0d1a..0000000000
--- a/spec/ruby/library/scanf/io/scanf_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require_relative 'shared/block_scanf'
- require 'scanf'
-
- describe "IO#scanf" do
- before :each do
- @hw = File.open(fixture(__FILE__, 'helloworld.txt'), 'rb')
- @data = File.open(fixture(__FILE__, 'date.txt'), 'rb')
- end
-
- after :each do
- @hw.close unless @hw.closed?
- @data.close unless @data.closed?
- end
-
- it "returns an array containing the input converted in the specified type" do
- @hw.scanf("%s%s").should == ["hello", "world"]
- @data.scanf("%s%d").should == ["Beethoven", 1770]
- end
-
- it "returns an array containing the input converted in the specified type with given maximum field width" do
- @hw.scanf("%2s").should == ["he"]
- @data.scanf("%2c").should == ["Be"]
- end
-
- it "returns an empty array when a wrong specifier is passed" do
- @hw.scanf("%a").should == []
- @hw.scanf("%1").should == []
- @data.scanf("abc").should == []
- end
- end
-
- describe "IO#scanf with block" do
- it_behaves_like :scanf_io_block_scanf, :scanf
- end
-end
diff --git a/spec/ruby/library/scanf/io/shared/block_scanf.rb b/spec/ruby/library/scanf/io/shared/block_scanf.rb
deleted file mode 100644
index d938f43734..0000000000
--- a/spec/ruby/library/scanf/io/shared/block_scanf.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-require 'scanf'
-
-describe :scanf_io_block_scanf, shared: true do
- before :each do
- @data = File.open(fixture(__FILE__, 'date.txt'), 'rb')
- end
-
- after :each do
- @data.close unless @data.closed?
- end
-
- it "passes each match to the block as an array" do
- res = @data.send(@method, "%s%d") { |name, year| "#{name} was born in #{year}." }
- res.should == ["Beethoven was born in 1770.", "Bach was born in 1685.", "Handel was born in 1685."]
- end
-
- it "keeps scanning the input and cycling back to the beginning of the input string" do
- a = []
- @data.send(@method, "%s"){|w| a << w}
- a.should == [["Beethoven"], ["1770"], ["Bach"], ["1685"], ["Handel"], ["1685"]]
- end
-
- it "returns an empty array when a wrong specifier is passed" do
- a = []
- @data.send(@method, "%z"){|w| a << w}
- a.empty?.should be_true
- end
-end
diff --git a/spec/ruby/library/scanf/string/block_scanf_spec.rb b/spec/ruby/library/scanf/string/block_scanf_spec.rb
deleted file mode 100644
index 277e1fa1d7..0000000000
--- a/spec/ruby/library/scanf/string/block_scanf_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require_relative 'shared/block_scanf'
- require 'scanf'
-
- describe "String#block_scanf" do
- it_behaves_like :scanf_string_block_scanf, :block_scanf
- end
-end
diff --git a/spec/ruby/library/scanf/string/scanf_spec.rb b/spec/ruby/library/scanf/string/scanf_spec.rb
deleted file mode 100644
index c8897db675..0000000000
--- a/spec/ruby/library/scanf/string/scanf_spec.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ''...'2.7' do
- require_relative 'shared/block_scanf'
- require 'scanf'
-
- describe "String#scanf" do
- it "returns an array containing the input converted in the specified type" do
- "hello world".scanf("%s").should == ["hello"]
- "hello world".scanf("%s%d").should == ["hello"]
- "hello world".scanf("%s%c").should == ["hello", " "]
- "hello world".scanf("%c%s").should == ["h", "ello"]
- "hello world".scanf("%s%s").should == ["hello", "world"]
- "hello world".scanf("%c").should == ["h"]
- "123".scanf("%s").should == ["123"]
- "123".scanf("%c").should == ["1"]
- "123".scanf("%d").should == [123]
- "123".scanf("%u").should == [123]
- "123".scanf("%o").should == [83]
- "123".scanf("%x").should == [291]
- "123".scanf("%i").should == [123]
- "0123".scanf("%i").should == [83]
- "123".scanf("%f").should == [123.0]
- "0X123".scanf("%i").should == [291]
- "0x123".scanf("%i").should == [291]
- end
-
- it "returns an array containing the input converted in the specified type with given maximum field width" do
- "hello world".scanf("%2s").should == ["he"]
- "hello world".scanf("%2c").should == ["he"]
- "123".scanf("%2s").should == ["12"]
- "123".scanf("%2c").should == ["12"]
- "123".scanf("%2d").should == [12]
- "123".scanf("%2u").should == [12]
- "123".scanf("%2o").should == [10]
- "123".scanf("%2x").should == [18]
- "123".scanf("%2i").should == [12]
- "0123".scanf("%2i").should == [1]
- "123".scanf("%2f").should == [12.0]
- "0X123".scanf("%2i").should == [0]
- "0X123".scanf("%3i").should == [1]
- "0X123".scanf("%4i").should == [18]
- end
-
- it "returns an empty array when a wrong specifier is passed" do
- "hello world".scanf("%a").should == []
- "123".scanf("%1").should == []
- "123".scanf("abc").should == []
- "123".scanf(:d).should == []
- end
- end
-
- describe "String#scanf with block" do
- it_behaves_like :scanf_string_block_scanf, :scanf
- end
-end
diff --git a/spec/ruby/library/scanf/string/shared/block_scanf.rb b/spec/ruby/library/scanf/string/shared/block_scanf.rb
deleted file mode 100644
index 25ab3f442a..0000000000
--- a/spec/ruby/library/scanf/string/shared/block_scanf.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'scanf'
-
-describe :scanf_string_block_scanf, shared: true do
- it "passes each match to the block as an array" do
- a = []
- "hello world".send(@method, "%s%s"){|w| a << w}
- a.should == [["hello", "world"]]
- end
-
- it "keeps scanning the input and cycling back to the beginning of the input string" do
- a = []
- "hello world".send(@method, "%s"){|w| a << w}
- a.should == [["hello"], ["world"]]
-
- string = "123 abc 456 def 789 ghi"
- s = string.send(@method, "%d%s"){|num,str| [num * 2, str.upcase]}
- s.should == [[246, "ABC"], [912, "DEF"], [1578, "GHI"]]
- end
-
- it "returns an empty array when a wrong specifier is passed" do
- a = []
- "hello world".send(@method, "%z"){|w| a << w}
- a.empty?.should be_true
- end
-end
diff --git a/spec/ruby/library/set/compare_by_identity_spec.rb b/spec/ruby/library/set/compare_by_identity_spec.rb
index 9ed1602189..602d1e758e 100644
--- a/spec/ruby/library/set/compare_by_identity_spec.rb
+++ b/spec/ruby/library/set/compare_by_identity_spec.rb
@@ -5,7 +5,7 @@ describe "Set#compare_by_identity" do
it "compares its members by identity" do
a = "a"
b1 = "b"
- b2 = "b"
+ b2 = b1.dup
set = Set.new
set.compare_by_identity
diff --git a/spec/ruby/library/set/comparison_spec.rb b/spec/ruby/library/set/comparison_spec.rb
new file mode 100644
index 0000000000..ddcfbae0af
--- /dev/null
+++ b/spec/ruby/library/set/comparison_spec.rb
@@ -0,0 +1,27 @@
+require_relative '../../spec_helper'
+require 'set'
+
+describe "Set#<=>" do
+ it "returns 0 if the sets are equal" do
+ (Set[] <=> Set[]).should == 0
+ (Set[:a, :b, :c] <=> Set[:a, :b, :c]).should == 0
+ end
+
+ it "returns -1 if the set is a proper subset of the other set" do
+ (Set[] <=> Set[1]).should == -1
+ (Set[1, 2] <=> Set[1, 2, 3]).should == -1
+ end
+
+ it "returns +1 if the set is a proper superset of other set" do
+ (Set[1] <=> Set[]).should == +1
+ (Set[1, 2, 3] <=> Set[1, 2]).should == +1
+ end
+
+ it "returns nil if the set has unique elements" do
+ (Set[1, 2, 3] <=> Set[:a, :b, :c]).should be_nil
+ end
+
+ it "returns nil when the argument is not set-like" do
+ (Set[] <=> false).should be_nil
+ end
+end
diff --git a/spec/ruby/library/set/divide_spec.rb b/spec/ruby/library/set/divide_spec.rb
index fdd8cd9622..998a1b292c 100644
--- a/spec/ruby/library/set/divide_spec.rb
+++ b/spec/ruby/library/set/divide_spec.rb
@@ -13,11 +13,11 @@ describe "Set#divide" do
ret.sort.should == ["five", "four", "one", "three", "two"]
end
- # BUG: Does not raise a LocalJumpError, but a NoMethodError
- #
- # it "raises a LocalJumpError when not passed a block" do
- # lambda { Set[1].divide }.should raise_error(LocalJumpError)
- # end
+ it "returns an enumerator when not passed a block" do
+ ret = Set[1, 2, 3, 4].divide
+ ret.should be_kind_of(Enumerator)
+ ret.each(&:even?).should == Set[Set[1, 3], Set[2, 4]]
+ end
end
describe "Set#divide when passed a block with an arity of 2" do
@@ -31,4 +31,29 @@ describe "Set#divide when passed a block with an arity of 2" do
Set[1, 2].divide { |x, y| ret << [x, y] }
ret.sort.should == [[1, 1], [1, 2], [2, 1], [2, 2]]
end
+
+ it "returns an enumerator when not passed a block" do
+ ret = Set[1, 2, 3, 4].divide
+ ret.should be_kind_of(Enumerator)
+ ret.each { |a, b| (a + b).even? }.should == Set[Set[1, 3], Set[2, 4]]
+ end
+end
+
+describe "Set#divide when passed a block with an arity of > 2" do
+ it "only uses the first element if the arity > 2" do
+ set = Set["one", "two", "three", "four", "five"].divide do |x, y, z|
+ y.should be_nil
+ z.should be_nil
+ x.length
+ end
+ set.map { |x| x.to_a.sort }.sort.should == [["five", "four"], ["one", "two"], ["three"]]
+ end
+
+ it "only uses the first element if the arity = -1" do
+ set = Set["one", "two", "three", "four", "five"].divide do |*xs|
+ xs.size.should == 1
+ xs.first.length
+ end
+ set.map { |x| x.to_a.sort }.sort.should == [["five", "four"], ["one", "two"], ["three"]]
+ end
end
diff --git a/spec/ruby/library/set/each_spec.rb b/spec/ruby/library/set/each_spec.rb
index 9bb5ead03a..44e185a4da 100644
--- a/spec/ruby/library/set/each_spec.rb
+++ b/spec/ruby/library/set/each_spec.rb
@@ -18,6 +18,7 @@ describe "Set#each" do
it "returns an Enumerator when not passed a block" do
enum = @set.each
+ enum.should be_an_instance_of(Enumerator)
ret = []
enum.each { |x| ret << x }
diff --git a/spec/ruby/library/set/enumerable/to_set_spec.rb b/spec/ruby/library/set/enumerable/to_set_spec.rb
index 3790d8deee..b2d850515b 100644
--- a/spec/ruby/library/set/enumerable/to_set_spec.rb
+++ b/spec/ruby/library/set/enumerable/to_set_spec.rb
@@ -7,14 +7,6 @@ describe "Enumerable#to_set" do
{a: 1, b: 2}.to_set.should == Set[[:b, 2], [:a, 1]]
end
- ruby_version_is ''...'3.0' do
- it "allows passing an alternate class for Set" do
- sorted_set = [1, 2, 3].to_set(SortedSet)
- sorted_set.should == SortedSet[1, 2, 3]
- sorted_set.instance_of?(SortedSet).should == true
- end
- end
-
it "passes down passed blocks" do
[1, 2, 3].to_set { |x| x * x }.should == Set[1, 4, 9]
end
diff --git a/spec/ruby/library/set/filter_spec.rb b/spec/ruby/library/set/filter_spec.rb
index a4dfe70d52..779254ad68 100644
--- a/spec/ruby/library/set/filter_spec.rb
+++ b/spec/ruby/library/set/filter_spec.rb
@@ -1,8 +1,6 @@
require_relative '../../spec_helper'
require_relative 'shared/select'
-ruby_version_is "2.6" do
- describe "Set#filter!" do
- it_behaves_like :set_select_bang, :filter!
- end
+describe "Set#filter!" do
+ it_behaves_like :set_select_bang, :filter!
end
diff --git a/spec/ruby/library/set/flatten_spec.rb b/spec/ruby/library/set/flatten_spec.rb
index 4ac83ea825..51b58d6439 100644
--- a/spec/ruby/library/set/flatten_spec.rb
+++ b/spec/ruby/library/set/flatten_spec.rb
@@ -1,6 +1,7 @@
require_relative '../../spec_helper'
require_relative 'fixtures/set_like'
require 'set'
+set_version = defined?(Set::VERSION) ? Set::VERSION : '1.0.0'
describe "Set#flatten" do
it "returns a copy of self with each included Set flattened" do
@@ -45,9 +46,11 @@ describe "Set#flatten!" do
-> { set.flatten! }.should raise_error(ArgumentError)
end
- context "when Set contains a Set-like object" do
- it "flattens self, including Set-like objects" do
- Set[SetSpecs::SetLike.new([1])].flatten!.should == Set[1]
+ version_is(set_version, ""..."1.1.0") do #ruby_version_is ""..."3.3" do
+ context "when Set contains a Set-like object" do
+ it "flattens self, including Set-like objects" do
+ Set[SetSpecs::SetLike.new([1])].flatten!.should == Set[1]
+ end
end
end
end
diff --git a/spec/ruby/library/set/initialize_clone_spec.rb b/spec/ruby/library/set/initialize_clone_spec.rb
new file mode 100644
index 0000000000..bda42cd6e8
--- /dev/null
+++ b/spec/ruby/library/set/initialize_clone_spec.rb
@@ -0,0 +1,16 @@
+require_relative '../../spec_helper'
+require 'set'
+
+describe "Set#initialize_clone" do
+ # See https://bugs.ruby-lang.org/issues/14266
+ it "does not freeze the new Set when called from clone(freeze: false)" do
+ set1 = Set[1, 2]
+ set1.freeze
+ set2 = set1.clone(freeze: false)
+ set1.frozen?.should == true
+ set2.frozen?.should == false
+ set2.add 3
+ set1.should == Set[1, 2]
+ set2.should == Set[1, 2, 3]
+ end
+end
diff --git a/spec/ruby/library/set/join_spec.rb b/spec/ruby/library/set/join_spec.rb
new file mode 100644
index 0000000000..3f511a84e4
--- /dev/null
+++ b/spec/ruby/library/set/join_spec.rb
@@ -0,0 +1,29 @@
+require_relative '../../spec_helper'
+require 'set'
+
+describe "Set#join" do
+ it "returns an empty string if the Set is empty" do
+ Set[].join.should == ''
+ end
+
+ it "returns a new string formed by joining elements after conversion" do
+ set = Set[:a, :b, :c]
+ set.join.should == "abc"
+ end
+
+ it "does not separate elements when the passed separator is nil" do
+ set = Set[:a, :b, :c]
+ set.join(nil).should == "abc"
+ end
+
+ it "returns a string formed by concatenating each element separated by the separator" do
+ set = Set[:a, :b, :c]
+ set.join(' | ').should == "a | b | c"
+ end
+
+ it "calls #to_a to convert the Set in to an Array" do
+ set = Set[:a, :b, :c]
+ set.should_receive(:to_a).and_return([:a, :b, :c])
+ set.join.should == "abc"
+ end
+end
diff --git a/spec/ruby/library/set/pretty_print_spec.rb b/spec/ruby/library/set/pretty_print_spec.rb
index f2392e6968..ea9ead0df8 100644
--- a/spec/ruby/library/set/pretty_print_spec.rb
+++ b/spec/ruby/library/set/pretty_print_spec.rb
@@ -1,17 +1,19 @@
require_relative '../../spec_helper'
require 'set'
-describe "Set#pretty_print" do
- it "passes the 'pretty print' representation of self to the pretty print writer" do
- pp = mock("PrettyPrint")
- set = Set[1, 2, 3]
+ruby_version_is ""..."3.1" do
+ describe "Set#pretty_print" do
+ it "passes the 'pretty print' representation of self to the pretty print writer" do
+ pp = mock("PrettyPrint")
+ set = Set[1, 2, 3]
- pp.should_receive(:text).with("#<Set: {")
- pp.should_receive(:text).with("}>")
+ pp.should_receive(:text).with("#<Set: {")
+ pp.should_receive(:text).with("}>")
- pp.should_receive(:nest).with(1).and_yield
- pp.should_receive(:seplist).with(set)
+ pp.should_receive(:nest).with(1).and_yield
+ pp.should_receive(:seplist).with(set)
- set.pretty_print(pp)
+ set.pretty_print(pp)
+ end
end
end
diff --git a/spec/ruby/library/set/proper_subset_spec.rb b/spec/ruby/library/set/proper_subset_spec.rb
index 1f496a6199..6b51dedc9f 100644
--- a/spec/ruby/library/set/proper_subset_spec.rb
+++ b/spec/ruby/library/set/proper_subset_spec.rb
@@ -1,6 +1,7 @@
require_relative '../../spec_helper'
require_relative 'fixtures/set_like'
require 'set'
+set_version = defined?(Set::VERSION) ? Set::VERSION : '1.0.0'
describe "Set#proper_subset?" do
before :each do
@@ -33,9 +34,11 @@ describe "Set#proper_subset?" do
-> { Set[].proper_subset?(Object.new) }.should raise_error(ArgumentError)
end
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a proper subset of" do
- Set[1, 2, 3].proper_subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
+ version_is(set_version, ""..."1.1.0") do #ruby_version_is ""..."3.3" do
+ context "when comparing to a Set-like object" do
+ it "returns true if passed a Set-like object that self is a proper subset of" do
+ Set[1, 2, 3].proper_subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
+ end
end
end
end
diff --git a/spec/ruby/library/set/set_spec.rb b/spec/ruby/library/set/set_spec.rb
new file mode 100644
index 0000000000..2a4edc6dfc
--- /dev/null
+++ b/spec/ruby/library/set/set_spec.rb
@@ -0,0 +1,12 @@
+require_relative '../../spec_helper'
+
+describe 'Set' do
+ ruby_version_is '3.2' do
+ it 'is available without explicit requiring' do
+ output = ruby_exe(<<~RUBY, options: '--disable-gems', args: '2>&1')
+ puts Set.new([1, 2, 3])
+ RUBY
+ output.chomp.should == "#<Set: {1, 2, 3}>"
+ end
+ end
+end
diff --git a/spec/ruby/library/set/shared/inspect.rb b/spec/ruby/library/set/shared/inspect.rb
index 69fbdd12f6..adb6ddb4c9 100644
--- a/spec/ruby/library/set/shared/inspect.rb
+++ b/spec/ruby/library/set/shared/inspect.rb
@@ -1,4 +1,4 @@
-describe "set_inspect", shared: true do
+describe :set_inspect, shared: true do
it "returns a String representation of self" do
Set[].send(@method).should be_kind_of(String)
Set[nil, false, true].send(@method).should be_kind_of(String)
@@ -7,9 +7,19 @@ describe "set_inspect", shared: true do
Set[:a, "b", Set[?c]].send(@method).should be_kind_of(String)
end
- it "correctly handles self-references" do
- (set = Set[]) << set
- set.send(@method).should be_kind_of(String)
- set.send(@method).should include("#<Set: {...}>")
+ it "does include the elements of the set" do
+ Set["1"].send(@method).should == '#<Set: {"1"}>'
+ end
+
+ it "puts spaces between the elements" do
+ Set["1", "2"].send(@method).should include('", "')
+ end
+
+ it "correctly handles cyclic-references" do
+ set1 = Set[]
+ set2 = Set[set1]
+ set1 << set2
+ set1.send(@method).should be_kind_of(String)
+ set1.send(@method).should include("#<Set: {...}>")
end
end
diff --git a/spec/ruby/library/set/sortedset/add_spec.rb b/spec/ruby/library/set/sortedset/add_spec.rb
deleted file mode 100644
index 4f3bb252e1..0000000000
--- a/spec/ruby/library/set/sortedset/add_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
- require_relative 'shared/add'
-
- describe "SortedSet#add" do
- it_behaves_like :sorted_set_add, :add
-
- it "takes only values which responds <=>" do
- obj = mock('no_comparison_operator')
- obj.stub!(:respond_to?).with(:<=>).and_return(false)
- -> { SortedSet["hello"].add(obj) }.should raise_error(ArgumentError)
- end
-
- it "raises on incompatible <=> comparison" do
- # Use #to_a here as elements are sorted only when needed.
- # Therefore the <=> incompatibility is only noticed on sorting.
- -> { SortedSet['1', '2'].add(3).to_a }.should raise_error(ArgumentError)
- end
- end
-
- describe "SortedSet#add?" do
- before :each do
- @set = SortedSet.new
- end
-
- it "adds the passed Object to self" do
- @set.add?("cat")
- @set.should include("cat")
- end
-
- it "returns self when the Object has not yet been added to self" do
- @set.add?("cat").should equal(@set)
- end
-
- it "returns nil when the Object has already been added to self" do
- @set.add?("cat")
- @set.add?("cat").should be_nil
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/append_spec.rb b/spec/ruby/library/set/sortedset/append_spec.rb
deleted file mode 100644
index d72d70b21f..0000000000
--- a/spec/ruby/library/set/sortedset/append_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
- require_relative 'shared/add'
-
- describe "SortedSet#<<" do
- it_behaves_like :sorted_set_add, :<<
- end
-end
diff --git a/spec/ruby/library/set/sortedset/case_equality_spec.rb b/spec/ruby/library/set/sortedset/case_equality_spec.rb
deleted file mode 100644
index d7c296b626..0000000000
--- a/spec/ruby/library/set/sortedset/case_equality_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/include'
- require 'set'
-
- describe "SortedSet#===" do
- it_behaves_like :sorted_set_include, :===
- end
-end
diff --git a/spec/ruby/library/set/sortedset/classify_spec.rb b/spec/ruby/library/set/sortedset/classify_spec.rb
deleted file mode 100644
index 4011e58b82..0000000000
--- a/spec/ruby/library/set/sortedset/classify_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#classify" do
- before :each do
- @set = SortedSet["one", "two", "three", "four"]
- end
-
- it "yields each Object in self in sorted order" do
- res = []
- @set.classify { |x| res << x }
- res.should == ["one", "two", "three", "four"].sort
- end
-
- it "returns an Enumerator when passed no block" do
- enum = @set.classify
- enum.should be_an_instance_of(Enumerator)
-
- classified = enum.each { |x| x.length }
- classified.should == { 3 => SortedSet["one", "two"], 4 => SortedSet["four"], 5 => SortedSet["three"] }
- end
-
- it "classifies the Objects in self based on the block's return value" do
- classified = @set.classify { |x| x.length }
- classified.should == { 3 => SortedSet["one", "two"], 4 => SortedSet["four"], 5 => SortedSet["three"] }
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/clear_spec.rb b/spec/ruby/library/set/sortedset/clear_spec.rb
deleted file mode 100644
index 879aa824d8..0000000000
--- a/spec/ruby/library/set/sortedset/clear_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#clear" do
- before :each do
- @set = SortedSet["one", "two", "three", "four"]
- end
-
- it "removes all elements from self" do
- @set.clear
- @set.should be_empty
- end
-
- it "returns self" do
- @set.clear.should equal(@set)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/collect_spec.rb b/spec/ruby/library/set/sortedset/collect_spec.rb
deleted file mode 100644
index 0674f0d130..0000000000
--- a/spec/ruby/library/set/sortedset/collect_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
- require_relative 'shared/collect'
-
- describe "SortedSet#collect!" do
- it_behaves_like :sorted_set_collect_bang, :collect!
- end
-end
diff --git a/spec/ruby/library/set/sortedset/constructor_spec.rb b/spec/ruby/library/set/sortedset/constructor_spec.rb
deleted file mode 100644
index 31f30fd892..0000000000
--- a/spec/ruby/library/set/sortedset/constructor_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet[]" do
- it "returns a new SortedSet populated with the passed Objects" do
- set = SortedSet[1, 2, 3]
-
- set.instance_of?(SortedSet).should be_true
- set.size.should eql(3)
-
- set.should include(1)
- set.should include(2)
- set.should include(3)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/delete_if_spec.rb b/spec/ruby/library/set/sortedset/delete_if_spec.rb
deleted file mode 100644
index 787639ae12..0000000000
--- a/spec/ruby/library/set/sortedset/delete_if_spec.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#delete_if" do
- before :each do
- @set = SortedSet["one", "two", "three"]
- end
-
- it "yields each Object in self in sorted order" do
- ret = []
- @set.delete_if { |x| ret << x }
- ret.should == ["one", "two", "three"].sort
- end
-
- it "deletes every element from self for which the passed block returns true" do
- @set.delete_if { |x| x.size == 3 }
- @set.size.should eql(1)
-
- @set.should_not include("one")
- @set.should_not include("two")
- @set.should include("three")
- end
-
- it "returns self" do
- @set.delete_if { |x| x }.should equal(@set)
- end
-
- it "returns an Enumerator when passed no block" do
- enum = @set.delete_if
- enum.should be_an_instance_of(Enumerator)
-
- enum.each { |x| x.size == 3 }
-
- @set.should_not include("one")
- @set.should_not include("two")
- @set.should include("three")
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/delete_spec.rb b/spec/ruby/library/set/sortedset/delete_spec.rb
deleted file mode 100644
index 0e2a6accf3..0000000000
--- a/spec/ruby/library/set/sortedset/delete_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#delete" do
- before :each do
- @set = SortedSet["a", "b", "c"]
- end
-
- it "deletes the passed Object from self" do
- @set.delete("a")
- @set.should_not include("a")
- end
-
- it "returns self" do
- @set.delete("a").should equal(@set)
- @set.delete("x").should equal(@set)
- end
- end
-
- describe "SortedSet#delete?" do
- before :each do
- @set = SortedSet["a", "b", "c"]
- end
-
- it "deletes the passed Object from self" do
- @set.delete?("a")
- @set.should_not include("a")
- end
-
- it "returns self when the passed Object is in self" do
- @set.delete?("a").should equal(@set)
- end
-
- it "returns nil when the passed Object is not in self" do
- @set.delete?("x").should be_nil
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/difference_spec.rb b/spec/ruby/library/set/sortedset/difference_spec.rb
deleted file mode 100644
index fb064bdff9..0000000000
--- a/spec/ruby/library/set/sortedset/difference_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
- require_relative 'shared/difference'
-
- describe "SortedSet#difference" do
- it_behaves_like :sorted_set_difference, :difference
- end
-end
diff --git a/spec/ruby/library/set/sortedset/divide_spec.rb b/spec/ruby/library/set/sortedset/divide_spec.rb
deleted file mode 100644
index 31ab6037e4..0000000000
--- a/spec/ruby/library/set/sortedset/divide_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#divide" do
- it "divides self into a set of subsets based on the blocks return values" do
- set = SortedSet["one", "two", "three", "four", "five"].divide { |x| x.length }
- set.map { |x| x.to_a }.to_a.sort.should == [["five", "four"], ["one", "two"], ["three"]]
- end
-
- it "yields each Object in self in sorted order" do
- ret = []
- SortedSet["one", "two", "three", "four", "five"].divide { |x| ret << x }
- ret.should == ["one", "two", "three", "four", "five"].sort
- end
-
- # BUG: Does not raise a LocalJumpError, but a NoMethodError
- #
- # it "raises a LocalJumpError when not passed a block" do
- # lambda { SortedSet[1].divide }.should raise_error(LocalJumpError)
- # end
- end
-
- describe "SortedSet#divide when passed a block with an arity of 2" do
- it "divides self into a set of subsets based on the blocks return values" do
- set = SortedSet[1, 3, 4, 6, 9, 10, 11].divide { |x, y| (x - y).abs == 1 }
- set.map { |x| x.to_a }.to_a.sort.should == [[1], [3, 4], [6], [9, 10, 11]]
- end
-
- it "yields each two Objects to the block" do
- ret = []
- SortedSet[1, 2].divide { |x, y| ret << [x, y] }
- ret.should == [[1, 1], [1, 2], [2, 1], [2, 2]]
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/each_spec.rb b/spec/ruby/library/set/sortedset/each_spec.rb
deleted file mode 100644
index 79d8aee223..0000000000
--- a/spec/ruby/library/set/sortedset/each_spec.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#each" do
- before :each do
- @set = SortedSet[1, 2, 3]
- end
-
- it "yields each Object in self in sorted order" do
- ret = []
- SortedSet["one", "two", "three"].each { |x| ret << x }
- ret.should == ["one", "two", "three"].sort
- end
-
- it "returns self" do
- @set.each { |x| x }.should equal(@set)
- end
-
- it "returns an Enumerator when not passed a block" do
- enum = @set.each
-
- ret = []
- enum.each { |x| ret << x }
- ret.sort.should == [1, 2, 3]
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/empty_spec.rb b/spec/ruby/library/set/sortedset/empty_spec.rb
deleted file mode 100644
index 2e52c3e81a..0000000000
--- a/spec/ruby/library/set/sortedset/empty_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#empty?" do
- it "returns true if self is empty" do
- SortedSet[].empty?.should be_true
- SortedSet[1].empty?.should be_false
- SortedSet[1,2,3].empty?.should be_false
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/eql_spec.rb b/spec/ruby/library/set/sortedset/eql_spec.rb
deleted file mode 100644
index 050464994b..0000000000
--- a/spec/ruby/library/set/sortedset/eql_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#eql?" do
- it "returns true when the passed argument is a SortedSet and contains the same elements" do
- SortedSet[].should eql(SortedSet[])
- SortedSet[1, 2, 3].should eql(SortedSet[1, 2, 3])
- SortedSet[1, 2, 3].should eql(SortedSet[3, 2, 1])
-
- # SortedSet["a", :b, ?c].should eql(SortedSet[?c, :b, "a"])
-
- SortedSet[1, 2, 3].should_not eql(SortedSet[1.0, 2, 3])
- SortedSet[1, 2, 3].should_not eql(SortedSet[2, 3])
- SortedSet[1, 2, 3].should_not eql(SortedSet[])
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/equal_value_spec.rb b/spec/ruby/library/set/sortedset/equal_value_spec.rb
deleted file mode 100644
index 30422f5b95..0000000000
--- a/spec/ruby/library/set/sortedset/equal_value_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#==" do
- it "returns true when the passed Object is a SortedSet and self and the Object contain the same elements" do
- SortedSet[].should == SortedSet[]
- SortedSet[1, 2, 3].should == SortedSet[1, 2, 3]
- SortedSet["1", "2", "3"].should == SortedSet["1", "2", "3"]
-
- SortedSet[1, 2, 3].should_not == SortedSet[1.0, 2, 3]
- SortedSet[1, 2, 3].should_not == [1, 2, 3]
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/exclusion_spec.rb b/spec/ruby/library/set/sortedset/exclusion_spec.rb
deleted file mode 100644
index 1967dfbfa6..0000000000
--- a/spec/ruby/library/set/sortedset/exclusion_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#^" do
- before :each do
- @set = SortedSet[1, 2, 3, 4]
- end
-
- it "returns a new SortedSet containing elements that are not in both self and the passed Enumerable" do
- (@set ^ SortedSet[3, 4, 5]).should == SortedSet[1, 2, 5]
- (@set ^ [3, 4, 5]).should == SortedSet[1, 2, 5]
- end
-
- it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set ^ 3 }.should raise_error(ArgumentError)
- -> { @set ^ Object.new }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/filter_spec.rb b/spec/ruby/library/set/sortedset/filter_spec.rb
deleted file mode 100644
index c6d881de67..0000000000
--- a/spec/ruby/library/set/sortedset/filter_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/select'
- require 'set'
-
- ruby_version_is "2.6" do
- describe "SortedSet#filter!" do
- it_behaves_like :sorted_set_select_bang, :filter!
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/flatten_merge_spec.rb b/spec/ruby/library/set/sortedset/flatten_merge_spec.rb
deleted file mode 100644
index 0d67cb331e..0000000000
--- a/spec/ruby/library/set/sortedset/flatten_merge_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#flatten_merge" do
- it "is protected" do
- SortedSet.should have_protected_instance_method("flatten_merge")
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/flatten_spec.rb b/spec/ruby/library/set/sortedset/flatten_spec.rb
deleted file mode 100644
index e83ad1044a..0000000000
--- a/spec/ruby/library/set/sortedset/flatten_spec.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- # Note: Flatten make little sens on sorted sets, because SortedSets are not (by default)
- # comparable. For a SortedSet to be both valid and nested, we need to define a comparison operator:
- module SortedSet_FlattenSpecs
- class ComparableSortedSet < SortedSet
- def <=>(other)
- return puts "#{other} vs #{self}" unless other.is_a?(ComparableSortedSet)
- to_a <=> other.to_a
- end
- end
- end
-
- describe "SortedSet#flatten" do
- it "returns a copy of self with each included SortedSet flattened" do
- klass = SortedSet_FlattenSpecs::ComparableSortedSet
- set = klass[klass[1,2], klass[3,4], klass[5,6,7], klass[8]]
- flattened_set = set.flatten
-
- flattened_set.should_not equal(set)
- flattened_set.should == klass[1, 2, 3, 4, 5, 6, 7, 8]
- end
- end
-
- describe "SortedSet#flatten!" do
- it "flattens self" do
- klass = SortedSet_FlattenSpecs::ComparableSortedSet
- set = klass[klass[1,2], klass[3,4], klass[5,6,7], klass[8]]
- set.flatten!
- set.should == klass[1, 2, 3, 4, 5, 6, 7, 8]
- end
-
- it "returns self when self was modified" do
- klass = SortedSet_FlattenSpecs::ComparableSortedSet
- set = klass[klass[1,2], klass[3,4]]
- set.flatten!.should equal(set)
- end
-
- it "returns nil when self was not modified" do
- set = SortedSet[1, 2, 3, 4]
- set.flatten!.should be_nil
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/hash_spec.rb b/spec/ruby/library/set/sortedset/hash_spec.rb
deleted file mode 100644
index 40676de7fc..0000000000
--- a/spec/ruby/library/set/sortedset/hash_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#hash" do
- it "is static" do
- SortedSet[].hash.should == SortedSet[].hash
- SortedSet[1, 2, 3].hash.should == SortedSet[1, 2, 3].hash
- SortedSet["a", "b", "c"].hash.should == SortedSet["c", "b", "a"].hash
-
- SortedSet[].hash.should_not == SortedSet[1, 2, 3].hash
- SortedSet[1, 2, 3].hash.should_not == SortedSet["a", "b", "c"].hash
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/include_spec.rb b/spec/ruby/library/set/sortedset/include_spec.rb
deleted file mode 100644
index ec2ad987d5..0000000000
--- a/spec/ruby/library/set/sortedset/include_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/include'
- require 'set'
-
- describe "SortedSet#include?" do
- it_behaves_like :sorted_set_include, :include?
- end
-end
diff --git a/spec/ruby/library/set/sortedset/initialize_spec.rb b/spec/ruby/library/set/sortedset/initialize_spec.rb
deleted file mode 100644
index 4d1707b72a..0000000000
--- a/spec/ruby/library/set/sortedset/initialize_spec.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#initialize" do
- it "is private" do
- SortedSet.should have_private_instance_method("initialize")
- end
-
- it "adds all elements of the passed Enumerable to self" do
- s = SortedSet.new([1, 2, 3])
- s.size.should eql(3)
- s.should include(1)
- s.should include(2)
- s.should include(3)
- end
-
- it "preprocesses all elements by a passed block before adding to self" do
- s = SortedSet.new([1, 2, 3]) { |x| x * x }
- s.size.should eql(3)
- s.should include(1)
- s.should include(4)
- s.should include(9)
- end
-
- it "raises on incompatible <=> comparison" do
- # Use #to_a here as elements are sorted only when needed.
- # Therefore the <=> incompatibility is only noticed on sorting.
- -> { SortedSet.new(['00', nil]).to_a }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/inspect_spec.rb b/spec/ruby/library/set/sortedset/inspect_spec.rb
deleted file mode 100644
index 1c4dd9e6e2..0000000000
--- a/spec/ruby/library/set/sortedset/inspect_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#inspect" do
- it "returns a String representation of self" do
- SortedSet[].inspect.should be_kind_of(String)
- SortedSet[1, 2, 3].inspect.should be_kind_of(String)
- SortedSet["1", "2", "3"].inspect.should be_kind_of(String)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/intersection_spec.rb b/spec/ruby/library/set/sortedset/intersection_spec.rb
deleted file mode 100644
index 6daa271b73..0000000000
--- a/spec/ruby/library/set/sortedset/intersection_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/intersection'
- require 'set'
-
- describe "SortedSet#intersection" do
- it_behaves_like :sorted_set_intersection, :intersection
- end
-
- describe "SortedSet#&" do
- it_behaves_like :sorted_set_intersection, :&
- end
-end
diff --git a/spec/ruby/library/set/sortedset/keep_if_spec.rb b/spec/ruby/library/set/sortedset/keep_if_spec.rb
deleted file mode 100644
index 3e5f3bbc47..0000000000
--- a/spec/ruby/library/set/sortedset/keep_if_spec.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#keep_if" do
- before :each do
- @set = SortedSet["one", "two", "three"]
- end
-
- it "yields each Object in self in sorted order" do
- ret = []
- @set.keep_if { |x| ret << x }
- ret.should == ["one", "two", "three"].sort
- end
-
- it "keeps every element from self for which the passed block returns true" do
- @set.keep_if { |x| x.size != 3 }
- @set.to_a.should == ["three"]
- end
-
- it "returns self" do
- @set.keep_if {}.should equal(@set)
- end
-
- it "returns an Enumerator when passed no block" do
- enum = @set.keep_if
- enum.should be_an_instance_of(Enumerator)
-
- enum.each { |x| x.size != 3 }
- @set.to_a.should == ["three"]
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/length_spec.rb b/spec/ruby/library/set/sortedset/length_spec.rb
deleted file mode 100644
index de6791f6bb..0000000000
--- a/spec/ruby/library/set/sortedset/length_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/length'
- require 'set'
-
- describe "SortedSet#length" do
- it_behaves_like :sorted_set_length, :length
- end
-end
diff --git a/spec/ruby/library/set/sortedset/map_spec.rb b/spec/ruby/library/set/sortedset/map_spec.rb
deleted file mode 100644
index 4971b9529b..0000000000
--- a/spec/ruby/library/set/sortedset/map_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
- require_relative 'shared/collect'
-
- describe "SortedSet#map!" do
- it_behaves_like :sorted_set_collect_bang, :map!
- end
-end
diff --git a/spec/ruby/library/set/sortedset/member_spec.rb b/spec/ruby/library/set/sortedset/member_spec.rb
deleted file mode 100644
index 142b09b651..0000000000
--- a/spec/ruby/library/set/sortedset/member_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/include'
- require 'set'
-
- describe "SortedSet#member?" do
- it_behaves_like :sorted_set_include, :member?
- end
-end
diff --git a/spec/ruby/library/set/sortedset/merge_spec.rb b/spec/ruby/library/set/sortedset/merge_spec.rb
deleted file mode 100644
index c4cbc6d2b4..0000000000
--- a/spec/ruby/library/set/sortedset/merge_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#merge" do
- it "adds the elements of the passed Enumerable to self" do
- SortedSet["a", "b"].merge(SortedSet["b", "c", "d"]).should == SortedSet["a", "b", "c", "d"]
- SortedSet[1, 2].merge([3, 4]).should == SortedSet[1, 2, 3, 4]
- end
-
- it "returns self" do
- set = SortedSet[1, 2]
- set.merge([3, 4]).should equal(set)
- end
-
- it "raises an ArgumentError when passed a non-Enumerable" do
- -> { SortedSet[1, 2].merge(1) }.should raise_error(ArgumentError)
- -> { SortedSet[1, 2].merge(Object.new) }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/minus_spec.rb b/spec/ruby/library/set/sortedset/minus_spec.rb
deleted file mode 100644
index d6abc5e204..0000000000
--- a/spec/ruby/library/set/sortedset/minus_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
- require_relative 'shared/difference'
-
- describe "SortedSet#-" do
- it_behaves_like :sorted_set_difference, :-
- end
-end
diff --git a/spec/ruby/library/set/sortedset/plus_spec.rb b/spec/ruby/library/set/sortedset/plus_spec.rb
deleted file mode 100644
index 13fc873ad1..0000000000
--- a/spec/ruby/library/set/sortedset/plus_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/union'
- require 'set'
-
- describe "SortedSet#+" do
- it_behaves_like :sorted_set_union, :+
- end
-end
diff --git a/spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb b/spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb
deleted file mode 100644
index e97f509406..0000000000
--- a/spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#pretty_print_cycle" do
- it "passes the 'pretty print' representation of a self-referencing SortedSet to the pretty print writer" do
- pp = mock("PrettyPrint")
- pp.should_receive(:text).with("#<SortedSet: {...}>")
- SortedSet[1, 2, 3].pretty_print_cycle(pp)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/pretty_print_spec.rb b/spec/ruby/library/set/sortedset/pretty_print_spec.rb
deleted file mode 100644
index a8088bf797..0000000000
--- a/spec/ruby/library/set/sortedset/pretty_print_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#pretty_print" do
- it "passes the 'pretty print' representation of self to the pretty print writer" do
- pp = mock("PrettyPrint")
- set = SortedSet[1, 2, 3]
-
- pp.should_receive(:text).with("#<SortedSet: {")
- pp.should_receive(:text).with("}>")
-
- pp.should_receive(:nest).with(1).and_yield
- pp.should_receive(:seplist).with(set)
-
- set.pretty_print(pp)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/proper_subset_spec.rb b/spec/ruby/library/set/sortedset/proper_subset_spec.rb
deleted file mode 100644
index 34fb89d13d..0000000000
--- a/spec/ruby/library/set/sortedset/proper_subset_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#proper_subset?" do
- before :each do
- @set = SortedSet[1, 2, 3, 4]
- end
-
- it "returns true if passed a SortedSet that self is a proper subset of" do
- SortedSet[].proper_subset?(@set).should be_true
- SortedSet[].proper_subset?(SortedSet[1, 2, 3]).should be_true
- SortedSet[].proper_subset?(SortedSet["a", "b", "c"]).should be_true
-
- SortedSet[1, 2, 3].proper_subset?(@set).should be_true
- SortedSet[1, 3].proper_subset?(@set).should be_true
- SortedSet[1, 2].proper_subset?(@set).should be_true
- SortedSet[1].proper_subset?(@set).should be_true
-
- SortedSet[5].proper_subset?(@set).should be_false
- SortedSet[1, 5].proper_subset?(@set).should be_false
- SortedSet["test"].proper_subset?(@set).should be_false
-
- @set.proper_subset?(@set).should be_false
- SortedSet[].proper_subset?(SortedSet[]).should be_false
- end
-
- it "raises an ArgumentError when passed a non-SortedSet" do
- -> { SortedSet[].proper_subset?([]) }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_subset?(1) }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_subset?("test") }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_subset?(Object.new) }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/proper_superset_spec.rb b/spec/ruby/library/set/sortedset/proper_superset_spec.rb
deleted file mode 100644
index 8b92444f72..0000000000
--- a/spec/ruby/library/set/sortedset/proper_superset_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#proper_superset?" do
- before :each do
- @set = SortedSet[1, 2, 3, 4]
- end
-
- it "returns true if passed a SortedSet that self is a proper superset of" do
- @set.proper_superset?(SortedSet[]).should be_true
- SortedSet[1, 2, 3].proper_superset?(SortedSet[]).should be_true
- SortedSet["a", "b", "c"].proper_superset?(SortedSet[]).should be_true
-
- @set.proper_superset?(SortedSet[1, 2, 3]).should be_true
- @set.proper_superset?(SortedSet[1, 3]).should be_true
- @set.proper_superset?(SortedSet[1, 2]).should be_true
- @set.proper_superset?(SortedSet[1]).should be_true
-
- @set.proper_superset?(SortedSet[5]).should be_false
- @set.proper_superset?(SortedSet[1, 5]).should be_false
- @set.proper_superset?(SortedSet["test"]).should be_false
-
- @set.proper_superset?(@set).should be_false
- SortedSet[].proper_superset?(SortedSet[]).should be_false
- end
-
- it "raises an ArgumentError when passed a non-SortedSet" do
- -> { SortedSet[].proper_superset?([]) }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_superset?(1) }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_superset?("test") }.should raise_error(ArgumentError)
- -> { SortedSet[].proper_superset?(Object.new) }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/reject_spec.rb b/spec/ruby/library/set/sortedset/reject_spec.rb
deleted file mode 100644
index 396b864cc5..0000000000
--- a/spec/ruby/library/set/sortedset/reject_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#reject!" do
- before :each do
- @set = SortedSet["one", "two", "three"]
- end
-
- it "yields each Object in self in sorted order" do
- res = []
- @set.reject! { |x| res << x }
- res.should == ["one", "two", "three"].sort
- end
-
- it "deletes every element from self for which the passed block returns true" do
- @set.reject! { |x| x.size == 3 }
- @set.size.should eql(1)
-
- @set.should_not include("one")
- @set.should_not include("two")
- @set.should include("three")
- end
-
- it "returns self when self was modified" do
- @set.reject! { |x| true }.should equal(@set)
- end
-
- it "returns nil when self was not modified" do
- @set.reject! { |x| false }.should be_nil
- end
-
- it "returns an Enumerator when passed no block" do
- enum = @set.reject!
- enum.should be_an_instance_of(Enumerator)
-
- enum.each { |x| x.size == 3 }
-
- @set.should_not include("one")
- @set.should_not include("two")
- @set.should include("three")
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/replace_spec.rb b/spec/ruby/library/set/sortedset/replace_spec.rb
deleted file mode 100644
index 2900221c01..0000000000
--- a/spec/ruby/library/set/sortedset/replace_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#replace" do
- before :each do
- @set = SortedSet["a", "b", "c"]
- end
-
- it "replaces the contents with other and returns self" do
- @set.replace(SortedSet[1, 2, 3]).should == @set
- @set.should == SortedSet[1, 2, 3]
- end
-
- it "accepts any enumerable as other" do
- @set.replace([1, 2, 3]).should == SortedSet[1, 2, 3]
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/select_spec.rb b/spec/ruby/library/set/sortedset/select_spec.rb
deleted file mode 100644
index fc4c15ee4d..0000000000
--- a/spec/ruby/library/set/sortedset/select_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/select'
- require 'set'
-
- describe "SortedSet#select!" do
- it_behaves_like :sorted_set_select_bang, :select!
- end
-end
diff --git a/spec/ruby/library/set/sortedset/shared/add.rb b/spec/ruby/library/set/sortedset/shared/add.rb
deleted file mode 100644
index 95ef1b090e..0000000000
--- a/spec/ruby/library/set/sortedset/shared/add.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-describe :sorted_set_add, shared: true do
- before :each do
- @set = SortedSet.new
- end
-
- it "adds the passed Object to self" do
- @set.send(@method, "dog")
- @set.should include("dog")
- end
-
- it "returns self" do
- @set.send(@method, "dog").should equal(@set)
- end
-end
diff --git a/spec/ruby/library/set/sortedset/shared/collect.rb b/spec/ruby/library/set/sortedset/shared/collect.rb
deleted file mode 100644
index e53304d427..0000000000
--- a/spec/ruby/library/set/sortedset/shared/collect.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-describe :sorted_set_collect_bang, shared: true do
- before :each do
- @set = SortedSet[1, 2, 3, 4, 5]
- end
-
- it "yields each Object in self in sorted order" do
- res = []
- SortedSet["one", "two", "three"].send(@method) { |x| res << x; x }
- res.should == ["one", "two", "three"].sort
- end
-
- it "returns self" do
- @set.send(@method) { |x| x }.should equal(@set)
- end
-
- it "replaces self with the return values of the block" do
- @set.send(@method) { |x| x * 2 }
- @set.should == SortedSet[2, 4, 6, 8, 10]
- end
-end
diff --git a/spec/ruby/library/set/sortedset/shared/difference.rb b/spec/ruby/library/set/sortedset/shared/difference.rb
deleted file mode 100644
index 688e23a7a7..0000000000
--- a/spec/ruby/library/set/sortedset/shared/difference.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-describe :sorted_set_difference, shared: true do
- before :each do
- @set = SortedSet["a", "b", "c"]
- end
-
- it "returns a new SortedSet containing self's elements excluding the elements in the passed Enumerable" do
- @set.send(@method, SortedSet["a", "b"]).should == SortedSet["c"]
- @set.send(@method, ["b", "c"]).should == SortedSet["a"]
- end
-
- it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set.send(@method, 1) }.should raise_error(ArgumentError)
- -> { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
- end
-end
diff --git a/spec/ruby/library/set/sortedset/shared/include.rb b/spec/ruby/library/set/sortedset/shared/include.rb
deleted file mode 100644
index cd1758819d..0000000000
--- a/spec/ruby/library/set/sortedset/shared/include.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-describe :sorted_set_include, shared: true do
- it "returns true when self contains the passed Object" do
- set = SortedSet["a", "b", "c"]
- set.send(@method, "a").should be_true
- set.send(@method, "e").should be_false
- end
-end
diff --git a/spec/ruby/library/set/sortedset/shared/intersection.rb b/spec/ruby/library/set/sortedset/shared/intersection.rb
deleted file mode 100644
index 045716ad05..0000000000
--- a/spec/ruby/library/set/sortedset/shared/intersection.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-describe :sorted_set_intersection, shared: true do
- before :each do
- @set = SortedSet["a", "b", "c"]
- end
-
- it "returns a new SortedSet containing only elements shared by self and the passed Enumerable" do
- @set.send(@method, SortedSet["b", "c", "d", "e"]).should == SortedSet["b", "c"]
- @set.send(@method, ["b", "c", "d"]).should == SortedSet["b", "c"]
- end
-
- it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set.send(@method, 1) }.should raise_error(ArgumentError)
- -> { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
- end
-end
diff --git a/spec/ruby/library/set/sortedset/shared/length.rb b/spec/ruby/library/set/sortedset/shared/length.rb
deleted file mode 100644
index d1dfee1cff..0000000000
--- a/spec/ruby/library/set/sortedset/shared/length.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-describe :sorted_set_length, shared: true do
- it "returns the number of elements in the set" do
- set = SortedSet["a", "b", "c"]
- set.send(@method).should == 3
- end
-end
diff --git a/spec/ruby/library/set/sortedset/shared/select.rb b/spec/ruby/library/set/sortedset/shared/select.rb
deleted file mode 100644
index e13311eda5..0000000000
--- a/spec/ruby/library/set/sortedset/shared/select.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require_relative '../../../../spec_helper'
-require 'set'
-
-describe :sorted_set_select_bang, shared: true do
- before :each do
- @set = SortedSet["one", "two", "three"]
- end
-
- it "yields each Object in self in sorted order" do
- res = []
- @set.send(@method) { |x| res << x }
- res.should == ["one", "two", "three"].sort
- end
-
- it "keeps every element from self for which the passed block returns true" do
- @set.send(@method) { |x| x.size != 3 }
- @set.to_a.should == ["three"]
- end
-
- it "returns self when self was modified" do
- @set.send(@method) { false }.should equal(@set)
- end
-
- it "returns nil when self was not modified" do
- @set.send(@method) { true }.should be_nil
- end
-
- it "returns an Enumerator when passed no block" do
- enum = @set.send(@method)
- enum.should be_an_instance_of(Enumerator)
-
- enum.each { |x| x.size != 3 }
- @set.to_a.should == ["three"]
- end
-end
diff --git a/spec/ruby/library/set/sortedset/shared/union.rb b/spec/ruby/library/set/sortedset/shared/union.rb
deleted file mode 100644
index 9015bdc8e3..0000000000
--- a/spec/ruby/library/set/sortedset/shared/union.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-describe :sorted_set_union, shared: true do
- before :each do
- @set = SortedSet["a", "b", "c"]
- end
-
- it "returns a new SortedSet containing all elements of self and the passed Enumerable" do
- @set.send(@method, SortedSet["b", "d", "e"]).should == SortedSet["a", "b", "c", "d", "e"]
- @set.send(@method, ["b", "e"]).should == SortedSet["a", "b", "c", "e"]
- end
-
- it "raises an ArgumentError when passed a non-Enumerable" do
- -> { @set.send(@method, 1) }.should raise_error(ArgumentError)
- -> { @set.send(@method, Object.new) }.should raise_error(ArgumentError)
- end
-end
diff --git a/spec/ruby/library/set/sortedset/size_spec.rb b/spec/ruby/library/set/sortedset/size_spec.rb
deleted file mode 100644
index d908b33b53..0000000000
--- a/spec/ruby/library/set/sortedset/size_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/length'
- require 'set'
-
- describe "SortedSet#size" do
- it_behaves_like :sorted_set_length, :size
- end
-end
diff --git a/spec/ruby/library/set/sortedset/sortedset_spec.rb b/spec/ruby/library/set/sortedset/sortedset_spec.rb
new file mode 100644
index 0000000000..67993dee29
--- /dev/null
+++ b/spec/ruby/library/set/sortedset/sortedset_spec.rb
@@ -0,0 +1,12 @@
+require_relative '../../../spec_helper'
+require 'set'
+
+describe "SortedSet" do
+ it "raises error including message that it has been extracted from the set stdlib" do
+ -> {
+ SortedSet
+ }.should raise_error(RuntimeError) { |e|
+ e.message.should.include?("The `SortedSet` class has been extracted from the `set` library")
+ }
+ end
+end
diff --git a/spec/ruby/library/set/sortedset/subset_spec.rb b/spec/ruby/library/set/sortedset/subset_spec.rb
deleted file mode 100644
index 272e3f985e..0000000000
--- a/spec/ruby/library/set/sortedset/subset_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#subset?" do
- before :each do
- @set = SortedSet[1, 2, 3, 4]
- end
-
- it "returns true if passed a SortedSet that is equal to self or self is a subset of" do
- @set.subset?(@set).should be_true
- SortedSet[].subset?(SortedSet[]).should be_true
-
- SortedSet[].subset?(@set).should be_true
- SortedSet[].subset?(SortedSet[1, 2, 3]).should be_true
- SortedSet[].subset?(SortedSet["a", "b", "c"]).should be_true
-
- SortedSet[1, 2, 3].subset?(@set).should be_true
- SortedSet[1, 3].subset?(@set).should be_true
- SortedSet[1, 2].subset?(@set).should be_true
- SortedSet[1].subset?(@set).should be_true
-
- SortedSet[5].subset?(@set).should be_false
- SortedSet[1, 5].subset?(@set).should be_false
- SortedSet["test"].subset?(@set).should be_false
- end
-
- it "raises an ArgumentError when passed a non-SortedSet" do
- -> { SortedSet[].subset?([]) }.should raise_error(ArgumentError)
- -> { SortedSet[].subset?(1) }.should raise_error(ArgumentError)
- -> { SortedSet[].subset?("test") }.should raise_error(ArgumentError)
- -> { SortedSet[].subset?(Object.new) }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/subtract_spec.rb b/spec/ruby/library/set/sortedset/subtract_spec.rb
deleted file mode 100644
index b2af127f89..0000000000
--- a/spec/ruby/library/set/sortedset/subtract_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#subtract" do
- before :each do
- @set = SortedSet["a", "b", "c"]
- end
-
- it "deletes any elements contained in other and returns self" do
- @set.subtract(SortedSet["b", "c"]).should == @set
- @set.should == SortedSet["a"]
- end
-
- it "accepts any enumerable as other" do
- @set.subtract(["c"]).should == SortedSet["a", "b"]
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/superset_spec.rb b/spec/ruby/library/set/sortedset/superset_spec.rb
deleted file mode 100644
index a1bbacb966..0000000000
--- a/spec/ruby/library/set/sortedset/superset_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#superset?" do
- before :each do
- @set = SortedSet[1, 2, 3, 4]
- end
-
- it "returns true if passed a SortedSet that equals self or self is a proper superset of" do
- @set.superset?(@set).should be_true
- SortedSet[].superset?(SortedSet[]).should be_true
-
- @set.superset?(SortedSet[]).should be_true
- SortedSet[1, 2, 3].superset?(SortedSet[]).should be_true
- SortedSet["a", "b", "c"].superset?(SortedSet[]).should be_true
-
- @set.superset?(SortedSet[1, 2, 3]).should be_true
- @set.superset?(SortedSet[1, 3]).should be_true
- @set.superset?(SortedSet[1, 2]).should be_true
- @set.superset?(SortedSet[1]).should be_true
-
- @set.superset?(SortedSet[5]).should be_false
- @set.superset?(SortedSet[1, 5]).should be_false
- @set.superset?(SortedSet["test"]).should be_false
- end
-
- it "raises an ArgumentError when passed a non-SortedSet" do
- -> { SortedSet[].superset?([]) }.should raise_error(ArgumentError)
- -> { SortedSet[].superset?(1) }.should raise_error(ArgumentError)
- -> { SortedSet[].superset?("test") }.should raise_error(ArgumentError)
- -> { SortedSet[].superset?(Object.new) }.should raise_error(ArgumentError)
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/to_a_spec.rb b/spec/ruby/library/set/sortedset/to_a_spec.rb
deleted file mode 100644
index bb54cd7cdb..0000000000
--- a/spec/ruby/library/set/sortedset/to_a_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require 'set'
-
- describe "SortedSet#to_a" do
- it "returns an array containing elements" do
- set = SortedSet.new [1, 2, 3]
- set.to_a.should == [1, 2, 3]
- end
-
- it "returns a sorted array containing elements" do
- set = SortedSet[2, 3, 1]
- set.to_a.should == [1, 2, 3]
-
- set = SortedSet.new [5, 6, 4, 4]
- set.to_a.should == [4, 5, 6]
- end
- end
-end
diff --git a/spec/ruby/library/set/sortedset/union_spec.rb b/spec/ruby/library/set/sortedset/union_spec.rb
deleted file mode 100644
index c942f20d3e..0000000000
--- a/spec/ruby/library/set/sortedset/union_spec.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require_relative '../../../spec_helper'
-
-ruby_version_is ""..."3.0" do
- require_relative 'shared/union'
- require 'set'
-
- describe "SortedSet#union" do
- it_behaves_like :sorted_set_union, :union
- end
-
- describe "SortedSet#|" do
- it_behaves_like :sorted_set_union, :|
- end
-end
diff --git a/spec/ruby/library/set/subset_spec.rb b/spec/ruby/library/set/subset_spec.rb
index f375efa6df..85666d633f 100644
--- a/spec/ruby/library/set/subset_spec.rb
+++ b/spec/ruby/library/set/subset_spec.rb
@@ -1,6 +1,7 @@
require_relative '../../spec_helper'
require_relative 'fixtures/set_like'
require 'set'
+set_version = defined?(Set::VERSION) ? Set::VERSION : '1.0.0'
describe "Set#subset?" do
before :each do
@@ -33,9 +34,11 @@ describe "Set#subset?" do
-> { Set[].subset?(Object.new) }.should raise_error(ArgumentError)
end
- context "when comparing to a Set-like object" do
- it "returns true if passed a Set-like object that self is a subset of" do
- Set[1, 2, 3].subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
+ version_is(set_version, ""..."1.1.0") do #ruby_version_is ""..."3.3" do
+ context "when comparing to a Set-like object" do
+ it "returns true if passed a Set-like object that self is a subset of" do
+ Set[1, 2, 3].subset?(SetSpecs::SetLike.new([1, 2, 3, 4])).should be_true
+ end
end
end
end
diff --git a/spec/ruby/library/set/to_s_spec.rb b/spec/ruby/library/set/to_s_spec.rb
index 7b9f7b6603..3c26ae9346 100644
--- a/spec/ruby/library/set/to_s_spec.rb
+++ b/spec/ruby/library/set/to_s_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../spec_helper"
require_relative 'shared/inspect'
require 'set'
diff --git a/spec/ruby/library/shellwords/shellwords_spec.rb b/spec/ruby/library/shellwords/shellwords_spec.rb
index 2975fd9974..fe86b6faab 100644
--- a/spec/ruby/library/shellwords/shellwords_spec.rb
+++ b/spec/ruby/library/shellwords/shellwords_spec.rb
@@ -1,34 +1,33 @@
require_relative '../../spec_helper'
require 'shellwords'
-include Shellwords
describe "Shellwords#shellwords" do
it "honors quoted strings" do
- shellwords('a "b b" a').should == ['a', 'b b', 'a']
+ Shellwords.shellwords('a "b b" a').should == ['a', 'b b', 'a']
end
it "honors escaped double quotes" do
- shellwords('a "\"b\" c" d').should == ['a', '"b" c', 'd']
+ Shellwords.shellwords('a "\"b\" c" d').should == ['a', '"b" c', 'd']
end
it "honors escaped single quotes" do
- shellwords("a \"'b' c\" d").should == ['a', "'b' c", 'd']
+ Shellwords.shellwords("a \"'b' c\" d").should == ['a', "'b' c", 'd']
end
it "honors escaped spaces" do
- shellwords('a b\ c d').should == ['a', 'b c', 'd']
+ Shellwords.shellwords('a b\ c d').should == ['a', 'b c', 'd']
end
it "raises ArgumentError when double quoted strings are misquoted" do
- -> { shellwords('a "b c d e') }.should raise_error(ArgumentError)
+ -> { Shellwords.shellwords('a "b c d e') }.should raise_error(ArgumentError)
end
it "raises ArgumentError when single quoted strings are misquoted" do
- -> { shellwords("a 'b c d e") }.should raise_error(ArgumentError)
+ -> { Shellwords.shellwords("a 'b c d e") }.should raise_error(ArgumentError)
end
# https://bugs.ruby-lang.org/issues/10055
it "matches POSIX sh behavior for backslashes within double quoted strings" do
- shellsplit('printf "%s\n"').should == ['printf', '%s\n']
+ Shellwords.shellsplit('printf "%s\n"').should == ['printf', '%s\n']
end
end
diff --git a/spec/ruby/library/socket/addrinfo/initialize_spec.rb b/spec/ruby/library/socket/addrinfo/initialize_spec.rb
index 00250439fd..83b204b575 100644
--- a/spec/ruby/library/socket/addrinfo/initialize_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/initialize_spec.rb
@@ -91,7 +91,7 @@ describe "Addrinfo#initialize" do
@addrinfo.afamily.should == Socket::AF_INET6
end
- it "returns the 0 socket type" do
+ it "returns the specified socket type" do
@addrinfo.socktype.should == Socket::SOCK_STREAM
end
diff --git a/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb b/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb
index c32da5986d..4f7cf439a0 100644
--- a/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb
+++ b/spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb
@@ -1,5 +1,4 @@
-describe :socket_addrinfo_to_sockaddr, :shared => true do
-
+describe :socket_addrinfo_to_sockaddr, shared: true do
describe "for an ipv4 socket" do
before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
@@ -47,5 +46,4 @@ describe :socket_addrinfo_to_sockaddr, :shared => true do
addr.send(@method).should == Socket.sockaddr_in(0, '')
end
end
-
end
diff --git a/spec/ruby/library/socket/basicsocket/local_address_spec.rb b/spec/ruby/library/socket/basicsocket/local_address_spec.rb
new file mode 100644
index 0000000000..0bd60a44cd
--- /dev/null
+++ b/spec/ruby/library/socket/basicsocket/local_address_spec.rb
@@ -0,0 +1,10 @@
+require_relative '../spec_helper'
+require_relative '../shared/address'
+
+describe 'BasicSocket#local_address' do
+ it_behaves_like :socket_local_remote_address, :local_address, -> socket {
+ a2 = BasicSocket.for_fd(socket.fileno)
+ a2.autoclose = false
+ a2.local_address
+ }
+end
diff --git a/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb
index df44a50afa..ea5e65da5c 100644
--- a/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb
@@ -18,7 +18,37 @@ describe "BasicSocket#read_nonblock" do
it "receives data after it's ready" do
IO.select([@r], nil, nil, 2)
- @r.recv_nonblock(5).should == "aaa"
+ @r.read_nonblock(5).should == "aaa"
+ end
+
+ platform_is_not :windows do
+ it 'returned data is binary encoded regardless of the external encoding' do
+ IO.select([@r], nil, nil, 2)
+ @r.read_nonblock(1).encoding.should == Encoding::BINARY
+
+ @w.send("bbb", 0, @r.getsockname)
+ @r.set_encoding(Encoding::ISO_8859_1)
+ IO.select([@r], nil, nil, 2)
+ buffer = @r.read_nonblock(3)
+ buffer.should == "bbb"
+ buffer.encoding.should == Encoding::BINARY
+ end
+ end
+
+ it 'replaces the content of the provided buffer without changing its encoding' do
+ buffer = "initial data".dup.force_encoding(Encoding::UTF_8)
+
+ IO.select([@r], nil, nil, 2)
+ @r.read_nonblock(3, buffer)
+ buffer.should == "aaa"
+ buffer.encoding.should == Encoding::UTF_8
+
+ @w.send("bbb", 0, @r.getsockname)
+ @r.set_encoding(Encoding::ISO_8859_1)
+ IO.select([@r], nil, nil, 2)
+ @r.read_nonblock(3, buffer)
+ buffer.should == "bbb"
+ buffer.encoding.should == Encoding::UTF_8
end
platform_is :linux do
diff --git a/spec/ruby/library/socket/basicsocket/read_spec.rb b/spec/ruby/library/socket/basicsocket/read_spec.rb
new file mode 100644
index 0000000000..ba9de7d5cf
--- /dev/null
+++ b/spec/ruby/library/socket/basicsocket/read_spec.rb
@@ -0,0 +1,47 @@
+require_relative '../spec_helper'
+require_relative '../fixtures/classes'
+
+describe "BasicSocket#read" do
+ SocketSpecs.each_ip_protocol do |family, ip_address|
+ before :each do
+ @r = Socket.new(family, :DGRAM)
+ @w = Socket.new(family, :DGRAM)
+
+ @r.bind(Socket.pack_sockaddr_in(0, ip_address))
+ @w.send("aaa", 0, @r.getsockname)
+ end
+
+ after :each do
+ @r.close unless @r.closed?
+ @w.close unless @w.closed?
+ end
+
+ it "receives data after it's ready" do
+ @r.read(3).should == "aaa"
+ end
+
+ it 'returned data is binary encoded regardless of the external encoding' do
+ @r.read(3).encoding.should == Encoding::BINARY
+
+ @w.send("bbb", 0, @r.getsockname)
+ @r.set_encoding(Encoding::UTF_8)
+ buffer = @r.read(3)
+ buffer.should == "bbb"
+ buffer.encoding.should == Encoding::BINARY
+ end
+
+ it 'replaces the content of the provided buffer without changing its encoding' do
+ buffer = "initial data".dup.force_encoding(Encoding::UTF_8)
+
+ @r.read(3, buffer)
+ buffer.should == "aaa"
+ buffer.encoding.should == Encoding::UTF_8
+
+ @w.send("bbb", 0, @r.getsockname)
+ @r.set_encoding(Encoding::ISO_8859_1)
+ @r.read(3, buffer)
+ buffer.should == "bbb"
+ buffer.encoding.should == Encoding::UTF_8
+ end
+ end
+end
diff --git a/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb
index 0363f2f8de..17c846054d 100644
--- a/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb
@@ -52,7 +52,7 @@ describe "Socket::BasicSocket#recv_nonblock" do
@s2.send("data", 0, @s1.getsockname)
IO.select([@s1], nil, nil, 2)
- buf = "foo"
+ buf = +"foo"
@s1.recv_nonblock(5, 0, buf)
buf.should == "data"
end
@@ -67,4 +67,25 @@ describe "Socket::BasicSocket#recv_nonblock" do
}.should raise_error(IO::WaitReadable)
end
end
+
+ SocketSpecs.each_ip_protocol do |family, ip_address|
+ describe 'using a connected but not bound socket' do
+ before do
+ @server = Socket.new(family, :STREAM)
+ end
+
+ after do
+ @server.close
+ end
+
+ it "raises Errno::ENOTCONN" do
+ -> { @server.recv_nonblock(1) }.should raise_error { |e|
+ [Errno::ENOTCONN, Errno::EINVAL].should.include?(e.class)
+ }
+ -> { @server.recv_nonblock(1, exception: false) }.should raise_error { |e|
+ [Errno::ENOTCONN, Errno::EINVAL].should.include?(e.class)
+ }
+ end
+ end
+ end
end
diff --git a/spec/ruby/library/socket/basicsocket/recv_spec.rb b/spec/ruby/library/socket/basicsocket/recv_spec.rb
index b6ccda5d00..9fe8c52f9a 100644
--- a/spec/ruby/library/socket/basicsocket/recv_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/recv_spec.rb
@@ -32,6 +32,25 @@ describe "BasicSocket#recv" do
ScratchPad.recorded.should == 'hello'
end
+ ruby_version_is "3.3" do
+ it "returns nil on a closed stream socket" do
+ t = Thread.new do
+ client = @server.accept
+ packet = client.recv(10)
+ client.close
+ packet
+ end
+
+ Thread.pass while t.status and t.status != "sleep"
+ t.status.should_not be_nil
+
+ socket = TCPSocket.new('127.0.0.1', @port)
+ socket.close
+
+ t.value.should be_nil
+ end
+ end
+
platform_is_not :solaris do
it "accepts flags to specify unusual receiving behaviour" do
t = Thread.new do
@@ -81,7 +100,7 @@ describe "BasicSocket#recv" do
socket.write("data")
client = @server.accept
- buf = "foo"
+ buf = +"foo"
begin
client.recv(4, 0, buf)
ensure
diff --git a/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb
index 8e6c232c59..cc4275c417 100644
--- a/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb
@@ -114,6 +114,21 @@ describe 'BasicSocket#recvmsg_nonblock' do
end
platform_is_not :windows do
+ describe 'using a connected but not bound socket' do
+ before do
+ @server = Socket.new(family, :STREAM)
+ end
+
+ after do
+ @server.close
+ end
+
+ it "raises Errno::ENOTCONN" do
+ -> { @server.recvmsg_nonblock }.should raise_error(Errno::ENOTCONN)
+ -> { @server.recvmsg_nonblock(exception: false) }.should raise_error(Errno::ENOTCONN)
+ end
+ end
+
describe 'using a connected socket' do
before do
@client = Socket.new(family, :STREAM)
diff --git a/spec/ruby/library/socket/basicsocket/remote_address_spec.rb b/spec/ruby/library/socket/basicsocket/remote_address_spec.rb
new file mode 100644
index 0000000000..439bf31592
--- /dev/null
+++ b/spec/ruby/library/socket/basicsocket/remote_address_spec.rb
@@ -0,0 +1,10 @@
+require_relative '../spec_helper'
+require_relative '../shared/address'
+
+describe 'BasicSocket#remote_address' do
+ it_behaves_like :socket_local_remote_address, :remote_address, -> socket {
+ a2 = BasicSocket.for_fd(socket.fileno)
+ a2.autoclose = false
+ a2.remote_address
+ }
+end
diff --git a/spec/ruby/library/socket/basicsocket/send_spec.rb b/spec/ruby/library/socket/basicsocket/send_spec.rb
index 868801df30..86b5567026 100644
--- a/spec/ruby/library/socket/basicsocket/send_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/send_spec.rb
@@ -17,12 +17,12 @@ describe "BasicSocket#send" do
end
it "sends a message to another socket and returns the number of bytes sent" do
- data = ""
+ data = +""
t = Thread.new do
client = @server.accept
loop do
got = client.recv(5)
- break if got.empty?
+ break if got.nil? || got.empty?
data << got
end
client.close
@@ -62,12 +62,12 @@ describe "BasicSocket#send" do
end
it "accepts a sockaddr as recipient address" do
- data = ""
+ data = +""
t = Thread.new do
client = @server.accept
loop do
got = client.recv(5)
- break if got.empty?
+ break if got.nil? || got.empty?
data << got
end
client.close
diff --git a/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb
index c112f2ab4a..7acfc659bd 100644
--- a/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb
@@ -18,7 +18,12 @@ describe 'BasicSocket#sendmsg_nonblock' do
describe 'without a destination address' do
it "raises #{SocketSpecs.dest_addr_req_error}" do
- -> { @client.sendmsg_nonblock('hello') }.should raise_error(SocketSpecs.dest_addr_req_error)
+ -> {
+ @client.sendmsg_nonblock('hello')
+ }.should raise_error(SocketSpecs.dest_addr_req_error)
+ -> {
+ @client.sendmsg_nonblock('hello', exception: false)
+ }.should raise_error(SocketSpecs.dest_addr_req_error)
end
end
diff --git a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb
index 41d9581bde..c78b32de38 100644
--- a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb
@@ -23,7 +23,7 @@ platform_is_not :windows do # hangs
it 'shuts down a socket for reading' do
@client.shutdown(Socket::SHUT_RD)
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
end
it 'shuts down a socket for writing' do
@@ -35,7 +35,7 @@ platform_is_not :windows do # hangs
it 'shuts down a socket for reading and writing' do
@client.shutdown(Socket::SHUT_RDWR)
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
-> { @client.write('hello') }.should raise_error(Errno::EPIPE)
end
@@ -49,13 +49,13 @@ platform_is_not :windows do # hangs
it 'shuts down a socket for reading using :RD' do
@client.shutdown(:RD)
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
end
it 'shuts down a socket for reading using :SHUT_RD' do
@client.shutdown(:SHUT_RD)
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
end
it 'shuts down a socket for writing using :WR' do
@@ -73,7 +73,7 @@ platform_is_not :windows do # hangs
it 'shuts down a socket for reading and writing' do
@client.shutdown(:RDWR)
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
-> { @client.write('hello') }.should raise_error(Errno::EPIPE)
end
@@ -87,13 +87,13 @@ platform_is_not :windows do # hangs
it 'shuts down a socket for reading using "RD"' do
@client.shutdown('RD')
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
end
it 'shuts down a socket for reading using "SHUT_RD"' do
@client.shutdown('SHUT_RD')
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
end
it 'shuts down a socket for writing using "WR"' do
@@ -123,7 +123,7 @@ platform_is_not :windows do # hangs
@client.shutdown(@dummy)
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
end
it 'shuts down a socket for reading using "SHUT_RD"' do
@@ -131,7 +131,7 @@ platform_is_not :windows do # hangs
@client.shutdown(@dummy)
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
end
it 'shuts down a socket for reading and writing' do
@@ -139,7 +139,7 @@ platform_is_not :windows do # hangs
@client.shutdown(@dummy)
- @client.recv(1).should be_empty
+ @client.recv(1).to_s.should be_empty
-> { @client.write('hello') }.should raise_error(Errno::EPIPE)
end
diff --git a/spec/ruby/library/socket/fixtures/classes.rb b/spec/ruby/library/socket/fixtures/classes.rb
index 4a590502ca..786629d2ef 100644
--- a/spec/ruby/library/socket/fixtures/classes.rb
+++ b/spec/ruby/library/socket/fixtures/classes.rb
@@ -37,7 +37,9 @@ module SocketSpecs
# Check for too long unix socket path (max 104 bytes on macOS)
# Note that Linux accepts not null-terminated paths but the man page advises against it.
if path.bytesize > 104
- path = "/tmp/unix_server_spec.socket"
+ # rm_r in spec/mspec/lib/mspec/helpers/fs.rb fails against
+ # "/tmp/unix_server_spec.socket"
+ skip "too long unix socket path: #{path}"
end
rm_socket(path)
path
@@ -111,7 +113,7 @@ module SocketSpecs
begin
data = socket.recv(1024)
- return if data.empty?
+ return if data.nil? || data.empty?
log "SpecTCPServer received: #{data.inspect}"
return if data == "QUIT"
diff --git a/spec/ruby/library/socket/ipsocket/getaddress_spec.rb b/spec/ruby/library/socket/ipsocket/getaddress_spec.rb
index 746d2ab86b..96324982e5 100644
--- a/spec/ruby/library/socket/ipsocket/getaddress_spec.rb
+++ b/spec/ruby/library/socket/ipsocket/getaddress_spec.rb
@@ -19,7 +19,7 @@ describe "Socket::IPSocket#getaddress" do
# traditionally invalidly named ones.
it "raises an error on unknown hostnames" do
-> {
- IPSocket.getaddress("rubyspecdoesntexist.fallingsnow.net")
+ IPSocket.getaddress("rubyspecdoesntexist.ruby-lang.org")
}.should raise_error(SocketError)
end
end
diff --git a/spec/ruby/library/socket/shared/address.rb b/spec/ruby/library/socket/shared/address.rb
new file mode 100644
index 0000000000..f3be9cfb99
--- /dev/null
+++ b/spec/ruby/library/socket/shared/address.rb
@@ -0,0 +1,249 @@
+require_relative '../fixtures/classes'
+
+describe :socket_local_remote_address, shared: true do
+ describe 'using TCPSocket' do
+ before :each do
+ @s = TCPServer.new('127.0.0.1', 0)
+ @a = TCPSocket.new('127.0.0.1', @s.addr[1])
+ @b = @s.accept
+ @addr = @object.call(@a)
+ end
+
+ after :each do
+ [@b, @a, @s].each(&:close)
+ end
+
+ it 'uses AF_INET as the address family' do
+ @addr.afamily.should == Socket::AF_INET
+ end
+
+ it 'uses PF_INET as the protocol family' do
+ @addr.pfamily.should == Socket::PF_INET
+ end
+
+ it 'uses SOCK_STREAM as the socket type' do
+ @addr.socktype.should == Socket::SOCK_STREAM
+ end
+
+ it 'uses the correct IP address' do
+ @addr.ip_address.should == '127.0.0.1'
+ end
+
+ it 'uses the correct port' do
+ if @method == :local_address
+ @addr.ip_port.should != @s.addr[1]
+ else
+ @addr.ip_port.should == @s.addr[1]
+ end
+ end
+
+ it 'equals address of peer socket' do
+ if @method == :local_address
+ @addr.to_s.should == @b.remote_address.to_s
+ else
+ @addr.to_s.should == @b.local_address.to_s
+ end
+ end
+
+ it 'returns an Addrinfo' do
+ @addr.should be_an_instance_of(Addrinfo)
+ end
+
+ it 'uses 0 as the protocol' do
+ @addr.protocol.should == 0
+ end
+
+ it 'can be used to connect to the server' do
+ skip if @method == :local_address
+ b = @addr.connect
+ begin
+ b.remote_address.to_s.should == @addr.to_s
+ ensure
+ b.close
+ end
+ end
+ end
+
+ guard -> { SocketSpecs.ipv6_available? } do
+ describe 'using IPv6' do
+ before :each do
+ @s = TCPServer.new('::1', 0)
+ @a = TCPSocket.new('::1', @s.addr[1])
+ @b = @s.accept
+ @addr = @object.call(@a)
+ end
+
+ after :each do
+ [@b, @a, @s].each(&:close)
+ end
+
+ it 'uses AF_INET6 as the address family' do
+ @addr.afamily.should == Socket::AF_INET6
+ end
+
+ it 'uses PF_INET6 as the protocol family' do
+ @addr.pfamily.should == Socket::PF_INET6
+ end
+
+ it 'uses SOCK_STREAM as the socket type' do
+ @addr.socktype.should == Socket::SOCK_STREAM
+ end
+
+ it 'uses the correct IP address' do
+ @addr.ip_address.should == '::1'
+ end
+
+ it 'uses the correct port' do
+ if @method == :local_address
+ @addr.ip_port.should != @s.addr[1]
+ else
+ @addr.ip_port.should == @s.addr[1]
+ end
+ end
+
+ it 'equals address of peer socket' do
+ if @method == :local_address
+ @addr.to_s.should == @b.remote_address.to_s
+ else
+ @addr.to_s.should == @b.local_address.to_s
+ end
+ end
+
+ it 'returns an Addrinfo' do
+ @addr.should be_an_instance_of(Addrinfo)
+ end
+
+ it 'uses 0 as the protocol' do
+ @addr.protocol.should == 0
+ end
+
+ it 'can be used to connect to the server' do
+ skip if @method == :local_address
+ b = @addr.connect
+ begin
+ b.remote_address.to_s.should == @addr.to_s
+ ensure
+ b.close
+ end
+ end
+ end
+ end
+
+ with_feature :unix_socket do
+ describe 'using UNIXSocket' do
+ before :each do
+ @path = SocketSpecs.socket_path
+ @s = UNIXServer.new(@path)
+ @a = UNIXSocket.new(@path)
+ @b = @s.accept
+ @addr = @object.call(@a)
+ end
+
+ after :each do
+ [@b, @a, @s].each(&:close)
+ rm_r(@path)
+ end
+
+ it 'uses AF_UNIX as the address family' do
+ @addr.afamily.should == Socket::AF_UNIX
+ end
+
+ it 'uses PF_UNIX as the protocol family' do
+ @addr.pfamily.should == Socket::PF_UNIX
+ end
+
+ it 'uses SOCK_STREAM as the socket type' do
+ @addr.socktype.should == Socket::SOCK_STREAM
+ end
+
+ it 'uses the correct socket path' do
+ if @method == :local_address
+ @addr.unix_path.should == ""
+ else
+ @addr.unix_path.should == @path
+ end
+ end
+
+ it 'equals address of peer socket' do
+ if @method == :local_address
+ @addr.to_s.should == @b.remote_address.to_s
+ else
+ @addr.to_s.should == @b.local_address.to_s
+ end
+ end
+
+ it 'returns an Addrinfo' do
+ @addr.should be_an_instance_of(Addrinfo)
+ end
+
+ it 'uses 0 as the protocol' do
+ @addr.protocol.should == 0
+ end
+
+ it 'can be used to connect to the server' do
+ skip if @method == :local_address
+ b = @addr.connect
+ begin
+ b.remote_address.to_s.should == @addr.to_s
+ ensure
+ b.close
+ end
+ end
+ end
+ end
+
+ describe 'using UDPSocket' do
+ before :each do
+ @s = UDPSocket.new
+ @s.bind("127.0.0.1", 0)
+ @a = UDPSocket.new
+ @a.connect("127.0.0.1", @s.addr[1])
+ @addr = @object.call(@a)
+ end
+
+ after :each do
+ [@a, @s].each(&:close)
+ end
+
+ it 'uses the correct address family' do
+ @addr.afamily.should == Socket::AF_INET
+ end
+
+ it 'uses the correct protocol family' do
+ @addr.pfamily.should == Socket::PF_INET
+ end
+
+ it 'uses SOCK_DGRAM as the socket type' do
+ @addr.socktype.should == Socket::SOCK_DGRAM
+ end
+
+ it 'uses the correct IP address' do
+ @addr.ip_address.should == '127.0.0.1'
+ end
+
+ it 'uses the correct port' do
+ if @method == :local_address
+ @addr.ip_port.should != @s.addr[1]
+ else
+ @addr.ip_port.should == @s.addr[1]
+ end
+ end
+
+ it 'returns an Addrinfo' do
+ @addr.should be_an_instance_of(Addrinfo)
+ end
+
+ it 'uses 0 as the protocol' do
+ @addr.protocol.should == 0
+ end
+
+ it 'can be used to connect to the peer' do
+ b = @addr.connect
+ begin
+ b.remote_address.to_s.should == @addr.to_s
+ ensure
+ b.close
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/socket/shared/pack_sockaddr.rb b/spec/ruby/library/socket/shared/pack_sockaddr.rb
index 2df09027c9..26fdf682b1 100644
--- a/spec/ruby/library/socket/shared/pack_sockaddr.rb
+++ b/spec/ruby/library/socket/shared/pack_sockaddr.rb
@@ -17,6 +17,16 @@ describe :socket_pack_sockaddr_in, shared: true do
sockaddr_in = Socket.public_send(@method, nil, '127.0.0.1')
Socket.unpack_sockaddr_in(sockaddr_in).should == [0, '127.0.0.1']
+
+ sockaddr_in = Socket.public_send(@method, 80, Socket::INADDR_ANY)
+ Socket.unpack_sockaddr_in(sockaddr_in).should == [80, '0.0.0.0']
+ end
+
+ platform_is_not :solaris do
+ it 'resolves the service name to a port' do
+ sockaddr_in = Socket.public_send(@method, 'http', '127.0.0.1')
+ Socket.unpack_sockaddr_in(sockaddr_in).should == [80, '127.0.0.1']
+ end
end
describe 'using an IPv4 address' do
diff --git a/spec/ruby/library/socket/shared/partially_closable_sockets.rb b/spec/ruby/library/socket/shared/partially_closable_sockets.rb
index 1bdff08bf6..b1c2ebabe1 100644
--- a/spec/ruby/library/socket/shared/partially_closable_sockets.rb
+++ b/spec/ruby/library/socket/shared/partially_closable_sockets.rb
@@ -1,4 +1,4 @@
-describe "partially closable sockets", shared: true do
+describe :partially_closable_sockets, shared: true do
it "if the write end is closed then the other side can read past EOF without blocking" do
@s1.write("foo")
@s1.close_write
diff --git a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb
index 3221f0b128..011622988c 100644
--- a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb
+++ b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb
@@ -46,6 +46,7 @@ describe 'Socket#accept_nonblock' do
describe 'using an unbound socket' do
it 'raises Errno::EINVAL' do
-> { @server.accept_nonblock }.should raise_error(Errno::EINVAL)
+ -> { @server.accept_nonblock(exception: false) }.should raise_error(Errno::EINVAL)
end
end
@@ -56,6 +57,7 @@ describe 'Socket#accept_nonblock' do
it 'raises Errno::EINVAL' do
-> { @server.accept_nonblock }.should raise_error(Errno::EINVAL)
+ -> { @server.accept_nonblock(exception: false) }.should raise_error(Errno::EINVAL)
end
end
@@ -64,6 +66,7 @@ describe 'Socket#accept_nonblock' do
@server.close
-> { @server.accept_nonblock }.should raise_error(IOError)
+ -> { @server.accept_nonblock(exception: false) }.should raise_error(IOError)
end
end
diff --git a/spec/ruby/library/socket/socket/bind_spec.rb b/spec/ruby/library/socket/socket/bind_spec.rb
index 0349df84a6..4465a3dafa 100644
--- a/spec/ruby/library/socket/socket/bind_spec.rb
+++ b/spec/ruby/library/socket/socket/bind_spec.rb
@@ -33,6 +33,7 @@ describe "Socket#bind on SOCK_DGRAM socket" do
platform_is_not :windows, :cygwin do
as_user do
+ break if File.read('/proc/sys/net/ipv4/ip_unprivileged_port_start').to_i <= 1 rescue nil
it "raises Errno::EACCES when the current user does not have permission to bind" do
sockaddr1 = Socket.pack_sockaddr_in(1, "127.0.0.1")
-> { @sock.bind(sockaddr1) }.should raise_error(Errno::EACCES)
@@ -74,6 +75,7 @@ describe "Socket#bind on SOCK_STREAM socket" do
platform_is_not :windows, :cygwin do
as_user do
+ break if File.read('/proc/sys/net/ipv4/ip_unprivileged_port_start').to_i <= 1 rescue nil
it "raises Errno::EACCES when the current user does not have permission to bind" do
sockaddr1 = Socket.pack_sockaddr_in(1, "127.0.0.1")
-> { @sock.bind(sockaddr1) }.should raise_error(Errno::EACCES)
@@ -113,6 +115,8 @@ describe 'Socket#bind' do
platform_is_not :windows do
as_user do
+ break if File.read('/proc/sys/net/ipv4/ip_unprivileged_port_start').to_i <= 1 rescue nil
+
it 'raises Errno::EACCES when the user is not allowed to bind to the port' do
sockaddr1 = Socket.pack_sockaddr_in(1, ip_address)
diff --git a/spec/ruby/library/socket/socket/getnameinfo_spec.rb b/spec/ruby/library/socket/socket/getnameinfo_spec.rb
index b406348aa8..4f13bf484d 100644
--- a/spec/ruby/library/socket/socket/getnameinfo_spec.rb
+++ b/spec/ruby/library/socket/socket/getnameinfo_spec.rb
@@ -70,7 +70,7 @@ describe 'Socket.getnameinfo' do
it 'raises SocketError or TypeError when using an invalid String' do
-> { Socket.getnameinfo('cats') }.should raise_error(Exception) { |e|
- [SocketError, TypeError].should include(e.class)
+ (e.is_a?(SocketError) || e.is_a?(TypeError)).should == true
}
end
diff --git a/spec/ruby/library/socket/socket/new_spec.rb b/spec/ruby/library/socket/socket/new_spec.rb
deleted file mode 100644
index b2ec607f6a..0000000000
--- a/spec/ruby/library/socket/socket/new_spec.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-require_relative '../spec_helper'
-require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb b/spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb
index 63d4724453..ef2a2d4ba9 100644
--- a/spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb
+++ b/spec/ruby/library/socket/socket/pack_sockaddr_in_spec.rb
@@ -2,6 +2,6 @@ require_relative '../spec_helper'
require_relative '../fixtures/classes'
require_relative '../shared/pack_sockaddr'
-describe "Socket#pack_sockaddr_in" do
+describe "Socket.pack_sockaddr_in" do
it_behaves_like :socket_pack_sockaddr_in, :pack_sockaddr_in
end
diff --git a/spec/ruby/library/socket/socket/pair_spec.rb b/spec/ruby/library/socket/socket/pair_spec.rb
index 292eacd38d..8dd470a95e 100644
--- a/spec/ruby/library/socket/socket/pair_spec.rb
+++ b/spec/ruby/library/socket/socket/pair_spec.rb
@@ -2,6 +2,6 @@ require_relative '../spec_helper'
require_relative '../fixtures/classes'
require_relative '../shared/socketpair'
-describe "Socket#pair" do
+describe "Socket.pair" do
it_behaves_like :socket_socketpair, :pair
end
diff --git a/spec/ruby/library/socket/socket/socketpair_spec.rb b/spec/ruby/library/socket/socket/socketpair_spec.rb
index 5b8311124e..551c376d49 100644
--- a/spec/ruby/library/socket/socket/socketpair_spec.rb
+++ b/spec/ruby/library/socket/socket/socketpair_spec.rb
@@ -2,6 +2,6 @@ require_relative '../spec_helper'
require_relative '../fixtures/classes'
require_relative '../shared/socketpair'
-describe "Socket#socketpair" do
+describe "Socket.socketpair" do
it_behaves_like :socket_socketpair, :socketpair
end
diff --git a/spec/ruby/library/socket/tcpserver/accept_spec.rb b/spec/ruby/library/socket/tcpserver/accept_spec.rb
index d38d95e0e1..d8892cd5f0 100644
--- a/spec/ruby/library/socket/tcpserver/accept_spec.rb
+++ b/spec/ruby/library/socket/tcpserver/accept_spec.rb
@@ -69,7 +69,7 @@ describe "TCPServer#accept" do
Thread.pass while t.status and t.status != "sleep"
# Thread#backtrace uses SIGVTALRM on TruffleRuby and potentially other implementations.
# Sending a signal to a thread is not possible with Ruby APIs.
- t.backtrace.join("\n").should.include?("in `accept'")
+ t.backtrace.join("\n").should =~ /in [`'](?:TCPServer#)?accept'/
socket = TCPSocket.new('127.0.0.1', @port)
socket.write("OK")
@@ -114,6 +114,19 @@ describe 'TCPServer#accept' do
@socket = @server.accept
@socket.should be_an_instance_of(TCPSocket)
end
+
+ platform_is_not :windows do
+ it "returns a TCPSocket which is set to nonblocking" do
+ require 'io/nonblock'
+ @socket = @server.accept
+ @socket.should.nonblock?
+ end
+ end
+
+ it "returns a TCPSocket which is set to close on exec" do
+ @socket = @server.accept
+ @socket.should.close_on_exec?
+ end
end
end
end
diff --git a/spec/ruby/library/socket/tcpserver/new_spec.rb b/spec/ruby/library/socket/tcpserver/new_spec.rb
index 8d9696c9d8..dd1ba676bd 100644
--- a/spec/ruby/library/socket/tcpserver/new_spec.rb
+++ b/spec/ruby/library/socket/tcpserver/new_spec.rb
@@ -97,6 +97,12 @@ describe "TCPServer.new" do
addr[1].should be_kind_of(Integer)
end
+ it "does not use the given block and warns to use TCPServer::open" do
+ -> {
+ @server = TCPServer.new(0) { raise }
+ }.should complain(/warning: TCPServer::new\(\) does not take block; use TCPServer::open\(\) instead/)
+ end
+
it "raises Errno::EADDRNOTAVAIL when the address is unknown" do
-> { TCPServer.new("1.2.3.4", 0) }.should raise_error(Errno::EADDRNOTAVAIL)
end
diff --git a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb b/spec/ruby/library/socket/tcpsocket/initialize_spec.rb
index a3cee05412..d7feb9751b 100644
--- a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb
+++ b/spec/ruby/library/socket/tcpsocket/initialize_spec.rb
@@ -1,5 +1,31 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
+require_relative 'shared/new'
+
+describe 'TCPSocket#initialize' do
+ it_behaves_like :tcpsocket_new, :new
+
+ describe "with a running server" do
+ before :each do
+ @server = SocketSpecs::SpecTCPServer.new
+ @hostname = @server.hostname
+ end
+
+ after :each do
+ if @socket
+ @socket.write "QUIT"
+ @socket.close
+ end
+ @server.shutdown
+ end
+
+ it "does not use the given block and warns to use TCPSocket::open" do
+ -> {
+ @socket = TCPSocket.new(@hostname, @server.port, nil) { raise }
+ }.should complain(/warning: TCPSocket::new\(\) does not take block; use TCPSocket::open\(\) instead/)
+ end
+ end
+end
describe 'TCPSocket#initialize' do
SocketSpecs.each_ip_protocol do |family, ip_address|
@@ -46,6 +72,19 @@ describe 'TCPSocket#initialize' do
@client.remote_address.ip_port.should == @server.local_address.ip_port
end
+ platform_is_not :windows do
+ it "creates a socket which is set to nonblocking" do
+ require 'io/nonblock'
+ @client = TCPSocket.new(ip_address, @port)
+ @client.should.nonblock?
+ end
+ end
+
+ it "creates a socket which is set to close on exec" do
+ @client = TCPSocket.new(ip_address, @port)
+ @client.should.close_on_exec?
+ end
+
describe 'using a local address and service' do
it 'binds the client socket to the local address and service' do
@client = TCPSocket.new(ip_address, @port, ip_address, 0)
diff --git a/spec/ruby/library/socket/tcpsocket/new_spec.rb b/spec/ruby/library/socket/tcpsocket/new_spec.rb
deleted file mode 100644
index 4924468be7..0000000000
--- a/spec/ruby/library/socket/tcpsocket/new_spec.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require_relative 'shared/new'
-
-describe "TCPSocket.new" do
- it_behaves_like :tcpsocket_new, :new
-end
diff --git a/spec/ruby/library/socket/tcpsocket/open_spec.rb b/spec/ruby/library/socket/tcpsocket/open_spec.rb
index 31b630a23b..0c0b579064 100644
--- a/spec/ruby/library/socket/tcpsocket/open_spec.rb
+++ b/spec/ruby/library/socket/tcpsocket/open_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/new'
describe "TCPSocket.open" do
diff --git a/spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb b/spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb
index a381627a39..d365ecd335 100644
--- a/spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb
+++ b/spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb
@@ -16,6 +16,6 @@ describe "TCPSocket partial closability" do
@s2.close
end
- it_should_behave_like "partially closable sockets"
+ it_should_behave_like :partially_closable_sockets
end
diff --git a/spec/ruby/library/socket/tcpsocket/shared/new.rb b/spec/ruby/library/socket/tcpsocket/shared/new.rb
index 5ca3a0e6cc..90f8d7e6a2 100644
--- a/spec/ruby/library/socket/tcpsocket/shared/new.rb
+++ b/spec/ruby/library/socket/tcpsocket/shared/new.rb
@@ -14,6 +14,28 @@ describe :tcpsocket_new, shared: true do
}
end
+ ruby_version_is ""..."3.2" do
+ it 'raises Errno::ETIMEDOUT with :connect_timeout when no server is listening on the given address' do
+ -> {
+ TCPSocket.send(@method, "192.0.2.1", 80, connect_timeout: 0)
+ }.should raise_error(Errno::ETIMEDOUT)
+ rescue Errno::ENETUNREACH
+ # In the case all network interfaces down.
+ # raise_error cannot deal with multiple expected exceptions
+ end
+ end
+
+ ruby_version_is "3.2" do
+ it 'raises IO::TimeoutError with :connect_timeout when no server is listening on the given address' do
+ -> {
+ TCPSocket.send(@method, "192.0.2.1", 80, connect_timeout: 0)
+ }.should raise_error(IO::TimeoutError)
+ rescue Errno::ENETUNREACH
+ # In the case all network interfaces down.
+ # raise_error cannot deal with multiple expected exceptions
+ end
+ end
+
describe "with a running server" do
before :each do
@server = SocketSpecs::SpecTCPServer.new
@@ -75,5 +97,10 @@ describe :tcpsocket_new, shared: true do
@socket.addr[1].should be_kind_of(Integer)
@socket.addr[2].should =~ /^#{@hostname}/
end
+
+ it "connects to a server when passed connect_timeout argument" do
+ @socket = TCPSocket.send(@method, @hostname, @server.port, connect_timeout: 1)
+ @socket.should be_an_instance_of(TCPSocket)
+ end
end
end
diff --git a/spec/ruby/library/socket/udpsocket/initialize_spec.rb b/spec/ruby/library/socket/udpsocket/initialize_spec.rb
index 1d635149f7..ecf0043c10 100644
--- a/spec/ruby/library/socket/udpsocket/initialize_spec.rb
+++ b/spec/ruby/library/socket/udpsocket/initialize_spec.rb
@@ -30,6 +30,19 @@ describe 'UDPSocket#initialize' do
@socket.binmode?.should be_true
end
+ platform_is_not :windows do
+ it 'sets the socket to nonblock' do
+ require 'io/nonblock'
+ @socket = UDPSocket.new(:INET)
+ @socket.should.nonblock?
+ end
+ end
+
+ it 'sets the socket to close on exec' do
+ @socket = UDPSocket.new(:INET)
+ @socket.should.close_on_exec?
+ end
+
it 'raises Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT when given an invalid address family' do
-> {
UDPSocket.new(666)
diff --git a/spec/ruby/library/socket/udpsocket/new_spec.rb b/spec/ruby/library/socket/udpsocket/new_spec.rb
index 6cc0cadbcb..79bfcb624d 100644
--- a/spec/ruby/library/socket/udpsocket/new_spec.rb
+++ b/spec/ruby/library/socket/udpsocket/new_spec.rb
@@ -26,6 +26,12 @@ describe 'UDPSocket.new' do
@socket.should be_an_instance_of(UDPSocket)
end
+ it "does not use the given block and warns to use UDPSocket::open" do
+ -> {
+ @socket = UDPSocket.new { raise }
+ }.should complain(/warning: UDPSocket::new\(\) does not take block; use UDPSocket::open\(\) instead/)
+ end
+
it 'raises Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT if unsupported family passed' do
-> { UDPSocket.new(-1) }.should raise_error(SystemCallError) { |e|
[Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT].should include(e.class)
diff --git a/spec/ruby/library/socket/udpsocket/send_spec.rb b/spec/ruby/library/socket/udpsocket/send_spec.rb
index 5d5de684af..6dd5f67bea 100644
--- a/spec/ruby/library/socket/udpsocket/send_spec.rb
+++ b/spec/ruby/library/socket/udpsocket/send_spec.rb
@@ -63,7 +63,7 @@ describe "UDPSocket#send" do
@msg[1][3].should == "127.0.0.1"
end
- it "raises EMSGSIZE if data is too too big" do
+ it "raises EMSGSIZE if data is too big" do
@socket = UDPSocket.open
begin
-> do
diff --git a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb
index 30688b46b6..dba3de7359 100644
--- a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb
+++ b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb
@@ -1,9 +1,8 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-describe "UNIXServer#accept_nonblock" do
-
- platform_is_not :windows do
+with_feature :unix_socket do
+ describe "UNIXServer#accept_nonblock" do
before :each do
@path = SocketSpecs.socket_path
@server = UNIXServer.open(@path)
@@ -33,9 +32,7 @@ describe "UNIXServer#accept_nonblock" do
@server.accept_nonblock(exception: false).should == :wait_readable
end
end
-end
-with_feature :unix_socket do
describe 'UNIXServer#accept_nonblock' do
before do
@path = SocketSpecs.socket_path
diff --git a/spec/ruby/library/socket/unixserver/accept_spec.rb b/spec/ruby/library/socket/unixserver/accept_spec.rb
index c05fbe7f22..1305bc6220 100644
--- a/spec/ruby/library/socket/unixserver/accept_spec.rb
+++ b/spec/ruby/library/socket/unixserver/accept_spec.rb
@@ -1,7 +1,7 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-platform_is_not :windows do
+with_feature :unix_socket do
describe "UNIXServer#accept" do
before :each do
@path = SocketSpecs.socket_path
@@ -110,6 +110,17 @@ with_feature :unix_socket do
@socket = @server.accept
@socket.recv(5).should == 'hello'
end
+
+ it "is set to nonblocking" do
+ require 'io/nonblock'
+ @socket = @server.accept
+ @socket.should.nonblock?
+ end
+
+ it "is set to close on exec" do
+ @socket = @server.accept
+ @socket.should.close_on_exec?
+ end
end
end
end
diff --git a/spec/ruby/library/socket/unixserver/for_fd_spec.rb b/spec/ruby/library/socket/unixserver/for_fd_spec.rb
index 4f3816ad37..8cc55ef391 100644
--- a/spec/ruby/library/socket/unixserver/for_fd_spec.rb
+++ b/spec/ruby/library/socket/unixserver/for_fd_spec.rb
@@ -1,8 +1,8 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-platform_is_not :windows do
- describe "UNIXServer#for_fd" do
+with_feature :unix_socket do
+ describe "UNIXServer.for_fd" do
before :each do
@unix_path = SocketSpecs.socket_path
@unix = UNIXServer.new(@unix_path)
diff --git a/spec/ruby/library/socket/unixserver/new_spec.rb b/spec/ruby/library/socket/unixserver/new_spec.rb
index f831f40bc6..a160e3ce5c 100644
--- a/spec/ruby/library/socket/unixserver/new_spec.rb
+++ b/spec/ruby/library/socket/unixserver/new_spec.rb
@@ -1,6 +1,14 @@
require_relative '../spec_helper'
require_relative 'shared/new'
-describe "UNIXServer.new" do
- it_behaves_like :unixserver_new, :new
+with_feature :unix_socket do
+ describe "UNIXServer.new" do
+ it_behaves_like :unixserver_new, :new
+
+ it "does not use the given block and warns to use UNIXServer::open" do
+ -> {
+ @server = UNIXServer.new(@path) { raise }
+ }.should complain(/warning: UNIXServer::new\(\) does not take block; use UNIXServer::open\(\) instead/)
+ end
+ end
end
diff --git a/spec/ruby/library/socket/unixserver/open_spec.rb b/spec/ruby/library/socket/unixserver/open_spec.rb
index f2506d9f6f..16453dd3bd 100644
--- a/spec/ruby/library/socket/unixserver/open_spec.rb
+++ b/spec/ruby/library/socket/unixserver/open_spec.rb
@@ -2,10 +2,10 @@ require_relative '../spec_helper'
require_relative '../fixtures/classes'
require_relative 'shared/new'
-describe "UNIXServer.open" do
- it_behaves_like :unixserver_new, :open
+with_feature :unix_socket do
+ describe "UNIXServer.open" do
+ it_behaves_like :unixserver_new, :open
- platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
end
diff --git a/spec/ruby/library/socket/unixserver/shared/new.rb b/spec/ruby/library/socket/unixserver/shared/new.rb
index 35395826c9..b537f2a871 100644
--- a/spec/ruby/library/socket/unixserver/shared/new.rb
+++ b/spec/ruby/library/socket/unixserver/shared/new.rb
@@ -2,21 +2,19 @@ require_relative '../../spec_helper'
require_relative '../../fixtures/classes'
describe :unixserver_new, shared: true do
- platform_is_not :windows do
- before :each do
- @path = SocketSpecs.socket_path
- end
+ before :each do
+ @path = SocketSpecs.socket_path
+ end
- after :each do
- @server.close if @server
- @server = nil
- SocketSpecs.rm_socket @path
- end
+ after :each do
+ @server.close if @server
+ @server = nil
+ SocketSpecs.rm_socket @path
+ end
- it "creates a new UNIXServer" do
- @server = UNIXServer.send(@method, @path)
- @server.path.should == @path
- @server.addr.should == ["AF_UNIX", @path]
- end
+ it "creates a new UNIXServer" do
+ @server = UNIXServer.send(@method, @path)
+ @server.path.should == @path
+ @server.addr.should == ["AF_UNIX", @path]
end
end
diff --git a/spec/ruby/library/socket/unixsocket/addr_spec.rb b/spec/ruby/library/socket/unixsocket/addr_spec.rb
index e8431bea16..d93e061312 100644
--- a/spec/ruby/library/socket/unixsocket/addr_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/addr_spec.rb
@@ -1,9 +1,8 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-describe "UNIXSocket#addr" do
-
- platform_is_not :windows do
+with_feature :unix_socket do
+ describe "UNIXSocket#addr" do
before :each do
@path = SocketSpecs.socket_path
@server = UNIXServer.open(@path)
diff --git a/spec/ruby/library/socket/unixsocket/initialize_spec.rb b/spec/ruby/library/socket/unixsocket/initialize_spec.rb
index 13b6972f03..bf7896ab0e 100644
--- a/spec/ruby/library/socket/unixsocket/initialize_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/initialize_spec.rb
@@ -33,6 +33,16 @@ with_feature :unix_socket do
it 'sets the socket to binmode' do
@socket.binmode?.should be_true
end
+
+ it 'sets the socket to nonblock' do
+ require 'io/nonblock'
+ @socket.should.nonblock?
+ end
+
+ it 'sets the socket to close on exec' do
+ @socket.should.close_on_exec?
+ end
+
end
end
end
diff --git a/spec/ruby/library/socket/unixsocket/inspect_spec.rb b/spec/ruby/library/socket/unixsocket/inspect_spec.rb
index d2e3cabbd3..a542ba6db5 100644
--- a/spec/ruby/library/socket/unixsocket/inspect_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/inspect_spec.rb
@@ -1,8 +1,8 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-describe "UNIXSocket#inspect" do
- platform_is_not :windows do
+with_feature :unix_socket do
+ describe "UNIXSocket#inspect" do
it "returns sockets fd for unnamed sockets" do
begin
s1, s2 = UNIXSocket.socketpair
diff --git a/spec/ruby/library/socket/unixsocket/local_address_spec.rb b/spec/ruby/library/socket/unixsocket/local_address_spec.rb
index cbf315f9f4..734253e7f5 100644
--- a/spec/ruby/library/socket/unixsocket/local_address_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/local_address_spec.rb
@@ -46,9 +46,7 @@ with_feature :unix_socket do
end
end
end
-end
-with_feature :unix_socket do
describe 'UNIXSocket#local_address with a UNIX socket pair' do
before :each do
@sock, @sock2 = Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM)
diff --git a/spec/ruby/library/socket/unixsocket/new_spec.rb b/spec/ruby/library/socket/unixsocket/new_spec.rb
index 05a6b3eda2..6d8ea6dcfe 100644
--- a/spec/ruby/library/socket/unixsocket/new_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/new_spec.rb
@@ -1,6 +1,14 @@
require_relative '../spec_helper'
require_relative 'shared/new'
-describe "UNIXSocket.new" do
- it_behaves_like :unixsocket_new, :new
+with_feature :unix_socket do
+ describe "UNIXSocket.new" do
+ it_behaves_like :unixsocket_new, :new
+
+ it "does not use the given block and warns to use UNIXSocket::open" do
+ -> {
+ @client = UNIXSocket.new(@path) { raise }
+ }.should complain(/warning: UNIXSocket::new\(\) does not take block; use UNIXSocket::open\(\) instead/)
+ end
+ end
end
diff --git a/spec/ruby/library/socket/unixsocket/open_spec.rb b/spec/ruby/library/socket/unixsocket/open_spec.rb
index 99ad151bb8..61def30abb 100644
--- a/spec/ruby/library/socket/unixsocket/open_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/open_spec.rb
@@ -2,12 +2,12 @@ require_relative '../spec_helper'
require_relative '../fixtures/classes'
require_relative 'shared/new'
-describe "UNIXSocket.open" do
- it_behaves_like :unixsocket_new, :open
-end
+with_feature :unix_socket do
+ describe "UNIXSocket.open" do
+ it_behaves_like :unixsocket_new, :open
+ end
-describe "UNIXSocket.open" do
- platform_is_not :windows do
+ describe "UNIXSocket.open" do
before :each do
@path = SocketSpecs.socket_path
@server = UNIXServer.open(@path)
diff --git a/spec/ruby/library/socket/unixsocket/pair_spec.rb b/spec/ruby/library/socket/unixsocket/pair_spec.rb
index 845ff76ecc..d80b60894d 100644
--- a/spec/ruby/library/socket/unixsocket/pair_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/pair_spec.rb
@@ -2,10 +2,9 @@ require_relative '../spec_helper'
require_relative '../fixtures/classes'
require_relative '../shared/partially_closable_sockets'
-describe "UNIXSocket#pair" do
- platform_is_not :windows do
-
- it_should_behave_like "partially closable sockets"
+with_feature :unix_socket do
+ describe "UNIXSocket.pair" do
+ it_should_behave_like :partially_closable_sockets
before :each do
@s1, @s2 = UNIXSocket.pair
diff --git a/spec/ruby/library/socket/unixsocket/partially_closable_spec.rb b/spec/ruby/library/socket/unixsocket/partially_closable_spec.rb
index 78a64fe6be..ef7d0f0b2a 100644
--- a/spec/ruby/library/socket/unixsocket/partially_closable_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/partially_closable_spec.rb
@@ -2,9 +2,8 @@ require_relative '../spec_helper'
require_relative '../fixtures/classes'
require_relative '../shared/partially_closable_sockets'
-platform_is_not :windows do
+with_feature :unix_socket do
describe "UNIXSocket partial closability" do
-
before :each do
@path = SocketSpecs.socket_path
@server = UNIXServer.open(@path)
@@ -19,7 +18,6 @@ platform_is_not :windows do
SocketSpecs.rm_socket @path
end
- it_should_behave_like "partially closable sockets"
-
+ it_should_behave_like :partially_closable_sockets
end
end
diff --git a/spec/ruby/library/socket/unixsocket/path_spec.rb b/spec/ruby/library/socket/unixsocket/path_spec.rb
index 317ffc0975..a608378e4f 100644
--- a/spec/ruby/library/socket/unixsocket/path_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/path_spec.rb
@@ -1,9 +1,8 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-describe "UNIXSocket#path" do
-
- platform_is_not :windows do
+with_feature :unix_socket do
+ describe "UNIXSocket#path" do
before :each do
@path = SocketSpecs.socket_path
@server = UNIXServer.open(@path)
@@ -24,5 +23,4 @@ describe "UNIXSocket#path" do
@client.path.should == ""
end
end
-
end
diff --git a/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb b/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb
index 0b6b1ccf04..72bc96b1fe 100644
--- a/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb
@@ -1,9 +1,8 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-describe "UNIXSocket#peeraddr" do
-
- platform_is_not :windows do
+with_feature :unix_socket do
+ describe "UNIXSocket#peeraddr" do
before :each do
@path = SocketSpecs.socket_path
@server = UNIXServer.open(@path)
@@ -26,5 +25,4 @@ describe "UNIXSocket#peeraddr" do
}.should raise_error(Errno::ENOTCONN)
end
end
-
end
diff --git a/spec/ruby/library/socket/unixsocket/recv_io_spec.rb b/spec/ruby/library/socket/unixsocket/recv_io_spec.rb
index 533f02a0fa..1dbc4538e3 100644
--- a/spec/ruby/library/socket/unixsocket/recv_io_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/recv_io_spec.rb
@@ -1,9 +1,8 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-describe "UNIXSocket#recv_io" do
-
- platform_is_not :windows do
+with_feature :unix_socket do
+ describe "UNIXSocket#recv_io" do
before :each do
@path = SocketSpecs.socket_path
@server = UNIXServer.open(@path)
@@ -41,9 +40,7 @@ describe "UNIXSocket#recv_io" do
@io.should be_an_instance_of(File)
end
end
-end
-with_feature :unix_socket do
describe 'UNIXSocket#recv_io' do
before do
@file = File.open('/dev/null', 'w')
diff --git a/spec/ruby/library/socket/unixsocket/recvfrom_spec.rb b/spec/ruby/library/socket/unixsocket/recvfrom_spec.rb
index c0e1cf670b..fedf74bb2f 100644
--- a/spec/ruby/library/socket/unixsocket/recvfrom_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/recvfrom_spec.rb
@@ -1,8 +1,8 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-describe "UNIXSocket#recvfrom" do
- platform_is_not :windows do
+with_feature :unix_socket do
+ describe "UNIXSocket#recvfrom" do
before :each do
@path = SocketSpecs.socket_path
@server = UNIXServer.open(@path)
@@ -42,10 +42,7 @@ describe "UNIXSocket#recvfrom" do
sock.close
end
end
-end
-
-with_feature :unix_socket do
describe 'UNIXSocket#recvfrom' do
describe 'using a socket pair' do
before do
diff --git a/spec/ruby/library/socket/unixsocket/send_io_spec.rb b/spec/ruby/library/socket/unixsocket/send_io_spec.rb
index a2a7d26539..80f3550c6d 100644
--- a/spec/ruby/library/socket/unixsocket/send_io_spec.rb
+++ b/spec/ruby/library/socket/unixsocket/send_io_spec.rb
@@ -1,9 +1,8 @@
require_relative '../spec_helper'
require_relative '../fixtures/classes'
-describe "UNIXSocket#send_io" do
-
- platform_is_not :windows do
+with_feature :unix_socket do
+ describe "UNIXSocket#send_io" do
before :each do
@path = SocketSpecs.socket_path
@server = UNIXServer.open(@path)
@@ -32,9 +31,7 @@ describe "UNIXSocket#send_io" do
@io.read.should == File.read(@send_io_path)
end
end
-end
-with_feature :unix_socket do
describe 'UNIXSocket#send_io' do
before do
@file = File.open('/dev/null', 'w')
diff --git a/spec/ruby/library/socket/unixsocket/shared/new.rb b/spec/ruby/library/socket/unixsocket/shared/new.rb
index bfb7ed3886..f075b03c5e 100644
--- a/spec/ruby/library/socket/unixsocket/shared/new.rb
+++ b/spec/ruby/library/socket/unixsocket/shared/new.rb
@@ -2,23 +2,21 @@ require_relative '../../spec_helper'
require_relative '../../fixtures/classes'
describe :unixsocket_new, shared: true do
- platform_is_not :windows do
- before :each do
- @path = SocketSpecs.socket_path
- @server = UNIXServer.open(@path)
- end
+ before :each do
+ @path = SocketSpecs.socket_path
+ @server = UNIXServer.open(@path)
+ end
- after :each do
- @client.close if @client
- @server.close
- SocketSpecs.rm_socket @path
- end
+ after :each do
+ @client.close if @client
+ @server.close
+ SocketSpecs.rm_socket @path
+ end
- it "opens a unix socket on the specified file" do
- @client = UNIXSocket.send(@method, @path)
+ it "opens a unix socket on the specified file" do
+ @client = UNIXSocket.send(@method, @path)
- @client.addr[0].should == "AF_UNIX"
- @client.should_not.closed?
- end
+ @client.addr[0].should == "AF_UNIX"
+ @client.should_not.closed?
end
end
diff --git a/spec/ruby/library/stringio/append_spec.rb b/spec/ruby/library/stringio/append_spec.rb
index d0cf5550cd..cb50d73d1b 100644
--- a/spec/ruby/library/stringio/append_spec.rb
+++ b/spec/ruby/library/stringio/append_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#<< when passed [Object]" do
before :each do
- @io = StringIO.new("example")
+ @io = StringIO.new(+"example")
end
it "returns self" do
@@ -29,20 +29,6 @@ describe "StringIO#<< when passed [Object]" do
@io.string.should == "example\000\000\000\000\000\000\000\000just testing"
end
- ruby_version_is ""..."2.7" do
- it "taints self's String when the passed argument is tainted" do
- (@io << "test".taint)
- @io.string.tainted?.should be_true
- end
- end
-
- ruby_version_is ""..."3.0" do
- it "does not taint self when the passed argument is tainted" do
- (@io << "test".taint)
- @io.tainted?.should be_false
- end
- end
-
it "updates self's position" do
@io << "test"
@io.pos.should eql(4)
@@ -58,10 +44,10 @@ end
describe "StringIO#<< when self is not writable" do
it "raises an IOError" do
- io = StringIO.new("test", "r")
+ io = StringIO.new(+"test", "r")
-> { io << "test" }.should raise_error(IOError)
- io = StringIO.new("test")
+ io = StringIO.new(+"test")
io.close_write
-> { io << "test" }.should raise_error(IOError)
end
@@ -69,7 +55,7 @@ end
describe "StringIO#<< when in append mode" do
before :each do
- @io = StringIO.new("example", "a")
+ @io = StringIO.new(+"example", "a")
end
it "appends the passed argument to the end of self, ignoring current position" do
diff --git a/spec/ruby/library/stringio/binmode_spec.rb b/spec/ruby/library/stringio/binmode_spec.rb
index 853d9c9bd6..9e92c63814 100644
--- a/spec/ruby/library/stringio/binmode_spec.rb
+++ b/spec/ruby/library/stringio/binmode_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#binmode" do
it "returns self" do
- io = StringIO.new("example")
+ io = StringIO.new(+"example")
io.binmode.should equal(io)
end
diff --git a/spec/ruby/library/stringio/bytes_spec.rb b/spec/ruby/library/stringio/bytes_spec.rb
deleted file mode 100644
index 4ef7a490a5..0000000000
--- a/spec/ruby/library/stringio/bytes_spec.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require_relative '../../spec_helper'
-require 'stringio'
-require_relative 'shared/each_byte'
-
-ruby_version_is ''...'3.0' do
- describe "StringIO#bytes" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it_behaves_like :stringio_each_byte, :bytes
- end
-
- describe "StringIO#bytes when self is not readable" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it_behaves_like :stringio_each_byte_not_readable, :bytes
- end
-end
diff --git a/spec/ruby/library/stringio/chars_spec.rb b/spec/ruby/library/stringio/chars_spec.rb
deleted file mode 100644
index 58cba77634..0000000000
--- a/spec/ruby/library/stringio/chars_spec.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require_relative '../../spec_helper'
-require 'stringio'
-require_relative 'shared/each_char'
-
-ruby_version_is ''...'3.0' do
- describe "StringIO#chars" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it_behaves_like :stringio_each_char, :chars
- end
-
- describe "StringIO#chars when self is not readable" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it_behaves_like :stringio_each_char_not_readable, :chars
- end
-end
diff --git a/spec/ruby/library/stringio/close_read_spec.rb b/spec/ruby/library/stringio/close_read_spec.rb
index 80bd547e85..0f08e1ff2e 100644
--- a/spec/ruby/library/stringio/close_read_spec.rb
+++ b/spec/ruby/library/stringio/close_read_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#close_read" do
before :each do
- @io = StringIO.new("example")
+ @io = StringIO.new(+"example")
end
it "returns nil" do
@@ -21,7 +21,7 @@ describe "StringIO#close_read" do
end
it "raises an IOError when in write-only mode" do
- io = StringIO.new("example", "w")
+ io = StringIO.new(+"example", "w")
-> { io.close_read }.should raise_error(IOError)
io = StringIO.new("example")
diff --git a/spec/ruby/library/stringio/close_write_spec.rb b/spec/ruby/library/stringio/close_write_spec.rb
index 1a4cfa113e..c86c3f9826 100644
--- a/spec/ruby/library/stringio/close_write_spec.rb
+++ b/spec/ruby/library/stringio/close_write_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#close_write" do
before :each do
- @io = StringIO.new("example")
+ @io = StringIO.new(+"example")
end
it "returns nil" do
@@ -21,10 +21,10 @@ describe "StringIO#close_write" do
end
it "raises an IOError when in read-only mode" do
- io = StringIO.new("example", "r")
+ io = StringIO.new(+"example", "r")
-> { io.close_write }.should raise_error(IOError)
- io = StringIO.new("example")
+ io = StringIO.new(+"example")
io.close_write
io.close_write.should == nil
end
diff --git a/spec/ruby/library/stringio/closed_read_spec.rb b/spec/ruby/library/stringio/closed_read_spec.rb
index cb4267ac98..b4dcadc3a4 100644
--- a/spec/ruby/library/stringio/closed_read_spec.rb
+++ b/spec/ruby/library/stringio/closed_read_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#closed_read?" do
it "returns true if self is not readable" do
- io = StringIO.new("example", "r+")
+ io = StringIO.new(+"example", "r+")
io.close_write
io.closed_read?.should be_false
io.close_read
diff --git a/spec/ruby/library/stringio/closed_spec.rb b/spec/ruby/library/stringio/closed_spec.rb
index ca8a2232a8..bf7ba63184 100644
--- a/spec/ruby/library/stringio/closed_spec.rb
+++ b/spec/ruby/library/stringio/closed_spec.rb
@@ -3,13 +3,13 @@ require_relative 'fixtures/classes'
describe "StringIO#closed?" do
it "returns true if self is completely closed" do
- io = StringIO.new("example", "r+")
+ io = StringIO.new(+"example", "r+")
io.close_read
io.closed?.should be_false
io.close_write
io.closed?.should be_true
- io = StringIO.new("example", "r+")
+ io = StringIO.new(+"example", "r+")
io.close
io.closed?.should be_true
end
diff --git a/spec/ruby/library/stringio/closed_write_spec.rb b/spec/ruby/library/stringio/closed_write_spec.rb
index 5c111affd8..2bd3e6fa8b 100644
--- a/spec/ruby/library/stringio/closed_write_spec.rb
+++ b/spec/ruby/library/stringio/closed_write_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#closed_write?" do
it "returns true if self is not writable" do
- io = StringIO.new("example", "r+")
+ io = StringIO.new(+"example", "r+")
io.close_read
io.closed_write?.should be_false
io.close_write
diff --git a/spec/ruby/library/stringio/codepoints_spec.rb b/spec/ruby/library/stringio/codepoints_spec.rb
deleted file mode 100644
index ceaadefc32..0000000000
--- a/spec/ruby/library/stringio/codepoints_spec.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- encoding: utf-8 -*-
-require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/codepoints'
-
-ruby_version_is ''...'3.0' do
- # See redmine #1667
- describe "StringIO#codepoints" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it_behaves_like :stringio_codepoints, :codepoints
- end
-end
diff --git a/spec/ruby/library/stringio/each_line_spec.rb b/spec/ruby/library/stringio/each_line_spec.rb
index 1389408399..c68f7dae82 100644
--- a/spec/ruby/library/stringio/each_line_spec.rb
+++ b/spec/ruby/library/stringio/each_line_spec.rb
@@ -17,3 +17,7 @@ end
describe "StringIO#each_line when passed chomp" do
it_behaves_like :stringio_each_chomp, :each_line
end
+
+describe "StringIO#each_line when passed limit" do
+ it_behaves_like :stringio_each_limit, :each_line
+end
diff --git a/spec/ruby/library/stringio/each_spec.rb b/spec/ruby/library/stringio/each_spec.rb
index a76460049b..2c30ed5cda 100644
--- a/spec/ruby/library/stringio/each_spec.rb
+++ b/spec/ruby/library/stringio/each_spec.rb
@@ -17,3 +17,11 @@ end
describe "StringIO#each when passed chomp" do
it_behaves_like :stringio_each_chomp, :each
end
+
+describe "StringIO#each when passed chomp" do
+ it_behaves_like :stringio_each_separator_and_chomp, :each
+end
+
+describe "StringIO#each when passed limit" do
+ it_behaves_like :stringio_each_limit, :each
+end
diff --git a/spec/ruby/library/stringio/flush_spec.rb b/spec/ruby/library/stringio/flush_spec.rb
index 17a16dfdd5..4dc58b1d48 100644
--- a/spec/ruby/library/stringio/flush_spec.rb
+++ b/spec/ruby/library/stringio/flush_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#flush" do
it "returns self" do
- io = StringIO.new("flush")
+ io = StringIO.new(+"flush")
io.flush.should equal(io)
end
end
diff --git a/spec/ruby/library/stringio/fsync_spec.rb b/spec/ruby/library/stringio/fsync_spec.rb
index 8fb2b59a24..85053cb2e5 100644
--- a/spec/ruby/library/stringio/fsync_spec.rb
+++ b/spec/ruby/library/stringio/fsync_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#fsync" do
it "returns zero" do
- io = StringIO.new("fsync")
+ io = StringIO.new(+"fsync")
io.fsync.should eql(0)
end
end
diff --git a/spec/ruby/library/stringio/gets_spec.rb b/spec/ruby/library/stringio/gets_spec.rb
index 97429e6a29..4af7704a41 100644
--- a/spec/ruby/library/stringio/gets_spec.rb
+++ b/spec/ruby/library/stringio/gets_spec.rb
@@ -171,6 +171,10 @@ describe "StringIO#gets when passed [limit]" do
it "returns a blank string when passed a limit of 0" do
@io.gets(0).should == ""
end
+
+ it "ignores it when passed a negative limit" do
+ @io.gets(-4).should == "this>is>an>example"
+ end
end
describe "StringIO#gets when passed [separator] and [limit]" do
@@ -229,7 +233,7 @@ end
describe "StringIO#gets when in write-only mode" do
it "raises an IOError" do
- io = StringIO.new("xyz", "w")
+ io = StringIO.new(+"xyz", "w")
-> { io.gets }.should raise_error(IOError)
io = StringIO.new("xyz")
diff --git a/spec/ruby/library/stringio/initialize_spec.rb b/spec/ruby/library/stringio/initialize_spec.rb
index 1e8096e3bb..ad067a0be1 100644
--- a/spec/ruby/library/stringio/initialize_spec.rb
+++ b/spec/ruby/library/stringio/initialize_spec.rb
@@ -13,99 +13,99 @@ describe "StringIO#initialize when passed [Object, mode]" do
it "sets the mode based on the passed mode" do
io = StringIO.allocate
- io.send(:initialize, "example", "r")
+ io.send(:initialize, +"example", "r")
io.closed_read?.should be_false
io.closed_write?.should be_true
io = StringIO.allocate
- io.send(:initialize, "example", "rb")
+ io.send(:initialize, +"example", "rb")
io.closed_read?.should be_false
io.closed_write?.should be_true
io = StringIO.allocate
- io.send(:initialize, "example", "r+")
+ io.send(:initialize, +"example", "r+")
io.closed_read?.should be_false
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", "rb+")
+ io.send(:initialize, +"example", "rb+")
io.closed_read?.should be_false
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", "w")
+ io.send(:initialize, +"example", "w")
io.closed_read?.should be_true
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", "wb")
+ io.send(:initialize, +"example", "wb")
io.closed_read?.should be_true
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", "w+")
+ io.send(:initialize, +"example", "w+")
io.closed_read?.should be_false
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", "wb+")
+ io.send(:initialize, +"example", "wb+")
io.closed_read?.should be_false
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", "a")
+ io.send(:initialize, +"example", "a")
io.closed_read?.should be_true
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", "ab")
+ io.send(:initialize, +"example", "ab")
io.closed_read?.should be_true
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", "a+")
+ io.send(:initialize, +"example", "a+")
io.closed_read?.should be_false
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", "ab+")
+ io.send(:initialize, +"example", "ab+")
io.closed_read?.should be_false
io.closed_write?.should be_false
end
it "allows passing the mode as an Integer" do
io = StringIO.allocate
- io.send(:initialize, "example", IO::RDONLY)
+ io.send(:initialize, +"example", IO::RDONLY)
io.closed_read?.should be_false
io.closed_write?.should be_true
io = StringIO.allocate
- io.send(:initialize, "example", IO::RDWR)
+ io.send(:initialize, +"example", IO::RDWR)
io.closed_read?.should be_false
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", IO::WRONLY)
+ io.send(:initialize, +"example", IO::WRONLY)
io.closed_read?.should be_true
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", IO::WRONLY | IO::TRUNC)
+ io.send(:initialize, +"example", IO::WRONLY | IO::TRUNC)
io.closed_read?.should be_true
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", IO::RDWR | IO::TRUNC)
+ io.send(:initialize, +"example", IO::RDWR | IO::TRUNC)
io.closed_read?.should be_false
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", IO::WRONLY | IO::APPEND)
+ io.send(:initialize, +"example", IO::WRONLY | IO::APPEND)
io.closed_read?.should be_true
io.closed_write?.should be_false
io = StringIO.allocate
- io.send(:initialize, "example", IO::RDWR | IO::APPEND)
+ io.send(:initialize, +"example", IO::RDWR | IO::APPEND)
io.closed_read?.should be_false
io.closed_write?.should be_false
end
@@ -118,7 +118,7 @@ describe "StringIO#initialize when passed [Object, mode]" do
it "tries to convert the passed mode to a String using #to_str" do
obj = mock('to_str')
obj.should_receive(:to_str).and_return("r")
- @io.send(:initialize, "example", obj)
+ @io.send(:initialize, +"example", obj)
@io.closed_read?.should be_false
@io.closed_write?.should be_true
@@ -142,12 +142,18 @@ describe "StringIO#initialize when passed [Object]" do
@io.string.should equal(str)
end
- it "sets the mode to read-write" do
- @io.send(:initialize, "example")
+ it "sets the mode to read-write if the string is mutable" do
+ @io.send(:initialize, +"example")
@io.closed_read?.should be_false
@io.closed_write?.should be_false
end
+ it "sets the mode to read if the string is frozen" do
+ @io.send(:initialize, -"example")
+ @io.closed_read?.should be_false
+ @io.closed_write?.should be_true
+ end
+
it "tries to convert the passed Object to a String using #to_str" do
obj = mock('to_str')
obj.should_receive(:to_str).and_return("example")
@@ -163,6 +169,91 @@ describe "StringIO#initialize when passed [Object]" do
end
end
+# NOTE: Synchronise with core/io/new_spec.rb (core/io/shared/new.rb)
+describe "StringIO#initialize when passed keyword arguments" do
+ it "sets the mode based on the passed :mode option" do
+ io = StringIO.new("example", "r")
+ io.closed_read?.should be_false
+ io.closed_write?.should be_true
+ end
+
+ it "accepts a mode argument set to nil with a valid :mode option" do
+ @io = StringIO.new(+'', nil, mode: "w")
+ @io.write("foo").should == 3
+ end
+
+ it "accepts a mode argument with a :mode option set to nil" do
+ @io = StringIO.new(+'', "w", mode: nil)
+ @io.write("foo").should == 3
+ end
+
+ it "sets binmode from :binmode option" do
+ @io = StringIO.new(+'', 'w', binmode: true)
+ @io.external_encoding.to_s.should == "ASCII-8BIT" # #binmode? isn't implemented in StringIO
+ end
+
+ it "does not set binmode from false :binmode" do
+ @io = StringIO.new(+'', 'w', binmode: false)
+ @io.external_encoding.to_s.should == "UTF-8" # #binmode? isn't implemented in StringIO
+ end
+end
+
+# NOTE: Synchronise with core/io/new_spec.rb (core/io/shared/new.rb)
+describe "StringIO#initialize when passed keyword arguments and error happens" do
+ it "raises an error if passed encodings two ways" do
+ -> {
+ @io = StringIO.new(+'', 'w:ISO-8859-1', encoding: 'ISO-8859-1')
+ }.should raise_error(ArgumentError)
+ -> {
+ @io = StringIO.new(+'', 'w:ISO-8859-1', external_encoding: 'ISO-8859-1')
+ }.should raise_error(ArgumentError)
+ -> {
+ @io = StringIO.new(+'', 'w:ISO-8859-1:UTF-8', internal_encoding: 'ISO-8859-1')
+ }.should raise_error(ArgumentError)
+ end
+
+ it "raises an error if passed matching binary/text mode two ways" do
+ -> {
+ @io = StringIO.new(+'', "wb", binmode: true)
+ }.should raise_error(ArgumentError)
+ -> {
+ @io = StringIO.new(+'', "wt", textmode: true)
+ }.should raise_error(ArgumentError)
+
+ -> {
+ @io = StringIO.new(+'', "wb", textmode: false)
+ }.should raise_error(ArgumentError)
+ -> {
+ @io = StringIO.new(+'', "wt", binmode: false)
+ }.should raise_error(ArgumentError)
+ end
+
+ it "raises an error if passed conflicting binary/text mode two ways" do
+ -> {
+ @io = StringIO.new(+'', "wb", binmode: false)
+ }.should raise_error(ArgumentError)
+ -> {
+ @io = StringIO.new(+'', "wt", textmode: false)
+ }.should raise_error(ArgumentError)
+
+ -> {
+ @io = StringIO.new(+'', "wb", textmode: true)
+ }.should raise_error(ArgumentError)
+ -> {
+ @io = StringIO.new(+'', "wt", binmode: true)
+ }.should raise_error(ArgumentError)
+ end
+
+ it "raises an error when trying to set both binmode and textmode" do
+ -> {
+ @io = StringIO.new(+'', "w", textmode: true, binmode: true)
+ }.should raise_error(ArgumentError)
+ -> {
+ @io = StringIO.new(+'', File::Constants::WRONLY, textmode: true, binmode: true)
+ }.should raise_error(ArgumentError)
+ end
+end
+
describe "StringIO#initialize when passed no arguments" do
before :each do
@io = StringIO.allocate
@@ -173,7 +264,7 @@ describe "StringIO#initialize when passed no arguments" do
end
it "sets the mode to read-write" do
- @io.send(:initialize, "example")
+ @io.send(:initialize)
@io.closed_read?.should be_false
@io.closed_write?.should be_false
end
@@ -204,19 +295,14 @@ describe "StringIO#initialize sets" do
end
it "the encoding to the encoding of the String when passed a String" do
- s = ''.force_encoding(Encoding::EUC_JP)
+ s = ''.dup.force_encoding(Encoding::EUC_JP)
io = StringIO.new(s)
io.string.encoding.should == Encoding::EUC_JP
end
- guard_not -> { # [Bug #16497]
- stringio_version = StringIO.const_defined?(:VERSION) ? StringIO::VERSION : "0.0.2"
- version_is(stringio_version, "0.0.3"..."0.1.1")
- } do
- it "the #external_encoding to the encoding of the String when passed a String" do
- s = ''.force_encoding(Encoding::EUC_JP)
- io = StringIO.new(s)
- io.external_encoding.should == Encoding::EUC_JP
- end
+ it "the #external_encoding to the encoding of the String when passed a String" do
+ s = ''.dup.force_encoding(Encoding::EUC_JP)
+ io = StringIO.new(s)
+ io.external_encoding.should == Encoding::EUC_JP
end
end
diff --git a/spec/ruby/library/stringio/lines_spec.rb b/spec/ruby/library/stringio/lines_spec.rb
deleted file mode 100644
index 42d11772ae..0000000000
--- a/spec/ruby/library/stringio/lines_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require_relative '../../spec_helper'
-require 'stringio'
-require_relative 'shared/each'
-
-ruby_version_is ''...'3.0' do
- describe "StringIO#lines when passed a separator" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it_behaves_like :stringio_each_separator, :lines
- end
-
- describe "StringIO#lines when passed no arguments" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it_behaves_like :stringio_each_no_arguments, :lines
- end
-
- describe "StringIO#lines when self is not readable" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it_behaves_like :stringio_each_not_readable, :lines
- end
-
- describe "StringIO#lines when passed chomp" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it_behaves_like :stringio_each_chomp, :lines
- end
-end
diff --git a/spec/ruby/library/stringio/new_spec.rb b/spec/ruby/library/stringio/new_spec.rb
new file mode 100644
index 0000000000..ec4b32aa11
--- /dev/null
+++ b/spec/ruby/library/stringio/new_spec.rb
@@ -0,0 +1,10 @@
+require_relative '../../spec_helper'
+require 'stringio'
+
+describe "StringIO.new" do
+ it "does not use the given block and warns to use StringIO::open" do
+ -> {
+ StringIO.new { raise }
+ }.should complain(/warning: StringIO::new\(\) does not take block; use StringIO::open\(\) instead/)
+ end
+end
diff --git a/spec/ruby/library/stringio/open_spec.rb b/spec/ruby/library/stringio/open_spec.rb
index acab6e9056..b7c90661f9 100644
--- a/spec/ruby/library/stringio/open_spec.rb
+++ b/spec/ruby/library/stringio/open_spec.rb
@@ -8,26 +8,26 @@ describe "StringIO.open when passed [Object, mode]" do
end
it "returns the blocks return value when yielding" do
- ret = StringIO.open("example", "r") { :test }
+ ret = StringIO.open(+"example", "r") { :test }
ret.should equal(:test)
end
it "yields self to the passed block" do
io = nil
- StringIO.open("example", "r") { |strio| io = strio }
+ StringIO.open(+"example", "r") { |strio| io = strio }
io.should be_kind_of(StringIO)
end
it "closes self after yielding" do
io = nil
- StringIO.open("example", "r") { |strio| io = strio }
+ StringIO.open(+"example", "r") { |strio| io = strio }
io.closed?.should be_true
end
it "even closes self when an exception is raised while yielding" do
io = nil
begin
- StringIO.open("example", "r") do |strio|
+ StringIO.open(+"example", "r") do |strio|
io = strio
raise "Error"
end
@@ -38,14 +38,14 @@ describe "StringIO.open when passed [Object, mode]" do
it "sets self's string to nil after yielding" do
io = nil
- StringIO.open("example", "r") { |strio| io = strio }
+ StringIO.open(+"example", "r") { |strio| io = strio }
io.string.should be_nil
end
it "even sets self's string to nil when an exception is raised while yielding" do
io = nil
begin
- StringIO.open("example", "r") do |strio|
+ StringIO.open(+"example", "r") do |strio|
io = strio
raise "Error"
end
@@ -55,81 +55,81 @@ describe "StringIO.open when passed [Object, mode]" do
end
it "sets the mode based on the passed mode" do
- io = StringIO.open("example", "r")
+ io = StringIO.open(+"example", "r")
io.closed_read?.should be_false
io.closed_write?.should be_true
- io = StringIO.open("example", "rb")
+ io = StringIO.open(+"example", "rb")
io.closed_read?.should be_false
io.closed_write?.should be_true
- io = StringIO.open("example", "r+")
+ io = StringIO.open(+"example", "r+")
io.closed_read?.should be_false
io.closed_write?.should be_false
- io = StringIO.open("example", "rb+")
+ io = StringIO.open(+"example", "rb+")
io.closed_read?.should be_false
io.closed_write?.should be_false
- io = StringIO.open("example", "w")
+ io = StringIO.open(+"example", "w")
io.closed_read?.should be_true
io.closed_write?.should be_false
- io = StringIO.open("example", "wb")
+ io = StringIO.open(+"example", "wb")
io.closed_read?.should be_true
io.closed_write?.should be_false
- io = StringIO.open("example", "w+")
+ io = StringIO.open(+"example", "w+")
io.closed_read?.should be_false
io.closed_write?.should be_false
- io = StringIO.open("example", "wb+")
+ io = StringIO.open(+"example", "wb+")
io.closed_read?.should be_false
io.closed_write?.should be_false
- io = StringIO.open("example", "a")
+ io = StringIO.open(+"example", "a")
io.closed_read?.should be_true
io.closed_write?.should be_false
- io = StringIO.open("example", "ab")
+ io = StringIO.open(+"example", "ab")
io.closed_read?.should be_true
io.closed_write?.should be_false
- io = StringIO.open("example", "a+")
+ io = StringIO.open(+"example", "a+")
io.closed_read?.should be_false
io.closed_write?.should be_false
- io = StringIO.open("example", "ab+")
+ io = StringIO.open(+"example", "ab+")
io.closed_read?.should be_false
io.closed_write?.should be_false
end
it "allows passing the mode as an Integer" do
- io = StringIO.open("example", IO::RDONLY)
+ io = StringIO.open(+"example", IO::RDONLY)
io.closed_read?.should be_false
io.closed_write?.should be_true
- io = StringIO.open("example", IO::RDWR)
+ io = StringIO.open(+"example", IO::RDWR)
io.closed_read?.should be_false
io.closed_write?.should be_false
- io = StringIO.open("example", IO::WRONLY)
+ io = StringIO.open(+"example", IO::WRONLY)
io.closed_read?.should be_true
io.closed_write?.should be_false
- io = StringIO.open("example", IO::WRONLY | IO::TRUNC)
+ io = StringIO.open(+"example", IO::WRONLY | IO::TRUNC)
io.closed_read?.should be_true
io.closed_write?.should be_false
- io = StringIO.open("example", IO::RDWR | IO::TRUNC)
+ io = StringIO.open(+"example", IO::RDWR | IO::TRUNC)
io.closed_read?.should be_false
io.closed_write?.should be_false
- io = StringIO.open("example", IO::WRONLY | IO::APPEND)
+ io = StringIO.open(+"example", IO::WRONLY | IO::APPEND)
io.closed_read?.should be_true
io.closed_write?.should be_false
- io = StringIO.open("example", IO::RDWR | IO::APPEND)
+ io = StringIO.open(+"example", IO::RDWR | IO::APPEND)
io.closed_read?.should be_false
io.closed_write?.should be_false
end
@@ -141,7 +141,7 @@ describe "StringIO.open when passed [Object, mode]" do
it "tries to convert the passed mode to a String using #to_str" do
obj = mock('to_str')
obj.should_receive(:to_str).and_return("r")
- io = StringIO.open("example", obj)
+ io = StringIO.open(+"example", obj)
io.closed_read?.should be_false
io.closed_write?.should be_true
@@ -163,14 +163,18 @@ describe "StringIO.open when passed [Object]" do
it "yields self to the passed block" do
io = nil
- ret = StringIO.open("example") { |strio| io = strio }
+ ret = StringIO.open(+"example") { |strio| io = strio }
io.should equal(ret)
end
- it "sets the mode to read-write" do
- io = StringIO.open("example")
+ it "sets the mode to read-write (r+)" do
+ io = StringIO.open(+"example")
io.closed_read?.should be_false
io.closed_write?.should be_false
+
+ io = StringIO.new(+"example")
+ io.printf("%d", 123)
+ io.string.should == "123mple"
end
it "tries to convert the passed Object to a String using #to_str" do
@@ -195,10 +199,14 @@ describe "StringIO.open when passed no arguments" do
io.should equal(ret)
end
- it "sets the mode to read-write" do
+ it "sets the mode to read-write (r+)" do
io = StringIO.open
io.closed_read?.should be_false
io.closed_write?.should be_false
+
+ io = StringIO.new(+"example")
+ io.printf("%d", 123)
+ io.string.should == "123mple"
end
it "uses an empty String as the StringIO backend" do
diff --git a/spec/ruby/library/stringio/print_spec.rb b/spec/ruby/library/stringio/print_spec.rb
index 6ac6430900..00c33367dc 100644
--- a/spec/ruby/library/stringio/print_spec.rb
+++ b/spec/ruby/library/stringio/print_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#print" do
before :each do
- @io = StringIO.new('example')
+ @io = StringIO.new(+'example')
end
it "prints $_ when passed no arguments" do
@@ -73,7 +73,7 @@ end
describe "StringIO#print when in append mode" do
before :each do
- @io = StringIO.new("example", "a")
+ @io = StringIO.new(+"example", "a")
end
it "appends the passed argument to the end of self" do
@@ -92,10 +92,10 @@ end
describe "StringIO#print when self is not writable" do
it "raises an IOError" do
- io = StringIO.new("test", "r")
+ io = StringIO.new(+"test", "r")
-> { io.print("test") }.should raise_error(IOError)
- io = StringIO.new("test")
+ io = StringIO.new(+"test")
io.close_write
-> { io.print("test") }.should raise_error(IOError)
end
diff --git a/spec/ruby/library/stringio/printf_spec.rb b/spec/ruby/library/stringio/printf_spec.rb
index 9dd1a3b410..ca82e84757 100644
--- a/spec/ruby/library/stringio/printf_spec.rb
+++ b/spec/ruby/library/stringio/printf_spec.rb
@@ -4,7 +4,7 @@ require_relative '../../core/kernel/shared/sprintf'
describe "StringIO#printf" do
before :each do
- @io = StringIO.new('example')
+ @io = StringIO.new()
end
it "returns nil" do
@@ -12,9 +12,9 @@ describe "StringIO#printf" do
end
it "pads self with \\000 when the current position is after the end" do
- @io.pos = 10
+ @io.pos = 3
@io.printf("%d", 123)
- @io.string.should == "example\000\000\000123"
+ @io.string.should == "\000\000\000123"
end
it "performs format conversion" do
@@ -39,9 +39,30 @@ describe "StringIO#printf" do
end
end
+describe "StringIO#printf when in read-write mode" do
+ before :each do
+ @io = StringIO.new(+"example", "r+")
+ end
+
+ it "starts from the beginning" do
+ @io.printf("%s", "abcdefghijk")
+ @io.string.should == "abcdefghijk"
+ end
+
+ it "does not truncate existing string" do
+ @io.printf("%s", "abc")
+ @io.string.should == "abcmple"
+ end
+
+ it "correctly updates self's position" do
+ @io.printf("%s", "abc")
+ @io.pos.should eql(3)
+ end
+end
+
describe "StringIO#printf when in append mode" do
before :each do
- @io = StringIO.new("example", "a")
+ @io = StringIO.new(+"example", "a")
end
it "appends the passed argument to the end of self" do
@@ -60,10 +81,10 @@ end
describe "StringIO#printf when self is not writable" do
it "raises an IOError" do
- io = StringIO.new("test", "r")
+ io = StringIO.new(+"test", "r")
-> { io.printf("test") }.should raise_error(IOError)
- io = StringIO.new("test")
+ io = StringIO.new(+"test")
io.close_write
-> { io.printf("test") }.should raise_error(IOError)
end
diff --git a/spec/ruby/library/stringio/putc_spec.rb b/spec/ruby/library/stringio/putc_spec.rb
index 223b3523e5..9f1ac8ffb2 100644
--- a/spec/ruby/library/stringio/putc_spec.rb
+++ b/spec/ruby/library/stringio/putc_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#putc when passed [String]" do
before :each do
- @io = StringIO.new('example')
+ @io = StringIO.new(+'example')
end
it "overwrites the character at the current position" do
@@ -35,11 +35,26 @@ describe "StringIO#putc when passed [String]" do
@io.putc("t")
@io.pos.should == 3
end
+
+ it "handles concurrent writes correctly" do
+ @io = StringIO.new
+ n = 8
+ go = false
+ threads = n.times.map { |i|
+ Thread.new {
+ Thread.pass until go
+ @io.putc i.to_s
+ }
+ }
+ go = true
+ threads.each(&:join)
+ @io.string.size.should == n
+ end
end
describe "StringIO#putc when passed [Object]" do
before :each do
- @io = StringIO.new('example')
+ @io = StringIO.new(+'example')
end
it "it writes the passed Integer % 256 to self" do
@@ -70,7 +85,7 @@ end
describe "StringIO#putc when in append mode" do
it "appends to the end of self" do
- io = StringIO.new("test", "a")
+ io = StringIO.new(+"test", "a")
io.putc(?t)
io.string.should == "testt"
end
@@ -78,10 +93,10 @@ end
describe "StringIO#putc when self is not writable" do
it "raises an IOError" do
- io = StringIO.new("test", "r")
+ io = StringIO.new(+"test", "r")
-> { io.putc(?a) }.should raise_error(IOError)
- io = StringIO.new("test")
+ io = StringIO.new(+"test")
io.close_write
-> { io.putc("t") }.should raise_error(IOError)
end
diff --git a/spec/ruby/library/stringio/puts_spec.rb b/spec/ruby/library/stringio/puts_spec.rb
index a9f289a5a5..054ec8227f 100644
--- a/spec/ruby/library/stringio/puts_spec.rb
+++ b/spec/ruby/library/stringio/puts_spec.rb
@@ -101,6 +101,20 @@ describe "StringIO#puts when passed 1 or more objects" do
@io.puts ''
@io.string.should == "\n"
end
+
+ it "handles concurrent writes correctly" do
+ n = 8
+ go = false
+ threads = n.times.map { |i|
+ Thread.new {
+ Thread.pass until go
+ @io.puts i
+ }
+ }
+ go = true
+ threads.each(&:join)
+ @io.string.size.should == n.times.map { |i| "#{i}\n" }.join.size
+ end
end
describe "StringIO#puts when passed no arguments" do
@@ -131,7 +145,7 @@ end
describe "StringIO#puts when in append mode" do
before :each do
- @io = StringIO.new("example", "a")
+ @io = StringIO.new(+"example", "a")
end
it "appends the passed argument to the end of self" do
@@ -150,10 +164,10 @@ end
describe "StringIO#puts when self is not writable" do
it "raises an IOError" do
- io = StringIO.new("test", "r")
+ io = StringIO.new(+"test", "r")
-> { io.puts }.should raise_error(IOError)
- io = StringIO.new("test")
+ io = StringIO.new(+"test")
io.close_write
-> { io.puts }.should raise_error(IOError)
end
@@ -161,7 +175,7 @@ end
describe "StringIO#puts when passed an encoded string" do
it "stores the bytes unmodified" do
- io = StringIO.new("")
+ io = StringIO.new(+"")
io.puts "\x00\x01\x02"
io.puts "æåø"
diff --git a/spec/ruby/library/stringio/read_nonblock_spec.rb b/spec/ruby/library/stringio/read_nonblock_spec.rb
index 2a8f926bd0..74736f7792 100644
--- a/spec/ruby/library/stringio/read_nonblock_spec.rb
+++ b/spec/ruby/library/stringio/read_nonblock_spec.rb
@@ -5,10 +5,21 @@ require_relative 'shared/sysread'
describe "StringIO#read_nonblock when passed length, buffer" do
it_behaves_like :stringio_read, :read_nonblock
+
+ it "accepts :exception option" do
+ io = StringIO.new("example")
+ io.read_nonblock(3, buffer = +"", exception: true)
+ buffer.should == "exa"
+ end
end
describe "StringIO#read_nonblock when passed length" do
it_behaves_like :stringio_read_length, :read_nonblock
+
+ it "accepts :exception option" do
+ io = StringIO.new("example")
+ io.read_nonblock(3, exception: true).should == "exa"
+ end
end
describe "StringIO#read_nonblock when passed nil" do
@@ -29,7 +40,7 @@ describe "StringIO#read_nonblock" do
context "when exception option is set to false" do
context "when the end is reached" do
it "returns nil" do
- stringio = StringIO.new('')
+ stringio = StringIO.new(+'')
stringio << "hello"
stringio.rewind
diff --git a/spec/ruby/library/stringio/read_spec.rb b/spec/ruby/library/stringio/read_spec.rb
index 52ab3dcf47..e49f262127 100644
--- a/spec/ruby/library/stringio/read_spec.rb
+++ b/spec/ruby/library/stringio/read_spec.rb
@@ -53,7 +53,7 @@ describe "StringIO#read when passed length and a buffer" do
end
it "reads [length] characters into the buffer" do
- buf = "foo"
+ buf = +"foo"
result = @io.read(10, buf)
buf.should == "abcdefghij"
diff --git a/spec/ruby/library/stringio/readline_spec.rb b/spec/ruby/library/stringio/readline_spec.rb
index 94b67bc92d..b16a16e23f 100644
--- a/spec/ruby/library/stringio/readline_spec.rb
+++ b/spec/ruby/library/stringio/readline_spec.rb
@@ -113,7 +113,7 @@ end
describe "StringIO#readline when in write-only mode" do
it "raises an IOError" do
- io = StringIO.new("xyz", "w")
+ io = StringIO.new(+"xyz", "w")
-> { io.readline }.should raise_error(IOError)
io = StringIO.new("xyz")
@@ -128,3 +128,23 @@ describe "StringIO#readline when passed [chomp]" do
io.readline(chomp: true).should == "this>is>an>example"
end
end
+
+describe "StringIO#readline when passed [limit]" do
+ before :each do
+ @io = StringIO.new("this>is>an>example")
+ end
+
+ it "returns the data read until the limit is met" do
+ io = StringIO.new("this>is>an>example\n")
+ io.readline(3).should == "thi"
+ end
+
+ it "returns a blank string when passed a limit of 0" do
+ @io.readline(0).should == ""
+ end
+
+ it "ignores it when the limit is negative" do
+ seen = []
+ @io.readline(-4).should == "this>is>an>example"
+ end
+end
diff --git a/spec/ruby/library/stringio/readlines_spec.rb b/spec/ruby/library/stringio/readlines_spec.rb
index 4b007787e2..ed7cc22b3d 100644
--- a/spec/ruby/library/stringio/readlines_spec.rb
+++ b/spec/ruby/library/stringio/readlines_spec.rb
@@ -83,7 +83,7 @@ end
describe "StringIO#readlines when in write-only mode" do
it "raises an IOError" do
- io = StringIO.new("xyz", "w")
+ io = StringIO.new(+"xyz", "w")
-> { io.readlines }.should raise_error(IOError)
io = StringIO.new("xyz")
@@ -98,3 +98,21 @@ describe "StringIO#readlines when passed [chomp]" do
io.readlines(chomp: true).should == ["this>is", "an>example"]
end
end
+
+describe "StringIO#readlines when passed [limit]" do
+ before :each do
+ @io = StringIO.new("a b c d e\n1 2 3 4 5")
+ end
+
+ it "returns the data read until the limit is met" do
+ @io.readlines(4).should == ["a b ", "c d ", "e\n", "1 2 ", "3 4 ", "5"]
+ end
+
+ it "raises ArgumentError when limit is 0" do
+ -> { @io.readlines(0) }.should raise_error(ArgumentError)
+ end
+
+ it "ignores it when the limit is negative" do
+ @io.readlines(-4).should == ["a b c d e\n", "1 2 3 4 5"]
+ end
+end
diff --git a/spec/ruby/library/stringio/readpartial_spec.rb b/spec/ruby/library/stringio/readpartial_spec.rb
index 2601fe8c42..f25cef4014 100644
--- a/spec/ruby/library/stringio/readpartial_spec.rb
+++ b/spec/ruby/library/stringio/readpartial_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#readpartial" do
before :each do
- @string = StringIO.new('Stop, look, listen')
+ @string = StringIO.new(+'Stop, look, listen')
end
after :each do
@@ -48,7 +48,7 @@ describe "StringIO#readpartial" do
end
it "discards the existing buffer content upon successful read" do
- buffer = "existing"
+ buffer = +"existing"
@string.readpartial(11, buffer)
buffer.should == "Stop, look,"
end
@@ -59,7 +59,7 @@ describe "StringIO#readpartial" do
end
it "discards the existing buffer content upon error" do
- buffer = 'hello'
+ buffer = +'hello'
@string.readpartial(100)
-> { @string.readpartial(1, buffer) }.should raise_error(EOFError)
buffer.should be_empty
diff --git a/spec/ruby/library/stringio/reopen_spec.rb b/spec/ruby/library/stringio/reopen_spec.rb
index 6752cf9970..7021ff17e5 100644
--- a/spec/ruby/library/stringio/reopen_spec.rb
+++ b/spec/ruby/library/stringio/reopen_spec.rb
@@ -12,31 +12,20 @@ describe "StringIO#reopen when passed [Object, Integer]" do
@io.closed_write?.should be_true
@io.string.should == "reopened"
- @io.reopen("reopened, twice", IO::WRONLY)
+ @io.reopen(+"reopened, twice", IO::WRONLY)
@io.closed_read?.should be_true
@io.closed_write?.should be_false
@io.string.should == "reopened, twice"
- @io.reopen("reopened, another time", IO::RDWR)
+ @io.reopen(+"reopened, another time", IO::RDWR)
@io.closed_read?.should be_false
@io.closed_write?.should be_false
@io.string.should == "reopened, another time"
end
- ruby_version_is ""..."3.0" do
- # NOTE: WEIRD!
- it "does not taint self when the passed Object was tainted" do
- @io.reopen("reopened".taint, IO::RDONLY)
- @io.tainted?.should be_false
-
- @io.reopen("reopened".taint, IO::WRONLY)
- @io.tainted?.should be_false
- end
- end
-
it "tries to convert the passed Object to a String using #to_str" do
obj = mock("to_str")
- obj.should_receive(:to_str).and_return("to_str")
+ obj.should_receive(:to_str).and_return(+"to_str")
@io.reopen(obj, IO::RDWR)
@io.string.should == "to_str"
end
@@ -71,38 +60,27 @@ describe "StringIO#reopen when passed [Object, Object]" do
@io.closed_write?.should be_true
@io.string.should == "reopened"
- @io.reopen("reopened, twice", "r+")
+ @io.reopen(+"reopened, twice", "r+")
@io.closed_read?.should be_false
@io.closed_write?.should be_false
@io.string.should == "reopened, twice"
- @io.reopen("reopened, another", "w+")
+ @io.reopen(+"reopened, another", "w+")
@io.closed_read?.should be_false
@io.closed_write?.should be_false
@io.string.should == ""
- @io.reopen("reopened, another time", "r+")
+ @io.reopen(+"reopened, another time", "r+")
@io.closed_read?.should be_false
@io.closed_write?.should be_false
@io.string.should == "reopened, another time"
end
it "truncates the passed String when opened in truncate mode" do
- @io.reopen(str = "reopened", "w")
+ @io.reopen(str = +"reopened", "w")
str.should == ""
end
- ruby_version_is ""..."3.0" do
- # NOTE: WEIRD!
- it "does not taint self when the passed Object was tainted" do
- @io.reopen("reopened".taint, "r")
- @io.tainted?.should be_false
-
- @io.reopen("reopened".taint, "w")
- @io.tainted?.should be_false
- end
- end
-
it "tries to convert the passed Object to a String using #to_str" do
obj = mock("to_str")
obj.should_receive(:to_str).and_return("to_str")
@@ -116,13 +94,13 @@ describe "StringIO#reopen when passed [Object, Object]" do
it "resets self's position to 0" do
@io.read(5)
- @io.reopen("reopened")
+ @io.reopen(+"reopened")
@io.pos.should eql(0)
end
it "resets self's line number to 0" do
@io.gets
- @io.reopen("reopened")
+ @io.reopen(+"reopened")
@io.lineno.should eql(0)
end
@@ -156,7 +134,7 @@ describe "StringIO#reopen when passed [String]" do
it "reopens self with the passed String in read-write mode" do
@io.close
- @io.reopen("reopened")
+ @io.reopen(+"reopened")
@io.closed_write?.should be_false
@io.closed_read?.should be_false
@@ -164,23 +142,15 @@ describe "StringIO#reopen when passed [String]" do
@io.string.should == "reopened"
end
- ruby_version_is ""..."3.0" do
- # NOTE: WEIRD!
- it "does not taint self when the passed Object was tainted" do
- @io.reopen("reopened".taint)
- @io.tainted?.should be_false
- end
- end
-
it "resets self's position to 0" do
@io.read(5)
- @io.reopen("reopened")
+ @io.reopen(+"reopened")
@io.pos.should eql(0)
end
it "resets self's line number to 0" do
@io.gets
- @io.reopen("reopened")
+ @io.reopen(+"reopened")
@io.lineno.should eql(0)
end
end
@@ -202,18 +172,10 @@ describe "StringIO#reopen when passed [Object]" do
it "tries to convert the passed Object to a StringIO using #to_strio" do
obj = mock("to_strio")
- obj.should_receive(:to_strio).and_return(StringIO.new("to_strio"))
+ obj.should_receive(:to_strio).and_return(StringIO.new(+"to_strio"))
@io.reopen(obj)
@io.string.should == "to_strio"
end
-
- # NOTE: WEIRD!
- ruby_version_is ""..."2.7" do
- it "taints self when the passed Object was tainted" do
- @io.reopen(StringIO.new("reopened").taint)
- @io.tainted?.should be_true
- end
- end
end
describe "StringIO#reopen when passed no arguments" do
@@ -246,49 +208,40 @@ end
# for details.
describe "StringIO#reopen" do
before :each do
- @io = StringIO.new('hello','a')
+ @io = StringIO.new(+'hello', 'a')
end
# TODO: find out if this is really a bug
it "reopens a stream when given a String argument" do
- @io.reopen('goodbye').should == @io
+ @io.reopen(+'goodbye').should == @io
@io.string.should == 'goodbye'
@io << 'x'
@io.string.should == 'xoodbye'
end
it "reopens a stream in append mode when flagged as such" do
- @io.reopen('goodbye', 'a').should == @io
+ @io.reopen(+'goodbye', 'a').should == @io
@io.string.should == 'goodbye'
@io << 'x'
@io.string.should == 'goodbyex'
end
it "reopens and truncate when reopened in write mode" do
- @io.reopen('goodbye', 'wb').should == @io
+ @io.reopen(+'goodbye', 'wb').should == @io
@io.string.should == ''
@io << 'x'
@io.string.should == 'x'
end
it "truncates the given string, not a copy" do
- str = 'goodbye'
+ str = +'goodbye'
@io.reopen(str, 'w')
@io.string.should == ''
str.should == ''
end
- ruby_version_is ""..."2.7" do
- it "taints self if the provided StringIO argument is tainted" do
- new_io = StringIO.new("tainted")
- new_io.taint
- @io.reopen(new_io)
- @io.should.tainted?
- end
- end
-
it "does not truncate the content even when the StringIO argument is in the truncate mode" do
- orig_io = StringIO.new("Original StringIO", IO::RDWR|IO::TRUNC)
+ orig_io = StringIO.new(+"Original StringIO", IO::RDWR|IO::TRUNC)
orig_io.write("BLAH") # make sure the content is not empty
@io.reopen(orig_io)
diff --git a/spec/ruby/library/stringio/set_encoding_spec.rb b/spec/ruby/library/stringio/set_encoding_spec.rb
index 21d45750f3..19ca0875bf 100644
--- a/spec/ruby/library/stringio/set_encoding_spec.rb
+++ b/spec/ruby/library/stringio/set_encoding_spec.rb
@@ -17,4 +17,12 @@ describe "StringIO#set_encoding" do
io.set_encoding Encoding::UTF_8
io.string.encoding.should == Encoding::US_ASCII
end
+
+ it "accepts a String" do
+ str = "".encode(Encoding::US_ASCII)
+ io = StringIO.new(str)
+ io.set_encoding("ASCII-8BIT")
+ io.external_encoding.should == Encoding::BINARY
+ str.encoding.should == Encoding::BINARY
+ end
end
diff --git a/spec/ruby/library/stringio/shared/codepoints.rb b/spec/ruby/library/stringio/shared/codepoints.rb
index 9d84aa4919..25333bb0fd 100644
--- a/spec/ruby/library/stringio/shared/codepoints.rb
+++ b/spec/ruby/library/stringio/shared/codepoints.rb
@@ -27,7 +27,7 @@ describe :stringio_codepoints, shared: true do
@io.close_read
-> { @enum.to_a }.should raise_error(IOError)
- io = StringIO.new("xyz", "w")
+ io = StringIO.new(+"xyz", "w")
-> { io.send(@method).to_a }.should raise_error(IOError)
end
diff --git a/spec/ruby/library/stringio/shared/each.rb b/spec/ruby/library/stringio/shared/each.rb
index 14b0a013b3..e0dd3f9b8f 100644
--- a/spec/ruby/library/stringio/shared/each.rb
+++ b/spec/ruby/library/stringio/shared/each.rb
@@ -36,11 +36,22 @@ describe :stringio_each_separator, shared: true do
seen.should == ["2 1 2 1 2"]
end
- it "yields each paragraph when passed an empty String as separator" do
- seen = []
- io = StringIO.new("para1\n\npara2\n\n\npara3")
- io.send(@method, "") {|s| seen << s}
- seen.should == ["para1\n\n", "para2\n\n", "para3"]
+ version_is StringIO::VERSION, ""..."3.0.4" do #ruby_version_is ""..."3.2" do
+ it "yields each paragraph with two separation characters when passed an empty String as separator" do
+ seen = []
+ io = StringIO.new("para1\n\npara2\n\n\npara3")
+ io.send(@method, "") {|s| seen << s}
+ seen.should == ["para1\n\n", "para2\n\n", "para3"]
+ end
+ end
+
+ version_is StringIO::VERSION, "3.0.4" do #ruby_version_is "3.2" do
+ it "yields each paragraph with all separation characters when passed an empty String as separator" do
+ seen = []
+ io = StringIO.new("para1\n\npara2\n\n\npara3")
+ io.send(@method, "") {|s| seen << s}
+ seen.should == ["para1\n\n", "para2\n\n\n", "para3"]
+ end
end
end
@@ -96,7 +107,7 @@ end
describe :stringio_each_not_readable, shared: true do
it "raises an IOError" do
- io = StringIO.new("a b c d e", "w")
+ io = StringIO.new(+"a b c d e", "w")
-> { io.send(@method) { |b| b } }.should raise_error(IOError)
io = StringIO.new("a b c d e")
@@ -112,4 +123,41 @@ describe :stringio_each_chomp, shared: true do
io.send(@method, chomp: true) {|s| seen << s }
seen.should == ["a b \rc d e", "1 2 3 4 5", "the end"]
end
+
+ it "returns each line with removed newline characters when called without block" do
+ seen = []
+ io = StringIO.new("a b \rc d e\n1 2 3 4 5\r\nthe end")
+ enum = io.send(@method, chomp: true)
+ enum.each {|s| seen << s }
+ seen.should == ["a b \rc d e", "1 2 3 4 5", "the end"]
+ end
+end
+
+describe :stringio_each_separator_and_chomp, shared: true do
+ it "yields each line with removed separator to the passed block" do
+ seen = []
+ io = StringIO.new("a b \nc d e|1 2 3 4 5\n|the end")
+ io.send(@method, "|", chomp: true) {|s| seen << s }
+ seen.should == ["a b \nc d e", "1 2 3 4 5\n", "the end"]
+ end
+
+ it "returns each line with removed separator when called without block" do
+ seen = []
+ io = StringIO.new("a b \nc d e|1 2 3 4 5\n|the end")
+ enum = io.send(@method, "|", chomp: true)
+ enum.each {|s| seen << s }
+ seen.should == ["a b \nc d e", "1 2 3 4 5\n", "the end"]
+ end
+end
+
+describe :stringio_each_limit, shared: true do
+ before :each do
+ @io = StringIO.new("a b c d e\n1 2 3 4 5")
+ end
+
+ it "returns the data read until the limit is met" do
+ seen = []
+ @io.send(@method, 4) { |s| seen << s }
+ seen.should == ["a b ", "c d ", "e\n", "1 2 ", "3 4 ", "5"]
+ end
end
diff --git a/spec/ruby/library/stringio/shared/each_byte.rb b/spec/ruby/library/stringio/shared/each_byte.rb
index 56734ff99d..b51fa38f2f 100644
--- a/spec/ruby/library/stringio/shared/each_byte.rb
+++ b/spec/ruby/library/stringio/shared/each_byte.rb
@@ -38,7 +38,7 @@ end
describe :stringio_each_byte_not_readable, shared: true do
it "raises an IOError" do
- io = StringIO.new("xyz", "w")
+ io = StringIO.new(+"xyz", "w")
-> { io.send(@method) { |b| b } }.should raise_error(IOError)
io = StringIO.new("xyz")
diff --git a/spec/ruby/library/stringio/shared/each_char.rb b/spec/ruby/library/stringio/shared/each_char.rb
index bcdac53282..197237c1c8 100644
--- a/spec/ruby/library/stringio/shared/each_char.rb
+++ b/spec/ruby/library/stringio/shared/each_char.rb
@@ -26,7 +26,7 @@ end
describe :stringio_each_char_not_readable, shared: true do
it "raises an IOError" do
- io = StringIO.new("xyz", "w")
+ io = StringIO.new(+"xyz", "w")
-> { io.send(@method) { |b| b } }.should raise_error(IOError)
io = StringIO.new("xyz")
diff --git a/spec/ruby/library/stringio/shared/getc.rb b/spec/ruby/library/stringio/shared/getc.rb
index 6318bcc30f..ba65040bce 100644
--- a/spec/ruby/library/stringio/shared/getc.rb
+++ b/spec/ruby/library/stringio/shared/getc.rb
@@ -33,7 +33,7 @@ end
describe :stringio_getc_not_readable, shared: true do
it "raises an IOError" do
- io = StringIO.new("xyz", "w")
+ io = StringIO.new(+"xyz", "w")
-> { io.send(@method) }.should raise_error(IOError)
io = StringIO.new("xyz")
diff --git a/spec/ruby/library/stringio/shared/isatty.rb b/spec/ruby/library/stringio/shared/isatty.rb
index 3da5999953..c9e7ee7321 100644
--- a/spec/ruby/library/stringio/shared/isatty.rb
+++ b/spec/ruby/library/stringio/shared/isatty.rb
@@ -1,5 +1,5 @@
describe :stringio_isatty, shared: true do
it "returns false" do
- StringIO.new('tty').send(@method).should be_false
+ StringIO.new("tty").send(@method).should be_false
end
end
diff --git a/spec/ruby/library/stringio/shared/read.rb b/spec/ruby/library/stringio/shared/read.rb
index c60677bba7..e3840786d9 100644
--- a/spec/ruby/library/stringio/shared/read.rb
+++ b/spec/ruby/library/stringio/shared/read.rb
@@ -5,19 +5,19 @@ describe :stringio_read, shared: true do
it "returns the passed buffer String" do
# Note: Rubinius bug:
- # @io.send(@method, 7, buffer = "").should equal(buffer)
- ret = @io.send(@method, 7, buffer = "")
+ # @io.send(@method, 7, buffer = +"").should equal(buffer)
+ ret = @io.send(@method, 7, buffer = +"")
ret.should equal(buffer)
end
it "reads length bytes and writes them to the buffer String" do
- @io.send(@method, 7, buffer = "")
+ @io.send(@method, 7, buffer = +"")
buffer.should == "example"
end
it "tries to convert the passed buffer Object to a String using #to_str" do
obj = mock("to_str")
- obj.should_receive(:to_str).and_return(buffer = "")
+ obj.should_receive(:to_str).and_return(buffer = +"")
@io.send(@method, 7, obj)
buffer.should == "example"
@@ -75,7 +75,7 @@ end
describe :stringio_read_no_arguments, shared: true do
before :each do
- @io = StringIO.new("example")
+ @io = StringIO.new(+"example")
end
it "reads the whole content starting from the current position" do
@@ -89,6 +89,12 @@ describe :stringio_read_no_arguments, shared: true do
@io.send(@method)
@io.pos.should eql(7)
end
+
+ it "correctly update the current position in bytes when multi-byte characters are used" do
+ @io.print("example\u03A3") # Overwrite the original string with 8 characters containing 9 bytes.
+ @io.send(@method)
+ @io.pos.should eql(9)
+ end
end
describe :stringio_read_nil, shared: true do
@@ -111,7 +117,7 @@ end
describe :stringio_read_not_readable, shared: true do
it "raises an IOError" do
- io = StringIO.new("test", "w")
+ io = StringIO.new(+"test", "w")
-> { io.send(@method) }.should raise_error(IOError)
io = StringIO.new("test")
diff --git a/spec/ruby/library/stringio/shared/readchar.rb b/spec/ruby/library/stringio/shared/readchar.rb
index 4248e75420..72d7446c36 100644
--- a/spec/ruby/library/stringio/shared/readchar.rb
+++ b/spec/ruby/library/stringio/shared/readchar.rb
@@ -19,7 +19,7 @@ end
describe :stringio_readchar_not_readable, shared: true do
it "raises an IOError" do
- io = StringIO.new("a b c d e", "w")
+ io = StringIO.new(+"a b c d e", "w")
-> { io.send(@method) }.should raise_error(IOError)
io = StringIO.new("a b c d e")
diff --git a/spec/ruby/library/stringio/shared/sysread.rb b/spec/ruby/library/stringio/shared/sysread.rb
index 3376bd9907..937bac705c 100644
--- a/spec/ruby/library/stringio/shared/sysread.rb
+++ b/spec/ruby/library/stringio/shared/sysread.rb
@@ -1,4 +1,4 @@
-describe :stringio_sysread_length, :shared => true do
+describe :stringio_sysread_length, shared: true do
before :each do
@io = StringIO.new("example")
end
diff --git a/spec/ruby/library/stringio/shared/write.rb b/spec/ruby/library/stringio/shared/write.rb
index 080729217b..404e08b93d 100644
--- a/spec/ruby/library/stringio/shared/write.rb
+++ b/spec/ruby/library/stringio/shared/write.rb
@@ -1,6 +1,6 @@
describe :stringio_write, shared: true do
before :each do
- @io = StringIO.new('12345')
+ @io = StringIO.new(+'12345')
end
it "tries to convert the passed Object to a String using #to_s" do
@@ -13,7 +13,7 @@ end
describe :stringio_write_string, shared: true do
before :each do
- @io = StringIO.new('12345')
+ @io = StringIO.new(+'12345')
end
# TODO: RDoc says that #write appends at the current position.
@@ -45,27 +45,71 @@ describe :stringio_write_string, shared: true do
@io.pos.should eql(4)
end
- ruby_version_is ""..."2.7" do
- it "taints self's String when the passed argument is tainted" do
- @io.send(@method, "test".taint)
- @io.string.tainted?.should be_true
- end
+ it "handles concurrent writes correctly" do
+ @io = StringIO.new
+ n = 8
+ go = false
+ threads = n.times.map { |i|
+ Thread.new {
+ Thread.pass until go
+ @io.write i.to_s
+ }
+ }
+ go = true
+ threads.each(&:join)
+ @io.string.size.should == n.times.map(&:to_s).join.size
end
- ruby_version_is ""..."3.0" do
- it "does not taint self when the passed argument is tainted" do
- @io.send(@method, "test".taint)
- @io.tainted?.should be_false
- end
+ it "handles writing non-ASCII UTF-8 after seek" do
+ @io.binmode
+ @io << "\x80"
+ @io.pos = 0
+ @io << "\x81"
+ @io.string.should == "\x812345".b
+ end
+
+ it "handles writing with position < buffer size" do
+ @io.pos = 2
+ @io.write "abc"
+ @io.string.should == "12abc"
+
+ @io.pos = 2
+ @io.write "de"
+ @io.string.should == "12dec"
+
+ @io.pos = 2
+ @io.write "fghi"
+ @io.string.should == "12fghi"
+ end
+
+ it "transcodes the given string when the external encoding is set and neither is BINARY" do
+ utf8_str = "hello"
+ io = StringIO.new.set_encoding(Encoding::UTF_16BE)
+ io.external_encoding.should == Encoding::UTF_16BE
+
+ io.send(@method, utf8_str)
+
+ expected = [0, 104, 0, 101, 0, 108, 0, 108, 0, 111] # UTF-16BE bytes for "hello"
+ io.string.bytes.should == expected
+ end
+
+ it "does not transcode the given string when the external encoding is set and the string encoding is BINARY" do
+ str = "été".b
+ io = StringIO.new.set_encoding(Encoding::UTF_16BE)
+ io.external_encoding.should == Encoding::UTF_16BE
+
+ io.send(@method, str)
+
+ io.string.bytes.should == str.bytes
end
end
describe :stringio_write_not_writable, shared: true do
it "raises an IOError" do
- io = StringIO.new("test", "r")
+ io = StringIO.new(+"test", "r")
-> { io.send(@method, "test") }.should raise_error(IOError)
- io = StringIO.new("test")
+ io = StringIO.new(+"test")
io.close_write
-> { io.send(@method, "test") }.should raise_error(IOError)
end
@@ -73,7 +117,7 @@ end
describe :stringio_write_append, shared: true do
before :each do
- @io = StringIO.new("example", "a")
+ @io = StringIO.new(+"example", "a")
end
it "appends the passed argument to the end of self" do
diff --git a/spec/ruby/library/stringio/truncate_spec.rb b/spec/ruby/library/stringio/truncate_spec.rb
index ba910ee98c..592ca5a6e1 100644
--- a/spec/ruby/library/stringio/truncate_spec.rb
+++ b/spec/ruby/library/stringio/truncate_spec.rb
@@ -3,13 +3,11 @@ require "stringio"
describe "StringIO#truncate when passed [length]" do
before :each do
- @io = StringIO.new('123456789')
+ @io = StringIO.new(+'123456789')
end
- # TODO: Report to Ruby-Core: The RDoc says it always returns 0
- it "returns the passed length" do
- @io.truncate(4).should eql(4)
- @io.truncate(10).should eql(10)
+ it "returns an Integer" do
+ @io.truncate(4).should be_kind_of(Integer)
end
it "truncated the underlying string down to the passed length" do
@@ -18,7 +16,7 @@ describe "StringIO#truncate when passed [length]" do
end
it "does not create a copy of the underlying string" do
- io = StringIO.new(str = "123456789")
+ io = StringIO.new(str = +"123456789")
io.truncate(4)
io.string.should equal(str)
end
@@ -47,12 +45,6 @@ describe "StringIO#truncate when passed [length]" do
@io.string.should == "1234"
end
- it "returns the passed length Object, NOT the result of #to_int" do
- obj = mock("to_int")
- obj.should_receive(:to_int).and_return(4)
- @io.truncate(obj).should equal(obj)
- end
-
it "raises a TypeError when the passed length can't be converted to an Integer" do
-> { @io.truncate(Object.new) }.should raise_error(TypeError)
end
@@ -60,10 +52,10 @@ end
describe "StringIO#truncate when self is not writable" do
it "raises an IOError" do
- io = StringIO.new("test", "r")
+ io = StringIO.new(+"test", "r")
-> { io.truncate(2) }.should raise_error(IOError)
- io = StringIO.new("test")
+ io = StringIO.new(+"test")
io.close_write
-> { io.truncate(2) }.should raise_error(IOError)
end
diff --git a/spec/ruby/library/stringio/ungetbyte_spec.rb b/spec/ruby/library/stringio/ungetbyte_spec.rb
index 701463e621..87b27b837e 100644
--- a/spec/ruby/library/stringio/ungetbyte_spec.rb
+++ b/spec/ruby/library/stringio/ungetbyte_spec.rb
@@ -1,6 +1,42 @@
+# frozen_string_literal: false
require_relative '../../spec_helper'
require 'stringio'
describe "StringIO#ungetbyte" do
- it "needs to be reviewed for spec completeness"
+ it "ungets a single byte from a string starting with a single byte character" do
+ str = 'This is a simple string.'
+ io = StringIO.new("#{str}")
+ c = io.getc
+ c.should == 'T'
+ io.ungetbyte(83)
+ io.string.should == 'Shis is a simple string.'
+ end
+
+ it "ungets a single byte from a string in the middle of a multibyte character" do
+ str = "\u01a9"
+ io = StringIO.new(str)
+ b = io.getbyte
+ b.should == 0xc6 # First byte of UTF-8 encoding of \u01a9
+ io.ungetbyte(0xce) # First byte of UTF-8 encoding of \u03a9
+ io.string.should == "\u03a9"
+ end
+
+ it "constrains the value of a numeric argument to a single byte" do
+ str = 'This is a simple string.'
+ io = StringIO.new("#{str}")
+ c = io.getc
+ c.should == 'T'
+ io.ungetbyte(83 | 0xff00)
+ io.string.should == 'Shis is a simple string.'
+ end
+
+ it "ungets the bytes of a string if given a string as an argument" do
+ str = "\u01a9"
+ io = StringIO.new(str)
+ b = io.getbyte
+ b.should == 0xc6 # First byte of UTF-8 encoding of \u01a9
+ io.ungetbyte("\u01a9")
+ io.string.bytes.should == [198, 169, 169]
+ end
+
end
diff --git a/spec/ruby/library/stringio/ungetc_spec.rb b/spec/ruby/library/stringio/ungetc_spec.rb
index 91ef2100a1..bceafa79ff 100644
--- a/spec/ruby/library/stringio/ungetc_spec.rb
+++ b/spec/ruby/library/stringio/ungetc_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe "StringIO#ungetc when passed [char]" do
before :each do
- @io = StringIO.new('1234')
+ @io = StringIO.new(+'1234')
end
it "writes the passed char before the current position" do
@@ -45,11 +45,11 @@ end
describe "StringIO#ungetc when self is not readable" do
it "raises an IOError" do
- io = StringIO.new("test", "w")
+ io = StringIO.new(+"test", "w")
io.pos = 1
-> { io.ungetc(?A) }.should raise_error(IOError)
- io = StringIO.new("test")
+ io = StringIO.new(+"test")
io.pos = 1
io.close_read
-> { io.ungetc(?A) }.should raise_error(IOError)
@@ -60,11 +60,11 @@ end
#
# describe "StringIO#ungetc when self is not writable" do
# it "raises an IOError" do
-# io = StringIO.new("test", "r")
+# io = StringIO.new(+"test", "r")
# io.pos = 1
# lambda { io.ungetc(?A) }.should raise_error(IOError)
#
-# io = StringIO.new("test")
+# io = StringIO.new(+"test")
# io.pos = 1
# io.close_write
# lambda { io.ungetc(?A) }.should raise_error(IOError)
diff --git a/spec/ruby/library/stringio/write_nonblock_spec.rb b/spec/ruby/library/stringio/write_nonblock_spec.rb
index 4f4c5039fe..b48ef6698a 100644
--- a/spec/ruby/library/stringio/write_nonblock_spec.rb
+++ b/spec/ruby/library/stringio/write_nonblock_spec.rb
@@ -8,6 +8,12 @@ end
describe "StringIO#write_nonblock when passed [String]" do
it_behaves_like :stringio_write_string, :write_nonblock
+
+ it "accepts :exception option" do
+ io = StringIO.new(+"12345", "a")
+ io.write_nonblock("67890", exception: true)
+ io.string.should == "1234567890"
+ end
end
describe "StringIO#write_nonblock when self is not writable" do
diff --git a/spec/ruby/library/stringscanner/check_spec.rb b/spec/ruby/library/stringscanner/check_spec.rb
index c7f788f0b3..a97c26af83 100644
--- a/spec/ruby/library/stringscanner/check_spec.rb
+++ b/spec/ruby/library/stringscanner/check_spec.rb
@@ -13,4 +13,13 @@ describe "StringScanner#check" do
@s.check(/is/).should == nil
@s.matched.should == nil
end
+
+ it "treats String as the pattern itself" do
+ @s.check("This").should == "This"
+ @s.matched.should == "This"
+ @s.pos.should == 0
+ @s.check(/is/).should == nil
+ @s.matched.should == nil
+ end
+
end
diff --git a/spec/ruby/library/stringscanner/check_until_spec.rb b/spec/ruby/library/stringscanner/check_until_spec.rb
index e92ae5a2e9..ad222fd76b 100644
--- a/spec/ruby/library/stringscanner/check_until_spec.rb
+++ b/spec/ruby/library/stringscanner/check_until_spec.rb
@@ -12,4 +12,10 @@ describe "StringScanner#check_until" do
@s.matched.should == "a"
@s.check_until(/test/).should == "This is a test"
end
+
+ it "raises TypeError if given a String" do
+ -> {
+ @s.check_until('T')
+ }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)')
+ end
end
diff --git a/spec/ruby/library/stringscanner/exist_spec.rb b/spec/ruby/library/stringscanner/exist_spec.rb
index beafadc07b..ff860a0d3e 100644
--- a/spec/ruby/library/stringscanner/exist_spec.rb
+++ b/spec/ruby/library/stringscanner/exist_spec.rb
@@ -21,4 +21,10 @@ describe "StringScanner#exist?" do
@s.scan(/This is/)
@s.exist?(/i/).should == nil
end
+
+ it "raises TypeError if given a String" do
+ -> {
+ @s.exist?('T')
+ }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)')
+ end
end
diff --git a/spec/ruby/library/stringscanner/getch_spec.rb b/spec/ruby/library/stringscanner/getch_spec.rb
index a6be0d4221..449c20ad3b 100644
--- a/spec/ruby/library/stringscanner/getch_spec.rb
+++ b/spec/ruby/library/stringscanner/getch_spec.rb
@@ -13,7 +13,7 @@ describe "StringScanner#getch" do
it "is multi-byte character sensitive" do
# Japanese hiragana "A" in EUC-JP
- src = "\244\242".force_encoding("euc-jp")
+ src = "\244\242".dup.force_encoding("euc-jp")
s = StringScanner.new(src)
s.getch.should == src
diff --git a/spec/ruby/library/stringscanner/matched_size_spec.rb b/spec/ruby/library/stringscanner/matched_size_spec.rb
index a36bd3aafe..d9c338a07e 100644
--- a/spec/ruby/library/stringscanner/matched_size_spec.rb
+++ b/spec/ruby/library/stringscanner/matched_size_spec.rb
@@ -1,7 +1,24 @@
require_relative '../../spec_helper'
-require_relative 'shared/matched_size'
require 'strscan'
describe "StringScanner#matched_size" do
- it_behaves_like :strscan_matched_size, :matched_size
+ before :each do
+ @s = StringScanner.new("This is a test")
+ end
+
+ it "returns the size of the most recent match" do
+ @s.check(/This/)
+ @s.matched_size.should == 4
+ @s.matched_size.should == 4
+ @s.scan(//)
+ @s.matched_size.should == 0
+ end
+
+ it "returns nil if there was no recent match" do
+ @s.matched_size.should == nil
+ @s.check(/\d+/)
+ @s.matched_size.should == nil
+ @s.terminate
+ @s.matched_size.should == nil
+ end
end
diff --git a/spec/ruby/library/stringscanner/scan_spec.rb b/spec/ruby/library/stringscanner/scan_spec.rb
index 2269abd6b3..ea711767b9 100644
--- a/spec/ruby/library/stringscanner/scan_spec.rb
+++ b/spec/ruby/library/stringscanner/scan_spec.rb
@@ -50,17 +50,9 @@ describe "StringScanner#scan" do
@s.scan(/./).should be_nil
end
- ruby_version_is ""..."2.7" do
- it "raises a TypeError if pattern is a String" do
- -> { @s.scan("aoeu") }.should raise_error(TypeError)
- end
- end
-
- ruby_version_is "2.7" do
- it "treats String as the pattern itself" do
- @s.scan("this").should be_nil
- @s.scan("This").should == "This"
- end
+ it "treats String as the pattern itself" do
+ @s.scan("this").should be_nil
+ @s.scan("This").should == "This"
end
it "raises a TypeError if pattern isn't a Regexp nor String" do
@@ -75,23 +67,21 @@ describe "StringScanner#scan with fixed_anchor: true" do
@s = StringScanner.new("This\nis\na\ntest", fixed_anchor: true)
end
- ruby_version_is "2.7" do
- it "returns the matched string" do
- @s.scan(/\w+/).should == "This"
- @s.scan(/.../m).should == "\nis"
- @s.scan(//).should == ""
- @s.scan(/\s+/).should == "\n"
- end
+ it "returns the matched string" do
+ @s.scan(/\w+/).should == "This"
+ @s.scan(/.../m).should == "\nis"
+ @s.scan(//).should == ""
+ @s.scan(/\s+/).should == "\n"
+ end
- it "treats ^ as matching from the beginning of line" do
- @s.scan(/\w+\n/).should == "This\n"
- @s.scan(/^\w/).should == "i"
- @s.scan(/^\w/).should be_nil
- end
+ it "treats ^ as matching from the beginning of line" do
+ @s.scan(/\w+\n/).should == "This\n"
+ @s.scan(/^\w/).should == "i"
+ @s.scan(/^\w/).should be_nil
+ end
- it "treats \\A as matching from the beginning of string" do
- @s.scan(/\A\w/).should == "T"
- @s.scan(/\A\w/).should be_nil
- end
+ it "treats \\A as matching from the beginning of string" do
+ @s.scan(/\A\w/).should == "T"
+ @s.scan(/\A\w/).should be_nil
end
end
diff --git a/spec/ruby/library/stringscanner/scan_until_spec.rb b/spec/ruby/library/stringscanner/scan_until_spec.rb
index 94239db50e..6b7782572d 100644
--- a/spec/ruby/library/stringscanner/scan_until_spec.rb
+++ b/spec/ruby/library/stringscanner/scan_until_spec.rb
@@ -20,4 +20,10 @@ describe "StringScanner#scan_until" do
@s.scan(/T/)
@s.scan_until(/^h/).should == "h"
end
+
+ it "raises TypeError if given a String" do
+ -> {
+ @s.scan_until('T')
+ }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)')
+ end
end
diff --git a/spec/ruby/library/stringscanner/search_full_spec.rb b/spec/ruby/library/stringscanner/search_full_spec.rb
index da9067e012..7d2a714fa5 100644
--- a/spec/ruby/library/stringscanner/search_full_spec.rb
+++ b/spec/ruby/library/stringscanner/search_full_spec.rb
@@ -27,4 +27,10 @@ describe "StringScanner#search_full" do
@s.search_full(/This/, true, true).should == "This"
@s.pos.should == 4
end
+
+ it "raises TypeError if given a String" do
+ -> {
+ @s.search_full('T', true, true)
+ }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)')
+ end
end
diff --git a/spec/ruby/library/stringscanner/shared/concat.rb b/spec/ruby/library/stringscanner/shared/concat.rb
index cb884a5c01..1dbae11f7c 100644
--- a/spec/ruby/library/stringscanner/shared/concat.rb
+++ b/spec/ruby/library/stringscanner/shared/concat.rb
@@ -1,6 +1,6 @@
describe :strscan_concat, shared: true do
it "concatenates the given argument to self and returns self" do
- s = StringScanner.new("hello ")
+ s = StringScanner.new(+"hello ")
s.send(@method, 'world').should == s
s.string.should == "hello world"
s.eos?.should be_false
diff --git a/spec/ruby/library/stringscanner/shared/extract_range.rb b/spec/ruby/library/stringscanner/shared/extract_range.rb
index 1c14f716c9..e7404fd0cb 100644
--- a/spec/ruby/library/stringscanner/shared/extract_range.rb
+++ b/spec/ruby/library/stringscanner/shared/extract_range.rb
@@ -8,17 +8,4 @@ describe :extract_range, shared: true do
ch.should_not be_kind_of(cls)
ch.should be_an_instance_of(String)
end
-
- ruby_version_is ''...'2.7' do
- it "taints the returned String if the input was tainted" do
- str = 'abc'
- str.taint
-
- s = StringScanner.new(str)
-
- s.send(@method).tainted?.should be_true
- s.send(@method).tainted?.should be_true
- s.send(@method).tainted?.should be_true
- end
- end
end
diff --git a/spec/ruby/library/stringscanner/shared/extract_range_matched.rb b/spec/ruby/library/stringscanner/shared/extract_range_matched.rb
index 5c536f5c01..070a132812 100644
--- a/spec/ruby/library/stringscanner/shared/extract_range_matched.rb
+++ b/spec/ruby/library/stringscanner/shared/extract_range_matched.rb
@@ -10,15 +10,4 @@ describe :extract_range_matched, shared: true do
ch.should_not be_kind_of(cls)
ch.should be_an_instance_of(String)
end
-
- ruby_version_is ''...'2.7' do
- it "taints the returned String if the input was tainted" do
- str = 'abc'
- str.taint
-
- s = StringScanner.new(str)
- s.scan(/\w{1}/)
- s.send(@method).tainted?.should be_true
- end
- end
end
diff --git a/spec/ruby/library/stringscanner/shared/matched_size.rb b/spec/ruby/library/stringscanner/shared/matched_size.rb
deleted file mode 100644
index 92174733f7..0000000000
--- a/spec/ruby/library/stringscanner/shared/matched_size.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-describe :strscan_matched_size, shared: true do
- before :each do
- @s = StringScanner.new("This is a test")
- end
-
- it "returns the size of the most recent match" do
- @s.check(/This/)
- @s.send(@method).should == 4
- @s.send(@method).should == 4
- @s.scan(//)
- @s.send(@method).should == 0
- end
-
- it "returns nil if there was no recent match" do
- @s.send(@method).should == nil
- @s.check(/\d+/)
- @s.send(@method).should == nil
- @s.terminate
- @s.send(@method).should == nil
- end
-end
diff --git a/spec/ruby/library/stringscanner/shared/peek.rb b/spec/ruby/library/stringscanner/shared/peek.rb
index 4e2e643353..4c757866c1 100644
--- a/spec/ruby/library/stringscanner/shared/peek.rb
+++ b/spec/ruby/library/stringscanner/shared/peek.rb
@@ -36,14 +36,4 @@ describe :strscan_peek, shared: true do
ch.should_not be_kind_of(cls)
ch.should be_an_instance_of(String)
end
-
- ruby_version_is ''...'2.7' do
- it "taints the returned String if the input was tainted" do
- str = 'abc'
- str.taint
-
- s = StringScanner.new(str)
- s.send(@method, 1).tainted?.should be_true
- end
- end
end
diff --git a/spec/ruby/library/stringscanner/size_spec.rb b/spec/ruby/library/stringscanner/size_spec.rb
new file mode 100644
index 0000000000..3e475489e3
--- /dev/null
+++ b/spec/ruby/library/stringscanner/size_spec.rb
@@ -0,0 +1,17 @@
+require_relative '../../spec_helper'
+require 'strscan'
+
+describe "StringScanner#size" do
+ before :each do
+ @s = StringScanner.new("This is a test")
+ end
+
+ it "returns the number of captures groups of the last match" do
+ @s.scan(/(.)(.)(.)/)
+ @s.size.should == 4
+ end
+
+ it "returns nil if there is no last match" do
+ @s.size.should == nil
+ end
+end
diff --git a/spec/ruby/library/stringscanner/skip_until_spec.rb b/spec/ruby/library/stringscanner/skip_until_spec.rb
index 73eb91b8ad..7b56f13e4f 100644
--- a/spec/ruby/library/stringscanner/skip_until_spec.rb
+++ b/spec/ruby/library/stringscanner/skip_until_spec.rb
@@ -15,4 +15,10 @@ describe "StringScanner#skip_until" do
it "returns nil if no match was found" do
@s.skip_until(/d+/).should == nil
end
+
+ it "raises TypeError if given a String" do
+ -> {
+ @s.skip_until('T')
+ }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)')
+ end
end
diff --git a/spec/ruby/library/stringscanner/string_spec.rb b/spec/ruby/library/stringscanner/string_spec.rb
index 28e2f0ed37..cba6bd51dd 100644
--- a/spec/ruby/library/stringscanner/string_spec.rb
+++ b/spec/ruby/library/stringscanner/string_spec.rb
@@ -3,7 +3,7 @@ require 'strscan'
describe "StringScanner#string" do
before :each do
- @string = "This is a test"
+ @string = +"This is a test"
@s = StringScanner.new(@string)
end
diff --git a/spec/ruby/library/time/to_datetime_spec.rb b/spec/ruby/library/time/to_datetime_spec.rb
index 0e37a61108..9c44f38e5c 100644
--- a/spec/ruby/library/time/to_datetime_spec.rb
+++ b/spec/ruby/library/time/to_datetime_spec.rb
@@ -1,11 +1,13 @@
require_relative '../../spec_helper'
require 'time'
+require 'date'
+date_version = defined?(Date::VERSION) ? Date::VERSION : '3.1.0'
describe "Time#to_datetime" do
it "returns a DateTime representing the same instant" do
- time = Time.utc(3, 12, 31, 23, 58, 59)
+ time = Time.utc(2012, 12, 31, 23, 58, 59)
datetime = time.to_datetime
- datetime.year.should == 3
+ datetime.year.should == 2012
datetime.month.should == 12
datetime.day.should == 31
datetime.hour.should == 23
@@ -13,6 +15,19 @@ describe "Time#to_datetime" do
datetime.sec.should == 59
end
+ version_is date_version, '3.2.3' do #ruby_version_is '3.2' do
+ it "returns a DateTime representing the same instant before Gregorian" do
+ time = Time.utc(1582, 10, 14, 23, 58, 59)
+ datetime = time.to_datetime
+ datetime.year.should == 1582
+ datetime.month.should == 10
+ datetime.day.should == 4
+ datetime.hour.should == 23
+ datetime.min.should == 58
+ datetime.sec.should == 59
+ end
+ end
+
it "roundtrips" do
time = Time.utc(3, 12, 31, 23, 58, 59)
datetime = time.to_datetime
diff --git a/spec/ruby/library/uri/generic/host_spec.rb b/spec/ruby/library/uri/generic/host_spec.rb
index f2076d2bc1..210124ef66 100644
--- a/spec/ruby/library/uri/generic/host_spec.rb
+++ b/spec/ruby/library/uri/generic/host_spec.rb
@@ -2,7 +2,12 @@ require_relative '../../../spec_helper'
require 'uri'
describe "URI::Generic#host" do
- it "needs to be reviewed for spec completeness"
+ version_is URI::VERSION, "0.12" do #ruby_version_is "3.2" do
+ # https://hackerone.com/reports/156615
+ it "returns empty string when host is empty" do
+ URI.parse('http:////foo.com').host.should == ''
+ end
+ end
end
describe "URI::Generic#host=" do
diff --git a/spec/ruby/library/uri/generic/to_s_spec.rb b/spec/ruby/library/uri/generic/to_s_spec.rb
index 8c90d7645b..8cebd374a1 100644
--- a/spec/ruby/library/uri/generic/to_s_spec.rb
+++ b/spec/ruby/library/uri/generic/to_s_spec.rb
@@ -2,5 +2,10 @@ require_relative '../../../spec_helper'
require 'uri'
describe "URI::Generic#to_s" do
- it "needs to be reviewed for spec completeness"
+ version_is URI::VERSION, "0.12" do #ruby_version_is "3.2" do
+ # 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
end
diff --git a/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb b/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb
index 940eebfb91..52cb978bea 100644
--- a/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb
index 91f5091d24..994c2e6d36 100644
--- a/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/codepage_spec.rb b/spec/ruby/library/win32ole/win32ole/codepage_spec.rb
index 4e0cf5ca55..07e93646ac 100644
--- a/spec/ruby/library/win32ole/win32ole/codepage_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/codepage_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/connect_spec.rb b/spec/ruby/library/win32ole/win32ole/connect_spec.rb
index 72dceb1572..ac0976ddc1 100644
--- a/spec/ruby/library/win32ole/win32ole/connect_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/connect_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/const_load_spec.rb b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb
index cacc7a2b22..2099c4aa66 100644
--- a/spec/ruby/library/win32ole/win32ole/const_load_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/constants_spec.rb b/spec/ruby/library/win32ole/win32ole/constants_spec.rb
index 978b7ade92..8533741440 100644
--- a/spec/ruby/library/win32ole/win32ole/constants_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/constants_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb b/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb
index 2e18b6ab11..8aa853df9e 100644
--- a/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/create_guid_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/invoke_spec.rb b/spec/ruby/library/win32ole/win32ole/invoke_spec.rb
index 08a5156e05..d6ff7fade3 100644
--- a/spec/ruby/library/win32ole/win32ole/invoke_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/invoke_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/locale_spec.rb b/spec/ruby/library/win32ole/win32ole/locale_spec.rb
index 75a82ddd7f..78ede4375a 100644
--- a/spec/ruby/library/win32ole/win32ole/locale_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/locale_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/new_spec.rb b/spec/ruby/library/win32ole/win32ole/new_spec.rb
index 6b717195f1..7e91c2d3ea 100644
--- a/spec/ruby/library/win32ole/win32ole/new_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/new_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb
index 75748182fe..2bbe8c27d4 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb
index a991624a23..c1d1970214 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb
index 8a26d79a20..9cb3f9e6cf 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
require_relative 'shared/ole_method'
diff --git a/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb
index f82a212f5d..e48ff8d905 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_method_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
require_relative 'shared/ole_method'
diff --git a/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb
index 5ac9ae9cfa..fe161ce9f0 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb
index ef8944ee39..afcf16a051 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb
index 727291e9f0..c091c83c95 100644
--- a/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb b/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb
index 7409823f20..bacdee63da 100644
--- a/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole/setproperty_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
require_relative 'shared/setproperty'
diff --git a/spec/ruby/library/win32ole/win32ole_event/new_spec.rb b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb
index a1a1612393..94fabb1e3b 100644
--- a/spec/ruby/library/win32ole/win32ole_event/new_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
diff --git a/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb b/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb
index feb26b0637..0957bdd2d4 100644
--- a/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
guard -> { WIN32OLESpecs::MSXML_AVAILABLE } do
diff --git a/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb
index 69068683b7..ece71df0d4 100644
--- a/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb b/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb
index 70c8b30cca..78634d2fde 100644
--- a/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
guard -> { WIN32OLESpecs::SYSTEM_MONITOR_CONTROL_AVAILABLE } do
diff --git a/spec/ruby/library/win32ole/win32ole_method/event_spec.rb b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb
index c41f8fe99d..9b642a010c 100644
--- a/spec/ruby/library/win32ole/win32ole_method/event_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require_relative '../fixtures/classes'
guard -> { WIN32OLESpecs::SYSTEM_MONITOR_CONTROL_AVAILABLE } do
diff --git a/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb
index 21b3ae8bde..d1c5ee3be2 100644
--- a/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb
index b6d0a19a37..59dad9244c 100644
--- a/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb
index 9f940fd4a0..b2f24ba151 100644
--- a/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb
index 7fff479daf..d7fedf0d36 100644
--- a/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb b/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb
index e8638abd91..d5536fd17b 100644
--- a/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/name_spec.rb b/spec/ruby/library/win32ole/win32ole_method/name_spec.rb
index cd5404fc54..477b820f4d 100644
--- a/spec/ruby/library/win32ole/win32ole_method/name_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/name_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
diff --git a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb
index 8ebf93b992..4e427421b9 100644
--- a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb b/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb
index 8e50c39787..b3da9a8303 100644
--- a/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb
index 2f8da3d45b..09fb0eb5ac 100644
--- a/spec/ruby/library/win32ole/win32ole_method/params_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb
index f8ce3e1b3a..582a5951d5 100644
--- a/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb
index 58e26df77b..dd8add402d 100644
--- a/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb b/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb
index dc159dd09e..3fca3d54ed 100644
--- a/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb
index a38fe5c681..fe9facb53a 100644
--- a/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb
index 0c5a94c338..8ea6e61e7d 100644
--- a/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb
index ecb3c08038..11107a77fc 100644
--- a/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
diff --git a/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb
index 918b6ef782..d1a50523fc 100644
--- a/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_param/default_spec.rb b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb
index af08c84782..44bd3d7fd3 100644
--- a/spec/ruby/library/win32ole/win32ole_param/default_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb
index e2a90daa56..e9134b1df8 100644
--- a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_param/name_spec.rb b/spec/ruby/library/win32ole/win32ole_param/name_spec.rb
index 0c20c24720..67a8955ba4 100644
--- a/spec/ruby/library/win32ole/win32ole_param/name_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/name_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
diff --git a/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb
index e683d1c16e..f05455e3f1 100644
--- a/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb
index b9a3639c3e..1467130e03 100644
--- a/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb
index 3fb9dc1867..b39ee41179 100644
--- a/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb
index f5546e79e5..dd613dd29a 100644
--- a/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb
index 5b4b4c1c80..e9153a2eb2 100644
--- a/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
diff --git a/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb b/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb
index 25907c8e32..abdf8d34b9 100644
--- a/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/guid_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb
index d436835188..eee23abc56 100644
--- a/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb
index 01e6945138..3a0a9ead94 100644
--- a/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb
index 3bd2cbe5dd..9ab0004668 100644
--- a/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb b/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb
index 7dae16617d..7d2731f778 100644
--- a/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb b/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb
index ff412dd100..3904e78d42 100644
--- a/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/name_spec.rb b/spec/ruby/library/win32ole/win32ole_type/name_spec.rb
index b7a28c553a..d76998d7dc 100644
--- a/spec/ruby/library/win32ole/win32ole_type/name_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/name_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
diff --git a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb
index 3c3aa1c390..cc691ffa67 100644
--- a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb b/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb
index 0ce0fc98a4..a3a1d4ac58 100644
--- a/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb b/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb
index 9265549d20..3b99b97a61 100644
--- a/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb
index 2bc19aa85e..24292b1c4f 100644
--- a/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb b/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb
index f0d80ba39e..340fdb34e8 100644
--- a/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/progid_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb
index 19d8bf56e0..793535b48d 100644
--- a/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb b/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb
index 71e304d80a..3f89fe702a 100644
--- a/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb
index b713990ed2..9f086a5a35 100644
--- a/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
diff --git a/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb b/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb
index 35f3562721..391d505e01 100644
--- a/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb
index 369e0274f3..a487208caa 100644
--- a/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb b/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb
index fbf3dd0341..7f61b8af95 100644
--- a/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/variables_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb
index 403b2b843b..99e34edcdd 100644
--- a/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb
index 8bac1a9891..dd9bfa594f 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/name_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
diff --git a/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb
index dab4edabaa..7a9c791494 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb
index d08acc9bde..03a9aa4c74 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb
index 000ac14d7e..d4cab8e924 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
diff --git a/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb
index 4f240b561c..b7849793c5 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb
index 4cca7f8874..7a79d32ddc 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb
index 56cd1c337a..9d7b8238c8 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb
index 7f7a557b57..60252e8139 100644
--- a/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
platform_is :windows do
require 'win32ole'
diff --git a/spec/ruby/library/yaml/dump_spec.rb b/spec/ruby/library/yaml/dump_spec.rb
index 3107a8f51d..ea94b2f856 100644
--- a/spec/ruby/library/yaml/dump_spec.rb
+++ b/spec/ruby/library/yaml/dump_spec.rb
@@ -1,17 +1,21 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-# TODO: WTF is this using a global?
+require 'yaml'
+
describe "YAML.dump" do
+ before :each do
+ @test_file = tmp("yaml_test_file")
+ end
+
after :each do
- rm_r $test_file
+ rm_r @test_file
end
it "converts an object to YAML and write result to io when io provided" do
- File.open($test_file, 'w' ) do |io|
+ File.open(@test_file, 'w' ) do |io|
YAML.dump( ['badger', 'elephant', 'tiger'], io )
end
- YAML.load_file($test_file).should == ['badger', 'elephant', 'tiger']
+ YAML.load_file(@test_file).should == ['badger', 'elephant', 'tiger']
end
it "returns a string containing dumped YAML when no io provided" do
diff --git a/spec/ruby/library/yaml/dump_stream_spec.rb b/spec/ruby/library/yaml/dump_stream_spec.rb
index 9d30fef819..f0578fa800 100644
--- a/spec/ruby/library/yaml/dump_stream_spec.rb
+++ b/spec/ruby/library/yaml/dump_stream_spec.rb
@@ -1,5 +1,6 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+
+require 'yaml'
describe "YAML.dump_stream" do
it "returns a YAML stream containing the objects passed" do
diff --git a/spec/ruby/library/yaml/fixtures/common.rb b/spec/ruby/library/yaml/fixtures/common.rb
deleted file mode 100644
index 1d868806f1..0000000000
--- a/spec/ruby/library/yaml/fixtures/common.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-begin
- require 'syck'
-rescue LoadError
- # do nothing
-end
-
-require 'yaml'
-
-$test_file = tmp("yaml_test_file")
-$test_parse_file = File.dirname(__FILE__) + "/test_yaml.yml"
diff --git a/spec/ruby/library/yaml/fixtures/strings.rb b/spec/ruby/library/yaml/fixtures/strings.rb
index 6f66dc3659..f478f89823 100644
--- a/spec/ruby/library/yaml/fixtures/strings.rb
+++ b/spec/ruby/library/yaml/fixtures/strings.rb
@@ -1,36 +1,26 @@
-$complex_key_1 = <<EOY
- ? # PLAY SCHEDULE
- - Detroit Tigers
- - Chicago Cubs
- :
- - 2001-07-23
+module YAMLSpecs
+ COMPLEX_KEY_1 = <<~EOY
+ ? # PLAY SCHEDULE
+ - Detroit Tigers
+ - Chicago Cubs
+ :
+ - 2001-07-23
- ? [ New York Yankees,
- Atlanta Braves ]
- : [ 2001-07-02, 2001-08-12,
- 2001-08-14 ]
-EOY
+ ? [ New York Yankees,
+ Atlanta Braves ]
+ : [ 2001-07-02, 2001-08-12,
+ 2001-08-14 ]
+ EOY
-$to_yaml_hash =
-<<EOY
--
- avg: 0.278
- hr: 65
- name: Mark McGwire
--
- avg: 0.288
- hr: 63
- name: Sammy Sosa
-EOY
+ MULTIDOCUMENT = <<~EOY
+ ---
+ - Mark McGwire
+ - Sammy Sosa
+ - Ken Griffey
-$multidocument = <<EOY
----
-- Mark McGwire
-- Sammy Sosa
-- Ken Griffey
-
-# Team ranking
----
-- Chicago Cubs
-- St Louis Cardinals
-EOY
+ # Team ranking
+ ---
+ - Chicago Cubs
+ - St Louis Cardinals
+ EOY
+end
diff --git a/spec/ruby/library/yaml/load_file_spec.rb b/spec/ruby/library/yaml/load_file_spec.rb
index 2363c08120..4941d0485b 100644
--- a/spec/ruby/library/yaml/load_file_spec.rb
+++ b/spec/ruby/library/yaml/load_file_spec.rb
@@ -1,13 +1,18 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/common'
+
+require 'yaml'
describe "YAML.load_file" do
+ before :each do
+ @test_file = tmp("yaml_test_file")
+ end
+
after :each do
- rm_r $test_file
+ rm_r @test_file
end
it "returns a hash" do
- File.open($test_file,'w' ){|io| YAML.dump( {"bar"=>2, "car"=>1}, io ) }
- YAML.load_file($test_file).should == {"bar"=>2, "car"=>1}
+ File.open(@test_file,'w' ){|io| YAML.dump( {"bar"=>2, "car"=>1}, io ) }
+ YAML.load_file(@test_file).should == {"bar"=>2, "car"=>1}
end
end
diff --git a/spec/ruby/library/yaml/load_spec.rb b/spec/ruby/library/yaml/load_spec.rb
index 0b6bef2dac..56700a85f9 100644
--- a/spec/ruby/library/yaml/load_spec.rb
+++ b/spec/ruby/library/yaml/load_spec.rb
@@ -1,137 +1,10 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-require_relative 'fixtures/strings'
+require_relative 'shared/load'
describe "YAML.load" do
- after :each do
- rm_r $test_file
- end
-
- it "returns a document from current io stream when io provided" do
- File.open($test_file, 'w') do |io|
- YAML.dump( ['badger', 'elephant', 'tiger'], io )
- end
- File.open($test_file) { |yf| YAML.load( yf ) }.should == ['badger', 'elephant', 'tiger']
- end
-
- it "loads strings" do
- strings = ["str",
- " str",
- "'str'",
- "str",
- " str",
- "'str'",
- "\"str\"",
- "\n str",
- "--- str",
- "---\nstr",
- "--- \nstr",
- "--- \n str",
- "--- 'str'"
- ]
- strings.each do |str|
- YAML.load(str).should == "str"
- end
- end
-
- it "loads strings with chars from non-base Unicode plane" do
- # We add these strings as bytes and force the encoding for safety
- # as bugs in parsing unicode characters can obscure bugs in this
- # area.
-
- yaml_and_strings = {
- # "--- 🌵" => "🌵"
- [45, 45, 45, 32, 240, 159, 140, 181] =>
- [240, 159, 140, 181],
- # "--- 🌵 and some text" => "🌵 and some text"
- [45, 45, 45, 32, 240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116] =>
- [240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116],
- # "--- Some text 🌵 and some text" => "Some text 🌵 and some text"
- [45, 45, 45, 32, 83, 111, 109, 101, 32, 116, 101, 120, 116, 32, 240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116] =>
- [83, 111, 109, 101, 32, 116, 101, 120, 116, 32, 240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116]
- }
- yaml_and_strings.each do |yaml, str|
- YAML.load(yaml.pack("C*").force_encoding("UTF-8")).should == str.pack("C*").force_encoding("UTF-8")
- end
- end
-
- it "fails on invalid keys" do
- if YAML.to_s == "Psych"
- error = Psych::SyntaxError
- else
- error = ArgumentError
- end
- -> { YAML.load("key1: value\ninvalid_key") }.should raise_error(error)
- end
-
- it "accepts symbols" do
- YAML.load( "--- :locked" ).should == :locked
- end
-
- it "accepts numbers" do
- YAML.load("47").should == 47
- YAML.load("-1").should == -1
- end
-
- it "accepts collections" do
- expected = ["a", "b", "c"]
- YAML.load("--- \n- a\n- b\n- c\n").should == expected
- YAML.load("--- [a, b, c]").should == expected
- YAML.load("[a, b, c]").should == expected
- end
-
- it "parses start markers" do
- YAML.load("---\n").should == nil
- YAML.load("--- ---\n").should == "---"
- YAML.load("--- abc").should == "abc"
- end
-
- it "works with block sequence shortcuts" do
- block_seq = "- - - one\n - two\n - three"
- YAML.load(block_seq).should == [[["one", "two", "three"]]]
- end
-
- it "works on complex keys" do
- require 'date'
- expected = {
- [ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ],
- [ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ),
- Date.new( 2001, 8, 12 ),
- Date.new( 2001, 8, 14 ) ]
- }
- YAML.load($complex_key_1).should == expected
- end
-
- it "loads a symbol key that contains spaces" do
- string = ":user name: This is the user name."
- expected = { :"user name" => "This is the user name."}
- YAML.load(string).should == expected
- end
-
- describe "with iso8601 timestamp" do
- it "computes the microseconds" do
- [ [YAML.load("2011-03-22t23:32:11.2233+01:00"), 223300],
- [YAML.load("2011-03-22t23:32:11.0099+01:00"), 9900],
- [YAML.load("2011-03-22t23:32:11.000076+01:00"), 76]
- ].should be_computed_by(:usec)
- end
-
- it "rounds values smaller than 1 usec to 0 " do
- YAML.load("2011-03-22t23:32:11.000000342222+01:00").usec.should == 0
- end
- end
-
- it "loads an OpenStruct" do
- require "ostruct"
- os = OpenStruct.new("age" => 20, "name" => "John")
- loaded = YAML.load("--- !ruby/object:OpenStruct\ntable:\n :age: 20\n :name: John\n")
- loaded.should == os
- end
+ it_behaves_like :yaml_load_safe, :load
- it "loads a File but raise an error when used as it is uninitialized" do
- loaded = YAML.load("--- !ruby/object:File {}\n")
- -> {
- loaded.read(1)
- }.should raise_error(IOError)
+ guard -> { Psych::VERSION < "4.0.0" } do
+ it_behaves_like :yaml_load_unsafe, :load
end
end
diff --git a/spec/ruby/library/yaml/load_stream_spec.rb b/spec/ruby/library/yaml/load_stream_spec.rb
index 689653c8cd..31bc862f5e 100644
--- a/spec/ruby/library/yaml/load_stream_spec.rb
+++ b/spec/ruby/library/yaml/load_stream_spec.rb
@@ -1,8 +1,9 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/common'
require_relative 'fixtures/strings'
require_relative 'shared/each_document'
+require 'yaml'
+
describe "YAML.load_stream" do
it_behaves_like :yaml_each_document, :load_stream
end
diff --git a/spec/ruby/library/yaml/parse_file_spec.rb b/spec/ruby/library/yaml/parse_file_spec.rb
index 8c59a2d7ef..7bffcdc62f 100644
--- a/spec/ruby/library/yaml/parse_file_spec.rb
+++ b/spec/ruby/library/yaml/parse_file_spec.rb
@@ -1,8 +1,10 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-describe "YAML#parse_file" do
+require 'yaml'
+
+describe "YAML.parse_file" do
it "returns a YAML::Syck::Map object after parsing a YAML file" do
- YAML.parse_file($test_parse_file).should be_kind_of(Psych::Nodes::Document)
+ test_parse_file = fixture __FILE__, "test_yaml.yml"
+ YAML.parse_file(test_parse_file).should be_kind_of(Psych::Nodes::Document)
end
end
diff --git a/spec/ruby/library/yaml/parse_spec.rb b/spec/ruby/library/yaml/parse_spec.rb
index d5dbfdcee2..37e2b7fa0a 100644
--- a/spec/ruby/library/yaml/parse_spec.rb
+++ b/spec/ruby/library/yaml/parse_spec.rb
@@ -1,13 +1,14 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/common'
-describe "YAML#parse with an empty string" do
+require 'yaml'
+
+describe "YAML.parse with an empty string" do
it "returns false" do
YAML.parse('').should be_false
end
end
-describe "YAML#parse" do
+describe "YAML.parse" do
before :each do
@string_yaml = "foo".to_yaml
end
diff --git a/spec/ruby/library/yaml/shared/each_document.rb b/spec/ruby/library/yaml/shared/each_document.rb
index 999123dc2a..6f00aee297 100644
--- a/spec/ruby/library/yaml/shared/each_document.rb
+++ b/spec/ruby/library/yaml/shared/each_document.rb
@@ -1,7 +1,7 @@
describe :yaml_each_document, shared: true do
it "calls the block on each successive document" do
documents = []
- YAML.send(@method, $multidocument) do |doc|
+ YAML.send(@method, YAMLSpecs::MULTIDOCUMENT) do |doc|
documents << doc
end
documents.should == [["Mark McGwire", "Sammy Sosa", "Ken Griffey"],
@@ -9,7 +9,8 @@ describe :yaml_each_document, shared: true do
end
it "works on files" do
- File.open($test_parse_file, "r") do |file|
+ test_parse_file = fixture __FILE__, "test_yaml.yml"
+ File.open(test_parse_file, "r") do |file|
YAML.send(@method, file) do |doc|
doc.should == {"project"=>{"name"=>"RubySpec"}}
end
diff --git a/spec/ruby/library/yaml/shared/load.rb b/spec/ruby/library/yaml/shared/load.rb
new file mode 100644
index 0000000000..bd55332fe5
--- /dev/null
+++ b/spec/ruby/library/yaml/shared/load.rb
@@ -0,0 +1,138 @@
+require_relative '../fixtures/strings'
+
+require 'yaml'
+
+describe :yaml_load_safe, shared: true do
+ it "returns a document from current io stream when io provided" do
+ @test_file = tmp("yaml_test_file")
+ File.open(@test_file, 'w') do |io|
+ YAML.dump( ['badger', 'elephant', 'tiger'], io )
+ end
+ File.open(@test_file) { |yf| YAML.send(@method, yf ) }.should == ['badger', 'elephant', 'tiger']
+ ensure
+ rm_r @test_file
+ end
+
+ it "loads strings" do
+ strings = ["str",
+ " str",
+ "'str'",
+ "str",
+ " str",
+ "'str'",
+ "\"str\"",
+ "\n str",
+ "--- str",
+ "---\nstr",
+ "--- \nstr",
+ "--- \n str",
+ "--- 'str'"
+ ]
+ strings.each do |str|
+ YAML.send(@method, str).should == "str"
+ end
+ end
+
+ it "loads strings with chars from non-base Unicode plane" do
+ # We add these strings as bytes and force the encoding for safety
+ # as bugs in parsing unicode characters can obscure bugs in this
+ # area.
+
+ yaml_and_strings = {
+ # "--- 🌵" => "🌵"
+ [45, 45, 45, 32, 240, 159, 140, 181] =>
+ [240, 159, 140, 181],
+ # "--- 🌵 and some text" => "🌵 and some text"
+ [45, 45, 45, 32, 240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116] =>
+ [240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116],
+ # "--- Some text 🌵 and some text" => "Some text 🌵 and some text"
+ [45, 45, 45, 32, 83, 111, 109, 101, 32, 116, 101, 120, 116, 32, 240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116] =>
+ [83, 111, 109, 101, 32, 116, 101, 120, 116, 32, 240, 159, 140, 181, 32, 97, 110, 100, 32, 115, 111, 109, 101, 32, 116, 101, 120, 116]
+ }
+ yaml_and_strings.each do |yaml, str|
+ YAML.send(@method, yaml.pack("C*").force_encoding("UTF-8")).should == str.pack("C*").force_encoding("UTF-8")
+ end
+ end
+
+ it "fails on invalid keys" do
+ if YAML.to_s == "Psych"
+ error = Psych::SyntaxError
+ else
+ error = ArgumentError
+ end
+ -> { YAML.send(@method, "key1: value\ninvalid_key") }.should raise_error(error)
+ end
+
+ it "accepts symbols" do
+ YAML.send(@method, "--- :locked" ).should == :locked
+ end
+
+ it "accepts numbers" do
+ YAML.send(@method, "47").should == 47
+ YAML.send(@method, "-1").should == -1
+ end
+
+ it "accepts collections" do
+ expected = ["a", "b", "c"]
+ YAML.send(@method, "--- \n- a\n- b\n- c\n").should == expected
+ YAML.send(@method, "--- [a, b, c]").should == expected
+ YAML.send(@method, "[a, b, c]").should == expected
+ end
+
+ it "parses start markers" do
+ YAML.send(@method, "---\n").should == nil
+ YAML.send(@method, "--- ---\n").should == "---"
+ YAML.send(@method, "--- abc").should == "abc"
+ end
+
+ it "works with block sequence shortcuts" do
+ block_seq = "- - - one\n - two\n - three"
+ YAML.send(@method, block_seq).should == [[["one", "two", "three"]]]
+ end
+
+ it "loads a symbol key that contains spaces" do
+ string = ":user name: This is the user name."
+ expected = { :"user name" => "This is the user name."}
+ YAML.send(@method, string).should == expected
+ end
+end
+
+describe :yaml_load_unsafe, shared: true do
+ it "works on complex keys" do
+ require 'date'
+ expected = {
+ [ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ],
+ [ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ),
+ Date.new( 2001, 8, 12 ),
+ Date.new( 2001, 8, 14 ) ]
+ }
+ YAML.send(@method, YAMLSpecs::COMPLEX_KEY_1).should == expected
+ end
+
+ describe "with iso8601 timestamp" do
+ it "computes the microseconds" do
+ [ [YAML.send(@method, "2011-03-22t23:32:11.2233+01:00"), 223300],
+ [YAML.send(@method, "2011-03-22t23:32:11.0099+01:00"), 9900],
+ [YAML.send(@method, "2011-03-22t23:32:11.000076+01:00"), 76]
+ ].should be_computed_by(:usec)
+ end
+
+ it "rounds values smaller than 1 usec to 0 " do
+ YAML.send(@method, "2011-03-22t23:32:11.000000342222+01:00").usec.should == 0
+ end
+ end
+
+ it "loads an OpenStruct" do
+ require "ostruct"
+ os = OpenStruct.new("age" => 20, "name" => "John")
+ loaded = YAML.send(@method, "--- !ruby/object:OpenStruct\ntable:\n :age: 20\n :name: John\n")
+ loaded.should == os
+ end
+
+ it "loads a File but raise an error when used as it is uninitialized" do
+ loaded = YAML.send(@method, "--- !ruby/object:File {}\n")
+ -> {
+ loaded.read(1)
+ }.should raise_error(IOError)
+ end
+end
diff --git a/spec/ruby/library/yaml/to_yaml_spec.rb b/spec/ruby/library/yaml/to_yaml_spec.rb
index 03ec4f6916..547009c942 100644
--- a/spec/ruby/library/yaml/to_yaml_spec.rb
+++ b/spec/ruby/library/yaml/to_yaml_spec.rb
@@ -1,7 +1,8 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/common'
require_relative 'fixtures/example_class'
+require 'yaml'
+
describe "Object#to_yaml" do
it "returns the YAML representation of an Array object" do
@@ -12,13 +13,21 @@ describe "Object#to_yaml" do
{ "a" => "b"}.to_yaml.should match_yaml("--- \na: b\n")
end
- it "returns the YAML representation of a Class object" do
+ it "returns the YAML representation of an object" do
YAMLSpecs::Example.new("baz").to_yaml.should match_yaml("--- !ruby/object:YAMLSpecs::Example\nname: baz\n")
end
+ it "returns the YAML representation of a Class object" do
+ YAMLSpecs::Example.to_yaml.should match_yaml("--- !ruby/class 'YAMLSpecs::Example'\n")
+ end
+
+ it "returns the YAML representation of a Module object" do
+ Enumerable.to_yaml.should match_yaml("--- !ruby/module 'Enumerable'\n")
+ end
+
it "returns the YAML representation of a Date object" do
require 'date'
- Date.parse('1997/12/30').to_yaml.should match_yaml("--- 1997-12-30\n")
+ Date.new(1997, 12, 30).to_yaml.should match_yaml("--- 1997-12-30\n")
end
it "returns the YAML representation of a FalseClass" do
@@ -58,6 +67,11 @@ describe "Object#to_yaml" do
Person.new("Jane", "female").to_yaml.should match_yaml("--- !ruby/struct:Person\nname: Jane\ngender: female\n")
end
+ it "returns the YAML representation of an unnamed Struct object" do
+ person = Struct.new(:name, :gender)
+ person.new("Jane", "female").to_yaml.should match_yaml("--- !ruby/struct\nname: Jane\ngender: female\n")
+ end
+
it "returns the YAML representation of a Symbol object" do
:symbol.to_yaml.should match_yaml("--- :symbol\n")
end
@@ -72,16 +86,8 @@ describe "Object#to_yaml" do
true_klass.to_yaml.should match_yaml("--- true\n")
end
- ruby_version_is ""..."2.7" do
- it "returns the YAML representation of a Error object" do
- StandardError.new("foobar").to_yaml.should match_yaml("--- !ruby/exception:StandardError\nmessage: foobar\n")
- end
- end
-
- ruby_version_is "2.7" do
- it "returns the YAML representation of a Error object" do
- StandardError.new("foobar").to_yaml.should match_yaml("--- !ruby/exception:StandardError\nmessage: foobar\nbacktrace: \n")
- end
+ it "returns the YAML representation of a Error object" do
+ StandardError.new("foobar").to_yaml.should match_yaml("--- !ruby/exception:StandardError\nmessage: foobar\nbacktrace: \n")
end
it "returns the YAML representation for Range objects" do
diff --git a/spec/ruby/library/yaml/unsafe_load_spec.rb b/spec/ruby/library/yaml/unsafe_load_spec.rb
new file mode 100644
index 0000000000..385cd2a6e2
--- /dev/null
+++ b/spec/ruby/library/yaml/unsafe_load_spec.rb
@@ -0,0 +1,9 @@
+require_relative '../../spec_helper'
+require_relative 'shared/load'
+
+guard -> { Psych::VERSION >= "4.0.0" } do
+ describe "YAML.unsafe_load" do
+ it_behaves_like :yaml_load_safe, :unsafe_load
+ it_behaves_like :yaml_load_unsafe, :unsafe_load
+ end
+end
diff --git a/spec/ruby/library/zlib/crc_table_spec.rb b/spec/ruby/library/zlib/crc_table_spec.rb
index f7fc2749fa..de8876086b 100644
--- a/spec/ruby/library/zlib/crc_table_spec.rb
+++ b/spec/ruby/library/zlib/crc_table_spec.rb
@@ -2,74 +2,79 @@ require_relative '../../spec_helper'
require "zlib"
describe "Zlib.crc_table" do
-
- it "returns the same value as zlib's get_crc_table()" do
- Zlib.crc_table.should == [
- 0, 1996959894, 3993919788, 2567524794,
- 124634137, 1886057615, 3915621685, 2657392035,
- 249268274, 2044508324, 3772115230, 2547177864,
- 162941995, 2125561021, 3887607047, 2428444049,
- 498536548, 1789927666, 4089016648, 2227061214,
- 450548861, 1843258603, 4107580753, 2211677639,
- 325883990, 1684777152, 4251122042, 2321926636,
- 335633487, 1661365465, 4195302755, 2366115317,
- 997073096, 1281953886, 3579855332, 2724688242,
- 1006888145, 1258607687, 3524101629, 2768942443,
- 901097722, 1119000684, 3686517206, 2898065728,
- 853044451, 1172266101, 3705015759, 2882616665,
- 651767980, 1373503546, 3369554304, 3218104598,
- 565507253, 1454621731, 3485111705, 3099436303,
- 671266974, 1594198024, 3322730930, 2970347812,
- 795835527, 1483230225, 3244367275, 3060149565,
- 1994146192, 31158534, 2563907772, 4023717930,
- 1907459465, 112637215, 2680153253, 3904427059,
- 2013776290, 251722036, 2517215374, 3775830040,
- 2137656763, 141376813, 2439277719, 3865271297,
- 1802195444, 476864866, 2238001368, 4066508878,
- 1812370925, 453092731, 2181625025, 4111451223,
- 1706088902, 314042704, 2344532202, 4240017532,
- 1658658271, 366619977, 2362670323, 4224994405,
- 1303535960, 984961486, 2747007092, 3569037538,
- 1256170817, 1037604311, 2765210733, 3554079995,
- 1131014506, 879679996, 2909243462, 3663771856,
- 1141124467, 855842277, 2852801631, 3708648649,
- 1342533948, 654459306, 3188396048, 3373015174,
- 1466479909, 544179635, 3110523913, 3462522015,
- 1591671054, 702138776, 2966460450, 3352799412,
- 1504918807, 783551873, 3082640443, 3233442989,
- 3988292384, 2596254646, 62317068, 1957810842,
- 3939845945, 2647816111, 81470997, 1943803523,
- 3814918930, 2489596804, 225274430, 2053790376,
- 3826175755, 2466906013, 167816743, 2097651377,
- 4027552580, 2265490386, 503444072, 1762050814,
- 4150417245, 2154129355, 426522225, 1852507879,
- 4275313526, 2312317920, 282753626, 1742555852,
- 4189708143, 2394877945, 397917763, 1622183637,
- 3604390888, 2714866558, 953729732, 1340076626,
- 3518719985, 2797360999, 1068828381, 1219638859,
- 3624741850, 2936675148, 906185462, 1090812512,
- 3747672003, 2825379669, 829329135, 1181335161,
- 3412177804, 3160834842, 628085408, 1382605366,
- 3423369109, 3138078467, 570562233, 1426400815,
- 3317316542, 2998733608, 733239954, 1555261956,
- 3268935591, 3050360625, 752459403, 1541320221,
- 2607071920, 3965973030, 1969922972, 40735498,
- 2617837225, 3943577151, 1913087877, 83908371,
- 2512341634, 3803740692, 2075208622, 213261112,
- 2463272603, 3855990285, 2094854071, 198958881,
- 2262029012, 4057260610, 1759359992, 534414190,
- 2176718541, 4139329115, 1873836001, 414664567,
- 2282248934, 4279200368, 1711684554, 285281116,
- 2405801727, 4167216745, 1634467795, 376229701,
- 2685067896, 3608007406, 1308918612, 956543938,
- 2808555105, 3495958263, 1231636301, 1047427035,
- 2932959818, 3654703836, 1088359270, 936918000,
- 2847714899, 3736837829, 1202900863, 817233897,
- 3183342108, 3401237130, 1404277552, 615818150,
- 3134207493, 3453421203, 1423857449, 601450431,
- 3009837614, 3294710456, 1567103746, 711928724,
- 3020668471, 3272380065, 1510334235, 755167117,
- ]
+ # This spec fails when zlib.h and libz.so are not from the same version.
+ # In older zlib (< 1.2.7 it seems), get_crc_table() is stored as u64[],
+ # but in newer zlib, get_crc_table() is stored as u32[].
+ # Technically, there is ABI breakage between those zlib versions,
+ # but get_crc_table() is an "undocumented function" according to zlib.h.
+ guard -> { ENV["RUBY_SPEC_TEST_ZLIB_CRC_TABLE"] != "false" } do
+ it "returns the same value as zlib's get_crc_table()" do
+ Zlib.crc_table.should == [
+ 0, 1996959894, 3993919788, 2567524794,
+ 124634137, 1886057615, 3915621685, 2657392035,
+ 249268274, 2044508324, 3772115230, 2547177864,
+ 162941995, 2125561021, 3887607047, 2428444049,
+ 498536548, 1789927666, 4089016648, 2227061214,
+ 450548861, 1843258603, 4107580753, 2211677639,
+ 325883990, 1684777152, 4251122042, 2321926636,
+ 335633487, 1661365465, 4195302755, 2366115317,
+ 997073096, 1281953886, 3579855332, 2724688242,
+ 1006888145, 1258607687, 3524101629, 2768942443,
+ 901097722, 1119000684, 3686517206, 2898065728,
+ 853044451, 1172266101, 3705015759, 2882616665,
+ 651767980, 1373503546, 3369554304, 3218104598,
+ 565507253, 1454621731, 3485111705, 3099436303,
+ 671266974, 1594198024, 3322730930, 2970347812,
+ 795835527, 1483230225, 3244367275, 3060149565,
+ 1994146192, 31158534, 2563907772, 4023717930,
+ 1907459465, 112637215, 2680153253, 3904427059,
+ 2013776290, 251722036, 2517215374, 3775830040,
+ 2137656763, 141376813, 2439277719, 3865271297,
+ 1802195444, 476864866, 2238001368, 4066508878,
+ 1812370925, 453092731, 2181625025, 4111451223,
+ 1706088902, 314042704, 2344532202, 4240017532,
+ 1658658271, 366619977, 2362670323, 4224994405,
+ 1303535960, 984961486, 2747007092, 3569037538,
+ 1256170817, 1037604311, 2765210733, 3554079995,
+ 1131014506, 879679996, 2909243462, 3663771856,
+ 1141124467, 855842277, 2852801631, 3708648649,
+ 1342533948, 654459306, 3188396048, 3373015174,
+ 1466479909, 544179635, 3110523913, 3462522015,
+ 1591671054, 702138776, 2966460450, 3352799412,
+ 1504918807, 783551873, 3082640443, 3233442989,
+ 3988292384, 2596254646, 62317068, 1957810842,
+ 3939845945, 2647816111, 81470997, 1943803523,
+ 3814918930, 2489596804, 225274430, 2053790376,
+ 3826175755, 2466906013, 167816743, 2097651377,
+ 4027552580, 2265490386, 503444072, 1762050814,
+ 4150417245, 2154129355, 426522225, 1852507879,
+ 4275313526, 2312317920, 282753626, 1742555852,
+ 4189708143, 2394877945, 397917763, 1622183637,
+ 3604390888, 2714866558, 953729732, 1340076626,
+ 3518719985, 2797360999, 1068828381, 1219638859,
+ 3624741850, 2936675148, 906185462, 1090812512,
+ 3747672003, 2825379669, 829329135, 1181335161,
+ 3412177804, 3160834842, 628085408, 1382605366,
+ 3423369109, 3138078467, 570562233, 1426400815,
+ 3317316542, 2998733608, 733239954, 1555261956,
+ 3268935591, 3050360625, 752459403, 1541320221,
+ 2607071920, 3965973030, 1969922972, 40735498,
+ 2617837225, 3943577151, 1913087877, 83908371,
+ 2512341634, 3803740692, 2075208622, 213261112,
+ 2463272603, 3855990285, 2094854071, 198958881,
+ 2262029012, 4057260610, 1759359992, 534414190,
+ 2176718541, 4139329115, 1873836001, 414664567,
+ 2282248934, 4279200368, 1711684554, 285281116,
+ 2405801727, 4167216745, 1634467795, 376229701,
+ 2685067896, 3608007406, 1308918612, 956543938,
+ 2808555105, 3495958263, 1231636301, 1047427035,
+ 2932959818, 3654703836, 1088359270, 936918000,
+ 2847714899, 3736837829, 1202900863, 817233897,
+ 3183342108, 3401237130, 1404277552, 615818150,
+ 3134207493, 3453421203, 1423857449, 601450431,
+ 3009837614, 3294710456, 1567103746, 711928724,
+ 3020668471, 3272380065, 1510334235, 755167117,
+ ]
+ end
end
-
end
diff --git a/spec/ruby/library/zlib/deflate/deflate_spec.rb b/spec/ruby/library/zlib/deflate/deflate_spec.rb
index 828880f8d8..e16e6ad0ef 100644
--- a/spec/ruby/library/zlib/deflate/deflate_spec.rb
+++ b/spec/ruby/library/zlib/deflate/deflate_spec.rb
@@ -23,7 +23,7 @@ describe "Zlib::Deflate.deflate" do
it "deflates chunked data" do
random_generator = Random.new(0)
- deflated = ''
+ deflated = +''
Zlib::Deflate.deflate(random_generator.bytes(20000)) do |chunk|
deflated << chunk
@@ -58,6 +58,11 @@ describe "Zlib::Deflate#deflate" do
Array.new(31, 0) +
[24, 128, 0, 0, 1]).pack('C*')
end
+
+ it "has a binary encoding" do
+ @deflator.deflate("").encoding.should == Encoding::BINARY
+ @deflator.finish.encoding.should == Encoding::BINARY
+ end
end
describe "Zlib::Deflate#deflate" do
@@ -65,7 +70,7 @@ describe "Zlib::Deflate#deflate" do
before :each do
@deflator = Zlib::Deflate.new
@random_generator = Random.new(0)
- @original = ''
+ @original = +''
@chunks = []
end
diff --git a/spec/ruby/library/zlib/deflate/new_spec.rb b/spec/ruby/library/zlib/deflate/new_spec.rb
deleted file mode 100644
index e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/deflate/new_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
diff --git a/spec/ruby/library/zlib/deflate/params_spec.rb b/spec/ruby/library/zlib/deflate/params_spec.rb
index 0b1cca8c8a..0242653528 100644
--- a/spec/ruby/library/zlib/deflate/params_spec.rb
+++ b/spec/ruby/library/zlib/deflate/params_spec.rb
@@ -3,7 +3,7 @@ require 'zlib'
describe "Zlib::Deflate#params" do
it "changes the deflate parameters" do
- data = 'abcdefghijklm'
+ data = +'abcdefghijklm'
d = Zlib::Deflate.new Zlib::NO_COMPRESSION, Zlib::MAX_WBITS,
Zlib::DEF_MEM_LEVEL, Zlib::DEFAULT_STRATEGY
diff --git a/spec/ruby/library/zlib/gzipreader/each_line_spec.rb b/spec/ruby/library/zlib/gzipreader/each_line_spec.rb
index efaf27d6bb..6f17365879 100644
--- a/spec/ruby/library/zlib/gzipreader/each_line_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/each_line_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/each'
describe "Zlib::GzipReader#each_line" do
diff --git a/spec/ruby/library/zlib/gzipreader/each_spec.rb b/spec/ruby/library/zlib/gzipreader/each_spec.rb
index 59aa63e52c..3b98391a87 100644
--- a/spec/ruby/library/zlib/gzipreader/each_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/each_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require_relative 'shared/each'
describe "Zlib::GzipReader#each" do
diff --git a/spec/ruby/library/zlib/gzipreader/mtime_spec.rb b/spec/ruby/library/zlib/gzipreader/mtime_spec.rb
new file mode 100644
index 0000000000..e8e71fa72e
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipreader/mtime_spec.rb
@@ -0,0 +1,11 @@
+require_relative '../../../spec_helper'
+require 'zlib'
+require 'stringio'
+
+describe "Zlib::GzipReader#mtime" do
+ it "returns the timestamp from the Gzip header" do
+ io = StringIO.new "\x1f\x8b\x08\x00\x44\x33\x22\x11\x00\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ gz = Zlib::GzipReader.new(io)
+ gz.mtime.to_i.should == 0x11223344
+ end
+end
diff --git a/spec/ruby/library/zlib/gzipreader/new_spec.rb b/spec/ruby/library/zlib/gzipreader/new_spec.rb
deleted file mode 100644
index e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipreader/new_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
diff --git a/spec/ruby/library/zlib/inflate/finish_spec.rb b/spec/ruby/library/zlib/inflate/finish_spec.rb
index f6e592fb6b..3e0663e265 100644
--- a/spec/ruby/library/zlib/inflate/finish_spec.rb
+++ b/spec/ruby/library/zlib/inflate/finish_spec.rb
@@ -1,3 +1,4 @@
+require_relative "../../../spec_helper"
require 'zlib'
describe "Zlib::Inflate#finish" do
diff --git a/spec/ruby/library/zlib/inflate/inflate_spec.rb b/spec/ruby/library/zlib/inflate/inflate_spec.rb
index cc33bd4c32..b308a4ba67 100644
--- a/spec/ruby/library/zlib/inflate/inflate_spec.rb
+++ b/spec/ruby/library/zlib/inflate/inflate_spec.rb
@@ -39,6 +39,13 @@ describe "Zlib::Inflate#inflate" do
@inflator.finish.should == 'uncompressed_data'
end
+ it "has a binary encoding" do
+ data = [120, 156, 99, 96, 128, 1, 0, 0, 10, 0, 1].pack('C*')
+ unzipped = @inflator.inflate data
+ @inflator.finish.encoding.should == Encoding::BINARY
+ unzipped.encoding.should == Encoding::BINARY
+ end
+
end
describe "Zlib::Inflate.inflate" do
@@ -65,7 +72,7 @@ describe "Zlib::Inflate.inflate" do
data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*')
z = Zlib::Inflate.new
# add bytes, one by one
- result = ""
+ result = +""
data.each_byte { |d| result << z.inflate(d.chr)}
result << z.finish
result.should == "foo"
@@ -75,7 +82,7 @@ describe "Zlib::Inflate.inflate" do
data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*')[0,5]
z = Zlib::Inflate.new
# add bytes, one by one, but not all
- result = ""
+ result = +""
data.each_byte { |d| result << z.inflate(d.chr)}
-> { result << z.finish }.should raise_error(Zlib::BufError)
end
@@ -83,7 +90,7 @@ describe "Zlib::Inflate.inflate" do
it "properly handles excessive data, byte-by-byte" do
main_data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*')
data = main_data * 2
- result = ""
+ result = +""
z = Zlib::Inflate.new
# add bytes, one by one
@@ -98,7 +105,7 @@ describe "Zlib::Inflate.inflate" do
it "properly handles excessive data, in one go" do
main_data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*')
data = main_data * 2
- result = ""
+ result = +""
z = Zlib::Inflate.new
result << z.inflate(data)
diff --git a/spec/ruby/library/zlib/inflate/new_spec.rb b/spec/ruby/library/zlib/inflate/new_spec.rb
deleted file mode 100644
index e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/inflate/new_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'