From c133f51e3d9f9a3d0d3aa94b4eff1c42da78b7be Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Thu, 7 May 2026 11:21:59 -0400 Subject: [PATCH 01/34] ZJIT: Remove from `Invariants` on invalidation Previously, we kept around `PatchPoint`s after patching them for several kinds of invariants. That wasted compute since repeated invalidation with the same key patched a growing list of patchpoints each time, making it accidentally O(n^2). Retaining the patchpoints also used memory. Some invariants, such as rb_zjit_invalidate_no_singleton_class() and rb_zjit_invalidate_root_box(), already remove from the table. This commit makes all invariants remove from the table. --- zjit/src/invariants.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zjit/src/invariants.rs b/zjit/src/invariants.rs index 0fbeabab643418..0fa800755d5cb5 100644 --- a/zjit/src/invariants.rs +++ b/zjit/src/invariants.rs @@ -188,7 +188,7 @@ pub extern "C" fn rb_zjit_bop_redefined(klass: RedefinitionFlag, bop: ruby_basic with_vm_lock(src_loc!(), || { let invariants = ZJITState::get_invariants(); - if let Some(patch_points) = invariants.bop_patch_points.get(&(klass, bop)) { + if let Some(patch_points) = invariants.bop_patch_points.remove(&(klass, bop)) { let cb = ZJITState::get_code_block(); let bop = Invariant::BOPRedefined { klass, bop }; debug!("BOP is redefined: {}", bop); @@ -372,7 +372,7 @@ pub extern "C" fn rb_zjit_constant_state_changed(id: ID) { with_vm_lock(src_loc!(), || { let invariants = ZJITState::get_invariants(); - if let Some(patch_points) = invariants.constant_state_patch_points.get(&id) { + if let Some(patch_points) = invariants.constant_state_patch_points.remove(&id) { let cb = ZJITState::get_code_block(); debug!("Constant state changed: {:?}", id); From 203d127131d2a2ad02fd5a3f09ef891e921eea37 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Thu, 7 May 2026 19:15:22 +0200 Subject: [PATCH 02/34] [ruby/prism] Use less `visit_token` in the ripper translator The ripper translator is a good resource when porting ripper usage over to prism A few places use `visit_token` when it can be more specific. A call operator for example can ever only be one of three things. A positional argument can only ever be a identifier (no constant, no global, etc.) Also removes some stale comments. There are `*_TargetNode` for these now. https://github.com/ruby/prism/commit/62511d59a2 --- lib/prism/translation/ripper.rb | 35 +++++++++++----------------- lib/prism/translation/ruby_parser.rb | 12 ---------- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index 0d79b244a6322b..ddcec997b94efa 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -1147,7 +1147,7 @@ def visit_block_parameter_node(node) on_blockarg(nil) else bounds(node.name_loc) - name = visit_token(node.name.to_s) + name = on_ident(node.name.to_s) bounds(node.location) on_blockarg(name) @@ -1362,7 +1362,7 @@ def visit_call_node(node) receiver = visit(node.receiver) bounds(node.call_operator_loc) - call_operator = visit_token(node.call_operator) + call_operator = visit_call_operator(node.call_operator) message = if node.message_loc.nil? @@ -1473,7 +1473,7 @@ def visit_call_operator_write_node(node) receiver = visit(node.receiver) bounds(node.call_operator_loc) - call_operator = visit_token(node.call_operator) + call_operator = visit_call_operator(node.call_operator) bounds(node.message_loc) message = visit_token(node.message) @@ -1495,7 +1495,7 @@ def visit_call_and_write_node(node) receiver = visit(node.receiver) bounds(node.call_operator_loc) - call_operator = visit_token(node.call_operator) + call_operator = visit_call_operator(node.call_operator) bounds(node.message_loc) message = visit_token(node.message) @@ -1517,7 +1517,7 @@ def visit_call_or_write_node(node) receiver = visit(node.receiver) bounds(node.call_operator_loc) - call_operator = visit_token(node.call_operator) + call_operator = visit_call_operator(node.call_operator) bounds(node.message_loc) message = visit_token(node.message) @@ -1551,7 +1551,7 @@ def visit_call_target_node(node) receiver = visit(node.receiver) bounds(node.call_operator_loc) - call_operator = visit_token(node.call_operator) + call_operator = visit_call_operator(node.call_operator) bounds(node.message_loc) message = visit_token(node.message) @@ -1663,9 +1663,6 @@ def visit_class_variable_read_node(node) # @@foo = 1 # ^^^^^^^^^ - # - # @@foo, @@bar = 1 - # ^^^^^ ^^^^^ def visit_class_variable_write_node(node) bounds(node.name_loc) target = on_var_field(on_cvar(node.name.to_s)) @@ -1737,9 +1734,6 @@ def visit_constant_read_node(node) # Foo = 1 # ^^^^^^^ - # - # Foo, Bar = 1 - # ^^^ ^^^ def visit_constant_write_node(node) bounds(node.name_loc) target = on_var_field(on_const(node.name.to_s)) @@ -1832,9 +1826,6 @@ def visit_constant_path_node(node) # Foo::Bar = 1 # ^^^^^^^^^^^^ - # - # Foo::Foo, Bar::Bar = 1 - # ^^^^^^^^ ^^^^^^^^ def visit_constant_path_write_node(node) target = visit_constant_path_write_node_target(node.target) @@ -1932,7 +1923,7 @@ def visit_def_node(node) operator = if !node.operator_loc.nil? bounds(node.operator_loc) - visit_token(node.operator) + node.operator == "." ? on_period(".") : on_op("::") end bounds(node.name_loc) @@ -2247,9 +2238,6 @@ def visit_global_variable_read_node(node) # $foo = 1 # ^^^^^^^^ - # - # $foo, $bar = 1 - # ^^^^ ^^^^ def visit_global_variable_write_node(node) bounds(node.name_loc) target = on_var_field(on_gvar(node.name.to_s)) @@ -3211,7 +3199,7 @@ def visit_optional_keyword_parameter_node(node) # ^^^^^^^ def visit_optional_parameter_node(node) bounds(node.name_loc) - name = visit_token(node.name.to_s) + name = on_ident(node.name.to_s) bounds(node.operator_loc) on_op("=") @@ -3532,7 +3520,7 @@ def visit_rest_parameter_node(node) on_rest_param(nil) else bounds(node.name_loc) - on_rest_param(visit_token(node.name.to_s)) + on_rest_param(on_ident(node.name.to_s)) end end @@ -4137,6 +4125,11 @@ def visit_token(token, allow_keywords = true) end end + # Visit either `.`, `&.`, or `::`. + def visit_call_operator(token) + token == "." ? on_period(token) : on_op(token) + end + # Visit a node that represents a number. We need to explicitly handle the # unary - operator. def visit_number_node(node) diff --git a/lib/prism/translation/ruby_parser.rb b/lib/prism/translation/ruby_parser.rb index d2246042ed3cd4..42bc5ee658dec7 100644 --- a/lib/prism/translation/ruby_parser.rb +++ b/lib/prism/translation/ruby_parser.rb @@ -394,9 +394,6 @@ def visit_class_variable_read_node(node) # @@foo = 1 # ^^^^^^^^^ - # - # @@foo, @@bar = 1 - # ^^^^^ ^^^^^ def visit_class_variable_write_node(node) s(node, class_variable_write_type, node.name, visit_write_value(node.value)) end @@ -651,9 +648,6 @@ def visit_global_variable_read_node(node) # $foo = 1 # ^^^^^^^^ - # - # $foo, $bar = 1 - # ^^^^ ^^^^ def visit_global_variable_write_node(node) s(node, :gasgn, node.name, visit_write_value(node.value)) end @@ -799,9 +793,6 @@ def visit_instance_variable_read_node(node) # @foo = 1 # ^^^^^^^^ - # - # @foo, @bar = 1 - # ^^^^ ^^^^ def visit_instance_variable_write_node(node) s(node, :iasgn, node.name, visit_write_value(node.value)) end @@ -1013,9 +1004,6 @@ def visit_local_variable_read_node(node) # foo = 1 # ^^^^^^^ - # - # foo, bar = 1 - # ^^^ ^^^ def visit_local_variable_write_node(node) s(node, :lasgn, node.name, visit_write_value(node.value)) end From d5e2779bbb8fcbaacd5f6b63894a86b4916157c7 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 6 May 2026 19:41:29 -0400 Subject: [PATCH 03/34] Use rb_gc_get_ec in rb_gc_event_hook This would allow rb_gc_event_hook to run in a GC thread that is a non-Ruby thread. --- gc.c | 2 +- gc/default/default.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gc.c b/gc.c index d0dc70ff7fb356..0976d6b7b0b0cb 100644 --- a/gc.c +++ b/gc.c @@ -239,7 +239,7 @@ rb_gc_event_hook(VALUE obj, rb_event_flag_t event) { if (LIKELY(!rb_gc_event_hook_required_p(event))) return; - rb_execution_context_t *ec = GET_EC(); + rb_execution_context_t *ec = rb_gc_get_ec(); if (!ec->cfp) return; EXEC_EVENT_HOOK(ec, event, ec->cfp->self, 0, 0, 0, obj); diff --git a/gc/default/default.c b/gc/default/default.c index 6465b5c70e6313..a08f6b79c8eab3 100644 --- a/gc/default/default.c +++ b/gc/default/default.c @@ -6415,6 +6415,8 @@ garbage_collect(rb_objspace_t *objspace, unsigned int reason) static int gc_start(rb_objspace_t *objspace, unsigned int reason) { + rb_gc_initialize_vm_context(&objspace->vm_context); + unsigned int do_full_mark = !!(reason & GPR_FLAG_FULL_MARK); if (!rb_darray_size(objspace->heap_pages.sorted)) return TRUE; /* heap is not ready */ From 72d032e13edc4b9b17bd66ef69109d581641d5c1 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 8 May 2026 01:30:46 +0200 Subject: [PATCH 04/34] Update to ruby/mspec@dffcdf7 --- spec/mspec/lib/mspec/matchers/base.rb | 16 +++++ spec/mspec/lib/mspec/matchers/raise_error.rb | 56 +++++++++++---- spec/mspec/spec/matchers/raise_error_spec.rb | 73 +++++++++++++++++--- 3 files changed, 120 insertions(+), 25 deletions(-) diff --git a/spec/mspec/lib/mspec/matchers/base.rb b/spec/mspec/lib/mspec/matchers/base.rb index d9d7f6fec02055..3534520d88c438 100644 --- a/spec/mspec/lib/mspec/matchers/base.rb +++ b/spec/mspec/lib/mspec/matchers/base.rb @@ -36,6 +36,14 @@ def equal?(expected) end end + def raise(exception = ::Exception, message = nil, options = nil, &block) + matcher = ::RaiseErrorMatcher.new(exception, message, options, &block) + unless matcher.matches? @actual + expected, actual = matcher.failure_message + ::SpecExpectation.fail_with(expected, actual) + end + end + def method_missing(name, *args, &block) result = @actual.__send__(name, *args, &block) unless result @@ -70,6 +78,14 @@ def equal?(expected) end end + def raise(exception = ::Exception, message = nil, options = nil, &block) + matcher = ::RaiseErrorMatcher.new(exception, message, options, &block) + if matcher.matches? @actual + expected, actual = matcher.negative_failure_message + ::SpecExpectation.fail_with(expected, actual) + end + end + def method_missing(name, *args, &block) result = @actual.__send__(name, *args, &block) if result diff --git a/spec/mspec/lib/mspec/matchers/raise_error.rb b/spec/mspec/lib/mspec/matchers/raise_error.rb index 2aa3038ed1673a..8cba842ce3ffe8 100644 --- a/spec/mspec/lib/mspec/matchers/raise_error.rb +++ b/spec/mspec/lib/mspec/matchers/raise_error.rb @@ -1,11 +1,18 @@ class RaiseErrorMatcher FAILURE_MESSAGE_FOR_EXCEPTION = {}.compare_by_identity + UNDEF_CAUSE = Object.new attr_writer :block - def initialize(exception, message, &block) + def initialize(exception, message = nil, options = nil, &block) + if message.is_a? Hash + @message = nil + options = message + else + @message = message + end + @cause = options ? options.fetch(:cause, UNDEF_CAUSE) : UNDEF_CAUSE @exception = exception - @message = message @block = block @actual = nil end @@ -45,24 +52,45 @@ def matching_message?(exc) end end + def matching_cause?(exc) + case @cause + when UNDEF_CAUSE + true + else + @cause == exc.cause + end + end + def matching_exception?(exc) - matching_class?(exc) and matching_message?(exc) + matching_class?(exc) and matching_message?(exc) and matching_cause?(exc) end - def exception_class_and_message(exception_class, message) - if message - "#{exception_class} (#{message})" - else - "#{exception_class}" + def exception_class_and_message_and_cause(exception_class, message, cause) + string = "#{exception_class}" + prefixed = false + prefix = -> { prefixed ? ", " : prefixed = "(" } + + if message != nil + string << "#{prefix.()}#{message.inspect}" + end + + if cause != UNDEF_CAUSE + string << "#{prefix.()}cause: #{cause.inspect}" end + + string << ")" if prefixed + + string end def format_expected_exception - exception_class_and_message(@exception, @message) + exception_class_and_message_and_cause(@exception, @message, @cause) end def format_exception(exception) - exception_class_and_message(exception.class, exception.message) + exception_class_and_message_and_cause(exception.class, + @message == nil ? nil : exception.message, + @cause == UNDEF_CAUSE ? UNDEF_CAUSE : exception.cause) end def failure_message @@ -87,18 +115,18 @@ def negative_failure_message end module MSpecMatchers - private def raise_error(exception = Exception, message = nil, &block) - RaiseErrorMatcher.new(exception, message, &block) + private def raise_error(exception = Exception, message = nil, options = nil, &block) + RaiseErrorMatcher.new(exception, message, options, &block) end # CRuby < 4.1 has inconsistent coercion errors: # https://bugs.ruby-lang.org/issues/21864 # This matcher ignores the message on CRuby < 4.1 # and checks the message for all other cases, including other Rubies - private def raise_consistent_error(exception = Exception, message = nil, &block) + private def raise_consistent_error(exception = Exception, message = nil, options = nil, &block) if RUBY_ENGINE == "ruby" and ruby_version_is ""..."4.1" message = nil end - RaiseErrorMatcher.new(exception, message, &block) + RaiseErrorMatcher.new(exception, message, options, &block) end end diff --git a/spec/mspec/spec/matchers/raise_error_spec.rb b/spec/mspec/spec/matchers/raise_error_spec.rb index 8613eee11856dd..3849c7dd2a3bfb 100644 --- a/spec/mspec/spec/matchers/raise_error_spec.rb +++ b/spec/mspec/spec/matchers/raise_error_spec.rb @@ -84,10 +84,10 @@ class UnexpectedException < Exception; end matcher.matches?(Proc.new { raise exc }) rescue UnexpectedException => e expect(matcher.failure_message).to eq( - ["Expected ExpectedException (message)", "but got: UnexpectedException (message)"] + ['Expected ExpectedException("message")', 'but got: UnexpectedException("message")'] ) expect(ExceptionState.new(nil, nil, e).message).to eq( - "Expected ExpectedException (message)\nbut got: UnexpectedException (message)" + "Expected ExpectedException(\"message\")\nbut got: UnexpectedException(\"message\")" ) else raise "no exception" @@ -103,10 +103,10 @@ class UnexpectedException < Exception; end matcher.matches?(Proc.new { raise exc }) rescue ExpectedException => e expect(matcher.failure_message).to eq( - ["Expected ExpectedException (expected)", "but got: ExpectedException (unexpected)"] + ['Expected ExpectedException("expected")', 'but got: ExpectedException("unexpected")'] ) expect(ExceptionState.new(nil, nil, e).message).to eq( - "Expected ExpectedException (expected)\nbut got: ExpectedException (unexpected)" + "Expected ExpectedException(\"expected\")\nbut got: ExpectedException(\"unexpected\")" ) else raise "no exception" @@ -122,10 +122,10 @@ class UnexpectedException < Exception; end matcher.matches?(Proc.new { raise exc }) rescue UnexpectedException => e expect(matcher.failure_message).to eq( - ["Expected ExpectedException (expected)", "but got: UnexpectedException (unexpected)"] + ['Expected ExpectedException("expected")', 'but got: UnexpectedException("unexpected")'] ) expect(ExceptionState.new(nil, nil, e).message).to eq( - "Expected ExpectedException (expected)\nbut got: UnexpectedException (unexpected)" + "Expected ExpectedException(\"expected\")\nbut got: UnexpectedException(\"unexpected\")" ) else raise "no exception" @@ -137,7 +137,7 @@ class UnexpectedException < Exception; end matcher = RaiseErrorMatcher.new(ExpectedException, "expected") matcher.matches?(proc) expect(matcher.failure_message).to eq( - ["Expected ExpectedException (expected)", "but no exception was raised (120 was returned)"] + ['Expected ExpectedException("expected")', "but no exception was raised (120 was returned)"] ) end @@ -146,7 +146,7 @@ class UnexpectedException < Exception; end matcher = RaiseErrorMatcher.new(ExpectedException, "expected") matcher.matches?(proc) expect(matcher.failure_message).to eq( - ["Expected ExpectedException (expected)", "but no exception was raised (nil was returned)"] + ['Expected ExpectedException("expected")', "but no exception was raised (nil was returned)"] ) end @@ -159,7 +159,7 @@ def result.pretty_inspect matcher = RaiseErrorMatcher.new(ExpectedException, "expected") matcher.matches?(proc) expect(matcher.failure_message).to eq( - ["Expected ExpectedException (expected)", "but no exception was raised (#(#pretty_inspect raised #) was returned)"] + ['Expected ExpectedException("expected")', 'but no exception was raised (#(#pretty_inspect raised #) was returned)'] ) end @@ -168,7 +168,7 @@ def result.pretty_inspect matcher = RaiseErrorMatcher.new(ExpectedException, "expected") matcher.matches?(proc) expect(matcher.negative_failure_message).to eq( - ["Expected to not get ExpectedException (expected)", ""] + ['Expected to not get ExpectedException("expected")', ""] ) end @@ -177,7 +177,58 @@ def result.pretty_inspect matcher = RaiseErrorMatcher.new(Exception, nil) matcher.matches?(proc) expect(matcher.negative_failure_message).to eq( - ["Expected to not get Exception", "but got: UnexpectedException (unexpected)"] + ['Expected to not get Exception', 'but got: UnexpectedException'] ) end + + it "matches cause if given" do + cause = RuntimeError.new("foo") + proc = -> do + raise cause + rescue + raise "bar" + end + + matcher = RaiseErrorMatcher.new(RuntimeError, cause: cause) + expect(matcher.matches?(proc)).to eq(true) + end + + it "matches message and cause if given" do + cause = RuntimeError.new("foo") + proc = -> do + raise cause + rescue + raise "bar" + end + + matcher = RaiseErrorMatcher.new(RuntimeError, "bar", cause: cause) + expect(matcher.matches?(proc)).to eq(true) + end + + it "provides useful negative failure message when cause does not match" do + cause = RuntimeError.new("bar") + proc = -> do + raise "foo" + end + + matcher = RaiseErrorMatcher.new(RuntimeError, cause: cause) + + begin + matcher.matches?(proc) + rescue RuntimeError + expect(matcher.failure_message).to eq( + ['Expected RuntimeError(cause: #)', 'but got: RuntimeError(cause: nil)'] + ) + end + + matcher = RaiseErrorMatcher.new(RuntimeError, "foo", cause: cause) + + begin + matcher.matches?(proc) + rescue RuntimeError + expect(matcher.failure_message).to eq( + ['Expected RuntimeError("foo", cause: #)', 'but got: RuntimeError("foo", cause: nil)'] + ) + end + end end From 9f477803cd2ab1f27ffad0532982d43e19772170 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Fri, 8 May 2026 01:30:48 +0200 Subject: [PATCH 05/34] Update to ruby/spec@680fc69 --- spec/ruby/CONTRIBUTING.md | 27 +-- spec/ruby/command_line/dash_r_spec.rb | 8 +- spec/ruby/command_line/dash_upper_i_spec.rb | 10 +- spec/ruby/command_line/dash_v_spec.rb | 2 +- spec/ruby/command_line/dash_x_spec.rb | 2 +- spec/ruby/command_line/error_message_spec.rb | 2 +- spec/ruby/command_line/feature_spec.rb | 8 +- spec/ruby/command_line/frozen_strings_spec.rb | 12 +- spec/ruby/command_line/rubylib_spec.rb | 16 +- spec/ruby/core/argf/argf_spec.rb | 4 +- spec/ruby/core/argf/argv_spec.rb | 2 +- spec/ruby/core/argf/binmode_spec.rb | 2 +- spec/ruby/core/argf/close_spec.rb | 8 +- spec/ruby/core/argf/closed_spec.rb | 2 +- spec/ruby/core/argf/read_nonblock_spec.rb | 2 +- spec/ruby/core/argf/readchar_spec.rb | 2 +- spec/ruby/core/argf/readline_spec.rb | 2 +- spec/ruby/core/argf/readpartial_spec.rb | 6 +- spec/ruby/core/argf/rewind_spec.rb | 2 +- spec/ruby/core/argf/seek_spec.rb | 2 +- spec/ruby/core/argf/shared/each_byte.rb | 6 +- spec/ruby/core/argf/shared/each_char.rb | 6 +- spec/ruby/core/argf/shared/each_codepoint.rb | 8 +- spec/ruby/core/argf/shared/each_line.rb | 6 +- spec/ruby/core/argf/shared/eof.rb | 2 +- spec/ruby/core/argf/shared/fileno.rb | 2 +- spec/ruby/core/argf/shared/pos.rb | 2 +- spec/ruby/core/argf/skip_spec.rb | 2 +- spec/ruby/core/argf/to_io_spec.rb | 2 +- spec/ruby/core/array/allocate_spec.rb | 4 +- spec/ruby/core/array/append_spec.rb | 6 +- spec/ruby/core/array/assoc_spec.rb | 30 +-- spec/ruby/core/array/at_spec.rb | 4 +- spec/ruby/core/array/bsearch_index_spec.rb | 28 +-- spec/ruby/core/array/bsearch_spec.rb | 26 +- spec/ruby/core/array/clear_spec.rb | 8 +- spec/ruby/core/array/clone_spec.rb | 8 +- spec/ruby/core/array/combination_spec.rb | 6 +- spec/ruby/core/array/compact_spec.rb | 14 +- spec/ruby/core/array/comparison_spec.rb | 2 +- spec/ruby/core/array/concat_spec.rb | 10 +- spec/ruby/core/array/constructor_spec.rb | 4 +- spec/ruby/core/array/cycle_spec.rb | 20 +- spec/ruby/core/array/deconstruct_spec.rb | 2 +- spec/ruby/core/array/delete_at_spec.rb | 2 +- spec/ruby/core/array/delete_if_spec.rb | 16 +- spec/ruby/core/array/delete_spec.rb | 2 +- spec/ruby/core/array/difference_spec.rb | 4 +- spec/ruby/core/array/dig_spec.rb | 8 +- spec/ruby/core/array/drop_spec.rb | 8 +- spec/ruby/core/array/drop_while_spec.rb | 2 +- spec/ruby/core/array/dup_spec.rb | 12 +- spec/ruby/core/array/each_index_spec.rb | 2 +- spec/ruby/core/array/each_spec.rb | 2 +- .../ruby/core/array/element_reference_spec.rb | 4 +- spec/ruby/core/array/element_set_spec.rb | 48 ++-- spec/ruby/core/array/eql_spec.rb | 4 +- spec/ruby/core/array/equal_value_spec.rb | 10 +- spec/ruby/core/array/fetch_spec.rb | 10 +- spec/ruby/core/array/fetch_values_spec.rb | 6 +- spec/ruby/core/array/fill_spec.rb | 50 ++-- spec/ruby/core/array/filter_spec.rb | 2 +- spec/ruby/core/array/first_spec.rb | 24 +- spec/ruby/core/array/flatten_spec.rb | 36 +-- spec/ruby/core/array/hash_spec.rb | 8 +- spec/ruby/core/array/initialize_spec.rb | 32 +-- spec/ruby/core/array/insert_spec.rb | 14 +- spec/ruby/core/array/join_spec.rb | 4 +- spec/ruby/core/array/keep_if_spec.rb | 2 +- spec/ruby/core/array/last_spec.rb | 22 +- spec/ruby/core/array/max_spec.rb | 8 +- spec/ruby/core/array/min_spec.rb | 10 +- spec/ruby/core/array/multiply_spec.rb | 22 +- spec/ruby/core/array/new_spec.rb | 28 +-- spec/ruby/core/array/pack/a_spec.rb | 4 +- spec/ruby/core/array/pack/b_spec.rb | 4 +- spec/ruby/core/array/pack/buffer_spec.rb | 6 +- spec/ruby/core/array/pack/c_spec.rb | 2 +- spec/ruby/core/array/pack/h_spec.rb | 4 +- spec/ruby/core/array/pack/m_spec.rb | 12 +- spec/ruby/core/array/pack/percent_spec.rb | 2 +- spec/ruby/core/array/pack/r_spec.rb | 4 +- spec/ruby/core/array/pack/shared/basic.rb | 28 +-- spec/ruby/core/array/pack/shared/encodings.rb | 4 +- spec/ruby/core/array/pack/shared/float.rb | 24 +- spec/ruby/core/array/pack/shared/integer.rb | 12 +- .../core/array/pack/shared/numeric_basic.rb | 16 +- spec/ruby/core/array/pack/shared/string.rb | 6 +- spec/ruby/core/array/pack/shared/unicode.rb | 10 +- spec/ruby/core/array/pack/u_spec.rb | 10 +- spec/ruby/core/array/pack/w_spec.rb | 4 +- spec/ruby/core/array/pack/x_spec.rb | 4 +- spec/ruby/core/array/pack/z_spec.rb | 2 +- spec/ruby/core/array/partition_spec.rb | 6 +- spec/ruby/core/array/permutation_spec.rb | 10 +- spec/ruby/core/array/plus_spec.rb | 12 +- spec/ruby/core/array/pop_spec.rb | 24 +- spec/ruby/core/array/product_spec.rb | 14 +- spec/ruby/core/array/rassoc_spec.rb | 8 +- spec/ruby/core/array/reject_spec.rb | 16 +- .../core/array/repeated_combination_spec.rb | 8 +- .../core/array/repeated_permutation_spec.rb | 4 +- spec/ruby/core/array/reverse_each_spec.rb | 2 +- spec/ruby/core/array/reverse_spec.rb | 6 +- spec/ruby/core/array/rindex_spec.rb | 4 +- spec/ruby/core/array/rotate_spec.rb | 42 ++-- spec/ruby/core/array/sample_spec.rb | 32 +-- spec/ruby/core/array/select_spec.rb | 2 +- spec/ruby/core/array/shared/clone.rb | 8 +- spec/ruby/core/array/shared/collect.rb | 22 +- spec/ruby/core/array/shared/difference.rb | 8 +- spec/ruby/core/array/shared/enumeratorize.rb | 2 +- spec/ruby/core/array/shared/eql.rb | 66 +++--- spec/ruby/core/array/shared/index.rb | 2 +- spec/ruby/core/array/shared/inspect.rb | 4 +- spec/ruby/core/array/shared/intersection.rb | 6 +- spec/ruby/core/array/shared/join.rb | 10 +- spec/ruby/core/array/shared/keep_if.rb | 16 +- spec/ruby/core/array/shared/push.rb | 6 +- spec/ruby/core/array/shared/replace.rb | 8 +- spec/ruby/core/array/shared/select.rb | 2 +- spec/ruby/core/array/shared/slice.rb | 62 ++--- spec/ruby/core/array/shared/union.rb | 6 +- spec/ruby/core/array/shared/unshift.rb | 8 +- spec/ruby/core/array/shift_spec.rb | 20 +- spec/ruby/core/array/shuffle_spec.rb | 28 +-- spec/ruby/core/array/slice_spec.rb | 18 +- spec/ruby/core/array/sort_by_spec.rb | 16 +- spec/ruby/core/array/sort_spec.rb | 40 ++-- spec/ruby/core/array/sum_spec.rb | 4 +- spec/ruby/core/array/take_spec.rb | 4 +- spec/ruby/core/array/take_while_spec.rb | 2 +- spec/ruby/core/array/to_a_spec.rb | 4 +- spec/ruby/core/array/to_ary_spec.rb | 4 +- spec/ruby/core/array/to_h_spec.rb | 16 +- spec/ruby/core/array/transpose_spec.rb | 10 +- spec/ruby/core/array/try_convert_spec.rb | 14 +- spec/ruby/core/array/union_spec.rb | 2 +- spec/ruby/core/array/uniq_spec.rb | 12 +- spec/ruby/core/array/values_at_spec.rb | 2 +- spec/ruby/core/array/zip_spec.rb | 8 +- spec/ruby/core/basicobject/__send___spec.rb | 2 +- .../ruby/core/basicobject/basicobject_spec.rb | 20 +- spec/ruby/core/basicobject/equal_spec.rb | 14 +- .../ruby/core/basicobject/equal_value_spec.rb | 2 +- spec/ruby/core/basicobject/initialize_spec.rb | 4 +- .../core/basicobject/instance_eval_spec.rb | 46 ++-- .../core/basicobject/instance_exec_spec.rb | 30 ++- .../core/basicobject/method_missing_spec.rb | 2 +- spec/ruby/core/basicobject/not_equal_spec.rb | 16 +- spec/ruby/core/basicobject/not_spec.rb | 4 +- .../singleton_method_added_spec.rb | 12 +- .../singleton_method_removed_spec.rb | 2 +- .../singleton_method_undefined_spec.rb | 2 +- spec/ruby/core/binding/dup_spec.rb | 2 +- spec/ruby/core/binding/eval_spec.rb | 2 +- .../core/binding/local_variable_get_spec.rb | 10 +- .../core/binding/local_variable_set_spec.rb | 8 +- .../ruby/core/binding/local_variables_spec.rb | 2 +- .../builtin_constants_spec.rb | 36 +-- spec/ruby/core/class/allocate_spec.rb | 6 +- spec/ruby/core/class/attached_object_spec.rb | 8 +- spec/ruby/core/class/dup_spec.rb | 4 +- spec/ruby/core/class/inherited_spec.rb | 4 +- spec/ruby/core/class/initialize_spec.rb | 10 +- spec/ruby/core/class/new_spec.rb | 22 +- spec/ruby/core/class/subclasses_spec.rb | 4 +- spec/ruby/core/class/superclass_spec.rb | 2 +- spec/ruby/core/comparable/clamp_spec.rb | 78 +++--- spec/ruby/core/comparable/equal_value_spec.rb | 10 +- spec/ruby/core/comparable/gt_spec.rb | 2 +- spec/ruby/core/comparable/gte_spec.rb | 2 +- spec/ruby/core/comparable/lt_spec.rb | 4 +- spec/ruby/core/comparable/lte_spec.rb | 2 +- spec/ruby/core/complex/coerce_spec.rb | 32 +-- spec/ruby/core/complex/comparison_spec.rb | 12 +- spec/ruby/core/complex/constants_spec.rb | 2 +- spec/ruby/core/complex/eql_spec.rb | 12 +- spec/ruby/core/complex/equal_value_spec.rb | 8 +- spec/ruby/core/complex/exponent_spec.rb | 4 +- spec/ruby/core/complex/fdiv_spec.rb | 42 ++-- spec/ruby/core/complex/integer_spec.rb | 4 +- spec/ruby/core/complex/marshal_dump_spec.rb | 2 +- spec/ruby/core/complex/negative_spec.rb | 4 +- spec/ruby/core/complex/polar_spec.rb | 12 +- spec/ruby/core/complex/positive_spec.rb | 4 +- spec/ruby/core/complex/rationalize_spec.rb | 8 +- spec/ruby/core/complex/real_spec.rb | 8 +- spec/ruby/core/complex/shared/divide.rb | 6 +- spec/ruby/core/complex/shared/rect.rb | 12 +- spec/ruby/core/complex/to_c_spec.rb | 2 +- spec/ruby/core/complex/to_f_spec.rb | 4 +- spec/ruby/core/complex/to_i_spec.rb | 4 +- spec/ruby/core/complex/to_r_spec.rb | 4 +- .../core/conditionvariable/broadcast_spec.rb | 2 +- .../conditionvariable/marshal_dump_spec.rb | 2 +- .../core/conditionvariable/signal_spec.rb | 2 +- spec/ruby/core/conditionvariable/wait_spec.rb | 2 +- spec/ruby/core/data/deconstruct_keys_spec.rb | 16 +- spec/ruby/core/data/hash_spec.rb | 2 +- spec/ruby/core/data/initialize_spec.rb | 8 +- spec/ruby/core/data/to_h_spec.rb | 8 +- spec/ruby/core/data/with_spec.rb | 2 +- spec/ruby/core/dir/chdir_spec.rb | 6 +- spec/ruby/core/dir/children_spec.rb | 18 +- spec/ruby/core/dir/chroot_spec.rb | 6 +- spec/ruby/core/dir/close_spec.rb | 8 +- spec/ruby/core/dir/each_child_spec.rb | 6 +- spec/ruby/core/dir/each_spec.rb | 4 +- spec/ruby/core/dir/empty_spec.rb | 8 +- spec/ruby/core/dir/entries_spec.rb | 10 +- spec/ruby/core/dir/fchdir_spec.rb | 12 +- spec/ruby/core/dir/fileno_spec.rb | 4 +- spec/ruby/core/dir/for_fd_spec.rb | 6 +- spec/ruby/core/dir/foreach_spec.rb | 6 +- spec/ruby/core/dir/glob_spec.rb | 2 +- spec/ruby/core/dir/home_spec.rb | 2 +- spec/ruby/core/dir/inspect_spec.rb | 4 +- spec/ruby/core/dir/mkdir_spec.rb | 10 +- spec/ruby/core/dir/read_spec.rb | 4 +- spec/ruby/core/dir/scan_spec.rb | 28 +-- spec/ruby/core/dir/shared/chroot.rb | 4 +- spec/ruby/core/dir/shared/closed.rb | 2 +- spec/ruby/core/dir/shared/delete.rb | 8 +- spec/ruby/core/dir/shared/exist.rb | 24 +- spec/ruby/core/dir/shared/glob.rb | 12 +- spec/ruby/core/dir/shared/open.rb | 18 +- spec/ruby/core/dir/shared/path.rb | 2 +- spec/ruby/core/dir/shared/pos.rb | 10 +- spec/ruby/core/dir/shared/pwd.rb | 4 +- spec/ruby/core/encoding/aliases_spec.rb | 10 +- .../core/encoding/ascii_compatible_spec.rb | 4 +- spec/ruby/core/encoding/compatible_spec.rb | 36 +-- .../converter/asciicompat_encoding_spec.rb | 6 +- .../core/encoding/converter/constants_spec.rb | 52 ++-- .../core/encoding/converter/convert_spec.rb | 7 +- .../core/encoding/converter/finish_spec.rb | 2 +- .../encoding/converter/last_error_spec.rb | 32 +-- spec/ruby/core/encoding/converter/new_spec.rb | 10 +- .../converter/primitive_convert_spec.rb | 26 +- .../converter/primitive_errinfo_spec.rb | 4 +- .../core/encoding/converter/putback_spec.rb | 2 +- .../encoding/converter/replacement_spec.rb | 8 +- .../converter/search_convpath_spec.rb | 2 +- .../core/encoding/default_external_spec.rb | 6 +- .../core/encoding/default_internal_spec.rb | 12 +- spec/ruby/core/encoding/dummy_spec.rb | 10 +- spec/ruby/core/encoding/find_spec.rb | 8 +- spec/ruby/core/encoding/inspect_spec.rb | 2 +- .../destination_encoding_name_spec.rb | 4 +- .../destination_encoding_spec.rb | 4 +- .../error_bytes_spec.rb | 4 +- .../incomplete_input_spec.rb | 6 +- .../readagain_bytes_spec.rb | 4 +- .../source_encoding_name_spec.rb | 2 +- .../source_encoding_spec.rb | 4 +- spec/ruby/core/encoding/list_spec.rb | 10 +- .../ruby/core/encoding/locale_charmap_spec.rb | 2 +- spec/ruby/core/encoding/name_list_spec.rb | 8 +- spec/ruby/core/encoding/names_spec.rb | 6 +- spec/ruby/core/encoding/shared/name.rb | 2 +- .../destination_encoding_name_spec.rb | 2 +- .../destination_encoding_spec.rb | 2 +- .../error_char_spec.rb | 4 +- .../source_encoding_name_spec.rb | 2 +- .../source_encoding_spec.rb | 4 +- spec/ruby/core/enumerable/all_spec.rb | 20 +- spec/ruby/core/enumerable/any_spec.rb | 20 +- spec/ruby/core/enumerable/chain_spec.rb | 2 +- spec/ruby/core/enumerable/chunk_spec.rb | 8 +- spec/ruby/core/enumerable/chunk_while_spec.rb | 4 +- spec/ruby/core/enumerable/cycle_spec.rb | 10 +- spec/ruby/core/enumerable/drop_spec.rb | 10 +- spec/ruby/core/enumerable/drop_while_spec.rb | 4 +- spec/ruby/core/enumerable/each_cons_spec.rb | 18 +- spec/ruby/core/enumerable/each_entry_spec.rb | 8 +- spec/ruby/core/enumerable/each_slice_spec.rb | 20 +- .../core/enumerable/each_with_index_spec.rb | 6 +- .../core/enumerable/each_with_object_spec.rb | 8 +- spec/ruby/core/enumerable/filter_map_spec.rb | 2 +- spec/ruby/core/enumerable/find_index_spec.rb | 2 +- spec/ruby/core/enumerable/first_spec.rb | 2 +- spec/ruby/core/enumerable/grep_spec.rb | 2 +- spec/ruby/core/enumerable/grep_v_spec.rb | 4 +- spec/ruby/core/enumerable/group_by_spec.rb | 8 +- spec/ruby/core/enumerable/lazy_spec.rb | 2 +- spec/ruby/core/enumerable/max_by_spec.rb | 8 +- spec/ruby/core/enumerable/max_spec.rb | 8 +- spec/ruby/core/enumerable/min_by_spec.rb | 8 +- spec/ruby/core/enumerable/min_spec.rb | 10 +- spec/ruby/core/enumerable/minmax_by_spec.rb | 6 +- spec/ruby/core/enumerable/none_spec.rb | 28 +-- spec/ruby/core/enumerable/one_spec.rb | 32 +-- spec/ruby/core/enumerable/partition_spec.rb | 2 +- spec/ruby/core/enumerable/reject_spec.rb | 2 +- .../ruby/core/enumerable/reverse_each_spec.rb | 2 +- spec/ruby/core/enumerable/shared/collect.rb | 4 +- .../core/enumerable/shared/collect_concat.rb | 4 +- spec/ruby/core/enumerable/shared/find.rb | 2 +- spec/ruby/core/enumerable/shared/find_all.rb | 2 +- spec/ruby/core/enumerable/shared/include.rb | 2 +- spec/ruby/core/enumerable/shared/inject.rb | 12 +- spec/ruby/core/enumerable/shared/take.rb | 8 +- spec/ruby/core/enumerable/slice_after_spec.rb | 10 +- .../ruby/core/enumerable/slice_before_spec.rb | 10 +- spec/ruby/core/enumerable/slice_when_spec.rb | 4 +- spec/ruby/core/enumerable/sort_by_spec.rb | 2 +- spec/ruby/core/enumerable/sort_spec.rb | 6 +- spec/ruby/core/enumerable/take_spec.rb | 2 +- spec/ruby/core/enumerable/take_while_spec.rb | 4 +- spec/ruby/core/enumerable/tally_spec.rb | 12 +- spec/ruby/core/enumerable/to_h_spec.rb | 12 +- spec/ruby/core/enumerable/to_set_spec.rb | 4 +- spec/ruby/core/enumerable/zip_spec.rb | 6 +- .../arithmetic_sequence/each_spec.rb | 2 +- .../arithmetic_sequence/hash_spec.rb | 2 +- .../arithmetic_sequence/new_spec.rb | 4 +- .../core/enumerator/chain/initialize_spec.rb | 10 +- .../ruby/core/enumerator/chain/rewind_spec.rb | 6 +- spec/ruby/core/enumerator/each_spec.rb | 14 +- .../core/enumerator/each_with_index_spec.rb | 4 +- spec/ruby/core/enumerator/feed_spec.rb | 6 +- .../core/enumerator/generator/each_spec.rb | 6 +- .../enumerator/generator/initialize_spec.rb | 6 +- spec/ruby/core/enumerator/initialize_spec.rb | 14 +- spec/ruby/core/enumerator/lazy/chunk_spec.rb | 6 +- .../core/enumerator/lazy/chunk_while_spec.rb | 2 +- .../ruby/core/enumerator/lazy/compact_spec.rb | 2 +- spec/ruby/core/enumerator/lazy/drop_spec.rb | 4 +- .../core/enumerator/lazy/drop_while_spec.rb | 6 +- spec/ruby/core/enumerator/lazy/grep_spec.rb | 8 +- spec/ruby/core/enumerator/lazy/grep_v_spec.rb | 8 +- .../core/enumerator/lazy/initialize_spec.rb | 14 +- spec/ruby/core/enumerator/lazy/lazy_spec.rb | 8 +- spec/ruby/core/enumerator/lazy/reject_spec.rb | 8 +- .../core/enumerator/lazy/shared/collect.rb | 4 +- .../enumerator/lazy/shared/collect_concat.rb | 10 +- .../core/enumerator/lazy/shared/select.rb | 6 +- .../core/enumerator/lazy/shared/to_enum.rb | 6 +- .../core/enumerator/lazy/slice_after_spec.rb | 2 +- .../core/enumerator/lazy/slice_before_spec.rb | 2 +- .../core/enumerator/lazy/slice_when_spec.rb | 2 +- spec/ruby/core/enumerator/lazy/take_spec.rb | 4 +- .../core/enumerator/lazy/take_while_spec.rb | 6 +- spec/ruby/core/enumerator/lazy/uniq_spec.rb | 4 +- .../core/enumerator/lazy/with_index_spec.rb | 2 +- spec/ruby/core/enumerator/lazy/zip_spec.rb | 8 +- spec/ruby/core/enumerator/new_spec.rb | 2 +- spec/ruby/core/enumerator/next_spec.rb | 8 +- spec/ruby/core/enumerator/next_values_spec.rb | 2 +- spec/ruby/core/enumerator/peek_spec.rb | 2 +- spec/ruby/core/enumerator/peek_values_spec.rb | 2 +- spec/ruby/core/enumerator/plus_spec.rb | 2 +- .../ruby/core/enumerator/product/each_spec.rb | 2 +- .../product/initialize_copy_spec.rb | 10 +- .../enumerator/product/initialize_spec.rb | 10 +- spec/ruby/core/enumerator/product_spec.rb | 6 +- spec/ruby/core/enumerator/shared/enum_for.rb | 6 +- .../ruby/core/enumerator/shared/with_index.rb | 4 +- .../core/enumerator/shared/with_object.rb | 14 +- spec/ruby/core/enumerator/size_spec.rb | 2 +- spec/ruby/core/enumerator/with_index_spec.rb | 8 +- .../core/enumerator/yielder/append_spec.rb | 4 +- .../enumerator/yielder/initialize_spec.rb | 4 +- spec/ruby/core/env/assoc_spec.rb | 2 +- spec/ruby/core/env/clear_spec.rb | 2 +- spec/ruby/core/env/clone_spec.rb | 6 +- spec/ruby/core/env/delete_if_spec.rb | 10 +- spec/ruby/core/env/delete_spec.rb | 2 +- spec/ruby/core/env/dup_spec.rb | 2 +- spec/ruby/core/env/each_key_spec.rb | 8 +- spec/ruby/core/env/each_value_spec.rb | 8 +- spec/ruby/core/env/element_reference_spec.rb | 4 +- spec/ruby/core/env/fetch_spec.rb | 4 +- spec/ruby/core/env/fetch_values_spec.rb | 4 +- spec/ruby/core/env/keep_if_spec.rb | 10 +- spec/ruby/core/env/key_spec.rb | 4 +- spec/ruby/core/env/rassoc_spec.rb | 2 +- spec/ruby/core/env/reject_spec.rb | 14 +- spec/ruby/core/env/replace_spec.rb | 16 +- spec/ruby/core/env/shared/each.rb | 12 +- spec/ruby/core/env/shared/include.rb | 2 +- spec/ruby/core/env/shared/select.rb | 4 +- spec/ruby/core/env/shared/store.rb | 14 +- spec/ruby/core/env/shared/to_hash.rb | 4 +- spec/ruby/core/env/shared/update.rb | 16 +- spec/ruby/core/env/shift_spec.rb | 8 +- spec/ruby/core/env/slice_spec.rb | 2 +- spec/ruby/core/env/to_h_spec.rb | 8 +- spec/ruby/core/env/values_at_spec.rb | 2 +- .../exception/backtrace_locations_spec.rb | 6 +- spec/ruby/core/exception/backtrace_spec.rb | 10 +- spec/ruby/core/exception/cause_spec.rb | 54 ++--- spec/ruby/core/exception/dup_spec.rb | 14 +- spec/ruby/core/exception/equal_value_spec.rb | 4 +- spec/ruby/core/exception/errno_spec.rb | 10 +- spec/ruby/core/exception/exception_spec.rb | 4 +- spec/ruby/core/exception/exit_value_spec.rb | 2 +- spec/ruby/core/exception/frozen_error_spec.rb | 12 +- spec/ruby/core/exception/full_message_spec.rb | 24 +- spec/ruby/core/exception/io_error_spec.rb | 16 +- spec/ruby/core/exception/name_spec.rb | 12 +- .../core/exception/no_method_error_spec.rb | 8 +- spec/ruby/core/exception/reason_spec.rb | 2 +- spec/ruby/core/exception/receiver_spec.rb | 16 +- spec/ruby/core/exception/result_spec.rb | 4 +- spec/ruby/core/exception/shared/new.rb | 4 +- .../core/exception/shared/set_backtrace.rb | 10 +- .../core/exception/signal_exception_spec.rb | 10 +- spec/ruby/core/exception/signm_spec.rb | 2 +- spec/ruby/core/exception/signo_spec.rb | 2 +- .../core/exception/standard_error_spec.rb | 2 +- spec/ruby/core/exception/status_spec.rb | 2 +- spec/ruby/core/exception/success_spec.rb | 4 +- spec/ruby/core/exception/syntax_error_spec.rb | 4 +- .../core/exception/system_call_error_spec.rb | 30 +-- spec/ruby/core/false/dup_spec.rb | 2 +- spec/ruby/core/false/falseclass_spec.rb | 4 +- spec/ruby/core/false/singleton_method_spec.rb | 4 +- spec/ruby/core/false/to_s_spec.rb | 2 +- spec/ruby/core/fiber/alive_spec.rb | 20 +- spec/ruby/core/fiber/current_spec.rb | 14 +- spec/ruby/core/fiber/new_spec.rb | 8 +- spec/ruby/core/fiber/raise_spec.rb | 36 +-- spec/ruby/core/fiber/resume_spec.rb | 4 +- spec/ruby/core/fiber/shared/resume.rb | 14 +- spec/ruby/core/fiber/shared/scheduler.rb | 6 +- spec/ruby/core/fiber/storage_spec.rb | 26 +- spec/ruby/core/fiber/transfer_spec.rb | 6 +- spec/ruby/core/fiber/yield_spec.rb | 4 +- spec/ruby/core/file/absolute_path_spec.rb | 24 +- spec/ruby/core/file/atime_spec.rb | 6 +- spec/ruby/core/file/basename_spec.rb | 18 +- spec/ruby/core/file/birthtime_spec.rb | 6 +- spec/ruby/core/file/chmod_spec.rb | 12 +- spec/ruby/core/file/chown_spec.rb | 2 +- .../core/file/constants/constants_spec.rb | 6 +- spec/ruby/core/file/ctime_spec.rb | 6 +- spec/ruby/core/file/dirname_spec.rb | 18 +- spec/ruby/core/file/expand_path_spec.rb | 20 +- spec/ruby/core/file/extname_spec.rb | 12 +- spec/ruby/core/file/ftype_spec.rb | 8 +- spec/ruby/core/file/inspect_spec.rb | 2 +- spec/ruby/core/file/join_spec.rb | 14 +- spec/ruby/core/file/link_spec.rb | 12 +- spec/ruby/core/file/mkfifo_spec.rb | 4 +- spec/ruby/core/file/mtime_spec.rb | 6 +- spec/ruby/core/file/new_spec.rb | 54 ++--- spec/ruby/core/file/open_spec.rb | 128 +++++----- spec/ruby/core/file/path_spec.rb | 20 +- spec/ruby/core/file/readlink_spec.rb | 6 +- spec/ruby/core/file/realdirpath_spec.rb | 6 +- spec/ruby/core/file/realpath_spec.rb | 6 +- spec/ruby/core/file/rename_spec.rb | 8 +- spec/ruby/core/file/shared/fnmatch.rb | 64 ++--- spec/ruby/core/file/shared/open.rb | 2 +- spec/ruby/core/file/shared/path.rb | 2 +- spec/ruby/core/file/shared/read.rb | 4 +- spec/ruby/core/file/shared/stat.rb | 6 +- spec/ruby/core/file/shared/unlink.rb | 4 +- spec/ruby/core/file/size_spec.rb | 6 +- spec/ruby/core/file/split_spec.rb | 6 +- spec/ruby/core/file/stat/atime_spec.rb | 2 +- spec/ruby/core/file/stat/birthtime_spec.rb | 2 +- spec/ruby/core/file/stat/blocks_spec.rb | 2 +- spec/ruby/core/file/stat/ctime_spec.rb | 2 +- spec/ruby/core/file/stat/dev_major_spec.rb | 4 +- spec/ruby/core/file/stat/dev_minor_spec.rb | 4 +- spec/ruby/core/file/stat/dev_spec.rb | 2 +- spec/ruby/core/file/stat/ftype_spec.rb | 2 +- spec/ruby/core/file/stat/ino_spec.rb | 4 +- spec/ruby/core/file/stat/mtime_spec.rb | 2 +- spec/ruby/core/file/stat/new_spec.rb | 4 +- spec/ruby/core/file/stat/rdev_major_spec.rb | 4 +- spec/ruby/core/file/stat/rdev_minor_spec.rb | 4 +- spec/ruby/core/file/stat/rdev_spec.rb | 2 +- spec/ruby/core/file/stat_spec.rb | 12 +- spec/ruby/core/file/symlink_spec.rb | 12 +- spec/ruby/core/file/truncate_spec.rb | 24 +- spec/ruby/core/file/umask_spec.rb | 8 +- spec/ruby/core/file/world_readable_spec.rb | 2 +- spec/ruby/core/file/world_writable_spec.rb | 2 +- spec/ruby/core/filetest/grpowned_spec.rb | 2 +- spec/ruby/core/float/ceil_spec.rb | 28 +-- spec/ruby/core/float/comparison_spec.rb | 10 +- spec/ruby/core/float/constants_spec.rb | 2 +- spec/ruby/core/float/denominator_spec.rb | 2 +- spec/ruby/core/float/divide_spec.rb | 20 +- spec/ruby/core/float/divmod_spec.rb | 22 +- spec/ruby/core/float/dup_spec.rb | 2 +- spec/ruby/core/float/eql_spec.rb | 8 +- spec/ruby/core/float/float_spec.rb | 4 +- spec/ruby/core/float/floor_spec.rb | 28 +-- spec/ruby/core/float/gt_spec.rb | 4 +- spec/ruby/core/float/gte_spec.rb | 4 +- spec/ruby/core/float/lt_spec.rb | 4 +- spec/ruby/core/float/lte_spec.rb | 4 +- spec/ruby/core/float/multiply_spec.rb | 4 +- spec/ruby/core/float/negative_spec.rb | 10 +- spec/ruby/core/float/next_float_spec.rb | 2 +- spec/ruby/core/float/numerator_spec.rb | 4 +- spec/ruby/core/float/positive_spec.rb | 10 +- spec/ruby/core/float/prev_float_spec.rb | 2 +- spec/ruby/core/float/rationalize_spec.rb | 8 +- spec/ruby/core/float/round_spec.rb | 200 ++++++++-------- spec/ruby/core/float/shared/abs.rb | 2 +- spec/ruby/core/float/shared/arg.rb | 4 +- .../shared/arithmetic_exception_in_coerce.rb | 2 +- .../shared/comparison_exception_in_coerce.rb | 2 +- spec/ruby/core/float/shared/modulo.rb | 12 +- spec/ruby/core/float/shared/quo.rb | 8 +- spec/ruby/core/float/shared/to_i.rb | 14 +- spec/ruby/core/float/shared/to_s.rb | 4 +- spec/ruby/core/float/truncate_spec.rb | 10 +- spec/ruby/core/float/uplus_spec.rb | 2 +- spec/ruby/core/gc/config_spec.rb | 18 +- spec/ruby/core/gc/count_spec.rb | 2 +- spec/ruby/core/gc/profiler/enabled_spec.rb | 4 +- spec/ruby/core/gc/profiler/result_spec.rb | 2 +- spec/ruby/core/gc/profiler/total_time_spec.rb | 2 +- spec/ruby/core/gc/stat_spec.rb | 28 +-- spec/ruby/core/gc/stress_spec.rb | 8 +- spec/ruby/core/gc/total_time_spec.rb | 2 +- spec/ruby/core/hash/allocate_spec.rb | 2 +- spec/ruby/core/hash/assoc_spec.rb | 8 +- spec/ruby/core/hash/clear_spec.rb | 6 +- spec/ruby/core/hash/clone_spec.rb | 2 +- spec/ruby/core/hash/compact_spec.rb | 8 +- .../core/hash/compare_by_identity_spec.rb | 28 +-- spec/ruby/core/hash/constructor_spec.rb | 30 +-- spec/ruby/core/hash/deconstruct_keys_spec.rb | 4 +- spec/ruby/core/hash/default_proc_spec.rb | 20 +- spec/ruby/core/hash/default_spec.rb | 4 +- spec/ruby/core/hash/delete_if_spec.rb | 8 +- spec/ruby/core/hash/delete_spec.rb | 4 +- spec/ruby/core/hash/dig_spec.rb | 18 +- spec/ruby/core/hash/each_key_spec.rb | 2 +- spec/ruby/core/hash/each_value_spec.rb | 2 +- spec/ruby/core/hash/element_reference_spec.rb | 2 +- spec/ruby/core/hash/equal_value_spec.rb | 2 +- spec/ruby/core/hash/except_spec.rb | 10 +- spec/ruby/core/hash/fetch_spec.rb | 6 +- spec/ruby/core/hash/flatten_spec.rb | 4 +- spec/ruby/core/hash/gt_spec.rb | 2 +- spec/ruby/core/hash/gte_spec.rb | 2 +- spec/ruby/core/hash/initialize_spec.rb | 12 +- spec/ruby/core/hash/invert_spec.rb | 8 +- spec/ruby/core/hash/keep_if_spec.rb | 10 +- spec/ruby/core/hash/keys_spec.rb | 4 +- spec/ruby/core/hash/lt_spec.rb | 2 +- spec/ruby/core/hash/lte_spec.rb | 2 +- spec/ruby/core/hash/merge_spec.rb | 10 +- spec/ruby/core/hash/new_spec.rb | 20 +- spec/ruby/core/hash/rassoc_spec.rb | 10 +- spec/ruby/core/hash/rehash_spec.rb | 6 +- spec/ruby/core/hash/reject_spec.rb | 18 +- spec/ruby/core/hash/replace_spec.rb | 10 +- .../core/hash/ruby2_keywords_hash_spec.rb | 4 +- spec/ruby/core/hash/shared/comparison.rb | 10 +- spec/ruby/core/hash/shared/each.rb | 8 +- spec/ruby/core/hash/shared/eql.rb | 88 +++---- spec/ruby/core/hash/shared/greater_than.rb | 6 +- spec/ruby/core/hash/shared/index.rb | 4 +- spec/ruby/core/hash/shared/iteration.rb | 6 +- spec/ruby/core/hash/shared/less_than.rb | 6 +- spec/ruby/core/hash/shared/select.rb | 22 +- spec/ruby/core/hash/shared/store.rb | 18 +- spec/ruby/core/hash/shared/to_s.rb | 2 +- spec/ruby/core/hash/shared/update.rb | 12 +- spec/ruby/core/hash/shared/values_at.rb | 4 +- spec/ruby/core/hash/shift_spec.rb | 6 +- spec/ruby/core/hash/slice_spec.rb | 12 +- spec/ruby/core/hash/to_a_spec.rb | 4 +- spec/ruby/core/hash/to_h_spec.rb | 16 +- spec/ruby/core/hash/to_hash_spec.rb | 4 +- spec/ruby/core/hash/to_proc_spec.rb | 16 +- spec/ruby/core/hash/transform_keys_spec.rb | 28 +-- spec/ruby/core/hash/transform_values_spec.rb | 26 +- spec/ruby/core/hash/try_convert_spec.rb | 14 +- spec/ruby/core/hash/values_spec.rb | 2 +- spec/ruby/core/integer/allbits_spec.rb | 6 +- spec/ruby/core/integer/anybits_spec.rb | 6 +- spec/ruby/core/integer/bit_and_spec.rb | 8 +- spec/ruby/core/integer/bit_or_spec.rb | 10 +- spec/ruby/core/integer/bit_xor_spec.rb | 10 +- spec/ruby/core/integer/ceildiv_spec.rb | 22 +- spec/ruby/core/integer/chr_spec.rb | 62 ++--- spec/ruby/core/integer/coerce_spec.rb | 28 +-- spec/ruby/core/integer/comparison_spec.rb | 6 +- spec/ruby/core/integer/digits_spec.rb | 6 +- spec/ruby/core/integer/div_spec.rb | 40 ++-- spec/ruby/core/integer/divide_spec.rb | 16 +- spec/ruby/core/integer/divmod_spec.rb | 34 +-- spec/ruby/core/integer/downto_spec.rb | 8 +- spec/ruby/core/integer/dup_spec.rb | 4 +- .../core/integer/element_reference_spec.rb | 14 +- spec/ruby/core/integer/even_spec.rb | 26 +- spec/ruby/core/integer/fdiv_spec.rb | 8 +- spec/ruby/core/integer/gcd_spec.rb | 16 +- spec/ruby/core/integer/gcdlcm_spec.rb | 16 +- spec/ruby/core/integer/gt_spec.rb | 8 +- spec/ruby/core/integer/gte_spec.rb | 8 +- spec/ruby/core/integer/integer_spec.rb | 4 +- spec/ruby/core/integer/lcm_spec.rb | 16 +- spec/ruby/core/integer/left_shift_spec.rb | 28 +-- spec/ruby/core/integer/lt_spec.rb | 8 +- spec/ruby/core/integer/lte_spec.rb | 8 +- spec/ruby/core/integer/minus_spec.rb | 12 +- spec/ruby/core/integer/multiply_spec.rb | 12 +- spec/ruby/core/integer/nobits_spec.rb | 6 +- spec/ruby/core/integer/odd_spec.rb | 26 +- spec/ruby/core/integer/ord_spec.rb | 16 +- spec/ruby/core/integer/plus_spec.rb | 12 +- spec/ruby/core/integer/pow_spec.rb | 22 +- spec/ruby/core/integer/pred_spec.rb | 10 +- spec/ruby/core/integer/rationalize_spec.rb | 6 +- spec/ruby/core/integer/remainder_spec.rb | 14 +- spec/ruby/core/integer/right_shift_spec.rb | 28 +-- spec/ruby/core/integer/round_spec.rb | 62 ++--- .../core/integer/shared/arithmetic_coerce.rb | 2 +- .../core/integer/shared/comparison_coerce.rb | 2 +- spec/ruby/core/integer/shared/exponent.rb | 78 +++--- .../core/integer/shared/integer_rounding.rb | 6 +- spec/ruby/core/integer/shared/modulo.rb | 32 +-- spec/ruby/core/integer/shared/to_i.rb | 8 +- spec/ruby/core/integer/sqrt_spec.rb | 6 +- spec/ruby/core/integer/to_f_spec.rb | 6 +- spec/ruby/core/integer/to_r_spec.rb | 8 +- spec/ruby/core/integer/to_s_spec.rb | 24 +- spec/ruby/core/integer/truncate_spec.rb | 12 +- spec/ruby/core/integer/try_convert_spec.rb | 10 +- spec/ruby/core/integer/upto_spec.rb | 8 +- spec/ruby/core/io/advise_spec.rb | 28 +-- spec/ruby/core/io/autoclose_spec.rb | 4 +- spec/ruby/core/io/binmode_spec.rb | 10 +- spec/ruby/core/io/binread_spec.rb | 4 +- spec/ruby/core/io/buffer/and_spec.rb | 6 +- spec/ruby/core/io/buffer/bit_count_spec.rb | 6 +- spec/ruby/core/io/buffer/empty_spec.rb | 6 +- spec/ruby/core/io/buffer/external_spec.rb | 6 +- spec/ruby/core/io/buffer/for_spec.rb | 6 +- spec/ruby/core/io/buffer/free_spec.rb | 28 +-- spec/ruby/core/io/buffer/initialize_spec.rb | 14 +- spec/ruby/core/io/buffer/internal_spec.rb | 6 +- spec/ruby/core/io/buffer/locked_spec.rb | 22 +- spec/ruby/core/io/buffer/map_spec.rb | 24 +- spec/ruby/core/io/buffer/mapped_spec.rb | 6 +- spec/ruby/core/io/buffer/null_spec.rb | 6 +- spec/ruby/core/io/buffer/or_spec.rb | 6 +- spec/ruby/core/io/buffer/private_spec.rb | 6 +- spec/ruby/core/io/buffer/readonly_spec.rb | 8 +- spec/ruby/core/io/buffer/resize_spec.rb | 38 +-- .../core/io/buffer/shared/null_and_empty.rb | 20 +- spec/ruby/core/io/buffer/shared_spec.rb | 8 +- spec/ruby/core/io/buffer/string_spec.rb | 6 +- spec/ruby/core/io/buffer/transfer_spec.rb | 36 +-- spec/ruby/core/io/buffer/valid_spec.rb | 32 +-- spec/ruby/core/io/buffer/xor_spec.rb | 6 +- spec/ruby/core/io/close_on_exec_spec.rb | 4 +- spec/ruby/core/io/close_read_spec.rb | 10 +- spec/ruby/core/io/close_spec.rb | 12 +- spec/ruby/core/io/close_write_spec.rb | 10 +- spec/ruby/core/io/closed_spec.rb | 4 +- spec/ruby/core/io/copy_stream_spec.rb | 24 +- spec/ruby/core/io/dup_spec.rb | 6 +- spec/ruby/core/io/each_byte_spec.rb | 6 +- spec/ruby/core/io/each_codepoint_spec.rb | 4 +- spec/ruby/core/io/eof_spec.rb | 6 +- spec/ruby/core/io/external_encoding_spec.rb | 46 ++-- spec/ruby/core/io/fcntl_spec.rb | 2 +- spec/ruby/core/io/fileno_spec.rb | 2 +- spec/ruby/core/io/flush_spec.rb | 6 +- spec/ruby/core/io/foreach_spec.rb | 4 +- spec/ruby/core/io/fsync_spec.rb | 2 +- spec/ruby/core/io/getbyte_spec.rb | 4 +- spec/ruby/core/io/getc_spec.rb | 6 +- spec/ruby/core/io/gets_spec.rb | 14 +- spec/ruby/core/io/initialize_spec.rb | 12 +- spec/ruby/core/io/inspect_spec.rb | 4 +- spec/ruby/core/io/internal_encoding_spec.rb | 28 +-- spec/ruby/core/io/ioctl_spec.rb | 6 +- spec/ruby/core/io/lineno_spec.rb | 16 +- spec/ruby/core/io/open_spec.rb | 8 +- spec/ruby/core/io/output_spec.rb | 2 +- spec/ruby/core/io/pid_spec.rb | 4 +- spec/ruby/core/io/pipe_spec.rb | 32 +-- spec/ruby/core/io/popen_spec.rb | 18 +- spec/ruby/core/io/pread_spec.rb | 16 +- spec/ruby/core/io/print_spec.rb | 4 +- spec/ruby/core/io/printf_spec.rb | 2 +- spec/ruby/core/io/puts_spec.rb | 2 +- spec/ruby/core/io/pwrite_spec.rb | 8 +- spec/ruby/core/io/read_nonblock_spec.rb | 22 +- spec/ruby/core/io/read_spec.rb | 62 ++--- spec/ruby/core/io/readbyte_spec.rb | 2 +- spec/ruby/core/io/readchar_spec.rb | 10 +- spec/ruby/core/io/readline_spec.rb | 10 +- spec/ruby/core/io/readlines_spec.rb | 28 +-- spec/ruby/core/io/readpartial_spec.rb | 16 +- spec/ruby/core/io/reopen_spec.rb | 26 +- spec/ruby/core/io/rewind_spec.rb | 2 +- spec/ruby/core/io/seek_spec.rb | 2 +- spec/ruby/core/io/select_spec.rb | 22 +- spec/ruby/core/io/set_encoding_by_bom_spec.rb | 10 +- spec/ruby/core/io/set_encoding_spec.rb | 42 ++-- spec/ruby/core/io/shared/binwrite.rb | 4 +- spec/ruby/core/io/shared/chars.rb | 10 +- spec/ruby/core/io/shared/codepoints.rb | 6 +- spec/ruby/core/io/shared/each.rb | 20 +- spec/ruby/core/io/shared/new.rb | 58 ++--- spec/ruby/core/io/shared/pos.rb | 8 +- spec/ruby/core/io/shared/readlines.rb | 24 +- spec/ruby/core/io/shared/tty.rb | 2 +- spec/ruby/core/io/shared/write.rb | 8 +- spec/ruby/core/io/stat_spec.rb | 6 +- spec/ruby/core/io/sync_spec.rb | 4 +- spec/ruby/core/io/sysopen_spec.rb | 16 +- spec/ruby/core/io/sysread_spec.rb | 14 +- spec/ruby/core/io/sysseek_spec.rb | 4 +- spec/ruby/core/io/to_i_spec.rb | 2 +- spec/ruby/core/io/to_io_spec.rb | 4 +- spec/ruby/core/io/try_convert_spec.rb | 10 +- spec/ruby/core/io/ungetbyte_spec.rb | 12 +- spec/ruby/core/io/ungetc_spec.rb | 14 +- spec/ruby/core/io/write_nonblock_spec.rb | 8 +- spec/ruby/core/io/write_spec.rb | 12 +- spec/ruby/core/kernel/Array_spec.rb | 6 +- spec/ruby/core/kernel/Complex_spec.rb | 60 ++--- spec/ruby/core/kernel/Float_spec.rb | 128 +++++----- spec/ruby/core/kernel/Hash_spec.rb | 6 +- spec/ruby/core/kernel/Integer_spec.rb | 208 ++++++++-------- spec/ruby/core/kernel/Rational_spec.rb | 38 +-- spec/ruby/core/kernel/String_spec.rb | 14 +- spec/ruby/core/kernel/abort_spec.rb | 2 +- spec/ruby/core/kernel/at_exit_spec.rb | 4 +- .../core/kernel/autoload_relative_spec.rb | 26 +- spec/ruby/core/kernel/autoload_spec.rb | 14 +- spec/ruby/core/kernel/backtick_spec.rb | 14 +- spec/ruby/core/kernel/binding_spec.rb | 4 +- spec/ruby/core/kernel/block_given_spec.rb | 2 +- .../ruby/core/kernel/caller_locations_spec.rb | 2 +- spec/ruby/core/kernel/caller_spec.rb | 4 +- spec/ruby/core/kernel/case_compare_spec.rb | 14 +- spec/ruby/core/kernel/catch_spec.rb | 10 +- spec/ruby/core/kernel/chomp_spec.rb | 2 +- spec/ruby/core/kernel/chop_spec.rb | 2 +- spec/ruby/core/kernel/class_spec.rb | 20 +- spec/ruby/core/kernel/clone_spec.rb | 16 +- spec/ruby/core/kernel/comparison_spec.rb | 6 +- .../kernel/define_singleton_method_spec.rb | 20 +- spec/ruby/core/kernel/dup_spec.rb | 8 +- spec/ruby/core/kernel/eql_spec.rb | 2 +- spec/ruby/core/kernel/eval_spec.rb | 40 ++-- spec/ruby/core/kernel/exec_spec.rb | 2 +- spec/ruby/core/kernel/exit_spec.rb | 4 +- spec/ruby/core/kernel/extend_spec.rb | 8 +- spec/ruby/core/kernel/fail_spec.rb | 10 +- spec/ruby/core/kernel/fork_spec.rb | 2 +- spec/ruby/core/kernel/format_spec.rb | 8 +- spec/ruby/core/kernel/freeze_spec.rb | 28 +-- spec/ruby/core/kernel/frozen_spec.rb | 22 +- spec/ruby/core/kernel/gets_spec.rb | 2 +- .../ruby/core/kernel/global_variables_spec.rb | 6 +- spec/ruby/core/kernel/gsub_spec.rb | 8 +- .../ruby/core/kernel/initialize_clone_spec.rb | 2 +- spec/ruby/core/kernel/initialize_copy_spec.rb | 12 +- spec/ruby/core/kernel/initialize_dup_spec.rb | 2 +- spec/ruby/core/kernel/inspect_spec.rb | 6 +- spec/ruby/core/kernel/instance_of_spec.rb | 6 +- .../kernel/instance_variable_defined_spec.rb | 12 +- .../core/kernel/instance_variable_get_spec.rb | 28 +-- .../core/kernel/instance_variable_set_spec.rb | 28 +-- .../core/kernel/instance_variables_spec.rb | 2 +- spec/ruby/core/kernel/itself_spec.rb | 2 +- spec/ruby/core/kernel/lambda_spec.rb | 32 +-- spec/ruby/core/kernel/load_spec.rb | 2 +- spec/ruby/core/kernel/local_variables_spec.rb | 11 +- spec/ruby/core/kernel/loop_spec.rb | 6 +- spec/ruby/core/kernel/method_spec.rb | 22 +- spec/ruby/core/kernel/methods_spec.rb | 34 +-- spec/ruby/core/kernel/not_match_spec.rb | 2 +- spec/ruby/core/kernel/open_spec.rb | 22 +- spec/ruby/core/kernel/p_spec.rb | 2 +- spec/ruby/core/kernel/print_spec.rb | 2 +- spec/ruby/core/kernel/printf_spec.rb | 2 +- spec/ruby/core/kernel/private_methods_spec.rb | 10 +- spec/ruby/core/kernel/proc_spec.rb | 14 +- .../core/kernel/protected_methods_spec.rb | 10 +- spec/ruby/core/kernel/public_method_spec.rb | 6 +- spec/ruby/core/kernel/public_methods_spec.rb | 19 +- spec/ruby/core/kernel/public_send_spec.rb | 16 +- spec/ruby/core/kernel/putc_spec.rb | 2 +- spec/ruby/core/kernel/puts_spec.rb | 2 +- spec/ruby/core/kernel/raise_spec.rb | 6 +- spec/ruby/core/kernel/rand_spec.rb | 94 ++++---- spec/ruby/core/kernel/readline_spec.rb | 2 +- spec/ruby/core/kernel/readlines_spec.rb | 2 +- .../kernel/remove_instance_variable_spec.rb | 20 +- .../ruby/core/kernel/require_relative_spec.rb | 132 +++++------ spec/ruby/core/kernel/require_spec.rb | 2 +- .../core/kernel/respond_to_missing_spec.rb | 20 +- spec/ruby/core/kernel/respond_to_spec.rb | 6 +- spec/ruby/core/kernel/select_spec.rb | 2 +- spec/ruby/core/kernel/set_trace_func_spec.rb | 2 +- spec/ruby/core/kernel/shared/dup_clone.rb | 8 +- spec/ruby/core/kernel/shared/kind_of.rb | 8 +- spec/ruby/core/kernel/shared/lambda.rb | 2 +- spec/ruby/core/kernel/shared/load.rb | 54 ++--- spec/ruby/core/kernel/shared/method.rb | 12 +- spec/ruby/core/kernel/shared/require.rb | 208 ++++++++-------- spec/ruby/core/kernel/shared/sprintf.rb | 32 +-- .../core/kernel/shared/sprintf_encoding.rb | 12 +- spec/ruby/core/kernel/shared/then.rb | 12 +- spec/ruby/core/kernel/singleton_class_spec.rb | 14 +- .../ruby/core/kernel/singleton_method_spec.rb | 12 +- .../core/kernel/singleton_methods_spec.rb | 65 ++--- spec/ruby/core/kernel/sleep_spec.rb | 10 +- spec/ruby/core/kernel/spawn_spec.rb | 2 +- spec/ruby/core/kernel/srand_spec.rb | 8 +- spec/ruby/core/kernel/sub_spec.rb | 4 +- spec/ruby/core/kernel/syscall_spec.rb | 2 +- spec/ruby/core/kernel/system_spec.rb | 18 +- spec/ruby/core/kernel/tap_spec.rb | 4 +- spec/ruby/core/kernel/test_spec.rb | 12 +- spec/ruby/core/kernel/throw_spec.rb | 14 +- spec/ruby/core/kernel/trace_var_spec.rb | 4 +- spec/ruby/core/kernel/trap_spec.rb | 2 +- spec/ruby/core/kernel/untrace_var_spec.rb | 2 +- spec/ruby/core/kernel/warn_spec.rb | 18 +- spec/ruby/core/main/define_method_spec.rb | 6 +- spec/ruby/core/main/include_spec.rb | 4 +- spec/ruby/core/main/private_spec.rb | 14 +- spec/ruby/core/main/public_spec.rb | 14 +- spec/ruby/core/main/ruby2_keywords_spec.rb | 2 +- spec/ruby/core/main/using_spec.rb | 14 +- spec/ruby/core/marshal/dump_spec.rb | 64 ++--- spec/ruby/core/marshal/float_spec.rb | 2 +- spec/ruby/core/marshal/shared/load.rb | 84 +++---- spec/ruby/core/matchdata/allocate_spec.rb | 2 +- spec/ruby/core/matchdata/begin_spec.rb | 10 +- spec/ruby/core/matchdata/bytebegin_spec.rb | 10 +- spec/ruby/core/matchdata/byteend_spec.rb | 2 +- spec/ruby/core/matchdata/byteoffset_spec.rb | 10 +- .../core/matchdata/deconstruct_keys_spec.rb | 12 +- .../core/matchdata/element_reference_spec.rb | 6 +- spec/ruby/core/matchdata/end_spec.rb | 2 +- spec/ruby/core/matchdata/inspect_spec.rb | 2 +- spec/ruby/core/matchdata/names_spec.rb | 4 +- spec/ruby/core/matchdata/offset_spec.rb | 10 +- spec/ruby/core/matchdata/post_match_spec.rb | 6 +- spec/ruby/core/matchdata/pre_match_spec.rb | 6 +- spec/ruby/core/matchdata/regexp_spec.rb | 2 +- spec/ruby/core/matchdata/shared/captures.rb | 2 +- spec/ruby/core/matchdata/shared/eql.rb | 8 +- spec/ruby/core/matchdata/string_spec.rb | 2 +- spec/ruby/core/matchdata/to_a_spec.rb | 2 +- spec/ruby/core/matchdata/to_s_spec.rb | 2 +- spec/ruby/core/matchdata/values_at_spec.rb | 4 +- spec/ruby/core/math/acos_spec.rb | 14 +- spec/ruby/core/math/acosh_spec.rb | 14 +- spec/ruby/core/math/asin_spec.rb | 12 +- spec/ruby/core/math/asinh_spec.rb | 8 +- spec/ruby/core/math/atan2_spec.rb | 14 +- spec/ruby/core/math/atan_spec.rb | 8 +- spec/ruby/core/math/cbrt_spec.rb | 6 +- spec/ruby/core/math/cos_spec.rb | 12 +- spec/ruby/core/math/cosh_spec.rb | 8 +- spec/ruby/core/math/erf_spec.rb | 8 +- spec/ruby/core/math/erfc_spec.rb | 8 +- spec/ruby/core/math/exp_spec.rb | 8 +- spec/ruby/core/math/expm1_spec.rb | 6 +- spec/ruby/core/math/frexp_spec.rb | 6 +- spec/ruby/core/math/gamma_spec.rb | 6 +- spec/ruby/core/math/hypot_spec.rb | 12 +- spec/ruby/core/math/ldexp_spec.rb | 14 +- spec/ruby/core/math/lgamma_spec.rb | 2 +- spec/ruby/core/math/log10_spec.rb | 12 +- spec/ruby/core/math/log1p_spec.rb | 12 +- spec/ruby/core/math/log2_spec.rb | 10 +- spec/ruby/core/math/log_spec.rb | 16 +- spec/ruby/core/math/shared/atanh.rb | 12 +- spec/ruby/core/math/sin_spec.rb | 8 +- spec/ruby/core/math/sinh_spec.rb | 8 +- spec/ruby/core/math/sqrt_spec.rb | 10 +- spec/ruby/core/math/tan_spec.rb | 8 +- spec/ruby/core/math/tanh_spec.rb | 8 +- spec/ruby/core/method/curry_spec.rb | 18 +- spec/ruby/core/method/fixtures/classes.rb | 1 + spec/ruby/core/method/original_name_spec.rb | 21 ++ spec/ruby/core/method/parameters_spec.rb | 2 +- spec/ruby/core/method/receiver_spec.rb | 8 +- spec/ruby/core/method/shared/call.rb | 4 +- spec/ruby/core/method/shared/dup.rb | 2 +- spec/ruby/core/method/shared/eql.rb | 32 +-- spec/ruby/core/method/shared/to_s.rb | 4 +- spec/ruby/core/method/source_location_spec.rb | 12 +- spec/ruby/core/method/unbind_spec.rb | 2 +- spec/ruby/core/module/alias_method_spec.rb | 48 ++-- spec/ruby/core/module/ancestors_spec.rb | 14 +- spec/ruby/core/module/append_features_spec.rb | 14 +- spec/ruby/core/module/attr_accessor_spec.rb | 16 +- spec/ruby/core/module/attr_reader_spec.rb | 10 +- spec/ruby/core/module/attr_spec.rb | 14 +- spec/ruby/core/module/attr_writer_spec.rb | 12 +- .../core/module/autoload_relative_spec.rb | 34 +-- spec/ruby/core/module/autoload_spec.rb | 124 +++++----- .../module/class_variable_defined_spec.rb | 12 +- .../core/module/class_variable_get_spec.rb | 16 +- .../core/module/class_variable_set_spec.rb | 12 +- spec/ruby/core/module/class_variables_spec.rb | 8 +- spec/ruby/core/module/const_added_spec.rb | 2 +- spec/ruby/core/module/const_defined_spec.rb | 62 ++--- spec/ruby/core/module/const_get_spec.rb | 46 ++-- spec/ruby/core/module/const_missing_spec.rb | 2 +- spec/ruby/core/module/const_set_spec.rb | 24 +- .../core/module/const_source_location_spec.rb | 24 +- spec/ruby/core/module/constants_spec.rb | 7 +- spec/ruby/core/module/define_method_spec.rb | 112 ++++----- .../core/module/deprecate_constant_spec.rb | 8 +- spec/ruby/core/module/extend_object_spec.rb | 10 +- spec/ruby/core/module/extended_spec.rb | 2 +- spec/ruby/core/module/gt_spec.rb | 10 +- spec/ruby/core/module/gte_spec.rb | 2 +- spec/ruby/core/module/include_spec.rb | 36 +-- .../ruby/core/module/included_modules_spec.rb | 8 +- spec/ruby/core/module/included_spec.rb | 2 +- spec/ruby/core/module/instance_method_spec.rb | 30 +-- .../ruby/core/module/instance_methods_spec.rb | 30 +-- spec/ruby/core/module/lt_spec.rb | 10 +- spec/ruby/core/module/lte_spec.rb | 2 +- spec/ruby/core/module/method_added_spec.rb | 4 +- spec/ruby/core/module/method_defined_spec.rb | 6 +- spec/ruby/core/module/method_removed_spec.rb | 2 +- .../ruby/core/module/method_undefined_spec.rb | 2 +- spec/ruby/core/module/module_function_spec.rb | 22 +- spec/ruby/core/module/name_spec.rb | 12 +- spec/ruby/core/module/new_spec.rb | 2 +- .../ruby/core/module/prepend_features_spec.rb | 8 +- spec/ruby/core/module/prepend_spec.rb | 34 +-- spec/ruby/core/module/prepended_spec.rb | 2 +- .../core/module/private_class_method_spec.rb | 22 +- .../ruby/core/module/private_constant_spec.rb | 8 +- .../module/private_instance_methods_spec.rb | 18 +- .../module/private_method_defined_spec.rb | 10 +- spec/ruby/core/module/private_spec.rb | 18 +- .../module/protected_instance_methods_spec.rb | 12 +- .../module/protected_method_defined_spec.rb | 10 +- spec/ruby/core/module/protected_spec.rb | 16 +- .../core/module/public_class_method_spec.rb | 14 +- spec/ruby/core/module/public_constant_spec.rb | 2 +- .../module/public_instance_method_spec.rb | 20 +- .../module/public_instance_methods_spec.rb | 14 +- .../core/module/public_method_defined_spec.rb | 10 +- spec/ruby/core/module/public_spec.rb | 14 +- spec/ruby/core/module/refine_spec.rb | 31 ++- .../core/module/remove_class_variable_spec.rb | 12 +- spec/ruby/core/module/remove_const_spec.rb | 30 +-- spec/ruby/core/module/remove_method_spec.rb | 16 +- spec/ruby/core/module/ruby2_keywords_spec.rb | 4 +- .../core/module/set_temporary_name_spec.rb | 18 +- spec/ruby/core/module/shared/class_eval.rb | 12 +- spec/ruby/core/module/shared/class_exec.rb | 12 +- .../ruby/core/module/shared/set_visibility.rb | 36 +-- spec/ruby/core/module/undef_method_spec.rb | 32 +-- .../module/undefined_instance_methods_spec.rb | 7 +- spec/ruby/core/module/using_spec.rb | 12 +- spec/ruby/core/mutex/lock_spec.rb | 8 +- spec/ruby/core/mutex/locked_spec.rb | 8 +- spec/ruby/core/mutex/owned_spec.rb | 6 +- spec/ruby/core/mutex/sleep_spec.rb | 20 +- spec/ruby/core/mutex/synchronize_spec.rb | 8 +- spec/ruby/core/mutex/try_lock_spec.rb | 8 +- spec/ruby/core/mutex/unlock_spec.rb | 6 +- spec/ruby/core/nil/dup_spec.rb | 2 +- spec/ruby/core/nil/match_spec.rb | 14 +- spec/ruby/core/nil/nilclass_spec.rb | 4 +- spec/ruby/core/nil/rationalize_spec.rb | 4 +- spec/ruby/core/nil/singleton_method_spec.rb | 4 +- spec/ruby/core/nil/to_c_spec.rb | 2 +- spec/ruby/core/nil/to_s_spec.rb | 2 +- spec/ruby/core/numeric/abs2_spec.rb | 4 +- spec/ruby/core/numeric/clone_spec.rb | 10 +- spec/ruby/core/numeric/coerce_spec.rb | 12 +- spec/ruby/core/numeric/comparison_spec.rb | 8 +- spec/ruby/core/numeric/div_spec.rb | 6 +- spec/ruby/core/numeric/dup_spec.rb | 4 +- spec/ruby/core/numeric/eql_spec.rb | 12 +- spec/ruby/core/numeric/fdiv_spec.rb | 4 +- spec/ruby/core/numeric/finite_spec.rb | 2 +- spec/ruby/core/numeric/i_spec.rb | 2 +- spec/ruby/core/numeric/negative_spec.rb | 12 +- spec/ruby/core/numeric/polar_spec.rb | 6 +- spec/ruby/core/numeric/positive_spec.rb | 12 +- spec/ruby/core/numeric/quo_spec.rb | 24 +- spec/ruby/core/numeric/real_spec.rb | 4 +- spec/ruby/core/numeric/remainder_spec.rb | 6 +- spec/ruby/core/numeric/shared/conj.rb | 2 +- spec/ruby/core/numeric/shared/imag.rb | 2 +- spec/ruby/core/numeric/shared/rect.rb | 6 +- spec/ruby/core/numeric/shared/step.rb | 90 +++---- .../numeric/singleton_method_added_spec.rb | 8 +- spec/ruby/core/numeric/step_spec.rb | 12 +- spec/ruby/core/numeric/to_c_spec.rb | 4 +- spec/ruby/core/objectspace/_id2ref_spec.rb | 2 +- .../core/objectspace/define_finalizer_spec.rb | 22 +- .../ruby/core/objectspace/each_object_spec.rb | 46 ++-- .../core/objectspace/garbage_collect_spec.rb | 4 +- .../objectspace/undefine_finalizer_spec.rb | 2 +- .../weakkeymap/element_set_spec.rb | 14 +- .../objectspace/weakkeymap/getkey_spec.rb | 2 +- .../core/objectspace/weakmap/shared/each.rb | 2 +- spec/ruby/core/proc/allocate_spec.rb | 2 +- spec/ruby/core/proc/binding_spec.rb | 2 +- spec/ruby/core/proc/block_pass_spec.rb | 4 +- spec/ruby/core/proc/clone_spec.rb | 2 +- spec/ruby/core/proc/curry_spec.rb | 62 ++--- spec/ruby/core/proc/dup_spec.rb | 2 +- spec/ruby/core/proc/element_reference_spec.rb | 8 +- spec/ruby/core/proc/hash_spec.rb | 6 +- spec/ruby/core/proc/lambda_spec.rb | 38 +-- spec/ruby/core/proc/new_spec.rb | 28 +-- spec/ruby/core/proc/parameters_spec.rb | 4 +- spec/ruby/core/proc/ruby2_keywords_spec.rb | 2 +- spec/ruby/core/proc/shared/call.rb | 8 +- spec/ruby/core/proc/shared/compose.rb | 4 +- spec/ruby/core/proc/shared/dup.rb | 2 +- spec/ruby/core/proc/shared/equal.rb | 34 +-- spec/ruby/core/proc/source_location_spec.rb | 24 +- spec/ruby/core/proc/to_proc_spec.rb | 2 +- spec/ruby/core/process/_fork_spec.rb | 4 +- spec/ruby/core/process/argv0_spec.rb | 2 +- spec/ruby/core/process/clock_gettime_spec.rb | 62 ++--- spec/ruby/core/process/constants_spec.rb | 22 +- spec/ruby/core/process/daemon_spec.rb | 2 +- spec/ruby/core/process/detach_spec.rb | 12 +- spec/ruby/core/process/egid_spec.rb | 8 +- spec/ruby/core/process/euid_spec.rb | 8 +- spec/ruby/core/process/exec_spec.rb | 20 +- spec/ruby/core/process/getpriority_spec.rb | 8 +- spec/ruby/core/process/getrlimit_spec.rb | 14 +- spec/ruby/core/process/groups_spec.rb | 4 +- spec/ruby/core/process/initgroups_spec.rb | 2 +- spec/ruby/core/process/kill_spec.rb | 8 +- spec/ruby/core/process/last_status_spec.rb | 2 +- spec/ruby/core/process/maxgroups_spec.rb | 2 +- spec/ruby/core/process/pid_spec.rb | 2 +- spec/ruby/core/process/set_proctitle_spec.rb | 2 +- spec/ruby/core/process/setrlimit_spec.rb | 88 +++---- spec/ruby/core/process/spawn_spec.rb | 74 +++--- spec/ruby/core/process/status/bit_and_spec.rb | 2 +- spec/ruby/core/process/status/exited_spec.rb | 6 +- .../core/process/status/right_shift_spec.rb | 2 +- .../ruby/core/process/status/signaled_spec.rb | 6 +- spec/ruby/core/process/status/success_spec.rb | 8 +- spec/ruby/core/process/status/termsig_spec.rb | 4 +- spec/ruby/core/process/status/to_i_spec.rb | 4 +- spec/ruby/core/process/status/wait_spec.rb | 18 +- spec/ruby/core/process/times_spec.rb | 2 +- spec/ruby/core/process/uid_spec.rb | 6 +- spec/ruby/core/process/wait2_spec.rb | 10 +- spec/ruby/core/process/wait_spec.rb | 16 +- spec/ruby/core/process/waitall_spec.rb | 10 +- spec/ruby/core/queue/initialize_spec.rb | 8 +- spec/ruby/core/random/new_seed_spec.rb | 2 +- spec/ruby/core/random/new_spec.rb | 6 +- spec/ruby/core/random/rand_spec.rb | 34 +-- spec/ruby/core/random/seed_spec.rb | 2 +- spec/ruby/core/random/shared/bytes.rb | 2 +- spec/ruby/core/random/shared/rand.rb | 4 +- spec/ruby/core/random/urandom_spec.rb | 4 +- spec/ruby/core/range/bsearch_spec.rb | 104 ++++---- spec/ruby/core/range/cover_spec.rb | 2 +- spec/ruby/core/range/each_spec.rb | 10 +- spec/ruby/core/range/eql_spec.rb | 2 +- spec/ruby/core/range/first_spec.rb | 10 +- spec/ruby/core/range/hash_spec.rb | 8 +- spec/ruby/core/range/include_spec.rb | 2 +- spec/ruby/core/range/initialize_spec.rb | 20 +- spec/ruby/core/range/last_spec.rb | 10 +- spec/ruby/core/range/max_spec.rb | 32 +-- spec/ruby/core/range/min_spec.rb | 26 +- spec/ruby/core/range/minmax_spec.rb | 14 +- spec/ruby/core/range/new_spec.rb | 8 +- spec/ruby/core/range/overlap_spec.rb | 2 +- spec/ruby/core/range/reverse_each_spec.rb | 26 +- spec/ruby/core/range/shared/cover.rb | 142 +++++------ .../core/range/shared/cover_and_include.rb | 30 +-- spec/ruby/core/range/shared/include.rb | 32 +-- spec/ruby/core/range/size_spec.rb | 34 +-- spec/ruby/core/range/step_spec.rb | 156 ++++++------ spec/ruby/core/range/to_a_spec.rb | 6 +- spec/ruby/core/range/to_set_spec.rb | 12 +- spec/ruby/core/rational/ceil_spec.rb | 40 ++-- spec/ruby/core/rational/comparison_spec.rb | 44 ++-- spec/ruby/core/rational/denominator_spec.rb | 4 +- spec/ruby/core/rational/div_spec.rb | 14 +- spec/ruby/core/rational/divide_spec.rb | 34 +-- spec/ruby/core/rational/divmod_spec.rb | 24 +- spec/ruby/core/rational/equal_value_spec.rb | 26 +- spec/ruby/core/rational/exponent_spec.rb | 80 +++---- spec/ruby/core/rational/floor_spec.rb | 40 ++-- spec/ruby/core/rational/integer_spec.rb | 4 +- spec/ruby/core/rational/marshal_dump_spec.rb | 2 +- spec/ruby/core/rational/minus_spec.rb | 14 +- spec/ruby/core/rational/modulo_spec.rb | 10 +- spec/ruby/core/rational/multiply_spec.rb | 26 +- spec/ruby/core/rational/numerator_spec.rb | 4 +- spec/ruby/core/rational/plus_spec.rb | 14 +- spec/ruby/core/rational/rational_spec.rb | 2 +- spec/ruby/core/rational/rationalize_spec.rb | 4 +- spec/ruby/core/rational/round_spec.rb | 24 +- .../shared/arithmetic_exception_in_coerce.rb | 2 +- spec/ruby/core/rational/to_f_spec.rb | 8 +- spec/ruby/core/rational/to_i_spec.rb | 6 +- spec/ruby/core/rational/to_r_spec.rb | 8 +- spec/ruby/core/rational/truncate_spec.rb | 20 +- spec/ruby/core/rational/zero_spec.rb | 6 +- .../core/refinement/append_features_spec.rb | 4 +- .../core/refinement/extend_object_spec.rb | 4 +- .../core/refinement/import_methods_spec.rb | 16 +- spec/ruby/core/refinement/include_spec.rb | 2 +- .../core/refinement/prepend_features_spec.rb | 4 +- spec/ruby/core/refinement/prepend_spec.rb | 2 +- spec/ruby/core/regexp/case_compare_spec.rb | 14 +- spec/ruby/core/regexp/encoding_spec.rb | 2 +- spec/ruby/core/regexp/fixed_encoding_spec.rb | 16 +- spec/ruby/core/regexp/initialize_spec.rb | 10 +- spec/ruby/core/regexp/last_match_spec.rb | 6 +- spec/ruby/core/regexp/match_spec.rb | 38 +-- spec/ruby/core/regexp/named_captures_spec.rb | 4 +- spec/ruby/core/regexp/names_spec.rb | 4 +- spec/ruby/core/regexp/options_spec.rb | 6 +- spec/ruby/core/regexp/shared/new.rb | 42 ++-- spec/ruby/core/regexp/shared/quote.rb | 4 +- spec/ruby/core/regexp/source_spec.rb | 4 +- spec/ruby/core/regexp/timeout_spec.rb | 4 +- spec/ruby/core/regexp/try_convert_spec.rb | 2 +- spec/ruby/core/regexp/union_spec.rb | 28 +-- spec/ruby/core/set/add_spec.rb | 8 +- spec/ruby/core/set/classify_spec.rb | 2 +- spec/ruby/core/set/clear_spec.rb | 4 +- .../ruby/core/set/compare_by_identity_spec.rb | 16 +- spec/ruby/core/set/comparison_spec.rb | 4 +- spec/ruby/core/set/constructor_spec.rb | 10 +- spec/ruby/core/set/delete_if_spec.rb | 18 +- spec/ruby/core/set/delete_spec.rb | 12 +- spec/ruby/core/set/disjoint_spec.rb | 4 +- spec/ruby/core/set/divide_spec.rb | 8 +- spec/ruby/core/set/each_spec.rb | 4 +- spec/ruby/core/set/empty_spec.rb | 6 +- spec/ruby/core/set/eql_spec.rb | 14 +- spec/ruby/core/set/exclusion_spec.rb | 4 +- spec/ruby/core/set/flatten_merge_spec.rb | 4 +- spec/ruby/core/set/flatten_spec.rb | 10 +- spec/ruby/core/set/initialize_spec.rb | 64 +++-- spec/ruby/core/set/intersect_spec.rb | 4 +- spec/ruby/core/set/keep_if_spec.rb | 18 +- spec/ruby/core/set/merge_spec.rb | 8 +- spec/ruby/core/set/proper_subset_spec.rb | 34 +-- spec/ruby/core/set/proper_superset_spec.rb | 36 +-- spec/ruby/core/set/reject_spec.rb | 20 +- spec/ruby/core/set/replace_spec.rb | 2 +- spec/ruby/core/set/shared/add.rb | 4 +- spec/ruby/core/set/shared/collect.rb | 2 +- spec/ruby/core/set/shared/difference.rb | 4 +- spec/ruby/core/set/shared/include.rb | 4 +- spec/ruby/core/set/shared/inspect.rb | 20 +- spec/ruby/core/set/shared/intersection.rb | 4 +- spec/ruby/core/set/shared/select.rb | 20 +- spec/ruby/core/set/shared/union.rb | 4 +- .../ruby/core/set/sortedset/sortedset_spec.rb | 2 +- spec/ruby/core/set/subset_spec.rb | 34 +-- spec/ruby/core/set/superset_spec.rb | 36 +-- spec/ruby/core/signal/signame_spec.rb | 4 +- spec/ruby/core/signal/trap_spec.rb | 40 ++-- spec/ruby/core/string/allocate_spec.rb | 2 +- spec/ruby/core/string/append_as_bytes_spec.rb | 4 +- spec/ruby/core/string/append_spec.rb | 4 +- spec/ruby/core/string/ascii_only_spec.rb | 30 +-- spec/ruby/core/string/b_spec.rb | 2 +- spec/ruby/core/string/byteindex_spec.rb | 4 +- spec/ruby/core/string/byterindex_spec.rb | 4 +- spec/ruby/core/string/bytes_spec.rb | 6 +- spec/ruby/core/string/bytesplice_spec.rb | 66 +++--- spec/ruby/core/string/capitalize_spec.rb | 28 +-- spec/ruby/core/string/casecmp_spec.rb | 10 +- spec/ruby/core/string/center_spec.rb | 34 +-- spec/ruby/core/string/chilled_string_spec.rb | 4 +- spec/ruby/core/string/chomp_spec.rb | 40 ++-- spec/ruby/core/string/chop_spec.rb | 12 +- spec/ruby/core/string/chr_spec.rb | 4 +- spec/ruby/core/string/clear_spec.rb | 6 +- spec/ruby/core/string/clone_spec.rb | 4 +- spec/ruby/core/string/codepoints_spec.rb | 4 +- spec/ruby/core/string/comparison_spec.rb | 4 +- spec/ruby/core/string/concat_spec.rb | 2 +- spec/ruby/core/string/count_spec.rb | 12 +- spec/ruby/core/string/crypt_spec.rb | 30 +-- spec/ruby/core/string/delete_prefix_spec.rb | 16 +- spec/ruby/core/string/delete_spec.rb | 22 +- spec/ruby/core/string/delete_suffix_spec.rb | 16 +- spec/ruby/core/string/downcase_spec.rb | 26 +- spec/ruby/core/string/dump_spec.rb | 2 +- spec/ruby/core/string/dup_spec.rb | 6 +- spec/ruby/core/string/each_byte_spec.rb | 4 +- spec/ruby/core/string/element_set_spec.rb | 86 +++---- spec/ruby/core/string/encode_spec.rb | 36 +-- spec/ruby/core/string/encoding_spec.rb | 12 +- spec/ruby/core/string/eql_spec.rb | 8 +- spec/ruby/core/string/force_encoding_spec.rb | 10 +- spec/ruby/core/string/freeze_spec.rb | 4 +- spec/ruby/core/string/getbyte_spec.rb | 12 +- spec/ruby/core/string/gsub_spec.rb | 54 ++--- spec/ruby/core/string/include_spec.rb | 8 +- spec/ruby/core/string/index_spec.rb | 16 +- spec/ruby/core/string/initialize_spec.rb | 4 +- spec/ruby/core/string/insert_spec.rb | 16 +- spec/ruby/core/string/inspect_spec.rb | 2 +- spec/ruby/core/string/ljust_spec.rb | 32 +-- spec/ruby/core/string/lstrip_spec.rb | 16 +- spec/ruby/core/string/match_spec.rb | 20 +- spec/ruby/core/string/modulo_spec.rb | 144 +++++------ spec/ruby/core/string/new_spec.rb | 10 +- spec/ruby/core/string/ord_spec.rb | 6 +- spec/ruby/core/string/partition_spec.rb | 4 +- spec/ruby/core/string/plus_spec.rb | 18 +- spec/ruby/core/string/prepend_spec.rb | 12 +- spec/ruby/core/string/reverse_spec.rb | 18 +- spec/ruby/core/string/rindex_spec.rb | 16 +- spec/ruby/core/string/rjust_spec.rb | 32 +-- spec/ruby/core/string/rpartition_spec.rb | 4 +- spec/ruby/core/string/rstrip_spec.rb | 16 +- spec/ruby/core/string/scan_spec.rb | 10 +- spec/ruby/core/string/scrub_spec.rb | 18 +- spec/ruby/core/string/setbyte_spec.rb | 16 +- .../core/string/shared/byte_index_common.rb | 20 +- spec/ruby/core/string/shared/chars.rb | 4 +- spec/ruby/core/string/shared/codepoints.rb | 14 +- spec/ruby/core/string/shared/concat.rb | 36 +-- spec/ruby/core/string/shared/dedup.rb | 24 +- .../string/shared/each_char_without_block.rb | 2 +- .../shared/each_codepoint_without_block.rb | 8 +- spec/ruby/core/string/shared/each_line.rb | 10 +- .../string/shared/each_line_without_block.rb | 2 +- spec/ruby/core/string/shared/encode.rb | 38 +-- spec/ruby/core/string/shared/eql.rb | 16 +- spec/ruby/core/string/shared/equal_value.rb | 10 +- .../core/string/shared/grapheme_clusters.rb | 2 +- spec/ruby/core/string/shared/partition.rb | 6 +- spec/ruby/core/string/shared/replace.rb | 14 +- spec/ruby/core/string/shared/slice.rb | 86 +++---- spec/ruby/core/string/shared/strip.rb | 6 +- spec/ruby/core/string/shared/succ.rb | 12 +- spec/ruby/core/string/shared/to_s.rb | 4 +- spec/ruby/core/string/shared/to_sym.rb | 34 +-- spec/ruby/core/string/slice_spec.rb | 60 ++--- spec/ruby/core/string/split_spec.rb | 34 +-- spec/ruby/core/string/squeeze_spec.rb | 22 +- spec/ruby/core/string/strip_spec.rb | 8 +- spec/ruby/core/string/sub_spec.rb | 42 ++-- spec/ruby/core/string/swapcase_spec.rb | 28 +-- spec/ruby/core/string/to_c_spec.rb | 2 +- spec/ruby/core/string/to_f_spec.rb | 2 +- spec/ruby/core/string/to_i_spec.rb | 18 +- spec/ruby/core/string/to_r_spec.rb | 2 +- spec/ruby/core/string/tr_s_spec.rb | 8 +- spec/ruby/core/string/tr_spec.rb | 12 +- spec/ruby/core/string/try_convert_spec.rb | 14 +- spec/ruby/core/string/undump_spec.rb | 36 +-- .../core/string/unicode_normalize_spec.rb | 8 +- .../core/string/unicode_normalized_spec.rb | 20 +- spec/ruby/core/string/unpack/at_spec.rb | 2 +- spec/ruby/core/string/unpack/b_spec.rb | 4 +- spec/ruby/core/string/unpack/c_spec.rb | 2 +- spec/ruby/core/string/unpack/h_spec.rb | 4 +- spec/ruby/core/string/unpack/m_spec.rb | 2 +- spec/ruby/core/string/unpack/p_spec.rb | 4 +- spec/ruby/core/string/unpack/percent_spec.rb | 2 +- spec/ruby/core/string/unpack/shared/basic.rb | 14 +- spec/ruby/core/string/unpack/shared/float.rb | 16 +- .../ruby/core/string/unpack/shared/integer.rb | 12 +- .../ruby/core/string/unpack/shared/unicode.rb | 2 +- spec/ruby/core/string/unpack/u_spec.rb | 4 +- spec/ruby/core/string/unpack/w_spec.rb | 2 +- spec/ruby/core/string/unpack/x_spec.rb | 6 +- spec/ruby/core/string/unpack1_spec.rb | 6 +- spec/ruby/core/string/unpack_spec.rb | 8 +- spec/ruby/core/string/upcase_spec.rb | 28 +-- spec/ruby/core/string/upto_spec.rb | 10 +- spec/ruby/core/string/valid_encoding_spec.rb | 194 +++++++-------- .../ruby/core/struct/deconstruct_keys_spec.rb | 12 +- spec/ruby/core/struct/dig_spec.rb | 4 +- spec/ruby/core/struct/each_pair_spec.rb | 4 +- spec/ruby/core/struct/each_spec.rb | 2 +- .../core/struct/element_reference_spec.rb | 14 +- spec/ruby/core/struct/element_set_spec.rb | 10 +- spec/ruby/core/struct/eql_spec.rb | 2 +- spec/ruby/core/struct/hash_spec.rb | 4 +- spec/ruby/core/struct/initialize_spec.rb | 2 +- .../core/struct/instance_variable_get_spec.rb | 2 +- spec/ruby/core/struct/keyword_init_spec.rb | 16 +- spec/ruby/core/struct/new_spec.rb | 62 ++--- spec/ruby/core/struct/shared/select.rb | 6 +- spec/ruby/core/struct/struct_spec.rb | 4 +- spec/ruby/core/struct/to_h_spec.rb | 8 +- spec/ruby/core/struct/values_at_spec.rb | 8 +- spec/ruby/core/symbol/all_symbols_spec.rb | 8 +- spec/ruby/core/symbol/capitalize_spec.rb | 2 +- spec/ruby/core/symbol/casecmp_spec.rb | 6 +- spec/ruby/core/symbol/comparison_spec.rb | 6 +- spec/ruby/core/symbol/downcase_spec.rb | 2 +- spec/ruby/core/symbol/dup_spec.rb | 2 +- spec/ruby/core/symbol/empty_spec.rb | 4 +- spec/ruby/core/symbol/intern_spec.rb | 2 +- spec/ruby/core/symbol/match_spec.rb | 18 +- spec/ruby/core/symbol/shared/slice.rb | 58 ++--- spec/ruby/core/symbol/swapcase_spec.rb | 2 +- spec/ruby/core/symbol/symbol_spec.rb | 4 +- spec/ruby/core/symbol/to_proc_spec.rb | 12 +- spec/ruby/core/symbol/upcase_spec.rb | 2 +- .../core/thread/abort_on_exception_spec.rb | 8 +- spec/ruby/core/thread/allocate_spec.rb | 2 +- .../backtrace/location/absolute_path_spec.rb | 2 +- .../thread/backtrace/location/inspect_spec.rb | 2 +- .../thread/backtrace/location/label_spec.rb | 2 +- .../thread/backtrace/location/to_s_spec.rb | 2 +- .../core/thread/backtrace_locations_spec.rb | 12 +- spec/ruby/core/thread/backtrace_spec.rb | 4 +- spec/ruby/core/thread/current_spec.rb | 10 +- .../core/thread/each_caller_location_spec.rb | 8 +- .../core/thread/element_reference_spec.rb | 4 +- spec/ruby/core/thread/element_set_spec.rb | 8 +- spec/ruby/core/thread/exit_spec.rb | 2 +- spec/ruby/core/thread/fetch_spec.rb | 6 +- spec/ruby/core/thread/fixtures/classes.rb | 2 +- .../ruby/core/thread/handle_interrupt_spec.rb | 6 +- spec/ruby/core/thread/initialize_spec.rb | 2 +- spec/ruby/core/thread/join_spec.rb | 20 +- spec/ruby/core/thread/key_spec.rb | 16 +- spec/ruby/core/thread/keys_spec.rb | 12 +- spec/ruby/core/thread/kill_spec.rb | 2 +- spec/ruby/core/thread/list_spec.rb | 12 +- spec/ruby/core/thread/name_spec.rb | 2 +- .../ruby/core/thread/native_thread_id_spec.rb | 4 +- spec/ruby/core/thread/new_spec.rb | 4 +- .../core/thread/pending_interrupt_spec.rb | 2 +- spec/ruby/core/thread/priority_spec.rb | 8 +- spec/ruby/core/thread/raise_spec.rb | 34 +-- .../core/thread/report_on_exception_spec.rb | 12 +- spec/ruby/core/thread/shared/exit.rb | 6 +- spec/ruby/core/thread/shared/start.rb | 8 +- spec/ruby/core/thread/shared/to_s.rb | 20 +- spec/ruby/core/thread/shared/wakeup.rb | 2 +- .../core/thread/thread_variable_get_spec.rb | 12 +- .../core/thread/thread_variable_set_spec.rb | 10 +- spec/ruby/core/thread/thread_variable_spec.rb | 22 +- .../ruby/core/thread/thread_variables_spec.rb | 3 +- spec/ruby/core/thread/value_spec.rb | 2 +- spec/ruby/core/threadgroup/default_spec.rb | 2 +- spec/ruby/core/threadgroup/enclose_spec.rb | 2 +- spec/ruby/core/threadgroup/enclosed_spec.rb | 4 +- spec/ruby/core/threadgroup/list_spec.rb | 4 +- spec/ruby/core/time/_dump_spec.rb | 4 +- spec/ruby/core/time/_load_spec.rb | 2 +- spec/ruby/core/time/at_spec.rb | 54 ++--- spec/ruby/core/time/ceil_spec.rb | 4 +- spec/ruby/core/time/comparison_spec.rb | 2 +- spec/ruby/core/time/deconstruct_keys_spec.rb | 10 +- spec/ruby/core/time/dup_spec.rb | 14 +- spec/ruby/core/time/eql_spec.rb | 16 +- spec/ruby/core/time/floor_spec.rb | 4 +- spec/ruby/core/time/getlocal_spec.rb | 54 ++--- spec/ruby/core/time/hash_spec.rb | 2 +- spec/ruby/core/time/localtime_spec.rb | 42 ++-- spec/ruby/core/time/minus_spec.rb | 14 +- spec/ruby/core/time/new_spec.rb | 160 ++++++------- spec/ruby/core/time/now_spec.rb | 40 ++-- spec/ruby/core/time/plus_spec.rb | 16 +- spec/ruby/core/time/round_spec.rb | 4 +- spec/ruby/core/time/shared/gmtime.rb | 6 +- spec/ruby/core/time/shared/inspect.rb | 2 +- spec/ruby/core/time/shared/now.rb | 4 +- spec/ruby/core/time/shared/time_params.rb | 34 +-- spec/ruby/core/time/strftime_spec.rb | 2 +- spec/ruby/core/time/subsec_spec.rb | 12 +- spec/ruby/core/time/to_r_spec.rb | 4 +- spec/ruby/core/time/zone_spec.rb | 4 +- .../core/tracepoint/allow_reentry_spec.rb | 2 +- spec/ruby/core/tracepoint/binding_spec.rb | 2 +- .../core/tracepoint/defined_class_spec.rb | 10 +- spec/ruby/core/tracepoint/enable_spec.rb | 28 +-- spec/ruby/core/tracepoint/event_spec.rb | 6 +- spec/ruby/core/tracepoint/lineno_spec.rb | 2 +- spec/ruby/core/tracepoint/method_id_spec.rb | 2 +- spec/ruby/core/tracepoint/new_spec.rb | 22 +- .../core/tracepoint/raised_exception_spec.rb | 4 +- spec/ruby/core/tracepoint/self_spec.rb | 4 +- spec/ruby/core/true/dup_spec.rb | 2 +- spec/ruby/core/true/singleton_method_spec.rb | 4 +- spec/ruby/core/true/to_s_spec.rb | 2 +- spec/ruby/core/true/trueclass_spec.rb | 4 +- .../ruby/core/unboundmethod/bind_call_spec.rb | 4 +- spec/ruby/core/unboundmethod/bind_spec.rb | 16 +- .../core/unboundmethod/equal_value_spec.rb | 4 +- .../core/unboundmethod/fixtures/classes.rb | 1 + .../core/unboundmethod/original_name_spec.rb | 21 ++ spec/ruby/core/unboundmethod/shared/dup.rb | 2 +- spec/ruby/core/unboundmethod/shared/to_s.rb | 4 +- .../unboundmethod/source_location_spec.rb | 4 +- .../core/warning/element_reference_spec.rb | 8 +- spec/ruby/core/warning/element_set_spec.rb | 8 +- spec/ruby/core/warning/warn_spec.rb | 2 +- spec/ruby/language/BEGIN_spec.rb | 2 +- spec/ruby/language/alias_spec.rb | 14 +- spec/ruby/language/and_spec.rb | 16 +- spec/ruby/language/array_spec.rb | 8 +- spec/ruby/language/assignments_spec.rb | 10 +- spec/ruby/language/block_spec.rb | 86 ++++--- spec/ruby/language/break_spec.rb | 20 +- spec/ruby/language/case_spec.rb | 16 +- spec/ruby/language/class_spec.rb | 65 ++--- spec/ruby/language/class_variable_spec.rb | 22 +- spec/ruby/language/constants_spec.rb | 84 +++---- spec/ruby/language/def_spec.rb | 114 ++++----- spec/ruby/language/defined_spec.rb | 210 ++++++++-------- spec/ruby/language/delegation_spec.rb | 6 +- spec/ruby/language/encoding_spec.rb | 4 +- spec/ruby/language/ensure_spec.rb | 16 +- spec/ruby/language/file_spec.rb | 2 +- spec/ruby/language/for_spec.rb | 2 +- spec/ruby/language/hash_spec.rb | 24 +- spec/ruby/language/heredoc_spec.rb | 4 +- spec/ruby/language/if_spec.rb | 2 +- spec/ruby/language/it_parameter_spec.rb | 26 +- spec/ruby/language/keyword_arguments_spec.rb | 14 +- spec/ruby/language/lambda_spec.rb | 114 ++++----- spec/ruby/language/line_spec.rb | 2 +- spec/ruby/language/loop_spec.rb | 2 +- spec/ruby/language/metaclass_spec.rb | 22 +- spec/ruby/language/method_spec.rb | 126 +++++----- spec/ruby/language/module_spec.rb | 24 +- spec/ruby/language/next_spec.rb | 4 +- spec/ruby/language/not_spec.rb | 32 +-- .../ruby/language/numbered_parameters_spec.rb | 28 +-- spec/ruby/language/numbers_spec.rb | 6 +- .../language/optional_assignments_spec.rb | 10 +- spec/ruby/language/or_spec.rb | 32 +-- spec/ruby/language/pattern_matching_spec.rb | 30 +-- spec/ruby/language/precedence_spec.rb | 16 +- spec/ruby/language/predefined_spec.rb | 202 ++++++++-------- spec/ruby/language/private_spec.rb | 20 +- spec/ruby/language/proc_spec.rb | 34 +-- spec/ruby/language/redo_spec.rb | 2 +- spec/ruby/language/regexp/anchors_spec.rb | 58 ++--- .../language/regexp/back-references_spec.rb | 54 ++--- .../language/regexp/character_classes_spec.rb | 224 +++++++++--------- spec/ruby/language/regexp/encoding_spec.rb | 12 +- spec/ruby/language/regexp/escapes_spec.rb | 10 +- spec/ruby/language/regexp/grouping_spec.rb | 6 +- .../language/regexp/interpolation_spec.rb | 6 +- spec/ruby/language/regexp/modifiers_spec.rb | 40 ++-- spec/ruby/language/regexp/repetition_spec.rb | 2 +- spec/ruby/language/regexp_spec.rb | 24 +- spec/ruby/language/rescue_spec.rb | 34 +-- spec/ruby/language/reserved_keywords.rb | 12 +- spec/ruby/language/retry_spec.rb | 8 +- spec/ruby/language/return_spec.rb | 14 +- spec/ruby/language/safe_navigator_spec.rb | 8 +- spec/ruby/language/send_spec.rb | 53 +++-- spec/ruby/language/shared/__FILE__.rb | 4 +- spec/ruby/language/shared/__LINE__.rb | 2 +- spec/ruby/language/singleton_class_spec.rb | 84 +++---- spec/ruby/language/string_spec.rb | 6 +- spec/ruby/language/super_spec.rb | 8 +- spec/ruby/language/symbol_spec.rb | 22 +- spec/ruby/language/throw_spec.rb | 10 +- spec/ruby/language/undef_spec.rb | 14 +- spec/ruby/language/variables_spec.rb | 40 ++-- spec/ruby/language/while_spec.rb | 16 +- spec/ruby/language/yield_spec.rb | 26 +- spec/ruby/library/English/English_spec.rb | 52 ++-- spec/ruby/library/English/alias_spec.rb | 6 +- .../library/base64/strict_decode64_spec.rb | 8 +- .../library/bigdecimal/BigDecimal_spec.rb | 26 +- spec/ruby/library/bigdecimal/add_spec.rb | 8 +- spec/ruby/library/bigdecimal/ceil_spec.rb | 6 +- .../ruby/library/bigdecimal/constants_spec.rb | 6 +- spec/ruby/library/bigdecimal/core_spec.rb | 12 +- spec/ruby/library/bigdecimal/div_spec.rb | 28 +-- spec/ruby/library/bigdecimal/divmod_spec.rb | 14 +- spec/ruby/library/bigdecimal/fix_spec.rb | 2 +- spec/ruby/library/bigdecimal/floor_spec.rb | 6 +- spec/ruby/library/bigdecimal/gt_spec.rb | 12 +- spec/ruby/library/bigdecimal/gte_spec.rb | 12 +- spec/ruby/library/bigdecimal/lt_spec.rb | 12 +- spec/ruby/library/bigdecimal/lte_spec.rb | 12 +- spec/ruby/library/bigdecimal/mode_spec.rb | 10 +- spec/ruby/library/bigdecimal/nonzero_spec.rb | 10 +- .../ruby/library/bigdecimal/remainder_spec.rb | 6 +- spec/ruby/library/bigdecimal/round_spec.rb | 14 +- spec/ruby/library/bigdecimal/shared/clone.rb | 2 +- spec/ruby/library/bigdecimal/shared/modulo.rb | 8 +- spec/ruby/library/bigdecimal/shared/to_int.rb | 4 +- spec/ruby/library/bigdecimal/sqrt_spec.rb | 18 +- spec/ruby/library/bigdecimal/to_f_spec.rb | 6 +- spec/ruby/library/bigdecimal/to_r_spec.rb | 14 +- spec/ruby/library/bigdecimal/to_s_spec.rb | 6 +- spec/ruby/library/bigdecimal/truncate_spec.rb | 6 +- spec/ruby/library/bigdecimal/util_spec.rb | 2 +- spec/ruby/library/cgi/cookie/domain_spec.rb | 2 +- spec/ruby/library/cgi/cookie/expires_spec.rb | 2 +- .../library/cgi/cookie/initialize_spec.rb | 14 +- spec/ruby/library/cgi/cookie/secure_spec.rb | 20 +- spec/ruby/library/cgi/cookie/value_spec.rb | 2 +- .../library/cgi/escapeURIComponent_spec.rb | 2 +- spec/ruby/library/cgi/initialize_spec.rb | 66 +++--- spec/ruby/library/cgi/out_spec.rb | 2 +- .../cgi/queryextension/content_length_spec.rb | 4 +- .../queryextension/element_reference_spec.rb | 2 +- .../cgi/queryextension/multipart_spec.rb | 2 +- .../cgi/queryextension/server_port_spec.rb | 4 +- .../cgi/queryextension/shared/has_key.rb | 6 +- spec/ruby/library/cgi/shared/http_header.rb | 10 +- .../library/cgi/unescapeURIComponent_spec.rb | 8 +- spec/ruby/library/coverage/result_spec.rb | 4 +- spec/ruby/library/coverage/start_spec.rb | 6 +- spec/ruby/library/coverage/supported_spec.rb | 6 +- spec/ruby/library/csv/generate_spec.rb | 2 +- spec/ruby/library/csv/parse_spec.rb | 4 +- spec/ruby/library/csv/readlines_spec.rb | 2 +- spec/ruby/library/date/add_month_spec.rb | 8 +- spec/ruby/library/date/add_spec.rb | 8 +- spec/ruby/library/date/constants_spec.rb | 4 +- .../library/date/deconstruct_keys_spec.rb | 10 +- spec/ruby/library/date/eql_spec.rb | 4 +- spec/ruby/library/date/friday_spec.rb | 4 +- spec/ruby/library/date/gregorian_leap_spec.rb | 10 +- spec/ruby/library/date/gregorian_spec.rb | 6 +- spec/ruby/library/date/iso8601_spec.rb | 8 +- spec/ruby/library/date/julian_leap_spec.rb | 10 +- spec/ruby/library/date/julian_spec.rb | 4 +- spec/ruby/library/date/minus_month_spec.rb | 8 +- spec/ruby/library/date/minus_spec.rb | 6 +- spec/ruby/library/date/monday_spec.rb | 2 +- spec/ruby/library/date/parse_spec.rb | 6 +- spec/ruby/library/date/plus_spec.rb | 2 +- spec/ruby/library/date/saturday_spec.rb | 2 +- spec/ruby/library/date/shared/civil.rb | 16 +- spec/ruby/library/date/shared/commercial.rb | 18 +- spec/ruby/library/date/shared/valid_civil.rb | 16 +- .../library/date/shared/valid_commercial.rb | 24 +- spec/ruby/library/date/shared/valid_jd.rb | 14 +- spec/ruby/library/date/sunday_spec.rb | 2 +- spec/ruby/library/date/thursday_spec.rb | 2 +- spec/ruby/library/date/today_spec.rb | 2 +- spec/ruby/library/date/tuesday_spec.rb | 2 +- spec/ruby/library/date/wednesday_spec.rb | 2 +- .../library/datetime/deconstruct_keys_spec.rb | 10 +- spec/ruby/library/datetime/hour_spec.rb | 10 +- spec/ruby/library/datetime/new_spec.rb | 2 +- spec/ruby/library/datetime/now_spec.rb | 2 +- spec/ruby/library/datetime/parse_spec.rb | 12 +- spec/ruby/library/datetime/rfc2822_spec.rb | 2 +- spec/ruby/library/datetime/shared/min.rb | 10 +- spec/ruby/library/datetime/shared/sec.rb | 6 +- spec/ruby/library/datetime/to_date_spec.rb | 2 +- spec/ruby/library/datetime/to_s_spec.rb | 2 +- spec/ruby/library/datetime/to_time_spec.rb | 2 +- .../delegate_class/instance_method_spec.rb | 14 +- .../delegate_class/instance_methods_spec.rb | 12 +- .../private_instance_methods_spec.rb | 12 +- .../protected_instance_methods_spec.rb | 12 +- .../public_instance_methods_spec.rb | 10 +- .../library/delegate/delegator/eql_spec.rb | 8 +- .../library/delegate/delegator/equal_spec.rb | 6 +- .../delegate/delegator/equal_value_spec.rb | 6 +- .../library/delegate/delegator/frozen_spec.rb | 14 +- .../delegate/delegator/marshal_spec.rb | 2 +- .../library/delegate/delegator/method_spec.rb | 18 +- .../delegate/delegator/methods_spec.rb | 14 +- .../delegate/delegator/not_equal_spec.rb | 6 +- .../delegator/private_methods_spec.rb | 8 +- .../delegator/protected_methods_spec.rb | 4 +- .../delegate/delegator/public_methods_spec.rb | 4 +- .../library/delegate/delegator/send_spec.rb | 8 +- .../library/delegate/delegator/tap_spec.rb | 2 +- spec/ruby/library/digest/bubblebabble_spec.rb | 6 +- spec/ruby/library/digest/hexencode_spec.rb | 4 +- .../library/digest/instance/shared/update.rb | 2 +- spec/ruby/library/digest/md5/file_spec.rb | 8 +- spec/ruby/library/digest/sha1/file_spec.rb | 8 +- spec/ruby/library/digest/sha256/file_spec.rb | 8 +- spec/ruby/library/digest/sha384/file_spec.rb | 8 +- spec/ruby/library/digest/sha512/file_spec.rb | 8 +- spec/ruby/library/erb/filename_spec.rb | 4 +- spec/ruby/library/erb/new_spec.rb | 4 +- spec/ruby/library/erb/result_spec.rb | 4 +- spec/ruby/library/erb/run_spec.rb | 4 +- spec/ruby/library/etc/confstr_spec.rb | 4 +- spec/ruby/library/etc/getgrgid_spec.rb | 8 +- spec/ruby/library/etc/getgrnam_spec.rb | 2 +- spec/ruby/library/etc/getlogin_spec.rb | 4 +- spec/ruby/library/etc/getpwnam_spec.rb | 2 +- spec/ruby/library/etc/getpwuid_spec.rb | 2 +- spec/ruby/library/etc/group_spec.rb | 4 +- spec/ruby/library/etc/nprocessors_spec.rb | 2 +- spec/ruby/library/etc/passwd_spec.rb | 2 +- spec/ruby/library/etc/sysconf_spec.rb | 2 +- spec/ruby/library/etc/sysconfdir_spec.rb | 2 +- spec/ruby/library/etc/systmpdir_spec.rb | 2 +- spec/ruby/library/etc/uname_spec.rb | 2 +- spec/ruby/library/expect/expect_spec.rb | 4 +- .../library/fiddle/handle/initialize_spec.rb | 2 +- spec/ruby/library/find/find_spec.rb | 2 +- .../library/getoptlong/error_message_spec.rb | 2 +- spec/ruby/library/getoptlong/ordering_spec.rb | 4 +- .../library/getoptlong/set_options_spec.rb | 14 +- spec/ruby/library/getoptlong/shared/get.rb | 2 +- spec/ruby/library/io-wait/wait_spec.rb | 12 +- spec/ruby/library/ipaddr/new_spec.rb | 8 +- spec/ruby/library/ipaddr/operator_spec.rb | 16 +- spec/ruby/library/ipaddr/reverse_spec.rb | 4 +- spec/ruby/library/logger/device/new_spec.rb | 8 +- spec/ruby/library/logger/logger/add_spec.rb | 6 +- .../logger/logger/datetime_format_spec.rb | 2 +- spec/ruby/library/logger/logger/new_spec.rb | 10 +- .../library/logger/logger/unknown_spec.rb | 2 +- .../ruby/library/matrix/antisymmetric_spec.rb | 8 +- spec/ruby/library/matrix/build_spec.rb | 20 +- spec/ruby/library/matrix/clone_spec.rb | 8 +- spec/ruby/library/matrix/coerce_spec.rb | 2 +- spec/ruby/library/matrix/column_spec.rb | 6 +- .../ruby/library/matrix/column_vector_spec.rb | 6 +- .../library/matrix/column_vectors_spec.rb | 4 +- spec/ruby/library/matrix/columns_spec.rb | 4 +- spec/ruby/library/matrix/constructor_spec.rb | 20 +- spec/ruby/library/matrix/diagonal_spec.rb | 16 +- spec/ruby/library/matrix/divide_spec.rb | 16 +- spec/ruby/library/matrix/each_spec.rb | 10 +- .../library/matrix/each_with_index_spec.rb | 10 +- .../initialize_spec.rb | 6 +- .../library/matrix/element_reference_spec.rb | 4 +- spec/ruby/library/matrix/empty_spec.rb | 22 +- spec/ruby/library/matrix/eql_spec.rb | 2 +- spec/ruby/library/matrix/exponent_spec.rb | 10 +- spec/ruby/library/matrix/find_index_spec.rb | 16 +- spec/ruby/library/matrix/hash_spec.rb | 2 +- spec/ruby/library/matrix/hermitian_spec.rb | 12 +- .../library/matrix/lower_triangular_spec.rb | 22 +- .../lup_decomposition/determinant_spec.rb | 2 +- .../lup_decomposition/initialize_spec.rb | 4 +- .../matrix/lup_decomposition/l_spec.rb | 2 +- .../matrix/lup_decomposition/p_spec.rb | 2 +- .../matrix/lup_decomposition/solve_spec.rb | 6 +- .../matrix/lup_decomposition/to_a_spec.rb | 4 +- .../matrix/lup_decomposition/u_spec.rb | 2 +- spec/ruby/library/matrix/minor_spec.rb | 2 +- spec/ruby/library/matrix/minus_spec.rb | 20 +- spec/ruby/library/matrix/multiply_spec.rb | 14 +- spec/ruby/library/matrix/new_spec.rb | 2 +- spec/ruby/library/matrix/normal_spec.rb | 2 +- spec/ruby/library/matrix/orthogonal_spec.rb | 2 +- spec/ruby/library/matrix/permutation_spec.rb | 14 +- spec/ruby/library/matrix/plus_spec.rb | 20 +- spec/ruby/library/matrix/real_spec.rb | 12 +- spec/ruby/library/matrix/regular_spec.rb | 12 +- spec/ruby/library/matrix/round_spec.rb | 2 +- spec/ruby/library/matrix/row_spec.rb | 6 +- spec/ruby/library/matrix/row_vector_spec.rb | 4 +- spec/ruby/library/matrix/row_vectors_spec.rb | 4 +- spec/ruby/library/matrix/rows_spec.rb | 8 +- spec/ruby/library/matrix/scalar_spec.rb | 4 +- spec/ruby/library/matrix/shared/collect.rb | 6 +- spec/ruby/library/matrix/shared/conjugate.rb | 2 +- .../ruby/library/matrix/shared/determinant.rb | 4 +- .../ruby/library/matrix/shared/equal_value.rb | 20 +- spec/ruby/library/matrix/shared/identity.rb | 4 +- spec/ruby/library/matrix/shared/imaginary.rb | 2 +- spec/ruby/library/matrix/shared/inverse.rb | 6 +- .../ruby/library/matrix/shared/rectangular.rb | 2 +- spec/ruby/library/matrix/shared/trace.rb | 2 +- spec/ruby/library/matrix/shared/transpose.rb | 2 +- spec/ruby/library/matrix/singular_spec.rb | 12 +- spec/ruby/library/matrix/square_spec.rb | 16 +- spec/ruby/library/matrix/symmetric_spec.rb | 8 +- spec/ruby/library/matrix/unitary_spec.rb | 2 +- .../library/matrix/upper_triangular_spec.rb | 22 +- .../matrix/vector/cross_product_spec.rb | 2 +- spec/ruby/library/matrix/vector/each2_spec.rb | 12 +- spec/ruby/library/matrix/vector/eql_spec.rb | 4 +- .../matrix/vector/inner_product_spec.rb | 2 +- .../library/matrix/vector/normalize_spec.rb | 4 +- spec/ruby/library/matrix/zero_spec.rb | 4 +- spec/ruby/library/monitor/exit_spec.rb | 2 +- .../library/monitor/mon_initialize_spec.rb | 2 +- spec/ruby/library/monitor/synchronize_spec.rb | 4 +- spec/ruby/library/net-ftp/abort_spec.rb | 14 +- spec/ruby/library/net-ftp/acct_spec.rb | 12 +- spec/ruby/library/net-ftp/binary_spec.rb | 8 +- spec/ruby/library/net-ftp/chdir_spec.rb | 28 +-- spec/ruby/library/net-ftp/close_spec.rb | 6 +- spec/ruby/library/net-ftp/closed_spec.rb | 4 +- spec/ruby/library/net-ftp/connect_spec.rb | 10 +- spec/ruby/library/net-ftp/debug_mode_spec.rb | 8 +- spec/ruby/library/net-ftp/delete_spec.rb | 14 +- spec/ruby/library/net-ftp/help_spec.rb | 12 +- spec/ruby/library/net-ftp/initialize_spec.rb | 20 +- spec/ruby/library/net-ftp/login_spec.rb | 42 ++-- spec/ruby/library/net-ftp/mdtm_spec.rb | 4 +- spec/ruby/library/net-ftp/mkdir_spec.rb | 12 +- spec/ruby/library/net-ftp/mtime_spec.rb | 4 +- spec/ruby/library/net-ftp/nlst_spec.rb | 20 +- spec/ruby/library/net-ftp/noop_spec.rb | 6 +- spec/ruby/library/net-ftp/open_spec.rb | 6 +- spec/ruby/library/net-ftp/passive_spec.rb | 8 +- spec/ruby/library/net-ftp/pwd_spec.rb | 10 +- spec/ruby/library/net-ftp/quit_spec.rb | 4 +- spec/ruby/library/net-ftp/rename_spec.rb | 26 +- spec/ruby/library/net-ftp/resume_spec.rb | 8 +- spec/ruby/library/net-ftp/rmdir_spec.rb | 14 +- spec/ruby/library/net-ftp/sendcmd_spec.rb | 12 +- .../library/net-ftp/shared/getbinaryfile.rb | 34 +-- .../library/net-ftp/shared/gettextfile.rb | 22 +- spec/ruby/library/net-ftp/shared/list.rb | 20 +- .../library/net-ftp/shared/putbinaryfile.rb | 38 +-- .../library/net-ftp/shared/puttextfile.rb | 26 +- spec/ruby/library/net-ftp/site_spec.rb | 12 +- spec/ruby/library/net-ftp/size_spec.rb | 10 +- spec/ruby/library/net-ftp/status_spec.rb | 14 +- spec/ruby/library/net-ftp/system_spec.rb | 8 +- spec/ruby/library/net-ftp/voidcmd_spec.rb | 14 +- spec/ruby/library/net-ftp/welcome_spec.rb | 2 +- spec/ruby/library/net-http/http/Proxy_spec.rb | 6 +- spec/ruby/library/net-http/http/copy_spec.rb | 2 +- .../net-http/http/default_port_spec.rb | 2 +- .../ruby/library/net-http/http/delete_spec.rb | 2 +- .../ruby/library/net-http/http/finish_spec.rb | 4 +- spec/ruby/library/net-http/http/get_spec.rb | 2 +- spec/ruby/library/net-http/http/head_spec.rb | 4 +- .../net-http/http/http_default_port_spec.rb | 2 +- .../net-http/http/https_default_port_spec.rb | 2 +- .../library/net-http/http/initialize_spec.rb | 10 +- .../library/net-http/http/inspect_spec.rb | 2 +- spec/ruby/library/net-http/http/lock_spec.rb | 2 +- spec/ruby/library/net-http/http/mkcol_spec.rb | 2 +- spec/ruby/library/net-http/http/move_spec.rb | 2 +- spec/ruby/library/net-http/http/new_spec.rb | 40 ++-- .../ruby/library/net-http/http/newobj_spec.rb | 12 +- .../net-http/http/open_timeout_spec.rb | 8 +- .../library/net-http/http/options_spec.rb | 2 +- spec/ruby/library/net-http/http/port_spec.rb | 2 +- spec/ruby/library/net-http/http/post_spec.rb | 8 +- .../library/net-http/http/propfind_spec.rb | 2 +- .../library/net-http/http/proppatch_spec.rb | 2 +- .../net-http/http/proxy_address_spec.rb | 4 +- .../library/net-http/http/proxy_class_spec.rb | 4 +- .../library/net-http/http/proxy_pass_spec.rb | 8 +- .../library/net-http/http/proxy_port_spec.rb | 12 +- .../library/net-http/http/proxy_user_spec.rb | 8 +- spec/ruby/library/net-http/http/put_spec.rb | 2 +- .../net-http/http/read_timeout_spec.rb | 8 +- .../library/net-http/http/request_spec.rb | 8 +- .../net-http/http/request_types_spec.rb | 56 ++--- .../net-http/http/send_request_spec.rb | 8 +- .../net-http/http/set_debug_output_spec.rb | 2 +- .../net-http/http/shared/request_get.rb | 4 +- .../net-http/http/shared/request_head.rb | 10 +- .../net-http/http/shared/request_post.rb | 4 +- .../net-http/http/shared/request_put.rb | 4 +- .../library/net-http/http/shared/started.rb | 6 +- .../net-http/http/shared/version_1_1.rb | 2 +- .../net-http/http/shared/version_1_2.rb | 2 +- spec/ruby/library/net-http/http/start_spec.rb | 26 +- spec/ruby/library/net-http/http/trace_spec.rb | 2 +- .../ruby/library/net-http/http/unlock_spec.rb | 2 +- .../library/net-http/http/use_ssl_spec.rb | 2 +- .../library/net-http/http/version_1_2_spec.rb | 6 +- .../httpgenericrequest/body_exist_spec.rb | 4 +- .../net-http/httpgenericrequest/body_spec.rb | 4 +- .../httpgenericrequest/body_stream_spec.rb | 8 +- .../net-http/httpgenericrequest/exec_spec.rb | 2 +- .../request_body_permitted_spec.rb | 4 +- .../response_body_permitted_spec.rb | 4 +- .../set_body_internal_spec.rb | 4 +- .../net-http/httpheader/chunked_spec.rb | 8 +- .../httpheader/content_length_spec.rb | 12 +- .../net-http/httpheader/content_range_spec.rb | 8 +- .../net-http/httpheader/content_type_spec.rb | 2 +- .../net-http/httpheader/delete_spec.rb | 8 +- .../httpheader/each_capitalized_name_spec.rb | 2 +- .../net-http/httpheader/each_value_spec.rb | 2 +- .../httpheader/element_reference_spec.rb | 4 +- .../net-http/httpheader/element_set_spec.rb | 6 +- .../library/net-http/httpheader/fetch_spec.rb | 2 +- .../net-http/httpheader/get_fields_spec.rb | 4 +- .../library/net-http/httpheader/key_spec.rb | 8 +- .../net-http/httpheader/main_type_spec.rb | 2 +- .../net-http/httpheader/range_length_spec.rb | 12 +- .../library/net-http/httpheader/range_spec.rb | 10 +- .../httpheader/shared/each_capitalized.rb | 2 +- .../net-http/httpheader/shared/each_header.rb | 2 +- .../net-http/httpheader/shared/each_name.rb | 2 +- .../net-http/httpheader/shared/set_range.rb | 16 +- .../net-http/httpheader/shared/size.rb | 8 +- .../net-http/httpheader/sub_type_spec.rb | 6 +- .../net-http/httpheader/to_hash_spec.rb | 2 +- .../net-http/httprequest/initialize_spec.rb | 4 +- .../net-http/httpresponse/error_spec.rb | 12 +- .../net-http/httpresponse/header_spec.rb | 2 +- .../net-http/httpresponse/read_body_spec.rb | 14 +- .../net-http/httpresponse/read_header_spec.rb | 2 +- .../net-http/httpresponse/read_new_spec.rb | 2 +- .../httpresponse/reading_body_spec.rb | 14 +- .../net-http/httpresponse/response_spec.rb | 2 +- .../net-http/httpresponse/shared/body.rb | 2 +- .../net-http/httpresponse/value_spec.rb | 12 +- .../ruby/library/objectspace/dump_all_spec.rb | 4 +- spec/ruby/library/objectspace/dump_spec.rb | 22 +- .../objectspace/memsize_of_all_spec.rb | 4 +- .../library/objectspace/memsize_of_spec.rb | 2 +- .../reachable_objects_from_spec.rb | 12 +- .../trace_object_allocations_spec.rb | 2 +- .../library/observer/notify_observers_spec.rb | 2 +- spec/ruby/library/open3/popen3_spec.rb | 8 +- spec/ruby/library/openssl/cipher_spec.rb | 2 +- .../library/openssl/digest/initialize_spec.rb | 6 +- .../library/openssl/digest/shared/update.rb | 8 +- .../fixed_length_secure_compare_spec.rb | 12 +- .../library/openssl/kdf/pbkdf2_hmac_spec.rb | 26 +- spec/ruby/library/openssl/kdf/scrypt_spec.rb | 42 ++-- .../openssl/random/shared/random_bytes.rb | 4 +- .../library/openssl/secure_compare_spec.rb | 12 +- .../library/openssl/x509/name/parse_spec.rb | 4 +- .../library/openstruct/delete_field_spec.rb | 6 +- .../library/openstruct/equal_value_spec.rb | 22 +- spec/ruby/library/openstruct/frozen_spec.rb | 12 +- .../library/openstruct/initialize_spec.rb | 2 +- .../library/openstruct/marshal_load_spec.rb | 2 +- .../library/openstruct/method_missing_spec.rb | 6 +- spec/ruby/library/openstruct/new_spec.rb | 4 +- .../ruby/library/openstruct/shared/inspect.rb | 2 +- spec/ruby/library/openstruct/to_h_spec.rb | 10 +- spec/ruby/library/pathname/birthtime_spec.rb | 4 +- spec/ruby/library/pathname/empty_spec.rb | 8 +- spec/ruby/library/pathname/glob_spec.rb | 4 +- spec/ruby/library/pathname/inspect_spec.rb | 2 +- spec/ruby/library/pathname/new_spec.rb | 12 +- spec/ruby/library/pathname/pathname_spec.rb | 4 +- .../ruby/library/pathname/realdirpath_spec.rb | 2 +- spec/ruby/library/pathname/realpath_spec.rb | 2 +- .../pathname/relative_path_from_spec.rb | 4 +- spec/ruby/library/prime/each_spec.rb | 22 +- spec/ruby/library/prime/instance_spec.rb | 8 +- .../prime/integer/prime_division_spec.rb | 2 +- spec/ruby/library/prime/integer/prime_spec.rb | 14 +- .../ruby/library/prime/prime_division_spec.rb | 4 +- spec/ruby/library/prime/prime_spec.rb | 14 +- .../random/formatter/alphanumeric_spec.rb | 4 +- spec/ruby/library/rbconfig/rbconfig_spec.rb | 8 +- .../library/rbconfig/sizeof/limits_spec.rb | 6 +- .../library/rbconfig/sizeof/sizeof_spec.rb | 6 +- .../readline/basic_quote_characters_spec.rb | 2 +- .../basic_word_break_characters_spec.rb | 2 +- .../completer_quote_characters_spec.rb | 2 +- .../completer_word_break_characters_spec.rb | 2 +- .../completion_append_character_spec.rb | 2 +- .../readline/completion_case_fold_spec.rb | 2 +- .../library/readline/completion_proc_spec.rb | 4 +- spec/ruby/library/readline/constants_spec.rb | 4 +- .../readline/emacs_editing_mode_spec.rb | 2 +- .../filename_quote_characters_spec.rb | 2 +- .../library/readline/history/append_spec.rb | 2 +- .../readline/history/delete_at_spec.rb | 4 +- .../history/element_reference_spec.rb | 12 +- .../readline/history/element_set_spec.rb | 4 +- .../library/readline/history/empty_spec.rb | 6 +- .../library/readline/history/history_spec.rb | 2 +- .../ruby/library/readline/history/pop_spec.rb | 2 +- .../library/readline/history/push_spec.rb | 2 +- .../library/readline/history/shift_spec.rb | 2 +- .../library/readline/vi_editing_mode_spec.rb | 2 +- spec/ruby/library/resolv/get_address_spec.rb | 2 +- spec/ruby/library/resolv/get_name_spec.rb | 2 +- .../gem/load_path_insert_index_spec.rb | 2 +- spec/ruby/library/securerandom/base64_spec.rb | 10 +- spec/ruby/library/securerandom/hex_spec.rb | 14 +- .../library/securerandom/random_bytes_spec.rb | 12 +- .../securerandom/random_number_spec.rb | 20 +- .../library/shellwords/shellwords_spec.rb | 4 +- spec/ruby/library/singleton/allocate_spec.rb | 2 +- spec/ruby/library/singleton/clone_spec.rb | 2 +- spec/ruby/library/singleton/dup_spec.rb | 2 +- spec/ruby/library/singleton/instance_spec.rb | 12 +- spec/ruby/library/singleton/load_spec.rb | 13 +- spec/ruby/library/singleton/new_spec.rb | 2 +- .../ruby/library/socket/addrinfo/bind_spec.rb | 8 +- .../library/socket/addrinfo/canonname_spec.rb | 4 +- .../socket/addrinfo/connect_from_spec.rb | 12 +- .../library/socket/addrinfo/connect_spec.rb | 6 +- .../socket/addrinfo/connect_to_spec.rb | 12 +- .../socket/addrinfo/family_addrinfo_spec.rb | 18 +- .../library/socket/addrinfo/foreach_spec.rb | 2 +- .../socket/addrinfo/getaddrinfo_spec.rb | 10 +- .../socket/addrinfo/initialize_spec.rb | 18 +- .../socket/addrinfo/ip_address_spec.rb | 2 +- .../library/socket/addrinfo/ip_port_spec.rb | 2 +- spec/ruby/library/socket/addrinfo/ip_spec.rb | 8 +- .../library/socket/addrinfo/ip_unpack_spec.rb | 2 +- .../socket/addrinfo/ipv4_loopback_spec.rb | 8 +- .../socket/addrinfo/ipv4_multicast_spec.rb | 2 +- .../socket/addrinfo/ipv4_private_spec.rb | 6 +- .../ruby/library/socket/addrinfo/ipv4_spec.rb | 6 +- .../socket/addrinfo/ipv6_loopback_spec.rb | 10 +- .../socket/addrinfo/ipv6_multicast_spec.rb | 6 +- .../ruby/library/socket/addrinfo/ipv6_spec.rb | 6 +- .../socket/addrinfo/ipv6_to_ipv4_spec.rb | 18 +- .../library/socket/addrinfo/listen_spec.rb | 4 +- .../socket/addrinfo/marshal_dump_spec.rb | 4 +- spec/ruby/library/socket/addrinfo/tcp_spec.rb | 2 +- spec/ruby/library/socket/addrinfo/udp_spec.rb | 2 +- .../library/socket/addrinfo/unix_path_spec.rb | 4 +- .../ruby/library/socket/addrinfo/unix_spec.rb | 8 +- .../socket/ancillarydata/cmsg_is_spec.rb | 2 +- .../socket/ancillarydata/initialize_spec.rb | 34 +-- .../library/socket/ancillarydata/int_spec.rb | 4 +- .../socket/ancillarydata/ip_pktinfo_spec.rb | 16 +- .../ancillarydata/ipv6_pktinfo_addr_spec.rb | 2 +- .../socket/ancillarydata/ipv6_pktinfo_spec.rb | 10 +- .../socket/ancillarydata/unix_rights_spec.rb | 8 +- .../socket/basicsocket/close_read_spec.rb | 12 +- .../socket/basicsocket/close_write_spec.rb | 12 +- .../basicsocket/connect_address_spec.rb | 10 +- .../basicsocket/do_not_reverse_lookup_spec.rb | 2 +- .../library/socket/basicsocket/for_fd_spec.rb | 6 +- .../socket/basicsocket/getpeereid_spec.rb | 2 +- .../socket/basicsocket/getpeername_spec.rb | 2 +- .../socket/basicsocket/getsockname_spec.rb | 4 +- .../socket/basicsocket/getsockopt_spec.rb | 12 +- .../socket/basicsocket/recv_nonblock_spec.rb | 18 +- .../library/socket/basicsocket/recv_spec.rb | 10 +- .../basicsocket/recvmsg_nonblock_spec.rb | 30 +-- .../socket/basicsocket/recvmsg_spec.rb | 20 +- .../library/socket/basicsocket/send_spec.rb | 14 +- .../basicsocket/sendmsg_nonblock_spec.rb | 6 +- .../socket/basicsocket/sendmsg_spec.rb | 2 +- .../socket/basicsocket/setsockopt_spec.rb | 32 +-- .../socket/basicsocket/shutdown_spec.rb | 44 ++-- .../socket/constants/constants_spec.rb | 26 +- .../ruby/library/socket/ipsocket/addr_spec.rb | 8 +- .../socket/ipsocket/getaddress_spec.rb | 2 +- .../library/socket/ipsocket/peeraddr_spec.rb | 4 +- .../library/socket/ipsocket/recvfrom_spec.rb | 4 +- spec/ruby/library/socket/option/bool_spec.rb | 4 +- .../library/socket/option/initialize_spec.rb | 18 +- spec/ruby/library/socket/option/int_spec.rb | 6 +- .../ruby/library/socket/option/linger_spec.rb | 18 +- spec/ruby/library/socket/option/new_spec.rb | 6 +- spec/ruby/library/socket/shared/address.rb | 8 +- .../library/socket/shared/pack_sockaddr.rb | 10 +- spec/ruby/library/socket/shared/socketpair.rb | 38 +-- .../library/socket/socket/accept_loop_spec.rb | 8 +- .../socket/socket/accept_nonblock_spec.rb | 24 +- .../ruby/library/socket/socket/accept_spec.rb | 12 +- spec/ruby/library/socket/socket/bind_spec.rb | 28 +-- .../socket/socket/connect_nonblock_spec.rb | 10 +- .../library/socket/socket/connect_spec.rb | 4 +- .../library/socket/socket/getaddrinfo_spec.rb | 62 ++--- .../socket/socket/gethostbyaddr_spec.rb | 30 +-- .../socket/socket/gethostbyname_spec.rb | 10 +- .../library/socket/socket/getifaddrs_spec.rb | 40 ++-- .../library/socket/socket/getnameinfo_spec.rb | 10 +- .../socket/socket/getservbyname_spec.rb | 2 +- .../socket/socket/getservbyport_spec.rb | 2 +- .../library/socket/socket/initialize_spec.rb | 16 +- .../socket/socket/ip_address_list_spec.rb | 10 +- .../ruby/library/socket/socket/listen_spec.rb | 6 +- .../socket/socket/local_address_spec.rb | 2 +- .../socket/socket/recvfrom_nonblock_spec.rb | 12 +- .../library/socket/socket/recvfrom_spec.rb | 8 +- .../socket/socket/remote_address_spec.rb | 2 +- .../library/socket/socket/sysaccept_spec.rb | 10 +- .../socket/socket/tcp_server_loop_spec.rb | 4 +- .../socket/socket/tcp_server_sockets_spec.rb | 8 +- spec/ruby/library/socket/socket/tcp_spec.rb | 6 +- .../socket/socket/udp_server_loop_on_spec.rb | 2 +- .../socket/socket/udp_server_loop_spec.rb | 2 +- .../socket/socket/udp_server_recv_spec.rb | 2 +- .../socket/socket/udp_server_sockets_spec.rb | 8 +- .../socket/socket/unix_server_loop_spec.rb | 4 +- .../socket/socket/unix_server_socket_spec.rb | 6 +- spec/ruby/library/socket/socket/unix_spec.rb | 4 +- .../socket/socket/unpack_sockaddr_in_spec.rb | 4 +- .../socket/socket/unpack_sockaddr_un_spec.rb | 4 +- .../socket/tcpserver/accept_nonblock_spec.rb | 12 +- .../library/socket/tcpserver/accept_spec.rb | 8 +- .../library/socket/tcpserver/gets_spec.rb | 2 +- .../socket/tcpserver/initialize_spec.rb | 12 +- .../library/socket/tcpserver/listen_spec.rb | 2 +- .../ruby/library/socket/tcpserver/new_spec.rb | 28 +-- .../socket/tcpserver/sysaccept_spec.rb | 4 +- .../socket/tcpsocket/gethostbyname_spec.rb | 14 +- .../socket/tcpsocket/initialize_spec.rb | 10 +- .../socket/tcpsocket/local_address_spec.rb | 2 +- .../socket/tcpsocket/remote_address_spec.rb | 2 +- .../library/socket/tcpsocket/shared/new.rb | 22 +- .../library/socket/udpsocket/bind_spec.rb | 4 +- .../socket/udpsocket/initialize_spec.rb | 14 +- .../socket/udpsocket/local_address_spec.rb | 2 +- .../ruby/library/socket/udpsocket/new_spec.rb | 12 +- .../library/socket/udpsocket/open_spec.rb | 2 +- .../udpsocket/recvfrom_nonblock_spec.rb | 8 +- .../socket/udpsocket/remote_address_spec.rb | 2 +- .../library/socket/udpsocket/send_spec.rb | 12 +- .../library/socket/udpsocket/write_spec.rb | 2 +- .../socket/unixserver/accept_nonblock_spec.rb | 8 +- .../library/socket/unixserver/accept_spec.rb | 8 +- .../socket/unixserver/initialize_spec.rb | 6 +- .../socket/unixserver/sysaccept_spec.rb | 4 +- .../library/socket/unixsocket/addr_spec.rb | 2 +- .../socket/unixsocket/initialize_spec.rb | 8 +- .../socket/unixsocket/local_address_spec.rb | 8 +- .../socket/unixsocket/peeraddr_spec.rb | 2 +- .../library/socket/unixsocket/recv_io_spec.rb | 8 +- .../socket/unixsocket/remote_address_spec.rb | 2 +- .../library/socket/unixsocket/send_io_spec.rb | 2 +- .../library/socket/unixsocket/shared/pair.rb | 4 +- spec/ruby/library/stringio/append_spec.rb | 10 +- spec/ruby/library/stringio/binmode_spec.rb | 2 +- spec/ruby/library/stringio/close_read_spec.rb | 6 +- spec/ruby/library/stringio/close_spec.rb | 8 +- .../ruby/library/stringio/close_write_spec.rb | 6 +- .../ruby/library/stringio/closed_read_spec.rb | 4 +- spec/ruby/library/stringio/closed_spec.rb | 6 +- .../library/stringio/closed_write_spec.rb | 4 +- spec/ruby/library/stringio/fcntl_spec.rb | 2 +- spec/ruby/library/stringio/fileno_spec.rb | 2 +- spec/ruby/library/stringio/flush_spec.rb | 2 +- spec/ruby/library/stringio/fsync_spec.rb | 2 +- spec/ruby/library/stringio/gets_spec.rb | 16 +- spec/ruby/library/stringio/initialize_spec.rb | 140 +++++------ spec/ruby/library/stringio/inspect_spec.rb | 2 +- spec/ruby/library/stringio/lineno_spec.rb | 8 +- spec/ruby/library/stringio/open_spec.rb | 120 +++++----- spec/ruby/library/stringio/path_spec.rb | 2 +- spec/ruby/library/stringio/pid_spec.rb | 2 +- spec/ruby/library/stringio/pos_spec.rb | 2 +- spec/ruby/library/stringio/print_spec.rb | 14 +- spec/ruby/library/stringio/printf_spec.rb | 14 +- spec/ruby/library/stringio/putc_spec.rb | 8 +- spec/ruby/library/stringio/puts_spec.rb | 8 +- .../library/stringio/read_nonblock_spec.rb | 2 +- spec/ruby/library/stringio/read_spec.rb | 4 +- spec/ruby/library/stringio/readline_spec.rb | 8 +- spec/ruby/library/stringio/readlines_spec.rb | 14 +- .../ruby/library/stringio/readpartial_spec.rb | 12 +- spec/ruby/library/stringio/reopen_spec.rb | 74 +++--- spec/ruby/library/stringio/rewind_spec.rb | 2 +- spec/ruby/library/stringio/seek_spec.rb | 24 +- .../stringio/set_encoding_by_bom_spec.rb | 6 +- .../library/stringio/shared/codepoints.rb | 10 +- spec/ruby/library/stringio/shared/each.rb | 18 +- .../ruby/library/stringio/shared/each_byte.rb | 10 +- .../ruby/library/stringio/shared/each_char.rb | 8 +- spec/ruby/library/stringio/shared/eof.rb | 10 +- spec/ruby/library/stringio/shared/getc.rb | 20 +- spec/ruby/library/stringio/shared/gets.rb | 34 +-- spec/ruby/library/stringio/shared/isatty.rb | 2 +- spec/ruby/library/stringio/shared/read.rb | 26 +- spec/ruby/library/stringio/shared/readchar.rb | 6 +- spec/ruby/library/stringio/shared/sysread.rb | 2 +- spec/ruby/library/stringio/shared/write.rb | 8 +- spec/ruby/library/stringio/string_spec.rb | 12 +- spec/ruby/library/stringio/stringio_spec.rb | 2 +- spec/ruby/library/stringio/sync_spec.rb | 4 +- spec/ruby/library/stringio/sysread_spec.rb | 2 +- spec/ruby/library/stringio/truncate_spec.rb | 16 +- spec/ruby/library/stringio/ungetc_spec.rb | 14 +- spec/ruby/library/stringscanner/check_spec.rb | 12 +- .../library/stringscanner/check_until_spec.rb | 14 +- spec/ruby/library/stringscanner/dup_spec.rb | 4 +- .../stringscanner/element_reference_spec.rb | 16 +- spec/ruby/library/stringscanner/exist_spec.rb | 14 +- .../library/stringscanner/get_byte_spec.rb | 8 +- spec/ruby/library/stringscanner/getch_spec.rb | 8 +- .../library/stringscanner/initialize_spec.rb | 6 +- .../library/stringscanner/inspect_spec.rb | 2 +- spec/ruby/library/stringscanner/match_spec.rb | 2 +- .../library/stringscanner/matched_spec.rb | 4 +- spec/ruby/library/stringscanner/peek_spec.rb | 8 +- spec/ruby/library/stringscanner/rest_spec.rb | 6 +- .../library/stringscanner/scan_byte_spec.rb | 6 +- .../library/stringscanner/scan_full_spec.rb | 2 +- .../stringscanner/scan_integer_spec.rb | 10 +- spec/ruby/library/stringscanner/scan_spec.rb | 22 +- .../library/stringscanner/scan_until_spec.rb | 14 +- .../library/stringscanner/search_full_spec.rb | 12 +- spec/ruby/library/stringscanner/shared/bol.rb | 16 +- .../library/stringscanner/shared/concat.rb | 14 +- .../stringscanner/shared/extract_range.rb | 4 +- .../shared/extract_range_matched.rb | 4 +- spec/ruby/library/stringscanner/shared/pos.rb | 4 +- spec/ruby/library/stringscanner/skip_spec.rb | 2 +- .../library/stringscanner/skip_until_spec.rb | 14 +- .../ruby/library/stringscanner/string_spec.rb | 2 +- .../ruby/library/stringscanner/unscan_spec.rb | 4 +- .../library/stringscanner/values_at_spec.rb | 4 +- spec/ruby/library/syslog/close_spec.rb | 16 +- spec/ruby/library/syslog/constants_spec.rb | 2 +- spec/ruby/library/syslog/facility_spec.rb | 6 +- spec/ruby/library/syslog/ident_spec.rb | 4 +- spec/ruby/library/syslog/inspect_spec.rb | 4 +- spec/ruby/library/syslog/log_spec.rb | 8 +- spec/ruby/library/syslog/mask_spec.rb | 14 +- spec/ruby/library/syslog/open_spec.rb | 10 +- spec/ruby/library/syslog/opened_spec.rb | 16 +- spec/ruby/library/syslog/options_spec.rb | 6 +- spec/ruby/library/syslog/shared/log.rb | 4 +- spec/ruby/library/syslog/shared/reopen.rb | 14 +- spec/ruby/library/tempfile/_close_spec.rb | 4 +- spec/ruby/library/tempfile/close_spec.rb | 6 +- spec/ruby/library/tempfile/create_spec.rb | 28 +-- spec/ruby/library/tempfile/initialize_spec.rb | 2 +- spec/ruby/library/tempfile/open_spec.rb | 18 +- spec/ruby/library/tempfile/path_spec.rb | 2 +- spec/ruby/library/tempfile/shared/length.rb | 6 +- spec/ruby/library/thread/queue_spec.rb | 4 +- spec/ruby/library/thread/sizedqueue_spec.rb | 4 +- spec/ruby/library/time/shared/rfc2822.rb | 2 +- spec/ruby/library/time/to_time_spec.rb | 4 +- spec/ruby/library/timeout/error_spec.rb | 2 +- spec/ruby/library/timeout/timeout_spec.rb | 10 +- spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb | 18 +- spec/ruby/library/tmpdir/dir/tmpdir_spec.rb | 4 +- spec/ruby/library/uri/join_spec.rb | 2 +- spec/ruby/library/uri/mailto/build_spec.rb | 2 +- spec/ruby/library/uri/parse_spec.rb | 24 +- spec/ruby/library/uri/plus_spec.rb | 170 ++++++------- spec/ruby/library/uri/select_spec.rb | 6 +- spec/ruby/library/uri/set_component_spec.rb | 20 +- spec/ruby/library/uri/shared/eql.rb | 6 +- spec/ruby/library/uri/shared/join.rb | 2 +- spec/ruby/library/uri/shared/parse.rb | 32 +-- spec/ruby/library/uri/uri_spec.rb | 4 +- spec/ruby/library/weakref/__getobj___spec.rb | 4 +- spec/ruby/library/weakref/allocate_spec.rb | 2 +- spec/ruby/library/weakref/send_spec.rb | 4 +- .../library/weakref/weakref_alive_spec.rb | 4 +- .../library/win32ole/win32ole/_invoke_spec.rb | 6 +- .../library/win32ole/win32ole/connect_spec.rb | 4 +- .../win32ole/win32ole/const_load_spec.rb | 8 +- .../library/win32ole/win32ole/locale_spec.rb | 2 +- .../library/win32ole/win32ole/new_spec.rb | 8 +- .../win32ole/ole_func_methods_spec.rb | 6 +- .../win32ole/win32ole/ole_get_methods_spec.rb | 2 +- .../win32ole/win32ole/ole_methods_spec.rb | 6 +- .../win32ole/win32ole/ole_obj_help_spec.rb | 4 +- .../win32ole/win32ole/ole_put_methods_spec.rb | 6 +- .../win32ole/win32ole/shared/ole_method.rb | 4 +- .../win32ole/win32ole/shared/setproperty.rb | 2 +- .../win32ole/win32ole_event/new_spec.rb | 8 +- .../win32ole/win32ole_method/dispid_spec.rb | 2 +- .../win32ole_method/event_interface_spec.rb | 4 +- .../win32ole/win32ole_method/event_spec.rb | 4 +- .../win32ole_method/helpcontext_spec.rb | 2 +- .../win32ole/win32ole_method/helpfile_spec.rb | 2 +- .../win32ole_method/helpstring_spec.rb | 2 +- .../win32ole/win32ole_method/invkind_spec.rb | 2 +- .../win32ole_method/invoke_kind_spec.rb | 2 +- .../win32ole/win32ole_method/new_spec.rb | 14 +- .../win32ole_method/offset_vtbl_spec.rb | 2 +- .../win32ole/win32ole_method/params_spec.rb | 8 +- .../return_type_detail_spec.rb | 4 +- .../win32ole_method/return_type_spec.rb | 2 +- .../win32ole_method/return_vtype_spec.rb | 2 +- .../win32ole/win32ole_method/shared/name.rb | 2 +- .../win32ole_method/size_opt_params_spec.rb | 2 +- .../win32ole_method/size_params_spec.rb | 2 +- .../win32ole/win32ole_method/visible_spec.rb | 4 +- .../win32ole/win32ole_param/default_spec.rb | 4 +- .../win32ole/win32ole_param/input_spec.rb | 2 +- .../win32ole_param/ole_type_detail_spec.rb | 2 +- .../win32ole/win32ole_param/ole_type_spec.rb | 2 +- .../win32ole/win32ole_param/optional_spec.rb | 4 +- .../win32ole/win32ole_param/retval_spec.rb | 4 +- .../win32ole/win32ole_param/shared/name.rb | 2 +- .../win32ole_type/helpcontext_spec.rb | 2 +- .../win32ole/win32ole_type/helpfile_spec.rb | 2 +- .../win32ole_type/major_version_spec.rb | 2 +- .../win32ole_type/minor_version_spec.rb | 2 +- .../win32ole/win32ole_type/new_spec.rb | 16 +- .../win32ole_type/ole_classes_spec.rb | 2 +- .../win32ole_type/ole_methods_spec.rb | 2 +- .../win32ole/win32ole_type/progids_spec.rb | 4 +- .../win32ole/win32ole_type/shared/name.rb | 2 +- .../win32ole/win32ole_type/src_type_spec.rb | 2 +- .../win32ole/win32ole_type/typekind_spec.rb | 2 +- .../win32ole/win32ole_type/typelibs_spec.rb | 4 +- .../win32ole/win32ole_type/visible_spec.rb | 2 +- .../win32ole_variable/ole_type_detail_spec.rb | 4 +- .../win32ole_variable/ole_type_spec.rb | 2 +- .../win32ole/win32ole_variable/shared/name.rb | 2 +- .../win32ole/win32ole_variable/value_spec.rb | 2 +- .../win32ole_variable/variable_kind_spec.rb | 2 +- .../win32ole_variable/varkind_spec.rb | 2 +- .../win32ole_variable/visible_spec.rb | 2 +- spec/ruby/library/yaml/parse_file_spec.rb | 2 +- spec/ruby/library/yaml/parse_spec.rb | 2 +- spec/ruby/library/yaml/shared/load.rb | 6 +- spec/ruby/library/yaml/to_yaml_spec.rb | 18 +- spec/ruby/library/zlib/adler32_spec.rb | 2 +- spec/ruby/library/zlib/crc32_spec.rb | 2 +- spec/ruby/library/zlib/gzipfile/close_spec.rb | 6 +- .../library/zlib/gzipfile/comment_spec.rb | 3 +- .../library/zlib/gzipfile/orig_name_spec.rb | 3 +- spec/ruby/library/zlib/gzipreader/eof_spec.rb | 22 +- .../ruby/library/zlib/gzipreader/getc_spec.rb | 2 +- .../ruby/library/zlib/gzipreader/gets_spec.rb | 2 +- .../ruby/library/zlib/gzipreader/read_spec.rb | 6 +- .../library/zlib/gzipreader/ungetbyte_spec.rb | 4 +- .../library/zlib/gzipreader/ungetc_spec.rb | 12 +- .../library/zlib/gzipwriter/append_spec.rb | 2 +- .../library/zlib/gzipwriter/mtime_spec.rb | 3 +- spec/ruby/library/zlib/inflate/append_spec.rb | 2 +- spec/ruby/library/zlib/inflate/finish_spec.rb | 2 +- .../ruby/library/zlib/inflate/inflate_spec.rb | 4 +- spec/ruby/library/zlib/zlib_version_spec.rb | 2 +- spec/ruby/optional/capi/array_spec.rb | 40 ++-- spec/ruby/optional/capi/bignum_spec.rb | 16 +- spec/ruby/optional/capi/binding_spec.rb | 2 +- spec/ruby/optional/capi/class_spec.rb | 118 ++++----- spec/ruby/optional/capi/constants_spec.rb | 2 +- spec/ruby/optional/capi/data_spec.rb | 2 +- spec/ruby/optional/capi/debug_spec.rb | 10 +- spec/ruby/optional/capi/encoding_spec.rb | 38 +-- spec/ruby/optional/capi/exception_spec.rb | 32 +-- spec/ruby/optional/capi/fiber_spec.rb | 12 +- spec/ruby/optional/capi/file_spec.rb | 8 +- spec/ruby/optional/capi/fixnum_spec.rb | 20 +- spec/ruby/optional/capi/float_spec.rb | 4 +- spec/ruby/optional/capi/gc_spec.rb | 22 +- spec/ruby/optional/capi/globals_spec.rb | 20 +- spec/ruby/optional/capi/hash_spec.rb | 42 ++-- spec/ruby/optional/capi/io_spec.rb | 76 +++--- spec/ruby/optional/capi/kernel_spec.rb | 90 +++---- spec/ruby/optional/capi/module_spec.rb | 56 ++--- spec/ruby/optional/capi/mutex_spec.rb | 34 +-- spec/ruby/optional/capi/numeric_spec.rb | 56 ++--- spec/ruby/optional/capi/object_spec.rb | 150 ++++++------ spec/ruby/optional/capi/proc_spec.rb | 24 +- spec/ruby/optional/capi/range_spec.rb | 36 +-- spec/ruby/optional/capi/regexp_spec.rb | 2 +- spec/ruby/optional/capi/set_spec.rb | 2 +- spec/ruby/optional/capi/string_spec.rb | 96 ++++---- spec/ruby/optional/capi/struct_spec.rb | 40 ++-- spec/ruby/optional/capi/thread_spec.rb | 22 +- spec/ruby/optional/capi/time_spec.rb | 108 ++++----- spec/ruby/optional/capi/tracepoint_spec.rb | 2 +- spec/ruby/optional/capi/typed_data_spec.rb | 6 +- spec/ruby/optional/capi/util_spec.rb | 16 +- spec/ruby/security/cve_2010_1330_spec.rb | 2 +- spec/ruby/security/cve_2018_8778_spec.rb | 2 +- spec/ruby/security/cve_2018_8779_spec.rb | 4 +- spec/ruby/security/cve_2018_8780_spec.rb | 12 +- .../ruby/shared/basicobject/method_missing.rb | 18 +- spec/ruby/shared/basicobject/send.rb | 18 +- spec/ruby/shared/enumerable/minmax.rb | 6 +- spec/ruby/shared/file/directory.rb | 18 +- spec/ruby/shared/file/executable.rb | 8 +- spec/ruby/shared/file/executable_real.rb | 8 +- spec/ruby/shared/file/exist.rb | 6 +- spec/ruby/shared/file/file.rb | 8 +- spec/ruby/shared/file/grpowned.rb | 6 +- spec/ruby/shared/file/identical.rb | 18 +- spec/ruby/shared/file/size.rb | 2 +- spec/ruby/shared/file/world_readable.rb | 10 +- spec/ruby/shared/file/world_writable.rb | 10 +- spec/ruby/shared/file/writable_real.rb | 8 +- spec/ruby/shared/file/zero.rb | 10 +- spec/ruby/shared/hash/key_error.rb | 8 +- spec/ruby/shared/io/putc.rb | 8 +- spec/ruby/shared/kernel/at_exit.rb | 2 +- spec/ruby/shared/kernel/complex.rb | 2 +- spec/ruby/shared/kernel/equal.rb | 4 +- spec/ruby/shared/kernel/object_id.rb | 2 +- spec/ruby/shared/kernel/raise.rb | 118 ++++----- spec/ruby/shared/process/abort.rb | 12 +- spec/ruby/shared/process/exit.rb | 22 +- spec/ruby/shared/process/fork.rb | 6 +- spec/ruby/shared/queue/clear.rb | 4 +- spec/ruby/shared/queue/close.rb | 4 +- spec/ruby/shared/queue/closed.rb | 4 +- spec/ruby/shared/queue/deque.rb | 12 +- spec/ruby/shared/queue/empty.rb | 4 +- spec/ruby/shared/queue/enque.rb | 2 +- spec/ruby/shared/queue/freeze.rb | 2 +- spec/ruby/shared/sizedqueue/enque.rb | 10 +- spec/ruby/shared/sizedqueue/max.rb | 10 +- spec/ruby/shared/sizedqueue/new.rb | 10 +- spec/ruby/shared/string/end_with.rb | 8 +- spec/ruby/shared/string/start_with.rb | 16 +- spec/ruby/shared/string/times.rb | 22 +- 2301 files changed, 14082 insertions(+), 14005 deletions(-) diff --git a/spec/ruby/CONTRIBUTING.md b/spec/ruby/CONTRIBUTING.md index 366b484bada1c1..0b0f2514409681 100644 --- a/spec/ruby/CONTRIBUTING.md +++ b/spec/ruby/CONTRIBUTING.md @@ -55,6 +55,11 @@ which indicates the file was generated but the method unspecified. Here is a list of frequently-used matchers, which should be enough for most specs. There are a few extra specific matchers used in the couple specs that need it. +The general idea is: add `.should` just before the predicate you expect to be truthy, and done! +This works for most needs and provides a great error when it fails. +It's immediately clear which method is used and there no need to remember a mapping like in RSpec between e.g. `eq` and `==`. +See [this blog post](https://eregon.me/blog/2019/10/07/a-new-should-syntax.html) for the motivation behind that syntax. + #### Comparison matchers ```ruby @@ -83,43 +88,37 @@ File.should.equal?(File) # Calls #equal? (tests identity) (0.1 + 0.2).should be_close(0.3, TOLERANCE) # (0.2-0.1).abs < TOLERANCE (0.0/0.0).should.nan? -(1.0/0.0).should be_positive_infinity -(-1.0/0.0).should be_negative_infinity -3.14.should be_an_instance_of(Float) # Calls #instance_of? -3.14.should be_kind_of(Numeric) # Calls #is_a? -Numeric.should be_ancestor_of(Float) # Float.ancestors.include?(Numeric) +3.14.should.instance_of?(Float) # Calls #instance_of? +3.14.should.is_a?(Numeric) # Calls #is_a? 3.14.should.respond_to?(:to_i) -Integer.should have_instance_method(:+) -Array.should have_method(:new) +Integer.should.method_defined?(:+, false) ``` -Also `have_constant`, `have_private_instance_method`, `have_singleton_method`, etc. - #### Exception matchers ```ruby -> { raise "oops" -}.should raise_error(RuntimeError, /oops/) +}.should.raise(RuntimeError, /oops/) -> { raise "oops" -}.should raise_error(RuntimeError) { |e| +}.should.raise(RuntimeError) { |e| # Custom checks on the Exception object e.message.should.include?("oops") e.cause.should == nil } ``` -##### `should_not raise_error` +##### `should_not.raise` **Avoid this!** Instead, use an expectation testing what the code in the lambda does. If an exception is raised, it will fail the example anyway. ```ruby --> { ... }.should_not raise_error +-> { ... }.should_not.raise ``` #### Warning matcher @@ -274,7 +273,7 @@ how this is used currently: ```ruby describe :kernel_sprintf, shared: true do it "raises TypeError exception if cannot convert to Integer" do - -> { @method.call("%b", Object.new) }.should raise_error(TypeError) + -> { @method.call("%b", Object.new) }.should.raise(TypeError) end end diff --git a/spec/ruby/command_line/dash_r_spec.rb b/spec/ruby/command_line/dash_r_spec.rb index 62b8dc001452a7..0de9ba2e24e920 100644 --- a/spec/ruby/command_line/dash_r_spec.rb +++ b/spec/ruby/command_line/dash_r_spec.rb @@ -8,15 +8,15 @@ it "requires the specified file" do out = ruby_exe(@script, options: "-r #{@test_file}") - out.should include("REQUIRED") - out.should include(@test_file + ".rb") + out.should.include?("REQUIRED") + out.should.include?(@test_file + ".rb") end it "requires the file before parsing the main script" do out = ruby_exe(fixture(__FILE__, "bad_syntax.rb"), options: "-r #{@test_file}", args: "2>&1", exit_status: 1) $?.should_not.success? - out.should include("REQUIRED") - out.should include("SyntaxError") + out.should.include?("REQUIRED") + out.should.include?("SyntaxError") end it "does not require the file if the main script file does not exist" do diff --git a/spec/ruby/command_line/dash_upper_i_spec.rb b/spec/ruby/command_line/dash_upper_i_spec.rb index 4cafb724e30fb9..4005a27d2352da 100644 --- a/spec/ruby/command_line/dash_upper_i_spec.rb +++ b/spec/ruby/command_line/dash_upper_i_spec.rb @@ -6,7 +6,7 @@ end it "adds the path to the load path ($:)" do - ruby_exe(@script, options: "-I fixtures").should include("fixtures") + ruby_exe(@script, options: "-I fixtures").should.include?("fixtures") end it "adds the path at the front of $LOAD_PATH" do @@ -18,16 +18,16 @@ idx.should < 2 idx.should < lines.size-1 else - lines[0].should include("fixtures") + lines[0].should.include?("fixtures") end end it "adds the path expanded from CWD to $LOAD_PATH" do - ruby_exe(@script, options: "-I fixtures").lines.should include "#{Dir.pwd}/fixtures\n" + ruby_exe(@script, options: "-I fixtures").lines.should.include? "#{Dir.pwd}/fixtures\n" end it "expands a path from CWD even if it does not exist" do - ruby_exe(@script, options: "-I not_exist/not_exist").lines.should include "#{Dir.pwd}/not_exist/not_exist\n" + ruby_exe(@script, options: "-I not_exist/not_exist").lines.should.include? "#{Dir.pwd}/not_exist/not_exist\n" end end @@ -45,7 +45,7 @@ end it "does not expand symlinks" do - ruby_exe(@script, options: "-I #{@symlink}").lines.should include "#{@symlink}\n" + ruby_exe(@script, options: "-I #{@symlink}").lines.should.include? "#{@symlink}\n" end end end diff --git a/spec/ruby/command_line/dash_v_spec.rb b/spec/ruby/command_line/dash_v_spec.rb index b13350404c659c..6a4f7d3a156ae9 100644 --- a/spec/ruby/command_line/dash_v_spec.rb +++ b/spec/ruby/command_line/dash_v_spec.rb @@ -6,7 +6,7 @@ describe "when used alone" do it "prints version and ends" do - ruby_exe(nil, args: '-v').gsub("+PRISM ", "").should include(RUBY_DESCRIPTION.gsub("+PRISM ", "")) + ruby_exe(nil, args: '-v').gsub("+PRISM ", "").should.include?(RUBY_DESCRIPTION.gsub("+PRISM ", "")) end unless (defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?) || (defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?) || (ENV['RUBY_GC_LIBRARY'] && ENV['RUBY_GC_LIBRARY'].length > 0) || diff --git a/spec/ruby/command_line/dash_x_spec.rb b/spec/ruby/command_line/dash_x_spec.rb index ae14b610707e23..38f97a5ab1b2f7 100644 --- a/spec/ruby/command_line/dash_x_spec.rb +++ b/spec/ruby/command_line/dash_x_spec.rb @@ -10,7 +10,7 @@ it "fails when /\#!.*ruby.*/-ish line in target file is not found" do bad_embedded_ruby = fixture __FILE__, "bin/bad_embedded_ruby.txt" result = ruby_exe(bad_embedded_ruby, options: '-x', args: '2>&1', exit_status: 1) - result.should include "no Ruby script found in input" + result.should.include? "no Ruby script found in input" end it "behaves as -x was set when non-ruby shebang is encountered on first line" do diff --git a/spec/ruby/command_line/error_message_spec.rb b/spec/ruby/command_line/error_message_spec.rb index 5bed905cf634a6..157cb8969ca057 100644 --- a/spec/ruby/command_line/error_message_spec.rb +++ b/spec/ruby/command_line/error_message_spec.rb @@ -11,6 +11,6 @@ it "is not modified with extra escaping of control characters and backslashes" do out = ruby_exe('raise "\e[31mRed\e[0m error\\\\message"', args: "2>&1", exit_status: 1) - out.chomp.should include("\e[31mRed\e[0m error\\message") + out.chomp.should.include?("\e[31mRed\e[0m error\\message") end end diff --git a/spec/ruby/command_line/feature_spec.rb b/spec/ruby/command_line/feature_spec.rb index 838581d04abe3e..0a3252b88d72e6 100644 --- a/spec/ruby/command_line/feature_spec.rb +++ b/spec/ruby/command_line/feature_spec.rb @@ -62,10 +62,10 @@ end it "prints a warning for unknown features" do - ruby_exe("p 14", options: "--enable=ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --enable') - ruby_exe("p 14", options: "--disable=ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --disable') - ruby_exe("p 14", options: "--enable-ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --enable') - ruby_exe("p 14", options: "--disable-ruby-spec-feature-does-not-exist 2>&1").chomp.should include('warning: unknown argument for --disable') + ruby_exe("p 14", options: "--enable=ruby-spec-feature-does-not-exist 2>&1").chomp.should.include?('warning: unknown argument for --enable') + ruby_exe("p 14", options: "--disable=ruby-spec-feature-does-not-exist 2>&1").chomp.should.include?('warning: unknown argument for --disable') + ruby_exe("p 14", options: "--enable-ruby-spec-feature-does-not-exist 2>&1").chomp.should.include?('warning: unknown argument for --enable') + ruby_exe("p 14", options: "--disable-ruby-spec-feature-does-not-exist 2>&1").chomp.should.include?('warning: unknown argument for --disable') end end diff --git a/spec/ruby/command_line/frozen_strings_spec.rb b/spec/ruby/command_line/frozen_strings_spec.rb index 8acab5bc1d66ee..32ff7d03712247 100644 --- a/spec/ruby/command_line/frozen_strings_spec.rb +++ b/spec/ruby/command_line/frozen_strings_spec.rb @@ -78,17 +78,17 @@ describe "The --debug flag produces" do it "debugging info on attempted frozen string modification" do error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '--enable-frozen-string-literal --debug', args: "2>&1") - error_str.should include("can't modify frozen String") - error_str.should include("created at") - error_str.should include("command_line/fixtures/debug_info.rb:1") + error_str.should.include?("can't modify frozen String") + error_str.should.include?("created at") + error_str.should.include?("command_line/fixtures/debug_info.rb:1") end guard -> { ruby_version_is "3.4" and !"test".frozen? } do it "debugging info on mutating chilled string" do error_str = ruby_exe(fixture(__FILE__, 'debug_info.rb'), options: '-w --debug', args: "2>&1") - error_str.should include("literal string will be frozen in the future") - error_str.should include("the string was created here") - error_str.should include("command_line/fixtures/debug_info.rb:1") + error_str.should.include?("literal string will be frozen in the future") + error_str.should.include?("the string was created here") + error_str.should.include?("command_line/fixtures/debug_info.rb:1") end end end diff --git a/spec/ruby/command_line/rubylib_spec.rb b/spec/ruby/command_line/rubylib_spec.rb index b45919b9979f19..1bedd146e3772d 100644 --- a/spec/ruby/command_line/rubylib_spec.rb +++ b/spec/ruby/command_line/rubylib_spec.rb @@ -14,15 +14,15 @@ dir = tmp("rubylib/incl") ENV["RUBYLIB"] = @pre + dir paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp) - paths.should include(dir) + paths.should.include?(dir) end it "adds a File::PATH_SEPARATOR-separated list of directories to $LOAD_PATH" do dir1, dir2 = tmp("rubylib/incl1"), tmp("rubylib/incl2") ENV["RUBYLIB"] = @pre + "#{dir1}#{File::PATH_SEPARATOR}#{dir2}" paths = ruby_exe("puts $LOAD_PATH").lines.map(&:chomp) - paths.should include(dir1) - paths.should include(dir2) + paths.should.include?(dir1) + paths.should.include?(dir2) paths.index(dir1).should < paths.index(dir2) end @@ -46,8 +46,8 @@ rubylib_dir = tmp("rubylib_include") ENV["RUBYLIB"] = @pre + rubylib_dir paths = ruby_exe("puts $LOAD_PATH", options: "-I #{dash_i_dir}").lines.map(&:chomp) - paths.should include(dash_i_dir) - paths.should include(rubylib_dir) + paths.should.include?(dash_i_dir) + paths.should.include?(rubylib_dir) paths.index(dash_i_dir).should < paths.index(rubylib_dir) end @@ -56,14 +56,14 @@ rubylib_dir = tmp("rubylib_include") ENV["RUBYLIB"] = @pre + rubylib_dir paths = ruby_exe("puts $LOAD_PATH", env: { "RUBYOPT" => "-I#{rubyopt_dir}" }).lines.map(&:chomp) - paths.should include(rubyopt_dir) - paths.should include(rubylib_dir) + paths.should.include?(rubyopt_dir) + paths.should.include?(rubylib_dir) paths.index(rubyopt_dir).should < paths.index(rubylib_dir) end it "keeps spaces in the value" do ENV["RUBYLIB"] = @pre + " rubylib/incl " out = ruby_exe("puts $LOAD_PATH") - out.should include(" rubylib/incl ") + out.should.include?(" rubylib/incl ") end end diff --git a/spec/ruby/core/argf/argf_spec.rb b/spec/ruby/core/argf/argf_spec.rb index af67170b98d709..f9468539bba0e3 100644 --- a/spec/ruby/core/argf/argf_spec.rb +++ b/spec/ruby/core/argf/argf_spec.rb @@ -2,10 +2,10 @@ describe "ARGF" do it "is extended by the Enumerable module" do - ARGF.should be_kind_of(Enumerable) + ARGF.should.is_a?(Enumerable) end it "is an instance of ARGF.class" do - ARGF.should be_an_instance_of(ARGF.class) + ARGF.should.instance_of?(ARGF.class) end end diff --git a/spec/ruby/core/argf/argv_spec.rb b/spec/ruby/core/argf/argv_spec.rb index eab03c450f2953..77dfe78c21ee7c 100644 --- a/spec/ruby/core/argf/argv_spec.rb +++ b/spec/ruby/core/argf/argv_spec.rb @@ -7,7 +7,7 @@ end it "returns ARGV for the initial ARGF" do - ARGF.argv.should equal ARGV + ARGF.argv.should.equal? ARGV end it "returns the remaining arguments to treat" do diff --git a/spec/ruby/core/argf/binmode_spec.rb b/spec/ruby/core/argf/binmode_spec.rb index e083a30a27aed1..5288e3199d462d 100644 --- a/spec/ruby/core/argf/binmode_spec.rb +++ b/spec/ruby/core/argf/binmode_spec.rb @@ -9,7 +9,7 @@ it "returns self" do argf [@bin_file] do - @argf.binmode.should equal @argf + @argf.binmode.should.equal? @argf end end diff --git a/spec/ruby/core/argf/close_spec.rb b/spec/ruby/core/argf/close_spec.rb index d4d6a51e7239dc..8ca7d71dc20c7d 100644 --- a/spec/ruby/core/argf/close_spec.rb +++ b/spec/ruby/core/argf/close_spec.rb @@ -10,20 +10,20 @@ argf [@file1_name, @file2_name] do io = @argf.to_io @argf.close - io.closed?.should be_true + io.closed?.should == true end end it "returns self" do argf [@file1_name, @file2_name] do - @argf.close.should equal(@argf) + @argf.close.should.equal?(@argf) end end it "doesn't raise an IOError if called on a closed stream" do argf [@file1_name] do - -> { @argf.close }.should_not raise_error - -> { @argf.close }.should_not raise_error + -> { @argf.close }.should_not.raise + -> { @argf.close }.should_not.raise end end end diff --git a/spec/ruby/core/argf/closed_spec.rb b/spec/ruby/core/argf/closed_spec.rb index e2dd6134e50516..769381e8c3e662 100644 --- a/spec/ruby/core/argf/closed_spec.rb +++ b/spec/ruby/core/argf/closed_spec.rb @@ -11,7 +11,7 @@ stream = @argf.to_io stream.close - @argf.closed?.should be_true + @argf.closed?.should == true stream.reopen(@argf.filename, 'r') end end diff --git a/spec/ruby/core/argf/read_nonblock_spec.rb b/spec/ruby/core/argf/read_nonblock_spec.rb index 804a459a62d8c7..5c6bd52d805b17 100644 --- a/spec/ruby/core/argf/read_nonblock_spec.rb +++ b/spec/ruby/core/argf/read_nonblock_spec.rb @@ -66,7 +66,7 @@ argf ['-'] do -> { @argf.read_nonblock(4) - }.should raise_error(IO::EAGAINWaitReadable) + }.should.raise(IO::EAGAINWaitReadable) end end diff --git a/spec/ruby/core/argf/readchar_spec.rb b/spec/ruby/core/argf/readchar_spec.rb index 4eca2efcf7d5b5..63632721ecdee2 100644 --- a/spec/ruby/core/argf/readchar_spec.rb +++ b/spec/ruby/core/argf/readchar_spec.rb @@ -13,7 +13,7 @@ it "raises EOFError when end of stream reached" do argf [@file1, @file2] do - -> { while @argf.readchar; end }.should raise_error(EOFError) + -> { while @argf.readchar; end }.should.raise(EOFError) end end end diff --git a/spec/ruby/core/argf/readline_spec.rb b/spec/ruby/core/argf/readline_spec.rb index db53c499e9591b..8c23549b1bcfcd 100644 --- a/spec/ruby/core/argf/readline_spec.rb +++ b/spec/ruby/core/argf/readline_spec.rb @@ -17,7 +17,7 @@ it "raises an EOFError when reaching end of files" do argf [@file1, @file2] do - -> { while @argf.readline; end }.should raise_error(EOFError) + -> { while @argf.readline; end }.should.raise(EOFError) end end end diff --git a/spec/ruby/core/argf/readpartial_spec.rb b/spec/ruby/core/argf/readpartial_spec.rb index ea4301f25c690d..9f04e72cc265c8 100644 --- a/spec/ruby/core/argf/readpartial_spec.rb +++ b/spec/ruby/core/argf/readpartial_spec.rb @@ -16,7 +16,7 @@ it "raises an ArgumentError if called without a maximum read length" do argf [@file1_name] do - -> { @argf.readpartial }.should raise_error(ArgumentError) + -> { @argf.readpartial }.should.raise(ArgumentError) end end @@ -59,8 +59,8 @@ @argf.readpartial(@file1.size) @argf.readpartial(1) @argf.readpartial(@file2.size) - -> { @argf.readpartial(1) }.should raise_error(EOFError) - -> { @argf.readpartial(1) }.should raise_error(EOFError) + -> { @argf.readpartial(1) }.should.raise(EOFError) + -> { @argf.readpartial(1) }.should.raise(EOFError) end end diff --git a/spec/ruby/core/argf/rewind_spec.rb b/spec/ruby/core/argf/rewind_spec.rb index b29f0b75b765c5..9255f790fee11c 100644 --- a/spec/ruby/core/argf/rewind_spec.rb +++ b/spec/ruby/core/argf/rewind_spec.rb @@ -33,7 +33,7 @@ it "raises an ArgumentError when end of stream reached" do argf [@file1_name, @file2_name] do @argf.read - -> { @argf.rewind }.should raise_error(ArgumentError) + -> { @argf.rewind }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/argf/seek_spec.rb b/spec/ruby/core/argf/seek_spec.rb index 2b73bd46fb9d56..c1ea1ea4389e39 100644 --- a/spec/ruby/core/argf/seek_spec.rb +++ b/spec/ruby/core/argf/seek_spec.rb @@ -57,7 +57,7 @@ it "takes at least one argument (offset)" do argf [@file1_name] do - -> { @argf.seek }.should raise_error(ArgumentError) + -> { @argf.seek }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/argf/shared/each_byte.rb b/spec/ruby/core/argf/shared/each_byte.rb index 6b1dc1dae2e1e0..48c9ae04f88b15 100644 --- a/spec/ruby/core/argf/shared/each_byte.rb +++ b/spec/ruby/core/argf/shared/each_byte.rb @@ -18,14 +18,14 @@ it "returns self when passed a block" do argf [@file1_name, @file2_name] do - @argf.send(@method) {}.should equal(@argf) + @argf.send(@method) {}.should.equal?(@argf) end end it "returns an Enumerator when passed no block" do argf [@file1_name, @file2_name] do enum = @argf.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) bytes = [] enum.each { |b| bytes << b } @@ -37,7 +37,7 @@ it "returns an Enumerator" do argf [@file1_name, @file2_name] do enum = @argf.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) bytes = [] enum.each { |b| bytes << b } diff --git a/spec/ruby/core/argf/shared/each_char.rb b/spec/ruby/core/argf/shared/each_char.rb index 9e333ecc5b4ff4..4b5e8452ab9193 100644 --- a/spec/ruby/core/argf/shared/each_char.rb +++ b/spec/ruby/core/argf/shared/each_char.rb @@ -18,14 +18,14 @@ it "returns self when passed a block" do argf [@file1_name, @file2_name] do - @argf.send(@method) {}.should equal(@argf) + @argf.send(@method) {}.should.equal?(@argf) end end it "returns an Enumerator when passed no block" do argf [@file1_name, @file2_name] do enum = @argf.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) chars = [] enum.each { |c| chars << c } @@ -37,7 +37,7 @@ it "returns an Enumerator" do argf [@file1_name, @file2_name] do enum = @argf.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) chars = [] enum.each { |c| chars << c } diff --git a/spec/ruby/core/argf/shared/each_codepoint.rb b/spec/ruby/core/argf/shared/each_codepoint.rb index e2a2dfff4605f4..3137306ad5f572 100644 --- a/spec/ruby/core/argf/shared/each_codepoint.rb +++ b/spec/ruby/core/argf/shared/each_codepoint.rb @@ -10,7 +10,7 @@ it "is a public method" do argf @filenames do - @argf.public_methods(false).should include(@method) + @argf.public_methods(false).should.include?(@method) end end @@ -22,13 +22,13 @@ it "returns self when passed a block" do argf @filenames do - @argf.send(@method) {}.should equal(@argf) + @argf.send(@method) {}.should.equal?(@argf) end end it "returns an Enumerator when passed no block" do argf @filenames do - @argf.send(@method).should be_an_instance_of(Enumerator) + @argf.send(@method).should.instance_of?(Enumerator) end end @@ -41,7 +41,7 @@ describe "when no block is given" do it "returns an Enumerator" do argf @filenames do - @argf.send(@method).should be_an_instance_of(Enumerator) + @argf.send(@method).should.instance_of?(Enumerator) end end diff --git a/spec/ruby/core/argf/shared/each_line.rb b/spec/ruby/core/argf/shared/each_line.rb index c0ef77dc543645..7e66e38803302c 100644 --- a/spec/ruby/core/argf/shared/each_line.rb +++ b/spec/ruby/core/argf/shared/each_line.rb @@ -9,7 +9,7 @@ it "is a public method" do argf [@file1_name, @file2_name] do - @argf.public_methods(false).should include(@method) + @argf.public_methods(false).should.include?(@method) end end @@ -29,7 +29,7 @@ it "returns self when passed a block" do argf [@file1_name, @file2_name] do - @argf.send(@method) {}.should equal(@argf) + @argf.send(@method) {}.should.equal?(@argf) end end @@ -45,7 +45,7 @@ describe "when no block is given" do it "returns an Enumerator" do argf [@file1_name, @file2_name] do - @argf.send(@method).should be_an_instance_of(Enumerator) + @argf.send(@method).should.instance_of?(Enumerator) end end diff --git a/spec/ruby/core/argf/shared/eof.rb b/spec/ruby/core/argf/shared/eof.rb index 0e684f943f798a..8b3897b95204f3 100644 --- a/spec/ruby/core/argf/shared/eof.rb +++ b/spec/ruby/core/argf/shared/eof.rb @@ -18,7 +18,7 @@ it "raises IOError when called on a closed stream" do argf [@file1] do @argf.read - -> { @argf.send(@method) }.should raise_error(IOError) + -> { @argf.send(@method) }.should.raise(IOError) end end end diff --git a/spec/ruby/core/argf/shared/fileno.rb b/spec/ruby/core/argf/shared/fileno.rb index 4350d4374780ed..e605be46e31e4a 100644 --- a/spec/ruby/core/argf/shared/fileno.rb +++ b/spec/ruby/core/argf/shared/fileno.rb @@ -18,7 +18,7 @@ it "raises an ArgumentError when called on a closed stream" do argf [@file1] do @argf.read - -> { @argf.send(@method) }.should raise_error(ArgumentError) + -> { @argf.send(@method) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/argf/shared/pos.rb b/spec/ruby/core/argf/shared/pos.rb index 9836d5f1e4f507..f859d3a29d0ee9 100644 --- a/spec/ruby/core/argf/shared/pos.rb +++ b/spec/ruby/core/argf/shared/pos.rb @@ -25,7 +25,7 @@ it "raises an ArgumentError when called on a closed stream" do argf [@file1] do @argf.read - -> { @argf.send(@method) }.should raise_error(ArgumentError) + -> { @argf.send(@method) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/argf/skip_spec.rb b/spec/ruby/core/argf/skip_spec.rb index 0181801c2d1a73..bb1c0ae1105af1 100644 --- a/spec/ruby/core/argf/skip_spec.rb +++ b/spec/ruby/core/argf/skip_spec.rb @@ -37,6 +37,6 @@ # which as a side-effect calls argf.file which will initialize # internals of ARGF enough for this to work. it "has no effect when nothing has been processed yet" do - -> { ARGF.class.new(@file1_name).skip }.should_not raise_error + -> { ARGF.class.new(@file1_name).skip }.should_not.raise end end diff --git a/spec/ruby/core/argf/to_io_spec.rb b/spec/ruby/core/argf/to_io_spec.rb index 062383d2911c4d..ab5de58bcf274e 100644 --- a/spec/ruby/core/argf/to_io_spec.rb +++ b/spec/ruby/core/argf/to_io_spec.rb @@ -15,7 +15,7 @@ result << @argf.to_io end - result.each { |io| io.should be_kind_of(IO) } + result.each { |io| io.should.is_a?(IO) } result[0].should == result[1] result[2].should == result[3] end diff --git a/spec/ruby/core/array/allocate_spec.rb b/spec/ruby/core/array/allocate_spec.rb index 04f7c0d0ad3cfe..c9eceef5903f56 100644 --- a/spec/ruby/core/array/allocate_spec.rb +++ b/spec/ruby/core/array/allocate_spec.rb @@ -3,7 +3,7 @@ describe "Array.allocate" do it "returns an instance of Array" do ary = Array.allocate - ary.should be_an_instance_of(Array) + ary.should.instance_of?(Array) end it "returns a fully-formed instance of Array" do @@ -14,6 +14,6 @@ end it "does not accept any arguments" do - -> { Array.allocate(1) }.should raise_error(ArgumentError) + -> { Array.allocate(1) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/array/append_spec.rb b/spec/ruby/core/array/append_spec.rb index c12473dc07f18a..de0e56b5133bcb 100644 --- a/spec/ruby/core/array/append_spec.rb +++ b/spec/ruby/core/array/append_spec.rb @@ -10,8 +10,8 @@ it "returns self to allow chaining" do a = [] b = a - (a << 1).should equal(b) - (a << 2 << 3).should equal(b) + (a << 1).should.equal?(b) + (a << 2 << 3).should.equal?(b) end it "correctly resizes the Array" do @@ -31,7 +31,7 @@ end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array << 5 }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array << 5 }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/assoc_spec.rb b/spec/ruby/core/array/assoc_spec.rb index f0be3de7957807..a5026cf5d4f065 100644 --- a/spec/ruby/core/array/assoc_spec.rb +++ b/spec/ruby/core/array/assoc_spec.rb @@ -10,14 +10,14 @@ s5 = [:letters, "a", "i", "u"] s_nil = [nil, nil] a = [s1, s2, s3, s4, s5, s_nil] - a.assoc(s1.first).should equal(s1) - a.assoc(s2.first).should equal(s2) - a.assoc(s3.first).should equal(s3) - a.assoc(s4.first).should equal(s1) - a.assoc(s5.first).should equal(s2) - a.assoc(s_nil.first).should equal(s_nil) - a.assoc(4).should equal(s3) - a.assoc("key not in array").should be_nil + a.assoc(s1.first).should.equal?(s1) + a.assoc(s2.first).should.equal?(s2) + a.assoc(s3.first).should.equal?(s3) + a.assoc(s4.first).should.equal?(s1) + a.assoc(s5.first).should.equal?(s2) + a.assoc(s_nil.first).should.equal?(s_nil) + a.assoc(4).should.equal?(s3) + a.assoc("key not in array").should == nil end it "calls == on first element of each array" do @@ -25,17 +25,17 @@ key2 = mock('key2') items = [['not it', 1], [ArraySpecs::AssocKey.new, 2], ['na', 3]] - items.assoc(key1).should equal(items[1]) - items.assoc(key2).should be_nil + items.assoc(key1).should.equal?(items[1]) + items.assoc(key2).should == nil end it "ignores any non-Array elements" do - [1, 2, 3].assoc(2).should be_nil + [1, 2, 3].assoc(2).should == nil s1 = [4] s2 = [5, 4, 3] a = ["foo", [], s1, s2, nil, []] - a.assoc(s1.first).should equal(s1) - a.assoc(s2.first).should equal(s2) + a.assoc(s1.first).should.equal?(s1) + a.assoc(s2.first).should.equal?(s2) end it "calls to_ary on non-array elements" do @@ -44,9 +44,9 @@ a = [s1, s2] s1.should_not_receive(:to_ary) - a.assoc(s1.first).should equal(s1) + a.assoc(s1.first).should.equal?(s1) a.assoc(2).should == [2, 3] - s2.called.should equal(:to_ary) + s2.called.should.equal?(:to_ary) end end diff --git a/spec/ruby/core/array/at_spec.rb b/spec/ruby/core/array/at_spec.rb index 8bc789fef75cd1..3c7c99fdffe2f9 100644 --- a/spec/ruby/core/array/at_spec.rb +++ b/spec/ruby/core/array/at_spec.rb @@ -47,10 +47,10 @@ end it "raises a TypeError when the passed argument can't be coerced to Integer" do - -> { [].at("cat") }.should raise_error(TypeError) + -> { [].at("cat") }.should.raise(TypeError) end it "raises an ArgumentError when 2 or more arguments are passed" do - -> { [:a, :b].at(0,1) }.should raise_error(ArgumentError) + -> { [:a, :b].at(0,1) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/array/bsearch_index_spec.rb b/spec/ruby/core/array/bsearch_index_spec.rb index 94d85b37f33583..e1d5eb66bb1abb 100644 --- a/spec/ruby/core/array/bsearch_index_spec.rb +++ b/spec/ruby/core/array/bsearch_index_spec.rb @@ -8,11 +8,11 @@ end it "returns an Enumerator" do - @enum.should be_an_instance_of(Enumerator) + @enum.should.instance_of?(Enumerator) end it "returns an Enumerator with unknown size" do - @enum.size.should be_nil + @enum.size.should == nil end it "returns index of element when block condition is satisfied" do @@ -21,11 +21,11 @@ end it "raises a TypeError when block returns a String" do - -> { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError) + -> { [1, 2, 3].bsearch_index { "not ok" } }.should.raise(TypeError) end it "returns nil when block is empty" do - [1, 2, 3].bsearch_index {}.should be_nil + [1, 2, 3].bsearch_index {}.should == nil end context "minimum mode" do @@ -40,8 +40,8 @@ end it "returns nil when block condition is never satisfied" do - @array.bsearch_index { false }.should be_nil - @array.bsearch_index { |x| x >= 100 }.should be_nil + @array.bsearch_index { false }.should == nil + @array.bsearch_index { |x| x >= 100 }.should == nil end end @@ -51,30 +51,30 @@ end it "returns the index of any matched elements where element is between 4 <= x < 8" do - [1, 2].should include(@array.bsearch_index { |x| 1 - x / 4 }) + [1, 2].should.include?(@array.bsearch_index { |x| 1 - x / 4 }) end it "returns the index of any matched elements where element is between 8 <= x < 10" do - @array.bsearch_index { |x| 4 - x / 2 }.should be_nil + @array.bsearch_index { |x| 4 - x / 2 }.should == nil end it "returns nil when block never returns 0" do - @array.bsearch_index { |x| 1 }.should be_nil - @array.bsearch_index { |x| -1 }.should be_nil + @array.bsearch_index { |x| 1 }.should == nil + @array.bsearch_index { |x| -1 }.should == nil end context "magnitude does not effect the result" do it "returns the index of any matched elements where element is between 4n <= xn < 8n" do - [1, 2].should include(@array.bsearch_index { |x| (1 - x / 4) * (2**100) }) + [1, 2].should.include?(@array.bsearch_index { |x| (1 - x / 4) * (2**100) }) end it "returns nil when block never returns 0" do - @array.bsearch_index { |x| 1 * (2**100) }.should be_nil - @array.bsearch_index { |x| (-1) * (2**100) }.should be_nil + @array.bsearch_index { |x| 1 * (2**100) }.should == nil + @array.bsearch_index { |x| (-1) * (2**100) }.should == nil end it "handles values from Integer#coerce" do - [1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first }) + [1, 2].should.include?(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first }) end end end diff --git a/spec/ruby/core/array/bsearch_spec.rb b/spec/ruby/core/array/bsearch_spec.rb index 8fa6245dbff6b2..12aec606543a89 100644 --- a/spec/ruby/core/array/bsearch_spec.rb +++ b/spec/ruby/core/array/bsearch_spec.rb @@ -3,26 +3,26 @@ describe "Array#bsearch" do it "returns an Enumerator when not passed a block" do - [1].bsearch.should be_an_instance_of(Enumerator) + [1].bsearch.should.instance_of?(Enumerator) end it_behaves_like :enumeratorized_with_unknown_size, :bsearch, [1,2,3] it "raises a TypeError if the block returns an Object" do - -> { [1].bsearch { Object.new } }.should raise_error(TypeError) + -> { [1].bsearch { Object.new } }.should.raise(TypeError) end it "raises a TypeError if the block returns a String" do - -> { [1].bsearch { "1" } }.should raise_error(TypeError) + -> { [1].bsearch { "1" } }.should.raise(TypeError) end context "with a block returning true or false" do it "returns nil if the block returns false for every element" do - [0, 1, 2, 3].bsearch { |x| x > 3 }.should be_nil + [0, 1, 2, 3].bsearch { |x| x > 3 }.should == nil end it "returns nil if the block returns nil for every element" do - [0, 1, 2, 3].bsearch { |x| nil }.should be_nil + [0, 1, 2, 3].bsearch { |x| nil }.should == nil end it "returns element at zero if the block returns true for every element" do @@ -38,21 +38,21 @@ context "with a block returning negative, zero, positive numbers" do it "returns nil if the block returns less than zero for every element" do - [0, 1, 2, 3].bsearch { |x| x <=> 5 }.should be_nil + [0, 1, 2, 3].bsearch { |x| x <=> 5 }.should == nil end it "returns nil if the block returns greater than zero for every element" do - [0, 1, 2, 3].bsearch { |x| x <=> -1 }.should be_nil + [0, 1, 2, 3].bsearch { |x| x <=> -1 }.should == nil end it "returns nil if the block never returns zero" do - [0, 1, 3, 4].bsearch { |x| x <=> 2 }.should be_nil + [0, 1, 3, 4].bsearch { |x| x <=> 2 }.should == nil end it "accepts (+/-)Float::INFINITY from the block" do - [0, 1, 3, 4].bsearch { |x| Float::INFINITY }.should be_nil - [0, 1, 3, 4].bsearch { |x| -Float::INFINITY }.should be_nil + [0, 1, 3, 4].bsearch { |x| Float::INFINITY }.should == nil + [0, 1, 3, 4].bsearch { |x| -Float::INFINITY }.should == nil end it "returns an element at an index for which block returns 0.0" do @@ -62,17 +62,17 @@ it "returns an element at an index for which block returns 0" do result = [0, 1, 2, 3, 4].bsearch { |x| x < 1 ? 1 : x > 3 ? -1 : 0 } - [1, 2].should include(result) + [1, 2].should.include?(result) end end context "with a block that calls break" do it "returns nil if break is called without a value" do - ['a', 'b', 'c'].bsearch { |v| break }.should be_nil + ['a', 'b', 'c'].bsearch { |v| break }.should == nil end it "returns nil if break is called with a nil value" do - ['a', 'b', 'c'].bsearch { |v| break nil }.should be_nil + ['a', 'b', 'c'].bsearch { |v| break nil }.should == nil end it "returns object if break is called with an object" do diff --git a/spec/ruby/core/array/clear_spec.rb b/spec/ruby/core/array/clear_spec.rb index 81ba56e01e40fa..15778f864f5eb0 100644 --- a/spec/ruby/core/array/clear_spec.rb +++ b/spec/ruby/core/array/clear_spec.rb @@ -4,13 +4,13 @@ describe "Array#clear" do it "removes all elements" do a = [1, 2, 3, 4] - a.clear.should equal(a) + a.clear.should.equal?(a) a.should == [] end it "returns self" do a = [1] - a.should equal a.clear + a.should.equal? a.clear end it "leaves the Array empty" do @@ -21,12 +21,12 @@ end it "does not accept any arguments" do - -> { [1].clear(true) }.should raise_error(ArgumentError) + -> { [1].clear(true) }.should.raise(ArgumentError) end it "raises a FrozenError on a frozen array" do a = [1] a.freeze - -> { a.clear }.should raise_error(FrozenError) + -> { a.clear }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/clone_spec.rb b/spec/ruby/core/array/clone_spec.rb index e22a6c6d536795..7ce9d40a81f741 100644 --- a/spec/ruby/core/array/clone_spec.rb +++ b/spec/ruby/core/array/clone_spec.rb @@ -23,9 +23,9 @@ def a.a_singleton_method; end aa = a.clone bb = b.clone - a.respond_to?(:a_singleton_method).should be_true - b.respond_to?(:a_singleton_method).should be_false - aa.respond_to?(:a_singleton_method).should be_true - bb.respond_to?(:a_singleton_method).should be_false + a.respond_to?(:a_singleton_method).should == true + b.respond_to?(:a_singleton_method).should == false + aa.respond_to?(:a_singleton_method).should == true + bb.respond_to?(:a_singleton_method).should == false end end diff --git a/spec/ruby/core/array/combination_spec.rb b/spec/ruby/core/array/combination_spec.rb index f16d6f98fc760d..ac570687ca0edf 100644 --- a/spec/ruby/core/array/combination_spec.rb +++ b/spec/ruby/core/array/combination_spec.rb @@ -6,11 +6,11 @@ end it "returns an enumerator when no block is provided" do - @array.combination(2).should be_an_instance_of(Enumerator) + @array.combination(2).should.instance_of?(Enumerator) end it "returns self when a block is given" do - @array.combination(2){}.should equal(@array) + @array.combination(2){}.should.equal?(@array) end it "yields nothing for out of bounds length and return self" do @@ -30,7 +30,7 @@ it "yields a copy of self if the argument is the size of the receiver" do r = @array.combination(4).to_a r.should == [@array] - r[0].should_not equal(@array) + r[0].should_not.equal?(@array) end it "yields [] when length is 0" do diff --git a/spec/ruby/core/array/compact_spec.rb b/spec/ruby/core/array/compact_spec.rb index 83b3fa2a891043..dbcd16da35b554 100644 --- a/spec/ruby/core/array/compact_spec.rb +++ b/spec/ruby/core/array/compact_spec.rb @@ -15,30 +15,30 @@ it "does not return self" do a = [1, 2, 3] - a.compact.should_not equal(a) + a.compact.should_not.equal?(a) end it "does not return subclass instance for Array subclasses" do - ArraySpecs::MyArray[1, 2, 3, nil].compact.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3, nil].compact.should.instance_of?(Array) end end describe "Array#compact!" do it "removes all nil elements" do a = ['a', nil, 'b', false, 'c'] - a.compact!.should equal(a) + a.compact!.should.equal?(a) a.should == ["a", "b", false, "c"] a = [nil, 'a', 'b', false, 'c'] - a.compact!.should equal(a) + a.compact!.should.equal?(a) a.should == ["a", "b", false, "c"] a = ['a', 'b', false, 'c', nil] - a.compact!.should equal(a) + a.compact!.should.equal?(a) a.should == ["a", "b", false, "c"] end it "returns self if some nil elements are removed" do a = ['a', nil, 'b', false, 'c'] - a.compact!.should equal a + a.compact!.should.equal? a end it "returns nil if there are no nil elements to remove" do @@ -46,6 +46,6 @@ end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.compact! }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.compact! }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/comparison_spec.rb b/spec/ruby/core/array/comparison_spec.rb index 5d1c3265f17444..14e8931e5a4e98 100644 --- a/spec/ruby/core/array/comparison_spec.rb +++ b/spec/ruby/core/array/comparison_spec.rb @@ -92,6 +92,6 @@ end it "returns nil when the argument is not array-like" do - ([] <=> false).should be_nil + ([] <=> false).should == nil end end diff --git a/spec/ruby/core/array/concat_spec.rb b/spec/ruby/core/array/concat_spec.rb index f3cab9c17c4ffd..1e8d20c36c20e6 100644 --- a/spec/ruby/core/array/concat_spec.rb +++ b/spec/ruby/core/array/concat_spec.rb @@ -4,12 +4,12 @@ describe "Array#concat" do it "returns the array itself" do ary = [1,2,3] - ary.concat([4,5,6]).equal?(ary).should be_true + ary.concat([4,5,6]).equal?(ary).should == true end it "appends the elements in the other array" do ary = [1, 2, 3] - ary.concat([9, 10, 11]).should equal(ary) + ary.concat([9, 10, 11]).should.equal?(ary) ary.should == [1, 2, 3, 9, 10, 11] ary.concat([]) ary.should == [1, 2, 3, 9, 10, 11] @@ -33,12 +33,12 @@ end it "raises a FrozenError when Array is frozen and modification occurs" do - -> { ArraySpecs.frozen_array.concat [1] }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.concat [1] }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError when Array is frozen and no modification occurs" do - -> { ArraySpecs.frozen_array.concat([]) }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.concat([]) }.should.raise(FrozenError) end it "appends elements to an Array with enough capacity that has been shifted" do @@ -68,7 +68,7 @@ it "returns self when given no arguments" do ary = [1, 2] - ary.concat.should equal(ary) + ary.concat.should.equal?(ary) ary.should == [1, 2] end end diff --git a/spec/ruby/core/array/constructor_spec.rb b/spec/ruby/core/array/constructor_spec.rb index 6f36074c45ecc4..c4398c535d45d5 100644 --- a/spec/ruby/core/array/constructor_spec.rb +++ b/spec/ruby/core/array/constructor_spec.rb @@ -7,7 +7,7 @@ Array.[](5, true, nil, 'a', "Ruby", obj).should == [5, true, nil, "a", "Ruby", obj] a = ArraySpecs::MyArray.[](5, true, nil, 'a', "Ruby", obj) - a.should be_an_instance_of(ArraySpecs::MyArray) + a.should.instance_of?(ArraySpecs::MyArray) a.inspect.should == [5, true, nil, "a", "Ruby", obj].inspect end end @@ -18,7 +18,7 @@ Array[5, true, nil, 'a', "Ruby", obj].should == Array.[](5, true, nil, "a", "Ruby", obj) a = ArraySpecs::MyArray[5, true, nil, 'a', "Ruby", obj] - a.should be_an_instance_of(ArraySpecs::MyArray) + a.should.instance_of?(ArraySpecs::MyArray) a.inspect.should == [5, true, nil, "a", "Ruby", obj].inspect end end diff --git a/spec/ruby/core/array/cycle_spec.rb b/spec/ruby/core/array/cycle_spec.rb index 7219b498839059..29284257e9c70c 100644 --- a/spec/ruby/core/array/cycle_spec.rb +++ b/spec/ruby/core/array/cycle_spec.rb @@ -10,17 +10,17 @@ end it "does not yield and returns nil when the array is empty and passed value is an integer" do - [].cycle(6, &@prc).should be_nil + [].cycle(6, &@prc).should == nil ScratchPad.recorded.should == [] end it "does not yield and returns nil when the array is empty and passed value is nil" do - [].cycle(nil, &@prc).should be_nil + [].cycle(nil, &@prc).should == nil ScratchPad.recorded.should == [] end it "does not yield and returns nil when passed 0" do - @array.cycle(0, &@prc).should be_nil + @array.cycle(0, &@prc).should == nil ScratchPad.recorded.should == [] end @@ -48,13 +48,13 @@ it "does not rescue StopIteration when not passed a count" do -> do @array.cycle { raise StopIteration } - end.should raise_error(StopIteration) + end.should.raise(StopIteration) end it "does not rescue StopIteration when passed a count" do -> do @array.cycle(3) { raise StopIteration } - end.should raise_error(StopIteration) + end.should.raise(StopIteration) end it "iterates the array Integer(count) times when passed a Float count" do @@ -74,23 +74,23 @@ count = mock("cycle count 2") count.should_receive(:to_int).and_return("2") - -> { @array.cycle(count, &@prc) }.should raise_error(TypeError) + -> { @array.cycle(count, &@prc) }.should.raise(TypeError) end it "raises a TypeError if passed a String" do - -> { @array.cycle("4") { } }.should raise_error(TypeError) + -> { @array.cycle("4") { } }.should.raise(TypeError) end it "raises a TypeError if passed an Object" do - -> { @array.cycle(mock("cycle count")) { } }.should raise_error(TypeError) + -> { @array.cycle(mock("cycle count")) { } }.should.raise(TypeError) end it "raises a TypeError if passed true" do - -> { @array.cycle(true) { } }.should raise_error(TypeError) + -> { @array.cycle(true) { } }.should.raise(TypeError) end it "raises a TypeError if passed false" do - -> { @array.cycle(false) { } }.should raise_error(TypeError) + -> { @array.cycle(false) { } }.should.raise(TypeError) end before :all do diff --git a/spec/ruby/core/array/deconstruct_spec.rb b/spec/ruby/core/array/deconstruct_spec.rb index ad67abe47bc7fc..11bb8e72c418b3 100644 --- a/spec/ruby/core/array/deconstruct_spec.rb +++ b/spec/ruby/core/array/deconstruct_spec.rb @@ -4,6 +4,6 @@ it "returns self" do array = [1] - array.deconstruct.should equal array + array.deconstruct.should.equal? array end end diff --git a/spec/ruby/core/array/delete_at_spec.rb b/spec/ruby/core/array/delete_at_spec.rb index 80ec643702672d..1e298b6730d9a0 100644 --- a/spec/ruby/core/array/delete_at_spec.rb +++ b/spec/ruby/core/array/delete_at_spec.rb @@ -36,6 +36,6 @@ end it "raises a FrozenError on a frozen array" do - -> { [1,2,3].freeze.delete_at(0) }.should raise_error(FrozenError) + -> { [1,2,3].freeze.delete_at(0) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/delete_if_spec.rb b/spec/ruby/core/array/delete_if_spec.rb index 10972eee0e6eae..701a612395f734 100644 --- a/spec/ruby/core/array/delete_if_spec.rb +++ b/spec/ruby/core/array/delete_if_spec.rb @@ -17,7 +17,7 @@ end it "returns self" do - @a.delete_if{ true }.equal?(@a).should be_true + @a.delete_if{ true }.equal?(@a).should == true end it_behaves_like :enumeratorize, :delete_if @@ -25,27 +25,27 @@ it "returns self when called on an Array emptied with #shift" do array = [1] array.shift - array.delete_if { |x| true }.should equal(array) + array.delete_if { |x| true }.should.equal?(array) end it "returns an Enumerator if no block given, and the enumerator can modify the original array" do enum = @a.delete_if - enum.should be_an_instance_of(Enumerator) - @a.should_not be_empty + enum.should.instance_of?(Enumerator) + @a.should_not.empty? enum.each { true } - @a.should be_empty + @a.should.empty? end it "returns an Enumerator if no block given, and the array is frozen" do - @a.freeze.delete_if.should be_an_instance_of(Enumerator) + @a.freeze.delete_if.should.instance_of?(Enumerator) end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.delete_if {} }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.delete_if {} }.should.raise(FrozenError) end it "raises a FrozenError on an empty frozen array" do - -> { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(FrozenError) + -> { ArraySpecs.empty_frozen_array.delete_if {} }.should.raise(FrozenError) end it "does not truncate the array is the block raises an exception" do diff --git a/spec/ruby/core/array/delete_spec.rb b/spec/ruby/core/array/delete_spec.rb index dddbbe6bd33553..0d80b2839da08e 100644 --- a/spec/ruby/core/array/delete_spec.rb +++ b/spec/ruby/core/array/delete_spec.rb @@ -41,6 +41,6 @@ def x.==(other) 3 == other end end it "raises a FrozenError on a frozen array" do - -> { [1, 2, 3].freeze.delete(1) }.should raise_error(FrozenError) + -> { [1, 2, 3].freeze.delete(1) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/difference_spec.rb b/spec/ruby/core/array/difference_spec.rb index 9f7d4c4a1a2c8f..63e32feca00422 100644 --- a/spec/ruby/core/array/difference_spec.rb +++ b/spec/ruby/core/array/difference_spec.rb @@ -8,11 +8,11 @@ it "returns a copy when called without any parameter" do x = [1, 2, 3, 2] x.difference.should == x - x.difference.should_not equal x + x.difference.should_not.equal? x end it "does not return subclass instances for Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].difference.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].difference.should.instance_of?(Array) end it "accepts multiple arguments" do diff --git a/spec/ruby/core/array/dig_spec.rb b/spec/ruby/core/array/dig_spec.rb index f2d8ff47fdf14e..4166ff9f1fc3e3 100644 --- a/spec/ruby/core/array/dig_spec.rb +++ b/spec/ruby/core/array/dig_spec.rb @@ -4,7 +4,7 @@ it "returns #at with one arg" do ['a'].dig(0).should == 'a' - ['a'].dig(1).should be_nil + ['a'].dig(1).should == nil end it "recurses array elements" do @@ -22,20 +22,20 @@ it "raises a TypeError for a non-numeric index" do -> { ['a'].dig(:first) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a TypeError if any intermediate step does not respond to #dig" do a = [1, 2] -> { a.dig(0, 1) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises an ArgumentError if no arguments provided" do -> { [10].dig() - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "returns nil if any intermediate step is nil" do diff --git a/spec/ruby/core/array/drop_spec.rb b/spec/ruby/core/array/drop_spec.rb index 5926c291b84d29..c0e1c9edcea4e6 100644 --- a/spec/ruby/core/array/drop_spec.rb +++ b/spec/ruby/core/array/drop_spec.rb @@ -7,7 +7,7 @@ end it "raises an ArgumentError if the number of elements specified is negative" do - -> { [1, 2].drop(-3) }.should raise_error(ArgumentError) + -> { [1, 2].drop(-3) }.should.raise(ArgumentError) end it "returns an empty Array if all elements are dropped" do @@ -40,17 +40,17 @@ end it "raises a TypeError when the passed argument can't be coerced to Integer" do - -> { [1, 2].drop("cat") }.should raise_error(TypeError) + -> { [1, 2].drop("cat") }.should.raise(TypeError) end it "raises a TypeError when the passed argument isn't an integer and #to_int returns non-Integer" do obj = mock("to_int") obj.should_receive(:to_int).and_return("cat") - -> { [1, 2].drop(obj) }.should raise_error(TypeError) + -> { [1, 2].drop(obj) }.should.raise(TypeError) end it 'returns a Array instance for Array subclasses' do - ArraySpecs::MyArray[1, 2, 3, 4, 5].drop(1).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3, 4, 5].drop(1).should.instance_of?(Array) end end diff --git a/spec/ruby/core/array/drop_while_spec.rb b/spec/ruby/core/array/drop_while_spec.rb index bd46e8b882b3a9..4fead3ff065af5 100644 --- a/spec/ruby/core/array/drop_while_spec.rb +++ b/spec/ruby/core/array/drop_while_spec.rb @@ -19,6 +19,6 @@ end it 'returns a Array instance for Array subclasses' do - ArraySpecs::MyArray[1, 2, 3, 4, 5].drop_while { |n| n < 4 }.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3, 4, 5].drop_while { |n| n < 4 }.should.instance_of?(Array) end end diff --git a/spec/ruby/core/array/dup_spec.rb b/spec/ruby/core/array/dup_spec.rb index 17f467d5fc513a..f14aeca3b55248 100644 --- a/spec/ruby/core/array/dup_spec.rb +++ b/spec/ruby/core/array/dup_spec.rb @@ -12,8 +12,8 @@ aa = a.dup bb = b.dup - aa.frozen?.should be_false - bb.frozen?.should be_false + aa.frozen?.should == false + bb.frozen?.should == false end it "does not copy singleton methods" do @@ -23,9 +23,9 @@ def a.a_singleton_method; end aa = a.dup bb = b.dup - a.respond_to?(:a_singleton_method).should be_true - b.respond_to?(:a_singleton_method).should be_false - aa.respond_to?(:a_singleton_method).should be_false - bb.respond_to?(:a_singleton_method).should be_false + a.respond_to?(:a_singleton_method).should == true + b.respond_to?(:a_singleton_method).should == false + aa.respond_to?(:a_singleton_method).should == false + bb.respond_to?(:a_singleton_method).should == false end end diff --git a/spec/ruby/core/array/each_index_spec.rb b/spec/ruby/core/array/each_index_spec.rb index 3a4bca92515cd4..b238a89d8a0e6a 100644 --- a/spec/ruby/core/array/each_index_spec.rb +++ b/spec/ruby/core/array/each_index_spec.rb @@ -20,7 +20,7 @@ it "returns self" do a = [:a, :b, :c] - a.each_index { |i| }.should equal(a) + a.each_index { |i| }.should.equal?(a) end it "is not confused by removing elements from the front" do diff --git a/spec/ruby/core/array/each_spec.rb b/spec/ruby/core/array/each_spec.rb index f4b5b758d0aa9a..73a4c36b17baa3 100644 --- a/spec/ruby/core/array/each_spec.rb +++ b/spec/ruby/core/array/each_spec.rb @@ -13,7 +13,7 @@ it "yields each element to the block" do a = [] x = [1, 2, 3] - x.each { |item| a << item }.should equal(x) + x.each { |item| a << item }.should.equal?(x) a.should == [1, 2, 3] end diff --git a/spec/ruby/core/array/element_reference_spec.rb b/spec/ruby/core/array/element_reference_spec.rb index 31e5578a09394b..eb41a9e199c041 100644 --- a/spec/ruby/core/array/element_reference_spec.rb +++ b/spec/ruby/core/array/element_reference_spec.rb @@ -39,12 +39,12 @@ end it "returns an instance of the subclass" do - ArraySpecs::MyArray[1, 2, 3].should be_an_instance_of(ArraySpecs::MyArray) + ArraySpecs::MyArray[1, 2, 3].should.instance_of?(ArraySpecs::MyArray) end it "does not call #initialize on the subclass instance" do ArraySpecs::MyArray[1, 2, 3].should == [1, 2, 3] - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end end end diff --git a/spec/ruby/core/array/element_set_spec.rb b/spec/ruby/core/array/element_set_spec.rb index df5ca9582e8c80..671e4338de6543 100644 --- a/spec/ruby/core/array/element_set_spec.rb +++ b/spec/ruby/core/array/element_set_spec.rb @@ -95,8 +95,8 @@ it "checks frozen before attempting to coerce arguments" do a = [1,2,3,4].freeze - -> {a[:foo] = 1}.should raise_error(FrozenError) - -> {a[:foo, :bar] = 1}.should raise_error(FrozenError) + -> {a[:foo] = 1}.should.raise(FrozenError) + -> {a[:foo, :bar] = 1}.should.raise(FrozenError) end it "sets elements in the range arguments when passed ranges" do @@ -197,25 +197,25 @@ def to.to_int() -2 end a[to .. from] = ["x"] a.should == [1, "a", "b", "x", "c", 4] - -> { a["a" .. "b"] = [] }.should raise_error(TypeError) - -> { a[from .. "b"] = [] }.should raise_error(TypeError) + -> { a["a" .. "b"] = [] }.should.raise(TypeError) + -> { a[from .. "b"] = [] }.should.raise(TypeError) end it "raises an IndexError when passed indexes out of bounds" do a = [1, 2, 3, 4] - -> { a[-5] = "" }.should raise_error(IndexError) - -> { a[-5, -1] = "" }.should raise_error(IndexError) - -> { a[-5, 0] = "" }.should raise_error(IndexError) - -> { a[-5, 1] = "" }.should raise_error(IndexError) - -> { a[-5, 2] = "" }.should raise_error(IndexError) - -> { a[-5, 10] = "" }.should raise_error(IndexError) - - -> { a[-5..-5] = "" }.should raise_error(RangeError) - -> { a[-5...-5] = "" }.should raise_error(RangeError) - -> { a[-5..-4] = "" }.should raise_error(RangeError) - -> { a[-5...-4] = "" }.should raise_error(RangeError) - -> { a[-5..10] = "" }.should raise_error(RangeError) - -> { a[-5...10] = "" }.should raise_error(RangeError) + -> { a[-5] = "" }.should.raise(IndexError) + -> { a[-5, -1] = "" }.should.raise(IndexError) + -> { a[-5, 0] = "" }.should.raise(IndexError) + -> { a[-5, 1] = "" }.should.raise(IndexError) + -> { a[-5, 2] = "" }.should.raise(IndexError) + -> { a[-5, 10] = "" }.should.raise(IndexError) + + -> { a[-5..-5] = "" }.should.raise(RangeError) + -> { a[-5...-5] = "" }.should.raise(RangeError) + -> { a[-5..-4] = "" }.should.raise(RangeError) + -> { a[-5...-4] = "" }.should.raise(RangeError) + -> { a[-5..10] = "" }.should.raise(RangeError) + -> { a[-5...10] = "" }.should.raise(RangeError) # ok a[0..-9] = [1] @@ -239,7 +239,7 @@ def obj.to_ary() [1, 2, 3] end end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array[0, 0] = [] }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array[0, 0] = [] }.should.raise(FrozenError) end end @@ -349,12 +349,12 @@ def obj.to_ary() [1, 2, 3] end it "raises an IndexError when passed start and negative length" do a = [1, 2, 3, 4] - -> { a[-2, -1] = "" }.should raise_error(IndexError) - -> { a[0, -1] = "" }.should raise_error(IndexError) - -> { a[2, -1] = "" }.should raise_error(IndexError) - -> { a[4, -1] = "" }.should raise_error(IndexError) - -> { a[10, -1] = "" }.should raise_error(IndexError) - -> { [1, 2, 3, 4, 5][2, -1] = [7, 8] }.should raise_error(IndexError) + -> { a[-2, -1] = "" }.should.raise(IndexError) + -> { a[0, -1] = "" }.should.raise(IndexError) + -> { a[2, -1] = "" }.should.raise(IndexError) + -> { a[4, -1] = "" }.should.raise(IndexError) + -> { a[10, -1] = "" }.should.raise(IndexError) + -> { [1, 2, 3, 4, 5][2, -1] = [7, 8] }.should.raise(IndexError) end end diff --git a/spec/ruby/core/array/eql_spec.rb b/spec/ruby/core/array/eql_spec.rb index 8565b94c60a9b1..9a7447c2e8c56e 100644 --- a/spec/ruby/core/array/eql_spec.rb +++ b/spec/ruby/core/array/eql_spec.rb @@ -6,7 +6,7 @@ it_behaves_like :array_eql, :eql? it "returns false if any corresponding elements are not #eql?" do - [1, 2, 3, 4].should_not eql([1, 2, 3, 4.0]) + [1, 2, 3, 4].should_not.eql?([1, 2, 3, 4.0]) end it "returns false if other is not a kind of Array" do @@ -14,6 +14,6 @@ obj.should_not_receive(:to_ary) obj.should_not_receive(:eql?) - [1, 2, 3].should_not eql(obj) + [1, 2, 3].should_not.eql?(obj) end end diff --git a/spec/ruby/core/array/equal_value_spec.rb b/spec/ruby/core/array/equal_value_spec.rb index a82e07b218981d..4f7c0ce5e33823 100644 --- a/spec/ruby/core/array/equal_value_spec.rb +++ b/spec/ruby/core/array/equal_value_spec.rb @@ -10,17 +10,17 @@ obj.should_receive(:respond_to?).at_least(1).with(:to_ary).and_return(true) obj.should_receive(:==).with([1]).at_least(1).and_return(true) - ([1] == obj).should be_true - ([[1]] == [obj]).should be_true - ([[[1], 3], 2] == [[obj, 3], 2]).should be_true + ([1] == obj).should == true + ([[1]] == [obj]).should == true + ([[[1], 3], 2] == [[obj, 3], 2]).should == true # recursive arrays arr1 = [[1]] arr1 << arr1 arr2 = [obj] arr2 << arr2 - (arr1 == arr2).should be_true - (arr2 == arr1).should be_true + (arr1 == arr2).should == true + (arr2 == arr1).should == true end it "returns false if any corresponding elements are not #==" do diff --git a/spec/ruby/core/array/fetch_spec.rb b/spec/ruby/core/array/fetch_spec.rb index 598b481ba46a11..ee94cfcbb2357e 100644 --- a/spec/ruby/core/array/fetch_spec.rb +++ b/spec/ruby/core/array/fetch_spec.rb @@ -12,9 +12,9 @@ end it "raises an IndexError if there is no element at index" do - -> { [1, 2, 3].fetch(3) }.should raise_error(IndexError, "index 3 outside of array bounds: -3...3") - -> { [1, 2, 3].fetch(-4) }.should raise_error(IndexError, "index -4 outside of array bounds: -3...3") - -> { [].fetch(0) }.should raise_error(IndexError, "index 0 outside of array bounds: 0...0") + -> { [1, 2, 3].fetch(3) }.should.raise(IndexError, "index 3 outside of array bounds: -3...3") + -> { [1, 2, 3].fetch(-4) }.should.raise(IndexError, "index -4 outside of array bounds: -3...3") + -> { [].fetch(0) }.should.raise(IndexError, "index 0 outside of array bounds: 0...0") end it "returns default if there is no element at index if passed a default value" do @@ -33,7 +33,7 @@ o = mock('5') def o.to_int(); 5; end - [1, 2, 3].fetch(o) { |i| i }.should equal(o) + [1, 2, 3].fetch(o) { |i| i }.should.equal?(o) end it "gives precedence to the default block over the default argument" do @@ -50,6 +50,6 @@ def o.to_int(); 5; end end it "raises a TypeError when the passed argument can't be coerced to Integer" do - -> { [].fetch("cat") }.should raise_error(TypeError, "no implicit conversion of String into Integer") + -> { [].fetch("cat") }.should.raise(TypeError, "no implicit conversion of String into Integer") end end diff --git a/spec/ruby/core/array/fetch_values_spec.rb b/spec/ruby/core/array/fetch_values_spec.rb index cf377b3b716476..237d6ad7f7a35f 100644 --- a/spec/ruby/core/array/fetch_values_spec.rb +++ b/spec/ruby/core/array/fetch_values_spec.rb @@ -21,7 +21,7 @@ describe "with unmatched indexes" do it "raises a index error if no block is provided" do - -> { @array.fetch_values(0, 1, 44) }.should raise_error(IndexError, "index 44 outside of array bounds: -3...3") + -> { @array.fetch_values(0, 1, 44) }.should.raise(IndexError, "index 44 outside of array bounds: -3...3") end it "returns the default value from block" do @@ -45,11 +45,11 @@ it "does not support a Range object as argument" do -> { @array.fetch_values(1..2) - }.should raise_error(TypeError, "no implicit conversion of Range into Integer") + }.should.raise(TypeError, "no implicit conversion of Range into Integer") end it "raises a TypeError when the passed argument can't be coerced to Integer" do - -> { [].fetch_values("cat") }.should raise_error(TypeError, "no implicit conversion of String into Integer") + -> { [].fetch_values("cat") }.should.raise(TypeError, "no implicit conversion of String into Integer") end end end diff --git a/spec/ruby/core/array/fill_spec.rb b/spec/ruby/core/array/fill_spec.rb index 2c3b5d9e84b6d3..e4d51bd9985be7 100644 --- a/spec/ruby/core/array/fill_spec.rb +++ b/spec/ruby/core/array/fill_spec.rb @@ -10,7 +10,7 @@ it "returns self" do ary = [1, 2, 3] - ary.fill(:a).should equal(ary) + ary.fill(:a).should.equal?(ary) end it "is destructive" do @@ -25,10 +25,10 @@ ary.fill(str).should == [str, str, str, str] str << "y" ary.should == [str, str, str, str] - ary[0].should equal(str) - ary[1].should equal(str) - ary[2].should equal(str) - ary[3].should equal(str) + ary[0].should.equal?(str) + ary[1].should.equal?(str) + ary[2].should.equal?(str) + ary[3].should.equal?(str) end it "replaces all elements in the array with the filler if not given a index nor a length" do @@ -44,29 +44,29 @@ end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.fill('x') }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.fill('x') }.should.raise(FrozenError) end it "raises a FrozenError on an empty frozen array" do - -> { ArraySpecs.empty_frozen_array.fill('x') }.should raise_error(FrozenError) + -> { ArraySpecs.empty_frozen_array.fill('x') }.should.raise(FrozenError) end it "raises an ArgumentError if 4 or more arguments are passed when no block given" do [].fill('a').should == [] [].fill('a', 1).should == [] [].fill('a', 1, 2).should == [nil, 'a', 'a'] - -> { [].fill('a', 1, 2, true) }.should raise_error(ArgumentError) + -> { [].fill('a', 1, 2, true) }.should.raise(ArgumentError) end it "raises an ArgumentError if no argument passed and no block given" do - -> { [].fill }.should raise_error(ArgumentError) + -> { [].fill }.should.raise(ArgumentError) end it "raises an ArgumentError if 3 or more arguments are passed when a block given" do [].fill() {|i|}.should == [] [].fill(1) {|i|}.should == [] [].fill(1, 2) {|i|}.should == [nil, nil, nil] - -> { [].fill(1, 2, true) {|i|} }.should raise_error(ArgumentError) + -> { [].fill(1, 2, true) {|i|} }.should.raise(ArgumentError) end it "does not truncate the array is the block raises an exception" do @@ -237,24 +237,24 @@ end it "raises a TypeError if the index is not numeric" do - -> { [].fill 'a', true }.should raise_error(TypeError) + -> { [].fill 'a', true }.should.raise(TypeError) obj = mock('nonnumeric') - -> { [].fill('a', obj) }.should raise_error(TypeError) + -> { [].fill('a', obj) }.should.raise(TypeError) end it "raises a TypeError when the length is not numeric" do - -> { [1, 2, 3].fill("x", 1, "foo") }.should raise_error(TypeError, /no implicit conversion of String into Integer/) - -> { [1, 2, 3].fill("x", 1, :"foo") }.should raise_error(TypeError, /no implicit conversion of Symbol into Integer/) - -> { [1, 2, 3].fill("x", 1, Object.new) }.should raise_error(TypeError, /no implicit conversion of Object into Integer/) + -> { [1, 2, 3].fill("x", 1, "foo") }.should.raise(TypeError, /no implicit conversion of String into Integer/) + -> { [1, 2, 3].fill("x", 1, :"foo") }.should.raise(TypeError, /no implicit conversion of Symbol into Integer/) + -> { [1, 2, 3].fill("x", 1, Object.new) }.should.raise(TypeError, /no implicit conversion of Object into Integer/) end not_supported_on :opal do it "raises an ArgumentError or RangeError for too-large sizes" do error_types = [RangeError, ArgumentError] arr = [1, 2, 3] - -> { arr.fill(10, 1, fixnum_max) }.should raise_error { |err| error_types.should include(err.class) } - -> { arr.fill(10, 1, bignum_value) }.should raise_error(RangeError) + -> { arr.fill(10, 1, fixnum_max) }.should.raise { |err| error_types.should.include?(err.class) } + -> { arr.fill(10, 1, bignum_value) }.should.raise(RangeError) end end end @@ -284,7 +284,7 @@ end it "raises a TypeError with range and length argument" do - -> { [].fill('x', 0 .. 2, 5) }.should raise_error(TypeError) + -> { [].fill('x', 0 .. 2, 5) }.should.raise(TypeError) end it "replaces elements between the (-m)th to the last and the (n+1)th from the first if given an range m..n where m < 0 and n >= 0" do @@ -336,13 +336,13 @@ end it "raises an exception if some of the given range lies before the first of the array" do - -> { [1, 2, 3].fill('x', -5..-3) }.should raise_error(RangeError) - -> { [1, 2, 3].fill('x', -5...-3) }.should raise_error(RangeError) - -> { [1, 2, 3].fill('x', -5..-4) }.should raise_error(RangeError) + -> { [1, 2, 3].fill('x', -5..-3) }.should.raise(RangeError) + -> { [1, 2, 3].fill('x', -5...-3) }.should.raise(RangeError) + -> { [1, 2, 3].fill('x', -5..-4) }.should.raise(RangeError) - -> { [1, 2, 3].fill(-5..-3, &@never_passed) }.should raise_error(RangeError) - -> { [1, 2, 3].fill(-5...-3, &@never_passed) }.should raise_error(RangeError) - -> { [1, 2, 3].fill(-5..-4, &@never_passed) }.should raise_error(RangeError) + -> { [1, 2, 3].fill(-5..-3, &@never_passed) }.should.raise(RangeError) + -> { [1, 2, 3].fill(-5...-3, &@never_passed) }.should.raise(RangeError) + -> { [1, 2, 3].fill(-5..-4, &@never_passed) }.should.raise(RangeError) end it "tries to convert the start and end of the passed range to Integers using #to_int" do @@ -357,7 +357,7 @@ def obj.<=>(rhs); rhs == self ? 0 : nil end it "raises a TypeError if the start or end of the passed range is not numeric" do obj = mock('nonnumeric') def obj.<=>(rhs); rhs == self ? 0 : nil end - -> { [].fill('a', obj..obj) }.should raise_error(TypeError) + -> { [].fill('a', obj..obj) }.should.raise(TypeError) end it "works with endless ranges" do diff --git a/spec/ruby/core/array/filter_spec.rb b/spec/ruby/core/array/filter_spec.rb index 156ad14f9c71d7..7807c3886d4929 100644 --- a/spec/ruby/core/array/filter_spec.rb +++ b/spec/ruby/core/array/filter_spec.rb @@ -7,7 +7,7 @@ describe "Array#filter!" do it "returns nil if no changes were made in the array" do - [1, 2, 3].filter! { true }.should be_nil + [1, 2, 3].filter! { true }.should == nil end it_behaves_like :keep_if, :filter! diff --git a/spec/ruby/core/array/first_spec.rb b/spec/ruby/core/array/first_spec.rb index 66eeba65653d73..2c343ac8f67bfe 100644 --- a/spec/ruby/core/array/first_spec.rb +++ b/spec/ruby/core/array/first_spec.rb @@ -30,11 +30,11 @@ end it "raises an ArgumentError when count is negative" do - -> { [1, 2].first(-1) }.should raise_error(ArgumentError) + -> { [1, 2].first(-1) }.should.raise(ArgumentError) end it "raises a RangeError when count is a Bignum" do - -> { [].first(bignum_value) }.should raise_error(RangeError) + -> { [].first(bignum_value) }.should.raise(RangeError) end it "returns the entire array when count > length" do @@ -53,10 +53,10 @@ it "properly handles recursive arrays" do empty = ArraySpecs.empty_recursive_array - empty.first.should equal(empty) + empty.first.should.equal?(empty) ary = ArraySpecs.head_recursive_array - ary.first.should equal(ary) + ary.first.should.equal?(ary) end it "tries to convert the passed argument to an Integer using #to_int" do @@ -66,19 +66,19 @@ end it "raises a TypeError if the passed argument is not numeric" do - -> { [1,2].first(nil) }.should raise_error(TypeError) - -> { [1,2].first("a") }.should raise_error(TypeError) + -> { [1,2].first(nil) }.should.raise(TypeError) + -> { [1,2].first("a") }.should.raise(TypeError) obj = mock("nonnumeric") - -> { [1,2].first(obj) }.should raise_error(TypeError) + -> { [1,2].first(obj) }.should.raise(TypeError) end it "does not return subclass instance when passed count on Array subclasses" do - ArraySpecs::MyArray[].first(0).should be_an_instance_of(Array) - ArraySpecs::MyArray[].first(2).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].first(0).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].first(1).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].first(2).should be_an_instance_of(Array) + ArraySpecs::MyArray[].first(0).should.instance_of?(Array) + ArraySpecs::MyArray[].first(2).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].first(0).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].first(1).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].first(2).should.instance_of?(Array) end it "is not destructive" do diff --git a/spec/ruby/core/array/flatten_spec.rb b/spec/ruby/core/array/flatten_spec.rb index 8c97000c79cf47..272406b8f95f31 100644 --- a/spec/ruby/core/array/flatten_spec.rb +++ b/spec/ruby/core/array/flatten_spec.rb @@ -13,7 +13,7 @@ it "returns dup when the level of recursion is 0" do a = [ 1, 2, [3, [4, 5] ] ] a.flatten(0).should == a - a.flatten(0).should_not equal(a) + a.flatten(0).should_not.equal?(a) end it "ignores negative levels" do @@ -30,7 +30,7 @@ it "raises a TypeError when the passed Object can't be converted to an Integer" do obj = mock("Not converted") - -> { [ 1, 2, [3, [4, 5] ] ].flatten(obj) }.should raise_error(TypeError) + -> { [ 1, 2, [3, [4, 5] ] ].flatten(obj) }.should.raise(TypeError) end it "does not call flatten on elements" do @@ -46,13 +46,13 @@ it "raises an ArgumentError on recursive arrays" do x = [] x << x - -> { x.flatten }.should raise_error(ArgumentError) + -> { x.flatten }.should.raise(ArgumentError) x = [] y = [] x << y y << x - -> { x.flatten }.should raise_error(ArgumentError) + -> { x.flatten }.should.raise(ArgumentError) end it "flattens any element which responds to #to_ary, using the return value of said method" do @@ -76,11 +76,11 @@ end it "returns Array instance for Array subclasses" do - ArraySpecs::MyArray[].flatten.should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].flatten.should be_an_instance_of(Array) - ArraySpecs::MyArray[1, [2], 3].flatten.should be_an_instance_of(Array) + ArraySpecs::MyArray[].flatten.should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].flatten.should.instance_of?(Array) + ArraySpecs::MyArray[1, [2], 3].flatten.should.instance_of?(Array) ArraySpecs::MyArray[1, [2, 3], 4].flatten.should == [1, 2, 3, 4] - [ArraySpecs::MyArray[1, 2, 3]].flatten.should be_an_instance_of(Array) + [ArraySpecs::MyArray[1, 2, 3]].flatten.should.instance_of?(Array) end it "is not destructive" do @@ -106,7 +106,7 @@ it "raises a TypeError if #to_ary does not return an Array" do @obj.should_receive(:to_ary).and_return(1) - -> { [@obj].flatten }.should raise_error(TypeError) + -> { [@obj].flatten }.should.raise(TypeError) end it "calls respond_to_missing?(:to_ary, true) to try coercing" do @@ -125,7 +125,7 @@ def @obj.respond_to_missing?(name, priv) ScratchPad << name; false end it "calls #to_ary if not defined when #respond_to_missing? returns true" do def @obj.respond_to_missing?(name, priv) ScratchPad << name; true end - -> { [@obj].flatten }.should raise_error(NoMethodError) + -> { [@obj].flatten }.should.raise(NoMethodError) ScratchPad.recorded.should == [:to_ary] end @@ -168,7 +168,7 @@ def bo.respond_to?(name, *) it "returns self if made some modifications" do a = [[[1, [2, 3]],[2, 3, [4, [4, [5, 5]], [1, 2, 3]]], [4]], []] - a.flatten!.should equal(a) + a.flatten!.should.equal?(a) end it "returns nil if no modifications took place" do @@ -208,7 +208,7 @@ def bo.respond_to?(name, *) it "raises a TypeError when the passed Object can't be converted to an Integer" do obj = mock("Not converted") - -> { [ 1, 2, [3, [4, 5] ] ].flatten!(obj) }.should raise_error(TypeError) + -> { [ 1, 2, [3, [4, 5] ] ].flatten!(obj) }.should.raise(TypeError) end it "does not call flatten! on elements" do @@ -224,13 +224,13 @@ def bo.respond_to?(name, *) it "raises an ArgumentError on recursive arrays" do x = [] x << x - -> { x.flatten! }.should raise_error(ArgumentError) + -> { x.flatten! }.should.raise(ArgumentError) x = [] y = [] x << y y << x - -> { x.flatten! }.should raise_error(ArgumentError) + -> { x.flatten! }.should.raise(ArgumentError) end it "flattens any elements which responds to #to_ary, using the return value of said method" do @@ -248,19 +248,19 @@ def bo.respond_to?(name, *) ary = [ArraySpecs::MyArray[1, 2, 3]] ary.flatten! - ary.should be_an_instance_of(Array) + ary.should.instance_of?(Array) ary.should == [1, 2, 3] end it "raises a FrozenError on frozen arrays when the array is modified" do nested_ary = [1, 2, []] nested_ary.freeze - -> { nested_ary.flatten! }.should raise_error(FrozenError) + -> { nested_ary.flatten! }.should.raise(FrozenError) end # see [ruby-core:23663] it "raises a FrozenError on frozen arrays when the array would not be modified" do - -> { ArraySpecs.frozen_array.flatten! }.should raise_error(FrozenError) - -> { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.flatten! }.should.raise(FrozenError) + -> { ArraySpecs.empty_frozen_array.flatten! }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/hash_spec.rb b/spec/ruby/core/array/hash_spec.rb index f3bcc83fce8c88..3b7b6d5bedbe66 100644 --- a/spec/ruby/core/array/hash_spec.rb +++ b/spec/ruby/core/array/hash_spec.rb @@ -7,16 +7,16 @@ [[], [1, 2, 3]].each do |ary| ary.hash.should == ary.dup.hash - ary.hash.should be_an_instance_of(Integer) + ary.hash.should.instance_of?(Integer) end end it "properly handles recursive arrays" do empty = ArraySpecs.empty_recursive_array - -> { empty.hash }.should_not raise_error + -> { empty.hash }.should_not.raise array = ArraySpecs.recursive_array - -> { array.hash }.should_not raise_error + -> { array.hash }.should_not.raise end it "returns the same hash for equal recursive arrays" do @@ -74,7 +74,7 @@ def obj.hash() @hash end a.fill 'a', 0..3 b = %w|a a a a| a.hash.should == b.hash - a.should eql(b) + a.should.eql?(b) end it "produces different hashes for nested arrays with different values and empty terminator" do diff --git a/spec/ruby/core/array/initialize_spec.rb b/spec/ruby/core/array/initialize_spec.rb index b9fa77b16ebe4c..19ee37825e0098 100644 --- a/spec/ruby/core/array/initialize_spec.rb +++ b/spec/ruby/core/array/initialize_spec.rb @@ -7,7 +7,7 @@ end it "is private" do - Array.should have_private_instance_method("initialize") + Array.private_instance_methods(false).should.include?(:initialize) end it "is called on subclasses" do @@ -19,26 +19,26 @@ it "preserves the object's identity even when changing its value" do a = [1, 2, 3] - a.send(:initialize).should equal(a) + a.send(:initialize).should.equal?(a) a.should_not == [1, 2, 3] end it "raises an ArgumentError if passed 3 or more arguments" do -> do [1, 2].send :initialize, 1, 'x', true - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) -> do [1, 2].send(:initialize, 1, 'x', true) {} - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises a FrozenError on frozen arrays" do -> do ArraySpecs.frozen_array.send :initialize - end.should raise_error(FrozenError) + end.should.raise(FrozenError) -> do ArraySpecs.frozen_array.send :initialize, ArraySpecs.frozen_array - end.should raise_error(FrozenError) + end.should.raise(FrozenError) end it "calls #to_ary to convert the value to an array, even if it's private" do @@ -49,12 +49,12 @@ describe "Array#initialize with no arguments" do it "makes the array empty" do - [1, 2, 3].send(:initialize).should be_empty + [1, 2, 3].send(:initialize).should.empty? end it "does not use the given block" do -> { - -> { [1, 2, 3].send(:initialize) { raise } }.should_not raise_error + -> { [1, 2, 3].send(:initialize) { raise } }.should_not.raise }.should complain(/#{__FILE__}:#{__LINE__-1}: warning: given block not used/, verbose: true) end end @@ -66,7 +66,7 @@ end it "does not use the given block" do - ->{ [1, 2, 3].send(:initialize) { raise } }.should_not raise_error + ->{ [1, 2, 3].send(:initialize) { raise } }.should_not.raise end it "calls #to_ary to convert the value to an array" do @@ -83,7 +83,7 @@ end it "raises a TypeError if an Array type argument and a default object" do - -> { [].send(:initialize, [1, 2], 1) }.should raise_error(TypeError) + -> { [].send(:initialize, [1, 2], 1) }.should.raise(TypeError) end end @@ -92,8 +92,8 @@ a = [] obj = [3] a.send(:initialize, 2, obj).should == [obj, obj] - a[0].should equal(obj) - a[1].should equal(obj) + a[0].should.equal?(obj) + a[1].should.equal?(obj) b = [] b.send(:initialize, 3, 14).should == [14, 14, 14] @@ -105,12 +105,12 @@ end it "raises an ArgumentError if size is negative" do - -> { [].send(:initialize, -1, :a) }.should raise_error(ArgumentError) - -> { [].send(:initialize, -1) }.should raise_error(ArgumentError) + -> { [].send(:initialize, -1, :a) }.should.raise(ArgumentError) + -> { [].send(:initialize, -1) }.should.raise(ArgumentError) end it "raises an ArgumentError if size is too large" do - -> { [].send(:initialize, fixnum_max+1) }.should raise_error(ArgumentError) + -> { [].send(:initialize, fixnum_max+1) }.should.raise(ArgumentError) end it "calls #to_int to convert the size argument to an Integer when object is given" do @@ -128,7 +128,7 @@ it "raises a TypeError if the size argument is not an Integer type" do obj = mock('nonnumeric') obj.stub!(:to_ary).and_return([1, 2]) - ->{ [].send(:initialize, obj, :a) }.should raise_error(TypeError) + ->{ [].send(:initialize, obj, :a) }.should.raise(TypeError) end it "yields the index of the element and sets the element to the value of the block" do diff --git a/spec/ruby/core/array/insert_spec.rb b/spec/ruby/core/array/insert_spec.rb index 9e1757f68b447c..38e132fd259dd4 100644 --- a/spec/ruby/core/array/insert_spec.rb +++ b/spec/ruby/core/array/insert_spec.rb @@ -4,8 +4,8 @@ describe "Array#insert" do it "returns self" do ary = [] - ary.insert(0).should equal(ary) - ary.insert(0, :a).should equal(ary) + ary.insert(0).should.equal?(ary) + ary.insert(0, :a).should.equal?(ary) end it "inserts objects before the element at index for non-negative index" do @@ -46,8 +46,8 @@ end it "raises an IndexError if the negative index is out of bounds" do - -> { [].insert(-2, 1) }.should raise_error(IndexError) - -> { [1].insert(-3, 2) }.should raise_error(IndexError) + -> { [].insert(-2, 1) }.should.raise(IndexError) + -> { [1].insert(-3, 2) }.should.raise(IndexError) end it "does nothing of no object is passed" do @@ -64,15 +64,15 @@ end it "raises an ArgumentError if no argument passed" do - -> { [].insert() }.should raise_error(ArgumentError) + -> { [].insert() }.should.raise(ArgumentError) end it "raises a FrozenError on frozen arrays when the array is modified" do - -> { ArraySpecs.frozen_array.insert(0, 'x') }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.insert(0, 'x') }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on frozen arrays when the array would not be modified" do - -> { ArraySpecs.frozen_array.insert(0) }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.insert(0) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/join_spec.rb b/spec/ruby/core/array/join_spec.rb index e78ea6f9e1132f..811db036a844c5 100644 --- a/spec/ruby/core/array/join_spec.rb +++ b/spec/ruby/core/array/join_spec.rb @@ -24,11 +24,11 @@ it "raises a TypeError if the separator cannot be coerced to a String by calling #to_str" do obj = mock("not a string") - -> { [1, 2].join(obj) }.should raise_error(TypeError) + -> { [1, 2].join(obj) }.should.raise(TypeError) end it "raises a TypeError if passed false as the separator" do - -> { [1, 2].join(false) }.should raise_error(TypeError) + -> { [1, 2].join(false) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/array/keep_if_spec.rb b/spec/ruby/core/array/keep_if_spec.rb index 40f7329b7c8e81..62a65a04e85a54 100644 --- a/spec/ruby/core/array/keep_if_spec.rb +++ b/spec/ruby/core/array/keep_if_spec.rb @@ -4,7 +4,7 @@ describe "Array#keep_if" do it "returns the same array if no changes were made" do array = [1, 2, 3] - array.keep_if { true }.should equal(array) + array.keep_if { true }.should.equal?(array) end it_behaves_like :keep_if, :keep_if diff --git a/spec/ruby/core/array/last_spec.rb b/spec/ruby/core/array/last_spec.rb index d6fefada092772..ed417bcd2ab2f0 100644 --- a/spec/ruby/core/array/last_spec.rb +++ b/spec/ruby/core/array/last_spec.rb @@ -28,7 +28,7 @@ end it "raises an ArgumentError when count is negative" do - -> { [1, 2].last(-1) }.should raise_error(ArgumentError) + -> { [1, 2].last(-1) }.should.raise(ArgumentError) end it "returns the entire array when count > length" do @@ -47,10 +47,10 @@ it "properly handles recursive arrays" do empty = ArraySpecs.empty_recursive_array - empty.last.should equal(empty) + empty.last.should.equal?(empty) array = ArraySpecs.recursive_array - array.last.should equal(array) + array.last.should.equal?(array) end it "tries to convert the passed argument to an Integer using #to_int" do @@ -60,19 +60,19 @@ end it "raises a TypeError if the passed argument is not numeric" do - -> { [1,2].last(nil) }.should raise_error(TypeError) - -> { [1,2].last("a") }.should raise_error(TypeError) + -> { [1,2].last(nil) }.should.raise(TypeError) + -> { [1,2].last("a") }.should.raise(TypeError) obj = mock("nonnumeric") - -> { [1,2].last(obj) }.should raise_error(TypeError) + -> { [1,2].last(obj) }.should.raise(TypeError) end it "does not return subclass instance on Array subclasses" do - ArraySpecs::MyArray[].last(0).should be_an_instance_of(Array) - ArraySpecs::MyArray[].last(2).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].last(0).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].last(1).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].last(2).should be_an_instance_of(Array) + ArraySpecs::MyArray[].last(0).should.instance_of?(Array) + ArraySpecs::MyArray[].last(2).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].last(0).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].last(1).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].last(2).should.instance_of?(Array) end it "is not destructive" do diff --git a/spec/ruby/core/array/max_spec.rb b/spec/ruby/core/array/max_spec.rb index d1c64519d0b62b..868275a74852a9 100644 --- a/spec/ruby/core/array/max_spec.rb +++ b/spec/ruby/core/array/max_spec.rb @@ -2,7 +2,7 @@ describe "Array#max" do it "is defined on Array" do - [1].method(:max).owner.should equal Array + [1].method(:max).owner.should.equal? Array end it "returns nil with no values" do @@ -70,16 +70,16 @@ it "raises a NoMethodError for elements without #<=>" do -> do [BasicObject.new, BasicObject.new].max - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end it "raises an ArgumentError for incomparable elements" do -> do [11,"22"].max - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) -> do [11,12,22,33].max{|a, b| nil} - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "returns the maximum element (with block)" do diff --git a/spec/ruby/core/array/min_spec.rb b/spec/ruby/core/array/min_spec.rb index 3bdef0dd0090a6..5913e08cf80a21 100644 --- a/spec/ruby/core/array/min_spec.rb +++ b/spec/ruby/core/array/min_spec.rb @@ -2,7 +2,7 @@ describe "Array#min" do it "is defined on Array" do - [1].method(:max).owner.should equal Array + [1].method(:max).owner.should.equal? Array end it "returns nil with no values" do @@ -64,22 +64,22 @@ end it "returns nil for an empty Enumerable" do - [].min.should be_nil + [].min.should == nil end it "raises a NoMethodError for elements without #<=>" do -> do [BasicObject.new, BasicObject.new].min - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end it "raises an ArgumentError for incomparable elements" do -> do [11,"22"].min - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) -> do [11,12,22,33].min{|a, b| nil} - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "returns the minimum when using a block rule" do diff --git a/spec/ruby/core/array/multiply_spec.rb b/spec/ruby/core/array/multiply_spec.rb index eca51142fb2cc0..1ac14e1b09bc3e 100644 --- a/spec/ruby/core/array/multiply_spec.rb +++ b/spec/ruby/core/array/multiply_spec.rb @@ -17,7 +17,7 @@ it "raises a TypeError if the argument can neither be converted to a string nor an integer" do obj = mock('not a string or integer') - ->{ [1,2] * obj }.should raise_error(TypeError) + ->{ [1,2] * obj }.should.raise(TypeError) end it "converts the passed argument to a String rather than an Integer" do @@ -28,15 +28,15 @@ def obj.to_str() "2" end end it "raises a TypeError is the passed argument is nil" do - ->{ [1,2] * nil }.should raise_error(TypeError) + ->{ [1,2] * nil }.should.raise(TypeError) end it "raises an ArgumentError when passed 2 or more arguments" do - ->{ [1,2].send(:*, 1, 2) }.should raise_error(ArgumentError) + ->{ [1,2].send(:*, 1, 2) }.should.raise(ArgumentError) end it "raises an ArgumentError when passed no arguments" do - ->{ [1,2].send(:*) }.should raise_error(ArgumentError) + ->{ [1,2].send(:*) }.should.raise(ArgumentError) end end @@ -50,7 +50,7 @@ def obj.to_str() "2" end it "does not return self even if the passed integer is 1" do ary = [1, 2, 3] - (ary * 1).should_not equal(ary) + (ary * 1).should_not.equal?(ary) end it "properly handles recursive arrays" do @@ -65,8 +65,8 @@ def obj.to_str() "2" end end it "raises an ArgumentError when passed a negative integer" do - -> { [ 1, 2, 3 ] * -1 }.should raise_error(ArgumentError) - -> { [] * -1 }.should raise_error(ArgumentError) + -> { [ 1, 2, 3 ] * -1 }.should.raise(ArgumentError) + -> { [] * -1 }.should.raise(ArgumentError) end describe "with a subclass of Array" do @@ -77,14 +77,14 @@ def obj.to_str() "2" end end it "returns an Array instance" do - (@array * 0).should be_an_instance_of(Array) - (@array * 1).should be_an_instance_of(Array) - (@array * 2).should be_an_instance_of(Array) + (@array * 0).should.instance_of?(Array) + (@array * 1).should.instance_of?(Array) + (@array * 2).should.instance_of?(Array) end it "does not call #initialize on the subclass instance" do (@array * 2).should == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end end end diff --git a/spec/ruby/core/array/new_spec.rb b/spec/ruby/core/array/new_spec.rb index b50a4857b0fa44..b2f23e2f6b1fa4 100644 --- a/spec/ruby/core/array/new_spec.rb +++ b/spec/ruby/core/array/new_spec.rb @@ -3,31 +3,31 @@ describe "Array.new" do it "returns an instance of Array" do - Array.new.should be_an_instance_of(Array) + Array.new.should.instance_of?(Array) end it "returns an instance of a subclass" do - ArraySpecs::MyArray.new(1, 2).should be_an_instance_of(ArraySpecs::MyArray) + ArraySpecs::MyArray.new(1, 2).should.instance_of?(ArraySpecs::MyArray) end it "raises an ArgumentError if passed 3 or more arguments" do -> do [1, 2].send :initialize, 1, 'x', true - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) -> do [1, 2].send(:initialize, 1, 'x', true) {} - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end end describe "Array.new with no arguments" do it "returns an empty array" do - Array.new.should be_empty + Array.new.should.empty? end it "does not use the given block" do -> { - -> { Array.new { raise } }.should_not raise_error + -> { Array.new { raise } }.should_not.raise }.should complain(/warning: given block not used/, verbose: true) end end @@ -39,7 +39,7 @@ end it "does not use the given block" do - ->{ Array.new([1, 2]) { raise } }.should_not raise_error + ->{ Array.new([1, 2]) { raise } }.should_not.raise end it "calls #to_ary to convert the value to an array" do @@ -56,7 +56,7 @@ end it "raises a TypeError if an Array type argument and a default object" do - -> { Array.new([1, 2], 1) }.should raise_error(TypeError) + -> { Array.new([1, 2], 1) }.should.raise(TypeError) end end @@ -65,8 +65,8 @@ obj = [3] a = Array.new(2, obj) a.should == [obj, obj] - a[0].should equal(obj) - a[1].should equal(obj) + a[0].should.equal?(obj) + a[1].should.equal?(obj) Array.new(3, 14).should == [14, 14, 14] end @@ -76,12 +76,12 @@ end it "raises an ArgumentError if size is negative" do - -> { Array.new(-1, :a) }.should raise_error(ArgumentError) - -> { Array.new(-1) }.should raise_error(ArgumentError) + -> { Array.new(-1, :a) }.should.raise(ArgumentError) + -> { Array.new(-1) }.should.raise(ArgumentError) end it "raises an ArgumentError if size is too large" do - -> { Array.new(fixnum_max+1) }.should raise_error(ArgumentError) + -> { Array.new(fixnum_max+1) }.should.raise(ArgumentError) end it "calls #to_int to convert the size argument to an Integer when object is given" do @@ -99,7 +99,7 @@ it "raises a TypeError if the size argument is not an Integer type" do obj = mock('nonnumeric') obj.stub!(:to_ary).and_return([1, 2]) - ->{ Array.new(obj, :a) }.should raise_error(TypeError) + ->{ Array.new(obj, :a) }.should.raise(TypeError) end it "yields the index of the element and sets the element to the value of the block" do diff --git a/spec/ruby/core/array/pack/a_spec.rb b/spec/ruby/core/array/pack/a_spec.rb index 8245cd54709a2e..03bfd8214c8ee8 100644 --- a/spec/ruby/core/array/pack/a_spec.rb +++ b/spec/ruby/core/array/pack/a_spec.rb @@ -19,8 +19,8 @@ end it "will not implicitly convert a number to a string" do - -> { [0].pack('A') }.should raise_error(TypeError) - -> { [0].pack('a') }.should raise_error(TypeError) + -> { [0].pack('A') }.should.raise(TypeError) + -> { [0].pack('a') }.should.raise(TypeError) end it "adds all the bytes to the output when passed the '*' modifier" do diff --git a/spec/ruby/core/array/pack/b_spec.rb b/spec/ruby/core/array/pack/b_spec.rb index 247a9ca023f48d..f7576846ef9062 100644 --- a/spec/ruby/core/array/pack/b_spec.rb +++ b/spec/ruby/core/array/pack/b_spec.rb @@ -19,8 +19,8 @@ end it "will not implicitly convert a number to a string" do - -> { [0].pack('B') }.should raise_error(TypeError) - -> { [0].pack('b') }.should raise_error(TypeError) + -> { [0].pack('B') }.should.raise(TypeError) + -> { [0].pack('b') }.should.raise(TypeError) end it "encodes one bit for each character starting with the most significant bit" do diff --git a/spec/ruby/core/array/pack/buffer_spec.rb b/spec/ruby/core/array/pack/buffer_spec.rb index b77b2d1efa5048..d104c80186f047 100644 --- a/spec/ruby/core/array/pack/buffer_spec.rb +++ b/spec/ruby/core/array/pack/buffer_spec.rb @@ -7,7 +7,7 @@ n = [ 65, 66, 67 ] buffer = " "*3 result = n.pack("ccc", buffer: buffer) #=> "ABC" - result.should equal(buffer) + result.should.equal?(buffer) end it "adds result at the end of buffer content" do @@ -24,12 +24,12 @@ end it "raises TypeError exception if buffer is not String" do - -> { [65].pack("ccc", buffer: []) }.should raise_error( + -> { [65].pack("ccc", buffer: []) }.should.raise( TypeError, "buffer must be String, not Array") end it "raise FrozenError if buffer is frozen" do - -> { [65].pack("c", buffer: "frozen-string".freeze) }.should raise_error(FrozenError) + -> { [65].pack("c", buffer: "frozen-string".freeze) }.should.raise(FrozenError) end it "preserves the encoding of the given buffer" do diff --git a/spec/ruby/core/array/pack/c_spec.rb b/spec/ruby/core/array/pack/c_spec.rb index 7a2b95def87f7f..de06207a2333fb 100644 --- a/spec/ruby/core/array/pack/c_spec.rb +++ b/spec/ruby/core/array/pack/c_spec.rb @@ -48,7 +48,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [1, 2, 3].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do diff --git a/spec/ruby/core/array/pack/h_spec.rb b/spec/ruby/core/array/pack/h_spec.rb index ba188874ba6e33..1492d02b1fb2c6 100644 --- a/spec/ruby/core/array/pack/h_spec.rb +++ b/spec/ruby/core/array/pack/h_spec.rb @@ -19,8 +19,8 @@ end it "will not implicitly convert a number to a string" do - -> { [0].pack('H') }.should raise_error(TypeError) - -> { [0].pack('h') }.should raise_error(TypeError) + -> { [0].pack('H') }.should.raise(TypeError) + -> { [0].pack('h') }.should.raise(TypeError) end it "encodes the first character as the most significant nibble when passed no count modifier" do diff --git a/spec/ruby/core/array/pack/m_spec.rb b/spec/ruby/core/array/pack/m_spec.rb index a80f91275c9c1f..fb670d120e2f14 100644 --- a/spec/ruby/core/array/pack/m_spec.rb +++ b/spec/ruby/core/array/pack/m_spec.rb @@ -155,7 +155,7 @@ it "encodes a recursive array" do empty = ArraySpecs.empty_recursive_array - empty.pack('M').should be_an_instance_of(String) + empty.pack('M').should.instance_of?(String) array = ArraySpecs.recursive_array array.pack('M').should == "1=\n" @@ -172,7 +172,7 @@ obj = mock("pack M non-string") obj.should_receive(:to_s).and_return(2) - [obj].pack("M").should be_an_instance_of(String) + [obj].pack("M").should.instance_of?(String) end it "encodes a Symbol as a String" do @@ -293,16 +293,16 @@ it "raises a TypeError if #to_str does not return a String" do obj = mock("pack m non-string") - -> { [obj].pack("m") }.should raise_error(TypeError) + -> { [obj].pack("m") }.should.raise(TypeError) end it "raises a TypeError if passed nil" do - -> { [nil].pack("m") }.should raise_error(TypeError) + -> { [nil].pack("m") }.should.raise(TypeError) end it "raises a TypeError if passed an Integer" do - -> { [0].pack("m") }.should raise_error(TypeError) - -> { [bignum_value].pack("m") }.should raise_error(TypeError) + -> { [0].pack("m") }.should.raise(TypeError) + -> { [bignum_value].pack("m") }.should.raise(TypeError) end it "does not emit a newline if passed zero as the count modifier" do diff --git a/spec/ruby/core/array/pack/percent_spec.rb b/spec/ruby/core/array/pack/percent_spec.rb index 5d56dea5fe586e..29b119732a4e77 100644 --- a/spec/ruby/core/array/pack/percent_spec.rb +++ b/spec/ruby/core/array/pack/percent_spec.rb @@ -2,6 +2,6 @@ describe "Array#pack with format '%'" do it "raises an Argument Error" do - -> { [1].pack("%") }.should raise_error(ArgumentError) + -> { [1].pack("%") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/array/pack/r_spec.rb b/spec/ruby/core/array/pack/r_spec.rb index 62211e3a8efb1e..cefe1388d2b8ed 100644 --- a/spec/ruby/core/array/pack/r_spec.rb +++ b/spec/ruby/core/array/pack/r_spec.rb @@ -33,8 +33,8 @@ end it "raises an ArgumentError when passed a negative value" do - -> { [-1].pack("R") }.should raise_error(ArgumentError) - -> { [-100].pack("R") }.should raise_error(ArgumentError) + -> { [-1].pack("R") }.should.raise(ArgumentError) + -> { [-100].pack("R") }.should.raise(ArgumentError) end it "round-trips values through pack and unpack" do diff --git a/spec/ruby/core/array/pack/shared/basic.rb b/spec/ruby/core/array/pack/shared/basic.rb index 280212ecb86229..2894369c7138ac 100644 --- a/spec/ruby/core/array/pack/shared/basic.rb +++ b/spec/ruby/core/array/pack/shared/basic.rb @@ -1,6 +1,6 @@ describe :array_pack_arguments, shared: true do it "raises an ArgumentError if there are fewer elements than the format requires" do - -> { [].pack(pack_format(1)) }.should raise_error(ArgumentError) + -> { [].pack(pack_format(1)) }.should.raise(ArgumentError) end end @@ -10,11 +10,11 @@ end it "raises a TypeError when passed nil" do - -> { [@obj].pack(nil) }.should raise_error(TypeError) + -> { [@obj].pack(nil) }.should.raise(TypeError) end it "raises a TypeError when passed an Integer" do - -> { [@obj].pack(1) }.should raise_error(TypeError) + -> { [@obj].pack(1) }.should.raise(TypeError) end end @@ -24,50 +24,50 @@ end it "ignores whitespace in the format string" do - [@obj, @obj].pack("a \t\n\v\f\r"+pack_format).should be_an_instance_of(String) + [@obj, @obj].pack("a \t\n\v\f\r"+pack_format).should.instance_of?(String) end it "ignores comments in the format string" do # 2 additional directives ('a') are required for the X directive - [@obj, @obj, @obj, @obj].pack("aa #{pack_format} # some comment \n#{pack_format}").should be_an_instance_of(String) + [@obj, @obj, @obj, @obj].pack("aa #{pack_format} # some comment \n#{pack_format}").should.instance_of?(String) end it "raise ArgumentError when a directive is unknown" do # additional directive ('a') is required for the X directive - -> { [@obj, @obj].pack("a K" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'K'/) - -> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive '0'/) - -> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive ':'/) + -> { [@obj, @obj].pack("a K" + pack_format) }.should.raise(ArgumentError, /unknown pack directive 'K'/) + -> { [@obj, @obj].pack("a 0" + pack_format) }.should.raise(ArgumentError, /unknown pack directive '0'/) + -> { [@obj, @obj].pack("a :" + pack_format) }.should.raise(ArgumentError, /unknown pack directive ':'/) end it "calls #to_str to coerce the directives string" do d = mock("pack directive") d.should_receive(:to_str).and_return("x"+pack_format) - [@obj, @obj].pack(d).should be_an_instance_of(String) + [@obj, @obj].pack(d).should.instance_of?(String) end end describe :array_pack_basic_float, shared: true do it "ignores whitespace in the format string" do - [9.3, 4.7].pack(" \t\n\v\f\r"+pack_format).should be_an_instance_of(String) + [9.3, 4.7].pack(" \t\n\v\f\r"+pack_format).should.instance_of?(String) end it "ignores comments in the format string" do - [9.3, 4.7].pack(pack_format + "# some comment \n" + pack_format).should be_an_instance_of(String) + [9.3, 4.7].pack(pack_format + "# some comment \n" + pack_format).should.instance_of?(String) end it "calls #to_str to coerce the directives string" do d = mock("pack directive") d.should_receive(:to_str).and_return("x"+pack_format) - [1.2, 4.7].pack(d).should be_an_instance_of(String) + [1.2, 4.7].pack(d).should.instance_of?(String) end end describe :array_pack_no_platform, shared: true do it "raises ArgumentError when the format modifier is '_'" do - ->{ [1].pack(pack_format("_")) }.should raise_error(ArgumentError) + ->{ [1].pack(pack_format("_")) }.should.raise(ArgumentError) end it "raises ArgumentError when the format modifier is '!'" do - ->{ [1].pack(pack_format("!")) }.should raise_error(ArgumentError) + ->{ [1].pack(pack_format("!")) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/array/pack/shared/encodings.rb b/spec/ruby/core/array/pack/shared/encodings.rb index 6b7ffac7645aad..0b5a5cc8a01815 100644 --- a/spec/ruby/core/array/pack/shared/encodings.rb +++ b/spec/ruby/core/array/pack/shared/encodings.rb @@ -5,12 +5,12 @@ it "raises a TypeError if the object does not respond to #to_str" do obj = mock("pack hex non-string") - -> { [obj].pack(pack_format) }.should raise_error(TypeError) + -> { [obj].pack(pack_format) }.should.raise(TypeError) end it "raises a TypeError if #to_str does not return a String" do obj = mock("pack hex non-string") obj.should_receive(:to_str).and_return(1) - -> { [obj].pack(pack_format) }.should raise_error(TypeError) + -> { [obj].pack(pack_format) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/array/pack/shared/float.rb b/spec/ruby/core/array/pack/shared/float.rb index 3f60fee2150b48..c1efcd7677b587 100644 --- a/spec/ruby/core/array/pack/shared/float.rb +++ b/spec/ruby/core/array/pack/shared/float.rb @@ -14,7 +14,7 @@ end it "raises a TypeError if passed a String representation of a floating point number" do - -> { ["13"].pack(pack_format) }.should raise_error(TypeError) + -> { ["13"].pack(pack_format) }.should.raise(TypeError) end it "encodes the number of array elements specified by the count modifier" do @@ -28,7 +28,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [5.3, 9.2].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -45,7 +45,7 @@ it "encodes NaN" do nans = ["\x00\x00\xc0\xff", "\x00\x00\xc0\x7f", "\xFF\xFF\xFF\x7F"] - nans.should include([nan_value].pack(pack_format)) + nans.should.include?([nan_value].pack(pack_format)) end it "encodes a positive Float outside the range of a single precision float" do @@ -84,7 +84,7 @@ end it "raises a TypeError if passed a String representation of a floating point number" do - -> { ["13"].pack(pack_format) }.should raise_error(TypeError) + -> { ["13"].pack(pack_format) }.should.raise(TypeError) end it "encodes the number of array elements specified by the count modifier" do @@ -98,7 +98,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [5.3, 9.2].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -115,7 +115,7 @@ it "encodes NaN" do nans = ["\xff\xc0\x00\x00", "\x7f\xc0\x00\x00", "\x7F\xFF\xFF\xFF"] - nans.should include([nan_value].pack(pack_format)) + nans.should.include?([nan_value].pack(pack_format)) end it "encodes a positive Float outside the range of a single precision float" do @@ -146,7 +146,7 @@ end it "raises a TypeError if passed a String representation of a floating point number" do - -> { ["13"].pack(pack_format) }.should raise_error(TypeError) + -> { ["13"].pack(pack_format) }.should.raise(TypeError) end it "encodes the number of array elements specified by the count modifier" do @@ -160,7 +160,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [5.3, 9.2].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -181,7 +181,7 @@ "\x00\x00\x00\x00\x00\x00\xf8\x7f", "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x7F" ] - nans.should include([nan_value].pack(pack_format)) + nans.should.include?([nan_value].pack(pack_format)) end it "encodes a positive Float outside the range of a single precision float" do @@ -207,7 +207,7 @@ end it "raises a TypeError if passed a String representation of a floating point number" do - -> { ["13"].pack(pack_format) }.should raise_error(TypeError) + -> { ["13"].pack(pack_format) }.should.raise(TypeError) end it "encodes the number of array elements specified by the count modifier" do @@ -221,7 +221,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [5.3, 9.2].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -242,7 +242,7 @@ "\x7f\xf8\x00\x00\x00\x00\x00\x00", "\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF" ] - nans.should include([nan_value].pack(pack_format)) + nans.should.include?([nan_value].pack(pack_format)) end it "encodes a positive Float outside the range of a single precision float" do diff --git a/spec/ruby/core/array/pack/shared/integer.rb b/spec/ruby/core/array/pack/shared/integer.rb index ff2ee492016cc4..1cdd386cc154a1 100644 --- a/spec/ruby/core/array/pack/shared/integer.rb +++ b/spec/ruby/core/array/pack/shared/integer.rb @@ -44,7 +44,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -97,7 +97,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -150,7 +150,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -203,7 +203,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -316,7 +316,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -377,7 +377,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do diff --git a/spec/ruby/core/array/pack/shared/numeric_basic.rb b/spec/ruby/core/array/pack/shared/numeric_basic.rb index 545e215e646af6..6594914933bc55 100644 --- a/spec/ruby/core/array/pack/shared/numeric_basic.rb +++ b/spec/ruby/core/array/pack/shared/numeric_basic.rb @@ -4,15 +4,15 @@ end it "raises a TypeError when passed nil" do - -> { [nil].pack(pack_format) }.should raise_error(TypeError) + -> { [nil].pack(pack_format) }.should.raise(TypeError) end it "raises a TypeError when passed true" do - -> { [true].pack(pack_format) }.should raise_error(TypeError) + -> { [true].pack(pack_format) }.should.raise(TypeError) end it "raises a TypeError when passed false" do - -> { [false].pack(pack_format) }.should raise_error(TypeError) + -> { [false].pack(pack_format) }.should.raise(TypeError) end it "returns a binary string" do @@ -24,27 +24,27 @@ describe :array_pack_integer, shared: true do it "raises a TypeError when the object does not respond to #to_int" do obj = mock('not an integer') - -> { [obj].pack(pack_format) }.should raise_error(TypeError) + -> { [obj].pack(pack_format) }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { ["5"].pack(pack_format) }.should raise_error(TypeError) + -> { ["5"].pack(pack_format) }.should.raise(TypeError) end end describe :array_pack_float, shared: true do it "raises a TypeError if a String does not represent a floating point number" do - -> { ["a"].pack(pack_format) }.should raise_error(TypeError) + -> { ["a"].pack(pack_format) }.should.raise(TypeError) end it "raises a TypeError when the object is not Numeric" do obj = Object.new - -> { [obj].pack(pack_format) }.should raise_error(TypeError, /can't convert Object into Float/) + -> { [obj].pack(pack_format) }.should.raise(TypeError, /can't convert Object into Float/) end it "raises a TypeError when the Numeric object does not respond to #to_f" do klass = Class.new(Numeric) obj = klass.new - -> { [obj].pack(pack_format) }.should raise_error(TypeError) + -> { [obj].pack(pack_format) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/array/pack/shared/string.rb b/spec/ruby/core/array/pack/shared/string.rb index 805f78b53b682d..b02257059f8985 100644 --- a/spec/ruby/core/array/pack/shared/string.rb +++ b/spec/ruby/core/array/pack/shared/string.rb @@ -17,11 +17,11 @@ end it "raises an ArgumentError when the Array is empty" do - -> { [].pack(pack_format) }.should raise_error(ArgumentError) + -> { [].pack(pack_format) }.should.raise(ArgumentError) end it "raises an ArgumentError when the Array has too few elements" do - -> { ["a"].pack(pack_format(nil, 2)) }.should raise_error(ArgumentError) + -> { ["a"].pack(pack_format(nil, 2)) }.should.raise(ArgumentError) end it "calls #to_str to convert the element to a String" do @@ -33,7 +33,7 @@ it "raises a TypeError when the object does not respond to #to_str" do obj = mock("not a string") - -> { [obj].pack(pack_format) }.should raise_error(TypeError) + -> { [obj].pack(pack_format) }.should.raise(TypeError) end it "returns a string in encoding of common to the concatenated results" do diff --git a/spec/ruby/core/array/pack/shared/unicode.rb b/spec/ruby/core/array/pack/shared/unicode.rb index 0eccc7098c7cbf..58ba8a8b233f0a 100644 --- a/spec/ruby/core/array/pack/shared/unicode.rb +++ b/spec/ruby/core/array/pack/shared/unicode.rb @@ -26,7 +26,7 @@ it "constructs strings with valid encodings" do str = [0x85].pack("U*") str.should == "\xc2\x85" - str.valid_encoding?.should be_true + str.valid_encoding?.should == true end it "encodes values larger than UTF-8 max codepoints" do @@ -64,13 +64,13 @@ it "raises a TypeError if #to_int does not return an Integer" do obj = mock('to_int') obj.should_receive(:to_int).and_return("5") - -> { [obj].pack("U") }.should raise_error(TypeError) + -> { [obj].pack("U") }.should.raise(TypeError) end it "raise ArgumentError for NULL bytes between directives" do -> { [1, 2, 3].pack("U\x00U") - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -78,11 +78,11 @@ end it "raises a RangeError if passed a negative number" do - -> { [-1].pack("U") }.should raise_error(RangeError) + -> { [-1].pack("U") }.should.raise(RangeError) end it "raises a RangeError if passed a number larger than an unsigned 32-bit integer" do - -> { [2**32].pack("U") }.should raise_error(RangeError) + -> { [2**32].pack("U") }.should.raise(RangeError) end it "sets the output string to UTF-8 encoding" do diff --git a/spec/ruby/core/array/pack/u_spec.rb b/spec/ruby/core/array/pack/u_spec.rb index 1f84095ac46003..c6a0d77eb2d937 100644 --- a/spec/ruby/core/array/pack/u_spec.rb +++ b/spec/ruby/core/array/pack/u_spec.rb @@ -25,7 +25,7 @@ end it "will not implicitly convert a number to a string" do - -> { [0].pack('u') }.should raise_error(TypeError) + -> { [0].pack('u') }.should.raise(TypeError) end it "encodes an empty string as an empty string" do @@ -122,16 +122,16 @@ it "raises a TypeError if #to_str does not return a String" do obj = mock("pack m non-string") - -> { [obj].pack("u") }.should raise_error(TypeError) + -> { [obj].pack("u") }.should.raise(TypeError) end it "raises a TypeError if passed nil" do - -> { [nil].pack("u") }.should raise_error(TypeError) + -> { [nil].pack("u") }.should.raise(TypeError) end it "raises a TypeError if passed an Integer" do - -> { [0].pack("u") }.should raise_error(TypeError) - -> { [bignum_value].pack("u") }.should raise_error(TypeError) + -> { [0].pack("u") }.should.raise(TypeError) + -> { [bignum_value].pack("u") }.should.raise(TypeError) end it "sets the output string to US-ASCII encoding" do diff --git a/spec/ruby/core/array/pack/w_spec.rb b/spec/ruby/core/array/pack/w_spec.rb index ebadb94cab0504..263e2a2288ffab 100644 --- a/spec/ruby/core/array/pack/w_spec.rb +++ b/spec/ruby/core/array/pack/w_spec.rb @@ -27,7 +27,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { [1, 2, 3].pack("w\x00w") - }.should raise_error(ArgumentError, /unknown pack directive/) + }.should.raise(ArgumentError, /unknown pack directive/) end it "ignores spaces between directives" do @@ -35,7 +35,7 @@ end it "raises an ArgumentError when passed a negative value" do - -> { [-1].pack("w") }.should raise_error(ArgumentError) + -> { [-1].pack("w") }.should.raise(ArgumentError) end it "returns a binary string" do diff --git a/spec/ruby/core/array/pack/x_spec.rb b/spec/ruby/core/array/pack/x_spec.rb index 012fe4567f9cc2..7ff587a01edd8d 100644 --- a/spec/ruby/core/array/pack/x_spec.rb +++ b/spec/ruby/core/array/pack/x_spec.rb @@ -56,10 +56,10 @@ end it "raises an ArgumentError if the output string is empty" do - -> { [1, 2, 3].pack("XC") }.should raise_error(ArgumentError) + -> { [1, 2, 3].pack("XC") }.should.raise(ArgumentError) end it "raises an ArgumentError if the count modifier is greater than the bytes in the string" do - -> { [1, 2, 3].pack("C2X3") }.should raise_error(ArgumentError) + -> { [1, 2, 3].pack("C2X3") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/array/pack/z_spec.rb b/spec/ruby/core/array/pack/z_spec.rb index 60f8f7bf10c860..5cd084c8251212 100644 --- a/spec/ruby/core/array/pack/z_spec.rb +++ b/spec/ruby/core/array/pack/z_spec.rb @@ -19,7 +19,7 @@ end it "will not implicitly convert a number to a string" do - -> { [0].pack('Z') }.should raise_error(TypeError) + -> { [0].pack('Z') }.should.raise(TypeError) end it "adds all the bytes and appends a NULL byte when passed the '*' modifier" do diff --git a/spec/ruby/core/array/partition_spec.rb b/spec/ruby/core/array/partition_spec.rb index be36fffcab99c1..bd3f3a6b6f996a 100644 --- a/spec/ruby/core/array/partition_spec.rb +++ b/spec/ruby/core/array/partition_spec.rb @@ -36,8 +36,8 @@ it "does not return subclass instances on Array subclasses" do result = ArraySpecs::MyArray[1, 2, 3].partition { |x| x % 2 == 0 } - result.should be_an_instance_of(Array) - result[0].should be_an_instance_of(Array) - result[1].should be_an_instance_of(Array) + result.should.instance_of?(Array) + result[0].should.instance_of?(Array) + result[1].should.instance_of?(Array) end end diff --git a/spec/ruby/core/array/permutation_spec.rb b/spec/ruby/core/array/permutation_spec.rb index f15bd76639b332..b5df84b52b0a82 100644 --- a/spec/ruby/core/array/permutation_spec.rb +++ b/spec/ruby/core/array/permutation_spec.rb @@ -11,7 +11,7 @@ it "returns an Enumerator of all permutations when called without a block or arguments" do enum = @numbers.permutation - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.sort.should == [ [1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1] ].sort @@ -19,13 +19,13 @@ it "returns an Enumerator of permutations of given length when called with an argument but no block" do enum = @numbers.permutation(1) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.sort.should == [[1],[2],[3]] end it "yields all permutations to the block then returns self when called with block but no arguments" do array = @numbers.permutation {|n| @yielded << n} - array.should be_an_instance_of(Array) + array.should.instance_of?(Array) array.sort.should == @numbers.sort @yielded.sort.should == [ [1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1] @@ -34,7 +34,7 @@ it "yields all permutations of given length to the block then returns self when called with block and argument" do array = @numbers.permutation(2) {|n| @yielded << n} - array.should be_an_instance_of(Array) + array.should.instance_of?(Array) array.sort.should == @numbers.sort @yielded.sort.should == [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]].sort end @@ -78,7 +78,7 @@ [3, 1], [3, 2], [3, [4, 5]], [[4, 5], 1], [[4, 5], 2], [[4, 5], 3] ] - expected.each {|e| got.include?(e).should be_true} + expected.each {|e| got.include?(e).should == true} got.size.should == expected.size end diff --git a/spec/ruby/core/array/plus_spec.rb b/spec/ruby/core/array/plus_spec.rb index b7153fd3ef1969..7ead927fc0935e 100644 --- a/spec/ruby/core/array/plus_spec.rb +++ b/spec/ruby/core/array/plus_spec.rb @@ -22,14 +22,14 @@ end it "raises a TypeError if the given argument can't be converted to an array" do - -> { [1, 2, 3] + nil }.should raise_error(TypeError) - -> { [1, 2, 3] + "abc" }.should raise_error(TypeError) + -> { [1, 2, 3] + nil }.should.raise(TypeError) + -> { [1, 2, 3] + "abc" }.should.raise(TypeError) end it "raises a NoMethodError if the given argument raises a NoMethodError during type coercion to an Array" do obj = mock("hello") obj.should_receive(:to_ary).and_raise(NoMethodError) - -> { [1, 2, 3] + obj }.should raise_error(NoMethodError) + -> { [1, 2, 3] + obj }.should.raise(NoMethodError) end end @@ -45,9 +45,9 @@ end it "does return subclass instances with Array subclasses" do - (ArraySpecs::MyArray[1, 2, 3] + []).should be_an_instance_of(Array) - (ArraySpecs::MyArray[1, 2, 3] + ArraySpecs::MyArray[]).should be_an_instance_of(Array) - ([1, 2, 3] + ArraySpecs::MyArray[]).should be_an_instance_of(Array) + (ArraySpecs::MyArray[1, 2, 3] + []).should.instance_of?(Array) + (ArraySpecs::MyArray[1, 2, 3] + ArraySpecs::MyArray[]).should.instance_of?(Array) + ([1, 2, 3] + ArraySpecs::MyArray[]).should.instance_of?(Array) end it "does not call to_ary on array subclasses" do diff --git a/spec/ruby/core/array/pop_spec.rb b/spec/ruby/core/array/pop_spec.rb index 2a194086609828..069083331c1310 100644 --- a/spec/ruby/core/array/pop_spec.rb +++ b/spec/ruby/core/array/pop_spec.rb @@ -31,11 +31,11 @@ end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.pop }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.pop }.should.raise(FrozenError) end it "raises a FrozenError on an empty frozen array" do - -> { ArraySpecs.empty_frozen_array.pop }.should raise_error(FrozenError) + -> { ArraySpecs.empty_frozen_array.pop }.should.raise(FrozenError) end describe "passed a number n as an argument" do @@ -71,7 +71,7 @@ popped2.should == [] a.should == [] - popped1.should_not equal(popped2) + popped1.should_not.equal?(popped2) end it "returns whole elements if n exceeds size of the array" do @@ -82,14 +82,14 @@ it "does not return self even when it returns whole elements" do a = [1, 2, 3, 4, 5] - a.pop(5).should_not equal(a) + a.pop(5).should_not.equal?(a) a = [1, 2, 3, 4, 5] - a.pop(6).should_not equal(a) + a.pop(6).should_not.equal?(a) end it "raises an ArgumentError if n is negative" do - ->{ [1, 2, 3].pop(-1) }.should raise_error(ArgumentError) + ->{ [1, 2, 3].pop(-1) }.should.raise(ArgumentError) end it "tries to convert n to an Integer using #to_int" do @@ -104,21 +104,21 @@ end it "raises a TypeError when the passed n cannot be coerced to Integer" do - ->{ [1, 2].pop("cat") }.should raise_error(TypeError) - ->{ [1, 2].pop(nil) }.should raise_error(TypeError) + ->{ [1, 2].pop("cat") }.should.raise(TypeError) + ->{ [1, 2].pop(nil) }.should.raise(TypeError) end it "raises an ArgumentError if more arguments are passed" do - ->{ [1, 2].pop(1, 2) }.should raise_error(ArgumentError) + ->{ [1, 2].pop(1, 2) }.should.raise(ArgumentError) end it "does not return subclass instances with Array subclass" do - ArraySpecs::MyArray[1, 2, 3].pop(2).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].pop(2).should.instance_of?(Array) end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.pop(2) }.should raise_error(FrozenError) - -> { ArraySpecs.frozen_array.pop(0) }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.pop(2) }.should.raise(FrozenError) + -> { ArraySpecs.frozen_array.pop(0) }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/array/product_spec.rb b/spec/ruby/core/array/product_spec.rb index 6fb3818508ed9f..837f0eaf3455d1 100644 --- a/spec/ruby/core/array/product_spec.rb +++ b/spec/ruby/core/array/product_spec.rb @@ -3,7 +3,7 @@ describe "Array#product" do it "returns converted arguments using :to_ary" do - ->{ [1].product(2..3) }.should raise_error(TypeError) + ->{ [1].product(2..3) }.should.raise(TypeError) ar = ArraySpecs::ArrayConvertible.new(2,3) [1].product(ar).should == [[1,2],[1,3]] ar.called.should == :to_ary @@ -31,7 +31,7 @@ a = (0..100).to_a -> do a.product(a, a, a, a, a, a, a, a, a, a) - end.should raise_error(RangeError) + end.should.raise(RangeError) end describe "when given a block" do @@ -43,7 +43,7 @@ acc = [] [1,2].product([3,4,5],[],[6,8]){|array| acc << array} - acc.should be_empty + acc.should.empty? end it "returns self" do @@ -56,18 +56,18 @@ a = (0..100).to_a -> do a.product(a, a, a, a, a, a, a, a, a, a) - end.should raise_error(RangeError) + end.should.raise(RangeError) end end describe "when given an empty block" do it "returns self" do arr = [1,2] - arr.product([3,4,5],[6,8]){}.should equal(arr) + arr.product([3,4,5],[6,8]){}.should.equal?(arr) arr = [] - arr.product([3,4,5],[6,8]){}.should equal(arr) + arr.product([3,4,5],[6,8]){}.should.equal?(arr) arr = [1,2] - arr.product([]){}.should equal(arr) + arr.product([]){}.should.equal?(arr) end end end diff --git a/spec/ruby/core/array/rassoc_spec.rb b/spec/ruby/core/array/rassoc_spec.rb index a7ffb75fb53521..95e4ed18927518 100644 --- a/spec/ruby/core/array/rassoc_spec.rb +++ b/spec/ruby/core/array/rassoc_spec.rb @@ -12,11 +12,11 @@ it "properly handles recursive arrays" do empty = ArraySpecs.empty_recursive_array - empty.rassoc([]).should be_nil + empty.rassoc([]).should == nil [[empty, empty]].rassoc(empty).should == [empty, empty] array = ArraySpecs.recursive_array - array.rassoc(array).should be_nil + array.rassoc(array).should == nil [[empty, array]].rassoc(array).should == [empty, array] end @@ -42,9 +42,9 @@ def o.==(other); other == 'foobar'; end a = [s1, s2] s1.should_not_receive(:to_ary) - a.rassoc(2).should equal(s1) + a.rassoc(2).should.equal?(s1) a.rassoc(3).should == [2, 3] - s2.called.should equal(:to_ary) + s2.called.should.equal?(:to_ary) end end diff --git a/spec/ruby/core/array/reject_spec.rb b/spec/ruby/core/array/reject_spec.rb index 81a467e364c2f8..8d237b3a750aa1 100644 --- a/spec/ruby/core/array/reject_spec.rb +++ b/spec/ruby/core/array/reject_spec.rb @@ -10,9 +10,9 @@ ary = [1, 2, 3, 4, 5] ary.reject { true }.should == [] ary.reject { false }.should == ary - ary.reject { false }.should_not equal ary + ary.reject { false }.should_not.equal? ary ary.reject { nil }.should == ary - ary.reject { nil }.should_not equal ary + ary.reject { nil }.should_not.equal? ary ary.reject { 5 }.should == [] ary.reject { |i| i < 3 }.should == [3, 4, 5] ary.reject { |i| i % 2 == 0 }.should == [1, 3, 5] @@ -35,7 +35,7 @@ end it "does not return subclass instance on Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].reject { |x| x % 2 == 0 }.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].reject { |x| x % 2 == 0 }.should.instance_of?(Array) end it "does not retain instance variables" do @@ -55,7 +55,7 @@ describe "Array#reject!" do it "removes elements for which block is true" do a = [3, 4, 5, 6, 7, 8, 9, 10, 11] - a.reject! { |i| i % 2 == 0 }.should equal(a) + a.reject! { |i| i % 2 == 0 }.should.equal?(a) a.should == [3, 5, 7, 9, 11] a.reject! { |i| i > 8 } a.should == [3, 5, 7] @@ -105,20 +105,20 @@ end it "returns an Enumerator if no block given, and the array is frozen" do - ArraySpecs.frozen_array.reject!.should be_an_instance_of(Enumerator) + ArraySpecs.frozen_array.reject!.should.instance_of?(Enumerator) end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.reject! {} }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.reject! {} }.should.raise(FrozenError) end it "raises a FrozenError on an empty frozen array" do - -> { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(FrozenError) + -> { ArraySpecs.empty_frozen_array.reject! {} }.should.raise(FrozenError) end it "raises a FrozenError on a frozen array only during iteration if called without a block" do enum = ArraySpecs.frozen_array.reject! - -> { enum.each {} }.should raise_error(FrozenError) + -> { enum.each {} }.should.raise(FrozenError) end it "does not truncate the array is the block raises an exception" do diff --git a/spec/ruby/core/array/repeated_combination_spec.rb b/spec/ruby/core/array/repeated_combination_spec.rb index b62382024ab2a1..a714f05f54c013 100644 --- a/spec/ruby/core/array/repeated_combination_spec.rb +++ b/spec/ruby/core/array/repeated_combination_spec.rb @@ -6,16 +6,16 @@ end it "returns an enumerator when no block is provided" do - @array.repeated_combination(2).should be_an_instance_of(Enumerator) + @array.repeated_combination(2).should.instance_of?(Enumerator) end it "returns self when a block is given" do - @array.repeated_combination(2){}.should equal(@array) + @array.repeated_combination(2){}.should.equal?(@array) end it "yields nothing for negative length and return self" do - @array.repeated_combination(-1){ fail }.should equal(@array) - @array.repeated_combination(-10){ fail }.should equal(@array) + @array.repeated_combination(-1){ fail }.should.equal?(@array) + @array.repeated_combination(-10){ fail }.should.equal?(@array) end it "yields the expected repeated_combinations" do diff --git a/spec/ruby/core/array/repeated_permutation_spec.rb b/spec/ruby/core/array/repeated_permutation_spec.rb index a165fda09ed1f5..c54a8c0c2bf7f5 100644 --- a/spec/ruby/core/array/repeated_permutation_spec.rb +++ b/spec/ruby/core/array/repeated_permutation_spec.rb @@ -10,13 +10,13 @@ it "returns an Enumerator of all repeated permutations of given length when called without a block" do enum = @numbers.repeated_permutation(2) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.sort.should == @permutations end it "yields all repeated_permutations to the block then returns self when called with block but no arguments" do yielded = [] - @numbers.repeated_permutation(2) {|n| yielded << n}.should equal(@numbers) + @numbers.repeated_permutation(2) {|n| yielded << n}.should.equal?(@numbers) yielded.sort.should == @permutations end diff --git a/spec/ruby/core/array/reverse_each_spec.rb b/spec/ruby/core/array/reverse_each_spec.rb index 59dabcd33d06ab..8fa5ce6da1f020 100644 --- a/spec/ruby/core/array/reverse_each_spec.rb +++ b/spec/ruby/core/array/reverse_each_spec.rb @@ -19,7 +19,7 @@ it "returns self" do a = [:a, :b, :c] - a.reverse_each { |x| }.should equal(a) + a.reverse_each { |x| }.should.equal?(a) end it "yields only the top level element of an empty recursive arrays" do diff --git a/spec/ruby/core/array/reverse_spec.rb b/spec/ruby/core/array/reverse_spec.rb index 05dbd2efcf407d..f25a484be8bdbe 100644 --- a/spec/ruby/core/array/reverse_spec.rb +++ b/spec/ruby/core/array/reverse_spec.rb @@ -16,14 +16,14 @@ end it "does not return subclass instance on Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].reverse.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].reverse.should.instance_of?(Array) end end describe "Array#reverse!" do it "reverses the elements in place" do a = [6, 3, 4, 2, 1] - a.reverse!.should equal(a) + a.reverse!.should.equal?(a) a.should == [1, 2, 4, 3, 6] [].reverse!.should == [] end @@ -37,6 +37,6 @@ end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.reverse! }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.reverse! }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/rindex_spec.rb b/spec/ruby/core/array/rindex_spec.rb index 13de88818c705a..858c39dc9280b7 100644 --- a/spec/ruby/core/array/rindex_spec.rb +++ b/spec/ruby/core/array/rindex_spec.rb @@ -41,7 +41,7 @@ it "properly handles empty recursive arrays" do empty = ArraySpecs.empty_recursive_array empty.rindex(empty).should == 0 - empty.rindex(1).should be_nil + empty.rindex(1).should == nil end it "properly handles recursive arrays" do @@ -86,7 +86,7 @@ describe "given no argument and no block" do it "produces an Enumerator" do enum = [4, 2, 1, 5, 1, 3].rindex - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each { |x| x < 2 }.should == 4 end end diff --git a/spec/ruby/core/array/rotate_spec.rb b/spec/ruby/core/array/rotate_spec.rb index 60dcc8b1132075..009ce5ed49e207 100644 --- a/spec/ruby/core/array/rotate_spec.rb +++ b/spec/ruby/core/array/rotate_spec.rb @@ -29,10 +29,10 @@ it "raises a TypeError if not passed an integer-like argument" do -> { [1, 2].rotate(nil) - }.should raise_error(TypeError) + }.should.raise(TypeError) -> { [1, 2].rotate("4") - }.should raise_error(TypeError) + }.should.raise(TypeError) end end @@ -50,18 +50,18 @@ [].freeze.rotate [2].freeze.rotate(2) [1,2,3].freeze.rotate(-3) - }.should_not raise_error + }.should_not.raise end it "does not return self" do a = [1, 2, 3] - a.rotate.should_not equal(a) + a.rotate.should_not.equal?(a) a = [] - a.rotate(0).should_not equal(a) + a.rotate(0).should_not.equal?(a) end it "does not return subclass instance for Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].rotate.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].rotate.should.instance_of?(Array) end end @@ -69,7 +69,7 @@ describe "when passed no argument" do it "moves the first element to the end and returns self" do a = [1, 2, 3, 4, 5] - a.rotate!.should equal(a) + a.rotate!.should.equal?(a) a.should == [2, 3, 4, 5, 1] end end @@ -77,11 +77,11 @@ describe "with an argument n" do it "moves the first (n % size) elements at the end and returns self" do a = [1, 2, 3, 4, 5] - a.rotate!(2).should equal(a) + a.rotate!(2).should.equal?(a) a.should == [3, 4, 5, 1, 2] - a.rotate!(-12).should equal(a) + a.rotate!(-12).should.equal?(a) a.should == [1, 2, 3, 4, 5] - a.rotate!(13).should equal(a) + a.rotate!(13).should.equal?(a) a.should == [4, 5, 1, 2, 3] end @@ -96,34 +96,34 @@ it "raises a TypeError if not passed an integer-like argument" do -> { [1, 2].rotate!(nil) - }.should raise_error(TypeError) + }.should.raise(TypeError) -> { [1, 2].rotate!("4") - }.should raise_error(TypeError) + }.should.raise(TypeError) end end it "does nothing and returns self when the length is zero or one" do a = [1] - a.rotate!.should equal(a) + a.rotate!.should.equal?(a) a.should == [1] - a.rotate!(2).should equal(a) + a.rotate!(2).should.equal?(a) a.should == [1] - a.rotate!(-21).should equal(a) + a.rotate!(-21).should.equal?(a) a.should == [1] a = [] - a.rotate!.should equal(a) + a.rotate!.should.equal?(a) a.should == [] - a.rotate!(2).should equal(a) + a.rotate!(2).should.equal?(a) a.should == [] - a.rotate!(-21).should equal(a) + a.rotate!(-21).should.equal?(a) a.should == [] end it "raises a FrozenError on a frozen array" do - -> { [1, 2, 3].freeze.rotate!(0) }.should raise_error(FrozenError) - -> { [1].freeze.rotate!(42) }.should raise_error(FrozenError) - -> { [].freeze.rotate! }.should raise_error(FrozenError) + -> { [1, 2, 3].freeze.rotate!(0) }.should.raise(FrozenError) + -> { [1].freeze.rotate!(42) }.should.raise(FrozenError) + -> { [].freeze.rotate! }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/sample_spec.rb b/spec/ruby/core/array/sample_spec.rb index d4e945152d72cf..fd443b47de91ac 100644 --- a/spec/ruby/core/array/sample_spec.rb +++ b/spec/ruby/core/array/sample_spec.rb @@ -14,23 +14,23 @@ end it "returns nil for an empty Array" do - [].sample.should be_nil + [].sample.should == nil end it "returns nil for an empty array when called without n and a Random is given" do - [].sample(random: Random.new(42)).should be_nil + [].sample(random: Random.new(42)).should == nil end it "returns a single value when not passed a count" do - [4].sample.should equal(4) + [4].sample.should.equal?(4) end it "returns a single value when not passed a count and a Random is given" do - [4].sample(random: Random.new(42)).should equal(4) + [4].sample(random: Random.new(42)).should.equal?(4) end it "returns a single value when not passed a count and a Random class is given" do - [4].sample(random: Random).should equal(4) + [4].sample(random: Random).should.equal?(4) end it "returns an empty Array when passed zero" do @@ -38,12 +38,12 @@ end it "returns an Array of elements when passed a count" do - [1, 2, 3, 4].sample(3).should be_an_instance_of(Array) + [1, 2, 3, 4].sample(3).should.instance_of?(Array) end it "returns elements from the Array" do array = [1, 2, 3, 4] - array.sample(3).all? { |x| array.should include(x) } + array.sample(3).all? { |x| array.should.include?(x) } end it "returns at most the number of elements in the Array" do @@ -67,11 +67,11 @@ end it "raises ArgumentError when passed a negative count" do - -> { [1, 2].sample(-1) }.should raise_error(ArgumentError) + -> { [1, 2].sample(-1) }.should.raise(ArgumentError) end it "does not return subclass instances with Array subclass" do - ArraySpecs::MyArray[1, 2, 3].sample(2).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].sample(2).should.instance_of?(Array) end describe "with options" do @@ -79,13 +79,13 @@ obj = mock("array_sample_random") obj.should_receive(:rand).and_return(0.5) - [1, 2].sample(random: obj).should be_an_instance_of(Integer) + [1, 2].sample(random: obj).should.instance_of?(Integer) end it "raises a NoMethodError if an object passed for the RNG does not define #rand" do obj = BasicObject.new - -> { [1, 2].sample(random: obj) }.should raise_error(NoMethodError) + -> { [1, 2].sample(random: obj) }.should.raise(NoMethodError) end describe "when the object returned by #rand is an Integer" do @@ -105,21 +105,21 @@ random = mock("array_sample_random") random.should_receive(:rand).and_return(-1) - -> { [1, 2].sample(random: random) }.should raise_error(RangeError) + -> { [1, 2].sample(random: random) }.should.raise(RangeError) end it "raises a RangeError if the value is equal to the Array size" do random = mock("array_sample_random") random.should_receive(:rand).and_return(2) - -> { [1, 2].sample(random: random) }.should raise_error(RangeError) + -> { [1, 2].sample(random: random) }.should.raise(RangeError) end it "raises a RangeError if the value is greater than the Array size" do random = mock("array_sample_random") random.should_receive(:rand).and_return(3) - -> { [1, 2].sample(random: random) }.should raise_error(RangeError) + -> { [1, 2].sample(random: random) }.should.raise(RangeError) end end end @@ -140,7 +140,7 @@ random = mock("array_sample_random") random.should_receive(:rand).and_return(value) - -> { [1, 2].sample(random: random) }.should raise_error(RangeError) + -> { [1, 2].sample(random: random) }.should.raise(RangeError) end it "raises a RangeError if the value is equal to the Array size" do @@ -149,7 +149,7 @@ random = mock("array_sample_random") random.should_receive(:rand).and_return(value) - -> { [1, 2].sample(random: random) }.should raise_error(RangeError) + -> { [1, 2].sample(random: random) }.should.raise(RangeError) end end end diff --git a/spec/ruby/core/array/select_spec.rb b/spec/ruby/core/array/select_spec.rb index 298b5917449587..e8775ee5ac5223 100644 --- a/spec/ruby/core/array/select_spec.rb +++ b/spec/ruby/core/array/select_spec.rb @@ -7,7 +7,7 @@ describe "Array#select!" do it "returns nil if no changes were made in the array" do - [1, 2, 3].select! { true }.should be_nil + [1, 2, 3].select! { true }.should == nil end it_behaves_like :keep_if, :select! diff --git a/spec/ruby/core/array/shared/clone.rb b/spec/ruby/core/array/shared/clone.rb index 035b45ec99a146..1a45c2fe2c1b23 100644 --- a/spec/ruby/core/array/shared/clone.rb +++ b/spec/ruby/core/array/shared/clone.rb @@ -1,14 +1,14 @@ describe :array_clone, shared: true do it "returns an Array or a subclass instance" do - [].send(@method).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2].send(@method).should be_an_instance_of(ArraySpecs::MyArray) + [].send(@method).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2].send(@method).should.instance_of?(ArraySpecs::MyArray) end it "produces a shallow copy where the references are directly copied" do a = [mock('1'), mock('2')] b = a.send @method - b.first.should equal a.first - b.last.should equal a.last + b.first.should.equal? a.first + b.last.should.equal? a.last end it "creates a new array containing all elements or the original" do diff --git a/spec/ruby/core/array/shared/collect.rb b/spec/ruby/core/array/shared/collect.rb index 030302ced6cc37..aec51c9dc9623f 100644 --- a/spec/ruby/core/array/shared/collect.rb +++ b/spec/ruby/core/array/shared/collect.rb @@ -6,11 +6,11 @@ a = ['a', 'b', 'c', 'd'] b = a.send(@method) { |i| i + '!' } b.should == ["a!", "b!", "c!", "d!"] - b.should_not equal a + b.should_not.equal? a end it "does not return subclass instance" do - ArraySpecs::MyArray[1, 2, 3].send(@method) { |x| x + 1 }.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].send(@method) { |x| x + 1 }.should.instance_of?(Array) end it "does not change self" do @@ -33,14 +33,14 @@ it "returns an Enumerator when no block given" do a = [1, 2, 3] - a.send(@method).should be_an_instance_of(Enumerator) + a.send(@method).should.instance_of?(Enumerator) end it "raises an ArgumentError when no block and with arguments" do a = [1, 2, 3] -> { a.send(@method, :foo) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end before :all do @@ -54,14 +54,14 @@ describe :array_collect_b, shared: true do it "replaces each element with the value returned by block" do a = [7, 9, 3, 5] - a.send(@method) { |i| i - 1 }.should equal(a) + a.send(@method) { |i| i - 1 }.should.equal?(a) a.should == [6, 8, 2, 4] end it "returns self" do a = [1, 2, 3, 4, 5] b = a.send(@method) {|i| i+1 } - a.should equal b + a.should.equal? b end it "returns the evaluated value of block but its contents is partially modified, if it broke in the block" do @@ -80,28 +80,28 @@ it "returns an Enumerator when no block given, and the enumerator can modify the original array" do a = [1, 2, 3] enum = a.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each{|i| "#{i}!" } a.should == ["1!", "2!", "3!"] end describe "when frozen" do it "raises a FrozenError" do - -> { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.send(@method) {} }.should.raise(FrozenError) end it "raises a FrozenError when empty" do - -> { ArraySpecs.empty_frozen_array.send(@method) {} }.should raise_error(FrozenError) + -> { ArraySpecs.empty_frozen_array.send(@method) {} }.should.raise(FrozenError) end it "raises a FrozenError when calling #each on the returned Enumerator" do enumerator = ArraySpecs.frozen_array.send(@method) - -> { enumerator.each {|x| x } }.should raise_error(FrozenError) + -> { enumerator.each {|x| x } }.should.raise(FrozenError) end it "raises a FrozenError when calling #each on the returned Enumerator when empty" do enumerator = ArraySpecs.empty_frozen_array.send(@method) - -> { enumerator.each {|x| x } }.should raise_error(FrozenError) + -> { enumerator.each {|x| x } }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/shared/difference.rb b/spec/ruby/core/array/shared/difference.rb index 3e69050d826488..3fe22331bde2ec 100644 --- a/spec/ruby/core/array/shared/difference.rb +++ b/spec/ruby/core/array/shared/difference.rb @@ -27,13 +27,13 @@ it "raises a TypeError if the argument cannot be coerced to an Array by calling #to_ary" do obj = mock('not an array') - -> { [1, 2, 3].send(@method, obj) }.should raise_error(TypeError) + -> { [1, 2, 3].send(@method, obj) }.should.raise(TypeError) end it "does not return subclass instance for Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].send(@method, []).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[]).should be_an_instance_of(Array) - [1, 2, 3].send(@method, ArraySpecs::MyArray[]).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].send(@method, []).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[]).should.instance_of?(Array) + [1, 2, 3].send(@method, ArraySpecs::MyArray[]).should.instance_of?(Array) end it "does not call to_ary on array subclasses" do diff --git a/spec/ruby/core/array/shared/enumeratorize.rb b/spec/ruby/core/array/shared/enumeratorize.rb index a19a5d3b9b8c95..5beab5c4c448e4 100644 --- a/spec/ruby/core/array/shared/enumeratorize.rb +++ b/spec/ruby/core/array/shared/enumeratorize.rb @@ -1,5 +1,5 @@ describe :enumeratorize, shared: true do it "returns an Enumerator if no block given" do - [1,2].send(@method).should be_an_instance_of(Enumerator) + [1,2].send(@method).should.instance_of?(Enumerator) end end diff --git a/spec/ruby/core/array/shared/eql.rb b/spec/ruby/core/array/shared/eql.rb index b5d9128434d863..5e770bf16761b0 100644 --- a/spec/ruby/core/array/shared/eql.rb +++ b/spec/ruby/core/array/shared/eql.rb @@ -1,59 +1,59 @@ describe :array_eql, shared: true do it "returns true if other is the same array" do a = [1] - a.send(@method, a).should be_true + a.send(@method, a).should == true end it "returns true if corresponding elements are #eql?" do - [].send(@method, []).should be_true - [1, 2, 3, 4].send(@method, [1, 2, 3, 4]).should be_true + [].send(@method, []).should == true + [1, 2, 3, 4].send(@method, [1, 2, 3, 4]).should == true end it "returns false if other is shorter than self" do - [1, 2, 3, 4].send(@method, [1, 2, 3]).should be_false + [1, 2, 3, 4].send(@method, [1, 2, 3]).should == false end it "returns false if other is longer than self" do - [1, 2, 3, 4].send(@method, [1, 2, 3, 4, 5]).should be_false + [1, 2, 3, 4].send(@method, [1, 2, 3, 4, 5]).should == false end it "returns false immediately when sizes of the arrays differ" do obj = mock('1') obj.should_not_receive(@method) - [] .send(@method, [obj] ).should be_false - [obj] .send(@method, [] ).should be_false + [] .send(@method, [obj] ).should == false + [obj] .send(@method, [] ).should == false end it "handles well recursive arrays" do a = ArraySpecs.empty_recursive_array - a .send(@method, [a] ).should be_true - a .send(@method, [[a]] ).should be_true - [a] .send(@method, a ).should be_true - [[a]] .send(@method, a ).should be_true + a .send(@method, [a] ).should == true + a .send(@method, [[a]] ).should == true + [a] .send(@method, a ).should == true + [[a]] .send(@method, a ).should == true # These may be surprising, but no difference can be # found between these arrays, so they are ==. # There is no "path" that will lead to a difference # (contrary to other examples below) a2 = ArraySpecs.empty_recursive_array - a .send(@method, a2 ).should be_true - a .send(@method, [a2] ).should be_true - a .send(@method, [[a2]] ).should be_true - [a] .send(@method, a2 ).should be_true - [[a]] .send(@method, a2 ).should be_true + a .send(@method, a2 ).should == true + a .send(@method, [a2] ).should == true + a .send(@method, [[a2]] ).should == true + [a] .send(@method, a2 ).should == true + [[a]] .send(@method, a2 ).should == true back = [] forth = [back]; back << forth; - back .send(@method, a ).should be_true + back .send(@method, a ).should == true x = []; x << x << x - x .send(@method, a ).should be_false # since x.size != a.size - x .send(@method, [a, a] ).should be_false # since x[0].size != [a, a][0].size - x .send(@method, [x, a] ).should be_false # since x[1].size != [x, a][1].size - [x, a] .send(@method, [a, x] ).should be_false # etc... - x .send(@method, [x, x] ).should be_true - x .send(@method, [[x, x], [x, x]] ).should be_true + x .send(@method, a ).should == false # since x.size != a.size + x .send(@method, [a, a] ).should == false # since x[0].size != [a, a][0].size + x .send(@method, [x, a] ).should == false # since x[1].size != [x, a][1].size + [x, a] .send(@method, [a, x] ).should == false # etc... + x .send(@method, [x, x] ).should == true + x .send(@method, [[x, x], [x, x]] ).should == true tree = []; branch = []; branch << tree << tree; tree << branch @@ -62,31 +62,31 @@ forest = [tree, branch, :bird, a]; forest << forest forest2 = [tree2, branch2, :bird, a2]; forest2 << forest2 - forest .send(@method, forest2 ).should be_true - forest .send(@method, [tree2, branch, :bird, a, forest2]).should be_true + forest .send(@method, forest2 ).should == true + forest .send(@method, [tree2, branch, :bird, a, forest2]).should == true diffforest = [branch2, tree2, :bird, a2]; diffforest << forest2 - forest .send(@method, diffforest ).should be_false # since forest[0].size == 1 != 3 == diffforest[0] - forest .send(@method, [nil] ).should be_false - forest .send(@method, [forest] ).should be_false + forest .send(@method, diffforest ).should == false # since forest[0].size == 1 != 3 == diffforest[0] + forest .send(@method, [nil] ).should == false + forest .send(@method, [forest] ).should == false end it "does not call #to_ary on its argument" do obj = mock('to_ary') obj.should_not_receive(:to_ary) - [1, 2, 3].send(@method, obj).should be_false + [1, 2, 3].send(@method, obj).should == false end it "does not call #to_ary on Array subclasses" do ary = ArraySpecs::ToAryArray[5, 6, 7] ary.should_not_receive(:to_ary) - [5, 6, 7].send(@method, ary).should be_true + [5, 6, 7].send(@method, ary).should == true end it "ignores array class differences" do - ArraySpecs::MyArray[1, 2, 3].send(@method, [1, 2, 3]).should be_true - ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_true - [1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_true + ArraySpecs::MyArray[1, 2, 3].send(@method, [1, 2, 3]).should == true + ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should == true + [1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should == true end end diff --git a/spec/ruby/core/array/shared/index.rb b/spec/ruby/core/array/shared/index.rb index a4a0adbab664be..cc6d6cfb5b6f83 100644 --- a/spec/ruby/core/array/shared/index.rb +++ b/spec/ruby/core/array/shared/index.rb @@ -33,7 +33,7 @@ def x.==(obj) 3 == obj; end describe "given no argument and no block" do it "produces an Enumerator" do - [].send(@method).should be_an_instance_of(Enumerator) + [].send(@method).should.instance_of?(Enumerator) end end diff --git a/spec/ruby/core/array/shared/inspect.rb b/spec/ruby/core/array/shared/inspect.rb index af5128c645ac29..7197cd7f264813 100644 --- a/spec/ruby/core/array/shared/inspect.rb +++ b/spec/ruby/core/array/shared/inspect.rb @@ -2,7 +2,7 @@ describe :array_inspect, shared: true do it "returns a string" do - [1, 2, 3].send(@method).should be_an_instance_of(String) + [1, 2, 3].send(@method).should.instance_of?(String) end it "returns '[]' for an empty Array" do @@ -55,7 +55,7 @@ obj.should_receive(:inspect).and_return(obj) obj.should_receive(:to_s).and_raise(Exception) - -> { [obj].send(@method) }.should raise_error(Exception) + -> { [obj].send(@method) }.should.raise(Exception) end it "represents a recursive element with '[...]'" do diff --git a/spec/ruby/core/array/shared/intersection.rb b/spec/ruby/core/array/shared/intersection.rb index 0b4166ab6338e6..dda72e8bd796db 100644 --- a/spec/ruby/core/array/shared/intersection.rb +++ b/spec/ruby/core/array/shared/intersection.rb @@ -66,9 +66,9 @@ end it "does return subclass instances for Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].send(@method, []).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_an_instance_of(Array) - [].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].send(@method, []).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should.instance_of?(Array) + [].send(@method, ArraySpecs::MyArray[1, 2, 3]).should.instance_of?(Array) end it "does not call to_ary on array subclasses" do diff --git a/spec/ruby/core/array/shared/join.rb b/spec/ruby/core/array/shared/join.rb index 507b13e3c8abe6..2be60a4dbcd226 100644 --- a/spec/ruby/core/array/shared/join.rb +++ b/spec/ruby/core/array/shared/join.rb @@ -49,13 +49,13 @@ it "raises a NoMethodError if an element does not respond to #to_str, #to_ary, or #to_s" do obj = mock('o') class << obj; undef :to_s; end - -> { [1, obj].send(@method) }.should raise_error(NoMethodError) + -> { [1, obj].send(@method) }.should.raise(NoMethodError) end it "raises an ArgumentError when the Array is recursive" do - -> { ArraySpecs.recursive_array.send(@method) }.should raise_error(ArgumentError) - -> { ArraySpecs.head_recursive_array.send(@method) }.should raise_error(ArgumentError) - -> { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError) + -> { ArraySpecs.recursive_array.send(@method) }.should.raise(ArgumentError) + -> { ArraySpecs.head_recursive_array.send(@method) }.should.raise(ArgumentError) + -> { ArraySpecs.empty_recursive_array.send(@method) }.should.raise(ArgumentError) end it "uses the first encoding when other strings are compatible" do @@ -81,7 +81,7 @@ class << obj; undef :to_s; end it "fails for arrays with incompatibly-encoded strings" do ary_utf8_bad_binary = ArraySpecs.array_with_utf8_and_binary_strings - -> { ary_utf8_bad_binary.send(@method) }.should raise_error(EncodingError) + -> { ary_utf8_bad_binary.send(@method) }.should.raise(EncodingError) end context "when $, is not nil" do diff --git a/spec/ruby/core/array/shared/keep_if.rb b/spec/ruby/core/array/shared/keep_if.rb index 43a047c0a78f19..44625eebd1d295 100644 --- a/spec/ruby/core/array/shared/keep_if.rb +++ b/spec/ruby/core/array/shared/keep_if.rb @@ -4,12 +4,12 @@ describe :keep_if, shared: true do it "deletes elements for which the block returns a false value" do array = [1, 2, 3, 4, 5] - array.send(@method) {|item| item > 3 }.should equal(array) + array.send(@method) {|item| item > 3 }.should.equal?(array) array.should == [4, 5] end it "returns an enumerator if no block is given" do - [1, 2, 3].send(@method).should be_an_instance_of(Enumerator) + [1, 2, 3].send(@method).should.instance_of?(Enumerator) end it "updates the receiver after all blocks" do @@ -33,34 +33,34 @@ end it "returns an Enumerator if no block is given" do - @frozen.send(@method).should be_an_instance_of(Enumerator) + @frozen.send(@method).should.instance_of?(Enumerator) end describe "with truthy block" do it "keeps elements after any exception" do - -> { @frozen.send(@method) { true } }.should raise_error(Exception) + -> { @frozen.send(@method) { true } }.should.raise(Exception) @frozen.should == @origin end it "raises a FrozenError" do - -> { @frozen.send(@method) { true } }.should raise_error(FrozenError) + -> { @frozen.send(@method) { true } }.should.raise(FrozenError) end end describe "with falsy block" do it "keeps elements after any exception" do - -> { @frozen.send(@method) { false } }.should raise_error(Exception) + -> { @frozen.send(@method) { false } }.should.raise(Exception) @frozen.should == @origin end it "raises a FrozenError" do - -> { @frozen.send(@method) { false } }.should raise_error(FrozenError) + -> { @frozen.send(@method) { false } }.should.raise(FrozenError) end end it "raises a FrozenError on a frozen array only during iteration if called without a block" do enum = @frozen.send(@method) - -> { enum.each {} }.should raise_error(FrozenError) + -> { enum.each {} }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/shared/push.rb b/spec/ruby/core/array/shared/push.rb index ac790fb6a4eada..ec406e506e19b3 100644 --- a/spec/ruby/core/array/shared/push.rb +++ b/spec/ruby/core/array/shared/push.rb @@ -1,7 +1,7 @@ describe :array_push, shared: true do it "appends the arguments to the array" do a = [ "a", "b", "c" ] - a.send(@method, "d", "e", "f").should equal(a) + a.send(@method, "d", "e", "f").should.equal?(a) a.send(@method).should == ["a", "b", "c", "d", "e", "f"] a.send(@method, 5) a.should == ["a", "b", "c", "d", "e", "f", 5] @@ -27,7 +27,7 @@ end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(FrozenError) - -> { ArraySpecs.frozen_array.send(@method) }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.send(@method, 1) }.should.raise(FrozenError) + -> { ArraySpecs.frozen_array.send(@method) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/shared/replace.rb b/spec/ruby/core/array/shared/replace.rb index 9a6e60c1b02186..06bfd00795c9b4 100644 --- a/spec/ruby/core/array/shared/replace.rb +++ b/spec/ruby/core/array/shared/replace.rb @@ -2,9 +2,9 @@ it "replaces the elements with elements from other array" do a = [1, 2, 3, 4, 5] b = ['a', 'b', 'c'] - a.send(@method, b).should equal(a) + a.send(@method, b).should.equal?(a) a.should == b - a.should_not equal(b) + a.should_not.equal?(b) a.send(@method, [4] * 10) a.should == [4] * 10 @@ -27,7 +27,7 @@ it "returns self" do ary = [1, 2, 3] other = [:a, :b, :c] - ary.send(@method, other).should equal(ary) + ary.send(@method, other).should.equal?(ary) end it "does not make self dependent to the original array" do @@ -55,6 +55,6 @@ it "raises a FrozenError on a frozen array" do -> { ArraySpecs.frozen_array.send(@method, ArraySpecs.frozen_array) - }.should raise_error(FrozenError) + }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/array/shared/select.rb b/spec/ruby/core/array/shared/select.rb index 9c2cbf76c47f18..cb4f9acbb799b4 100644 --- a/spec/ruby/core/array/shared/select.rb +++ b/spec/ruby/core/array/shared/select.rb @@ -20,7 +20,7 @@ end it "does not return subclass instance on Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].send(@method) { true }.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].send(@method) { true }.should.instance_of?(Array) end it "properly handles recursive arrays" do diff --git a/spec/ruby/core/array/shared/slice.rb b/spec/ruby/core/array/shared/slice.rb index b80261d32fd64d..b838d86118c7ee 100644 --- a/spec/ruby/core/array/shared/slice.rb +++ b/spec/ruby/core/array/shared/slice.rb @@ -130,12 +130,12 @@ def to.<=>(o) 0 end def from.to_int() 'cat' end def to.to_int() -2 end - -> { a.send(@method, from..to) }.should raise_error(TypeError) + -> { a.send(@method, from..to) }.should.raise(TypeError) def from.to_int() 1 end def to.to_int() 'cat' end - -> { a.send(@method, from..to) }.should raise_error(TypeError) + -> { a.send(@method, from..to) }.should.raise(TypeError) end it "returns the elements specified by Range indexes with [m..n]" do @@ -287,10 +287,10 @@ def to.to_int() -2 end a.send(@method, 1..0).should == [] a.send(@method, 1...0).should == [] - -> { a.send(@method, "a" .. "b") }.should raise_error(TypeError) - -> { a.send(@method, "a" ... "b") }.should raise_error(TypeError) - -> { a.send(@method, from .. "b") }.should raise_error(TypeError) - -> { a.send(@method, from ... "b") }.should raise_error(TypeError) + -> { a.send(@method, "a" .. "b") }.should.raise(TypeError) + -> { a.send(@method, "a" ... "b") }.should.raise(TypeError) + -> { a.send(@method, from .. "b") }.should.raise(TypeError) + -> { a.send(@method, from ... "b") }.should.raise(TypeError) end it "returns the same elements as [m..n] and [m...n] with Range subclasses" do @@ -398,63 +398,63 @@ def to.to_int() -2 end end it "returns a Array instance with [n, m]" do - @array.send(@method, 0, 2).should be_an_instance_of(Array) + @array.send(@method, 0, 2).should.instance_of?(Array) end it "returns a Array instance with [-n, m]" do - @array.send(@method, -3, 2).should be_an_instance_of(Array) + @array.send(@method, -3, 2).should.instance_of?(Array) end it "returns a Array instance with [n..m]" do - @array.send(@method, 1..3).should be_an_instance_of(Array) + @array.send(@method, 1..3).should.instance_of?(Array) end it "returns a Array instance with [n...m]" do - @array.send(@method, 1...3).should be_an_instance_of(Array) + @array.send(@method, 1...3).should.instance_of?(Array) end it "returns a Array instance with [-n..-m]" do - @array.send(@method, -3..-1).should be_an_instance_of(Array) + @array.send(@method, -3..-1).should.instance_of?(Array) end it "returns a Array instance with [-n...-m]" do - @array.send(@method, -3...-1).should be_an_instance_of(Array) + @array.send(@method, -3...-1).should.instance_of?(Array) end it "returns an empty array when m == n with [m...n]" do @array.send(@method, 1...1).should == [] - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "returns an empty array with [0...0]" do @array.send(@method, 0...0).should == [] - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "returns an empty array when m > n and m, n are positive with [m..n]" do @array.send(@method, 3..2).should == [] - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "returns an empty array when m > n and m, n are negative with [m..n]" do @array.send(@method, -2..-3).should == [] - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "returns [] if index == array.size with [index, length]" do @array.send(@method, 5, 2).should == [] - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "returns [] if the index is valid but length is zero with [index, length]" do @array.send(@method, 0, 0).should == [] @array.send(@method, 2, 0).should == [] - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "does not call #initialize on the subclass instance" do @array.send(@method, 0, 3).should == [1, 2, 3] - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end end @@ -462,13 +462,13 @@ def to.to_int() -2 end array = [1, 2, 3, 4, 5, 6] obj = mock('large value') obj.should_receive(:to_int).and_return(bignum_value) - -> { array.send(@method, obj) }.should raise_error(RangeError) + -> { array.send(@method, obj) }.should.raise(RangeError) obj = 8e19 - -> { array.send(@method, obj) }.should raise_error(RangeError) + -> { array.send(@method, obj) }.should.raise(RangeError) # boundary value when longs are 64 bits - -> { array.send(@method, 2.0**63) }.should raise_error(RangeError) + -> { array.send(@method, 2.0**63) }.should.raise(RangeError) # just under the boundary value when longs are 64 bits array.send(@method, max_long.to_f.prev_float).should == nil @@ -478,20 +478,20 @@ def to.to_int() -2 end array = [1, 2, 3, 4, 5, 6] obj = mock('large value') obj.should_receive(:to_int).and_return(bignum_value) - -> { array.send(@method, 1, obj) }.should raise_error(RangeError) + -> { array.send(@method, 1, obj) }.should.raise(RangeError) obj = 8e19 - -> { array.send(@method, 1, obj) }.should raise_error(RangeError) + -> { array.send(@method, 1, obj) }.should.raise(RangeError) end it "raises a type error if a range is passed with a length" do - ->{ [1, 2, 3].send(@method, 1..2, 1) }.should raise_error(TypeError) + ->{ [1, 2, 3].send(@method, 1..2, 1) }.should.raise(TypeError) end it "raises a RangeError if passed a range with a bound that is too large" do array = [1, 2, 3, 4, 5, 6] - -> { array.send(@method, bignum_value..(bignum_value + 1)) }.should raise_error(RangeError) - -> { array.send(@method, 0..bignum_value) }.should raise_error(RangeError) + -> { array.send(@method, bignum_value..(bignum_value + 1)) }.should.raise(RangeError) + -> { array.send(@method, 0..bignum_value) }.should.raise(RangeError) end it "can accept endless ranges" do @@ -718,17 +718,17 @@ def to.to_int() -2 end it "has range with bounds outside of array" do # end is equal to array's length @array.send(@method, (0..6).step(1)).should == [0, 1, 2, 3, 4, 5] - -> { @array.send(@method, (0..6).step(2)) }.should raise_error(RangeError) + -> { @array.send(@method, (0..6).step(2)) }.should.raise(RangeError) # end is greater than length with positive steps @array.send(@method, (1..6).step(2)).should == [1, 3, 5] @array.send(@method, (2..7).step(2)).should == [2, 4] - -> { @array.send(@method, (2..8).step(2)) }.should raise_error(RangeError) + -> { @array.send(@method, (2..8).step(2)) }.should.raise(RangeError) # begin is greater than length with negative steps @array.send(@method, (6..1).step(-2)).should == [5, 3, 1] @array.send(@method, (7..2).step(-2)).should == [5, 3] - -> { @array.send(@method, (8..2).step(-2)) }.should raise_error(RangeError) + -> { @array.send(@method, (8..2).step(-2)) }.should.raise(RangeError) end it "has endless range with start outside of array's bounds" do @@ -736,7 +736,7 @@ def to.to_int() -2 end @array.send(@method, eval("(7..).step(1)")).should == nil @array.send(@method, eval("(6..).step(2)")).should == [] - -> { @array.send(@method, eval("(7..).step(2)")) }.should raise_error(RangeError) + -> { @array.send(@method, eval("(7..).step(2)")) }.should.raise(RangeError) end end diff --git a/spec/ruby/core/array/shared/union.rb b/spec/ruby/core/array/shared/union.rb index 0b60df9ca4d9ab..0b225b9a31253e 100644 --- a/spec/ruby/core/array/shared/union.rb +++ b/spec/ruby/core/array/shared/union.rb @@ -60,9 +60,9 @@ end it "does not return subclass instances for Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].send(@method, []).should be_an_instance_of(Array) - ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_an_instance_of(Array) - [].send(@method, ArraySpecs::MyArray[1, 2, 3]).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].send(@method, []).should.instance_of?(Array) + ArraySpecs::MyArray[1, 2, 3].send(@method, ArraySpecs::MyArray[1, 2, 3]).should.instance_of?(Array) + [].send(@method, ArraySpecs::MyArray[1, 2, 3]).should.instance_of?(Array) end it "does not call to_ary on array subclasses" do diff --git a/spec/ruby/core/array/shared/unshift.rb b/spec/ruby/core/array/shared/unshift.rb index 9e0fe7556a43af..b636347cd36d33 100644 --- a/spec/ruby/core/array/shared/unshift.rb +++ b/spec/ruby/core/array/shared/unshift.rb @@ -1,9 +1,9 @@ describe :array_unshift, shared: true do it "prepends object to the original array" do a = [1, 2, 3] - a.send(@method, "a").should equal(a) + a.send(@method, "a").should.equal?(a) a.should == ['a', 1, 2, 3] - a.send(@method).should equal(a) + a.send(@method).should.equal?(a) a.should == ['a', 1, 2, 3] a.send(@method, 5, 4, 3) a.should == [5, 4, 3, 'a', 1, 2, 3] @@ -41,12 +41,12 @@ end it "raises a FrozenError on a frozen array when the array is modified" do - -> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.send(@method, 1) }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen array when the array would not be modified" do - -> { ArraySpecs.frozen_array.send(@method) }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.send(@method) }.should.raise(FrozenError) end # https://github.com/truffleruby/truffleruby/issues/2772 diff --git a/spec/ruby/core/array/shift_spec.rb b/spec/ruby/core/array/shift_spec.rb index 6b4ef39f77c270..09dfa79c45fdae 100644 --- a/spec/ruby/core/array/shift_spec.rb +++ b/spec/ruby/core/array/shift_spec.rb @@ -31,10 +31,10 @@ end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.shift }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.shift }.should.raise(FrozenError) end it "raises a FrozenError on an empty frozen array" do - -> { ArraySpecs.empty_frozen_array.shift }.should raise_error(FrozenError) + -> { ArraySpecs.empty_frozen_array.shift }.should.raise(FrozenError) end describe "passed a number n as an argument" do @@ -72,7 +72,7 @@ popped2.should == [] a.should == [] - popped1.should_not equal(popped2) + popped1.should_not.equal?(popped2) end it "returns whole elements if n exceeds size of the array" do @@ -83,14 +83,14 @@ it "does not return self even when it returns whole elements" do a = [1, 2, 3, 4, 5] - a.shift(5).should_not equal(a) + a.shift(5).should_not.equal?(a) a = [1, 2, 3, 4, 5] - a.shift(6).should_not equal(a) + a.shift(6).should_not.equal?(a) end it "raises an ArgumentError if n is negative" do - ->{ [1, 2, 3].shift(-1) }.should raise_error(ArgumentError) + ->{ [1, 2, 3].shift(-1) }.should.raise(ArgumentError) end it "tries to convert n to an Integer using #to_int" do @@ -105,16 +105,16 @@ end it "raises a TypeError when the passed n cannot be coerced to Integer" do - ->{ [1, 2].shift("cat") }.should raise_error(TypeError) - ->{ [1, 2].shift(nil) }.should raise_error(TypeError) + ->{ [1, 2].shift("cat") }.should.raise(TypeError) + ->{ [1, 2].shift(nil) }.should.raise(TypeError) end it "raises an ArgumentError if more arguments are passed" do - ->{ [1, 2].shift(1, 2) }.should raise_error(ArgumentError) + ->{ [1, 2].shift(1, 2) }.should.raise(ArgumentError) end it "does not return subclass instances with Array subclass" do - ArraySpecs::MyArray[1, 2, 3].shift(2).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].shift(2).should.instance_of?(Array) end end end diff --git a/spec/ruby/core/array/shuffle_spec.rb b/spec/ruby/core/array/shuffle_spec.rb index b84394bcb5b7cb..9bc9df73ac2126 100644 --- a/spec/ruby/core/array/shuffle_spec.rb +++ b/spec/ruby/core/array/shuffle_spec.rb @@ -10,7 +10,7 @@ s.sort.should == a different ||= (a != s) end - different.should be_true # Will fail once in a blue moon (4!^10) + different.should == true # Will fail once in a blue moon (4!^10) end it "is not destructive" do @@ -22,7 +22,7 @@ end it "does not return subclass instances with Array subclass" do - ArraySpecs::MyArray[1, 2, 3].shuffle.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].shuffle.should.instance_of?(Array) end it "calls #rand on the Object passed by the :random key in the arguments Hash" do @@ -31,24 +31,24 @@ result = [1, 2].shuffle(random: obj) result.size.should == 2 - result.should include(1, 2) + result.sort.should == [1, 2] end it "raises a NoMethodError if an object passed for the RNG does not define #rand" do obj = BasicObject.new - -> { [1, 2].shuffle(random: obj) }.should raise_error(NoMethodError) + -> { [1, 2].shuffle(random: obj) }.should.raise(NoMethodError) end it "accepts a Float for the value returned by #rand" do random = mock("array_shuffle_random") random.should_receive(:rand).at_least(1).times.and_return(0.3) - [1, 2].shuffle(random: random).should be_an_instance_of(Array) + [1, 2].shuffle(random: random).should.instance_of?(Array) end it "accepts a Random class for the value for random: argument" do - [1, 2].shuffle(random: Random).should be_an_instance_of(Array) + [1, 2].shuffle(random: Random).should.instance_of?(Array) end it "calls #to_int on the Object returned by #rand" do @@ -57,7 +57,7 @@ random = mock("array_shuffle_random") random.should_receive(:rand).at_least(1).times.and_return(value) - [1, 2].shuffle(random: random).should be_an_instance_of(Array) + [1, 2].shuffle(random: random).should.instance_of?(Array) end it "raises a RangeError if the value is less than zero" do @@ -66,7 +66,7 @@ random = mock("array_shuffle_random") random.should_receive(:rand).and_return(value) - -> { [1, 2].shuffle(random: random) }.should raise_error(RangeError) + -> { [1, 2].shuffle(random: random) }.should.raise(RangeError) end it "raises a RangeError if the value is equal to the Array size" do @@ -75,7 +75,7 @@ random = mock("array_shuffle_random") random.should_receive(:rand).at_least(1).times.and_return(value) - -> { [1, 2].shuffle(random: random) }.should raise_error(RangeError) + -> { [1, 2].shuffle(random: random) }.should.raise(RangeError) end it "raises a RangeError if the value is greater than the Array size" do @@ -84,7 +84,7 @@ random = mock("array_shuffle_random") random.should_receive(:rand).at_least(1).times.and_return(value) - -> { [1, 2].shuffle(random: random) }.should raise_error(RangeError) + -> { [1, 2].shuffle(random: random) }.should.raise(RangeError) end end @@ -98,13 +98,13 @@ a.sort.should == [1, 2, 3, 4] different ||= (a != [1, 2, 3, 4]) end - different.should be_true # Will fail once in a blue moon (4!^10) - a.should equal(original) + different.should == true # Will fail once in a blue moon (4!^10) + a.should.equal?(original) end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.shuffle! }.should raise_error(FrozenError) - -> { ArraySpecs.empty_frozen_array.shuffle! }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.shuffle! }.should.raise(FrozenError) + -> { ArraySpecs.empty_frozen_array.shuffle! }.should.raise(FrozenError) end it "matches CRuby with random:" do diff --git a/spec/ruby/core/array/slice_spec.rb b/spec/ruby/core/array/slice_spec.rb index 731c12925125bf..eb7e47d9476ea3 100644 --- a/spec/ruby/core/array/slice_spec.rb +++ b/spec/ruby/core/array/slice_spec.rb @@ -116,8 +116,8 @@ def to.to_int() -2 end a.slice!(from .. to).should == [2, 3, 4] a.should == [1, 5] - -> { a.slice!("a" .. "b") }.should raise_error(TypeError) - -> { a.slice!(from .. "b") }.should raise_error(TypeError) + -> { a.slice!("a" .. "b") }.should.raise(TypeError) + -> { a.slice!(from .. "b") }.should.raise(TypeError) end it "returns last element for consecutive calls at zero index" do @@ -151,7 +151,7 @@ def to.to_int() -2 end end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.slice!(0, 0) }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.slice!(0, 0) }.should.raise(FrozenError) end it "works with endless ranges" do @@ -188,27 +188,27 @@ def to.to_int() -2 end end it "returns a Array instance with [n, m]" do - @array.slice!(0, 2).should be_an_instance_of(Array) + @array.slice!(0, 2).should.instance_of?(Array) end it "returns a Array instance with [-n, m]" do - @array.slice!(-3, 2).should be_an_instance_of(Array) + @array.slice!(-3, 2).should.instance_of?(Array) end it "returns a Array instance with [n..m]" do - @array.slice!(1..3).should be_an_instance_of(Array) + @array.slice!(1..3).should.instance_of?(Array) end it "returns a Array instance with [n...m]" do - @array.slice!(1...3).should be_an_instance_of(Array) + @array.slice!(1...3).should.instance_of?(Array) end it "returns a Array instance with [-n..-m]" do - @array.slice!(-3..-1).should be_an_instance_of(Array) + @array.slice!(-3..-1).should.instance_of?(Array) end it "returns a Array instance with [-n...-m]" do - @array.slice!(-3...-1).should be_an_instance_of(Array) + @array.slice!(-3...-1).should.instance_of?(Array) end end end diff --git a/spec/ruby/core/array/sort_by_spec.rb b/spec/ruby/core/array/sort_by_spec.rb index 0334f953f6c20a..132abb028a2327 100644 --- a/spec/ruby/core/array/sort_by_spec.rb +++ b/spec/ruby/core/array/sort_by_spec.rb @@ -11,30 +11,30 @@ end it "returns an Enumerator if not given a block" do - (1..10).to_a.sort_by!.should be_an_instance_of(Enumerator) + (1..10).to_a.sort_by!.should.instance_of?(Enumerator) end it "completes when supplied a block that always returns the same result" do a = [2, 3, 5, 1, 4] a.sort_by!{ 1 } - a.should be_an_instance_of(Array) + a.should.instance_of?(Array) a.sort_by!{ 0 } - a.should be_an_instance_of(Array) + a.should.instance_of?(Array) a.sort_by!{ -1 } - a.should be_an_instance_of(Array) + a.should.instance_of?(Array) end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.sort_by! {}}.should.raise(FrozenError) end it "raises a FrozenError on an empty frozen array" do - -> { ArraySpecs.empty_frozen_array.sort_by! {}}.should raise_error(FrozenError) + -> { ArraySpecs.empty_frozen_array.sort_by! {}}.should.raise(FrozenError) end it "raises a FrozenError on a frozen array only during iteration if called without a block" do enum = ArraySpecs.frozen_array.sort_by! - -> { enum.each {} }.should raise_error(FrozenError) + -> { enum.each {} }.should.raise(FrozenError) end it "returns the specified value when it would break in the given block" do @@ -47,7 +47,7 @@ ary.sort_by!{|x,y| break if x==i; x<=>y} ary } - partially_sorted.any?{|ary| ary != [1, 2, 3, 4, 5]}.should be_true + partially_sorted.any?{|ary| ary != [1, 2, 3, 4, 5]}.should == true end it "changes nothing when called on a single element array" do diff --git a/spec/ruby/core/array/sort_spec.rb b/spec/ruby/core/array/sort_spec.rb index e20b6505164da5..27300c338530bb 100644 --- a/spec/ruby/core/array/sort_spec.rb +++ b/spec/ruby/core/array/sort_spec.rb @@ -42,7 +42,7 @@ a = [1, 2, 3] sorted = a.sort sorted.should == a - sorted.should_not equal(a) + sorted.should_not.equal?(a) end it "properly handles recursive arrays" do @@ -68,7 +68,7 @@ -> { [o, 1].sort - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "may take a block which is used to determine the order of objects a and b described as -1, 0 or +1" do @@ -78,28 +78,28 @@ end it "raises an error when a given block returns nil" do - -> { [1, 2].sort {} }.should raise_error(ArgumentError) + -> { [1, 2].sort {} }.should.raise(ArgumentError) end it "does not call #<=> on contained objects when invoked with a block" do a = Array.new(25) (0...25).each {|i| a[i] = ArraySpecs::UFOSceptic.new } - a.sort { -1 }.should be_an_instance_of(Array) + a.sort { -1 }.should.instance_of?(Array) end it "does not call #<=> on elements when invoked with a block even if Array is large (Rubinius #412)" do a = Array.new(1500) (0...1500).each {|i| a[i] = ArraySpecs::UFOSceptic.new } - a.sort { -1 }.should be_an_instance_of(Array) + a.sort { -1 }.should.instance_of?(Array) end it "completes when supplied a block that always returns the same result" do a = [2, 3, 5, 1, 4] - a.sort { 1 }.should be_an_instance_of(Array) - a.sort { 0 }.should be_an_instance_of(Array) - a.sort { -1 }.should be_an_instance_of(Array) + a.sort { 1 }.should.instance_of?(Array) + a.sort { 0 }.should.instance_of?(Array) + a.sort { -1 }.should.instance_of?(Array) end it "does not freezes self during being sorted" do @@ -136,7 +136,7 @@ class Integer }.should == [-4, 1, 2, 5, 7, 10, 12] -> { a.sort { |n, m| (n - m).to_s } - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "sorts an array that has a value shifted off without a block" do @@ -155,7 +155,7 @@ class Integer it "raises an error if objects can't be compared" do a=[ArraySpecs::Uncomparable.new, ArraySpecs::Uncomparable.new] - -> {a.sort}.should raise_error(ArgumentError) + -> {a.sort}.should.raise(ArgumentError) end # From a strange Rubinius bug @@ -166,7 +166,7 @@ class Integer it "does not return subclass instance on Array subclasses" do ary = ArraySpecs::MyArray[1, 2, 3] - ary.sort.should be_an_instance_of(Array) + ary.sort.should.instance_of?(Array) end end @@ -184,13 +184,13 @@ class Integer it "returns self if the order of elements changed" do a = [6, 7, 2, 3, 7] - a.sort!.should equal(a) + a.sort!.should.equal?(a) a.should == [2, 3, 6, 7, 7] end it "returns self even if makes no modification" do a = [1, 2, 3, 4, 5] - a.sort!.should equal(a) + a.sort!.should.equal?(a) a.should == [1, 2, 3, 4, 5] end @@ -216,25 +216,25 @@ class Integer a = Array.new(25) (0...25).each {|i| a[i] = ArraySpecs::UFOSceptic.new } - a.sort! { -1 }.should be_an_instance_of(Array) + a.sort! { -1 }.should.instance_of?(Array) end it "does not call #<=> on elements when invoked with a block even if Array is large (Rubinius #412)" do a = Array.new(1500) (0...1500).each {|i| a[i] = ArraySpecs::UFOSceptic.new } - a.sort! { -1 }.should be_an_instance_of(Array) + a.sort! { -1 }.should.instance_of?(Array) end it "completes when supplied a block that always returns the same result" do a = [2, 3, 5, 1, 4] - a.sort!{ 1 }.should be_an_instance_of(Array) - a.sort!{ 0 }.should be_an_instance_of(Array) - a.sort!{ -1 }.should be_an_instance_of(Array) + a.sort!{ 1 }.should.instance_of?(Array) + a.sort!{ 0 }.should.instance_of?(Array) + a.sort!{ -1 }.should.instance_of?(Array) end it "raises a FrozenError on a frozen array" do - -> { ArraySpecs.frozen_array.sort! }.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.sort! }.should.raise(FrozenError) end it "returns the specified value when it would break in the given block" do @@ -247,6 +247,6 @@ class Integer ary.sort!{|x,y| break if x==i; x<=>y} ary } - partially_sorted.any?{|ary| ary != [1, 2, 3, 4, 5]}.should be_true + partially_sorted.any?{|ary| ary != [1, 2, 3, 4, 5]}.should == true end end diff --git a/spec/ruby/core/array/sum_spec.rb b/spec/ruby/core/array/sum_spec.rb index 1886d692faaddc..cd4ba4c2d8ebee 100644 --- a/spec/ruby/core/array/sum_spec.rb +++ b/spec/ruby/core/array/sum_spec.rb @@ -60,11 +60,11 @@ end it 'raises TypeError if any element are not numeric' do - -> { ["a"].sum }.should raise_error(TypeError) + -> { ["a"].sum }.should.raise(TypeError) end it 'raises TypeError if any element cannot be added to init value' do - -> { [1].sum([]) }.should raise_error(TypeError) + -> { [1].sum([]) }.should.raise(TypeError) end it "calls + to sum the elements" do diff --git a/spec/ruby/core/array/take_spec.rb b/spec/ruby/core/array/take_spec.rb index c4f0ac9aa4611e..837c734b77cd98 100644 --- a/spec/ruby/core/array/take_spec.rb +++ b/spec/ruby/core/array/take_spec.rb @@ -23,10 +23,10 @@ end it "raises an ArgumentError when the argument is negative" do - ->{ [1].take(-3) }.should raise_error(ArgumentError) + ->{ [1].take(-3) }.should.raise(ArgumentError) end it 'returns a Array instance for Array subclasses' do - ArraySpecs::MyArray[1, 2, 3, 4, 5].take(1).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3, 4, 5].take(1).should.instance_of?(Array) end end diff --git a/spec/ruby/core/array/take_while_spec.rb b/spec/ruby/core/array/take_while_spec.rb index 8f50260b42a7f9..7811edab9e08ad 100644 --- a/spec/ruby/core/array/take_while_spec.rb +++ b/spec/ruby/core/array/take_while_spec.rb @@ -16,7 +16,7 @@ end it 'returns a Array instance for Array subclasses' do - ArraySpecs::MyArray[1, 2, 3, 4, 5].take_while { |n| n < 4 }.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3, 4, 5].take_while { |n| n < 4 }.should.instance_of?(Array) end end diff --git a/spec/ruby/core/array/to_a_spec.rb b/spec/ruby/core/array/to_a_spec.rb index 49d0a4782e33d4..078de1638a1344 100644 --- a/spec/ruby/core/array/to_a_spec.rb +++ b/spec/ruby/core/array/to_a_spec.rb @@ -5,12 +5,12 @@ it "returns self" do a = [1, 2, 3] a.to_a.should == [1, 2, 3] - a.should equal(a.to_a) + a.should.equal?(a.to_a) end it "does not return subclass instance on Array subclasses" do e = ArraySpecs::MyArray.new(1, 2) - e.to_a.should be_an_instance_of(Array) + e.to_a.should.instance_of?(Array) e.to_a.should == [1, 2] end diff --git a/spec/ruby/core/array/to_ary_spec.rb b/spec/ruby/core/array/to_ary_spec.rb index 314699b709a7ad..dc5193158dbdf2 100644 --- a/spec/ruby/core/array/to_ary_spec.rb +++ b/spec/ruby/core/array/to_ary_spec.rb @@ -4,9 +4,9 @@ describe "Array#to_ary" do it "returns self" do a = [1, 2, 3] - a.should equal(a.to_ary) + a.should.equal?(a.to_ary) a = ArraySpecs::MyArray[1, 2, 3] - a.should equal(a.to_ary) + a.should.equal?(a.to_ary) end it "properly handles recursive arrays" do diff --git a/spec/ruby/core/array/to_h_spec.rb b/spec/ruby/core/array/to_h_spec.rb index 1c814f3d012c96..1d626763c2f1d8 100644 --- a/spec/ruby/core/array/to_h_spec.rb +++ b/spec/ruby/core/array/to_h_spec.rb @@ -25,19 +25,19 @@ end it "raises TypeError if an element is not an array" do - -> { [:x].to_h }.should raise_error(TypeError) + -> { [:x].to_h }.should.raise(TypeError) end it "raises ArgumentError if an element is not a [key, value] pair" do - -> { [[:x]].to_h }.should raise_error(ArgumentError) + -> { [[:x]].to_h }.should.raise(ArgumentError) end it "does not accept arguments" do - -> { [].to_h(:a, :b) }.should raise_error(ArgumentError) + -> { [].to_h(:a, :b) }.should.raise(ArgumentError) end it "produces a hash that returns nil for a missing element" do - [[:a, 1], [:b, 2]].to_h[:c].should be_nil + [[:a, 1], [:b, 2]].to_h[:c].should == nil end context "with block" do @@ -54,17 +54,17 @@ it "raises ArgumentError if block returns longer or shorter array" do -> do [:a, :b].to_h { |k| [k, k.to_s, 1] } - end.should raise_error(ArgumentError, /wrong array length at 0/) + end.should.raise(ArgumentError, /wrong array length at 0/) -> do [:a, :b].to_h { |k| [k] } - end.should raise_error(ArgumentError, /wrong array length at 0/) + end.should.raise(ArgumentError, /wrong array length at 0/) end it "raises TypeError if block returns something other than Array" do -> do [:a, :b].to_h { |k| "not-array" } - end.should raise_error(TypeError, /wrong element type String at 0/) + end.should.raise(TypeError, /wrong element type String at 0/) end it "coerces returned pair to Array with #to_ary" do @@ -80,7 +80,7 @@ -> do [:a].to_h { |k| x } - end.should raise_error(TypeError, /wrong element type MockObject at 0/) + end.should.raise(TypeError, /wrong element type MockObject at 0/) end end end diff --git a/spec/ruby/core/array/transpose_spec.rb b/spec/ruby/core/array/transpose_spec.rb index b39077f4c9dc0e..d45e9c351ca57b 100644 --- a/spec/ruby/core/array/transpose_spec.rb +++ b/spec/ruby/core/array/transpose_spec.rb @@ -32,7 +32,7 @@ end it "raises a TypeError if the passed Argument does not respond to #to_ary" do - -> { [Object.new, [:a, :b]].transpose }.should raise_error(TypeError) + -> { [Object.new, [:a, :b]].transpose }.should.raise(TypeError) end it "does not call to_ary on array subclass elements" do @@ -41,13 +41,13 @@ end it "raises an IndexError if the arrays are not of the same length" do - -> { [[1, 2], [:a]].transpose }.should raise_error(IndexError) + -> { [[1, 2], [:a]].transpose }.should.raise(IndexError) end it "does not return subclass instance on Array subclasses" do result = ArraySpecs::MyArray[ArraySpecs::MyArray[1, 2, 3], ArraySpecs::MyArray[4, 5, 6]].transpose - result.should be_an_instance_of(Array) - result[0].should be_an_instance_of(Array) - result[1].should be_an_instance_of(Array) + result.should.instance_of?(Array) + result[0].should.instance_of?(Array) + result[1].should.instance_of?(Array) end end diff --git a/spec/ruby/core/array/try_convert_spec.rb b/spec/ruby/core/array/try_convert_spec.rb index 2d5e14375f6e1e..3eaa0f4b7c2cf2 100644 --- a/spec/ruby/core/array/try_convert_spec.rb +++ b/spec/ruby/core/array/try_convert_spec.rb @@ -4,36 +4,36 @@ describe "Array.try_convert" do it "returns the argument if it's an Array" do x = Array.new - Array.try_convert(x).should equal(x) + Array.try_convert(x).should.equal?(x) end it "returns the argument if it's a kind of Array" do x = ArraySpecs::MyArray[] - Array.try_convert(x).should equal(x) + Array.try_convert(x).should.equal?(x) end it "returns nil when the argument does not respond to #to_ary" do - Array.try_convert(Object.new).should be_nil + Array.try_convert(Object.new).should == nil end it "sends #to_ary to the argument and returns the result if it's nil" do obj = mock("to_ary") obj.should_receive(:to_ary).and_return(nil) - Array.try_convert(obj).should be_nil + Array.try_convert(obj).should == nil end it "sends #to_ary to the argument and returns the result if it's an Array" do x = Array.new obj = mock("to_ary") obj.should_receive(:to_ary).and_return(x) - Array.try_convert(obj).should equal(x) + Array.try_convert(obj).should.equal?(x) end it "sends #to_ary to the argument and returns the result if it's a kind of Array" do x = ArraySpecs::MyArray[] obj = mock("to_ary") obj.should_receive(:to_ary).and_return(x) - Array.try_convert(obj).should equal(x) + Array.try_convert(obj).should.equal?(x) end it "sends #to_ary to the argument and raises TypeError if it's not a kind of Array" do @@ -45,6 +45,6 @@ it "does not rescue exceptions raised by #to_ary" do obj = mock("to_ary") obj.should_receive(:to_ary).and_raise(RuntimeError) - -> { Array.try_convert obj }.should raise_error(RuntimeError) + -> { Array.try_convert obj }.should.raise(RuntimeError) end end diff --git a/spec/ruby/core/array/union_spec.rb b/spec/ruby/core/array/union_spec.rb index ba2cc0d6b7dd17..110894e83d3bf0 100644 --- a/spec/ruby/core/array/union_spec.rb +++ b/spec/ruby/core/array/union_spec.rb @@ -15,7 +15,7 @@ end it "does not return subclass instances for Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].union.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].union.should.instance_of?(Array) end it "accepts multiple arguments" do diff --git a/spec/ruby/core/array/uniq_spec.rb b/spec/ruby/core/array/uniq_spec.rb index d5d826db15b1ce..0289bee7c2cc3d 100644 --- a/spec/ruby/core/array/uniq_spec.rb +++ b/spec/ruby/core/array/uniq_spec.rb @@ -86,7 +86,7 @@ def obj.eql?(o) end it "returns Array instance on Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].uniq.should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].uniq.should.instance_of?(Array) end it "properly handles an identical item even when its #eql? isn't reflexive" do @@ -138,7 +138,7 @@ def hash it "returns self" do a = [ "a", "a", "b", "b", "c" ] - a.should equal(a.uniq!) + a.should.equal?(a.uniq!) end it "properly handles recursive arrays" do @@ -185,17 +185,17 @@ def hash it "raises a FrozenError on a frozen array when the array is modified" do dup_ary = [1, 1, 2] dup_ary.freeze - -> { dup_ary.uniq! }.should raise_error(FrozenError) + -> { dup_ary.uniq! }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen array when the array would not be modified" do - -> { ArraySpecs.frozen_array.uniq!}.should raise_error(FrozenError) - -> { ArraySpecs.empty_frozen_array.uniq!}.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.uniq!}.should.raise(FrozenError) + -> { ArraySpecs.empty_frozen_array.uniq!}.should.raise(FrozenError) end it "doesn't yield to the block on a frozen array" do - -> { ArraySpecs.frozen_array.uniq!{ raise RangeError, "shouldn't yield"}}.should raise_error(FrozenError) + -> { ArraySpecs.frozen_array.uniq!{ raise RangeError, "shouldn't yield"}}.should.raise(FrozenError) end it "compares elements based on the value returned from the block" do diff --git a/spec/ruby/core/array/values_at_spec.rb b/spec/ruby/core/array/values_at_spec.rb index e85bbee400bf52..e11e7e4451c41a 100644 --- a/spec/ruby/core/array/values_at_spec.rb +++ b/spec/ruby/core/array/values_at_spec.rb @@ -59,7 +59,7 @@ def to.to_int() -2 end end it "does not return subclass instance on Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].values_at(0, 1..2, 1).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].values_at(0, 1..2, 1).should.instance_of?(Array) end it "works when given endless ranges" do diff --git a/spec/ruby/core/array/zip_spec.rb b/spec/ruby/core/array/zip_spec.rb index 2a0f64cb491e82..3ccdf143d69817 100644 --- a/spec/ruby/core/array/zip_spec.rb +++ b/spec/ruby/core/array/zip_spec.rb @@ -60,12 +60,12 @@ def obj.each end it "does not return subclass instance on Array subclasses" do - ArraySpecs::MyArray[1, 2, 3].zip(["a", "b"]).should be_an_instance_of(Array) + ArraySpecs::MyArray[1, 2, 3].zip(["a", "b"]).should.instance_of?(Array) end it "raises TypeError when some argument isn't Array and doesn't respond to #to_ary and #to_enum" do - -> { [1, 2, 3].zip(Object.new) }.should raise_error(TypeError, "wrong argument type Object (must respond to :each)") - -> { [1, 2, 3].zip(1) }.should raise_error(TypeError, "wrong argument type Integer (must respond to :each)") - -> { [1, 2, 3].zip(true) }.should raise_error(TypeError, "wrong argument type TrueClass (must respond to :each)") + -> { [1, 2, 3].zip(Object.new) }.should.raise(TypeError, "wrong argument type Object (must respond to :each)") + -> { [1, 2, 3].zip(1) }.should.raise(TypeError, "wrong argument type Integer (must respond to :each)") + -> { [1, 2, 3].zip(true) }.should.raise(TypeError, "wrong argument type TrueClass (must respond to :each)") end end diff --git a/spec/ruby/core/basicobject/__send___spec.rb b/spec/ruby/core/basicobject/__send___spec.rb index 005b1d0d9082de..2f814e448ca712 100644 --- a/spec/ruby/core/basicobject/__send___spec.rb +++ b/spec/ruby/core/basicobject/__send___spec.rb @@ -3,7 +3,7 @@ describe "BasicObject#__send__" do it "is a public instance method" do - BasicObject.should have_public_instance_method(:__send__) + BasicObject.public_instance_methods(false).should.include?(:__send__) end it_behaves_like :basicobject_send, :__send__ diff --git a/spec/ruby/core/basicobject/basicobject_spec.rb b/spec/ruby/core/basicobject/basicobject_spec.rb index 27a322e72cf4d5..af28de0687a53d 100644 --- a/spec/ruby/core/basicobject/basicobject_spec.rb +++ b/spec/ruby/core/basicobject/basicobject_spec.rb @@ -8,23 +8,23 @@ end it "raises NameError when referencing built-in constants" do - -> { class BasicObjectSpecs::BOSubclass; Kernel; end }.should raise_error(NameError) + -> { class BasicObjectSpecs::BOSubclass; Kernel; end }.should.raise(NameError) end it "does not define built-in constants (according to const_defined?)" do - BasicObject.const_defined?(:Kernel).should be_false + BasicObject.const_defined?(:Kernel).should == false end it "does not define built-in constants (according to defined?)" do - BasicObjectSpecs::BOSubclass.kernel_defined?.should be_nil + BasicObjectSpecs::BOSubclass.kernel_defined?.should == nil end it "is included in Object's list of constants" do - Object.constants(false).should include(:BasicObject) + Object.constants(false).should.include?(:BasicObject) end it "includes itself in its list of constants" do - BasicObject.constants(false).should include(:BasicObject) + BasicObject.constants(false).should.include?(:BasicObject) end end @@ -34,11 +34,11 @@ end it "is an instance of Class" do - @meta.should be_an_instance_of(Class) + @meta.should.instance_of?(Class) end it "has Class as superclass" do - @meta.superclass.should equal(Class) + @meta.superclass.should.equal?(Class) end it "contains methods for the BasicObject class" do @@ -57,11 +57,11 @@ def rubyspec_test_method() :test end end it "is an instance of Class" do - @meta.should be_an_instance_of(Class) + @meta.should.instance_of?(Class) end it "has BasicObject as superclass" do - @meta.superclass.should equal(BasicObject) + @meta.superclass.should.equal?(BasicObject) end it "contains methods defined for the BasicObject instance" do @@ -85,7 +85,7 @@ def test_method() :test end describe "BasicObject references" do it "can refer to BasicObject from within itself" do - -> { BasicObject::BasicObject }.should_not raise_error + -> { BasicObject::BasicObject }.should_not.raise end end end diff --git a/spec/ruby/core/basicobject/equal_spec.rb b/spec/ruby/core/basicobject/equal_spec.rb index ce28eaed95547b..c0f41dc0c0acb4 100644 --- a/spec/ruby/core/basicobject/equal_spec.rb +++ b/spec/ruby/core/basicobject/equal_spec.rb @@ -3,7 +3,7 @@ describe "BasicObject#equal?" do it "is a public instance method" do - BasicObject.should have_public_instance_method(:equal?) + BasicObject.public_instance_methods(false).should.include?(:equal?) end it_behaves_like :object_equal, :equal? @@ -15,7 +15,7 @@ def o1.__id__; 10; end def o2.__id__; 10; end } - o1.equal?(o2).should be_false + o1.equal?(o2).should == false end it "is unaffected by overriding object_id" do @@ -23,7 +23,7 @@ def o2.__id__; 10; end o1.stub!(:object_id).and_return(10) o2 = mock("object") o2.stub!(:object_id).and_return(10) - o1.equal?(o2).should be_false + o1.equal?(o2).should == false end it "is unaffected by overriding ==" do @@ -31,12 +31,12 @@ def o2.__id__; 10; end o1 = mock("object") o1.stub!(:==).and_return(true) o2 = mock("object") - o1.equal?(o2).should be_false + o1.equal?(o2).should == false # same objects, overriding == to return false o3 = mock("object") o3.stub!(:==).and_return(false) - o3.equal?(o3).should be_true + o3.equal?(o3).should == true end it "is unaffected by overriding eql?" do @@ -44,11 +44,11 @@ def o2.__id__; 10; end o1 = mock("object") o1.stub!(:eql?).and_return(true) o2 = mock("object") - o1.equal?(o2).should be_false + o1.equal?(o2).should == false # same objects, overriding eql? to return false o3 = mock("object") o3.stub!(:eql?).and_return(false) - o3.equal?(o3).should be_true + o3.equal?(o3).should == true end end diff --git a/spec/ruby/core/basicobject/equal_value_spec.rb b/spec/ruby/core/basicobject/equal_value_spec.rb index 6c825513c19243..eb951a8305f6b1 100644 --- a/spec/ruby/core/basicobject/equal_value_spec.rb +++ b/spec/ruby/core/basicobject/equal_value_spec.rb @@ -3,7 +3,7 @@ describe "BasicObject#==" do it "is a public instance method" do - BasicObject.should have_public_instance_method(:==) + BasicObject.public_instance_methods(false).should.include?(:==) end it_behaves_like :object_equal, :== diff --git a/spec/ruby/core/basicobject/initialize_spec.rb b/spec/ruby/core/basicobject/initialize_spec.rb index b7ce73ffd5c380..09e86676b61ac1 100644 --- a/spec/ruby/core/basicobject/initialize_spec.rb +++ b/spec/ruby/core/basicobject/initialize_spec.rb @@ -2,12 +2,12 @@ describe "BasicObject#initialize" do it "is a private instance method" do - BasicObject.should have_private_instance_method(:initialize) + BasicObject.private_instance_methods(false).should.include?(:initialize) end it "does not accept arguments" do -> { BasicObject.new("This", "makes it easier", "to call super", "from other constructors") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/basicobject/instance_eval_spec.rb b/spec/ruby/core/basicobject/instance_eval_spec.rb index 475910e56eba07..124d179b5a2228 100644 --- a/spec/ruby/core/basicobject/instance_eval_spec.rb +++ b/spec/ruby/core/basicobject/instance_eval_spec.rb @@ -7,31 +7,31 @@ end it "is a public instance method" do - BasicObject.should have_public_instance_method(:instance_eval) + BasicObject.public_instance_methods(false).should.include?(:instance_eval) end it "sets self to the receiver in the context of the passed block" do a = BasicObject.new - a.instance_eval { self }.equal?(a).should be_true + a.instance_eval { self }.equal?(a).should == true end it "evaluates strings" do a = BasicObject.new - a.instance_eval('self').equal?(a).should be_true + a.instance_eval('self').equal?(a).should == true end it "raises an ArgumentError when no arguments and no block are given" do - -> { "hola".instance_eval }.should raise_error(ArgumentError, "wrong number of arguments (given 0, expected 1..3)") + -> { "hola".instance_eval }.should.raise(ArgumentError, "wrong number of arguments (given 0, expected 1..3)") end it "raises an ArgumentError when a block and normal arguments are given" do - -> { "hola".instance_eval(4, 5) {|a,b| a + b } }.should raise_error(ArgumentError, "wrong number of arguments (given 2, expected 0)") + -> { "hola".instance_eval(4, 5) {|a,b| a + b } }.should.raise(ArgumentError, "wrong number of arguments (given 2, expected 0)") end it "raises an ArgumentError when more than 3 arguments are given" do -> { "hola".instance_eval("1 + 1", "some file", 0, "bogus") - }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") + }.should.raise(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") end it "yields the object to the block" do @@ -51,7 +51,7 @@ def foo end end f.foo.should == 1 - -> { Object.new.foo }.should raise_error(NoMethodError) + -> { Object.new.foo }.should.raise(NoMethodError) end it "preserves self in the original block when passed a block argument" do @@ -71,9 +71,9 @@ def foo it "binds self to the receiver" do s = "hola" - (s == s.instance_eval { self }).should be_true + (s == s.instance_eval { self }).should == true o = mock('o') - (o == o.instance_eval("self")).should be_true + (o == o.instance_eval("self")).should == true end it "executes in the context of the receiver" do @@ -95,15 +95,15 @@ def foo end it "raises TypeError for frozen objects when tries to set receiver's instance variables" do - -> { nil.instance_eval { @foo = 42 } }.should raise_error(FrozenError, "can't modify frozen NilClass: nil") - -> { true.instance_eval { @foo = 42 } }.should raise_error(FrozenError, "can't modify frozen TrueClass: true") - -> { false.instance_eval { @foo = 42 } }.should raise_error(FrozenError, "can't modify frozen FalseClass: false") - -> { 1.instance_eval { @foo = 42 } }.should raise_error(FrozenError, "can't modify frozen Integer: 1") - -> { :symbol.instance_eval { @foo = 42 } }.should raise_error(FrozenError, "can't modify frozen Symbol: :symbol") + -> { nil.instance_eval { @foo = 42 } }.should.raise(FrozenError, "can't modify frozen NilClass: nil") + -> { true.instance_eval { @foo = 42 } }.should.raise(FrozenError, "can't modify frozen TrueClass: true") + -> { false.instance_eval { @foo = 42 } }.should.raise(FrozenError, "can't modify frozen FalseClass: false") + -> { 1.instance_eval { @foo = 42 } }.should.raise(FrozenError, "can't modify frozen Integer: 1") + -> { :symbol.instance_eval { @foo = 42 } }.should.raise(FrozenError, "can't modify frozen Symbol: :symbol") obj = Object.new obj.freeze - -> { obj.instance_eval { @foo = 42 } }.should raise_error(FrozenError) + -> { obj.instance_eval { @foo = 42 } }.should.raise(FrozenError) end it "treats block-local variables as local to the block" do @@ -128,7 +128,7 @@ def foo class B; end B } - obj.singleton_class.const_get(:B).should be_an_instance_of(Class) + obj.singleton_class.const_get(:B).should.instance_of?(Class) end describe "constants lookup when a String given" do @@ -169,16 +169,16 @@ class B; end end it "doesn't get constants in the receiver if a block given" do - BasicObjectSpecs::InstEvalOuter::Inner::X_BY_BLOCK.should be_nil + BasicObjectSpecs::InstEvalOuter::Inner::X_BY_BLOCK.should == nil end it "raises a TypeError when defining methods on an immediate" do -> do 1.instance_eval { def foo; end } - end.should raise_error(TypeError) + end.should.raise(TypeError) -> do :foo.instance_eval { def foo; end } - end.should raise_error(TypeError) + end.should.raise(TypeError) end describe "class variables lookup" do @@ -217,23 +217,23 @@ class B; end it "does not have access to class variables in the receiver class when called with a String" do receiver = BasicObjectSpecs::InstEval::CVar::Get::ReceiverScope.new caller = BasicObjectSpecs::InstEval::CVar::Get::CallerWithoutCVarScope.new - -> { caller.get_class_variable_with_string(receiver) }.should raise_error(NameError, /uninitialized class variable @@cvar/) + -> { caller.get_class_variable_with_string(receiver) }.should.raise(NameError, /uninitialized class variable @@cvar/) end it "does not have access to class variables in the receiver's singleton class when called with a String" do receiver = BasicObjectSpecs::InstEval::CVar::Get::ReceiverWithCVarDefinedInSingletonClass caller = BasicObjectSpecs::InstEval::CVar::Get::CallerWithoutCVarScope.new - -> { caller.get_class_variable_with_string(receiver) }.should raise_error(NameError, /uninitialized class variable @@cvar/) + -> { caller.get_class_variable_with_string(receiver) }.should.raise(NameError, /uninitialized class variable @@cvar/) end end it "raises a TypeError when defining methods on numerics" do -> do (1.0).instance_eval { def foo; end } - end.should raise_error(TypeError) + end.should.raise(TypeError) -> do (1 << 64).instance_eval { def foo; end } - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "evaluates procs originating from methods" do diff --git a/spec/ruby/core/basicobject/instance_exec_spec.rb b/spec/ruby/core/basicobject/instance_exec_spec.rb index 370f03d33c6bd2..cfce9a65ade6ac 100644 --- a/spec/ruby/core/basicobject/instance_exec_spec.rb +++ b/spec/ruby/core/basicobject/instance_exec_spec.rb @@ -3,21 +3,21 @@ describe "BasicObject#instance_exec" do it "is a public instance method" do - BasicObject.should have_public_instance_method(:instance_exec) + BasicObject.public_instance_methods(false).should.include?(:instance_exec) end it "sets self to the receiver in the context of the passed block" do a = BasicObject.new - a.instance_exec { self }.equal?(a).should be_true + a.instance_exec { self }.equal?(a).should == true end it "passes arguments to the block" do a = BasicObject.new - a.instance_exec(1) { |b| b }.should equal(1) + a.instance_exec(1) { |b| b }.should.equal?(1) end it "raises a LocalJumpError unless given a block" do - -> { "hola".instance_exec }.should raise_error(LocalJumpError) + -> { "hola".instance_exec }.should.raise(LocalJumpError) end it "has an arity of -1" do @@ -25,17 +25,23 @@ end it "accepts arguments with a block" do - -> { "hola".instance_exec(4, 5) { |a,b| a + b } }.should_not raise_error + -> { "hola".instance_exec(4, 5) { |a,b| a + b } }.should_not.raise end it "doesn't pass self to the block as an argument" do - "hola".instance_exec { |o| o }.should be_nil + "hola".instance_exec { |o| o }.should == nil end it "passes any arguments to the block" do Object.new.instance_exec(1,2) {|one, two| one + two}.should == 3 end + describe "with optional argument" do + it "does not destructure a single array argument" do + Object.new.instance_exec([1, 2, 3]) { |a = 99| a }.should == [1, 2, 3] + end + end + it "only binds the exec to the receiver" do f = Object.new f.instance_exec do @@ -44,7 +50,7 @@ def foo end end f.foo.should == 1 - -> { Object.new.foo }.should raise_error(NoMethodError) + -> { Object.new.foo }.should.raise(NoMethodError) end # TODO: This should probably be replaced with a "should behave like" that uses @@ -71,17 +77,17 @@ def foo end it "sets class variables in the receiver" do - BasicObjectSpecs::InstExec.class_variables.should include(:@@count) + BasicObjectSpecs::InstExec.class_variables.should.include?(:@@count) BasicObjectSpecs::InstExec.send(:class_variable_get, :@@count).should == 2 end it "raises a TypeError when defining methods on an immediate" do -> do 1.instance_exec { def foo; end } - end.should raise_error(TypeError) + end.should.raise(TypeError) -> do :foo.instance_exec { def foo; end } - end.should raise_error(TypeError) + end.should.raise(TypeError) end quarantine! do # Not clean, leaves cvars lying around to break other specs @@ -99,9 +105,9 @@ def foo it "raises a TypeError when defining methods on numerics" do -> do (1.0).instance_exec { def foo; end } - end.should raise_error(TypeError) + end.should.raise(TypeError) -> do (1 << 64).instance_exec { def foo; end } - end.should raise_error(TypeError) + end.should.raise(TypeError) end end diff --git a/spec/ruby/core/basicobject/method_missing_spec.rb b/spec/ruby/core/basicobject/method_missing_spec.rb index a29d4375bce096..8785b41b211c60 100644 --- a/spec/ruby/core/basicobject/method_missing_spec.rb +++ b/spec/ruby/core/basicobject/method_missing_spec.rb @@ -3,7 +3,7 @@ describe "BasicObject#method_missing" do it "is a private method" do - BasicObject.should have_private_instance_method(:method_missing) + BasicObject.private_instance_methods(false).should.include?(:method_missing) end end diff --git a/spec/ruby/core/basicobject/not_equal_spec.rb b/spec/ruby/core/basicobject/not_equal_spec.rb index 9329128c4346d1..29b14b0fff6cad 100644 --- a/spec/ruby/core/basicobject/not_equal_spec.rb +++ b/spec/ruby/core/basicobject/not_equal_spec.rb @@ -2,24 +2,24 @@ describe "BasicObject#!=" do it "is a public instance method" do - BasicObject.should have_public_instance_method(:'!=') + BasicObject.public_instance_methods(false).should.include?(:'!=') end it "returns true if other is not identical to self" do a = BasicObject.new b = BasicObject.new - (a != b).should be_true + (a != b).should == true end it "returns true if other is an Object" do a = BasicObject.new b = Object.new - (a != b).should be_true + (a != b).should == true end it "returns false if other is identical to self" do a = BasicObject.new - (a != a).should be_false + (a != a).should == false end it "dispatches to #==" do @@ -27,19 +27,19 @@ b = BasicObject.new a.should_receive(:==).and_return(true) - (a != b).should be_false + (a != b).should == false end describe "when invoked using Kernel#send" do it "returns true if other is not identical to self" do a = Object.new b = Object.new - a.send(:!=, b).should be_true + a.send(:!=, b).should == true end it "returns false if other is identical to self" do a = Object.new - a.send(:!=, a).should be_false + a.send(:!=, a).should == false end it "dispatches to #==" do @@ -47,7 +47,7 @@ b = Object.new a.should_receive(:==).and_return(true) - a.send(:!=, b).should be_false + a.send(:!=, b).should == false end end end diff --git a/spec/ruby/core/basicobject/not_spec.rb b/spec/ruby/core/basicobject/not_spec.rb index ca4cb6f5ffbd7a..a6f58ae6f5d00f 100644 --- a/spec/ruby/core/basicobject/not_spec.rb +++ b/spec/ruby/core/basicobject/not_spec.rb @@ -2,10 +2,10 @@ describe "BasicObject#!" do it "is a public instance method" do - BasicObject.should have_public_instance_method(:'!') + BasicObject.public_instance_methods(false).should.include?(:'!') end it "returns false" do - (!BasicObject.new).should be_false + (!BasicObject.new).should == false end end diff --git a/spec/ruby/core/basicobject/singleton_method_added_spec.rb b/spec/ruby/core/basicobject/singleton_method_added_spec.rb index bd21458ea76f20..f39b91768c39f5 100644 --- a/spec/ruby/core/basicobject/singleton_method_added_spec.rb +++ b/spec/ruby/core/basicobject/singleton_method_added_spec.rb @@ -7,7 +7,7 @@ end it "is a private method" do - BasicObject.should have_private_instance_method(:singleton_method_added) + BasicObject.private_instance_methods(false).should.include?(:singleton_method_added) end it "is called when a singleton method is defined on an object" do @@ -35,7 +35,7 @@ def new_instance_method end end - ScratchPad.recorded.should_not include(:new_instance_method) + ScratchPad.recorded.should_not.include?(:new_instance_method) end it "is called when a singleton method is defined on a module" do @@ -94,7 +94,7 @@ class << self -> { def self.foo end - }.should raise_error(NoMethodError, /undefined method [`']singleton_method_added' for/) + }.should.raise(NoMethodError, /undefined method [`']singleton_method_added' for/) end ensure BasicObjectSpecs.send(:remove_const, :NoSingletonMethodAdded) @@ -108,16 +108,16 @@ class << object -> { def foo end - }.should raise_error(NoMethodError, /undefined method [`']singleton_method_added' for # { define_method(:bar) {} - }.should raise_error(NoMethodError, /undefined method [`']singleton_method_added' for # { object.define_singleton_method(:baz) {} - }.should raise_error(NoMethodError, /undefined method [`']singleton_method_added' for # { eval("b", bind1) }.should raise_error(NameError) + -> { eval("b", bind1) }.should.raise(NameError) eval("b", bind2).should == 2 bind1.local_variables.sort.should == [:a, :bind1, :bind2] diff --git a/spec/ruby/core/binding/eval_spec.rb b/spec/ruby/core/binding/eval_spec.rb index 7852e1c93936b4..f1d859132004b3 100644 --- a/spec/ruby/core/binding/eval_spec.rb +++ b/spec/ruby/core/binding/eval_spec.rb @@ -7,7 +7,7 @@ bind = obj.get_binding bind.eval("@secret += square(3)").should == 10 - bind.eval("a").should be_true + bind.eval("a").should == true bind.eval("class Inside; end") bind.eval("Inside.name").should == "BindingSpecs::Demo::Inside" diff --git a/spec/ruby/core/binding/local_variable_get_spec.rb b/spec/ruby/core/binding/local_variable_get_spec.rb index 005670becc23cd..d97100deda3da6 100644 --- a/spec/ruby/core/binding/local_variable_get_spec.rb +++ b/spec/ruby/core/binding/local_variable_get_spec.rb @@ -13,7 +13,7 @@ -> { bind.local_variable_get(:no_such_variable) - }.should raise_error(NameError) + }.should.raise(NameError) end it "reads variables added later to the binding" do @@ -21,7 +21,7 @@ -> { bind.local_variable_get(:a) - }.should raise_error(NameError) + }.should.raise(NameError) bind.local_variable_set(:a, 42) @@ -45,12 +45,12 @@ it "raises a NameError on global access" do bind = binding - -> { bind.local_variable_get(:$0) }.should raise_error(NameError) + -> { bind.local_variable_get(:$0) }.should.raise(NameError) end it "raises a NameError on special variable access" do bind = binding - -> { bind.local_variable_get(:$~) }.should raise_error(NameError) - -> { bind.local_variable_get(:$_) }.should raise_error(NameError) + -> { bind.local_variable_get(:$~) }.should.raise(NameError) + -> { bind.local_variable_get(:$_) }.should.raise(NameError) end end diff --git a/spec/ruby/core/binding/local_variable_set_spec.rb b/spec/ruby/core/binding/local_variable_set_spec.rb index 1456c6dda1d2f3..3e4f407fc3292c 100644 --- a/spec/ruby/core/binding/local_variable_set_spec.rb +++ b/spec/ruby/core/binding/local_variable_set_spec.rb @@ -38,7 +38,7 @@ bind = binding bind.local_variable_set(:number, 10) - -> { number }.should raise_error(NameError) + -> { number }.should.raise(NameError) end it 'overwrites an existing local variable defined before a Binding' do @@ -59,13 +59,13 @@ it "raises a NameError on global access" do bind = binding - -> { bind.local_variable_set(:$0, "") }.should raise_error(NameError) + -> { bind.local_variable_set(:$0, "") }.should.raise(NameError) end it "raises a NameError on special variable access" do bind = binding - -> { bind.local_variable_set(:$~, "") }.should raise_error(NameError) - -> { bind.local_variable_set(:$_, "") }.should raise_error(NameError) + -> { bind.local_variable_set(:$~, "") }.should.raise(NameError) + -> { bind.local_variable_set(:$_, "") }.should.raise(NameError) end end diff --git a/spec/ruby/core/binding/local_variables_spec.rb b/spec/ruby/core/binding/local_variables_spec.rb index 92c817b9a81cd1..0f596813420df5 100644 --- a/spec/ruby/core/binding/local_variables_spec.rb +++ b/spec/ruby/core/binding/local_variables_spec.rb @@ -2,7 +2,7 @@ describe "Binding#local_variables" do it "returns an Array" do - binding.local_variables.should be_kind_of(Array) + binding.local_variables.should.is_a?(Array) end it "includes local variables in the current scope" do diff --git a/spec/ruby/core/builtin_constants/builtin_constants_spec.rb b/spec/ruby/core/builtin_constants/builtin_constants_spec.rb index 2c71b416679749..67b3339aa66c44 100644 --- a/spec/ruby/core/builtin_constants/builtin_constants_spec.rb +++ b/spec/ruby/core/builtin_constants/builtin_constants_spec.rb @@ -2,7 +2,7 @@ describe "RUBY_VERSION" do it "is a String" do - RUBY_VERSION.should be_kind_of(String) + RUBY_VERSION.should.is_a?(String) end it "is frozen" do @@ -12,13 +12,13 @@ describe "RUBY_PATCHLEVEL" do it "is an Integer" do - RUBY_PATCHLEVEL.should be_kind_of(Integer) + RUBY_PATCHLEVEL.should.is_a?(Integer) end end describe "RUBY_COPYRIGHT" do it "is a String" do - RUBY_COPYRIGHT.should be_kind_of(String) + RUBY_COPYRIGHT.should.is_a?(String) end it "is frozen" do @@ -28,7 +28,7 @@ describe "RUBY_DESCRIPTION" do it "is a String" do - RUBY_DESCRIPTION.should be_kind_of(String) + RUBY_DESCRIPTION.should.is_a?(String) end it "is frozen" do @@ -38,7 +38,7 @@ describe "RUBY_ENGINE" do it "is a String" do - RUBY_ENGINE.should be_kind_of(String) + RUBY_ENGINE.should.is_a?(String) end it "is frozen" do @@ -48,7 +48,7 @@ describe "RUBY_ENGINE_VERSION" do it "is a String" do - RUBY_ENGINE_VERSION.should be_kind_of(String) + RUBY_ENGINE_VERSION.should.is_a?(String) end it "is frozen" do @@ -58,7 +58,7 @@ describe "RUBY_PLATFORM" do it "is a String" do - RUBY_PLATFORM.should be_kind_of(String) + RUBY_PLATFORM.should.is_a?(String) end it "is frozen" do @@ -68,7 +68,7 @@ describe "RUBY_RELEASE_DATE" do it "is a String" do - RUBY_RELEASE_DATE.should be_kind_of(String) + RUBY_RELEASE_DATE.should.is_a?(String) end it "is frozen" do @@ -78,7 +78,7 @@ describe "RUBY_REVISION" do it "is a String" do - RUBY_REVISION.should be_kind_of(String) + RUBY_REVISION.should.is_a?(String) end it "is frozen" do @@ -95,55 +95,55 @@ describe "Ruby::VERSION" do it "is equal to RUBY_VERSION" do - Ruby::VERSION.should equal(RUBY_VERSION) + Ruby::VERSION.should.equal?(RUBY_VERSION) end end describe "RUBY::PATCHLEVEL" do it "is equal to RUBY_PATCHLEVEL" do - Ruby::PATCHLEVEL.should equal(RUBY_PATCHLEVEL) + Ruby::PATCHLEVEL.should.equal?(RUBY_PATCHLEVEL) end end describe "Ruby::COPYRIGHT" do it "is equal to RUBY_COPYRIGHT" do - Ruby::COPYRIGHT.should equal(RUBY_COPYRIGHT) + Ruby::COPYRIGHT.should.equal?(RUBY_COPYRIGHT) end end describe "Ruby::DESCRIPTION" do it "is equal to RUBY_DESCRIPTION" do - Ruby::DESCRIPTION.should equal(RUBY_DESCRIPTION) + Ruby::DESCRIPTION.should.equal?(RUBY_DESCRIPTION) end end describe "Ruby::ENGINE" do it "is equal to RUBY_ENGINE" do - Ruby::ENGINE.should equal(RUBY_ENGINE) + Ruby::ENGINE.should.equal?(RUBY_ENGINE) end end describe "Ruby::ENGINE_VERSION" do it "is equal to RUBY_ENGINE_VERSION" do - Ruby::ENGINE_VERSION.should equal(RUBY_ENGINE_VERSION) + Ruby::ENGINE_VERSION.should.equal?(RUBY_ENGINE_VERSION) end end describe "Ruby::PLATFORM" do it "is equal to RUBY_PLATFORM" do - Ruby::PLATFORM.should equal(RUBY_PLATFORM) + Ruby::PLATFORM.should.equal?(RUBY_PLATFORM) end end describe "Ruby::RELEASE_DATE" do it "is equal to RUBY_RELEASE_DATE" do - Ruby::RELEASE_DATE.should equal(RUBY_RELEASE_DATE) + Ruby::RELEASE_DATE.should.equal?(RUBY_RELEASE_DATE) end end describe "Ruby::REVISION" do it "is equal to RUBY_REVISION" do - Ruby::REVISION.should equal(RUBY_REVISION) + Ruby::REVISION.should.equal?(RUBY_REVISION) end end end diff --git a/spec/ruby/core/class/allocate_spec.rb b/spec/ruby/core/class/allocate_spec.rb index b39622e06a4ade..b8950a678ec686 100644 --- a/spec/ruby/core/class/allocate_spec.rb +++ b/spec/ruby/core/class/allocate_spec.rb @@ -3,7 +3,7 @@ describe "Class#allocate" do it "returns an instance of self" do klass = Class.new - klass.allocate.should be_an_instance_of(klass) + klass.allocate.should.instance_of?(klass) end it "returns a fully-formed instance of Module" do @@ -16,7 +16,7 @@ klass = Class.allocate -> do klass.new - end.should raise_error(Exception) + end.should.raise(Exception) end it "does not call initialize on the new instance" do @@ -36,6 +36,6 @@ def initialized? it "raises TypeError for #superclass" do -> do Class.allocate.superclass - end.should raise_error(TypeError) + end.should.raise(TypeError) end end diff --git a/spec/ruby/core/class/attached_object_spec.rb b/spec/ruby/core/class/attached_object_spec.rb index 8f8a0734c6e71f..b75e61ca07beef 100644 --- a/spec/ruby/core/class/attached_object_spec.rb +++ b/spec/ruby/core/class/attached_object_spec.rb @@ -18,12 +18,12 @@ it "raises TypeError if the class is not a singleton class" do a = Class.new - -> { a.attached_object }.should raise_error(TypeError, /is not a singleton class/) + -> { a.attached_object }.should.raise(TypeError, /is not a singleton class/) end it "raises TypeError for special singleton classes" do - -> { nil.singleton_class.attached_object }.should raise_error(TypeError, /[`']NilClass' is not a singleton class/) - -> { true.singleton_class.attached_object }.should raise_error(TypeError, /[`']TrueClass' is not a singleton class/) - -> { false.singleton_class.attached_object }.should raise_error(TypeError, /[`']FalseClass' is not a singleton class/) + -> { nil.singleton_class.attached_object }.should.raise(TypeError, /[`']NilClass' is not a singleton class/) + -> { true.singleton_class.attached_object }.should.raise(TypeError, /[`']TrueClass' is not a singleton class/) + -> { false.singleton_class.attached_object }.should.raise(TypeError, /[`']FalseClass' is not a singleton class/) end end diff --git a/spec/ruby/core/class/dup_spec.rb b/spec/ruby/core/class/dup_spec.rb index 1ff9abf7b44afb..17c0171ceb1763 100644 --- a/spec/ruby/core/class/dup_spec.rb +++ b/spec/ruby/core/class/dup_spec.rb @@ -53,7 +53,7 @@ def self.message it "sets the name from the class to nil if not assigned to a constant" do copy = CoreClassSpecs::Record.dup - copy.name.should be_nil + copy.name.should == nil end it "stores the new name if assigned to a constant" do @@ -64,6 +64,6 @@ def self.message end it "raises TypeError if called on BasicObject" do - -> { BasicObject.dup }.should raise_error(TypeError, "can't copy the root class") + -> { BasicObject.dup }.should.raise(TypeError, "can't copy the root class") end end diff --git a/spec/ruby/core/class/inherited_spec.rb b/spec/ruby/core/class/inherited_spec.rb index 2a8d1ff813aa54..c9acc740a10bdd 100644 --- a/spec/ruby/core/class/inherited_spec.rb +++ b/spec/ruby/core/class/inherited_spec.rb @@ -92,10 +92,10 @@ def inherited(cls); end end class << top; private :inherited; end - -> { Class.new(top) }.should_not raise_error + -> { Class.new(top) }.should_not.raise class << top; protected :inherited; end - -> { Class.new(top) }.should_not raise_error + -> { Class.new(top) }.should_not.raise end it "if the subclass is assigned to a constant, it is all set" do diff --git a/spec/ruby/core/class/initialize_spec.rb b/spec/ruby/core/class/initialize_spec.rb index 63487584857717..ab8f0a157e6993 100644 --- a/spec/ruby/core/class/initialize_spec.rb +++ b/spec/ruby/core/class/initialize_spec.rb @@ -2,24 +2,24 @@ describe "Class#initialize" do it "is private" do - Class.should have_private_method(:initialize) + Class.private_methods(false).should.include?(:initialize) end it "raises a TypeError when called on already initialized classes" do ->{ Integer.send :initialize - }.should raise_error(TypeError) + }.should.raise(TypeError) ->{ Object.send :initialize - }.should raise_error(TypeError) + }.should.raise(TypeError) end # See [redmine:2601] it "raises a TypeError when called on BasicObject" do ->{ BasicObject.send :initialize - }.should raise_error(TypeError) + }.should.raise(TypeError) end describe "when given the Class" do @@ -28,7 +28,7 @@ end it "raises a TypeError" do - ->{@uninitialized.send(:initialize, Class)}.should raise_error(TypeError) + ->{@uninitialized.send(:initialize, Class)}.should.raise(TypeError) end end end diff --git a/spec/ruby/core/class/new_spec.rb b/spec/ruby/core/class/new_spec.rb index 6fe54c3209b3b7..111e31252eb8c6 100644 --- a/spec/ruby/core/class/new_spec.rb +++ b/spec/ruby/core/class/new_spec.rb @@ -7,7 +7,7 @@ klass = Class.new do self_in_block = self end - self_in_block.should equal klass + self_in_block.should.equal? klass end it "uses the given block as the class' body" do @@ -70,11 +70,11 @@ def message2; "hello"; end it "raises a TypeError if passed a metaclass" do obj = mock("Class.new metaclass") meta = obj.singleton_class - -> { Class.new meta }.should raise_error(TypeError) + -> { Class.new meta }.should.raise(TypeError) end it "creates a class without a name" do - Class.new.name.should be_nil + Class.new.name.should == nil end it "creates a class that can be given a name by assigning it to a constant" do @@ -98,12 +98,12 @@ def message2; "hello"; end it "raises a TypeError when given a non-Class" do error_msg = /superclass must be a.*Class/ - -> { Class.new("") }.should raise_error(TypeError, error_msg) - -> { Class.new(1) }.should raise_error(TypeError, error_msg) - -> { Class.new(:symbol) }.should raise_error(TypeError, error_msg) - -> { Class.new(mock('o')) }.should raise_error(TypeError, error_msg) - -> { Class.new(Module.new) }.should raise_error(TypeError, error_msg) - -> { Class.new(BasicObject.new) }.should raise_error(TypeError, error_msg) + -> { Class.new("") }.should.raise(TypeError, error_msg) + -> { Class.new(1) }.should.raise(TypeError, error_msg) + -> { Class.new(:symbol) }.should.raise(TypeError, error_msg) + -> { Class.new(mock('o')) }.should.raise(TypeError, error_msg) + -> { Class.new(Module.new) }.should.raise(TypeError, error_msg) + -> { Class.new(BasicObject.new) }.should.raise(TypeError, error_msg) end end @@ -141,8 +141,8 @@ def self.allocate end instance = klass.new - instance.should be_kind_of klass - instance.class.should equal klass + instance.should.is_a? klass + instance.class.should.equal? klass end it "passes the block to #initialize" do diff --git a/spec/ruby/core/class/subclasses_spec.rb b/spec/ruby/core/class/subclasses_spec.rb index f6921527871077..c3d7b07e124356 100644 --- a/spec/ruby/core/class/subclasses_spec.rb +++ b/spec/ruby/core/class/subclasses_spec.rb @@ -50,7 +50,7 @@ def a_obj.force_singleton_class 42 end - a.subclasses.should_not include(a_obj.singleton_class) + a.subclasses.should_not.include?(a_obj.singleton_class) end it "has 1 entry per module or class" do @@ -76,7 +76,7 @@ def a_obj.force_singleton_class classes = threads.map(&:value) superclass.subclasses.size.should == t * n - superclass.subclasses.each { |c| c.should be_kind_of(Class) } + superclass.subclasses.each { |c| c.should.is_a?(Class) } end def assert_subclasses(mod,subclasses) diff --git a/spec/ruby/core/class/superclass_spec.rb b/spec/ruby/core/class/superclass_spec.rb index 00579238a6eede..87d9b20490bf31 100644 --- a/spec/ruby/core/class/superclass_spec.rb +++ b/spec/ruby/core/class/superclass_spec.rb @@ -3,7 +3,7 @@ describe "Class#superclass" do it "returns the superclass of self" do - BasicObject.superclass.should be_nil + BasicObject.superclass.should == nil Object.superclass.should == BasicObject Class.superclass.should == Module Class.new.superclass.should == Object diff --git a/spec/ruby/core/comparable/clamp_spec.rb b/spec/ruby/core/comparable/clamp_spec.rb index 18f616a997998d..eb1dc1ff98a811 100644 --- a/spec/ruby/core/comparable/clamp_spec.rb +++ b/spec/ruby/core/comparable/clamp_spec.rb @@ -7,9 +7,9 @@ two = ComparableSpecs::WithOnlyCompareDefined.new(2) c = ComparableSpecs::Weird.new(3) - -> { c.clamp(two, one) }.should raise_error(ArgumentError) + -> { c.clamp(two, one) }.should.raise(ArgumentError) one.should_receive(:<=>).any_number_of_times.and_return(nil) - -> { c.clamp(one, two) }.should raise_error(ArgumentError) + -> { c.clamp(one, two) }.should.raise(ArgumentError) end it 'returns self if within the given parameters' do @@ -18,10 +18,10 @@ three = ComparableSpecs::WithOnlyCompareDefined.new(3) c = ComparableSpecs::Weird.new(2) - c.clamp(one, two).should equal(c) - c.clamp(two, two).should equal(c) - c.clamp(one, three).should equal(c) - c.clamp(two, three).should equal(c) + c.clamp(one, two).should.equal?(c) + c.clamp(two, two).should.equal?(c) + c.clamp(one, three).should.equal?(c) + c.clamp(two, three).should.equal?(c) end it 'returns the min parameter if less than it' do @@ -29,7 +29,7 @@ two = ComparableSpecs::WithOnlyCompareDefined.new(2) c = ComparableSpecs::Weird.new(0) - c.clamp(one, two).should equal(one) + c.clamp(one, two).should.equal?(one) end it 'returns the max parameter if greater than it' do @@ -37,20 +37,20 @@ two = ComparableSpecs::WithOnlyCompareDefined.new(2) c = ComparableSpecs::Weird.new(3) - c.clamp(one, two).should equal(two) + c.clamp(one, two).should.equal?(two) end context 'max is nil' do it 'returns min if less than it' do one = ComparableSpecs::WithOnlyCompareDefined.new(1) c = ComparableSpecs::Weird.new(0) - c.clamp(one, nil).should equal(one) + c.clamp(one, nil).should.equal?(one) end it 'always returns self if greater than min' do one = ComparableSpecs::WithOnlyCompareDefined.new(1) c = ComparableSpecs::Weird.new(2) - c.clamp(one, nil).should equal(c) + c.clamp(one, nil).should.equal?(c) end end @@ -58,19 +58,19 @@ it 'returns max if greater than it' do one = ComparableSpecs::WithOnlyCompareDefined.new(1) c = ComparableSpecs::Weird.new(2) - c.clamp(nil, one).should equal(one) + c.clamp(nil, one).should.equal?(one) end it 'always returns self if less than max' do one = ComparableSpecs::WithOnlyCompareDefined.new(1) c = ComparableSpecs::Weird.new(0) - c.clamp(nil, one).should equal(c) + c.clamp(nil, one).should.equal?(c) end end it 'always returns self when min is nil and max is nil' do c = ComparableSpecs::Weird.new(1) - c.clamp(nil, nil).should equal(c) + c.clamp(nil, nil).should.equal?(c) end it 'returns self if within the given range parameters' do @@ -79,10 +79,10 @@ three = ComparableSpecs::WithOnlyCompareDefined.new(3) c = ComparableSpecs::Weird.new(2) - c.clamp(one..two).should equal(c) - c.clamp(two..two).should equal(c) - c.clamp(one..three).should equal(c) - c.clamp(two..three).should equal(c) + c.clamp(one..two).should.equal?(c) + c.clamp(two..two).should.equal?(c) + c.clamp(one..three).should.equal?(c) + c.clamp(two..three).should.equal?(c) end it 'returns the minimum value of the range parameters if less than it' do @@ -90,7 +90,7 @@ two = ComparableSpecs::WithOnlyCompareDefined.new(2) c = ComparableSpecs::Weird.new(0) - c.clamp(one..two).should equal(one) + c.clamp(one..two).should.equal?(one) end it 'returns the maximum value of the range parameters if greater than it' do @@ -98,7 +98,7 @@ two = ComparableSpecs::WithOnlyCompareDefined.new(2) c = ComparableSpecs::Weird.new(3) - c.clamp(one..two).should equal(two) + c.clamp(one..two).should.equal?(two) end it 'raises an Argument error if the range parameter is exclusive' do @@ -106,7 +106,7 @@ two = ComparableSpecs::WithOnlyCompareDefined.new(2) c = ComparableSpecs::Weird.new(3) - -> { c.clamp(one...two) }.should raise_error(ArgumentError) + -> { c.clamp(one...two) }.should.raise(ArgumentError) end context 'with nil as the max argument' do @@ -115,8 +115,8 @@ zero = ComparableSpecs::WithOnlyCompareDefined.new(0) c = ComparableSpecs::Weird.new(0) - c.clamp(one, nil).should equal(one) - c.clamp(zero, nil).should equal(c) + c.clamp(one, nil).should.equal?(one) + c.clamp(zero, nil).should.equal?(c) end it 'always returns self if greater than min argument' do @@ -124,8 +124,8 @@ two = ComparableSpecs::WithOnlyCompareDefined.new(2) c = ComparableSpecs::Weird.new(2) - c.clamp(one, nil).should equal(c) - c.clamp(two, nil).should equal(c) + c.clamp(one, nil).should.equal?(c) + c.clamp(two, nil).should.equal?(c) end end @@ -135,8 +135,8 @@ zero = ComparableSpecs::WithOnlyCompareDefined.new(0) c = ComparableSpecs::Weird.new(0) - c.clamp(one..).should equal(one) - c.clamp(zero..).should equal(c) + c.clamp(one..).should.equal?(one) + c.clamp(zero..).should.equal?(c) end it 'always returns self if greater than minimum value of the range parameters' do @@ -144,15 +144,15 @@ two = ComparableSpecs::WithOnlyCompareDefined.new(2) c = ComparableSpecs::Weird.new(2) - c.clamp(one..).should equal(c) - c.clamp(two..).should equal(c) + c.clamp(one..).should.equal?(c) + c.clamp(two..).should.equal?(c) end it 'works with exclusive range' do one = ComparableSpecs::WithOnlyCompareDefined.new(1) c = ComparableSpecs::Weird.new(2) - c.clamp(one...).should equal(c) + c.clamp(one...).should.equal?(c) end end @@ -161,7 +161,7 @@ one = ComparableSpecs::WithOnlyCompareDefined.new(1) c = ComparableSpecs::Weird.new(2) - c.clamp(nil, one).should equal(one) + c.clamp(nil, one).should.equal?(one) end it 'always returns self if less than max argument' do @@ -169,8 +169,8 @@ zero = ComparableSpecs::WithOnlyCompareDefined.new(0) c = ComparableSpecs::Weird.new(0) - c.clamp(nil, one).should equal(c) - c.clamp(nil, zero).should equal(c) + c.clamp(nil, one).should.equal?(c) + c.clamp(nil, zero).should.equal?(c) end end @@ -179,7 +179,7 @@ one = ComparableSpecs::WithOnlyCompareDefined.new(1) c = ComparableSpecs::Weird.new(2) - c.clamp(..one).should equal(one) + c.clamp(..one).should.equal?(one) end it 'always returns self if less than maximum value of the range parameters' do @@ -187,15 +187,15 @@ zero = ComparableSpecs::WithOnlyCompareDefined.new(0) c = ComparableSpecs::Weird.new(0) - c.clamp(..one).should equal(c) - c.clamp(..zero).should equal(c) + c.clamp(..one).should.equal?(c) + c.clamp(..zero).should.equal?(c) end it 'raises an Argument error if the range parameter is exclusive' do one = ComparableSpecs::WithOnlyCompareDefined.new(1) c = ComparableSpecs::Weird.new(0) - -> { c.clamp(...one) }.should raise_error(ArgumentError) + -> { c.clamp(...one) }.should.raise(ArgumentError) end end @@ -203,7 +203,7 @@ it 'always returns self' do c = ComparableSpecs::Weird.new(1) - c.clamp(nil, nil).should equal(c) + c.clamp(nil, nil).should.equal?(c) end end @@ -211,13 +211,13 @@ it 'always returns self' do c = ComparableSpecs::Weird.new(1) - c.clamp(nil..nil).should equal(c) + c.clamp(nil..nil).should.equal?(c) end it 'works with exclusive range' do c = ComparableSpecs::Weird.new(2) - c.clamp(nil...nil).should equal(c) + c.clamp(nil...nil).should.equal?(c) end end end diff --git a/spec/ruby/core/comparable/equal_value_spec.rb b/spec/ruby/core/comparable/equal_value_spec.rb index ddcc03cb410306..3af40d1c7e33f3 100644 --- a/spec/ruby/core/comparable/equal_value_spec.rb +++ b/spec/ruby/core/comparable/equal_value_spec.rb @@ -39,7 +39,7 @@ end it "returns false" do - (a == b).should be_false + (a == b).should == false end end @@ -49,7 +49,7 @@ end it "raises an ArgumentError" do - -> { (a == b) }.should raise_error(ArgumentError) + -> { (a == b) }.should.raise(ArgumentError) end end @@ -60,7 +60,7 @@ end it "lets it go through" do - -> { (a == b) }.should raise_error(StandardError) + -> { (a == b) }.should.raise(StandardError) end end @@ -71,13 +71,13 @@ end it "lets it go through" do - -> { (a == b) }.should raise_error(TypeError) + -> { (a == b) }.should.raise(TypeError) end end it "lets it go through if it is not a StandardError" do a.should_receive(:<=>).once.and_raise(Exception) - -> { (a == b) }.should raise_error(Exception) + -> { (a == b) }.should.raise(Exception) end end diff --git a/spec/ruby/core/comparable/gt_spec.rb b/spec/ruby/core/comparable/gt_spec.rb index 150e653dc75282..cebb5464ad06b6 100644 --- a/spec/ruby/core/comparable/gt_spec.rb +++ b/spec/ruby/core/comparable/gt_spec.rb @@ -38,6 +38,6 @@ b = ComparableSpecs::Weird.new(20) a.should_receive(:<=>).any_number_of_times.and_return(nil) - -> { (a > b) }.should raise_error(ArgumentError) + -> { (a > b) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/comparable/gte_spec.rb b/spec/ruby/core/comparable/gte_spec.rb index 328f58c66cf51e..16da81b3ead206 100644 --- a/spec/ruby/core/comparable/gte_spec.rb +++ b/spec/ruby/core/comparable/gte_spec.rb @@ -42,6 +42,6 @@ b = ComparableSpecs::Weird.new(20) a.should_receive(:<=>).any_number_of_times.and_return(nil) - -> { (a >= b) }.should raise_error(ArgumentError) + -> { (a >= b) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/comparable/lt_spec.rb b/spec/ruby/core/comparable/lt_spec.rb index 3c73e410ea14ed..175646d0d7dd44 100644 --- a/spec/ruby/core/comparable/lt_spec.rb +++ b/spec/ruby/core/comparable/lt_spec.rb @@ -38,11 +38,11 @@ b = ComparableSpecs::Weird.new(20) a.should_receive(:<=>).any_number_of_times.and_return(nil) - -> { (a < b) }.should raise_error(ArgumentError) + -> { (a < b) }.should.raise(ArgumentError) end it "raises an argument error with a message containing the value" do - -> { ("foo" < 7) }.should raise_error(ArgumentError) { |e| + -> { ("foo" < 7) }.should.raise(ArgumentError) { |e| e.message.should.include? "String with 7 failed" } end diff --git a/spec/ruby/core/comparable/lte_spec.rb b/spec/ruby/core/comparable/lte_spec.rb index b5cb9cc4e7fbc2..8cbbd5ebb4a420 100644 --- a/spec/ruby/core/comparable/lte_spec.rb +++ b/spec/ruby/core/comparable/lte_spec.rb @@ -41,6 +41,6 @@ b = ComparableSpecs::Weird.new(20) a.should_receive(:<=>).any_number_of_times.and_return(nil) - -> { (a <= b) }.should raise_error(ArgumentError) + -> { (a <= b) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/complex/coerce_spec.rb b/spec/ruby/core/complex/coerce_spec.rb index a30a6c1d5f7a6c..d4ea85a713655e 100644 --- a/spec/ruby/core/complex/coerce_spec.rb +++ b/spec/ruby/core/complex/coerce_spec.rb @@ -8,37 +8,37 @@ it "returns an array containing other and self as Complex when other is an Integer" do result = @one.coerce(2) result.should == [2, 1] - result.first.should be_kind_of(Complex) - result.last.should be_kind_of(Complex) + result.first.should.is_a?(Complex) + result.last.should.is_a?(Complex) end it "returns an array containing other and self as Complex when other is a Float" do result = @one.coerce(20.5) result.should == [20.5, 1] - result.first.should be_kind_of(Complex) - result.last.should be_kind_of(Complex) + result.first.should.is_a?(Complex) + result.last.should.is_a?(Complex) end it "returns an array containing other and self as Complex when other is a Bignum" do result = @one.coerce(4294967296) result.should == [4294967296, 1] - result.first.should be_kind_of(Complex) - result.last.should be_kind_of(Complex) + result.first.should.is_a?(Complex) + result.last.should.is_a?(Complex) end it "returns an array containing other and self as Complex when other is a Rational" do result = @one.coerce(Rational(5,6)) result.should == [Rational(5,6), 1] - result.first.should be_kind_of(Complex) - result.last.should be_kind_of(Complex) + result.first.should.is_a?(Complex) + result.last.should.is_a?(Complex) end it "returns an array containing other and self when other is a Complex" do other = Complex(2) result = @one.coerce(other) result.should == [other, @one] - result.first.should equal(other) - result.last.should equal(@one) + result.first.should.equal?(other) + result.last.should.equal?(@one) end it "returns an array containing other as Complex and self when other is a Numeric which responds to #real? with true" do @@ -46,25 +46,25 @@ other.should_receive(:real?).any_number_of_times.and_return(true) result = @one.coerce(other) result.should == [other, @one] - result.first.should eql(Complex(other)) - result.last.should equal(@one) + result.first.should.eql?(Complex(other)) + result.last.should.equal?(@one) end it "raises TypeError when other is a Numeric which responds to #real? with false" do other = mock_numeric('other') other.should_receive(:real?).any_number_of_times.and_return(false) - -> { @one.coerce(other) }.should raise_error(TypeError) + -> { @one.coerce(other) }.should.raise(TypeError) end it "raises a TypeError when other is a String" do - -> { @one.coerce("20") }.should raise_error(TypeError) + -> { @one.coerce("20") }.should.raise(TypeError) end it "raises a TypeError when other is nil" do - -> { @one.coerce(nil) }.should raise_error(TypeError) + -> { @one.coerce(nil) }.should.raise(TypeError) end it "raises a TypeError when other is false" do - -> { @one.coerce(false) }.should raise_error(TypeError) + -> { @one.coerce(false) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/complex/comparison_spec.rb b/spec/ruby/core/complex/comparison_spec.rb index 3a3142f234446a..3115f4e205bf9c 100644 --- a/spec/ruby/core/complex/comparison_spec.rb +++ b/spec/ruby/core/complex/comparison_spec.rb @@ -2,15 +2,15 @@ describe "Complex#<=>" do it "returns nil if either self or argument has imaginary part" do - (Complex(5, 1) <=> Complex(2)).should be_nil - (Complex(1) <=> Complex(2, 1)).should be_nil - (5 <=> Complex(2, 1)).should be_nil + (Complex(5, 1) <=> Complex(2)).should == nil + (Complex(1) <=> Complex(2, 1)).should == nil + (5 <=> Complex(2, 1)).should == nil end it "returns nil if argument is not numeric" do - (Complex(5, 1) <=> "cmp").should be_nil - (Complex(1) <=> "cmp").should be_nil - (Complex(1) <=> Object.new).should be_nil + (Complex(5, 1) <=> "cmp").should == nil + (Complex(1) <=> "cmp").should == nil + (Complex(1) <=> Object.new).should == nil end it "returns 0, 1, or -1 if self and argument do not have imaginary part" do diff --git a/spec/ruby/core/complex/constants_spec.rb b/spec/ruby/core/complex/constants_spec.rb index 50303de16ccd62..200e97731a1e5a 100644 --- a/spec/ruby/core/complex/constants_spec.rb +++ b/spec/ruby/core/complex/constants_spec.rb @@ -2,6 +2,6 @@ describe "Complex::I" do it "is Complex(0, 1)" do - Complex::I.should eql(Complex(0, 1)) + Complex::I.should.eql?(Complex(0, 1)) end end diff --git a/spec/ruby/core/complex/eql_spec.rb b/spec/ruby/core/complex/eql_spec.rb index 9194efc074de52..2082a22feb8a19 100644 --- a/spec/ruby/core/complex/eql_spec.rb +++ b/spec/ruby/core/complex/eql_spec.rb @@ -2,23 +2,23 @@ describe "Complex#eql?" do it "returns false if other is not Complex" do - Complex(1).eql?(1).should be_false + Complex(1).eql?(1).should == false end it "returns true when the respective parts are of the same classes and self == other" do - Complex(1, 2).eql?(Complex(1, 2)).should be_true + Complex(1, 2).eql?(Complex(1, 2)).should == true end it "returns false when the real parts are of different classes" do - Complex(1).eql?(Complex(1.0)).should be_false + Complex(1).eql?(Complex(1.0)).should == false end it "returns false when the imaginary parts are of different classes" do - Complex(1, 2).eql?(Complex(1, 2.0)).should be_false + Complex(1, 2).eql?(Complex(1, 2.0)).should == false end it "returns false when self == other is false" do - Complex(1, 2).eql?(Complex(2, 3)).should be_false + Complex(1, 2).eql?(Complex(2, 3)).should == false end it "does NOT send #eql? to real or imaginary parts" do @@ -26,6 +26,6 @@ imag = mock_numeric('imag') real.should_not_receive(:eql?) imag.should_not_receive(:eql?) - Complex(real, imag).eql?(Complex(real, imag)).should be_true + Complex(real, imag).eql?(Complex(real, imag)).should == true end end diff --git a/spec/ruby/core/complex/equal_value_spec.rb b/spec/ruby/core/complex/equal_value_spec.rb index 97c486d8204470..b3562ff3fb808f 100644 --- a/spec/ruby/core/complex/equal_value_spec.rb +++ b/spec/ruby/core/complex/equal_value_spec.rb @@ -60,7 +60,7 @@ obj = mock("Object") obj.should_receive(:==).with(value).and_return(:expected) - (value == obj).should_not be_false + (value == obj).should_not == false end end @@ -73,11 +73,11 @@ it "returns real == other when the imaginary part is zero" do real = mock_numeric('real') real.should_receive(:==).with(@other).and_return(true) - (Complex(real, 0) == @other).should be_true + (Complex(real, 0) == @other).should == true end it "returns false when the imaginary part is not zero" do - (Complex(3, 1) == @other).should be_false + (Complex(3, 1) == @other).should == false end end @@ -87,7 +87,7 @@ other = mock_numeric('other') other.should_receive(:real?).any_number_of_times.and_return(false) other.should_receive(:==).with(complex).and_return(true) - (complex == other).should be_true + (complex == other).should == true end end end diff --git a/spec/ruby/core/complex/exponent_spec.rb b/spec/ruby/core/complex/exponent_spec.rb index 86f827aece965d..d0db0a40c2a91b 100644 --- a/spec/ruby/core/complex/exponent_spec.rb +++ b/spec/ruby/core/complex/exponent_spec.rb @@ -3,13 +3,13 @@ describe "Complex#**" do describe "with Integer 0" do it "returns Complex(1)" do - (Complex(3, 4) ** 0).should eql(Complex(1)) + (Complex(3, 4) ** 0).should.eql?(Complex(1)) end end describe "with Float 0.0" do it "returns Complex(1.0, 0.0)" do - (Complex(3, 4) ** 0.0).should eql(Complex(1.0, 0.0)) + (Complex(3, 4) ** 0.0).should.eql?(Complex(1.0, 0.0)) end end diff --git a/spec/ruby/core/complex/fdiv_spec.rb b/spec/ruby/core/complex/fdiv_spec.rb index 68f7d1b309fa91..fdcbc6a95d78c4 100644 --- a/spec/ruby/core/complex/fdiv_spec.rb +++ b/spec/ruby/core/complex/fdiv_spec.rb @@ -2,44 +2,44 @@ describe "Complex#fdiv" do it "accepts a numeric argument" do - -> { Complex(20).fdiv(2) }.should_not raise_error(TypeError) - -> { Complex(20).fdiv(2.0) }.should_not raise_error(TypeError) - -> { Complex(20).fdiv(bignum_value) }.should_not raise_error(TypeError) + -> { Complex(20).fdiv(2) }.should_not.raise(TypeError) + -> { Complex(20).fdiv(2.0) }.should_not.raise(TypeError) + -> { Complex(20).fdiv(bignum_value) }.should_not.raise(TypeError) end it "accepts a negative numeric argument" do - -> { Complex(20).fdiv(-2) }.should_not raise_error(TypeError) - -> { Complex(20).fdiv(-2.0) }.should_not raise_error(TypeError) - -> { Complex(20).fdiv(-bignum_value) }.should_not raise_error(TypeError) + -> { Complex(20).fdiv(-2) }.should_not.raise(TypeError) + -> { Complex(20).fdiv(-2.0) }.should_not.raise(TypeError) + -> { Complex(20).fdiv(-bignum_value) }.should_not.raise(TypeError) end it "raises a TypeError if passed a non-numeric argument" do - -> { Complex(20).fdiv([]) }.should raise_error(TypeError) - -> { Complex(20).fdiv(:sym) }.should raise_error(TypeError) - -> { Complex(20).fdiv('s') }.should raise_error(TypeError) + -> { Complex(20).fdiv([]) }.should.raise(TypeError) + -> { Complex(20).fdiv(:sym) }.should.raise(TypeError) + -> { Complex(20).fdiv('s') }.should.raise(TypeError) end it "sets the real part to NaN if self's real part is NaN" do - Complex(nan_value).fdiv(2).real.nan?.should be_true + Complex(nan_value).fdiv(2).real.nan?.should == true end it "sets the imaginary part to NaN if self's imaginary part is NaN" do - Complex(2, nan_value).fdiv(2).imag.nan?.should be_true + Complex(2, nan_value).fdiv(2).imag.nan?.should == true end it "sets the real and imaginary part to NaN if self's real and imaginary parts are NaN" do - Complex(nan_value, nan_value).fdiv(2).imag.nan?.should be_true - Complex(nan_value, nan_value).fdiv(2).real.nan?.should be_true + Complex(nan_value, nan_value).fdiv(2).imag.nan?.should == true + Complex(nan_value, nan_value).fdiv(2).real.nan?.should == true end it "sets the real and imaginary part to NaN if self's real part and the argument are both NaN" do - Complex(nan_value, 2).fdiv(nan_value).imag.nan?.should be_true - Complex(nan_value, 2).fdiv(nan_value).real.nan?.should be_true + Complex(nan_value, 2).fdiv(nan_value).imag.nan?.should == true + Complex(nan_value, 2).fdiv(nan_value).real.nan?.should == true end it "sets the real and imaginary part to NaN if self's real part, self's imaginary part, and the argument are NaN" do - Complex(nan_value, nan_value).fdiv(nan_value).imag.nan?.should be_true - Complex(nan_value, nan_value).fdiv(nan_value).real.nan?.should be_true + Complex(nan_value, nan_value).fdiv(nan_value).imag.nan?.should == true + Complex(nan_value, nan_value).fdiv(nan_value).real.nan?.should == true end it "sets the real part to Infinity if self's real part is Infinity" do @@ -58,8 +58,8 @@ end it "sets the real part to NaN and the imaginary part to NaN if self's imaginary part, self's real part, and the argument are Infinity" do - Complex(infinity_value, infinity_value).fdiv(infinity_value).real.nan?.should be_true - Complex(infinity_value, infinity_value).fdiv(infinity_value).imag.nan?.should be_true + Complex(infinity_value, infinity_value).fdiv(infinity_value).real.nan?.should == true + Complex(infinity_value, infinity_value).fdiv(infinity_value).imag.nan?.should == true end end @@ -71,7 +71,7 @@ it "returns a Complex number" do @numbers.each do |real| @numbers.each do |other| - Complex(real).fdiv(other).should be_an_instance_of(Complex) + Complex(real).fdiv(other).should.instance_of?(Complex) end end end @@ -103,7 +103,7 @@ @numbers.each_with_index do |other,idx| Complex( real,@numbers[idx == 0 ? -1 : idx-1] - ).fdiv(other).should be_an_instance_of(Complex) + ).fdiv(other).should.instance_of?(Complex) end end end diff --git a/spec/ruby/core/complex/integer_spec.rb b/spec/ruby/core/complex/integer_spec.rb index 0957accb70bc30..559bfbccfd7a66 100644 --- a/spec/ruby/core/complex/integer_spec.rb +++ b/spec/ruby/core/complex/integer_spec.rb @@ -2,10 +2,10 @@ describe "Complex#integer?" do it "returns false for a Complex with no imaginary part" do - Complex(20).integer?.should be_false + Complex(20).integer?.should == false end it "returns false for a Complex with an imaginary part" do - Complex(20,3).integer?.should be_false + Complex(20,3).integer?.should == false end end diff --git a/spec/ruby/core/complex/marshal_dump_spec.rb b/spec/ruby/core/complex/marshal_dump_spec.rb index 116899b0adb956..201d55e9e55a8e 100644 --- a/spec/ruby/core/complex/marshal_dump_spec.rb +++ b/spec/ruby/core/complex/marshal_dump_spec.rb @@ -2,7 +2,7 @@ describe "Complex#marshal_dump" do it "is a private method" do - Complex.should have_private_instance_method(:marshal_dump, false) + Complex.private_instance_methods(false).should.include?(:marshal_dump) end it "dumps real and imaginary parts" do diff --git a/spec/ruby/core/complex/negative_spec.rb b/spec/ruby/core/complex/negative_spec.rb index 62ab89c04a057f..566975b8e1e798 100644 --- a/spec/ruby/core/complex/negative_spec.rb +++ b/spec/ruby/core/complex/negative_spec.rb @@ -4,10 +4,10 @@ it "is undefined" do c = Complex(1) - c.methods.should_not include(:negative?) + c.methods.should_not.include?(:negative?) -> { c.negative? - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/complex/polar_spec.rb b/spec/ruby/core/complex/polar_spec.rb index 56335584efe0c5..824211fcd053b3 100644 --- a/spec/ruby/core/complex/polar_spec.rb +++ b/spec/ruby/core/complex/polar_spec.rb @@ -7,22 +7,22 @@ end it "raises a TypeError when given non real arguments" do - ->{ Complex.polar(nil) }.should raise_error(TypeError) - ->{ Complex.polar(nil, nil) }.should raise_error(TypeError) + ->{ Complex.polar(nil) }.should.raise(TypeError) + ->{ Complex.polar(nil, nil) }.should.raise(TypeError) end it "computes the real values of the real & imaginary parts from the polar form" do a = Complex.polar(1.0+0.0i, Math::PI/2+0.0i) a.real.should be_close(0.0, TOLERANCE) a.imag.should be_close(1.0, TOLERANCE) - a.real.real?.should be_true - a.imag.real?.should be_true + a.real.real?.should == true + a.imag.real?.should == true b = Complex.polar(1+0.0i) b.real.should be_close(1.0, TOLERANCE) b.imag.should be_close(0.0, TOLERANCE) - b.real.real?.should be_true - b.imag.real?.should be_true + b.real.real?.should == true + b.imag.real?.should == true end end diff --git a/spec/ruby/core/complex/positive_spec.rb b/spec/ruby/core/complex/positive_spec.rb index f1bad8608ca14c..d2fb256538138d 100644 --- a/spec/ruby/core/complex/positive_spec.rb +++ b/spec/ruby/core/complex/positive_spec.rb @@ -4,10 +4,10 @@ it "is undefined" do c = Complex(1) - c.methods.should_not include(:positive?) + c.methods.should_not.include?(:positive?) -> { c.positive? - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/complex/rationalize_spec.rb b/spec/ruby/core/complex/rationalize_spec.rb index 043b8ddf2a013a..d49bb52def782a 100644 --- a/spec/ruby/core/complex/rationalize_spec.rb +++ b/spec/ruby/core/complex/rationalize_spec.rb @@ -2,11 +2,11 @@ describe "Complex#rationalize" do it "raises RangeError if self has non-zero imaginary part" do - -> { Complex(1,5).rationalize }.should raise_error(RangeError) + -> { Complex(1,5).rationalize }.should.raise(RangeError) end it "raises RangeError if self has 0.0 imaginary part" do - -> { Complex(1,0.0).rationalize }.should raise_error(RangeError) + -> { Complex(1,0.0).rationalize }.should.raise(RangeError) end it "returns a Rational if self has zero imaginary part" do @@ -25,7 +25,7 @@ end it "raises ArgumentError when passed more than one argument" do - -> { Complex(1,0).rationalize(0.1, 0.1) }.should raise_error(ArgumentError) - -> { Complex(1,0).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError) + -> { Complex(1,0).rationalize(0.1, 0.1) }.should.raise(ArgumentError) + -> { Complex(1,0).rationalize(0.1, 0.1, 2) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/complex/real_spec.rb b/spec/ruby/core/complex/real_spec.rb index 2ea791c005a384..41734b23f0bd95 100644 --- a/spec/ruby/core/complex/real_spec.rb +++ b/spec/ruby/core/complex/real_spec.rb @@ -11,18 +11,18 @@ describe "Complex#real?" do it "returns false if there is an imaginary part" do - Complex(2,3).real?.should be_false + Complex(2,3).real?.should == false end it "returns false if there is not an imaginary part" do - Complex(2).real?.should be_false + Complex(2).real?.should == false end it "returns false if the real part is Infinity" do - Complex(infinity_value).real?.should be_false + Complex(infinity_value).real?.should == false end it "returns false if the real part is NaN" do - Complex(nan_value).real?.should be_false + Complex(nan_value).real?.should == false end end diff --git a/spec/ruby/core/complex/shared/divide.rb b/spec/ruby/core/complex/shared/divide.rb index a60802c74cb382..ef79ecdf751fa0 100644 --- a/spec/ruby/core/complex/shared/divide.rb +++ b/spec/ruby/core/complex/shared/divide.rb @@ -19,11 +19,11 @@ end it "raises a ZeroDivisionError when given zero" do - -> { Complex(20, 40).send(@method, 0) }.should raise_error(ZeroDivisionError) + -> { Complex(20, 40).send(@method, 0) }.should.raise(ZeroDivisionError) end it "produces Rational parts" do - Complex(5, 9).send(@method, 2).should eql(Complex(Rational(5,2), Rational(9,2))) + Complex(5, 9).send(@method, 2).should.eql?(Complex(Rational(5,2), Rational(9,2))) end end @@ -76,7 +76,7 @@ other = mock_numeric('other') other.should_receive(:real?).any_number_of_times.and_return(false) other.should_receive(:coerce).with(complex).and_return([5, 2]) - complex.send(@method, other).should eql(Rational(5, 2)) + complex.send(@method, other).should.eql?(Rational(5, 2)) end end end diff --git a/spec/ruby/core/complex/shared/rect.rb b/spec/ruby/core/complex/shared/rect.rb index 4ac294e7716bd6..858234961b648b 100644 --- a/spec/ruby/core/complex/shared/rect.rb +++ b/spec/ruby/core/complex/shared/rect.rb @@ -13,7 +13,7 @@ it "returns an Array" do @numbers.each do |number| - number.send(@method).should be_an_instance_of(Array) + number.send(@method).should.instance_of?(Array) end end @@ -37,7 +37,7 @@ it "raises an ArgumentError if given any arguments" do @numbers.each do |number| - -> { number.send(@method, number) }.should raise_error(ArgumentError) + -> { number.send(@method, number) }.should.raise(ArgumentError) end end end @@ -57,7 +57,7 @@ it "raises TypeError" do n = mock_numeric('n') n.should_receive(:real?).any_number_of_times.and_return(false) - -> { Complex.send(@method, n) }.should raise_error(TypeError) + -> { Complex.send(@method, n) }.should.raise(TypeError) end end @@ -68,7 +68,7 @@ n2 = mock_numeric('n2') n1.should_receive(:real?).any_number_of_times.and_return(r1) n2.should_receive(:real?).any_number_of_times.and_return(r2) - -> { Complex.send(@method, n1, n2) }.should raise_error(TypeError) + -> { Complex.send(@method, n1, n2) }.should.raise(TypeError) end end end @@ -87,8 +87,8 @@ describe "passed a non-Numeric" do it "raises TypeError" do - -> { Complex.send(@method, :sym) }.should raise_error(TypeError) - -> { Complex.send(@method, 0, :sym) }.should raise_error(TypeError) + -> { Complex.send(@method, :sym) }.should.raise(TypeError) + -> { Complex.send(@method, 0, :sym) }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/complex/to_c_spec.rb b/spec/ruby/core/complex/to_c_spec.rb index 5ce01d9d4e9f53..cd7195556c9b5d 100644 --- a/spec/ruby/core/complex/to_c_spec.rb +++ b/spec/ruby/core/complex/to_c_spec.rb @@ -3,7 +3,7 @@ describe "Complex#to_c" do it "returns self" do value = Complex(1, 5) - value.to_c.should equal(value) + value.to_c.should.equal?(value) end it 'returns the same value' do diff --git a/spec/ruby/core/complex/to_f_spec.rb b/spec/ruby/core/complex/to_f_spec.rb index b53471c1fccaea..9f3265cdb9278f 100644 --- a/spec/ruby/core/complex/to_f_spec.rb +++ b/spec/ruby/core/complex/to_f_spec.rb @@ -29,13 +29,13 @@ describe "when the imaginary part is non-zero" do it "raises RangeError" do - -> { Complex(0, 1).to_f }.should raise_error(RangeError) + -> { Complex(0, 1).to_f }.should.raise(RangeError) end end describe "when the imaginary part is Float 0.0" do it "raises RangeError" do - -> { Complex(0, 0.0).to_f }.should raise_error(RangeError) + -> { Complex(0, 0.0).to_f }.should.raise(RangeError) end end end diff --git a/spec/ruby/core/complex/to_i_spec.rb b/spec/ruby/core/complex/to_i_spec.rb index 1e78f5ec0e6d3f..9149ffbbaa0ef7 100644 --- a/spec/ruby/core/complex/to_i_spec.rb +++ b/spec/ruby/core/complex/to_i_spec.rb @@ -29,13 +29,13 @@ describe "when the imaginary part is non-zero" do it "raises RangeError" do - -> { Complex(0, 1).to_i }.should raise_error(RangeError) + -> { Complex(0, 1).to_i }.should.raise(RangeError) end end describe "when the imaginary part is Float 0.0" do it "raises RangeError" do - -> { Complex(0, 0.0).to_i }.should raise_error(RangeError) + -> { Complex(0, 0.0).to_i }.should.raise(RangeError) end end end diff --git a/spec/ruby/core/complex/to_r_spec.rb b/spec/ruby/core/complex/to_r_spec.rb index 788027a50039c5..6587ae9e2eb1ab 100644 --- a/spec/ruby/core/complex/to_r_spec.rb +++ b/spec/ruby/core/complex/to_r_spec.rb @@ -29,14 +29,14 @@ describe "when the imaginary part is non-zero" do it "raises RangeError" do - -> { Complex(0, 1).to_r }.should raise_error(RangeError) + -> { Complex(0, 1).to_r }.should.raise(RangeError) end end describe "when the imaginary part is Float 0.0" do ruby_version_is ''...'3.4' do it "raises RangeError" do - -> { Complex(0, 0.0).to_r }.should raise_error(RangeError) + -> { Complex(0, 0.0).to_r }.should.raise(RangeError) end end diff --git a/spec/ruby/core/conditionvariable/broadcast_spec.rb b/spec/ruby/core/conditionvariable/broadcast_spec.rb index 55a7b89c7295c2..16c7b4cc8d492b 100644 --- a/spec/ruby/core/conditionvariable/broadcast_spec.rb +++ b/spec/ruby/core/conditionvariable/broadcast_spec.rb @@ -24,7 +24,7 @@ # wait until all threads are sleeping (ie waiting) Thread.pass until threads.all?(&:stop?) - r2.should be_empty + r2.should.empty? m.synchronize do cv.broadcast end diff --git a/spec/ruby/core/conditionvariable/marshal_dump_spec.rb b/spec/ruby/core/conditionvariable/marshal_dump_spec.rb index 88b1cc38c14296..594c178e8883ed 100644 --- a/spec/ruby/core/conditionvariable/marshal_dump_spec.rb +++ b/spec/ruby/core/conditionvariable/marshal_dump_spec.rb @@ -3,6 +3,6 @@ describe "ConditionVariable#marshal_dump" do it "raises a TypeError" do cv = ConditionVariable.new - -> { cv.marshal_dump }.should raise_error(TypeError, /can't dump/) + -> { cv.marshal_dump }.should.raise(TypeError, /can't dump/) end end diff --git a/spec/ruby/core/conditionvariable/signal_spec.rb b/spec/ruby/core/conditionvariable/signal_spec.rb index 43a9cc611b5e7e..3b266cf8c67289 100644 --- a/spec/ruby/core/conditionvariable/signal_spec.rb +++ b/spec/ruby/core/conditionvariable/signal_spec.rb @@ -24,7 +24,7 @@ # wait until all threads are sleeping (ie waiting) Thread.pass until threads.all?(&:stop?) - r2.should be_empty + r2.should.empty? 100.times do |i| m.synchronize do cv.signal diff --git a/spec/ruby/core/conditionvariable/wait_spec.rb b/spec/ruby/core/conditionvariable/wait_spec.rb index fe73e513c07653..1af53a15a2dba5 100644 --- a/spec/ruby/core/conditionvariable/wait_spec.rb +++ b/spec/ruby/core/conditionvariable/wait_spec.rb @@ -163,7 +163,7 @@ # On TruffleRuby, this causes a safepoint which has interesting # interactions with the ConditionVariable. bt = t.backtrace - bt.should be_kind_of(Array) + bt.should.is_a?(Array) bt.size.should >= 2 } end diff --git a/spec/ruby/core/data/deconstruct_keys_spec.rb b/spec/ruby/core/data/deconstruct_keys_spec.rb index 5914fcf6b7ce69..53f2334546a25c 100644 --- a/spec/ruby/core/data/deconstruct_keys_spec.rb +++ b/spec/ruby/core/data/deconstruct_keys_spec.rb @@ -15,7 +15,7 @@ -> { d.deconstruct_keys - }.should raise_error(ArgumentError, /wrong number of arguments \(given 0, expected 1\)/) + }.should.raise(ArgumentError, /wrong number of arguments \(given 0, expected 1\)/) end it "returns only specified keys" do @@ -73,7 +73,7 @@ -> { d.deconstruct_keys([0, 1]) - }.should raise_error(TypeError, "0 is not a symbol nor a string") + }.should.raise(TypeError, "0 is not a symbol nor a string") end it "raises a TypeError if the conversion with #to_str does not return a String" do @@ -88,13 +88,13 @@ }.should raise_consistent_error(TypeError, /can't convert MockObject into String/) end - it "raises TypeError if index is not a Symbol and not convertible to String " do + it "raises TypeError if index is not a Symbol and not convertible to String" do klass = Data.define(:x, :y) d = klass.new(1, 2) -> { d.deconstruct_keys([0, []]) - }.should raise_error(TypeError, "0 is not a symbol nor a string") + }.should.raise(TypeError, "0 is not a symbol nor a string") end end @@ -102,9 +102,9 @@ klass = Data.define(:x, :y) d = klass.new(1, 2) - -> { d.deconstruct_keys('x') }.should raise_error(TypeError, /expected Array or nil/) - -> { d.deconstruct_keys(1) }.should raise_error(TypeError, /expected Array or nil/) - -> { d.deconstruct_keys(:x) }.should raise_error(TypeError, /expected Array or nil/) - -> { d.deconstruct_keys({}) }.should raise_error(TypeError, /expected Array or nil/) + -> { d.deconstruct_keys('x') }.should.raise(TypeError, /expected Array or nil/) + -> { d.deconstruct_keys(1) }.should.raise(TypeError, /expected Array or nil/) + -> { d.deconstruct_keys(:x) }.should.raise(TypeError, /expected Array or nil/) + -> { d.deconstruct_keys({}) }.should.raise(TypeError, /expected Array or nil/) end end diff --git a/spec/ruby/core/data/hash_spec.rb b/spec/ruby/core/data/hash_spec.rb index c23f08a71d61cc..bab146c92efdba 100644 --- a/spec/ruby/core/data/hash_spec.rb +++ b/spec/ruby/core/data/hash_spec.rb @@ -6,7 +6,7 @@ a = DataSpecs::Measure.new(42, "km") b = DataSpecs::Measure.new(42, "km") a.hash.should == b.hash - a.hash.should be_an_instance_of(Integer) + a.hash.should.instance_of?(Integer) end it "returns different hashes for objects with different values" do diff --git a/spec/ruby/core/data/initialize_spec.rb b/spec/ruby/core/data/initialize_spec.rb index 9c3f97ec86720d..63d49e9c84da56 100644 --- a/spec/ruby/core/data/initialize_spec.rb +++ b/spec/ruby/core/data/initialize_spec.rb @@ -61,7 +61,7 @@ it "raises ArgumentError if no arguments are given" do -> { DataSpecs::Measure.new - }.should raise_error(ArgumentError) { |e| + }.should.raise(ArgumentError) { |e| e.message.should.include?("missing keywords: :amount, :unit") } end @@ -69,7 +69,7 @@ it "raises ArgumentError if at least one argument is missing" do -> { DataSpecs::Measure.new(unit: "km") - }.should raise_error(ArgumentError) { |e| + }.should.raise(ArgumentError) { |e| e.message.should.include?("missing keyword: :amount") } end @@ -77,7 +77,7 @@ it "raises ArgumentError if unknown keyword is given" do -> { DataSpecs::Measure.new(amount: 42, unit: "km", system: "metric") - }.should raise_error(ArgumentError) { |e| + }.should.raise(ArgumentError) { |e| e.message.should.include?("unknown keyword: :system") } end @@ -90,7 +90,7 @@ end it "supports Data with no fields" do - -> { DataSpecs::Empty.new }.should_not raise_error + -> { DataSpecs::Empty.new }.should_not.raise end it "can be overridden" do diff --git a/spec/ruby/core/data/to_h_spec.rb b/spec/ruby/core/data/to_h_spec.rb index 64816b72510ae9..41925cf3b240db 100644 --- a/spec/ruby/core/data/to_h_spec.rb +++ b/spec/ruby/core/data/to_h_spec.rb @@ -28,18 +28,18 @@ data = DataSpecs::Measure.new(amount: 42, unit: 'km') -> do data.to_h { |k, v| [k.to_s, v*v, 1] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) -> do data.to_h { |k, v| [k] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) end it "raises TypeError if block returns something other than Array" do data = DataSpecs::Measure.new(amount: 42, unit: 'km') -> do data.to_h { |k, v| "not-array" } - end.should raise_error(TypeError, /wrong element type String/) + end.should.raise(TypeError, /wrong element type String/) end it "coerces returned pair to Array with #to_ary" do @@ -57,7 +57,7 @@ -> do data.to_h { |k| x } - end.should raise_error(TypeError, /wrong element type MockObject/) + end.should.raise(TypeError, /wrong element type MockObject/) end end end diff --git a/spec/ruby/core/data/with_spec.rb b/spec/ruby/core/data/with_spec.rb index 83cb97fa60777b..b74df185c72ec1 100644 --- a/spec/ruby/core/data/with_spec.rb +++ b/spec/ruby/core/data/with_spec.rb @@ -28,7 +28,7 @@ -> { data.with(4, "m") - }.should raise_error(ArgumentError, "wrong number of arguments (given 2, expected 0)") + }.should.raise(ArgumentError, "wrong number of arguments (given 2, expected 0)") end it "does not depend on the Data.new method" do diff --git a/spec/ruby/core/dir/chdir_spec.rb b/spec/ruby/core/dir/chdir_spec.rb index fd277e4e1d64fc..2dc598e2a9562d 100644 --- a/spec/ruby/core/dir/chdir_spec.rb +++ b/spec/ruby/core/dir/chdir_spec.rb @@ -90,8 +90,8 @@ def to_str; DirSpecs.mock_dir; end end it "raises an Errno::ENOENT if the directory does not exist" do - -> { Dir.chdir DirSpecs.nonexistent }.should raise_error(Errno::ENOENT) - -> { Dir.chdir(DirSpecs.nonexistent) { } }.should raise_error(Errno::ENOENT) + -> { Dir.chdir DirSpecs.nonexistent }.should.raise(Errno::ENOENT) + -> { Dir.chdir(DirSpecs.nonexistent) { } }.should.raise(Errno::ENOENT) end it "raises an Errno::ENOENT if the original directory no longer exists" do @@ -106,7 +106,7 @@ def to_str; DirSpecs.mock_dir; end Dir.chdir dir1 do Dir.chdir(dir2) { Dir.unlink dir1 } end - }.should raise_error(Errno::ENOENT) + }.should.raise(Errno::ENOENT) ensure Dir.unlink dir1 if Dir.exist?(dir1) Dir.unlink dir2 if Dir.exist?(dir2) diff --git a/spec/ruby/core/dir/children_spec.rb b/spec/ruby/core/dir/children_spec.rb index 0ad3df4669e36d..6e6da1dd44352e 100644 --- a/spec/ruby/core/dir/children_spec.rb +++ b/spec/ruby/core/dir/children_spec.rb @@ -47,25 +47,25 @@ encoding = Encoding.find("filesystem") encoding = Encoding::BINARY if encoding == Encoding::US_ASCII platform_is_not :windows do - children.should include("こんにちは.txt".dup.force_encoding(encoding)) + children.should.include?("こんにちは.txt".dup.force_encoding(encoding)) end - children.first.encoding.should equal(Encoding.find("filesystem")) + children.first.encoding.should.equal?(Encoding.find("filesystem")) end it "returns children encoded with the specified encoding" do dir = File.join(DirSpecs.mock_dir, 'special') children = Dir.children(dir, encoding: "euc-jp").sort - children.first.encoding.should equal(Encoding::EUC_JP) + children.first.encoding.should.equal?(Encoding::EUC_JP) end it "returns children transcoded to the default internal encoding" do Encoding.default_internal = Encoding::EUC_KR children = Dir.children(File.join(DirSpecs.mock_dir, 'special')).sort - children.first.encoding.should equal(Encoding::EUC_KR) + children.first.encoding.should.equal?(Encoding::EUC_KR) end it "raises a SystemCallError if called with a nonexistent directory" do - -> { Dir.children DirSpecs.nonexistent }.should raise_error(SystemCallError) + -> { Dir.children DirSpecs.nonexistent }.should.raise(SystemCallError) end end @@ -113,23 +113,23 @@ encoding = Encoding.find("filesystem") encoding = Encoding::BINARY if encoding == Encoding::US_ASCII platform_is_not :windows do - children.should include("こんにちは.txt".dup.force_encoding(encoding)) + children.should.include?("こんにちは.txt".dup.force_encoding(encoding)) end - children.first.encoding.should equal(Encoding.find("filesystem")) + children.first.encoding.should.equal?(Encoding.find("filesystem")) end it "returns children encoded with the specified encoding" do path = File.join(DirSpecs.mock_dir, 'special') @dir = Dir.new(path, encoding: "euc-jp") children = @dir.children.sort - children.first.encoding.should equal(Encoding::EUC_JP) + children.first.encoding.should.equal?(Encoding::EUC_JP) end it "returns children transcoded to the default internal encoding" do Encoding.default_internal = Encoding::EUC_KR @dir = Dir.new(File.join(DirSpecs.mock_dir, 'special')) children = @dir.children.sort - children.first.encoding.should equal(Encoding::EUC_KR) + children.first.encoding.should.equal?(Encoding::EUC_KR) end it "returns the same result when called repeatedly" do diff --git a/spec/ruby/core/dir/chroot_spec.rb b/spec/ruby/core/dir/chroot_spec.rb index a5ca8943fcd333..79ad9759b0613f 100644 --- a/spec/ruby/core/dir/chroot_spec.rb +++ b/spec/ruby/core/dir/chroot_spec.rb @@ -21,17 +21,17 @@ end it "raises an Errno::EPERM exception if the directory exists" do - -> { Dir.chroot('.') }.should raise_error(Errno::EPERM) + -> { Dir.chroot('.') }.should.raise(Errno::EPERM) end it "raises a SystemCallError if the directory doesn't exist" do - -> { Dir.chroot('xgwhwhsjai2222jg') }.should raise_error(SystemCallError) + -> { Dir.chroot('xgwhwhsjai2222jg') }.should.raise(SystemCallError) end it "calls #to_path on non-String argument" do p = mock('path') p.should_receive(:to_path).and_return('.') - -> { Dir.chroot(p) }.should raise_error(Errno::EPERM) + -> { Dir.chroot(p) }.should.raise(Errno::EPERM) end end end diff --git a/spec/ruby/core/dir/close_spec.rb b/spec/ruby/core/dir/close_spec.rb index 10ad1369c84d2f..9902d98934b12c 100644 --- a/spec/ruby/core/dir/close_spec.rb +++ b/spec/ruby/core/dir/close_spec.rb @@ -15,7 +15,7 @@ dir.close.should == nil platform_is_not :windows do - -> { dir.fileno }.should raise_error(IOError, /closed directory/) + -> { dir.fileno }.should.raise(IOError, /closed directory/) end end @@ -33,8 +33,8 @@ dir.close dir_new.close - -> { dir.fileno }.should raise_error(IOError, /closed directory/) - -> { dir_new.fileno }.should raise_error(IOError, /closed directory/) + -> { dir.fileno }.should.raise(IOError, /closed directory/) + -> { dir_new.fileno }.should.raise(IOError, /closed directory/) end end end @@ -46,7 +46,7 @@ dir_new = Dir.for_fd(dir.fileno) dir.close - -> { dir_new.close }.should raise_error(Errno::EBADF, 'Bad file descriptor - closedir') + -> { dir_new.close }.should.raise(Errno::EBADF, 'Bad file descriptor - closedir') end end end diff --git a/spec/ruby/core/dir/each_child_spec.rb b/spec/ruby/core/dir/each_child_spec.rb index 7194273b9529c4..4d6575df39d64d 100644 --- a/spec/ruby/core/dir/each_child_spec.rb +++ b/spec/ruby/core/dir/each_child_spec.rb @@ -36,12 +36,12 @@ end it "raises a SystemCallError if passed a nonexistent directory" do - -> { Dir.each_child(DirSpecs.nonexistent) {} }.should raise_error(SystemCallError) + -> { Dir.each_child(DirSpecs.nonexistent) {} }.should.raise(SystemCallError) end describe "when no block is given" do it "returns an Enumerator" do - Dir.each_child(DirSpecs.mock_dir).should be_an_instance_of(Enumerator) + Dir.each_child(DirSpecs.mock_dir).should.instance_of?(Enumerator) Dir.each_child(DirSpecs.mock_dir).to_a.sort.should == DirSpecs.expected_paths - %w[. ..] end @@ -103,7 +103,7 @@ it "returns an Enumerator" do @dir = Dir.new(DirSpecs.mock_dir) - @dir.each_child.should be_an_instance_of(Enumerator) + @dir.each_child.should.instance_of?(Enumerator) @dir.each_child.to_a.sort.should == DirSpecs.expected_paths - %w|. ..| end diff --git a/spec/ruby/core/dir/each_spec.rb b/spec/ruby/core/dir/each_spec.rb index 7674663d82b0e4..e997e340b12806 100644 --- a/spec/ruby/core/dir/each_spec.rb +++ b/spec/ruby/core/dir/each_spec.rb @@ -32,7 +32,7 @@ @dir.each {}.should == @dir @dir.read.should == nil @dir.rewind - ls.should include(@dir.read) + ls.should.include?(@dir.read) end it "returns the same result when called repeatedly" do @@ -48,7 +48,7 @@ describe "when no block is given" do it "returns an Enumerator" do - @dir.each.should be_an_instance_of(Enumerator) + @dir.each.should.instance_of?(Enumerator) @dir.each.to_a.sort.should == DirSpecs.expected_paths end diff --git a/spec/ruby/core/dir/empty_spec.rb b/spec/ruby/core/dir/empty_spec.rb index 8cc875779832b9..3b6b2bac85336d 100644 --- a/spec/ruby/core/dir/empty_spec.rb +++ b/spec/ruby/core/dir/empty_spec.rb @@ -12,20 +12,20 @@ it "returns true for empty directories" do result = Dir.empty? @empty_dir - result.should be_true + result.should == true end it "returns false for non-empty directories" do result = Dir.empty? __dir__ - result.should be_false + result.should == false end it "returns false for a non-directory" do result = Dir.empty? __FILE__ - result.should be_false + result.should == false end it "raises ENOENT for nonexistent directories" do - -> { Dir.empty? tmp("nonexistent") }.should raise_error(Errno::ENOENT) + -> { Dir.empty? tmp("nonexistent") }.should.raise(Errno::ENOENT) end end diff --git a/spec/ruby/core/dir/entries_spec.rb b/spec/ruby/core/dir/entries_spec.rb index 7462542acf42e2..f3ca49b26d4898 100644 --- a/spec/ruby/core/dir/entries_spec.rb +++ b/spec/ruby/core/dir/entries_spec.rb @@ -47,24 +47,24 @@ encoding = Encoding.find("filesystem") encoding = Encoding::BINARY if encoding == Encoding::US_ASCII platform_is_not :windows do - entries.should include("こんにちは.txt".dup.force_encoding(encoding)) + entries.should.include?("こんにちは.txt".dup.force_encoding(encoding)) end - entries.first.encoding.should equal(Encoding.find("filesystem")) + entries.first.encoding.should.equal?(Encoding.find("filesystem")) end it "returns entries encoded with the specified encoding" do dir = File.join(DirSpecs.mock_dir, 'special') entries = Dir.entries(dir, encoding: "euc-jp").sort - entries.first.encoding.should equal(Encoding::EUC_JP) + entries.first.encoding.should.equal?(Encoding::EUC_JP) end it "returns entries transcoded to the default internal encoding" do Encoding.default_internal = Encoding::EUC_KR entries = Dir.entries(File.join(DirSpecs.mock_dir, 'special')).sort - entries.first.encoding.should equal(Encoding::EUC_KR) + entries.first.encoding.should.equal?(Encoding::EUC_KR) end it "raises a SystemCallError if called with a nonexistent directory" do - -> { Dir.entries DirSpecs.nonexistent }.should raise_error(SystemCallError) + -> { Dir.entries DirSpecs.nonexistent }.should.raise(SystemCallError) end end diff --git a/spec/ruby/core/dir/fchdir_spec.rb b/spec/ruby/core/dir/fchdir_spec.rb index d5e77f7f03f372..bd1a92b05ef269 100644 --- a/spec/ruby/core/dir/fchdir_spec.rb +++ b/spec/ruby/core/dir/fchdir_spec.rb @@ -50,13 +50,13 @@ end it "raises a SystemCallError if the file descriptor given is not valid" do - -> { Dir.fchdir(-1) }.should raise_error(SystemCallError, "Bad file descriptor - fchdir") - -> { Dir.fchdir(-1) { } }.should raise_error(SystemCallError, "Bad file descriptor - fchdir") + -> { Dir.fchdir(-1) }.should.raise(SystemCallError, "Bad file descriptor - fchdir") + -> { Dir.fchdir(-1) { } }.should.raise(SystemCallError, "Bad file descriptor - fchdir") end it "raises a SystemCallError if the file descriptor given is not for a directory" do - -> { Dir.fchdir $stdout.fileno }.should raise_error(SystemCallError, /(Not a directory|Invalid argument) - fchdir/) - -> { Dir.fchdir($stdout.fileno) { } }.should raise_error(SystemCallError, /(Not a directory|Invalid argument) - fchdir/) + -> { Dir.fchdir $stdout.fileno }.should.raise(SystemCallError, /(Not a directory|Invalid argument) - fchdir/) + -> { Dir.fchdir($stdout.fileno) { } }.should.raise(SystemCallError, /(Not a directory|Invalid argument) - fchdir/) end end end @@ -64,8 +64,8 @@ platform_is :windows do describe "Dir.fchdir" do it "raises NotImplementedError" do - -> { Dir.fchdir 1 }.should raise_error(NotImplementedError) - -> { Dir.fchdir(1) { } }.should raise_error(NotImplementedError) + -> { Dir.fchdir 1 }.should.raise(NotImplementedError) + -> { Dir.fchdir(1) { } }.should.raise(NotImplementedError) end end end diff --git a/spec/ruby/core/dir/fileno_spec.rb b/spec/ruby/core/dir/fileno_spec.rb index bb84ef5378f0ac..3b563eb18fda67 100644 --- a/spec/ruby/core/dir/fileno_spec.rb +++ b/spec/ruby/core/dir/fileno_spec.rb @@ -27,11 +27,11 @@ if has_dir_fileno it "returns the file descriptor of the dir" do - @dir.fileno.should be_kind_of(Integer) + @dir.fileno.should.is_a?(Integer) end else it "raises an error when not implemented on the platform" do - -> { @dir.fileno }.should raise_error(NotImplementedError) + -> { @dir.fileno }.should.raise(NotImplementedError) end end end diff --git a/spec/ruby/core/dir/for_fd_spec.rb b/spec/ruby/core/dir/for_fd_spec.rb index be80a2c1fe2667..bbc75e0f8f1999 100644 --- a/spec/ruby/core/dir/for_fd_spec.rb +++ b/spec/ruby/core/dir/for_fd_spec.rb @@ -58,11 +58,11 @@ end it "raises a SystemCallError if the file descriptor given is not valid" do - -> { Dir.for_fd(-1) }.should raise_error(SystemCallError, "Bad file descriptor - fdopendir") + -> { Dir.for_fd(-1) }.should.raise(SystemCallError, "Bad file descriptor - fdopendir") end it "raises a SystemCallError if the file descriptor given is not for a directory" do - -> { Dir.for_fd $stdout.fileno }.should raise_error(SystemCallError, "Not a directory - fdopendir") + -> { Dir.for_fd $stdout.fileno }.should.raise(SystemCallError, "Not a directory - fdopendir") end end end @@ -70,7 +70,7 @@ platform_is :windows do describe "Dir.for_fd" do it "raises NotImplementedError" do - -> { Dir.for_fd 1 }.should raise_error(NotImplementedError) + -> { Dir.for_fd 1 }.should.raise(NotImplementedError) end end end diff --git a/spec/ruby/core/dir/foreach_spec.rb b/spec/ruby/core/dir/foreach_spec.rb index 9cf34b1d71c8fe..2a2265a0298009 100644 --- a/spec/ruby/core/dir/foreach_spec.rb +++ b/spec/ruby/core/dir/foreach_spec.rb @@ -31,11 +31,11 @@ end it "raises a SystemCallError if passed a nonexistent directory" do - -> { Dir.foreach(DirSpecs.nonexistent) {} }.should raise_error(SystemCallError) + -> { Dir.foreach(DirSpecs.nonexistent) {} }.should.raise(SystemCallError) end it "returns an Enumerator if no block given" do - Dir.foreach(DirSpecs.mock_dir).should be_an_instance_of(Enumerator) + Dir.foreach(DirSpecs.mock_dir).should.instance_of?(Enumerator) Dir.foreach(DirSpecs.mock_dir).to_a.sort.should == DirSpecs.expected_paths end @@ -53,7 +53,7 @@ describe "when no block is given" do it "returns an Enumerator" do - Dir.foreach(DirSpecs.mock_dir).should be_an_instance_of(Enumerator) + Dir.foreach(DirSpecs.mock_dir).should.instance_of?(Enumerator) Dir.foreach(DirSpecs.mock_dir).to_a.sort.should == DirSpecs.expected_paths end diff --git a/spec/ruby/core/dir/glob_spec.rb b/spec/ruby/core/dir/glob_spec.rb index a60b233bc0f2d8..9e81feb15fc1cd 100644 --- a/spec/ruby/core/dir/glob_spec.rb +++ b/spec/ruby/core/dir/glob_spec.rb @@ -149,7 +149,7 @@ it "accepts a block and yields it with each elements" do ary = [] ret = Dir.glob(["file_o*", "file_t*"]) { |t| ary << t } - ret.should be_nil + ret.should == nil ary.should == %w!file_one.ext file_two.ext! end diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb index 966ac38af3ec04..f0b20e06877d67 100644 --- a/spec/ruby/core/dir/home_spec.rb +++ b/spec/ruby/core/dir/home_spec.rb @@ -74,7 +74,7 @@ end it "raises an ArgumentError if the named user doesn't exist" do - -> { Dir.home('geuw2n288dh2k') }.should raise_error(ArgumentError) + -> { Dir.home('geuw2n288dh2k') }.should.raise(ArgumentError) end describe "when called with a nil user name" do diff --git a/spec/ruby/core/dir/inspect_spec.rb b/spec/ruby/core/dir/inspect_spec.rb index 37338a97d4f25e..eabaa54ce03eb0 100644 --- a/spec/ruby/core/dir/inspect_spec.rb +++ b/spec/ruby/core/dir/inspect_spec.rb @@ -11,7 +11,7 @@ end it "returns a String" do - @dir.inspect.should be_an_instance_of(String) + @dir.inspect.should.instance_of?(String) end it "includes the class name" do @@ -19,6 +19,6 @@ end it "includes the directory name" do - @dir.inspect.should include(Dir.getwd) + @dir.inspect.should.include?(Dir.getwd) end end diff --git a/spec/ruby/core/dir/mkdir_spec.rb b/spec/ruby/core/dir/mkdir_spec.rb index 076ec19dd96641..37513e417ad059 100644 --- a/spec/ruby/core/dir/mkdir_spec.rb +++ b/spec/ruby/core/dir/mkdir_spec.rb @@ -67,19 +67,19 @@ path = DirSpecs.mock_dir('nonexisting') permissions = Object.new - -> { Dir.mkdir(path, permissions) }.should raise_error(TypeError, 'no implicit conversion of Object into Integer') + -> { Dir.mkdir(path, permissions) }.should.raise(TypeError, 'no implicit conversion of Object into Integer') end it "raises a SystemCallError if any of the directories in the path before the last does not exist" do - -> { Dir.mkdir "#{DirSpecs.nonexistent}/subdir" }.should raise_error(SystemCallError) + -> { Dir.mkdir "#{DirSpecs.nonexistent}/subdir" }.should.raise(SystemCallError) end it "raises Errno::EEXIST if the specified directory already exists" do - -> { Dir.mkdir("#{DirSpecs.mock_dir}/dir") }.should raise_error(Errno::EEXIST) + -> { Dir.mkdir("#{DirSpecs.mock_dir}/dir") }.should.raise(Errno::EEXIST) end it "raises Errno::EEXIST if the argument points to the existing file" do - -> { Dir.mkdir("#{DirSpecs.mock_dir}/file_one.ext") }.should raise_error(Errno::EEXIST) + -> { Dir.mkdir("#{DirSpecs.mock_dir}/file_one.ext") }.should.raise(Errno::EEXIST) end end @@ -100,7 +100,7 @@ it "raises a SystemCallError when lacking adequate permissions in the parent dir" do Dir.mkdir @dir, 0000 - -> { Dir.mkdir "#{@dir}/subdir" }.should raise_error(SystemCallError) + -> { Dir.mkdir "#{@dir}/subdir" }.should.raise(SystemCallError) end end end diff --git a/spec/ruby/core/dir/read_spec.rb b/spec/ruby/core/dir/read_spec.rb index 276930c6b7ecc0..3f842457f4d52a 100644 --- a/spec/ruby/core/dir/read_spec.rb +++ b/spec/ruby/core/dir/read_spec.rb @@ -15,7 +15,7 @@ # an FS does not necessarily impose order ls = Dir.entries DirSpecs.mock_dir dir = Dir.open DirSpecs.mock_dir - ls.should include(dir.read) + ls.should.include?(dir.read) dir.close end @@ -61,7 +61,7 @@ while entry = d.read shift_jis_entries << entry end - }.should_not raise_error + }.should_not.raise end ensure Encoding.default_internal = old_internal_encoding diff --git a/spec/ruby/core/dir/scan_spec.rb b/spec/ruby/core/dir/scan_spec.rb index a34eedf13bce4f..3aa071337b9942 100644 --- a/spec/ruby/core/dir/scan_spec.rb +++ b/spec/ruby/core/dir/scan_spec.rb @@ -69,49 +69,49 @@ encoding = Encoding.find("filesystem") encoding = Encoding::BINARY if encoding == Encoding::US_ASCII platform_is_not :windows do - children.should include(["こんにちは.txt".dup.force_encoding(encoding), :file]) + children.should.include?(["こんにちは.txt".dup.force_encoding(encoding), :file]) end - children.first.first.encoding.should equal(Encoding.find("filesystem")) + children.first.first.encoding.should.equal?(Encoding.find("filesystem")) end it "returns children names encoded with the specified encoding" do dir = File.join(DirSpecs.mock_dir, 'special') children = Dir.scan(dir, encoding: "euc-jp").sort - children.first.first.encoding.should equal(Encoding::EUC_JP) + children.first.first.encoding.should.equal?(Encoding::EUC_JP) end it "returns children names transcoded to the default internal encoding" do Encoding.default_internal = Encoding::EUC_KR children = Dir.scan(File.join(DirSpecs.mock_dir, 'special')).sort - children.first.first.encoding.should equal(Encoding::EUC_KR) + children.first.first.encoding.should.equal?(Encoding::EUC_KR) end it "raises a SystemCallError if called with a nonexistent directory" do - -> { Dir.scan DirSpecs.nonexistent }.should raise_error(SystemCallError) + -> { Dir.scan DirSpecs.nonexistent }.should.raise(SystemCallError) end it "handles symlink" do FileSpecs.symlink do |path| - Dir.scan(File.dirname(path)).map(&:last).should include(:link) + Dir.scan(File.dirname(path)).map(&:last).should.include?(:link) end end platform_is_not :windows do it "handles socket" do FileSpecs.socket do |path| - Dir.scan(File.dirname(path)).map(&:last).should include(:socket) + Dir.scan(File.dirname(path)).map(&:last).should.include?(:socket) end end it "handles FIFO" do FileSpecs.fifo do |path| - Dir.scan(File.dirname(path)).map(&:last).should include(:fifo) + Dir.scan(File.dirname(path)).map(&:last).should.include?(:fifo) end end it "handles character devices" do FileSpecs.character_device do |path| - Dir.scan(File.dirname(path)).map(&:last).should include(:characterSpecial) + Dir.scan(File.dirname(path)).map(&:last).should.include?(:characterSpecial) end end end @@ -120,7 +120,7 @@ with_block_device do it "handles block devices" do FileSpecs.block_device do |path| - Dir.scan(File.dirname(path)).map(&:last).should include(:blockSpecial) + Dir.scan(File.dirname(path)).map(&:last).should.include?(:blockSpecial) end end end @@ -189,23 +189,23 @@ encoding = Encoding.find("filesystem") encoding = Encoding::BINARY if encoding == Encoding::US_ASCII platform_is_not :windows do - children.should include(["こんにちは.txt".dup.force_encoding(encoding), :file]) + children.should.include?(["こんにちは.txt".dup.force_encoding(encoding), :file]) end - children.first.first.encoding.should equal(Encoding.find("filesystem")) + children.first.first.encoding.should.equal?(Encoding.find("filesystem")) end it "returns children names encoded with the specified encoding" do path = File.join(DirSpecs.mock_dir, 'special') @dir = Dir.new(path, encoding: "euc-jp") children = @dir.children.sort - children.first.encoding.should equal(Encoding::EUC_JP) + children.first.encoding.should.equal?(Encoding::EUC_JP) end it "returns children names transcoded to the default internal encoding" do Encoding.default_internal = Encoding::EUC_KR @dir = Dir.new(File.join(DirSpecs.mock_dir, 'special')) children = @dir.scan.sort - children.first.first.encoding.should equal(Encoding::EUC_KR) + children.first.first.encoding.should.equal?(Encoding::EUC_KR) end it "returns the same result when called repeatedly" do diff --git a/spec/ruby/core/dir/shared/chroot.rb b/spec/ruby/core/dir/shared/chroot.rb index a8f7c10a199a0f..e4e61037996aa8 100644 --- a/spec/ruby/core/dir/shared/chroot.rb +++ b/spec/ruby/core/dir/shared/chroot.rb @@ -18,7 +18,7 @@ compilations_ci = ENV["GITHUB_WORKFLOW"] == "Compilations" it "can be used to change the process' root directory" do - -> { Dir.send(@method, __dir__) }.should_not raise_error + -> { Dir.send(@method, __dir__) }.should_not.raise File.should.exist?("/#{File.basename(__FILE__)}") end unless compilations_ci @@ -27,7 +27,7 @@ end it "raises an Errno::ENOENT exception if the directory doesn't exist" do - -> { Dir.send(@method, 'xgwhwhsjai2222jg') }.should raise_error(Errno::ENOENT) + -> { Dir.send(@method, 'xgwhwhsjai2222jg') }.should.raise(Errno::ENOENT) end it "can be escaped from with ../" do diff --git a/spec/ruby/core/dir/shared/closed.rb b/spec/ruby/core/dir/shared/closed.rb index 17d8332c2a6f9c..c868fd6e6d9005 100644 --- a/spec/ruby/core/dir/shared/closed.rb +++ b/spec/ruby/core/dir/shared/closed.rb @@ -4,6 +4,6 @@ dir = Dir.open DirSpecs.mock_dir dir.close dir.send(@method) {} - }.should raise_error(IOError) + }.should.raise(IOError) end end diff --git a/spec/ruby/core/dir/shared/delete.rb b/spec/ruby/core/dir/shared/delete.rb index a81b0597593ddd..ba013e8615af16 100644 --- a/spec/ruby/core/dir/shared/delete.rb +++ b/spec/ruby/core/dir/shared/delete.rb @@ -20,13 +20,13 @@ it "raises an Errno::ENOTEMPTY when trying to remove a nonempty directory" do -> do Dir.send @method, DirSpecs.mock_rmdir("nonempty") - end.should raise_error(Errno::ENOTEMPTY) + end.should.raise(Errno::ENOTEMPTY) end it "raises an Errno::ENOENT when trying to remove a non-existing directory" do -> do Dir.send @method, DirSpecs.nonexistent - end.should raise_error(Errno::ENOENT) + end.should.raise(Errno::ENOENT) end it "raises an Errno::ENOTDIR when trying to remove a non-directory" do @@ -34,7 +34,7 @@ touch(file) -> do Dir.send @method, file - end.should raise_error(Errno::ENOTDIR) + end.should.raise(Errno::ENOTDIR) end # this won't work on Windows, since chmod(0000) does not remove all permissions @@ -46,7 +46,7 @@ File.chmod(0000, parent) -> do Dir.send @method, child - end.should raise_error(Errno::EACCES) + end.should.raise(Errno::EACCES) end end end diff --git a/spec/ruby/core/dir/shared/exist.rb b/spec/ruby/core/dir/shared/exist.rb index 3097f57715118c..4ceaccea66fe6b 100644 --- a/spec/ruby/core/dir/shared/exist.rb +++ b/spec/ruby/core/dir/shared/exist.rb @@ -1,52 +1,52 @@ describe :dir_exist, shared: true do it "returns true if the given directory exists" do - Dir.send(@method, __dir__).should be_true + Dir.send(@method, __dir__).should == true end it "returns true for '.'" do - Dir.send(@method, '.').should be_true + Dir.send(@method, '.').should == true end it "returns true for '..'" do - Dir.send(@method, '..').should be_true + Dir.send(@method, '..').should == true end it "understands non-ASCII paths" do subdir = File.join(tmp("\u{9876}\u{665}")) - Dir.send(@method, subdir).should be_false + Dir.send(@method, subdir).should == false Dir.mkdir(subdir) - Dir.send(@method, subdir).should be_true + Dir.send(@method, subdir).should == true Dir.rmdir(subdir) end it "understands relative paths" do - Dir.send(@method, __dir__ + '/../').should be_true + Dir.send(@method, __dir__ + '/../').should == true end it "returns false if the given directory doesn't exist" do - Dir.send(@method, 'y26dg27n2nwjs8a/').should be_false + Dir.send(@method, 'y26dg27n2nwjs8a/').should == false end it "doesn't require the name to have a trailing slash" do dir = __dir__ dir.sub!(/\/$/,'') - Dir.send(@method, dir).should be_true + Dir.send(@method, dir).should == true end it "doesn't expand paths" do skip "$HOME not valid directory" unless ENV['HOME'] && File.directory?(ENV['HOME']) - Dir.send(@method, File.expand_path('~')).should be_true - Dir.send(@method, '~').should be_false + Dir.send(@method, File.expand_path('~')).should == true + Dir.send(@method, '~').should == false end it "returns false if the argument exists but is a file" do File.should.exist?(__FILE__) - Dir.send(@method, __FILE__).should be_false + Dir.send(@method, __FILE__).should == false end it "doesn't set $! when file doesn't exist" do Dir.send(@method, "/path/to/non/existent/dir") - $!.should be_nil + $!.should == nil end it "calls #to_path on non String arguments" do diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb index b1fc924f0838ad..86aa105259a0cb 100644 --- a/spec/ruby/core/dir/shared/glob.rb +++ b/spec/ruby/core/dir/shared/glob.rb @@ -13,7 +13,7 @@ it "raises an Encoding::CompatibilityError if the argument encoding is not compatible with US-ASCII" do pattern = "files*".dup.force_encoding Encoding::UTF_16BE - -> { Dir.send(@method, pattern) }.should raise_error(Encoding::CompatibilityError) + -> { Dir.send(@method, pattern) }.should.raise(Encoding::CompatibilityError) end it "calls #to_path to convert a pattern" do @@ -24,7 +24,7 @@ end it "raises an ArgumentError if the string contains \\0" do - -> {Dir.send(@method, "file_o*\0file_t*")}.should raise_error ArgumentError, /nul-separated/ + -> {Dir.send(@method, "file_o*\0file_t*")}.should.raise ArgumentError, /nul-separated/ end it "result is sorted by default" do @@ -43,9 +43,9 @@ end it "raises an ArgumentError if sort: is not true or false" do - -> { Dir.send(@method, '*', sort: 0) }.should raise_error ArgumentError, /expected true or false/ - -> { Dir.send(@method, '*', sort: nil) }.should raise_error ArgumentError, /expected true or false/ - -> { Dir.send(@method, '*', sort: 'false') }.should raise_error ArgumentError, /expected true or false/ + -> { Dir.send(@method, '*', sort: 0) }.should.raise ArgumentError, /expected true or false/ + -> { Dir.send(@method, '*', sort: nil) }.should.raise ArgumentError, /expected true or false/ + -> { Dir.send(@method, '*', sort: 'false') }.should.raise ArgumentError, /expected true or false/ end it "matches non-dotfiles with '*'" do @@ -373,7 +373,7 @@ it "raises TypeError when cannot convert value to string" do -> { Dir.send(@method, "*", base: []) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "handles '' as current directory path" do diff --git a/spec/ruby/core/dir/shared/open.rb b/spec/ruby/core/dir/shared/open.rb index 920845cba18b3d..9ac3a40694375d 100644 --- a/spec/ruby/core/dir/shared/open.rb +++ b/spec/ruby/core/dir/shared/open.rb @@ -1,18 +1,18 @@ describe :dir_open, shared: true do it "returns a Dir instance representing the specified directory" do dir = Dir.send(@method, DirSpecs.mock_dir) - dir.should be_kind_of(Dir) + dir.should.is_a?(Dir) dir.close end it "raises a SystemCallError if the directory does not exist" do -> do Dir.send @method, DirSpecs.nonexistent - end.should raise_error(SystemCallError) + end.should.raise(SystemCallError) end it "may take a block which is yielded to with the Dir instance" do - Dir.send(@method, DirSpecs.mock_dir) {|dir| dir.should be_kind_of(Dir)} + Dir.send(@method, DirSpecs.mock_dir) {|dir| dir.should.is_a?(Dir)} end it "returns the value of the block if a block is given" do @@ -21,7 +21,7 @@ it "closes the Dir instance when the block exits if given a block" do closed_dir = Dir.send(@method, DirSpecs.mock_dir) { |dir| dir } - -> { closed_dir.read }.should raise_error(IOError) + -> { closed_dir.read }.should.raise(IOError) end it "closes the Dir instance when the block exits the block even due to an exception" do @@ -32,9 +32,9 @@ closed_dir = dir raise "dir specs" end - end.should raise_error(RuntimeError, "dir specs") + end.should.raise(RuntimeError, "dir specs") - -> { closed_dir.read }.should raise_error(IOError) + -> { closed_dir.read }.should.raise(IOError) end it "calls #to_path on non-String arguments" do @@ -45,7 +45,7 @@ it "accepts an options Hash" do dir = Dir.send(@method, DirSpecs.mock_dir, encoding: "utf-8") {|d| d } - dir.should be_kind_of(Dir) + dir.should.is_a?(Dir) end it "calls #to_hash to convert the options object" do @@ -53,12 +53,12 @@ options.should_receive(:to_hash).and_return({ encoding: Encoding::UTF_8 }) dir = Dir.send(@method, DirSpecs.mock_dir, **options) {|d| d } - dir.should be_kind_of(Dir) + dir.should.is_a?(Dir) end it "ignores the :encoding option if it is nil" do dir = Dir.send(@method, DirSpecs.mock_dir, encoding: nil) {|d| d } - dir.should be_kind_of(Dir) + dir.should.is_a?(Dir) end platform_is_not :windows do diff --git a/spec/ruby/core/dir/shared/path.rb b/spec/ruby/core/dir/shared/path.rb index 494dcca7751a08..7647c04421127b 100644 --- a/spec/ruby/core/dir/shared/path.rb +++ b/spec/ruby/core/dir/shared/path.rb @@ -22,7 +22,7 @@ path = DirSpecs.mock_dir.force_encoding Encoding::IBM866 dir = Dir.open path begin - dir.send(@method).encoding.should equal(Encoding::IBM866) + dir.send(@method).encoding.should.equal?(Encoding::IBM866) ensure dir.close end diff --git a/spec/ruby/core/dir/shared/pos.rb b/spec/ruby/core/dir/shared/pos.rb index 2165932d991c99..11712cc75df463 100644 --- a/spec/ruby/core/dir/shared/pos.rb +++ b/spec/ruby/core/dir/shared/pos.rb @@ -8,9 +8,9 @@ end it "returns an Integer representing the current position in the directory" do - @dir.send(@method).should be_kind_of(Integer) - @dir.send(@method).should be_kind_of(Integer) - @dir.send(@method).should be_kind_of(Integer) + @dir.send(@method).should.is_a?(Integer) + @dir.send(@method).should.is_a?(Integer) + @dir.send(@method).should.is_a?(Integer) end it "returns a different Integer if moved from previous position" do @@ -18,8 +18,8 @@ @dir.read b = @dir.send(@method) - a.should be_kind_of(Integer) - b.should be_kind_of(Integer) + a.should.is_a?(Integer) + b.should.is_a?(Integer) a.should_not == b end diff --git a/spec/ruby/core/dir/shared/pwd.rb b/spec/ruby/core/dir/shared/pwd.rb index 2a8d7fe790d0b8..ed47fe382af309 100644 --- a/spec/ruby/core/dir/shared/pwd.rb +++ b/spec/ruby/core/dir/shared/pwd.rb @@ -37,9 +37,9 @@ it "returns a String with the filesystem encoding" do enc = Dir.send(@method).encoding if @fs_encoding == Encoding::US_ASCII - [Encoding::US_ASCII, Encoding::BINARY].should include(enc) + [Encoding::US_ASCII, Encoding::BINARY].should.include?(enc) else - enc.should equal(@fs_encoding) + enc.should.equal?(@fs_encoding) end end end diff --git a/spec/ruby/core/encoding/aliases_spec.rb b/spec/ruby/core/encoding/aliases_spec.rb index 786157981a9d56..12c6c6cf853a2f 100644 --- a/spec/ruby/core/encoding/aliases_spec.rb +++ b/spec/ruby/core/encoding/aliases_spec.rb @@ -2,24 +2,24 @@ describe "Encoding.aliases" do it "returns a Hash" do - Encoding.aliases.should be_an_instance_of(Hash) + Encoding.aliases.should.instance_of?(Hash) end it "has Strings as keys" do Encoding.aliases.keys.each do |key| - key.should be_an_instance_of(String) + key.should.instance_of?(String) end end it "has Strings as values" do Encoding.aliases.values.each do |value| - value.should be_an_instance_of(String) + value.should.instance_of?(String) end end it "has alias names as its keys" do - Encoding.aliases.key?('BINARY').should be_true - Encoding.aliases.key?('ASCII').should be_true + Encoding.aliases.key?('BINARY').should == true + Encoding.aliases.key?('ASCII').should == true end it "has the names of the aliased encoding as its values" do diff --git a/spec/ruby/core/encoding/ascii_compatible_spec.rb b/spec/ruby/core/encoding/ascii_compatible_spec.rb index bbcc6add9e4e1b..04fc159bb83fe3 100644 --- a/spec/ruby/core/encoding/ascii_compatible_spec.rb +++ b/spec/ruby/core/encoding/ascii_compatible_spec.rb @@ -2,11 +2,11 @@ describe "Encoding#ascii_compatible?" do it "returns true if self represents an ASCII-compatible encoding" do - Encoding::UTF_8.ascii_compatible?.should be_true + Encoding::UTF_8.ascii_compatible?.should == true end it "returns false if self does not represent an ASCII-compatible encoding" do - Encoding::UTF_16LE.ascii_compatible?.should be_false + Encoding::UTF_16LE.ascii_compatible?.should == false end it "returns false for UTF_16 and UTF_32" do diff --git a/spec/ruby/core/encoding/compatible_spec.rb b/spec/ruby/core/encoding/compatible_spec.rb index 97860af8d332ef..0d620e5bf39931 100644 --- a/spec/ruby/core/encoding/compatible_spec.rb +++ b/spec/ruby/core/encoding/compatible_spec.rb @@ -55,7 +55,7 @@ it "returns nil if the second's Encoding is not ASCII compatible" do a = "abc".dup.force_encoding("UTF-8") b = "1234".dup.force_encoding("UTF-16LE") - Encoding.compatible?(a, b).should be_nil + Encoding.compatible?(a, b).should == nil end end @@ -69,7 +69,7 @@ end it "returns nil if the second encoding is ASCII compatible but neither String's encoding is ASCII only" do - Encoding.compatible?("\xff", "\u3042".encode("utf-8")).should be_nil + Encoding.compatible?("\xff", "\u3042".encode("utf-8")).should == nil end end @@ -79,15 +79,15 @@ end it "returns nil when the second String is US-ASCII" do - Encoding.compatible?(@str, "def".encode("us-ascii")).should be_nil + Encoding.compatible?(@str, "def".encode("us-ascii")).should == nil end it "returns nil when the second String is BINARY and ASCII only" do - Encoding.compatible?(@str, "\x7f").should be_nil + Encoding.compatible?(@str, "\x7f").should == nil end it "returns nil when the second String is BINARY but not ASCII only" do - Encoding.compatible?(@str, "\xff").should be_nil + Encoding.compatible?(@str, "\xff").should == nil end it "returns the Encoding when the second's Encoding is not ASCII compatible but the same as the first's Encoding" do @@ -110,15 +110,15 @@ end it "returns nil when the second's Encoding is BINARY but not ASCII only" do - Encoding.compatible?(@str, "\xff").should be_nil + Encoding.compatible?(@str, "\xff").should == nil end it "returns nil when the second's Encoding is invalid and ASCII only" do - Encoding.compatible?(@str, "\x7f\x7f".dup.force_encoding("utf-16be")).should be_nil + Encoding.compatible?(@str, "\x7f\x7f".dup.force_encoding("utf-16be")).should == nil end it "returns nil when the second's Encoding is invalid and not ASCII only" do - Encoding.compatible?(@str, "\xff\xff".dup.force_encoding("utf-16be")).should be_nil + Encoding.compatible?(@str, "\xff\xff".dup.force_encoding("utf-16be")).should == nil end it "returns the Encoding when the second's Encoding is invalid but the same as the first" do @@ -589,11 +589,11 @@ describe "Encoding.compatible? String, Encoding" do it "returns nil if the String's encoding is not ASCII compatible" do - Encoding.compatible?("abc".encode("utf-32le"), Encoding::US_ASCII).should be_nil + Encoding.compatible?("abc".encode("utf-32le"), Encoding::US_ASCII).should == nil end it "returns nil if the Encoding is not ASCII compatible" do - Encoding.compatible?("abc".encode("us-ascii"), Encoding::UTF_32LE).should be_nil + Encoding.compatible?("abc".encode("us-ascii"), Encoding::UTF_32LE).should == nil end it "returns the String's encoding if the Encoding is US-ASCII" do @@ -614,7 +614,7 @@ end it "returns nil if the String's encoding is ASCII compatible but the string is not ASCII only" do - Encoding.compatible?("\u3042".encode("utf-8"), Encoding::BINARY).should be_nil + Encoding.compatible?("\u3042".encode("utf-8"), Encoding::BINARY).should == nil end end @@ -741,32 +741,32 @@ describe "Encoding.compatible? Object, Object" do it "returns nil for Object, String" do - Encoding.compatible?(Object.new, "abc").should be_nil + Encoding.compatible?(Object.new, "abc").should == nil end it "returns nil for Object, Regexp" do - Encoding.compatible?(Object.new, /./).should be_nil + Encoding.compatible?(Object.new, /./).should == nil end it "returns nil for Object, Symbol" do - Encoding.compatible?(Object.new, :sym).should be_nil + Encoding.compatible?(Object.new, :sym).should == nil end it "returns nil for String, Object" do - Encoding.compatible?("abc", Object.new).should be_nil + Encoding.compatible?("abc", Object.new).should == nil end it "returns nil for Regexp, Object" do - Encoding.compatible?(/./, Object.new).should be_nil + Encoding.compatible?(/./, Object.new).should == nil end it "returns nil for Symbol, Object" do - Encoding.compatible?(:sym, Object.new).should be_nil + Encoding.compatible?(:sym, Object.new).should == nil end end describe "Encoding.compatible? nil, nil" do it "returns nil" do - Encoding.compatible?(nil, nil).should be_nil + Encoding.compatible?(nil, nil).should == nil end end diff --git a/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb b/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb index 1beb40af3fb8b9..07c7a883562a81 100644 --- a/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb +++ b/spec/ruby/core/encoding/converter/asciicompat_encoding_spec.rb @@ -24,14 +24,14 @@ end it "returns nil when the given encoding is ASCII compatible" do - Encoding::Converter.asciicompat_encoding('ASCII').should be_nil - Encoding::Converter.asciicompat_encoding('UTF-8').should be_nil + Encoding::Converter.asciicompat_encoding('ASCII').should == nil + Encoding::Converter.asciicompat_encoding('UTF-8').should == nil end it "handles encoding names who resolve to nil encodings" do internal = Encoding.default_internal Encoding.default_internal = nil - Encoding::Converter.asciicompat_encoding('internal').should be_nil + Encoding::Converter.asciicompat_encoding('internal').should == nil Encoding.default_internal = internal end end diff --git a/spec/ruby/core/encoding/converter/constants_spec.rb b/spec/ruby/core/encoding/converter/constants_spec.rb index 7d29bdb2785823..e2d21b54293b8d 100644 --- a/spec/ruby/core/encoding/converter/constants_spec.rb +++ b/spec/ruby/core/encoding/converter/constants_spec.rb @@ -2,130 +2,130 @@ describe "Encoding::Converter::INVALID_MASK" do it "exists" do - Encoding::Converter.should have_constant(:INVALID_MASK) + Encoding::Converter.should.const_defined?(:INVALID_MASK, false) end it "has an Integer value" do - Encoding::Converter::INVALID_MASK.should be_an_instance_of(Integer) + Encoding::Converter::INVALID_MASK.should.instance_of?(Integer) end end describe "Encoding::Converter::INVALID_REPLACE" do it "exists" do - Encoding::Converter.should have_constant(:INVALID_REPLACE) + Encoding::Converter.should.const_defined?(:INVALID_REPLACE, false) end it "has an Integer value" do - Encoding::Converter::INVALID_REPLACE.should be_an_instance_of(Integer) + Encoding::Converter::INVALID_REPLACE.should.instance_of?(Integer) end end describe "Encoding::Converter::UNDEF_MASK" do it "exists" do - Encoding::Converter.should have_constant(:UNDEF_MASK) + Encoding::Converter.should.const_defined?(:UNDEF_MASK, false) end it "has an Integer value" do - Encoding::Converter::UNDEF_MASK.should be_an_instance_of(Integer) + Encoding::Converter::UNDEF_MASK.should.instance_of?(Integer) end end describe "Encoding::Converter::UNDEF_REPLACE" do it "exists" do - Encoding::Converter.should have_constant(:UNDEF_REPLACE) + Encoding::Converter.should.const_defined?(:UNDEF_REPLACE, false) end it "has an Integer value" do - Encoding::Converter::UNDEF_REPLACE.should be_an_instance_of(Integer) + Encoding::Converter::UNDEF_REPLACE.should.instance_of?(Integer) end end describe "Encoding::Converter::UNDEF_HEX_CHARREF" do it "exists" do - Encoding::Converter.should have_constant(:UNDEF_HEX_CHARREF) + Encoding::Converter.should.const_defined?(:UNDEF_HEX_CHARREF, false) end it "has an Integer value" do - Encoding::Converter::UNDEF_HEX_CHARREF.should be_an_instance_of(Integer) + Encoding::Converter::UNDEF_HEX_CHARREF.should.instance_of?(Integer) end end describe "Encoding::Converter::PARTIAL_INPUT" do it "exists" do - Encoding::Converter.should have_constant(:PARTIAL_INPUT) + Encoding::Converter.should.const_defined?(:PARTIAL_INPUT, false) end it "has an Integer value" do - Encoding::Converter::PARTIAL_INPUT.should be_an_instance_of(Integer) + Encoding::Converter::PARTIAL_INPUT.should.instance_of?(Integer) end end describe "Encoding::Converter::AFTER_OUTPUT" do it "exists" do - Encoding::Converter.should have_constant(:AFTER_OUTPUT) + Encoding::Converter.should.const_defined?(:AFTER_OUTPUT, false) end it "has an Integer value" do - Encoding::Converter::AFTER_OUTPUT.should be_an_instance_of(Integer) + Encoding::Converter::AFTER_OUTPUT.should.instance_of?(Integer) end end describe "Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR" do it "exists" do - Encoding::Converter.should have_constant(:UNIVERSAL_NEWLINE_DECORATOR) + Encoding::Converter.should.const_defined?(:UNIVERSAL_NEWLINE_DECORATOR, false) end it "has an Integer value" do - Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR.should be_an_instance_of(Integer) + Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR.should.instance_of?(Integer) end end describe "Encoding::Converter::CRLF_NEWLINE_DECORATOR" do it "exists" do - Encoding::Converter.should have_constant(:CRLF_NEWLINE_DECORATOR) + Encoding::Converter.should.const_defined?(:CRLF_NEWLINE_DECORATOR, false) end it "has an Integer value" do - Encoding::Converter::CRLF_NEWLINE_DECORATOR.should be_an_instance_of(Integer) + Encoding::Converter::CRLF_NEWLINE_DECORATOR.should.instance_of?(Integer) end end describe "Encoding::Converter::CR_NEWLINE_DECORATOR" do it "exists" do - Encoding::Converter.should have_constant(:CR_NEWLINE_DECORATOR) + Encoding::Converter.should.const_defined?(:CR_NEWLINE_DECORATOR, false) end it "has an Integer value" do - Encoding::Converter::CR_NEWLINE_DECORATOR.should be_an_instance_of(Integer) + Encoding::Converter::CR_NEWLINE_DECORATOR.should.instance_of?(Integer) end end describe "Encoding::Converter::XML_TEXT_DECORATOR" do it "exists" do - Encoding::Converter.should have_constant(:XML_TEXT_DECORATOR) + Encoding::Converter.should.const_defined?(:XML_TEXT_DECORATOR, false) end it "has an Integer value" do - Encoding::Converter::XML_TEXT_DECORATOR.should be_an_instance_of(Integer) + Encoding::Converter::XML_TEXT_DECORATOR.should.instance_of?(Integer) end end describe "Encoding::Converter::XML_ATTR_CONTENT_DECORATOR" do it "exists" do - Encoding::Converter.should have_constant(:XML_ATTR_CONTENT_DECORATOR) + Encoding::Converter.should.const_defined?(:XML_ATTR_CONTENT_DECORATOR, false) end it "has an Integer value" do - Encoding::Converter::XML_ATTR_CONTENT_DECORATOR.should be_an_instance_of(Integer) + Encoding::Converter::XML_ATTR_CONTENT_DECORATOR.should.instance_of?(Integer) end end describe "Encoding::Converter::XML_ATTR_QUOTE_DECORATOR" do it "exists" do - Encoding::Converter.should have_constant(:XML_ATTR_QUOTE_DECORATOR) + Encoding::Converter.should.const_defined?(:XML_ATTR_QUOTE_DECORATOR, false) end it "has an Integer value" do - Encoding::Converter::XML_ATTR_QUOTE_DECORATOR.should be_an_instance_of(Integer) + Encoding::Converter::XML_ATTR_QUOTE_DECORATOR.should.instance_of?(Integer) end end diff --git a/spec/ruby/core/encoding/converter/convert_spec.rb b/spec/ruby/core/encoding/converter/convert_spec.rb index 8533af45650c7a..c95e88a4915cfb 100644 --- a/spec/ruby/core/encoding/converter/convert_spec.rb +++ b/spec/ruby/core/encoding/converter/convert_spec.rb @@ -5,7 +5,7 @@ describe "Encoding::Converter#convert" do it "returns a String" do ec = Encoding::Converter.new('ascii', 'utf-8') - ec.convert('glark').should be_an_instance_of(String) + ec.convert('glark').should.instance_of?(String) end it "sets the encoding of the result to the target encoding" do @@ -34,13 +34,12 @@ it "raises UndefinedConversionError if the String contains characters invalid for the target encoding" do ec = Encoding::Converter.new('UTF-8', Encoding.find('macCyrillic')) - -> { ec.convert("\u{6543}".dup.force_encoding('UTF-8')) }.should \ - raise_error(Encoding::UndefinedConversionError) + -> { ec.convert("\u{6543}".dup.force_encoding('UTF-8')) }.should.raise(Encoding::UndefinedConversionError) end it "raises an ArgumentError if called on a finished stream" do ec = Encoding::Converter.new('UTF-8', Encoding.find('macCyrillic')) ec.finish - -> { ec.convert("\u{65}") }.should raise_error(ArgumentError) + -> { ec.convert("\u{65}") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/encoding/converter/finish_spec.rb b/spec/ruby/core/encoding/converter/finish_spec.rb index 22e66df38cae2f..e13b7415f89154 100644 --- a/spec/ruby/core/encoding/converter/finish_spec.rb +++ b/spec/ruby/core/encoding/converter/finish_spec.rb @@ -7,7 +7,7 @@ it "returns a String" do @ec.convert('foo') - @ec.finish.should be_an_instance_of(String) + @ec.finish.should.instance_of?(String) end it "returns an empty String if there is nothing more to convert" do diff --git a/spec/ruby/core/encoding/converter/last_error_spec.rb b/spec/ruby/core/encoding/converter/last_error_spec.rb index ff2a2b4cbe2505..3984a628f55e8f 100644 --- a/spec/ruby/core/encoding/converter/last_error_spec.rb +++ b/spec/ruby/core/encoding/converter/last_error_spec.rb @@ -4,51 +4,51 @@ describe "Encoding::Converter#last_error" do it "returns nil when the no conversion has been attempted" do ec = Encoding::Converter.new('ascii','utf-8') - ec.last_error.should be_nil + ec.last_error.should == nil end it "returns nil when the last conversion did not produce an error" do ec = Encoding::Converter.new('ascii','utf-8') ec.convert('a'.dup.force_encoding('ascii')) - ec.last_error.should be_nil + ec.last_error.should == nil end it "returns nil when #primitive_convert last returned :destination_buffer_full" do ec = Encoding::Converter.new("utf-8", "iso-2022-jp") ec.primitive_convert(+"\u{9999}", +"", 0, 0, partial_input: false) \ .should == :destination_buffer_full - ec.last_error.should be_nil + ec.last_error.should == nil end it "returns nil when #primitive_convert last returned :finished" do ec = Encoding::Converter.new("utf-8", "iso-8859-1") ec.primitive_convert("glark".dup.force_encoding('utf-8'), +"").should == :finished - ec.last_error.should be_nil + ec.last_error.should == nil end it "returns nil if the last conversion succeeded but the penultimate failed" do ec = Encoding::Converter.new("utf-8", "iso-8859-1") ec.primitive_convert(+"\xf1abcd", +"").should == :invalid_byte_sequence ec.primitive_convert("glark".dup.force_encoding('utf-8'), +"").should == :finished - ec.last_error.should be_nil + ec.last_error.should == nil end it "returns an Encoding::InvalidByteSequenceError when #primitive_convert last returned :invalid_byte_sequence" do ec = Encoding::Converter.new("utf-8", "iso-8859-1") ec.primitive_convert(+"\xf1abcd", +"").should == :invalid_byte_sequence - ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError) + ec.last_error.should.instance_of?(Encoding::InvalidByteSequenceError) end it "returns an Encoding::UndefinedConversionError when #primitive_convert last returned :undefined_conversion" do ec = Encoding::Converter.new("utf-8", "iso-8859-1") ec.primitive_convert(+"\u{9876}", +"").should == :undefined_conversion - ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError) + ec.last_error.should.instance_of?(Encoding::UndefinedConversionError) end it "returns an Encoding::InvalidByteSequenceError when #primitive_convert last returned :incomplete_input" do ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.primitive_convert(+"\xa4", +"", nil, 10).should == :incomplete_input - ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError) + ec.last_error.should.instance_of?(Encoding::InvalidByteSequenceError) end it "returns an Encoding::InvalidByteSequenceError when the last call to #convert produced one" do @@ -56,10 +56,10 @@ exception = nil -> { ec.convert("\xf1abcd") - }.should raise_error(Encoding::InvalidByteSequenceError) { |e| + }.should.raise(Encoding::InvalidByteSequenceError) { |e| exception = e } - ec.last_error.should be_an_instance_of(Encoding::InvalidByteSequenceError) + ec.last_error.should.instance_of?(Encoding::InvalidByteSequenceError) ec.last_error.message.should == exception.message end @@ -68,12 +68,12 @@ exception = nil -> { ec.convert("\u{9899}") - }.should raise_error(Encoding::UndefinedConversionError) { |e| + }.should.raise(Encoding::UndefinedConversionError) { |e| exception = e } - ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError) + ec.last_error.should.instance_of?(Encoding::UndefinedConversionError) ec.last_error.message.should == exception.message - ec.last_error.message.should include "from UTF-8 to ISO-8859-1" + ec.last_error.message.should.include? "from UTF-8 to ISO-8859-1" end it "returns the last error of #convert with a message showing the transcoding path" do @@ -81,11 +81,11 @@ exception = nil -> { ec.convert("\xE9") # é in ISO-8859-1 - }.should raise_error(Encoding::UndefinedConversionError) { |e| + }.should.raise(Encoding::UndefinedConversionError) { |e| exception = e } - ec.last_error.should be_an_instance_of(Encoding::UndefinedConversionError) + ec.last_error.should.instance_of?(Encoding::UndefinedConversionError) ec.last_error.message.should == exception.message - ec.last_error.message.should include "from ISO-8859-1 to UTF-8 to Big5" + ec.last_error.message.should.include? "from ISO-8859-1 to UTF-8 to Big5" end end diff --git a/spec/ruby/core/encoding/converter/new_spec.rb b/spec/ruby/core/encoding/converter/new_spec.rb index a7bef538092339..bbdfb48bce4e4f 100644 --- a/spec/ruby/core/encoding/converter/new_spec.rb +++ b/spec/ruby/core/encoding/converter/new_spec.rb @@ -25,7 +25,7 @@ it "raises an Encoding::ConverterNotFoundError if both encodings are the same" do -> do Encoding::Converter.new "utf-8", "utf-8" - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) end it "calls #to_str to convert the source encoding argument to an encoding name" do @@ -67,25 +67,25 @@ -> do Encoding::Converter.new("us-ascii", "utf-8", replace: obj) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed true for the replacement object" do -> do Encoding::Converter.new("us-ascii", "utf-8", replace: true) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed false for the replacement object" do -> do Encoding::Converter.new("us-ascii", "utf-8", replace: false) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed an Integer for the replacement object" do -> do Encoding::Converter.new("us-ascii", "utf-8", replace: 1) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "accepts an empty String for the replacement object" do diff --git a/spec/ruby/core/encoding/converter/primitive_convert_spec.rb b/spec/ruby/core/encoding/converter/primitive_convert_spec.rb index e4aeed103e08de..ab9ce6a9928bf0 100644 --- a/spec/ruby/core/encoding/converter/primitive_convert_spec.rb +++ b/spec/ruby/core/encoding/converter/primitive_convert_spec.rb @@ -8,23 +8,23 @@ end it "accepts a nil source buffer" do - -> { @ec.primitive_convert(nil,"") }.should_not raise_error + -> { @ec.primitive_convert(nil,"") }.should_not.raise end it "accepts a String as the source buffer" do - -> { @ec.primitive_convert("","") }.should_not raise_error + -> { @ec.primitive_convert("","") }.should_not.raise end it "raises FrozenError when the destination buffer is a frozen String" do - -> { @ec.primitive_convert("", "".freeze) }.should raise_error(FrozenError) + -> { @ec.primitive_convert("", "".freeze) }.should.raise(FrozenError) end it "accepts nil for the destination byte offset" do - -> { @ec.primitive_convert("","", nil) }.should_not raise_error + -> { @ec.primitive_convert("","", nil) }.should_not.raise end it "accepts an integer for the destination byte offset" do - -> { @ec.primitive_convert("","a", 1) }.should_not raise_error + -> { @ec.primitive_convert("","a", 1) }.should_not.raise end it "calls #to_int to convert the destination byte offset" do @@ -35,10 +35,10 @@ end it "raises an ArgumentError if the destination byte offset is greater than the bytesize of the destination buffer" do - -> { @ec.primitive_convert("","am", 0) }.should_not raise_error - -> { @ec.primitive_convert("","am", 1) }.should_not raise_error - -> { @ec.primitive_convert("","am", 2) }.should_not raise_error - -> { @ec.primitive_convert("","am", 3) }.should raise_error(ArgumentError) + -> { @ec.primitive_convert("","am", 0) }.should_not.raise + -> { @ec.primitive_convert("","am", 1) }.should_not.raise + -> { @ec.primitive_convert("","am", 2) }.should_not.raise + -> { @ec.primitive_convert("","am", 3) }.should.raise(ArgumentError) end it "uses the destination byte offset to determine where to write the result in the destination buffer" do @@ -54,19 +54,19 @@ end it "accepts nil for the destination bytesize" do - -> { @ec.primitive_convert("","", nil, nil) }.should_not raise_error + -> { @ec.primitive_convert("","", nil, nil) }.should_not.raise end it "accepts an integer for the destination bytesize" do - -> { @ec.primitive_convert("","", nil, 0) }.should_not raise_error + -> { @ec.primitive_convert("","", nil, 0) }.should_not.raise end it "allows a destination bytesize value greater than the bytesize of the source buffer" do - -> { @ec.primitive_convert("am","", nil, 3) }.should_not raise_error + -> { @ec.primitive_convert("am","", nil, 3) }.should_not.raise end it "allows a destination bytesize value less than the bytesize of the source buffer" do - -> { @ec.primitive_convert("am","", nil, 1) }.should_not raise_error + -> { @ec.primitive_convert("am","", nil, 1) }.should_not.raise end it "calls #to_int to convert the destination byte size" do diff --git a/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb b/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb index 5ee8b1fecd1a41..580e2e37e10344 100644 --- a/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb +++ b/spec/ruby/core/encoding/converter/primitive_errinfo_spec.rb @@ -55,7 +55,7 @@ it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #convert last raised InvalidByteSequenceError" do ec = Encoding::Converter.new("utf-8", "iso-8859-1") - -> { ec.convert("\xf1abcd") }.should raise_error(Encoding::InvalidByteSequenceError) + -> { ec.convert("\xf1abcd") }.should.raise(Encoding::InvalidByteSequenceError) ec.primitive_errinfo.should == [:invalid_byte_sequence, "UTF-8", "ISO-8859-1", "\xF1", "a"] end @@ -63,7 +63,7 @@ it "returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #finish last raised InvalidByteSequenceError" do ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") ec.convert("\xa4") - -> { ec.finish }.should raise_error(Encoding::InvalidByteSequenceError) + -> { ec.finish }.should.raise(Encoding::InvalidByteSequenceError) ec.primitive_errinfo.should == [:incomplete_input, "EUC-JP", "UTF-8", "\xA4", ""] end end diff --git a/spec/ruby/core/encoding/converter/putback_spec.rb b/spec/ruby/core/encoding/converter/putback_spec.rb index 04bb5656553b64..a85cec51455968 100644 --- a/spec/ruby/core/encoding/converter/putback_spec.rb +++ b/spec/ruby/core/encoding/converter/putback_spec.rb @@ -8,7 +8,7 @@ end it "returns a String" do - @ec.putback.should be_an_instance_of(String) + @ec.putback.should.instance_of?(String) end it "returns a String in the source encoding" do diff --git a/spec/ruby/core/encoding/converter/replacement_spec.rb b/spec/ruby/core/encoding/converter/replacement_spec.rb index ea514ca8ddf79d..c25ec365174db4 100644 --- a/spec/ruby/core/encoding/converter/replacement_spec.rb +++ b/spec/ruby/core/encoding/converter/replacement_spec.rb @@ -33,7 +33,7 @@ it "raises a TypeError if assigned a non-String argument" do ec = Encoding::Converter.new("utf-8", "us-ascii") - -> { ec.replacement = nil }.should raise_error(TypeError) + -> { ec.replacement = nil }.should.raise(TypeError) end it "sets #replacement" do @@ -47,16 +47,14 @@ ec = Encoding::Converter.new("sjis", "ascii") utf8_q = "\u{986}".dup.force_encoding('utf-8') ec.primitive_convert(utf8_q.dup, +"").should == :undefined_conversion - -> { ec.replacement = utf8_q }.should \ - raise_error(Encoding::UndefinedConversionError) + -> { ec.replacement = utf8_q }.should.raise(Encoding::UndefinedConversionError) end it "does not change the replacement character if the argument cannot be converted into the destination encoding" do ec = Encoding::Converter.new("sjis", "ascii") utf8_q = "\u{986}".dup.force_encoding('utf-8') ec.primitive_convert(utf8_q.dup, +"").should == :undefined_conversion - -> { ec.replacement = utf8_q }.should \ - raise_error(Encoding::UndefinedConversionError) + -> { ec.replacement = utf8_q }.should.raise(Encoding::UndefinedConversionError) ec.replacement.should == "?".dup.force_encoding('us-ascii') end diff --git a/spec/ruby/core/encoding/converter/search_convpath_spec.rb b/spec/ruby/core/encoding/converter/search_convpath_spec.rb index 59fe4520c05a2e..cac44765f8b2b1 100644 --- a/spec/ruby/core/encoding/converter/search_convpath_spec.rb +++ b/spec/ruby/core/encoding/converter/search_convpath_spec.rb @@ -25,6 +25,6 @@ it "raises an Encoding::ConverterNotFoundError if no conversion path exists" do -> do Encoding::Converter.search_convpath(Encoding::BINARY, Encoding::Emacs_Mule) - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) end end diff --git a/spec/ruby/core/encoding/default_external_spec.rb b/spec/ruby/core/encoding/default_external_spec.rb index 9aae4976e045f5..2a2bd7f6aef39c 100644 --- a/spec/ruby/core/encoding/default_external_spec.rb +++ b/spec/ruby/core/encoding/default_external_spec.rb @@ -10,7 +10,7 @@ end it "returns an Encoding object" do - Encoding.default_external.should be_an_instance_of(Encoding) + Encoding.default_external.should.instance_of?(Encoding) end it "returns the default external encoding" do @@ -60,10 +60,10 @@ end it "raises a TypeError unless the argument is an Encoding or convertible to a String" do - -> { Encoding.default_external = [] }.should raise_error(TypeError) + -> { Encoding.default_external = [] }.should.raise(TypeError) end it "raises an ArgumentError if the argument is nil" do - -> { Encoding.default_external = nil }.should raise_error(ArgumentError) + -> { Encoding.default_external = nil }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/encoding/default_internal_spec.rb b/spec/ruby/core/encoding/default_internal_spec.rb index 855f4e9f32477e..38aef9dce94b92 100644 --- a/spec/ruby/core/encoding/default_internal_spec.rb +++ b/spec/ruby/core/encoding/default_internal_spec.rb @@ -10,17 +10,17 @@ end it "is nil by default" do - Encoding.default_internal.should be_nil + Encoding.default_internal.should == nil end it "returns an Encoding object if a default internal encoding is set" do Encoding.default_internal = Encoding::ASCII - Encoding.default_internal.should be_an_instance_of(Encoding) + Encoding.default_internal.should.instance_of?(Encoding) end it "returns nil if no default internal encoding is set" do Encoding.default_internal = nil - Encoding.default_internal.should be_nil + Encoding.default_internal.should == nil end it "returns the default internal encoding" do @@ -60,15 +60,15 @@ obj = mock('string') obj.should_receive(:to_str).at_least(1).times.and_return(1) - -> { Encoding.default_internal = obj }.should raise_error(TypeError) + -> { Encoding.default_internal = obj }.should.raise(TypeError) end it "raises a TypeError when passed an object not providing #to_str" do - -> { Encoding.default_internal = mock("encoding") }.should raise_error(TypeError) + -> { Encoding.default_internal = mock("encoding") }.should.raise(TypeError) end it "accepts an argument of nil to unset the default internal encoding" do Encoding.default_internal = nil - Encoding.default_internal.should be_nil + Encoding.default_internal.should == nil end end diff --git a/spec/ruby/core/encoding/dummy_spec.rb b/spec/ruby/core/encoding/dummy_spec.rb index 77caebca9a2871..05530a818651c6 100644 --- a/spec/ruby/core/encoding/dummy_spec.rb +++ b/spec/ruby/core/encoding/dummy_spec.rb @@ -2,14 +2,14 @@ describe "Encoding#dummy?" do it "returns false for proper encodings" do - Encoding::UTF_8.dummy?.should be_false - Encoding::ASCII.dummy?.should be_false + Encoding::UTF_8.dummy?.should == false + Encoding::ASCII.dummy?.should == false end it "returns true for dummy encodings" do - Encoding::ISO_2022_JP.dummy?.should be_true - Encoding::CP50221.dummy?.should be_true - Encoding::UTF_7.dummy?.should be_true + Encoding::ISO_2022_JP.dummy?.should == true + Encoding::CP50221.dummy?.should == true + Encoding::UTF_7.dummy?.should == true end it "returns true for UTF_16 and UTF_32" do diff --git a/spec/ruby/core/encoding/find_spec.rb b/spec/ruby/core/encoding/find_spec.rb index 9c34fe0e77ffee..c5356560ebd012 100644 --- a/spec/ruby/core/encoding/find_spec.rb +++ b/spec/ruby/core/encoding/find_spec.rb @@ -7,18 +7,18 @@ it "returns the corresponding Encoding object if given a valid encoding name" do @encodings.each do |enc| - Encoding.find(enc).should be_an_instance_of(Encoding) + Encoding.find(enc).should.instance_of?(Encoding) end end it "returns the corresponding Encoding object if given a valid alias name" do Encoding.aliases.keys.each do |enc_alias| - Encoding.find(enc_alias).should be_an_instance_of(Encoding) + Encoding.find(enc_alias).should.instance_of?(Encoding) end end it "raises a TypeError if passed a Symbol" do - -> { Encoding.find(:"utf-8") }.should raise_error(TypeError) + -> { Encoding.find(:"utf-8") }.should.raise(TypeError) end it "returns the passed Encoding object" do @@ -50,7 +50,7 @@ def to_str; @encoding_name; end end it "raises an ArgumentError if the given encoding does not exist" do - -> { Encoding.find('dh2dh278d') }.should raise_error(ArgumentError, 'unknown encoding name - dh2dh278d') + -> { Encoding.find('dh2dh278d') }.should.raise(ArgumentError, 'unknown encoding name - dh2dh278d') end # Not sure how to do a better test, since locale depends on weird platform-specific stuff diff --git a/spec/ruby/core/encoding/inspect_spec.rb b/spec/ruby/core/encoding/inspect_spec.rb index df96141db90498..ab7f8cf9fcea3c 100644 --- a/spec/ruby/core/encoding/inspect_spec.rb +++ b/spec/ruby/core/encoding/inspect_spec.rb @@ -2,7 +2,7 @@ describe "Encoding#inspect" do it "returns a String" do - Encoding::UTF_8.inspect.should be_an_instance_of(String) + Encoding::UTF_8.inspect.should.instance_of?(String) end ruby_version_is ""..."3.4" do diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb index 2b15fc1a0f9459..7d3cc77c0bdf2d 100644 --- a/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb +++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb @@ -8,8 +8,8 @@ end it "returns a String" do - @exception.destination_encoding_name.should be_an_instance_of(String) - @exception2.destination_encoding_name.should be_an_instance_of(String) + @exception.destination_encoding_name.should.instance_of?(String) + @exception2.destination_encoding_name.should.instance_of?(String) end it "is equal to the destination encoding name of the object that raised it" do diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb index c2ed6de1d854d8..264c409b1c237d 100644 --- a/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb +++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb @@ -8,8 +8,8 @@ end it "returns an Encoding object" do - @exception.destination_encoding.should be_an_instance_of(Encoding) - @exception2.destination_encoding.should be_an_instance_of(Encoding) + @exception.destination_encoding.should.instance_of?(Encoding) + @exception2.destination_encoding.should.instance_of?(Encoding) end it "is equal to the destination encoding of the object that raised it" do diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb index 8b7e87960f8c59..40a9a35caf0b39 100644 --- a/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb +++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb @@ -9,8 +9,8 @@ end it "returns a String" do - @exception.error_bytes.should be_an_instance_of(String) - @exception2.error_bytes.should be_an_instance_of(String) + @exception.error_bytes.should.instance_of?(String) + @exception2.error_bytes.should.instance_of?(String) end it "returns the bytes that caused the exception" do diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb index 83606f77b4d70b..143db7b6da5144 100644 --- a/spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb +++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb @@ -3,7 +3,7 @@ describe "Encoding::InvalidByteSequenceError#incomplete_input?" do it "returns nil by default" do - Encoding::InvalidByteSequenceError.new.incomplete_input?.should be_nil + Encoding::InvalidByteSequenceError.new.incomplete_input?.should == nil end it "returns true if #primitive_convert returned :incomplete_input for the same data" do @@ -12,7 +12,7 @@ begin ec.convert("\xA1") rescue Encoding::InvalidByteSequenceError => e - e.incomplete_input?.should be_true + e.incomplete_input?.should == true end end @@ -22,7 +22,7 @@ begin ec.convert("\xfffffffff") rescue Encoding::InvalidByteSequenceError => e - e.incomplete_input?.should be_false + e.incomplete_input?.should == false end end end diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb index e5ad0a61bd716f..e4fc81aac61bd4 100644 --- a/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb +++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb @@ -9,8 +9,8 @@ end it "returns a String" do - @exception.readagain_bytes.should be_an_instance_of(String) - @exception2.readagain_bytes.should be_an_instance_of(String) + @exception.readagain_bytes.should.instance_of?(String) + @exception2.readagain_bytes.should.instance_of?(String) end it "returns the bytes to be read again" do diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb index a9464114a8925e..b00e1ad4e8039f 100644 --- a/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb +++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb @@ -8,7 +8,7 @@ end it "returns a String" do - @exception.source_encoding_name.should be_an_instance_of(String) + @exception.source_encoding_name.should.instance_of?(String) end it "is equal to the source encoding name of the object that raised it" do diff --git a/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb b/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb index 7fdc0a122bf0ad..32ad25dbb50050 100644 --- a/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb +++ b/spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb @@ -8,8 +8,8 @@ end it "returns an Encoding object" do - @exception.source_encoding.should be_an_instance_of(Encoding) - @exception2.source_encoding.should be_an_instance_of(Encoding) + @exception.source_encoding.should.instance_of?(Encoding) + @exception2.source_encoding.should.instance_of?(Encoding) end it "is equal to the source encoding of the object that raised it" do diff --git a/spec/ruby/core/encoding/list_spec.rb b/spec/ruby/core/encoding/list_spec.rb index bd3d5b7bc0d0f9..9fe336c6085f82 100644 --- a/spec/ruby/core/encoding/list_spec.rb +++ b/spec/ruby/core/encoding/list_spec.rb @@ -2,12 +2,12 @@ describe "Encoding.list" do it "returns an Array" do - Encoding.list.should be_an_instance_of(Array) + Encoding.list.should.instance_of?(Array) end it "returns an Array of Encoding objects" do Encoding.list.each do |enc| - enc.should be_an_instance_of(Encoding) + enc.should.instance_of?(Encoding) end end @@ -17,18 +17,18 @@ end it "includes the default external encoding" do - Encoding.list.include?(Encoding.default_external).should be_true + Encoding.list.include?(Encoding.default_external).should == true end it "does not include any alias names" do Encoding.aliases.keys.each do |enc_alias| - Encoding.list.include?(enc_alias).should be_false + Encoding.list.include?(enc_alias).should == false end end it "includes all aliased encodings" do Encoding.aliases.values.each do |enc_alias| - Encoding.list.include?(Encoding.find(enc_alias)).should be_true + Encoding.list.include?(Encoding.find(enc_alias)).should == true end end diff --git a/spec/ruby/core/encoding/locale_charmap_spec.rb b/spec/ruby/core/encoding/locale_charmap_spec.rb index 345a7b7093705e..0d77bf227b4dbd 100644 --- a/spec/ruby/core/encoding/locale_charmap_spec.rb +++ b/spec/ruby/core/encoding/locale_charmap_spec.rb @@ -2,7 +2,7 @@ describe "Encoding.locale_charmap" do it "returns a String" do - Encoding.locale_charmap.should be_an_instance_of(String) + Encoding.locale_charmap.should.instance_of?(String) end describe "when setting LC_ALL=C" do diff --git a/spec/ruby/core/encoding/name_list_spec.rb b/spec/ruby/core/encoding/name_list_spec.rb index 836381c4d8601e..1ba8d383bca900 100644 --- a/spec/ruby/core/encoding/name_list_spec.rb +++ b/spec/ruby/core/encoding/name_list_spec.rb @@ -2,22 +2,22 @@ describe "Encoding.name_list" do it "returns an Array" do - Encoding.name_list.should be_an_instance_of(Array) + Encoding.name_list.should.instance_of?(Array) end it "returns encoding names as Strings" do - Encoding.name_list.each {|e| e.should be_an_instance_of(String) } + Encoding.name_list.each {|e| e.should.instance_of?(String) } end it "includes all aliases" do Encoding.aliases.keys.each do |enc_alias| - Encoding.name_list.include?(enc_alias).should be_true + Encoding.name_list.include?(enc_alias).should == true end end it "includes all non-dummy encodings" do Encoding.list.each do |enc| - Encoding.name_list.include?(enc.name).should be_true + Encoding.name_list.include?(enc.name).should == true end end end diff --git a/spec/ruby/core/encoding/names_spec.rb b/spec/ruby/core/encoding/names_spec.rb index 9ded043bbbb6e6..e6bcbf474a42d9 100644 --- a/spec/ruby/core/encoding/names_spec.rb +++ b/spec/ruby/core/encoding/names_spec.rb @@ -4,7 +4,7 @@ it "returns an Array" do Encoding.name_list.each do |name| e = Encoding.find(name) or next - e.names.should be_an_instance_of(Array) + e.names.should.instance_of?(Array) end end @@ -12,7 +12,7 @@ Encoding.name_list.each do |name| e = Encoding.find(name) or next e.names.each do |this_name| - this_name.should be_an_instance_of(String) + this_name.should.instance_of?(String) end end end @@ -29,7 +29,7 @@ e = Encoding.find(name) or next aliases = Encoding.aliases.select{|a,n| n == name}.keys names = e.names - aliases.each {|a| names.include?(a).should be_true} + aliases.each {|a| names.include?(a).should == true} end end end diff --git a/spec/ruby/core/encoding/shared/name.rb b/spec/ruby/core/encoding/shared/name.rb index cd37ea06dbc0fe..4d4b860a1f652f 100644 --- a/spec/ruby/core/encoding/shared/name.rb +++ b/spec/ruby/core/encoding/shared/name.rb @@ -3,7 +3,7 @@ describe :encoding_name, shared: true do it "returns a String" do Encoding.list.each do |e| - e.send(@method).should be_an_instance_of(String) + e.send(@method).should.instance_of?(String) end end diff --git a/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb index a51a9f46a00656..bc36695ca79aaa 100644 --- a/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb +++ b/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb @@ -7,7 +7,7 @@ end it "returns a String" do - @exception.destination_encoding_name.should be_an_instance_of(String) + @exception.destination_encoding_name.should.instance_of?(String) end it "is equal to the destination encoding name of the object that raised it" do diff --git a/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb index 905556407c9bf1..c0fcf8de58cb64 100644 --- a/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb +++ b/spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb @@ -7,7 +7,7 @@ end it "returns an Encoding object" do - @exception.destination_encoding.should be_an_instance_of(Encoding) + @exception.destination_encoding.should.instance_of?(Encoding) end it "is equal to the destination encoding of the object that raised it" do diff --git a/spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb index 9cb55e6d95ef89..333acf5ee664d0 100644 --- a/spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb +++ b/spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb @@ -8,8 +8,8 @@ end it "returns a String" do - @exception.error_char.should be_an_instance_of(String) - @exception2.error_char.should be_an_instance_of(String) + @exception.error_char.should.instance_of?(String) + @exception2.error_char.should.instance_of?(String) end it "returns the one-character String that caused the exception" do diff --git a/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb index d5e60e78dbd59c..4932a25ed710f0 100644 --- a/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb +++ b/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb @@ -8,7 +8,7 @@ end it "returns a String" do - @exception.source_encoding_name.should be_an_instance_of(String) + @exception.source_encoding_name.should.instance_of?(String) end it "is equal to the source encoding name of the object that raised it" do diff --git a/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb b/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb index de456a4b5ad7e4..cf12020ad2f636 100644 --- a/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb +++ b/spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb @@ -8,8 +8,8 @@ end it "returns an Encoding object" do - @exception.source_encoding.should be_an_instance_of(Encoding) - @exception2.source_encoding.should be_an_instance_of(Encoding) + @exception.source_encoding.should.instance_of?(Encoding) + @exception2.source_encoding.should.instance_of?(Encoding) end it "is equal to the source encoding of the object that raised it" do diff --git a/spec/ruby/core/enumerable/all_spec.rb b/spec/ruby/core/enumerable/all_spec.rb index 160cd52628f4fd..cbdd63f86a97fe 100644 --- a/spec/ruby/core/enumerable/all_spec.rb +++ b/spec/ruby/core/enumerable/all_spec.rb @@ -21,19 +21,19 @@ end it "raises an ArgumentError when more than 1 argument is provided" do - -> { @enum.all?(1, 2, 3) }.should raise_error(ArgumentError) - -> { [].all?(1, 2, 3) }.should raise_error(ArgumentError) - -> { {}.all?(1, 2, 3) }.should raise_error(ArgumentError) + -> { @enum.all?(1, 2, 3) }.should.raise(ArgumentError) + -> { [].all?(1, 2, 3) }.should.raise(ArgumentError) + -> { {}.all?(1, 2, 3) }.should.raise(ArgumentError) end it "does not hide exceptions out of #each" do -> { EnumerableSpecs::ThrowingEach.new.all? - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) -> { EnumerableSpecs::ThrowingEach.new.all? { false } - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end describe "with no block" do @@ -60,7 +60,7 @@ it "gathers whole arrays as elements when each yields multiple" do multi = EnumerableSpecs::YieldsMultiWithFalse.new - multi.all?.should be_true + multi.all?.should == true end end @@ -106,7 +106,7 @@ it "does not hide exceptions out of the block" do -> { @enum.all? { raise "from block" } - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "gathers initial args as elements when each yields multiple" do @@ -125,7 +125,7 @@ end describe 'when given a pattern argument' do - it "calls `===` on the pattern the return value " do + it "calls `===` on the pattern the return value" do pattern = EnumerableSpecs::Pattern.new { |x| x >= 0 } @enum1.all?(pattern).should == false pattern.yielded.should == [[0], [1], [2], [-1]] @@ -140,7 +140,7 @@ it "does not hide exceptions out of #each" do -> { EnumerableSpecs::ThrowingEach.new.all?(Integer) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "returns true if the pattern never returns false or nil" do @@ -168,7 +168,7 @@ pattern = EnumerableSpecs::Pattern.new { raise "from pattern" } -> { @enum.all?(pattern) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "calls the pattern with gathered array when yielded with multiple arguments" do diff --git a/spec/ruby/core/enumerable/any_spec.rb b/spec/ruby/core/enumerable/any_spec.rb index 243f8735d5e85c..4405d4740a534d 100644 --- a/spec/ruby/core/enumerable/any_spec.rb +++ b/spec/ruby/core/enumerable/any_spec.rb @@ -21,19 +21,19 @@ end it "raises an ArgumentError when more than 1 argument is provided" do - -> { @enum.any?(1, 2, 3) }.should raise_error(ArgumentError) - -> { [].any?(1, 2, 3) }.should raise_error(ArgumentError) - -> { {}.any?(1, 2, 3) }.should raise_error(ArgumentError) + -> { @enum.any?(1, 2, 3) }.should.raise(ArgumentError) + -> { [].any?(1, 2, 3) }.should.raise(ArgumentError) + -> { {}.any?(1, 2, 3) }.should.raise(ArgumentError) end it "does not hide exceptions out of #each" do -> { EnumerableSpecs::ThrowingEach.new.any? - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) -> { EnumerableSpecs::ThrowingEach.new.any? { false } - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end describe "with no block" do @@ -60,7 +60,7 @@ it "gathers whole arrays as elements when each yields multiple" do multi = EnumerableSpecs::YieldsMultiWithFalse.new - multi.any?.should be_true + multi.any?.should == true end end @@ -120,7 +120,7 @@ it "does not hide exceptions out of the block" do -> { @enum.any? { raise "from block" } - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "gathers initial args as elements when each yields multiple" do @@ -139,7 +139,7 @@ end describe 'when given a pattern argument' do - it "calls `===` on the pattern the return value " do + it "calls `===` on the pattern the return value" do pattern = EnumerableSpecs::Pattern.new { |x| x == 2 } @enum1.any?(pattern).should == true pattern.yielded.should == [[0], [1], [2]] @@ -154,7 +154,7 @@ it "does not hide exceptions out of #each" do -> { EnumerableSpecs::ThrowingEach.new.any?(Integer) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "returns true if the pattern ever returns a truthy value" do @@ -181,7 +181,7 @@ pattern = EnumerableSpecs::Pattern.new { raise "from pattern" } -> { @enum.any?(pattern) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "calls the pattern with gathered array when yielded with multiple arguments" do diff --git a/spec/ruby/core/enumerable/chain_spec.rb b/spec/ruby/core/enumerable/chain_spec.rb index 5e2105d2946e85..a0597e46a1ba2b 100644 --- a/spec/ruby/core/enumerable/chain_spec.rb +++ b/spec/ruby/core/enumerable/chain_spec.rb @@ -18,6 +18,6 @@ end it "returns an Enumerator::Chain if given a block" do - EnumerableSpecs::Numerous.new.chain.should be_an_instance_of(Enumerator::Chain) + EnumerableSpecs::Numerous.new.chain.should.instance_of?(Enumerator::Chain) end end diff --git a/spec/ruby/core/enumerable/chunk_spec.rb b/spec/ruby/core/enumerable/chunk_spec.rb index ed6304307fe9b6..7c9b31c991e48b 100644 --- a/spec/ruby/core/enumerable/chunk_spec.rb +++ b/spec/ruby/core/enumerable/chunk_spec.rb @@ -8,13 +8,13 @@ it "returns an Enumerator if called without a block" do chunk = EnumerableSpecs::Numerous.new(1, 2, 3, 1, 2).chunk - chunk.should be_an_instance_of(Enumerator) + chunk.should.instance_of?(Enumerator) result = chunk.with_index {|elt, i| elt - i }.to_a result.should == [[1, [1, 2, 3]], [-2, [1, 2]]] end it "returns an Enumerator if given a block" do - EnumerableSpecs::Numerous.new.chunk {}.should be_an_instance_of(Enumerator) + EnumerableSpecs::Numerous.new.chunk {}.should.instance_of?(Enumerator) end it "yields the current element and the current chunk to the block" do @@ -59,14 +59,14 @@ it "raises a RuntimeError if the block returns a Symbol starting with an underscore other than :_alone or :_separator" do e = EnumerableSpecs::Numerous.new(1, 2, 3, 2, 1) - -> { e.chunk { |x| :_arbitrary }.to_a }.should raise_error(RuntimeError) + -> { e.chunk { |x| :_arbitrary }.to_a }.should.raise(RuntimeError) end it "does not accept arguments" do e = EnumerableSpecs::Numerous.new(1, 2, 3) -> { e.chunk(1) {} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it 'returned Enumerator size returns nil' do diff --git a/spec/ruby/core/enumerable/chunk_while_spec.rb b/spec/ruby/core/enumerable/chunk_while_spec.rb index 26bcc983db9d45..286f7174428ba4 100644 --- a/spec/ruby/core/enumerable/chunk_while_spec.rb +++ b/spec/ruby/core/enumerable/chunk_while_spec.rb @@ -11,7 +11,7 @@ context "when given a block" do it "returns an enumerator" do - @result.should be_an_instance_of(Enumerator) + @result.should.instance_of?(Enumerator) end it "splits chunks between adjacent elements i and j where the block returns false" do @@ -30,7 +30,7 @@ context "when not given a block" do it "raises an ArgumentError" do - -> { @enum.chunk_while }.should raise_error(ArgumentError) + -> { @enum.chunk_while }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/enumerable/cycle_spec.rb b/spec/ruby/core/enumerable/cycle_spec.rb index 487086cba3e6f7..1fb3cc3d4195b5 100644 --- a/spec/ruby/core/enumerable/cycle_spec.rb +++ b/spec/ruby/core/enumerable/cycle_spec.rb @@ -17,7 +17,7 @@ it "returns nil if there are no elements" do out = EnumerableSpecs::Empty.new.cycle { break :nope } - out.should be_nil + out.should == nil end it "yields successive elements of the array repeatedly" do @@ -44,8 +44,8 @@ describe "passed a number n as an argument" do it "returns nil and does nothing for non positive n" do - EnumerableSpecs::ThrowingEach.new.cycle(0) {}.should be_nil - EnumerableSpecs::NoEach.new.cycle(-22) {}.should be_nil + EnumerableSpecs::ThrowingEach.new.cycle(0) {}.should == nil + EnumerableSpecs::NoEach.new.cycle(-22) {}.should == nil end it "calls each at most once" do @@ -71,12 +71,12 @@ it "raises a TypeError when the passed n cannot be coerced to Integer" do enum = EnumerableSpecs::Numerous.new - ->{ enum.cycle("cat"){} }.should raise_error(TypeError) + ->{ enum.cycle("cat"){} }.should.raise(TypeError) end it "raises an ArgumentError if more arguments are passed" do enum = EnumerableSpecs::Numerous.new - ->{ enum.cycle(1, 2) {} }.should raise_error(ArgumentError) + ->{ enum.cycle(1, 2) {} }.should.raise(ArgumentError) end it "gathers whole arrays as elements when each yields multiple" do diff --git a/spec/ruby/core/enumerable/drop_spec.rb b/spec/ruby/core/enumerable/drop_spec.rb index 423cc0088bb969..8d95f464b35637 100644 --- a/spec/ruby/core/enumerable/drop_spec.rb +++ b/spec/ruby/core/enumerable/drop_spec.rb @@ -7,13 +7,13 @@ end it "requires exactly one argument" do - ->{ @enum.drop{} }.should raise_error(ArgumentError) - ->{ @enum.drop(1, 2){} }.should raise_error(ArgumentError) + ->{ @enum.drop{} }.should.raise(ArgumentError) + ->{ @enum.drop(1, 2){} }.should.raise(ArgumentError) end describe "passed a number n as an argument" do it "raises ArgumentError if n < 0" do - ->{ @enum.drop(-1) }.should raise_error(ArgumentError) + ->{ @enum.drop(-1) }.should.raise(ArgumentError) end it "tries to convert n to an Integer using #to_int" do @@ -35,8 +35,8 @@ end it "raises a TypeError when the passed n cannot be coerced to Integer" do - ->{ @enum.drop("hat") }.should raise_error(TypeError) - ->{ @enum.drop(nil) }.should raise_error(TypeError) + ->{ @enum.drop("hat") }.should.raise(TypeError) + ->{ @enum.drop(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/enumerable/drop_while_spec.rb b/spec/ruby/core/enumerable/drop_while_spec.rb index 636c3d284a1639..4b4fdf2d4f7871 100644 --- a/spec/ruby/core/enumerable/drop_while_spec.rb +++ b/spec/ruby/core/enumerable/drop_while_spec.rb @@ -8,7 +8,7 @@ end it "returns an Enumerator if no block given" do - @enum.drop_while.should be_an_instance_of(Enumerator) + @enum.drop_while.should.instance_of?(Enumerator) end it "returns no/all elements for {true/false} block" do @@ -38,7 +38,7 @@ it "doesn't return self when it could" do a = [1,2,3] - a.drop_while{false}.should_not equal(a) + a.drop_while{false}.should_not.equal?(a) end it "gathers whole arrays as elements when each yields multiple" do diff --git a/spec/ruby/core/enumerable/each_cons_spec.rb b/spec/ruby/core/enumerable/each_cons_spec.rb index ed77741862432e..c5e299fd004157 100644 --- a/spec/ruby/core/enumerable/each_cons_spec.rb +++ b/spec/ruby/core/enumerable/each_cons_spec.rb @@ -15,14 +15,14 @@ end it "raises an ArgumentError if there is not a single parameter > 0" do - ->{ @enum.each_cons(0){} }.should raise_error(ArgumentError) - ->{ @enum.each_cons(-2){} }.should raise_error(ArgumentError) - ->{ @enum.each_cons{} }.should raise_error(ArgumentError) - ->{ @enum.each_cons(2,2){} }.should raise_error(ArgumentError) - ->{ @enum.each_cons(0) }.should raise_error(ArgumentError) - ->{ @enum.each_cons(-2) }.should raise_error(ArgumentError) - ->{ @enum.each_cons }.should raise_error(ArgumentError) - ->{ @enum.each_cons(2,2) }.should raise_error(ArgumentError) + ->{ @enum.each_cons(0){} }.should.raise(ArgumentError) + ->{ @enum.each_cons(-2){} }.should.raise(ArgumentError) + ->{ @enum.each_cons{} }.should.raise(ArgumentError) + ->{ @enum.each_cons(2,2){} }.should.raise(ArgumentError) + ->{ @enum.each_cons(0) }.should.raise(ArgumentError) + ->{ @enum.each_cons(-2) }.should.raise(ArgumentError) + ->{ @enum.each_cons }.should.raise(ArgumentError) + ->{ @enum.each_cons(2,2) }.should.raise(ArgumentError) end it "tries to convert n to an Integer using #to_int" do @@ -63,7 +63,7 @@ describe "when no block is given" do it "returns an enumerator" do e = @enum.each_cons(3) - e.should be_an_instance_of(Enumerator) + e.should.instance_of?(Enumerator) e.to_a.should == @in_threes end diff --git a/spec/ruby/core/enumerable/each_entry_spec.rb b/spec/ruby/core/enumerable/each_entry_spec.rb index edf00f3137440b..9dc89ec28e14f9 100644 --- a/spec/ruby/core/enumerable/each_entry_spec.rb +++ b/spec/ruby/core/enumerable/each_entry_spec.rb @@ -11,13 +11,13 @@ it "yields multiple arguments as an array" do acc = [] - @enum.each_entry {|g| acc << g}.should equal(@enum) + @enum.each_entry {|g| acc << g}.should.equal?(@enum) acc.should == @entries end it "returns an enumerator if no block" do e = @enum.each_entry - e.should be_an_instance_of(Enumerator) + e.should.instance_of?(Enumerator) e.to_a.should == @entries end @@ -27,8 +27,8 @@ end it "raises an ArgumentError when extra arguments" do - -> { @enum.each_entry("one").to_a }.should raise_error(ArgumentError) - -> { @enum.each_entry("one"){}.to_a }.should raise_error(ArgumentError) + -> { @enum.each_entry("one").to_a }.should.raise(ArgumentError) + -> { @enum.each_entry("one"){}.to_a }.should.raise(ArgumentError) end it "passes extra arguments to #each" do diff --git a/spec/ruby/core/enumerable/each_slice_spec.rb b/spec/ruby/core/enumerable/each_slice_spec.rb index 47b8c9ba334f1d..d05abad1e9f454 100644 --- a/spec/ruby/core/enumerable/each_slice_spec.rb +++ b/spec/ruby/core/enumerable/each_slice_spec.rb @@ -15,14 +15,14 @@ end it "raises an ArgumentError if there is not a single parameter > 0" do - ->{ @enum.each_slice(0){} }.should raise_error(ArgumentError) - ->{ @enum.each_slice(-2){} }.should raise_error(ArgumentError) - ->{ @enum.each_slice{} }.should raise_error(ArgumentError) - ->{ @enum.each_slice(2,2){} }.should raise_error(ArgumentError) - ->{ @enum.each_slice(0) }.should raise_error(ArgumentError) - ->{ @enum.each_slice(-2) }.should raise_error(ArgumentError) - ->{ @enum.each_slice }.should raise_error(ArgumentError) - ->{ @enum.each_slice(2,2) }.should raise_error(ArgumentError) + ->{ @enum.each_slice(0){} }.should.raise(ArgumentError) + ->{ @enum.each_slice(-2){} }.should.raise(ArgumentError) + ->{ @enum.each_slice{} }.should.raise(ArgumentError) + ->{ @enum.each_slice(2,2){} }.should.raise(ArgumentError) + ->{ @enum.each_slice(0) }.should.raise(ArgumentError) + ->{ @enum.each_slice(-2) }.should.raise(ArgumentError) + ->{ @enum.each_slice }.should.raise(ArgumentError) + ->{ @enum.each_slice(2,2) }.should.raise(ArgumentError) end it "tries to convert n to an Integer using #to_int" do @@ -53,7 +53,7 @@ it "returns an enumerator if no block" do e = @enum.each_slice(3) - e.should be_an_instance_of(Enumerator) + e.should.instance_of?(Enumerator) e.to_a.should == @sliced end @@ -69,7 +69,7 @@ describe "when no block is given" do it "returns an enumerator" do e = @enum.each_slice(3) - e.should be_an_instance_of(Enumerator) + e.should.instance_of?(Enumerator) e.to_a.should == @sliced end diff --git a/spec/ruby/core/enumerable/each_with_index_spec.rb b/spec/ruby/core/enumerable/each_with_index_spec.rb index 122e88eab7e190..fcb2f82f84f6bb 100644 --- a/spec/ruby/core/enumerable/each_with_index_spec.rb +++ b/spec/ruby/core/enumerable/each_with_index_spec.rb @@ -26,19 +26,19 @@ acc = [] res = @b.each_with_index {|a,i| acc << [a,i]} [[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]].should == acc - res.should eql(@b) + res.should.eql?(@b) end it "binds splat arguments properly" do acc = [] res = @b.each_with_index { |*b| c,d = b; acc << c; acc << d } [2, 0, 5, 1, 3, 2, 6, 3, 1, 4, 4, 5].should == acc - res.should eql(@b) + res.should.eql?(@b) end it "returns an enumerator if no block" do e = @b.each_with_index - e.should be_an_instance_of(Enumerator) + e.should.instance_of?(Enumerator) e.to_a.should == [[2, 0], [5, 1], [3, 2], [6, 3], [1, 4], [4, 5]] end diff --git a/spec/ruby/core/enumerable/each_with_object_spec.rb b/spec/ruby/core/enumerable/each_with_object_spec.rb index 35665e7019a5fb..1760d3b267d78e 100644 --- a/spec/ruby/core/enumerable/each_with_object_spec.rb +++ b/spec/ruby/core/enumerable/each_with_object_spec.rb @@ -12,10 +12,10 @@ it "passes each element and its argument to the block" do acc = [] @enum.each_with_object(@initial) do |elem, obj| - obj.should equal(@initial) + obj.should.equal?(@initial) obj = 42 acc << elem - end.should equal(@initial) + end.should.equal?(@initial) acc.should == @values end @@ -23,10 +23,10 @@ acc = [] e = @enum.each_with_object(@initial) e.each do |elem, obj| - obj.should equal(@initial) + obj.should.equal?(@initial) obj = 42 acc << elem - end.should equal(@initial) + end.should.equal?(@initial) acc.should == @values end diff --git a/spec/ruby/core/enumerable/filter_map_spec.rb b/spec/ruby/core/enumerable/filter_map_spec.rb index aa4894230b530d..1ed131a9601a40 100644 --- a/spec/ruby/core/enumerable/filter_map_spec.rb +++ b/spec/ruby/core/enumerable/filter_map_spec.rb @@ -19,6 +19,6 @@ end it 'returns an enumerator when no block given' do - @numerous.filter_map.should be_an_instance_of(Enumerator) + @numerous.filter_map.should.instance_of?(Enumerator) end end diff --git a/spec/ruby/core/enumerable/find_index_spec.rb b/spec/ruby/core/enumerable/find_index_spec.rb index 542660fe04dd1b..2e714367baa6fb 100644 --- a/spec/ruby/core/enumerable/find_index_spec.rb +++ b/spec/ruby/core/enumerable/find_index_spec.rb @@ -47,7 +47,7 @@ end it "returns an Enumerator if no block given" do - @numerous.find_index.should be_an_instance_of(Enumerator) + @numerous.find_index.should.instance_of?(Enumerator) end it "uses #== for testing equality" do diff --git a/spec/ruby/core/enumerable/first_spec.rb b/spec/ruby/core/enumerable/first_spec.rb index ed1ba599b49947..592dff1ebc40e2 100644 --- a/spec/ruby/core/enumerable/first_spec.rb +++ b/spec/ruby/core/enumerable/first_spec.rb @@ -19,7 +19,7 @@ it "raises a RangeError when passed a Bignum" do enum = EnumerableSpecs::Empty.new - -> { enum.first(bignum_value) }.should raise_error(RangeError) + -> { enum.first(bignum_value) }.should.raise(RangeError) end describe "when passed an argument" do diff --git a/spec/ruby/core/enumerable/grep_spec.rb b/spec/ruby/core/enumerable/grep_spec.rb index 989358f01b5266..965e1837667178 100644 --- a/spec/ruby/core/enumerable/grep_spec.rb +++ b/spec/ruby/core/enumerable/grep_spec.rb @@ -81,7 +81,7 @@ def (@odd_matcher = BasicObject.new).===(obj) end it "raises an ArgumentError when not given a pattern" do - -> { @numerous.grep { |e| e } }.should raise_error(ArgumentError) + -> { @numerous.grep { |e| e } }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/enumerable/grep_v_spec.rb b/spec/ruby/core/enumerable/grep_v_spec.rb index ba192169684595..ee99a77ac1e556 100644 --- a/spec/ruby/core/enumerable/grep_v_spec.rb +++ b/spec/ruby/core/enumerable/grep_v_spec.rb @@ -55,7 +55,7 @@ def o.to_str end it "raises an ArgumentError when not given a pattern" do - -> { @numerous.grep_v }.should raise_error(ArgumentError) + -> { @numerous.grep_v }.should.raise(ArgumentError) end end @@ -70,7 +70,7 @@ def o.to_str end it "raises an ArgumentError when not given a pattern" do - -> { @numerous.grep_v { |e| e } }.should raise_error(ArgumentError) + -> { @numerous.grep_v { |e| e } }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/enumerable/group_by_spec.rb b/spec/ruby/core/enumerable/group_by_spec.rb index 4fd1603819f0a3..904e5d6c68989c 100644 --- a/spec/ruby/core/enumerable/group_by_spec.rb +++ b/spec/ruby/core/enumerable/group_by_spec.rb @@ -16,13 +16,13 @@ it "returns a hash without default_proc" do e = EnumerableSpecs::Numerous.new("foo", "bar", "baz") h = e.group_by { |word| word[0..0].to_sym } - h[:some].should be_nil - h.default_proc.should be_nil - h.default.should be_nil + h[:some].should == nil + h.default_proc.should == nil + h.default.should == nil end it "returns an Enumerator if called without a block" do - EnumerableSpecs::Numerous.new.group_by.should be_an_instance_of(Enumerator) + EnumerableSpecs::Numerous.new.group_by.should.instance_of?(Enumerator) end it "gathers whole arrays as elements when each yields multiple" do diff --git a/spec/ruby/core/enumerable/lazy_spec.rb b/spec/ruby/core/enumerable/lazy_spec.rb index 9a9ead81a00b33..935e5740672111 100644 --- a/spec/ruby/core/enumerable/lazy_spec.rb +++ b/spec/ruby/core/enumerable/lazy_spec.rb @@ -5,6 +5,6 @@ describe "Enumerable#lazy" do it "returns an instance of Enumerator::Lazy" do - EnumerableSpecs::Numerous.new.lazy.should be_an_instance_of(Enumerator::Lazy) + EnumerableSpecs::Numerous.new.lazy.should.instance_of?(Enumerator::Lazy) end end diff --git a/spec/ruby/core/enumerable/max_by_spec.rb b/spec/ruby/core/enumerable/max_by_spec.rb index ec1738ea3bc05c..f67b5d15ea4579 100644 --- a/spec/ruby/core/enumerable/max_by_spec.rb +++ b/spec/ruby/core/enumerable/max_by_spec.rb @@ -4,7 +4,7 @@ describe "Enumerable#max_by" do it "returns an enumerator if no block" do - EnumerableSpecs::Numerous.new(42).max_by.should be_an_instance_of(Enumerator) + EnumerableSpecs::Numerous.new(42).max_by.should.instance_of?(Enumerator) end it "returns nil if #each yields no objects" do @@ -18,7 +18,7 @@ it "returns the object that appears first in #each in case of a tie" do a, b, c = '1', '2', '2' - EnumerableSpecs::Numerous.new(a, b, c).max_by {|obj| obj.to_i }.should equal(b) + EnumerableSpecs::Numerous.new(a, b, c).max_by {|obj| obj.to_i }.should.equal?(b) end it "uses max.<=>(current) to determine order" do @@ -48,7 +48,7 @@ context "without a block" do it "returns an enumerator" do - @enum.max_by(2).should be_an_instance_of(Enumerator) + @enum.max_by(2).should.instance_of?(Enumerator) end end @@ -67,7 +67,7 @@ context "when n is negative" do it "raises an ArgumentError" do - -> { @enum.max_by(-1) { |i| i.to_s } }.should raise_error(ArgumentError) + -> { @enum.max_by(-1) { |i| i.to_s } }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/enumerable/max_spec.rb b/spec/ruby/core/enumerable/max_spec.rb index 0c11ca0969c06e..d92700258bc3b7 100644 --- a/spec/ruby/core/enumerable/max_spec.rb +++ b/spec/ruby/core/enumerable/max_spec.rb @@ -38,16 +38,16 @@ it "raises a NoMethodError for elements without #<=>" do -> do EnumerableSpecs::EachDefiner.new(BasicObject.new, BasicObject.new).max - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end it "raises an ArgumentError for incomparable elements" do -> do EnumerableSpecs::EachDefiner.new(11,"22").max - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) -> do EnumerableSpecs::EachDefiner.new(11,12,22,33).max{|a, b| nil} - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end context "when passed a block" do @@ -106,7 +106,7 @@ context "that is negative" do it "raises an ArgumentError" do - -> { @e_ints.max(-1) }.should raise_error(ArgumentError) + -> { @e_ints.max(-1) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/enumerable/min_by_spec.rb b/spec/ruby/core/enumerable/min_by_spec.rb index 3ff87e49d80cb5..4f949e213090aa 100644 --- a/spec/ruby/core/enumerable/min_by_spec.rb +++ b/spec/ruby/core/enumerable/min_by_spec.rb @@ -4,7 +4,7 @@ describe "Enumerable#min_by" do it "returns an enumerator if no block" do - EnumerableSpecs::Numerous.new(42).min_by.should be_an_instance_of(Enumerator) + EnumerableSpecs::Numerous.new(42).min_by.should.instance_of?(Enumerator) end it "returns nil if #each yields no objects" do @@ -18,7 +18,7 @@ it "returns the object that appears first in #each in case of a tie" do a, b, c = '2', '1', '1' - EnumerableSpecs::Numerous.new(a, b, c).min_by {|obj| obj.to_i }.should equal(b) + EnumerableSpecs::Numerous.new(a, b, c).min_by {|obj| obj.to_i }.should.equal?(b) end it "uses min.<=>(current) to determine order" do @@ -48,7 +48,7 @@ context "without a block" do it "returns an enumerator" do - @enum.min_by(2).should be_an_instance_of(Enumerator) + @enum.min_by(2).should.instance_of?(Enumerator) end end @@ -67,7 +67,7 @@ context "when n is negative" do it "raises an ArgumentError" do - -> { @enum.min_by(-1) { |i| i.to_s } }.should raise_error(ArgumentError) + -> { @enum.min_by(-1) { |i| i.to_s } }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/enumerable/min_spec.rb b/spec/ruby/core/enumerable/min_spec.rb index 4b6ae248fabaaa..f05d59c2c98a59 100644 --- a/spec/ruby/core/enumerable/min_spec.rb +++ b/spec/ruby/core/enumerable/min_spec.rb @@ -32,22 +32,22 @@ end it "returns nil for an empty Enumerable" do - EnumerableSpecs::EachDefiner.new.min.should be_nil + EnumerableSpecs::EachDefiner.new.min.should == nil end it "raises a NoMethodError for elements without #<=>" do -> do EnumerableSpecs::EachDefiner.new(BasicObject.new, BasicObject.new).min - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end it "raises an ArgumentError for incomparable elements" do -> do EnumerableSpecs::EachDefiner.new(11,"22").min - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) -> do EnumerableSpecs::EachDefiner.new(11,12,22,33).min{|a, b| nil} - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "returns the minimum when using a block rule" do @@ -110,7 +110,7 @@ context "that is negative" do it "raises an ArgumentError" do - -> { @e_ints.min(-1) }.should raise_error(ArgumentError) + -> { @e_ints.min(-1) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/enumerable/minmax_by_spec.rb b/spec/ruby/core/enumerable/minmax_by_spec.rb index a6a924927010f3..30c88cfcfb5ea9 100644 --- a/spec/ruby/core/enumerable/minmax_by_spec.rb +++ b/spec/ruby/core/enumerable/minmax_by_spec.rb @@ -4,7 +4,7 @@ describe "Enumerable#minmax_by" do it "returns an enumerator if no block" do - EnumerableSpecs::Numerous.new(42).minmax_by.should be_an_instance_of(Enumerator) + EnumerableSpecs::Numerous.new(42).minmax_by.should.instance_of?(Enumerator) end it "returns nil if #each yields no objects" do @@ -19,8 +19,8 @@ it "returns the object that appears first in #each in case of a tie" do a, b, c, d = '1', '1', '2', '2' mm = EnumerableSpecs::Numerous.new(a, b, c, d).minmax_by {|obj| obj.to_i } - mm[0].should equal(a) - mm[1].should equal(c) + mm[0].should.equal?(a) + mm[1].should.equal?(c) end it "uses min/max.<=>(current) to determine order" do diff --git a/spec/ruby/core/enumerable/none_spec.rb b/spec/ruby/core/enumerable/none_spec.rb index fb42f13386d1e8..d9ee0b441e4648 100644 --- a/spec/ruby/core/enumerable/none_spec.rb +++ b/spec/ruby/core/enumerable/none_spec.rb @@ -15,35 +15,35 @@ end it "raises an ArgumentError when more than 1 argument is provided" do - -> { @enum.none?(1, 2, 3) }.should raise_error(ArgumentError) - -> { [].none?(1, 2, 3) }.should raise_error(ArgumentError) - -> { {}.none?(1, 2, 3) }.should raise_error(ArgumentError) + -> { @enum.none?(1, 2, 3) }.should.raise(ArgumentError) + -> { [].none?(1, 2, 3) }.should.raise(ArgumentError) + -> { {}.none?(1, 2, 3) }.should.raise(ArgumentError) end it "does not hide exceptions out of #each" do -> { EnumerableSpecs::ThrowingEach.new.none? - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) -> { EnumerableSpecs::ThrowingEach.new.none? { false } - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end describe "with no block" do it "returns true if none of the elements in self are true" do e = EnumerableSpecs::Numerous.new(false, nil, false) - e.none?.should be_true + e.none?.should == true end it "returns false if at least one of the elements in self are true" do e = EnumerableSpecs::Numerous.new(false, nil, true, false) - e.none?.should be_false + e.none?.should == false end it "gathers whole arrays as elements when each yields multiple" do multi = EnumerableSpecs::YieldsMultiWithFalse.new - multi.none?.should be_false + multi.none?.should == false end end @@ -65,17 +65,17 @@ end it "returns true if the block never returns true" do - @e.none? {|e| false }.should be_true + @e.none? {|e| false }.should == true end it "returns false if the block ever returns true" do - @e.none? {|e| e == 3 ? true : false }.should be_false + @e.none? {|e| e == 3 ? true : false }.should == false end it "does not hide exceptions out of the block" do -> { @enum.none? { raise "from block" } - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "gathers initial args as elements when each yields multiple" do @@ -94,7 +94,7 @@ end describe 'when given a pattern argument' do - it "calls `===` on the pattern the return value " do + it "calls `===` on the pattern the return value" do pattern = EnumerableSpecs::Pattern.new { |x| x == 3 } @enum1.none?(pattern).should == true pattern.yielded.should == [[0], [1], [2], [-1]] @@ -109,7 +109,7 @@ it "does not hide exceptions out of #each" do -> { EnumerableSpecs::ThrowingEach.new.none?(Integer) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "returns true if the pattern never returns a truthy value" do @@ -134,7 +134,7 @@ pattern = EnumerableSpecs::Pattern.new { raise "from pattern" } -> { @enum.none?(pattern) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "calls the pattern with gathered array when yielded with multiple arguments" do diff --git a/spec/ruby/core/enumerable/one_spec.rb b/spec/ruby/core/enumerable/one_spec.rb index 4bf8623d2e6876..cf966d4a9bc62b 100644 --- a/spec/ruby/core/enumerable/one_spec.rb +++ b/spec/ruby/core/enumerable/one_spec.rb @@ -15,57 +15,57 @@ end it "raises an ArgumentError when more than 1 argument is provided" do - -> { @enum.one?(1, 2, 3) }.should raise_error(ArgumentError) - -> { [].one?(1, 2, 3) }.should raise_error(ArgumentError) - -> { {}.one?(1, 2, 3) }.should raise_error(ArgumentError) + -> { @enum.one?(1, 2, 3) }.should.raise(ArgumentError) + -> { [].one?(1, 2, 3) }.should.raise(ArgumentError) + -> { {}.one?(1, 2, 3) }.should.raise(ArgumentError) end it "does not hide exceptions out of #each" do -> { EnumerableSpecs::ThrowingEach.new.one? - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) -> { EnumerableSpecs::ThrowingEach.new.one? { false } - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end describe "with no block" do it "returns true if only one element evaluates to true" do - [false, nil, true].one?.should be_true + [false, nil, true].one?.should == true end it "returns false if two elements evaluate to true" do - [false, :value, nil, true].one?.should be_false + [false, :value, nil, true].one?.should == false end it "returns false if all elements evaluate to false" do - [false, nil, false].one?.should be_false + [false, nil, false].one?.should == false end it "gathers whole arrays as elements when each yields multiple" do multi = EnumerableSpecs::YieldsMultiWithSingleTrue.new - multi.one?.should be_false + multi.one?.should == false end end describe "with a block" do it "returns true if block returns true once" do - [:a, :b, :c].one? { |s| s == :a }.should be_true + [:a, :b, :c].one? { |s| s == :a }.should == true end it "returns false if the block returns true more than once" do - [:a, :b, :c].one? { |s| s == :a || s == :b }.should be_false + [:a, :b, :c].one? { |s| s == :a || s == :b }.should == false end it "returns false if the block only returns false" do - [:a, :b, :c].one? { |s| s == :d }.should be_false + [:a, :b, :c].one? { |s| s == :d }.should == false end it "does not hide exceptions out of the block" do -> { @enum.one? { raise "from block" } - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "gathers initial args as elements when each yields multiple" do @@ -84,7 +84,7 @@ end describe 'when given a pattern argument' do - it "calls `===` on the pattern the return value " do + it "calls `===` on the pattern the return value" do pattern = EnumerableSpecs::Pattern.new { |x| x == 1 } @enum1.one?(pattern).should == true pattern.yielded.should == [[0], [1], [2], [-1]] @@ -99,7 +99,7 @@ it "does not hide exceptions out of #each" do -> { EnumerableSpecs::ThrowingEach.new.one?(Integer) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "returns true if the pattern returns a truthy value only once" do @@ -135,7 +135,7 @@ pattern = EnumerableSpecs::Pattern.new { raise "from pattern" } -> { @enum.one?(pattern) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "calls the pattern with gathered array when yielded with multiple arguments" do diff --git a/spec/ruby/core/enumerable/partition_spec.rb b/spec/ruby/core/enumerable/partition_spec.rb index d3d220b4b4420f..8272ee189e1fe2 100644 --- a/spec/ruby/core/enumerable/partition_spec.rb +++ b/spec/ruby/core/enumerable/partition_spec.rb @@ -8,7 +8,7 @@ end it "returns an Enumerator if called without a block" do - EnumerableSpecs::Numerous.new.partition.should be_an_instance_of(Enumerator) + EnumerableSpecs::Numerous.new.partition.should.instance_of?(Enumerator) end it "gathers whole arrays as elements when each yields multiple" do diff --git a/spec/ruby/core/enumerable/reject_spec.rb b/spec/ruby/core/enumerable/reject_spec.rb index 0d86b49ea2212b..31e89f5b0e5ead 100644 --- a/spec/ruby/core/enumerable/reject_spec.rb +++ b/spec/ruby/core/enumerable/reject_spec.rb @@ -13,7 +13,7 @@ end it "returns an Enumerator if called without a block" do - EnumerableSpecs::Numerous.new.reject.should be_an_instance_of(Enumerator) + EnumerableSpecs::Numerous.new.reject.should.instance_of?(Enumerator) end it "gathers whole arrays as elements when each yields multiple" do diff --git a/spec/ruby/core/enumerable/reverse_each_spec.rb b/spec/ruby/core/enumerable/reverse_each_spec.rb index 2b1c2334888d82..47539567248391 100644 --- a/spec/ruby/core/enumerable/reverse_each_spec.rb +++ b/spec/ruby/core/enumerable/reverse_each_spec.rb @@ -11,7 +11,7 @@ it "returns an Enumerator if no block given" do enum = EnumerableSpecs::Numerous.new.reverse_each - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == [4, 1, 6, 3, 5, 2] end diff --git a/spec/ruby/core/enumerable/shared/collect.rb b/spec/ruby/core/enumerable/shared/collect.rb index 6df1a616ebe1a7..4696d324544e90 100644 --- a/spec/ruby/core/enumerable/shared/collect.rb +++ b/spec/ruby/core/enumerable/shared/collect.rb @@ -30,7 +30,7 @@ it "returns an enumerator when no block given" do enum = EnumerableSpecs::Numerous.new.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each { |i| -i }.should == [-2, -5, -3, -6, -1, -4] end @@ -86,7 +86,7 @@ def register(a, b, c) -> do { 1 => 'a', 2 => 'b' }.map(&m) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "calls the each method on sub-classes" do diff --git a/spec/ruby/core/enumerable/shared/collect_concat.rb b/spec/ruby/core/enumerable/shared/collect_concat.rb index ddd431baeb4693..1694e3fdce6f31 100644 --- a/spec/ruby/core/enumerable/shared/collect_concat.rb +++ b/spec/ruby/core/enumerable/shared/collect_concat.rb @@ -41,12 +41,12 @@ obj = mock("to_ary defined") obj.should_receive(:to_ary).and_return("array") - -> { [1, obj, 3].send(@method) { |i| i } }.should raise_error(TypeError) + -> { [1, obj, 3].send(@method) { |i| i } }.should.raise(TypeError) end it "returns an enumerator when no block given" do enum = EnumerableSpecs::Numerous.new(1, 2).send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each{ |i| [i] * i }.should == [1, 2, 2] end diff --git a/spec/ruby/core/enumerable/shared/find.rb b/spec/ruby/core/enumerable/shared/find.rb index 61d63ba3d58bc3..cdff6404151b74 100644 --- a/spec/ruby/core/enumerable/shared/find.rb +++ b/spec/ruby/core/enumerable/shared/find.rb @@ -59,7 +59,7 @@ end it "returns an enumerator when no block given" do - @numerous.send(@method).should be_an_instance_of(Enumerator) + @numerous.send(@method).should.instance_of?(Enumerator) end it "passes the ifnone proc to the enumerator" do diff --git a/spec/ruby/core/enumerable/shared/find_all.rb b/spec/ruby/core/enumerable/shared/find_all.rb index 1bbe71f3727083..27f01de6e01d53 100644 --- a/spec/ruby/core/enumerable/shared/find_all.rb +++ b/spec/ruby/core/enumerable/shared/find_all.rb @@ -14,7 +14,7 @@ end it "returns an enumerator when no block given" do - @numerous.send(@method).should be_an_instance_of(Enumerator) + @numerous.send(@method).should.instance_of?(Enumerator) end it "passes through the values yielded by #each_with_index" do diff --git a/spec/ruby/core/enumerable/shared/include.rb b/spec/ruby/core/enumerable/shared/include.rb index 569f350fd52762..ea250f032bb55a 100644 --- a/spec/ruby/core/enumerable/shared/include.rb +++ b/spec/ruby/core/enumerable/shared/include.rb @@ -28,7 +28,7 @@ class EnumerableSpecIncludeP11; def ==(obj); obj == '11'; end; end it "gathers whole arrays as elements when each yields multiple" do multi = EnumerableSpecs::YieldsMulti.new - multi.send(@method, [1,2]).should be_true + multi.send(@method, [1,2]).should == true end end diff --git a/spec/ruby/core/enumerable/shared/inject.rb b/spec/ruby/core/enumerable/shared/inject.rb index 8fb7e98c2b294c..7da4f0ca9938b2 100644 --- a/spec/ruby/core/enumerable/shared/inject.rb +++ b/spec/ruby/core/enumerable/shared/inject.rb @@ -31,8 +31,8 @@ def name.to_str; "-"; end end it "raises TypeError when the second argument is not Symbol or String and it cannot be converted to String if two arguments" do - -> { EnumerableSpecs::Numerous.new(1, 2, 3).send(@method, 10, Object.new) }.should raise_error(TypeError, /is not a symbol nor a string/) - -> { [1, 2, 3].send(@method, 10, Object.new) }.should raise_error(TypeError, /is not a symbol nor a string/) + -> { EnumerableSpecs::Numerous.new(1, 2, 3).send(@method, 10, Object.new) }.should.raise(TypeError, /is not a symbol nor a string/) + -> { [1, 2, 3].send(@method, 10, Object.new) }.should.raise(TypeError, /is not a symbol nor a string/) end it "ignores the block if two arguments" do @@ -73,8 +73,8 @@ def name.to_str; "-"; end end it "raises TypeError when passed not Symbol or String method name argument and it cannot be converted to String" do - -> { EnumerableSpecs::Numerous.new(10, 1, 2, 3).send(@method, Object.new) }.should raise_error(TypeError, /is not a symbol nor a string/) - -> { [10, 1, 2, 3].send(@method, Object.new) }.should raise_error(TypeError, /is not a symbol nor a string/) + -> { EnumerableSpecs::Numerous.new(10, 1, 2, 3).send(@method, Object.new) }.should.raise(TypeError, /is not a symbol nor a string/) + -> { [10, 1, 2, 3].send(@method, Object.new) }.should.raise(TypeError, /is not a symbol nor a string/) end it "without argument takes a block with an accumulator (with first element as initial value) and the current element. Value of block becomes new accumulator" do @@ -136,7 +136,7 @@ def name.to_str; "-"; end end it "raises an ArgumentError when no parameters or block is given" do - -> { [1,2].send(@method) }.should raise_error(ArgumentError) - -> { {one: 1, two: 2}.send(@method) }.should raise_error(ArgumentError) + -> { [1,2].send(@method) }.should.raise(ArgumentError) + -> { {one: 1, two: 2}.send(@method) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/enumerable/shared/take.rb b/spec/ruby/core/enumerable/shared/take.rb index ce2ace20fa5534..a6da06325ffe93 100644 --- a/spec/ruby/core/enumerable/shared/take.rb +++ b/spec/ruby/core/enumerable/shared/take.rb @@ -25,7 +25,7 @@ end it "raises an ArgumentError when count is negative" do - -> { @enum.send(@method, -1) }.should raise_error(ArgumentError) + -> { @enum.send(@method, -1) }.should.raise(ArgumentError) end it "returns the entire array when count > length" do @@ -40,11 +40,11 @@ end it "raises a TypeError if the passed argument is not numeric" do - -> { @enum.send(@method, nil) }.should raise_error(TypeError) - -> { @enum.send(@method, "a") }.should raise_error(TypeError) + -> { @enum.send(@method, nil) }.should.raise(TypeError) + -> { @enum.send(@method, "a") }.should.raise(TypeError) obj = mock("nonnumeric") - -> { @enum.send(@method, obj) }.should raise_error(TypeError) + -> { @enum.send(@method, obj) }.should.raise(TypeError) end it "gathers whole arrays as elements when each yields multiple" do diff --git a/spec/ruby/core/enumerable/slice_after_spec.rb b/spec/ruby/core/enumerable/slice_after_spec.rb index 0e46688db1493c..1ef37195e5eb49 100644 --- a/spec/ruby/core/enumerable/slice_after_spec.rb +++ b/spec/ruby/core/enumerable/slice_after_spec.rb @@ -11,7 +11,7 @@ arg = mock("filter") arg.should_receive(:===).and_return(false, true, false, false, false, true, false) e = @enum.slice_after(arg) - e.should be_an_instance_of(Enumerator) + e.should.instance_of?(Enumerator) e.to_a.should == [[7, 6], [5, 4, 3, 2], [1]] end @@ -34,21 +34,21 @@ describe "and no argument" do it "calls the block to determine when to yield" do e = @enum.slice_after{ |i| i == 6 || i == 2 } - e.should be_an_instance_of(Enumerator) + e.should.instance_of?(Enumerator) e.to_a.should == [[7, 6], [5, 4, 3, 2], [1]] end end describe "and an argument" do it "raises an ArgumentError" do - -> { @enum.slice_after(42) { |i| i == 6 } }.should raise_error(ArgumentError) + -> { @enum.slice_after(42) { |i| i == 6 } }.should.raise(ArgumentError) end end end it "raises an ArgumentError when given an incorrect number of arguments" do - -> { @enum.slice_after("one", "two") }.should raise_error(ArgumentError) - -> { @enum.slice_after }.should raise_error(ArgumentError) + -> { @enum.slice_after("one", "two") }.should.raise(ArgumentError) + -> { @enum.slice_after }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/enumerable/slice_before_spec.rb b/spec/ruby/core/enumerable/slice_before_spec.rb index f9b33f7b2805be..7eb4410a256db1 100644 --- a/spec/ruby/core/enumerable/slice_before_spec.rb +++ b/spec/ruby/core/enumerable/slice_before_spec.rb @@ -12,7 +12,7 @@ arg = mock "filter" arg.should_receive(:===).and_return(false, true, false, false, false, true, false) e = @enum.slice_before(arg) - e.should be_an_instance_of(Enumerator) + e.should.instance_of?(Enumerator) e.to_a.should == [[7], [6, 5, 4, 3], [2, 1]] end @@ -35,7 +35,7 @@ describe "and no argument" do it "calls the block to determine when to yield" do e = @enum.slice_before{|i| i == 6 || i == 2} - e.should be_an_instance_of(Enumerator) + e.should.instance_of?(Enumerator) e.to_a.should == [[7], [6, 5, 4, 3], [2, 1]] end end @@ -43,13 +43,13 @@ it "does not accept arguments" do -> { @enum.slice_before(1) {} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end it "raises an ArgumentError when given an incorrect number of arguments" do - -> { @enum.slice_before("one", "two") }.should raise_error(ArgumentError) - -> { @enum.slice_before }.should raise_error(ArgumentError) + -> { @enum.slice_before("one", "two") }.should.raise(ArgumentError) + -> { @enum.slice_before }.should.raise(ArgumentError) end describe "when an iterator method yields more than one value" do diff --git a/spec/ruby/core/enumerable/slice_when_spec.rb b/spec/ruby/core/enumerable/slice_when_spec.rb index 6b8ea0923e44ba..fe1ecd31e24d6f 100644 --- a/spec/ruby/core/enumerable/slice_when_spec.rb +++ b/spec/ruby/core/enumerable/slice_when_spec.rb @@ -11,7 +11,7 @@ context "when given a block" do it "returns an enumerator" do - @result.should be_an_instance_of(Enumerator) + @result.should.instance_of?(Enumerator) end it "splits chunks between adjacent elements i and j where the block returns true" do @@ -39,7 +39,7 @@ context "when not given a block" do it "raises an ArgumentError" do - -> { @enum.slice_when }.should raise_error(ArgumentError) + -> { @enum.slice_when }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/enumerable/sort_by_spec.rb b/spec/ruby/core/enumerable/sort_by_spec.rb index 8fdd923fb44c24..62cf38ce3efc5d 100644 --- a/spec/ruby/core/enumerable/sort_by_spec.rb +++ b/spec/ruby/core/enumerable/sort_by_spec.rb @@ -18,7 +18,7 @@ it "returns an Enumerator when a block is not supplied" do a = EnumerableSpecs::Numerous.new("a","b") - a.sort_by.should be_an_instance_of(Enumerator) + a.sort_by.should.instance_of?(Enumerator) a.to_a.should == ["a", "b"] end diff --git a/spec/ruby/core/enumerable/sort_spec.rb b/spec/ruby/core/enumerable/sort_spec.rb index 6fc64f325e4ce5..427b1cd8f12b01 100644 --- a/spec/ruby/core/enumerable/sort_spec.rb +++ b/spec/ruby/core/enumerable/sort_spec.rb @@ -16,7 +16,7 @@ it "raises a NoMethodError if elements do not define <=>" do -> do EnumerableSpecs::Numerous.new(BasicObject.new, BasicObject.new, BasicObject.new).sort - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end it "sorts enumerables that contain nils" do @@ -35,12 +35,12 @@ }.should == [6, 5, 4, 3, 2, 1] -> { EnumerableSpecs::Numerous.new.sort { |n, m| (n <=> m).to_s } - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an error if objects can't be compared" do a=EnumerableSpecs::Numerous.new(EnumerableSpecs::Uncomparable.new, EnumerableSpecs::Uncomparable.new) - -> {a.sort}.should raise_error(ArgumentError) + -> {a.sort}.should.raise(ArgumentError) end it "gathers whole arrays as elements when each yields multiple" do diff --git a/spec/ruby/core/enumerable/take_spec.rb b/spec/ruby/core/enumerable/take_spec.rb index 41a7438330f8cf..8cc746f88d9edd 100644 --- a/spec/ruby/core/enumerable/take_spec.rb +++ b/spec/ruby/core/enumerable/take_spec.rb @@ -4,7 +4,7 @@ describe "Enumerable#take" do it "requires an argument" do - ->{ EnumerableSpecs::Numerous.new.take}.should raise_error(ArgumentError) + ->{ EnumerableSpecs::Numerous.new.take}.should.raise(ArgumentError) end describe "when passed an argument" do diff --git a/spec/ruby/core/enumerable/take_while_spec.rb b/spec/ruby/core/enumerable/take_while_spec.rb index 26db39ac4bf539..918bfc897d3bca 100644 --- a/spec/ruby/core/enumerable/take_while_spec.rb +++ b/spec/ruby/core/enumerable/take_while_spec.rb @@ -8,7 +8,7 @@ end it "returns an Enumerator if no block given" do - @enum.take_while.should be_an_instance_of(Enumerator) + @enum.take_while.should.instance_of?(Enumerator) end it "returns no/all elements for {true/false} block" do @@ -38,7 +38,7 @@ it "doesn't return self when it could" do a = [1,2,3] - a.take_while{true}.should_not equal(a) + a.take_while{true}.should_not.equal?(a) end it "calls the block with initial args when yielded with multiple arguments" do diff --git a/spec/ruby/core/enumerable/tally_spec.rb b/spec/ruby/core/enumerable/tally_spec.rb index 95c64c12949505..deef741407140d 100644 --- a/spec/ruby/core/enumerable/tally_spec.rb +++ b/spec/ruby/core/enumerable/tally_spec.rb @@ -13,8 +13,8 @@ it "returns a hash without default" do hash = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz').tally - hash.default_proc.should be_nil - hash.default.should be_nil + hash.default_proc.should == nil + hash.default.should == nil end it "returns an empty hash for empty enumerables" do @@ -45,7 +45,7 @@ it "returns the given hash" do enum = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz') hash = { 'foo' => 1 } - enum.tally(hash).should equal(hash) + enum.tally(hash).should.equal?(hash) end it "calls #to_hash to convert argument to Hash implicitly if passed not a Hash" do @@ -58,14 +58,14 @@ def object.to_hash; { 'foo' => 1 }; end it "raises a FrozenError and does not update the given hash when the hash is frozen" do enum = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz') hash = { 'foo' => 1 }.freeze - -> { enum.tally(hash) }.should raise_error(FrozenError) + -> { enum.tally(hash) }.should.raise(FrozenError) hash.should == { 'foo' => 1 } end it "raises a FrozenError even if enumerable is empty" do enum = EnumerableSpecs::Numerous.new() hash = { 'foo' => 1 }.freeze - -> { enum.tally(hash) }.should raise_error(FrozenError) + -> { enum.tally(hash) }.should.raise(FrozenError) end it "does not call given block" do @@ -86,6 +86,6 @@ def object.to_hash; { 'foo' => 1 }; end it "needs the values counting each elements to be an integer" do enum = EnumerableSpecs::Numerous.new('foo') - -> { enum.tally({ 'foo' => 'bar' }) }.should raise_error(TypeError) + -> { enum.tally({ 'foo' => 'bar' }) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/enumerable/to_h_spec.rb b/spec/ruby/core/enumerable/to_h_spec.rb index 11a4933c10c453..38847eccfb91e0 100644 --- a/spec/ruby/core/enumerable/to_h_spec.rb +++ b/spec/ruby/core/enumerable/to_h_spec.rb @@ -36,12 +36,12 @@ def enum.each(*args) it "raises TypeError if an element is not an array" do enum = EnumerableSpecs::EachDefiner.new(:x) - -> { enum.to_h }.should raise_error(TypeError) + -> { enum.to_h }.should.raise(TypeError) end it "raises ArgumentError if an element is not a [key, value] pair" do enum = EnumerableSpecs::EachDefiner.new([:x]) - -> { enum.to_h }.should raise_error(ArgumentError) + -> { enum.to_h }.should.raise(ArgumentError) end context "with block" do @@ -64,17 +64,17 @@ def enum.each(*args) it "raises ArgumentError if block returns longer or shorter array" do -> do @enum.to_h { |k| [k, k.to_s, 1] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) -> do @enum.to_h { |k| [k] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) end it "raises TypeError if block returns something other than Array" do -> do @enum.to_h { |k| "not-array" } - end.should raise_error(TypeError, /wrong element type String/) + end.should.raise(TypeError, /wrong element type String/) end it "coerces returned pair to Array with #to_ary" do @@ -90,7 +90,7 @@ def enum.each(*args) -> do @enum.to_h { |k| x } - end.should raise_error(TypeError, /wrong element type MockObject/) + end.should.raise(TypeError, /wrong element type MockObject/) end end end diff --git a/spec/ruby/core/enumerable/to_set_spec.rb b/spec/ruby/core/enumerable/to_set_spec.rb index c02ead11fa4638..7b04c72bce6f7e 100644 --- a/spec/ruby/core/enumerable/to_set_spec.rb +++ b/spec/ruby/core/enumerable/to_set_spec.rb @@ -15,7 +15,7 @@ it "instantiates an object of provided as the first argument set class" do set = nil proc{set = [1, 2, 3].to_set(EnumerableSpecs::SetSubclass)}.should complain(/Enumerable#to_set/) - set.should be_kind_of(EnumerableSpecs::SetSubclass) + set.should.is_a?(EnumerableSpecs::SetSubclass) set.to_a.sort.should == [1, 2, 3] end end @@ -23,7 +23,7 @@ ruby_version_is ""..."4.0" do it "instantiates an object of provided as the first argument set class" do set = [1, 2, 3].to_set(EnumerableSpecs::SetSubclass) - set.should be_kind_of(EnumerableSpecs::SetSubclass) + set.should.is_a?(EnumerableSpecs::SetSubclass) set.to_a.sort.should == [1, 2, 3] end end diff --git a/spec/ruby/core/enumerable/zip_spec.rb b/spec/ruby/core/enumerable/zip_spec.rb index ab148f2a6e04ac..c5f9a3e4d4c8de 100644 --- a/spec/ruby/core/enumerable/zip_spec.rb +++ b/spec/ruby/core/enumerable/zip_spec.rb @@ -39,8 +39,8 @@ end it "raises TypeError when some argument isn't Array and doesn't respond to #to_ary and #to_enum" do - -> { EnumerableSpecs::Numerous.new(1,2,3).zip(Object.new) }.should raise_error(TypeError, "wrong argument type Object (must respond to :each)") - -> { EnumerableSpecs::Numerous.new(1,2,3).zip(1) }.should raise_error(TypeError, "wrong argument type Integer (must respond to :each)") - -> { EnumerableSpecs::Numerous.new(1,2,3).zip(true) }.should raise_error(TypeError, "wrong argument type TrueClass (must respond to :each)") + -> { EnumerableSpecs::Numerous.new(1,2,3).zip(Object.new) }.should.raise(TypeError, "wrong argument type Object (must respond to :each)") + -> { EnumerableSpecs::Numerous.new(1,2,3).zip(1) }.should.raise(TypeError, "wrong argument type Integer (must respond to :each)") + -> { EnumerableSpecs::Numerous.new(1,2,3).zip(true) }.should.raise(TypeError, "wrong argument type TrueClass (must respond to :each)") end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb index d4fff3e01f0e0c..0a83019d49b050 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/each_spec.rb @@ -12,6 +12,6 @@ end it "returns self" do - @seq.each { |item| }.should equal(@seq) + @seq.each { |item| }.should.equal?(@seq) end end diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb index bdb308074b5187..a18c554fb39dd7 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/hash_spec.rb @@ -2,7 +2,7 @@ describe "Enumerator::ArithmeticSequence#hash" do it "is based on begin, end, step and exclude_end?" do - 1.step(10).hash.should be_an_instance_of(Integer) + 1.step(10).hash.should.instance_of?(Integer) 1.step(10).hash.should == 1.step(10).hash 1.step(10, 5).hash.should == 1.step(10, 5).hash diff --git a/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb b/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb index 201598382615d0..1bd2f7f0f709bb 100644 --- a/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb +++ b/spec/ruby/core/enumerator/arithmetic_sequence/new_spec.rb @@ -4,7 +4,7 @@ it "is not defined" do -> { Enumerator::ArithmeticSequence.new - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end end @@ -12,6 +12,6 @@ it "is not defined" do -> { Enumerator::ArithmeticSequence.allocate - }.should raise_error(TypeError, 'allocator undefined for Enumerator::ArithmeticSequence') + }.should.raise(TypeError, 'allocator undefined for Enumerator::ArithmeticSequence') end end diff --git a/spec/ruby/core/enumerator/chain/initialize_spec.rb b/spec/ruby/core/enumerator/chain/initialize_spec.rb index daa30351d7847c..1df1dec5f82532 100644 --- a/spec/ruby/core/enumerator/chain/initialize_spec.rb +++ b/spec/ruby/core/enumerator/chain/initialize_spec.rb @@ -6,26 +6,26 @@ end it "is a private method" do - Enumerator::Chain.should have_private_instance_method(:initialize, false) + Enumerator::Chain.private_instance_methods(false).should.include?(:initialize) end it "returns self" do - @uninitialized.send(:initialize).should equal(@uninitialized) + @uninitialized.send(:initialize).should.equal?(@uninitialized) end it "accepts many arguments" do - @uninitialized.send(:initialize, 0..1, 2..3, 4..5).should equal(@uninitialized) + @uninitialized.send(:initialize, 0..1, 2..3, 4..5).should.equal?(@uninitialized) end it "accepts arguments that are not Enumerable nor responding to :each" do - @uninitialized.send(:initialize, Object.new).should equal(@uninitialized) + @uninitialized.send(:initialize, Object.new).should.equal?(@uninitialized) end describe "on frozen instance" do it "raises a FrozenError" do -> { @uninitialized.freeze.send(:initialize) - }.should raise_error(FrozenError) + }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/enumerator/chain/rewind_spec.rb b/spec/ruby/core/enumerator/chain/rewind_spec.rb index 5f51ce2cf170a7..4525b82f7b3a0a 100644 --- a/spec/ruby/core/enumerator/chain/rewind_spec.rb +++ b/spec/ruby/core/enumerator/chain/rewind_spec.rb @@ -10,7 +10,7 @@ end it "returns self" do - @enum.rewind.should equal @enum + @enum.rewind.should.equal? @enum end it "does nothing if receiver has not been iterated" do @@ -35,7 +35,7 @@ @obj.should_not_receive(:rewind) @second.should_receive(:rewind).and_raise(RuntimeError) @enum.each {} - -> { @enum.rewind }.should raise_error(RuntimeError) + -> { @enum.rewind }.should.raise(RuntimeError) end it "calls rewind only for objects that have actually been iterated on" do @@ -45,7 +45,7 @@ @obj.should_receive(:rewind) @second.should_not_receive(:rewind) - -> { @enum.each {} }.should raise_error(RuntimeError) + -> { @enum.each {} }.should.raise(RuntimeError) @enum.rewind end end diff --git a/spec/ruby/core/enumerator/each_spec.rb b/spec/ruby/core/enumerator/each_spec.rb index 8c9785cc85fe37..03be53fe055a8a 100644 --- a/spec/ruby/core/enumerator/each_spec.rb +++ b/spec/ruby/core/enumerator/each_spec.rb @@ -51,17 +51,17 @@ def object_each_with_arguments.each_with_arguments(arg, *args) enum = Object.new.to_enum -> do enum.each { |e| e } - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end it "returns self if not given arguments and not given a block" do - @enum_with_arguments.each.should equal(@enum_with_arguments) + @enum_with_arguments.each.should.equal?(@enum_with_arguments) - @enum_with_yielder.each.should equal(@enum_with_yielder) + @enum_with_yielder.each.should.equal?(@enum_with_yielder) end it "returns the same value from receiver.each if block is given" do - @enum_with_arguments.each {}.should equal(:method_returned) + @enum_with_arguments.each {}.should.equal?(:method_returned) end it "passes given arguments at initialized to receiver.each" do @@ -78,13 +78,13 @@ def object_each_with_arguments.each_with_arguments(arg, *args) end it "returns the same value from receiver.each if block and arguments are given" do - @enum_with_arguments.each(:each1, :each2) {}.should equal(:method_returned) + @enum_with_arguments.each(:each1, :each2) {}.should.equal?(:method_returned) end it "returns new Enumerator if given arguments but not given a block" do ret = @enum_with_arguments.each 1 - ret.should be_an_instance_of(Enumerator) - ret.should_not equal(@enum_with_arguments) + ret.should.instance_of?(Enumerator) + ret.should_not.equal?(@enum_with_arguments) end it "does not destructure yielded array values when chaining each.map" do diff --git a/spec/ruby/core/enumerator/each_with_index_spec.rb b/spec/ruby/core/enumerator/each_with_index_spec.rb index 4898e86fa9c643..0630b7045ec2c0 100644 --- a/spec/ruby/core/enumerator/each_with_index_spec.rb +++ b/spec/ruby/core/enumerator/each_with_index_spec.rb @@ -9,14 +9,14 @@ it "returns a new Enumerator when no block is given" do enum1 = [1,2,3].select enum2 = enum1.each_with_index - enum2.should be_an_instance_of(Enumerator) + enum2.should.instance_of?(Enumerator) enum1.should_not == enum2 end it "raises an ArgumentError if passed extra arguments" do -> do [1].to_enum.each_with_index(:glark) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "passes on the given block's return value" do diff --git a/spec/ruby/core/enumerator/feed_spec.rb b/spec/ruby/core/enumerator/feed_spec.rb index e387c6cd394003..781947a8c75aed 100644 --- a/spec/ruby/core/enumerator/feed_spec.rb +++ b/spec/ruby/core/enumerator/feed_spec.rb @@ -33,20 +33,20 @@ end it "returns nil" do - @enum.feed(:a).should be_nil + @enum.feed(:a).should == nil end it "raises a TypeError if called more than once without advancing the enumerator" do @enum.feed :a @enum.next - -> { @enum.feed :b }.should raise_error(TypeError) + -> { @enum.feed :b }.should.raise(TypeError) end it "sets the return value of Yielder#yield" do enum = Enumerator.new { |y| ScratchPad << y.yield } enum.next enum.feed :a - -> { enum.next }.should raise_error(StopIteration) + -> { enum.next }.should.raise(StopIteration) ScratchPad.recorded.should == [:a] end end diff --git a/spec/ruby/core/enumerator/generator/each_spec.rb b/spec/ruby/core/enumerator/generator/each_spec.rb index a43805dd16f310..41a494298b8817 100644 --- a/spec/ruby/core/enumerator/generator/each_spec.rb +++ b/spec/ruby/core/enumerator/generator/each_spec.rb @@ -10,7 +10,7 @@ end it "is an enumerable" do - @generator.should be_kind_of(Enumerable) + @generator.should.is_a?(Enumerable) end it "supports enumeration with a block" do @@ -21,11 +21,11 @@ end it "raises a LocalJumpError if no block given" do - -> { @generator.each }.should raise_error(LocalJumpError) + -> { @generator.each }.should.raise(LocalJumpError) end it "returns the block returned value" do - @generator.each {}.should equal(:block_returned) + @generator.each {}.should.equal?(:block_returned) end it "requires multiple arguments" do diff --git a/spec/ruby/core/enumerator/generator/initialize_spec.rb b/spec/ruby/core/enumerator/generator/initialize_spec.rb index acc1174253344c..0f77d591d90fc2 100644 --- a/spec/ruby/core/enumerator/generator/initialize_spec.rb +++ b/spec/ruby/core/enumerator/generator/initialize_spec.rb @@ -9,18 +9,18 @@ end it "is a private method" do - @class.should have_private_instance_method(:initialize, false) + @class.private_instance_methods(false).should.include?(:initialize) end it "returns self when given a block" do - @uninitialized.send(:initialize) {}.should equal(@uninitialized) + @uninitialized.send(:initialize) {}.should.equal?(@uninitialized) end describe "on frozen instance" do it "raises a FrozenError" do -> { @uninitialized.freeze.send(:initialize) {} - }.should raise_error(FrozenError) + }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/enumerator/initialize_spec.rb b/spec/ruby/core/enumerator/initialize_spec.rb index 5e0256ca4688f9..9929494b5a861b 100644 --- a/spec/ruby/core/enumerator/initialize_spec.rb +++ b/spec/ruby/core/enumerator/initialize_spec.rb @@ -8,11 +8,11 @@ end it "is a private method" do - Enumerator.should have_private_instance_method(:initialize, false) + Enumerator.private_instance_methods(false).should.include?(:initialize) end it "returns self when given a block" do - @uninitialized.send(:initialize) {}.should equal(@uninitialized) + @uninitialized.send(:initialize) {}.should.equal?(@uninitialized) end # Maybe spec should be broken up? @@ -21,22 +21,22 @@ r = yielder.yield 3 yielder << r << 2 << 1 end - @uninitialized.should be_an_instance_of(Enumerator) + @uninitialized.should.instance_of?(Enumerator) r = [] @uninitialized.each{|x| r << x; x * 2} r.should == [3, 6, 2, 1] end it "sets size to nil if size is not given" do - @uninitialized.send(:initialize) {}.size.should be_nil + @uninitialized.send(:initialize) {}.size.should == nil end it "sets size to nil if the given size is nil" do - @uninitialized.send(:initialize, nil) {}.size.should be_nil + @uninitialized.send(:initialize, nil) {}.size.should == nil end it "sets size to the given size if the given size is Float::INFINITY" do - @uninitialized.send(:initialize, Float::INFINITY) {}.size.should equal(Float::INFINITY) + @uninitialized.send(:initialize, Float::INFINITY) {}.size.should.equal?(Float::INFINITY) end it "sets size to the given size if the given size is an Integer" do @@ -51,7 +51,7 @@ it "raises a FrozenError" do -> { @uninitialized.freeze.send(:initialize) {} - }.should raise_error(FrozenError) + }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/enumerator/lazy/chunk_spec.rb b/spec/ruby/core/enumerator/lazy/chunk_spec.rb index 87d2b0c206b7b6..d0179d32b60dee 100644 --- a/spec/ruby/core/enumerator/lazy/chunk_spec.rb +++ b/spec/ruby/core/enumerator/lazy/chunk_spec.rb @@ -17,8 +17,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.chunk {} - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets #size to nil" do @@ -27,7 +27,7 @@ it "returns an Enumerator if called without a block" do chunk = @yieldsmixed.chunk - chunk.should be_an_instance_of(Enumerator::Lazy) + chunk.should.instance_of?(Enumerator::Lazy) res = chunk.each { |v| true }.force res.should == [[true, EnumeratorLazySpecs::YieldsMixed.gathered_yields]] diff --git a/spec/ruby/core/enumerator/lazy/chunk_while_spec.rb b/spec/ruby/core/enumerator/lazy/chunk_while_spec.rb index 772bd42de9117a..edba8e1363a32a 100644 --- a/spec/ruby/core/enumerator/lazy/chunk_while_spec.rb +++ b/spec/ruby/core/enumerator/lazy/chunk_while_spec.rb @@ -9,6 +9,6 @@ it "should return a lazy enumerator" do s = 0..Float::INFINITY - s.lazy.chunk_while { |a, b| false }.should be_kind_of(Enumerator::Lazy) + s.lazy.chunk_while { |a, b| false }.should.is_a?(Enumerator::Lazy) end end diff --git a/spec/ruby/core/enumerator/lazy/compact_spec.rb b/spec/ruby/core/enumerator/lazy/compact_spec.rb index 65c544f0629bbc..7305e1c9c4b7fa 100644 --- a/spec/ruby/core/enumerator/lazy/compact_spec.rb +++ b/spec/ruby/core/enumerator/lazy/compact_spec.rb @@ -4,7 +4,7 @@ describe "Enumerator::Lazy#compact" do it 'returns array without nil elements' do arr = [1, nil, 3, false, 5].to_enum.lazy.compact - arr.should be_an_instance_of(Enumerator::Lazy) + arr.should.instance_of?(Enumerator::Lazy) arr.force.should == [1, 3, false, 5] end diff --git a/spec/ruby/core/enumerator/lazy/drop_spec.rb b/spec/ruby/core/enumerator/lazy/drop_spec.rb index 822b8034fb8909..95ac7e9ecce610 100644 --- a/spec/ruby/core/enumerator/lazy/drop_spec.rb +++ b/spec/ruby/core/enumerator/lazy/drop_spec.rb @@ -16,8 +16,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.drop(1) - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets difference of given count with old size to new size" do diff --git a/spec/ruby/core/enumerator/lazy/drop_while_spec.rb b/spec/ruby/core/enumerator/lazy/drop_while_spec.rb index 4f6e366f880c2a..65f3007dec2b27 100644 --- a/spec/ruby/core/enumerator/lazy/drop_while_spec.rb +++ b/spec/ruby/core/enumerator/lazy/drop_while_spec.rb @@ -16,8 +16,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.drop_while {} - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets #size to nil" do @@ -40,7 +40,7 @@ end it "raises an ArgumentError when not given a block" do - -> { @yieldsmixed.drop_while }.should raise_error(ArgumentError) + -> { @yieldsmixed.drop_while }.should.raise(ArgumentError) end describe "on a nested Lazy" do diff --git a/spec/ruby/core/enumerator/lazy/grep_spec.rb b/spec/ruby/core/enumerator/lazy/grep_spec.rb index e67686c9a3f04f..383f80a918c0f8 100644 --- a/spec/ruby/core/enumerator/lazy/grep_spec.rb +++ b/spec/ruby/core/enumerator/lazy/grep_spec.rb @@ -20,12 +20,12 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.grep(Object) {} - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) ret = @yieldsmixed.grep(Object) - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets #size to nil" do diff --git a/spec/ruby/core/enumerator/lazy/grep_v_spec.rb b/spec/ruby/core/enumerator/lazy/grep_v_spec.rb index 67173021bb4e18..19c917f2543540 100644 --- a/spec/ruby/core/enumerator/lazy/grep_v_spec.rb +++ b/spec/ruby/core/enumerator/lazy/grep_v_spec.rb @@ -18,12 +18,12 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.grep_v(Object) {} - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) ret = @yieldsmixed.grep_v(Object) - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets #size to nil" do diff --git a/spec/ruby/core/enumerator/lazy/initialize_spec.rb b/spec/ruby/core/enumerator/lazy/initialize_spec.rb index e1e0b1d608363d..47765d32c38ece 100644 --- a/spec/ruby/core/enumerator/lazy/initialize_spec.rb +++ b/spec/ruby/core/enumerator/lazy/initialize_spec.rb @@ -16,11 +16,11 @@ def receiver.each end it "is a private method" do - Enumerator::Lazy.should have_private_instance_method(:initialize, false) + Enumerator::Lazy.private_instance_methods(false).should.include?(:initialize) end it "returns self" do - @uninitialized.send(:initialize, @receiver) {}.should equal(@uninitialized) + @uninitialized.send(:initialize, @receiver) {}.should.equal?(@uninitialized) end describe "when the returned lazy enumerator is evaluated by Enumerable#first" do @@ -32,15 +32,15 @@ def receiver.each end it "sets #size to nil if not given a size" do - @uninitialized.send(:initialize, @receiver) {}.size.should be_nil + @uninitialized.send(:initialize, @receiver) {}.size.should == nil end it "sets #size to nil if given size is nil" do - @uninitialized.send(:initialize, @receiver, nil) {}.size.should be_nil + @uninitialized.send(:initialize, @receiver, nil) {}.size.should == nil end it "sets given size to own size if the given size is Float::INFINITY" do - @uninitialized.send(:initialize, @receiver, Float::INFINITY) {}.size.should equal(Float::INFINITY) + @uninitialized.send(:initialize, @receiver, Float::INFINITY) {}.size.should.equal?(Float::INFINITY) end it "sets given size to own size if the given size is an Integer" do @@ -52,12 +52,12 @@ def receiver.each end it "raises an ArgumentError when block is not given" do - -> { @uninitialized.send :initialize, @receiver }.should raise_error(ArgumentError) + -> { @uninitialized.send :initialize, @receiver }.should.raise(ArgumentError) end describe "on frozen instance" do it "raises a FrozenError" do - -> { @uninitialized.freeze.send(:initialize, @receiver) {} }.should raise_error(FrozenError) + -> { @uninitialized.freeze.send(:initialize, @receiver) {} }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/enumerator/lazy/lazy_spec.rb b/spec/ruby/core/enumerator/lazy/lazy_spec.rb index b43864b6739905..12107383d683c7 100644 --- a/spec/ruby/core/enumerator/lazy/lazy_spec.rb +++ b/spec/ruby/core/enumerator/lazy/lazy_spec.rb @@ -4,24 +4,24 @@ describe "Enumerator::Lazy" do it "is a subclass of Enumerator" do - Enumerator::Lazy.superclass.should equal(Enumerator) + Enumerator::Lazy.superclass.should.equal?(Enumerator) end it "defines lazy versions of a whitelist of Enumerator methods" do - lazy_methods = [ + lazy_methods = Set[ :chunk, :chunk_while, :collect, :collect_concat, :compact, :drop, :drop_while, :enum_for, :find_all, :flat_map, :force, :grep, :grep_v, :lazy, :map, :reject, :select, :slice_after, :slice_before, :slice_when, :take, :take_while, :to_enum, :uniq, :zip ] - Enumerator::Lazy.instance_methods(false).should include(*lazy_methods) + Enumerator::Lazy.instance_methods(false).to_set.should >= lazy_methods end end describe "Enumerator::Lazy#lazy" do it "returns self" do lazy = (1..3).to_enum.lazy - lazy.lazy.should equal(lazy) + lazy.lazy.should.equal?(lazy) end end diff --git a/spec/ruby/core/enumerator/lazy/reject_spec.rb b/spec/ruby/core/enumerator/lazy/reject_spec.rb index 0e1632d667ac84..374d4df14ed000 100644 --- a/spec/ruby/core/enumerator/lazy/reject_spec.rb +++ b/spec/ruby/core/enumerator/lazy/reject_spec.rb @@ -16,8 +16,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.reject {} - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets #size to nil" do @@ -42,7 +42,7 @@ -> { lazy.first - }.should raise_error(RuntimeError, "foo") + }.should.raise(RuntimeError, "foo") end it "calls the block with a gathered array when yield with multiple arguments" do @@ -52,7 +52,7 @@ end it "raises an ArgumentError when not given a block" do - -> { @yieldsmixed.reject }.should raise_error(ArgumentError) + -> { @yieldsmixed.reject }.should.raise(ArgumentError) end describe "on a nested Lazy" do diff --git a/spec/ruby/core/enumerator/lazy/shared/collect.rb b/spec/ruby/core/enumerator/lazy/shared/collect.rb index 5690255a0cf53d..0ed04c8e02dd4c 100644 --- a/spec/ruby/core/enumerator/lazy/shared/collect.rb +++ b/spec/ruby/core/enumerator/lazy/shared/collect.rb @@ -16,8 +16,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.send(@method) {} - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "keeps size" do diff --git a/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb b/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb index 00d7941a61eaa0..685e6d05948648 100644 --- a/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb +++ b/spec/ruby/core/enumerator/lazy/shared/collect_concat.rb @@ -16,8 +16,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.send(@method) {} - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets #size to nil" do @@ -34,7 +34,7 @@ it "flattens elements when the given block returned an array or responding to .each and .force" do (0..Float::INFINITY).lazy.send(@method) { |n| (n * 10).to_s.chars }.first(6).should == %w[0 1 0 2 0 3] - (0..Float::INFINITY).lazy.send(@method) { |n| (n * 10).to_s.each_char }.first(6).all? { |o| o.instance_of? Enumerator }.should be_true + (0..Float::INFINITY).lazy.send(@method) { |n| (n * 10).to_s.each_char }.first(6).all? { |o| o.instance_of? Enumerator }.should == true (0..Float::INFINITY).lazy.send(@method) { |n| (n * 10).to_s.each_char.lazy }.first(6).should == %w[0 1 0 2 0 3] end end @@ -46,7 +46,7 @@ end it "raises an ArgumentError when not given a block" do - -> { @yieldsmixed.send(@method) }.should raise_error(ArgumentError) + -> { @yieldsmixed.send(@method) }.should.raise(ArgumentError) end describe "on a nested Lazy" do @@ -64,7 +64,7 @@ it "flattens elements when the given block returned an array or responding to .each and .force" do (0..Float::INFINITY).lazy.map {|n| n * 10 }.send(@method) { |n| n.to_s.chars }.first(6).should == %w[0 1 0 2 0 3] - (0..Float::INFINITY).lazy.map {|n| n * 10 }.send(@method) { |n| n.to_s.each_char }.first(6).all? { |o| o.instance_of? Enumerator }.should be_true + (0..Float::INFINITY).lazy.map {|n| n * 10 }.send(@method) { |n| n.to_s.each_char }.first(6).all? { |o| o.instance_of? Enumerator }.should == true (0..Float::INFINITY).lazy.map {|n| n * 10 }.send(@method) { |n| n.to_s.each_char.lazy }.first(6).should == %w[0 1 0 2 0 3] end end diff --git a/spec/ruby/core/enumerator/lazy/shared/select.rb b/spec/ruby/core/enumerator/lazy/shared/select.rb index 50a00bcbf4589b..2d151766201110 100644 --- a/spec/ruby/core/enumerator/lazy/shared/select.rb +++ b/spec/ruby/core/enumerator/lazy/shared/select.rb @@ -16,8 +16,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.send(@method) {} - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets #size to nil" do @@ -40,7 +40,7 @@ end it "raises an ArgumentError when not given a block" do - -> { @yieldsmixed.send(@method) }.should raise_error(ArgumentError) + -> { @yieldsmixed.send(@method) }.should.raise(ArgumentError) end describe "on a nested Lazy" do diff --git a/spec/ruby/core/enumerator/lazy/shared/to_enum.rb b/spec/ruby/core/enumerator/lazy/shared/to_enum.rb index 0c91ea55b95829..75b9aefe8c1e78 100644 --- a/spec/ruby/core/enumerator/lazy/shared/to_enum.rb +++ b/spec/ruby/core/enumerator/lazy/shared/to_enum.rb @@ -13,8 +13,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @infinite.send @method - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@infinite) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@infinite) end it "sets #size to nil when not given a block" do @@ -43,7 +43,7 @@ each_entry: [], each_cons: [2] }.each_pair do |method, args| - @infinite.send(method, *args).should be_an_instance_of(Enumerator::Lazy) + @infinite.send(method, *args).should.instance_of?(Enumerator::Lazy) end end diff --git a/spec/ruby/core/enumerator/lazy/slice_after_spec.rb b/spec/ruby/core/enumerator/lazy/slice_after_spec.rb index 8b08a1ecfd7f11..f8cd97178f6718 100644 --- a/spec/ruby/core/enumerator/lazy/slice_after_spec.rb +++ b/spec/ruby/core/enumerator/lazy/slice_after_spec.rb @@ -9,6 +9,6 @@ it "should return a lazy enumerator" do s = 0..Float::INFINITY - s.lazy.slice_after { |n| true }.should be_kind_of(Enumerator::Lazy) + s.lazy.slice_after { |n| true }.should.is_a?(Enumerator::Lazy) end end diff --git a/spec/ruby/core/enumerator/lazy/slice_before_spec.rb b/spec/ruby/core/enumerator/lazy/slice_before_spec.rb index 9c1ec9ba4abf90..192e853343d7ac 100644 --- a/spec/ruby/core/enumerator/lazy/slice_before_spec.rb +++ b/spec/ruby/core/enumerator/lazy/slice_before_spec.rb @@ -9,6 +9,6 @@ it "should return a lazy enumerator" do s = 0..Float::INFINITY - s.lazy.slice_before { |n| true }.should be_kind_of(Enumerator::Lazy) + s.lazy.slice_before { |n| true }.should.is_a?(Enumerator::Lazy) end end diff --git a/spec/ruby/core/enumerator/lazy/slice_when_spec.rb b/spec/ruby/core/enumerator/lazy/slice_when_spec.rb index f83403425db9ca..fc9d5f5069605c 100644 --- a/spec/ruby/core/enumerator/lazy/slice_when_spec.rb +++ b/spec/ruby/core/enumerator/lazy/slice_when_spec.rb @@ -9,6 +9,6 @@ it "should return a lazy enumerator" do s = 0..Float::INFINITY - s.lazy.slice_when { |a, b| true }.should be_kind_of(Enumerator::Lazy) + s.lazy.slice_when { |a, b| true }.should.is_a?(Enumerator::Lazy) end end diff --git a/spec/ruby/core/enumerator/lazy/take_spec.rb b/spec/ruby/core/enumerator/lazy/take_spec.rb index 9fc17e969f4dc5..f92360f543e7ef 100644 --- a/spec/ruby/core/enumerator/lazy/take_spec.rb +++ b/spec/ruby/core/enumerator/lazy/take_spec.rb @@ -16,8 +16,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.take(1) - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets given count to size if the given count is less than old size" do diff --git a/spec/ruby/core/enumerator/lazy/take_while_spec.rb b/spec/ruby/core/enumerator/lazy/take_while_spec.rb index bcea0b1419f4fa..c369712c56c208 100644 --- a/spec/ruby/core/enumerator/lazy/take_while_spec.rb +++ b/spec/ruby/core/enumerator/lazy/take_while_spec.rb @@ -16,8 +16,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.take_while {} - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "sets #size to nil" do @@ -40,7 +40,7 @@ end it "raises an ArgumentError when not given a block" do - -> { @yieldsmixed.take_while }.should raise_error(ArgumentError) + -> { @yieldsmixed.take_while }.should.raise(ArgumentError) end describe "on a nested Lazy" do diff --git a/spec/ruby/core/enumerator/lazy/uniq_spec.rb b/spec/ruby/core/enumerator/lazy/uniq_spec.rb index ce67ace5abdbad..d30ed8df2f270f 100644 --- a/spec/ruby/core/enumerator/lazy/uniq_spec.rb +++ b/spec/ruby/core/enumerator/lazy/uniq_spec.rb @@ -8,7 +8,7 @@ end it 'returns a lazy enumerator' do - @lazy.should be_an_instance_of(Enumerator::Lazy) + @lazy.should.instance_of?(Enumerator::Lazy) @lazy.force.should == [0, 1] end @@ -28,7 +28,7 @@ end it 'returns a lazy enumerator' do - @lazy.should be_an_instance_of(Enumerator::Lazy) + @lazy.should.instance_of?(Enumerator::Lazy) @lazy.force.should == [0, 1] end diff --git a/spec/ruby/core/enumerator/lazy/with_index_spec.rb b/spec/ruby/core/enumerator/lazy/with_index_spec.rb index a6b5c38777a1b5..2e983fd3b15701 100644 --- a/spec/ruby/core/enumerator/lazy/with_index_spec.rb +++ b/spec/ruby/core/enumerator/lazy/with_index_spec.rb @@ -17,7 +17,7 @@ end it "raises TypeError when offset does not convert to Integer" do - -> { (0..Float::INFINITY).lazy.with_index(false).map { |i, idx| i }.first(3) }.should raise_error(TypeError) + -> { (0..Float::INFINITY).lazy.with_index(false).map { |i, idx| i }.first(3) }.should.raise(TypeError) end it "enumerates with a given block" do diff --git a/spec/ruby/core/enumerator/lazy/zip_spec.rb b/spec/ruby/core/enumerator/lazy/zip_spec.rb index 5a828c1dccd5fc..9f612542d71f5b 100644 --- a/spec/ruby/core/enumerator/lazy/zip_spec.rb +++ b/spec/ruby/core/enumerator/lazy/zip_spec.rb @@ -16,8 +16,8 @@ it "returns a new instance of Enumerator::Lazy" do ret = @yieldsmixed.zip [] - ret.should be_an_instance_of(Enumerator::Lazy) - ret.should_not equal(@yieldsmixed) + ret.should.instance_of?(Enumerator::Lazy) + ret.should_not.equal?(@yieldsmixed) end it "keeps size" do @@ -40,11 +40,11 @@ end it "returns a Lazy when no arguments given" do - @yieldsmixed.zip.should be_an_instance_of(Enumerator::Lazy) + @yieldsmixed.zip.should.instance_of?(Enumerator::Lazy) end it "raises a TypeError if arguments contain non-list object" do - -> { @yieldsmixed.zip [], Object.new, [] }.should raise_error(TypeError) + -> { @yieldsmixed.zip [], Object.new, [] }.should.raise(TypeError) end describe "on a nested Lazy" do diff --git a/spec/ruby/core/enumerator/new_spec.rb b/spec/ruby/core/enumerator/new_spec.rb index 671912224f9317..539328a6c9dc87 100644 --- a/spec/ruby/core/enumerator/new_spec.rb +++ b/spec/ruby/core/enumerator/new_spec.rb @@ -3,7 +3,7 @@ describe "Enumerator.new" do context "no block given" do it "raises" do - -> { Enumerator.new(1, :upto, 3) }.should raise_error(ArgumentError) + -> { Enumerator.new(1, :upto, 3) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/enumerator/next_spec.rb b/spec/ruby/core/enumerator/next_spec.rb index a5e01a399d41c2..77e79185a97c7a 100644 --- a/spec/ruby/core/enumerator/next_spec.rb +++ b/spec/ruby/core/enumerator/next_spec.rb @@ -13,14 +13,14 @@ it "raises a StopIteration exception at the end of the stream" do 3.times { @enum.next } - -> { @enum.next }.should raise_error(StopIteration) + -> { @enum.next }.should.raise(StopIteration) end it "cannot be called again until the enumerator is rewound" do 3.times { @enum.next } - -> { @enum.next }.should raise_error(StopIteration) - -> { @enum.next }.should raise_error(StopIteration) - -> { @enum.next }.should raise_error(StopIteration) + -> { @enum.next }.should.raise(StopIteration) + -> { @enum.next }.should.raise(StopIteration) + -> { @enum.next }.should.raise(StopIteration) @enum.rewind @enum.next.should == 1 end diff --git a/spec/ruby/core/enumerator/next_values_spec.rb b/spec/ruby/core/enumerator/next_values_spec.rb index 2202700c588832..63e024e2b4414d 100644 --- a/spec/ruby/core/enumerator/next_values_spec.rb +++ b/spec/ruby/core/enumerator/next_values_spec.rb @@ -56,6 +56,6 @@ def o.each it "raises StopIteration if called on a finished enumerator" do 8.times { @e.next } - -> { @e.next_values }.should raise_error(StopIteration) + -> { @e.next_values }.should.raise(StopIteration) end end diff --git a/spec/ruby/core/enumerator/peek_spec.rb b/spec/ruby/core/enumerator/peek_spec.rb index 2334385437f966..096fd2b10c0da5 100644 --- a/spec/ruby/core/enumerator/peek_spec.rb +++ b/spec/ruby/core/enumerator/peek_spec.rb @@ -31,6 +31,6 @@ it "raises StopIteration if called on a finished enumerator" do 5.times { @e.next } - -> { @e.peek }.should raise_error(StopIteration) + -> { @e.peek }.should.raise(StopIteration) end end diff --git a/spec/ruby/core/enumerator/peek_values_spec.rb b/spec/ruby/core/enumerator/peek_values_spec.rb index 8b84fc8afcde8f..63f7988bcd20a5 100644 --- a/spec/ruby/core/enumerator/peek_values_spec.rb +++ b/spec/ruby/core/enumerator/peek_values_spec.rb @@ -58,6 +58,6 @@ def o.each it "raises StopIteration if called on a finished enumerator" do 8.times { @e.next } - -> { @e.peek_values }.should raise_error(StopIteration) + -> { @e.peek_values }.should.raise(StopIteration) end end diff --git a/spec/ruby/core/enumerator/plus_spec.rb b/spec/ruby/core/enumerator/plus_spec.rb index 755be5b4ebe5bb..d6c0fa93acdc45 100644 --- a/spec/ruby/core/enumerator/plus_spec.rb +++ b/spec/ruby/core/enumerator/plus_spec.rb @@ -12,7 +12,7 @@ chain = one + two + three - chain.should be_an_instance_of(Enumerator::Chain) + chain.should.instance_of?(Enumerator::Chain) chain.each { |item| ScratchPad << item } ScratchPad.recorded.should == [1, 2, 3] end diff --git a/spec/ruby/core/enumerator/product/each_spec.rb b/spec/ruby/core/enumerator/product/each_spec.rb index 88f115a7124bdb..164998404d418f 100644 --- a/spec/ruby/core/enumerator/product/each_spec.rb +++ b/spec/ruby/core/enumerator/product/each_spec.rb @@ -33,7 +33,7 @@ def object2.each_entry it "raises a NoMethodError if the object doesn't respond to #each_entry" do -> { Enumerator::Product.new(Object.new).each {} - }.should raise_error(NoMethodError, /undefined method [`']each_entry' for/) + }.should.raise(NoMethodError, /undefined method [`']each_entry' for/) end it "returns enumerator if not given a block" do diff --git a/spec/ruby/core/enumerator/product/initialize_copy_spec.rb b/spec/ruby/core/enumerator/product/initialize_copy_spec.rb index b1b9f3ca9b91ea..b5d2b345a9f6d7 100644 --- a/spec/ruby/core/enumerator/product/initialize_copy_spec.rb +++ b/spec/ruby/core/enumerator/product/initialize_copy_spec.rb @@ -17,7 +17,7 @@ end it "is a private method" do - Enumerator::Product.should have_private_instance_method(:initialize_copy, false) + Enumerator::Product.private_instance_methods(false).should.include?(:initialize_copy) end it "does nothing if the argument is the same as the receiver" do @@ -32,21 +32,21 @@ enum = Enumerator::Product.new(1..2) enum2 = Enumerator::Product.new(3..4) - -> { enum.freeze.send(:initialize_copy, enum2) }.should raise_error(FrozenError) + -> { enum.freeze.send(:initialize_copy, enum2) }.should.raise(FrozenError) end it "raises TypeError if the objects are of different class" do enum = Enumerator::Product.new(1..2) enum2 = Class.new(Enumerator::Product).new(3..4) - -> { enum.send(:initialize_copy, enum2) }.should raise_error(TypeError, 'initialize_copy should take same class object') - -> { enum2.send(:initialize_copy, enum) }.should raise_error(TypeError, 'initialize_copy should take same class object') + -> { enum.send(:initialize_copy, enum2) }.should.raise(TypeError, 'initialize_copy should take same class object') + -> { enum2.send(:initialize_copy, enum) }.should.raise(TypeError, 'initialize_copy should take same class object') end it "raises ArgumentError if the argument is not initialized yet" do enum = Enumerator::Product.new(1..2) enum2 = Enumerator::Product.allocate - -> { enum.send(:initialize_copy, enum2) }.should raise_error(ArgumentError, 'uninitialized product') + -> { enum.send(:initialize_copy, enum2) }.should.raise(ArgumentError, 'uninitialized product') end end diff --git a/spec/ruby/core/enumerator/product/initialize_spec.rb b/spec/ruby/core/enumerator/product/initialize_spec.rb index ed2a8a2a1350c6..8814f9d3c7be8b 100644 --- a/spec/ruby/core/enumerator/product/initialize_spec.rb +++ b/spec/ruby/core/enumerator/product/initialize_spec.rb @@ -6,26 +6,26 @@ end it "is a private method" do - Enumerator::Product.should have_private_instance_method(:initialize, false) + Enumerator::Product.private_instance_methods(false).should.include?(:initialize) end it "returns self" do - @uninitialized.send(:initialize).should equal(@uninitialized) + @uninitialized.send(:initialize).should.equal?(@uninitialized) end it "accepts many arguments" do - @uninitialized.send(:initialize, 0..1, 2..3, 4..5).should equal(@uninitialized) + @uninitialized.send(:initialize, 0..1, 2..3, 4..5).should.equal?(@uninitialized) end it "accepts arguments that are not Enumerable nor responding to :each_entry" do - @uninitialized.send(:initialize, Object.new).should equal(@uninitialized) + @uninitialized.send(:initialize, Object.new).should.equal?(@uninitialized) end describe "on frozen instance" do it "raises a FrozenError" do -> { @uninitialized.freeze.send(:initialize, 0..1) - }.should raise_error(FrozenError) + }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/enumerator/product_spec.rb b/spec/ruby/core/enumerator/product_spec.rb index 83c7cb8e0e8643..0f37ef76e7f202 100644 --- a/spec/ruby/core/enumerator/product_spec.rb +++ b/spec/ruby/core/enumerator/product_spec.rb @@ -51,7 +51,7 @@ it "reject keyword arguments" do -> { Enumerator.product(1..3, foo: 1, bar: 2) - }.should raise_error(ArgumentError, "unknown keywords: :foo, :bar") + }.should.raise(ArgumentError, "unknown keywords: :foo, :bar") end it "calls only #each_entry method on arguments" do @@ -68,11 +68,11 @@ def object.each_entry it "raises NoMethodError when argument doesn't respond to #each_entry" do -> { Enumerator.product(Object.new).to_a - }.should raise_error(NoMethodError, /undefined method [`']each_entry' for/) + }.should.raise(NoMethodError, /undefined method [`']each_entry' for/) end it "calls #each_entry lazily" do - Enumerator.product(Object.new).should be_kind_of(Enumerator) + Enumerator.product(Object.new).should.is_a?(Enumerator) end it "iterates through consuming enumerator elements only once" do diff --git a/spec/ruby/core/enumerator/shared/enum_for.rb b/spec/ruby/core/enumerator/shared/enum_for.rb index a67a76c4613a7c..4388103ecf409d 100644 --- a/spec/ruby/core/enumerator/shared/enum_for.rb +++ b/spec/ruby/core/enumerator/shared/enum_for.rb @@ -1,10 +1,10 @@ describe :enum_for, shared: true do it "is defined in Kernel" do - Kernel.method_defined?(@method).should be_true + Kernel.method_defined?(@method).should == true end it "returns a new enumerator" do - "abc".send(@method).should be_an_instance_of(Enumerator) + "abc".send(@method).should.instance_of?(Enumerator) end it "defaults the first argument to :each" do @@ -49,7 +49,7 @@ def o.each 100 end - ScratchPad.recorded.should be_empty + ScratchPad.recorded.should.empty? enum.size ScratchPad.recorded.should == [:called] diff --git a/spec/ruby/core/enumerator/shared/with_index.rb b/spec/ruby/core/enumerator/shared/with_index.rb index 78771ffe82d8da..0992397e958675 100644 --- a/spec/ruby/core/enumerator/shared/with_index.rb +++ b/spec/ruby/core/enumerator/shared/with_index.rb @@ -16,7 +16,7 @@ end it "returns the object being enumerated when given a block" do - @enum.send(@method) { |o, i| :glark }.should equal(@origin) + @enum.send(@method) { |o, i| :glark }.should.equal?(@origin) end it "binds splat arguments properly" do @@ -27,7 +27,7 @@ it "returns an enumerator if no block is supplied" do ewi = @enum.send(@method) - ewi.should be_an_instance_of(Enumerator) + ewi.should.instance_of?(Enumerator) ewi.to_a.should == [[1, 0], [2, 1], [3, 2], [4, 3]] end end diff --git a/spec/ruby/core/enumerator/shared/with_object.rb b/spec/ruby/core/enumerator/shared/with_object.rb index d8e9d8e9f7be4b..50d4f24eb34f63 100644 --- a/spec/ruby/core/enumerator/shared/with_object.rb +++ b/spec/ruby/core/enumerator/shared/with_object.rb @@ -16,18 +16,18 @@ ret = @enum.send(@method, @memo) do |elm, memo| # nothing end - ret.should equal(@memo) + ret.should.equal?(@memo) end context "the block parameter" do it "passes each element to first parameter" do - @block_params[0][0].should equal(:a) - @block_params[1][0].should equal(:b) + @block_params[0][0].should.equal?(:a) + @block_params[1][0].should.equal?(:b) end it "passes the given object to last parameter" do - @block_params[0][1].should equal(@memo) - @block_params[1][1].should equal(@memo) + @block_params[0][1].should.equal?(@memo) + @block_params[1][1].should.equal?(@memo) end end end @@ -35,8 +35,8 @@ context "without block" do it "returns new Enumerator" do ret = @enum.send(@method, @memo) - ret.should be_an_instance_of(Enumerator) - ret.should_not equal(@enum) + ret.should.instance_of?(Enumerator) + ret.should_not.equal?(@enum) end end end diff --git a/spec/ruby/core/enumerator/size_spec.rb b/spec/ruby/core/enumerator/size_spec.rb index 6accd26a4e3b88..4b2beffbbe584a 100644 --- a/spec/ruby/core/enumerator/size_spec.rb +++ b/spec/ruby/core/enumerator/size_spec.rb @@ -6,7 +6,7 @@ end it "returns nil if set size is nil" do - Enumerator.new(nil) {}.size.should be_nil + Enumerator.new(nil) {}.size.should == nil end it "returns returning value from size.call if set size is a Proc" do diff --git a/spec/ruby/core/enumerator/with_index_spec.rb b/spec/ruby/core/enumerator/with_index_spec.rb index e49aa7a939b9e8..ca90fd18f7f7ae 100644 --- a/spec/ruby/core/enumerator/with_index_spec.rb +++ b/spec/ruby/core/enumerator/with_index_spec.rb @@ -9,20 +9,20 @@ it "returns a new Enumerator when no block is given" do enum1 = [1,2,3].select enum2 = enum1.with_index - enum2.should be_an_instance_of(Enumerator) + enum2.should.instance_of?(Enumerator) enum1.should_not === enum2 end it "accepts an optional argument when given a block" do -> do @enum.with_index(1) { |f| f} - end.should_not raise_error(ArgumentError) + end.should_not.raise(ArgumentError) end it "accepts an optional argument when not given a block" do -> do @enum.with_index(1) - end.should_not raise_error(ArgumentError) + end.should_not.raise(ArgumentError) end it "numbers indices from the given index when given an offset but no block" do @@ -38,7 +38,7 @@ it "raises a TypeError when the argument cannot be converted to numeric" do -> do @enum.with_index('1') {|*i| i} - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "converts non-numeric arguments to Integer via #to_int" do diff --git a/spec/ruby/core/enumerator/yielder/append_spec.rb b/spec/ruby/core/enumerator/yielder/append_spec.rb index a36e5d64b6c0fb..2e1f5203d9447e 100644 --- a/spec/ruby/core/enumerator/yielder/append_spec.rb +++ b/spec/ruby/core/enumerator/yielder/append_spec.rb @@ -19,7 +19,7 @@ it "returns self" do y = Enumerator::Yielder.new {|x| x + 1} - (y << 1).should equal(y) + (y << 1).should.equal?(y) end context "when multiple arguments passed" do @@ -29,7 +29,7 @@ -> { y.<<(1, 2) - }.should raise_error(ArgumentError, /wrong number of arguments/) + }.should.raise(ArgumentError, /wrong number of arguments/) end end end diff --git a/spec/ruby/core/enumerator/yielder/initialize_spec.rb b/spec/ruby/core/enumerator/yielder/initialize_spec.rb index 5a6eee2d0f391b..925f561ec43db7 100644 --- a/spec/ruby/core/enumerator/yielder/initialize_spec.rb +++ b/spec/ruby/core/enumerator/yielder/initialize_spec.rb @@ -9,10 +9,10 @@ end it "is a private method" do - @class.should have_private_instance_method(:initialize, false) + @class.private_instance_methods(false).should.include?(:initialize) end it "returns self when given a block" do - @uninitialized.send(:initialize) {}.should equal(@uninitialized) + @uninitialized.send(:initialize) {}.should.equal?(@uninitialized) end end diff --git a/spec/ruby/core/env/assoc_spec.rb b/spec/ruby/core/env/assoc_spec.rb index c7a388db754e0e..b81be7ddf22715 100644 --- a/spec/ruby/core/env/assoc_spec.rb +++ b/spec/ruby/core/env/assoc_spec.rb @@ -26,6 +26,6 @@ end it "raises TypeError if the argument is not a String and does not respond to #to_str" do - -> { ENV.assoc(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.assoc(Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") end end diff --git a/spec/ruby/core/env/clear_spec.rb b/spec/ruby/core/env/clear_spec.rb index 48b034ba1d968d..c0d20193ad24e9 100644 --- a/spec/ruby/core/env/clear_spec.rb +++ b/spec/ruby/core/env/clear_spec.rb @@ -4,7 +4,7 @@ it "deletes all environment variables" do orig = ENV.to_hash begin - ENV.clear.should equal(ENV) + ENV.clear.should.equal?(ENV) # This used 'env' the helper before. That shells out to 'env' which # itself sets up certain environment variables before it runs, because diff --git a/spec/ruby/core/env/clone_spec.rb b/spec/ruby/core/env/clone_spec.rb index 01a29c6ab48a18..bb3c7ff2f86f0b 100644 --- a/spec/ruby/core/env/clone_spec.rb +++ b/spec/ruby/core/env/clone_spec.rb @@ -4,18 +4,18 @@ it "raises ArgumentError when keyword argument 'freeze' is neither nil nor boolean" do -> { ENV.clone(freeze: 1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises ArgumentError when keyword argument is not 'freeze'" do -> { ENV.clone(foo: nil) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises TypeError" do -> { ENV.clone - }.should raise_error(TypeError, /Cannot clone ENV, use ENV.to_h to get a copy of ENV as a hash/) + }.should.raise(TypeError, /Cannot clone ENV, use ENV.to_h to get a copy of ENV as a hash/) end end diff --git a/spec/ruby/core/env/delete_if_spec.rb b/spec/ruby/core/env/delete_if_spec.rb index d2de51c225327e..4b05064eba2625 100644 --- a/spec/ruby/core/env/delete_if_spec.rb +++ b/spec/ruby/core/env/delete_if_spec.rb @@ -22,15 +22,15 @@ end it "returns ENV when block given" do - ENV.delete_if { |k, v| ["foo", "bar"].include?(k) }.should equal(ENV) + ENV.delete_if { |k, v| ["foo", "bar"].include?(k) }.should.equal?(ENV) end it "returns ENV even if nothing deleted" do - ENV.delete_if { false }.should equal(ENV) + ENV.delete_if { false }.should.equal?(ENV) end it "returns an Enumerator if no block given" do - ENV.delete_if.should be_an_instance_of(Enumerator) + ENV.delete_if.should.instance_of?(Enumerator) end it "deletes pairs through enumerator" do @@ -42,12 +42,12 @@ it "returns ENV from enumerator" do enum = ENV.delete_if - enum.each { |k, v| ["foo", "bar"].include?(k) }.should equal(ENV) + enum.each { |k, v| ["foo", "bar"].include?(k) }.should.equal?(ENV) end it "returns ENV from enumerator even if nothing deleted" do enum = ENV.delete_if - enum.each { false }.should equal(ENV) + enum.each { false }.should.equal?(ENV) end it_behaves_like :enumeratorized_with_origin_size, :delete_if, ENV diff --git a/spec/ruby/core/env/delete_spec.rb b/spec/ruby/core/env/delete_spec.rb index f28ac97911126f..db6d07b057ea2d 100644 --- a/spec/ruby/core/env/delete_spec.rb +++ b/spec/ruby/core/env/delete_spec.rb @@ -50,6 +50,6 @@ end it "raises TypeError if the argument is not a String and does not respond to #to_str" do - -> { ENV.delete(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.delete(Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") end end diff --git a/spec/ruby/core/env/dup_spec.rb b/spec/ruby/core/env/dup_spec.rb index ac66b455cdebe9..d8cfac891da299 100644 --- a/spec/ruby/core/env/dup_spec.rb +++ b/spec/ruby/core/env/dup_spec.rb @@ -4,6 +4,6 @@ it "raises TypeError" do -> { ENV.dup - }.should raise_error(TypeError, /Cannot dup ENV, use ENV.to_h to get a copy of ENV as a hash/) + }.should.raise(TypeError, /Cannot dup ENV, use ENV.to_h to get a copy of ENV as a hash/) end end diff --git a/spec/ruby/core/env/each_key_spec.rb b/spec/ruby/core/env/each_key_spec.rb index 0efcb09900d027..ad2cb560a09430 100644 --- a/spec/ruby/core/env/each_key_spec.rb +++ b/spec/ruby/core/env/each_key_spec.rb @@ -10,9 +10,9 @@ ENV.clear ENV["1"] = "3" ENV["2"] = "4" - ENV.each_key { |k| e << k }.should equal(ENV) - e.should include("1") - e.should include("2") + ENV.each_key { |k| e << k }.should.equal?(ENV) + e.should.include?("1") + e.should.include?("2") ensure ENV.replace orig end @@ -20,7 +20,7 @@ it "returns an Enumerator if called without a block" do enum = ENV.each_key - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == ENV.keys end diff --git a/spec/ruby/core/env/each_value_spec.rb b/spec/ruby/core/env/each_value_spec.rb index cc3c9ebfb8c947..6f65e923e68cc3 100644 --- a/spec/ruby/core/env/each_value_spec.rb +++ b/spec/ruby/core/env/each_value_spec.rb @@ -10,9 +10,9 @@ ENV.clear ENV["1"] = "3" ENV["2"] = "4" - ENV.each_value { |v| e << v }.should equal(ENV) - e.should include("3") - e.should include("4") + ENV.each_value { |v| e << v }.should.equal?(ENV) + e.should.include?("3") + e.should.include?("4") ensure ENV.replace orig end @@ -20,7 +20,7 @@ it "returns an Enumerator if called without a block" do enum = ENV.each_value - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == ENV.values end diff --git a/spec/ruby/core/env/element_reference_spec.rb b/spec/ruby/core/env/element_reference_spec.rb index 66a9bc96906afd..e3ac9794189332 100644 --- a/spec/ruby/core/env/element_reference_spec.rb +++ b/spec/ruby/core/env/element_reference_spec.rb @@ -28,7 +28,7 @@ end it "raises TypeError if the argument is not a String and does not respond to #to_str" do - -> { ENV[Object.new] }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV[Object.new] }.should.raise(TypeError, "no implicit conversion of Object into String") end platform_is :windows do @@ -71,6 +71,6 @@ ENV[@variable] = "" Encoding.default_internal = Encoding::IBM437 - ENV[@variable].encoding.should equal(Encoding::IBM437) + ENV[@variable].encoding.should.equal?(Encoding::IBM437) end end diff --git a/spec/ruby/core/env/fetch_spec.rb b/spec/ruby/core/env/fetch_spec.rb index 2c5d7cc3a0059c..a2ec79c62bccbe 100644 --- a/spec/ruby/core/env/fetch_spec.rb +++ b/spec/ruby/core/env/fetch_spec.rb @@ -16,7 +16,7 @@ end it "raises a TypeError if the key is not a String" do - -> { ENV.fetch Object.new }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.fetch Object.new }.should.raise(TypeError, "no implicit conversion of Object into String") end context "when the key is not found" do @@ -25,7 +25,7 @@ it "formats the object with #inspect in the KeyError message" do -> { ENV.fetch('foo') - }.should raise_error(KeyError, 'key not found: "foo"') + }.should.raise(KeyError, 'key not found: "foo"') end end diff --git a/spec/ruby/core/env/fetch_values_spec.rb b/spec/ruby/core/env/fetch_values_spec.rb index 5c80f1177cd5aa..302cde2fd150bd 100644 --- a/spec/ruby/core/env/fetch_values_spec.rb +++ b/spec/ruby/core/env/fetch_values_spec.rb @@ -36,7 +36,7 @@ ENV["bar"] = "rab" -> { ENV.fetch_values("bar", "y", "foo", "z") - }.should raise_error(KeyError, 'key not found: "y"') + }.should.raise(KeyError, 'key not found: "y"') end it "uses the locale encoding" do @@ -45,7 +45,7 @@ it "raises TypeError when a key is not coercible to String" do ENV["foo"] = "oof" - -> { ENV.fetch_values("foo", Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.fetch_values("foo", Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") end end end diff --git a/spec/ruby/core/env/keep_if_spec.rb b/spec/ruby/core/env/keep_if_spec.rb index 64b6a207d00c8a..f24981e2166418 100644 --- a/spec/ruby/core/env/keep_if_spec.rb +++ b/spec/ruby/core/env/keep_if_spec.rb @@ -22,15 +22,15 @@ end it "returns ENV when block given" do - ENV.keep_if { |k, v| !["foo", "bar"].include?(k) }.should equal(ENV) + ENV.keep_if { |k, v| !["foo", "bar"].include?(k) }.should.equal?(ENV) end it "returns ENV even if nothing deleted" do - ENV.keep_if { true }.should equal(ENV) + ENV.keep_if { true }.should.equal?(ENV) end it "returns an Enumerator if no block given" do - ENV.keep_if.should be_an_instance_of(Enumerator) + ENV.keep_if.should.instance_of?(Enumerator) end it "deletes pairs through enumerator" do @@ -42,12 +42,12 @@ it "returns ENV from enumerator" do enum = ENV.keep_if - enum.each { |k, v| !["foo", "bar"].include?(k) }.should equal(ENV) + enum.each { |k, v| !["foo", "bar"].include?(k) }.should.equal?(ENV) end it "returns ENV from enumerator even if nothing deleted" do enum = ENV.keep_if - enum.each { true }.should equal(ENV) + enum.each { true }.should.equal?(ENV) end it_behaves_like :enumeratorized_with_origin_size, :keep_if, ENV diff --git a/spec/ruby/core/env/key_spec.rb b/spec/ruby/core/env/key_spec.rb index cf7028640908c4..677cf35216ce52 100644 --- a/spec/ruby/core/env/key_spec.rb +++ b/spec/ruby/core/env/key_spec.rb @@ -21,7 +21,7 @@ it "returns nil if the passed value is not found" do ENV.delete("foo") - ENV.key("foo").should be_nil + ENV.key("foo").should == nil end it "coerces the key element with #to_str" do @@ -34,6 +34,6 @@ it "raises TypeError if the argument is not a String and does not respond to #to_str" do -> { ENV.key(Object.new) - }.should raise_error(TypeError, "no implicit conversion of Object into String") + }.should.raise(TypeError, "no implicit conversion of Object into String") end end diff --git a/spec/ruby/core/env/rassoc_spec.rb b/spec/ruby/core/env/rassoc_spec.rb index ab9fe6808815d2..e4ac5ce5e27098 100644 --- a/spec/ruby/core/env/rassoc_spec.rb +++ b/spec/ruby/core/env/rassoc_spec.rb @@ -22,7 +22,7 @@ [ ["foo", "bar"], ["baz", "bar"], - ].should include(ENV.rassoc("bar")) + ].should.include?(ENV.rassoc("bar")) end it "returns nil if no environment variable with the given value exists" do diff --git a/spec/ruby/core/env/reject_spec.rb b/spec/ruby/core/env/reject_spec.rb index 6a9794925dd0ee..4df864493d2356 100644 --- a/spec/ruby/core/env/reject_spec.rb +++ b/spec/ruby/core/env/reject_spec.rb @@ -25,15 +25,15 @@ it "returns itself or nil" do ENV.reject! { false }.should == nil ENV["foo"] = "bar" - ENV.reject! { |k, v| k == "foo" }.should equal(ENV) + ENV.reject! { |k, v| k == "foo" }.should.equal?(ENV) ENV["foo"].should == nil end it "returns an Enumerator if called without a block" do ENV["foo"] = "bar" enum = ENV.reject! - enum.should be_an_instance_of(Enumerator) - enum.each { |k, v| k == "foo" }.should equal(ENV) + enum.should.instance_of?(Enumerator) + enum.each { |k, v| k == "foo" }.should.equal?(ENV) ENV["foo"].should == nil end @@ -41,7 +41,7 @@ orig = ENV.to_hash begin ENV.clear - -> { ENV.reject! }.should_not raise_error(LocalJumpError) + -> { ENV.reject! }.should_not.raise(LocalJumpError) ensure ENV.replace orig end @@ -76,13 +76,13 @@ end it "returns a Hash" do - ENV.reject { false }.should be_kind_of(Hash) + ENV.reject { false }.should.is_a?(Hash) end it "returns an Enumerator if called without a block" do ENV["foo"] = "bar" enum = ENV.reject - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each { |k, v| k == "foo"} ENV["foo"] = nil end @@ -91,7 +91,7 @@ orig = ENV.to_hash begin ENV.clear - -> { ENV.reject }.should_not raise_error(LocalJumpError) + -> { ENV.reject }.should_not.raise(LocalJumpError) ensure ENV.replace orig end diff --git a/spec/ruby/core/env/replace_spec.rb b/spec/ruby/core/env/replace_spec.rb index 9fc67643d1361e..27eb3e45dd1823 100644 --- a/spec/ruby/core/env/replace_spec.rb +++ b/spec/ruby/core/env/replace_spec.rb @@ -11,41 +11,41 @@ end it "replaces ENV with a Hash" do - ENV.replace("foo" => "0", "bar" => "1").should equal(ENV) + ENV.replace("foo" => "0", "bar" => "1").should.equal?(ENV) ENV.size.should == 2 ENV["foo"].should == "0" ENV["bar"].should == "1" end it "raises TypeError if the argument is not a Hash" do - -> { ENV.replace(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into Hash") + -> { ENV.replace(Object.new) }.should.raise(TypeError, "no implicit conversion of Object into Hash") ENV.to_hash.should == @orig end it "raises TypeError if a key is not a String" do - -> { ENV.replace(Object.new => "0") }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.replace(Object.new => "0") }.should.raise(TypeError, "no implicit conversion of Object into String") ENV.to_hash.should == @orig end it "raises TypeError if a value is not a String" do - -> { ENV.replace("foo" => Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.replace("foo" => Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") ENV.to_hash.should == @orig end it "raises Errno::EINVAL when the key contains the '=' character" do - -> { ENV.replace("foo=" =>"bar") }.should raise_error(Errno::EINVAL) + -> { ENV.replace("foo=" =>"bar") }.should.raise(Errno::EINVAL) end it "raises Errno::EINVAL when the key is an empty string" do - -> { ENV.replace("" => "bar") }.should raise_error(Errno::EINVAL) + -> { ENV.replace("" => "bar") }.should.raise(Errno::EINVAL) end it "does not accept good data preceding an error" do - -> { ENV.replace("foo" => "1", Object.new => Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.replace("foo" => "1", Object.new => Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") end it "does not accept good data following an error" do - -> { ENV.replace(Object.new => Object.new, "foo" => "0") }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.replace(Object.new => Object.new, "foo" => "0") }.should.raise(TypeError, "no implicit conversion of Object into String") ENV.to_hash.should == @orig end end diff --git a/spec/ruby/core/env/shared/each.rb b/spec/ruby/core/env/shared/each.rb index d901b854c42d2a..0661ca924cee22 100644 --- a/spec/ruby/core/env/shared/each.rb +++ b/spec/ruby/core/env/shared/each.rb @@ -8,9 +8,9 @@ ENV.clear ENV["foo"] = "bar" ENV["baz"] = "boo" - ENV.send(@method) { |k, v| e << [k, v] }.should equal(ENV) - e.should include(["foo", "bar"]) - e.should include(["baz", "boo"]) + ENV.send(@method) { |k, v| e << [k, v] }.should.equal?(ENV) + e.should.include?(["foo", "bar"]) + e.should.include?(["baz", "boo"]) ensure ENV.replace orig end @@ -18,7 +18,7 @@ it "returns an Enumerator if called without a block" do enum = ENV.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each do |name, value| ENV[name].should == value end @@ -55,9 +55,9 @@ Encoding.default_internal = internal = Encoding::IBM437 ENV.send(@method) do |key, value| - key.encoding.should equal(internal) + key.encoding.should.equal?(internal) if value.ascii_only? - value.encoding.should equal(internal) + value.encoding.should.equal?(internal) end end end diff --git a/spec/ruby/core/env/shared/include.rb b/spec/ruby/core/env/shared/include.rb index 70aa5553017ea6..ceca02e3ebbc47 100644 --- a/spec/ruby/core/env/shared/include.rb +++ b/spec/ruby/core/env/shared/include.rb @@ -25,6 +25,6 @@ end it "raises TypeError if the argument is not a String and does not respond to #to_str" do - -> { ENV.send(@method, Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.send(@method, Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") end end diff --git a/spec/ruby/core/env/shared/select.rb b/spec/ruby/core/env/shared/select.rb index 75ba112a323f98..8ec648a637f044 100644 --- a/spec/ruby/core/env/shared/select.rb +++ b/spec/ruby/core/env/shared/select.rb @@ -14,7 +14,7 @@ it "returns an Enumerator when no block is given" do enum = ENV.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) end it "selects via the enumerator" do @@ -49,7 +49,7 @@ end it "returns an Enumerator if called without a block" do - ENV.send(@method).should be_an_instance_of(Enumerator) + ENV.send(@method).should.instance_of?(Enumerator) end it "selects via the enumerator" do diff --git a/spec/ruby/core/env/shared/store.rb b/spec/ruby/core/env/shared/store.rb index d6265c66a50dcd..388208a8ac16a1 100644 --- a/spec/ruby/core/env/shared/store.rb +++ b/spec/ruby/core/env/shared/store.rb @@ -14,13 +14,13 @@ it "returns the value" do value = "bar" - ENV.send(@method, "foo", value).should equal(value) + ENV.send(@method, "foo", value).should.equal?(value) end it "deletes the environment variable when the value is nil" do ENV["foo"] = "bar" ENV.send(@method, "foo", nil) - ENV.key?("foo").should be_false + ENV.key?("foo").should == false end it "coerces the key argument with #to_str" do @@ -38,23 +38,23 @@ end it "raises TypeError when the key is not coercible to String" do - -> { ENV.send(@method, Object.new, "bar") }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.send(@method, Object.new, "bar") }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises TypeError when the value is not coercible to String" do - -> { ENV.send(@method, "foo", Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.send(@method, "foo", Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises Errno::EINVAL when the key contains the '=' character" do - -> { ENV.send(@method, "foo=", "bar") }.should raise_error(Errno::EINVAL) + -> { ENV.send(@method, "foo=", "bar") }.should.raise(Errno::EINVAL) end it "raises Errno::EINVAL when the key is an empty string" do - -> { ENV.send(@method, "", "bar") }.should raise_error(Errno::EINVAL) + -> { ENV.send(@method, "", "bar") }.should.raise(Errno::EINVAL) end it "does nothing when the key is not a valid environment variable key and the value is nil" do ENV.send(@method, "foo=", nil) - ENV.key?("foo=").should be_false + ENV.key?("foo=").should == false end end diff --git a/spec/ruby/core/env/shared/to_hash.rb b/spec/ruby/core/env/shared/to_hash.rb index a0d4d7ce694610..7868690c38dfc1 100644 --- a/spec/ruby/core/env/shared/to_hash.rb +++ b/spec/ruby/core/env/shared/to_hash.rb @@ -10,7 +10,7 @@ it "returns the ENV as a hash" do ENV["foo"] = "bar" h = ENV.send(@method) - h.should be_an_instance_of(Hash) + h.should.instance_of?(Hash) h["foo"].should == "bar" end @@ -24,7 +24,7 @@ it "duplicates the ENV when converting to a Hash" do h = ENV.send(@method) - h.should_not equal ENV + h.should_not.equal? ENV h.size.should == ENV.size h.each_pair do |k, v| ENV[k].should == v diff --git a/spec/ruby/core/env/shared/update.rb b/spec/ruby/core/env/shared/update.rb index e1b1c9c290e2db..112cc2505d095e 100644 --- a/spec/ruby/core/env/shared/update.rb +++ b/spec/ruby/core/env/shared/update.rb @@ -10,19 +10,19 @@ end it "adds the parameter hash to ENV, returning ENV" do - ENV.send(@method, "foo" => "0", "bar" => "1").should equal(ENV) + ENV.send(@method, "foo" => "0", "bar" => "1").should.equal?(ENV) ENV["foo"].should == "0" ENV["bar"].should == "1" end it "adds the multiple parameter hashes to ENV, returning ENV" do - ENV.send(@method, {"foo" => "multi1"}, {"bar" => "multi2"}).should equal(ENV) + ENV.send(@method, {"foo" => "multi1"}, {"bar" => "multi2"}).should.equal?(ENV) ENV["foo"].should == "multi1" ENV["bar"].should == "multi2" end it "returns ENV when no block given" do - ENV.send(@method, {"foo" => "0", "bar" => "1"}).should equal(ENV) + ENV.send(@method, {"foo" => "0", "bar" => "1"}).should.equal?(ENV) end it "yields key, the old value and the new value when replacing an entry" do @@ -63,23 +63,23 @@ end it "returns ENV when block given" do - ENV.send(@method, {"foo" => "0", "bar" => "1"}){}.should equal(ENV) + ENV.send(@method, {"foo" => "0", "bar" => "1"}){}.should.equal?(ENV) end it "raises TypeError when a name is not coercible to String" do - -> { ENV.send @method, Object.new => "0" }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.send @method, Object.new => "0" }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises TypeError when a value is not coercible to String" do - -> { ENV.send @method, "foo" => Object.new }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.send @method, "foo" => Object.new }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises Errno::EINVAL when a name contains the '=' character" do - -> { ENV.send(@method, "foo=" => "bar") }.should raise_error(Errno::EINVAL) + -> { ENV.send(@method, "foo=" => "bar") }.should.raise(Errno::EINVAL) end it "raises Errno::EINVAL when a name is an empty string" do - -> { ENV.send(@method, "" => "bar") }.should raise_error(Errno::EINVAL) + -> { ENV.send(@method, "" => "bar") }.should.raise(Errno::EINVAL) end it "updates good data preceding an error" do diff --git a/spec/ruby/core/env/shift_spec.rb b/spec/ruby/core/env/shift_spec.rb index 1b92e5d1e4e19d..52bd0f9139516c 100644 --- a/spec/ruby/core/env/shift_spec.rb +++ b/spec/ruby/core/env/shift_spec.rb @@ -33,15 +33,15 @@ Encoding.default_internal = nil pair = ENV.shift - pair.first.encoding.should equal(ENVSpecs.encoding) - pair.last.encoding.should equal(ENVSpecs.encoding) + pair.first.encoding.should.equal?(ENVSpecs.encoding) + pair.last.encoding.should.equal?(ENVSpecs.encoding) end it "transcodes from the locale encoding to Encoding.default_internal if set" do Encoding.default_internal = Encoding::IBM437 pair = ENV.shift - pair.first.encoding.should equal(Encoding::IBM437) - pair.last.encoding.should equal(Encoding::IBM437) + pair.first.encoding.should.equal?(Encoding::IBM437) + pair.last.encoding.should.equal?(Encoding::IBM437) end end diff --git a/spec/ruby/core/env/slice_spec.rb b/spec/ruby/core/env/slice_spec.rb index 959239d2b2fb8c..4c0416547d2ef6 100644 --- a/spec/ruby/core/env/slice_spec.rb +++ b/spec/ruby/core/env/slice_spec.rb @@ -32,6 +32,6 @@ end it "raises TypeError if any argument is not a String and does not respond to #to_str" do - -> { ENV.slice(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.slice(Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") end end diff --git a/spec/ruby/core/env/to_h_spec.rb b/spec/ruby/core/env/to_h_spec.rb index 58ea2d2030e5e3..7e0fef2120525f 100644 --- a/spec/ruby/core/env/to_h_spec.rb +++ b/spec/ruby/core/env/to_h_spec.rb @@ -38,17 +38,17 @@ it "raises ArgumentError if block returns longer or shorter array" do -> do ENV.to_h { |k, v| [k, v.upcase, 1] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) -> do ENV.to_h { |k, v| [k] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) end it "raises TypeError if block returns something other than Array" do -> do ENV.to_h { |k, v| "not-array" } - end.should raise_error(TypeError, /wrong element type String/) + end.should.raise(TypeError, /wrong element type String/) end it "coerces returned pair to Array with #to_ary" do @@ -64,7 +64,7 @@ -> do ENV.to_h { |k| x } - end.should raise_error(TypeError, /wrong element type MockObject/) + end.should.raise(TypeError, /wrong element type MockObject/) end end end diff --git a/spec/ruby/core/env/values_at_spec.rb b/spec/ruby/core/env/values_at_spec.rb index 338680e8208036..4a733f4ed51eb2 100644 --- a/spec/ruby/core/env/values_at_spec.rb +++ b/spec/ruby/core/env/values_at_spec.rb @@ -33,6 +33,6 @@ end it "raises TypeError when a key is not coercible to String" do - -> { ENV.values_at("foo", Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { ENV.values_at("foo", Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") end end diff --git a/spec/ruby/core/exception/backtrace_locations_spec.rb b/spec/ruby/core/exception/backtrace_locations_spec.rb index 86eb9d3413d7dc..62eab8a0f31710 100644 --- a/spec/ruby/core/exception/backtrace_locations_spec.rb +++ b/spec/ruby/core/exception/backtrace_locations_spec.rb @@ -7,15 +7,15 @@ end it "returns nil if no backtrace was set" do - Exception.new.backtrace_locations.should be_nil + Exception.new.backtrace_locations.should == nil end it "returns an Array" do - @backtrace.should be_an_instance_of(Array) + @backtrace.should.instance_of?(Array) end it "sets each element to a Thread::Backtrace::Location" do - @backtrace.each {|l| l.should be_an_instance_of(Thread::Backtrace::Location)} + @backtrace.each {|l| l.should.instance_of?(Thread::Backtrace::Location)} end it "produces a backtrace for an exception captured using $!" do diff --git a/spec/ruby/core/exception/backtrace_spec.rb b/spec/ruby/core/exception/backtrace_spec.rb index 9a65ea3820e1fc..a4a8272030f8aa 100644 --- a/spec/ruby/core/exception/backtrace_spec.rb +++ b/spec/ruby/core/exception/backtrace_spec.rb @@ -7,15 +7,15 @@ end it "returns nil if no backtrace was set" do - Exception.new.backtrace.should be_nil + Exception.new.backtrace.should == nil end it "returns an Array" do - @backtrace.should be_an_instance_of(Array) + @backtrace.should.instance_of?(Array) end it "sets each element to a String" do - @backtrace.each {|l| l.should be_an_instance_of(String)} + @backtrace.each {|l| l.should.instance_of?(String)} end it "includes the filename of the location where self raised in the first element" do @@ -94,13 +94,13 @@ raise rescue RuntimeError => err bt = err.backtrace - err.dup.backtrace.should equal(bt) + err.dup.backtrace.should.equal?(bt) new_bt = ['hi'] err.set_backtrace new_bt err.backtrace.should == new_bt - err.dup.backtrace.should equal(new_bt) + err.dup.backtrace.should.equal?(new_bt) end end end diff --git a/spec/ruby/core/exception/cause_spec.rb b/spec/ruby/core/exception/cause_spec.rb index cf4aaeb1880e85..cfc15bdda385fb 100644 --- a/spec/ruby/core/exception/cause_spec.rb +++ b/spec/ruby/core/exception/cause_spec.rb @@ -4,53 +4,35 @@ it "returns the active exception when an exception is raised" do begin raise Exception, "the cause" - rescue Exception - begin + rescue Exception => cause + -> { raise RuntimeError, "the consequence" - rescue RuntimeError => e - e.should be_an_instance_of(RuntimeError) - e.message.should == "the consequence" - - e.cause.should be_an_instance_of(Exception) - e.cause.message.should == "the cause" - end + }.should.raise(RuntimeError, "the consequence", cause:) end end it "is set for user errors caused by internal errors" do - -> { - begin - 1 / 0 - rescue - raise "foo" - end - }.should raise_error(RuntimeError) { |e| - e.cause.should be_kind_of(ZeroDivisionError) - } + begin + 1 / 0 + rescue => cause + -> { raise "foo" }.should.raise(RuntimeError, cause:) + end end it "is set for internal errors caused by user errors" do cause = RuntimeError.new "cause" - -> { - begin - raise cause - rescue - 1 / 0 - end - }.should raise_error(ZeroDivisionError) { |e| - e.cause.should equal(cause) - } + begin + raise cause + rescue + -> { 1 / 0 }.should.raise(ZeroDivisionError, cause:) + end end it "is not set to the exception itself when it is re-raised" do - -> { - begin - raise RuntimeError - rescue RuntimeError => e - raise e - end - }.should raise_error(RuntimeError) { |e| - e.cause.should == nil - } + begin + raise RuntimeError + rescue RuntimeError => e + -> { raise e }.should.raise(RuntimeError, cause: nil) + end end end diff --git a/spec/ruby/core/exception/dup_spec.rb b/spec/ruby/core/exception/dup_spec.rb index edd54bfb37ae0c..b53ad79bf30672 100644 --- a/spec/ruby/core/exception/dup_spec.rb +++ b/spec/ruby/core/exception/dup_spec.rb @@ -20,7 +20,7 @@ it "does not copy singleton methods" do def @obj.special() :the_one end dup = @obj.dup - -> { dup.special }.should raise_error(NameError) + -> { dup.special }.should.raise(NameError) end it "does not copy modules included in the singleton class" do @@ -29,7 +29,7 @@ class << @obj end dup = @obj.dup - -> { dup.repr }.should raise_error(NameError) + -> { dup.repr }.should.raise(NameError) end it "does not copy constants defined in the singleton class" do @@ -38,7 +38,7 @@ class << @obj end dup = @obj.dup - -> { class << dup; CLONE; end }.should raise_error(NameError) + -> { class << dup; CLONE; end }.should.raise(NameError) end it "does copy the message" do @@ -61,13 +61,13 @@ class << @obj it "does copy the cause" do begin - raise StandardError, "the cause" + raise StandardError rescue StandardError => cause begin - raise RuntimeError, "the consequence" + raise RuntimeError rescue RuntimeError => e - e.cause.should equal(cause) - e.dup.cause.should equal(cause) + e.cause.should.equal?(cause) + e.dup.cause.should.equal?(cause) end end end diff --git a/spec/ruby/core/exception/equal_value_spec.rb b/spec/ruby/core/exception/equal_value_spec.rb index e8f3ce0f8d7c9d..b76b3bcd4a1e3c 100644 --- a/spec/ruby/core/exception/equal_value_spec.rb +++ b/spec/ruby/core/exception/equal_value_spec.rb @@ -31,10 +31,10 @@ it "returns false if the two exceptions inherit from Exception but have different classes" do one = RuntimeError.new("message") one.set_backtrace [__dir__] - one.should be_kind_of(Exception) + one.should.is_a?(Exception) two = TypeError.new("message") two.set_backtrace [__dir__] - two.should be_kind_of(Exception) + two.should.is_a?(Exception) one.should_not == two end diff --git a/spec/ruby/core/exception/errno_spec.rb b/spec/ruby/core/exception/errno_spec.rb index 1ab42777004f1d..36beae997629dc 100644 --- a/spec/ruby/core/exception/errno_spec.rb +++ b/spec/ruby/core/exception/errno_spec.rb @@ -4,21 +4,21 @@ describe "Errno::EINVAL.new" do it "can be called with no arguments" do exc = Errno::EINVAL.new - exc.should be_an_instance_of(Errno::EINVAL) + exc.should.instance_of?(Errno::EINVAL) exc.errno.should == Errno::EINVAL::Errno exc.message.should == "Invalid argument" end it "accepts an optional custom message" do exc = Errno::EINVAL.new('custom message') - exc.should be_an_instance_of(Errno::EINVAL) + exc.should.instance_of?(Errno::EINVAL) exc.errno.should == Errno::EINVAL::Errno exc.message.should == "Invalid argument - custom message" end it "accepts an optional custom message and location" do exc = Errno::EINVAL.new('custom message', 'location') - exc.should be_an_instance_of(Errno::EINVAL) + exc.should.instance_of?(Errno::EINVAL) exc.errno.should == Errno::EINVAL::Errno exc.message.should == "Invalid argument @ location - custom message" end @@ -28,7 +28,7 @@ it "can be subclassed" do ExceptionSpecs::EMFILESub = Class.new(Errno::EMFILE) exc = ExceptionSpecs::EMFILESub.new - exc.should be_an_instance_of(ExceptionSpecs::EMFILESub) + exc.should.instance_of?(ExceptionSpecs::EMFILESub) ensure ExceptionSpecs.send(:remove_const, :EMFILESub) end @@ -47,7 +47,7 @@ describe "Errno::ENOTSUP" do it "is defined" do - Errno.should have_constant(:ENOTSUP) + Errno.should.const_defined?(:ENOTSUP, false) end it "is the same class as Errno::EOPNOTSUPP if they represent the same errno value" do diff --git a/spec/ruby/core/exception/exception_spec.rb b/spec/ruby/core/exception/exception_spec.rb index d6f5283bd9e47a..f5424cdabdf74b 100644 --- a/spec/ruby/core/exception/exception_spec.rb +++ b/spec/ruby/core/exception/exception_spec.rb @@ -20,7 +20,7 @@ it "returns an exception of the same class as self with the message given as argument" do e = RuntimeError.new e2 = e.exception("message") - e2.should be_an_instance_of(RuntimeError) + e2.should.instance_of?(RuntimeError) e2.message.should == "message" end @@ -62,7 +62,7 @@ def initialize(val) it "returns an exception of the same class as self with the message given as argument, but without reinitializing" do e = CustomArgumentError.new(:boom) e2 = e.exception("message") - e2.should be_an_instance_of(CustomArgumentError) + e2.should.instance_of?(CustomArgumentError) e2.val.should == :boom e2.message.should == "message" end diff --git a/spec/ruby/core/exception/exit_value_spec.rb b/spec/ruby/core/exception/exit_value_spec.rb index 99987dd1bcb5c0..bb6cff183121c4 100644 --- a/spec/ruby/core/exception/exit_value_spec.rb +++ b/spec/ruby/core/exception/exit_value_spec.rb @@ -6,7 +6,7 @@ def get_me_a_return end it "returns the value given to return" do - -> { get_me_a_return.call }.should raise_error(LocalJumpError) { |e| + -> { get_me_a_return.call }.should.raise(LocalJumpError) { |e| e.exit_value.should == 42 } end diff --git a/spec/ruby/core/exception/frozen_error_spec.rb b/spec/ruby/core/exception/frozen_error_spec.rb index af2e92566192eb..a28f524b5400bd 100644 --- a/spec/ruby/core/exception/frozen_error_spec.rb +++ b/spec/ruby/core/exception/frozen_error_spec.rb @@ -3,7 +3,7 @@ describe "FrozenError.new" do it "should take optional receiver argument" do o = Object.new - FrozenError.new("msg", receiver: o).receiver.should equal(o) + FrozenError.new("msg", receiver: o).receiver.should.equal?(o) end end @@ -13,8 +13,8 @@ begin def o.x; end rescue => e - e.should be_kind_of(FrozenError) - e.receiver.should equal(o) + e.should.is_a?(FrozenError) + e.receiver.should.equal?(o) else raise end @@ -30,10 +30,10 @@ def o.x; end -> { def object.x; end - }.should raise_error(FrozenError, "can't modify frozen #{msg_class}: #{object}") + }.should.raise(FrozenError, "can't modify frozen #{msg_class}: #{object}") object = [].freeze - -> { object << nil }.should raise_error(FrozenError, "can't modify frozen Array: []") + -> { object << nil }.should.raise(FrozenError, "can't modify frozen Array: []") end end @@ -48,7 +48,7 @@ def object.modify; @a = 2 end # CRuby's message contains multiple whitespaces before '...'. # So handle both multiple and single whitespace. - -> { object.modify }.should raise_error(FrozenError, /can't modify frozen .*?: \s*.../) + -> { object.modify }.should.raise(FrozenError, /can't modify frozen .*?: \s*.../) end end end diff --git a/spec/ruby/core/exception/full_message_spec.rb b/spec/ruby/core/exception/full_message_spec.rb index 0761d2b40ce850..5a5e0a2b3a0090 100644 --- a/spec/ruby/core/exception/full_message_spec.rb +++ b/spec/ruby/core/exception/full_message_spec.rb @@ -6,10 +6,10 @@ e.set_backtrace(["a.rb:1", "b.rb:2"]) full_message = e.full_message - full_message.should include "RuntimeError" - full_message.should include "Some runtime error" - full_message.should include "a.rb:1" - full_message.should include "b.rb:2" + full_message.should.include? "RuntimeError" + full_message.should.include? "Some runtime error" + full_message.should.include? "a.rb:1" + full_message.should.include? "b.rb:2" end it "supports :highlight option and adds escape sequences to highlight some strings" do @@ -141,8 +141,8 @@ exception = e end - exception.full_message.should include "main exception" - exception.full_message.should include "the cause" + exception.full_message.should.include? "main exception" + exception.full_message.should.include? "the cause" end it 'contains all the chain of exceptions' do @@ -160,9 +160,9 @@ exception = e end - exception.full_message.should include "last exception" - exception.full_message.should include "intermediate exception" - exception.full_message.should include "origin exception" + exception.full_message.should.include? "last exception" + exception.full_message.should.include? "intermediate exception" + exception.full_message.should.include? "origin exception" end it "relies on #detailed_message" do @@ -219,8 +219,8 @@ class << e end full_message = e.full_message - full_message.should include "RuntimeError" - full_message.should include "Some runtime error" - full_message.should include "Some other runtime error" + full_message.should.include? "RuntimeError" + full_message.should.include? "Some runtime error" + full_message.should.include? "Some other runtime error" end end diff --git a/spec/ruby/core/exception/io_error_spec.rb b/spec/ruby/core/exception/io_error_spec.rb index ab8a72518ff2c0..940d5be87613b5 100644 --- a/spec/ruby/core/exception/io_error_spec.rb +++ b/spec/ruby/core/exception/io_error_spec.rb @@ -3,14 +3,14 @@ describe "IO::EAGAINWaitReadable" do it "combines Errno::EAGAIN and IO::WaitReadable" do IO::EAGAINWaitReadable.superclass.should == Errno::EAGAIN - IO::EAGAINWaitReadable.ancestors.should include IO::WaitReadable + IO::EAGAINWaitReadable.ancestors.should.include? IO::WaitReadable end it "is the same as IO::EWOULDBLOCKWaitReadable if Errno::EAGAIN is the same as Errno::EWOULDBLOCK" do if Errno::EAGAIN.equal? Errno::EWOULDBLOCK - IO::EAGAINWaitReadable.should equal IO::EWOULDBLOCKWaitReadable + IO::EAGAINWaitReadable.should.equal? IO::EWOULDBLOCKWaitReadable else - IO::EAGAINWaitReadable.should_not equal IO::EWOULDBLOCKWaitReadable + IO::EAGAINWaitReadable.should_not.equal? IO::EWOULDBLOCKWaitReadable end end end @@ -18,21 +18,21 @@ describe "IO::EWOULDBLOCKWaitReadable" do it "combines Errno::EWOULDBLOCK and IO::WaitReadable" do IO::EWOULDBLOCKWaitReadable.superclass.should == Errno::EWOULDBLOCK - IO::EAGAINWaitReadable.ancestors.should include IO::WaitReadable + IO::EAGAINWaitReadable.ancestors.should.include? IO::WaitReadable end end describe "IO::EAGAINWaitWritable" do it "combines Errno::EAGAIN and IO::WaitWritable" do IO::EAGAINWaitWritable.superclass.should == Errno::EAGAIN - IO::EAGAINWaitWritable.ancestors.should include IO::WaitWritable + IO::EAGAINWaitWritable.ancestors.should.include? IO::WaitWritable end it "is the same as IO::EWOULDBLOCKWaitWritable if Errno::EAGAIN is the same as Errno::EWOULDBLOCK" do if Errno::EAGAIN.equal? Errno::EWOULDBLOCK - IO::EAGAINWaitWritable.should equal IO::EWOULDBLOCKWaitWritable + IO::EAGAINWaitWritable.should.equal? IO::EWOULDBLOCKWaitWritable else - IO::EAGAINWaitWritable.should_not equal IO::EWOULDBLOCKWaitWritable + IO::EAGAINWaitWritable.should_not.equal? IO::EWOULDBLOCKWaitWritable end end end @@ -40,6 +40,6 @@ describe "IO::EWOULDBLOCKWaitWritable" do it "combines Errno::EWOULDBLOCK and IO::WaitWritable" do IO::EWOULDBLOCKWaitWritable.superclass.should == Errno::EWOULDBLOCK - IO::EAGAINWaitWritable.ancestors.should include IO::WaitWritable + IO::EAGAINWaitWritable.ancestors.should.include? IO::WaitWritable end end diff --git a/spec/ruby/core/exception/name_spec.rb b/spec/ruby/core/exception/name_spec.rb index c8a49b40e21b95..6e0e99d1941af2 100644 --- a/spec/ruby/core/exception/name_spec.rb +++ b/spec/ruby/core/exception/name_spec.rb @@ -4,25 +4,25 @@ it "returns a method name as a symbol" do -> { doesnt_exist - }.should raise_error(NameError) {|e| e.name.should == :doesnt_exist } + }.should.raise(NameError) {|e| e.name.should == :doesnt_exist } end it "returns a constant name as a symbol" do -> { DoesntExist - }.should raise_error(NameError) {|e| e.name.should == :DoesntExist } + }.should.raise(NameError) {|e| e.name.should == :DoesntExist } end it "returns a constant name without namespace as a symbol" do -> { Object::DoesntExist - }.should raise_error(NameError) {|e| e.name.should == :DoesntExist } + }.should.raise(NameError) {|e| e.name.should == :DoesntExist } end it "returns a class variable name as a symbol" do -> { eval("class singleton_class::A; @@doesnt_exist end", binding, __FILE__, __LINE__) - }.should raise_error(NameError) { |e| e.name.should == :@@doesnt_exist } + }.should.raise(NameError) { |e| e.name.should == :@@doesnt_exist } end it "returns the first argument passed to the method when a NameError is raised from #instance_variable_get" do @@ -30,7 +30,7 @@ -> { Object.new.instance_variable_get(invalid_ivar_name) - }.should raise_error(NameError) {|e| e.name.should equal(invalid_ivar_name) } + }.should.raise(NameError) {|e| e.name.should.equal?(invalid_ivar_name) } end it "returns the first argument passed to the method when a NameError is raised from #class_variable_get" do @@ -38,6 +38,6 @@ -> { Object.class_variable_get(invalid_cvar_name) - }.should raise_error(NameError) {|e| e.name.should equal(invalid_cvar_name) } + }.should.raise(NameError) {|e| e.name.should.equal?(invalid_cvar_name) } end end diff --git a/spec/ruby/core/exception/no_method_error_spec.rb b/spec/ruby/core/exception/no_method_error_spec.rb index d20878c6e3328d..9f9210408202ad 100644 --- a/spec/ruby/core/exception/no_method_error_spec.rb +++ b/spec/ruby/core/exception/no_method_error_spec.rb @@ -35,7 +35,7 @@ NoMethodErrorSpecs::NoMethodErrorB.new.foo(1,a) rescue Exception => e e.args.should == [1,a] - e.args[1].should equal a + e.args[1].should.equal? a end end end @@ -45,7 +45,7 @@ begin NoMethodErrorSpecs::NoMethodErrorD.new.foo rescue Exception => e - e.should be_kind_of(NoMethodError) + e.should.is_a?(NoMethodError) end end @@ -53,7 +53,7 @@ begin NoMethodErrorSpecs::NoMethodErrorC.new.a_protected_method rescue Exception => e - e.should be_kind_of(NoMethodError) + e.should.is_a?(NoMethodError) end end @@ -61,7 +61,7 @@ begin NoMethodErrorSpecs::NoMethodErrorC.new.a_private_method rescue Exception => e - e.should be_kind_of(NoMethodError) + e.should.is_a?(NoMethodError) e.message.lines[0].should =~ /private method [`']a_private_method' called for / end end diff --git a/spec/ruby/core/exception/reason_spec.rb b/spec/ruby/core/exception/reason_spec.rb index 210bbc9725e675..d7022768b63a96 100644 --- a/spec/ruby/core/exception/reason_spec.rb +++ b/spec/ruby/core/exception/reason_spec.rb @@ -6,7 +6,7 @@ def get_me_a_return end it "returns 'return' for a return" do - -> { get_me_a_return.call }.should raise_error(LocalJumpError) { |e| + -> { get_me_a_return.call }.should.raise(LocalJumpError) { |e| e.reason.should == :return } end diff --git a/spec/ruby/core/exception/receiver_spec.rb b/spec/ruby/core/exception/receiver_spec.rb index d1c23b67be9c7d..6ecf640ad8e2b7 100644 --- a/spec/ruby/core/exception/receiver_spec.rb +++ b/spec/ruby/core/exception/receiver_spec.rb @@ -11,31 +11,31 @@ def call_undefined_class_variable; @@doesnt_exist end -> { receiver.doesnt_exist - }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) } + }.should.raise(NameError) {|e| e.receiver.should.equal?(receiver) } end it "returns the Object class when an undefined constant is called without namespace" do -> { DoesntExist - }.should raise_error(NameError) {|e| e.receiver.should equal(Object) } + }.should.raise(NameError) {|e| e.receiver.should.equal?(Object) } end it "returns a class when an undefined constant is called" do -> { NameErrorSpecs::ReceiverClass::DoesntExist - }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) } + }.should.raise(NameError) {|e| e.receiver.should.equal?(NameErrorSpecs::ReceiverClass) } end it "returns the Object class when an undefined class variable is called" do -> { eval("class singleton_class::A; @@doesnt_exist end", binding, __FILE__, __LINE__) - }.should raise_error(NameError) {|e| e.receiver.should equal(singleton_class::A) } + }.should.raise(NameError) {|e| e.receiver.should.equal?(singleton_class::A) } end it "returns a class when an undefined class variable is called in a subclass' namespace" do -> { NameErrorSpecs::ReceiverClass.new.call_undefined_class_variable - }.should raise_error(NameError) {|e| e.receiver.should equal(NameErrorSpecs::ReceiverClass) } + }.should.raise(NameError) {|e| e.receiver.should.equal?(NameErrorSpecs::ReceiverClass) } end it "returns the receiver when raised from #instance_variable_get" do @@ -43,16 +43,16 @@ def call_undefined_class_variable; @@doesnt_exist end -> { receiver.instance_variable_get("invalid_ivar_name") - }.should raise_error(NameError) {|e| e.receiver.should equal(receiver) } + }.should.raise(NameError) {|e| e.receiver.should.equal?(receiver) } end it "returns the receiver when raised from #class_variable_get" do -> { Object.class_variable_get("invalid_cvar_name") - }.should raise_error(NameError) {|e| e.receiver.should equal(Object) } + }.should.raise(NameError) {|e| e.receiver.should.equal?(Object) } end it "raises an ArgumentError when the receiver is none" do - -> { NameError.new.receiver }.should raise_error(ArgumentError) + -> { NameError.new.receiver }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/exception/result_spec.rb b/spec/ruby/core/exception/result_spec.rb index d42fcdffcb99ad..451ff43af5c8b6 100644 --- a/spec/ruby/core/exception/result_spec.rb +++ b/spec/ruby/core/exception/result_spec.rb @@ -14,8 +14,8 @@ def obj.each it "returns the method-returned-object from an Enumerator" do @enum.next @enum.next - -> { @enum.next }.should raise_error(StopIteration) { |error| - error.result.should equal(:method_returned) + -> { @enum.next }.should.raise(StopIteration) { |error| + error.result.should.equal?(:method_returned) } end end diff --git a/spec/ruby/core/exception/shared/new.rb b/spec/ruby/core/exception/shared/new.rb index bcde8ee4b29313..048fd14dd2dc37 100644 --- a/spec/ruby/core/exception/shared/new.rb +++ b/spec/ruby/core/exception/shared/new.rb @@ -1,6 +1,6 @@ describe :exception_new, shared: true do it "creates a new instance of Exception" do - Exception.should be_ancestor_of(Exception.send(@method).class) + Exception.send(@method).class.ancestors.should.include?(Exception) end it "sets the message of the Exception when passes a message" do @@ -12,7 +12,7 @@ end it "returns the exception when it has a custom constructor" do - ExceptionSpecs::ConstructorException.send(@method).should be_kind_of(ExceptionSpecs::ConstructorException) + ExceptionSpecs::ConstructorException.send(@method).should.is_a?(ExceptionSpecs::ConstructorException) end end diff --git a/spec/ruby/core/exception/shared/set_backtrace.rb b/spec/ruby/core/exception/shared/set_backtrace.rb index c6213b42b48920..934bf3dc5f152e 100644 --- a/spec/ruby/core/exception/shared/set_backtrace.rb +++ b/spec/ruby/core/exception/shared/set_backtrace.rb @@ -43,22 +43,22 @@ it "accepts nil" do err = @method.call(nil) - err.backtrace.should be_nil + err.backtrace.should == nil end it "raises a TypeError when passed a Symbol" do - -> { @method.call(:unhappy) }.should raise_error(TypeError) + -> { @method.call(:unhappy) }.should.raise(TypeError) end it "raises a TypeError when the Array contains a Symbol" do - -> { @method.call(["String", :unhappy]) }.should raise_error(TypeError) + -> { @method.call(["String", :unhappy]) }.should.raise(TypeError) end it "raises a TypeError when the array contains nil" do - -> { @method.call(["String", nil]) }.should raise_error(TypeError) + -> { @method.call(["String", nil]) }.should.raise(TypeError) end it "raises a TypeError when the argument is a nested array" do - -> { @method.call(["String", ["String"]]) }.should raise_error(TypeError) + -> { @method.call(["String", ["String"]]) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/exception/signal_exception_spec.rb b/spec/ruby/core/exception/signal_exception_spec.rb index 1a0940743f7a6e..010181bc557951 100644 --- a/spec/ruby/core/exception/signal_exception_spec.rb +++ b/spec/ruby/core/exception/signal_exception_spec.rb @@ -9,7 +9,7 @@ end it "raises an exception with an invalid signal number" do - -> { SignalException.new(100000) }.should raise_error(ArgumentError) + -> { SignalException.new(100000) }.should.raise(ArgumentError) end it "takes a signal name without SIG prefix as the first argument" do @@ -27,11 +27,11 @@ end it "raises an exception with an invalid signal name" do - -> { SignalException.new("NONEXISTENT") }.should raise_error(ArgumentError) + -> { SignalException.new("NONEXISTENT") }.should.raise(ArgumentError) end it "raises an exception with an invalid first argument type" do - -> { SignalException.new(Object.new) }.should raise_error(ArgumentError) + -> { SignalException.new(Object.new) }.should.raise(ArgumentError) end it "takes a signal symbol without SIG prefix as the first argument" do @@ -49,7 +49,7 @@ end it "raises an exception with an invalid signal name" do - -> { SignalException.new(:NONEXISTENT) }.should raise_error(ArgumentError) + -> { SignalException.new(:NONEXISTENT) }.should.raise(ArgumentError) end it "takes an optional message argument with a signal number" do @@ -60,7 +60,7 @@ end it "raises an exception for an optional argument with a signal name" do - -> { SignalException.new("INT","name") }.should raise_error(ArgumentError) + -> { SignalException.new("INT","name") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/exception/signm_spec.rb b/spec/ruby/core/exception/signm_spec.rb index 4adff3b5eea1f1..cabcc7ad584ff9 100644 --- a/spec/ruby/core/exception/signm_spec.rb +++ b/spec/ruby/core/exception/signm_spec.rb @@ -2,7 +2,7 @@ describe "SignalException#signm" do it "returns the signal name" do - -> { Process.kill(:TERM, Process.pid) }.should raise_error(SignalException) { |e| + -> { Process.kill(:TERM, Process.pid) }.should.raise(SignalException) { |e| e.signm.should == 'SIGTERM' } end diff --git a/spec/ruby/core/exception/signo_spec.rb b/spec/ruby/core/exception/signo_spec.rb index 62fc321516c6c5..46e79a8daf191e 100644 --- a/spec/ruby/core/exception/signo_spec.rb +++ b/spec/ruby/core/exception/signo_spec.rb @@ -2,7 +2,7 @@ describe "SignalException#signo" do it "returns the signal number" do - -> { Process.kill(:TERM, Process.pid) }.should raise_error(SignalException) { |e| + -> { Process.kill(:TERM, Process.pid) }.should.raise(SignalException) { |e| e.signo.should == Signal.list['TERM'] } end diff --git a/spec/ruby/core/exception/standard_error_spec.rb b/spec/ruby/core/exception/standard_error_spec.rb index 17e98ce7f02c37..b05d247f676ac8 100644 --- a/spec/ruby/core/exception/standard_error_spec.rb +++ b/spec/ruby/core/exception/standard_error_spec.rb @@ -18,6 +18,6 @@ end it "does not rescue superclass of StandardError" do - -> { begin; raise Exception; rescue; end }.should raise_error(Exception) + -> { begin; raise Exception; rescue; end }.should.raise(Exception) end end diff --git a/spec/ruby/core/exception/status_spec.rb b/spec/ruby/core/exception/status_spec.rb index 8ace00fe100a0c..7369b0815d4814 100644 --- a/spec/ruby/core/exception/status_spec.rb +++ b/spec/ruby/core/exception/status_spec.rb @@ -2,7 +2,7 @@ describe "SystemExit#status" do it "returns the exit status" do - -> { exit 42 }.should raise_error(SystemExit) { |e| + -> { exit 42 }.should.raise(SystemExit) { |e| e.status.should == 42 } end diff --git a/spec/ruby/core/exception/success_spec.rb b/spec/ruby/core/exception/success_spec.rb index 6f217433401360..5ab8f94454ba7c 100644 --- a/spec/ruby/core/exception/success_spec.rb +++ b/spec/ruby/core/exception/success_spec.rb @@ -2,13 +2,13 @@ describe "SystemExit#success?" do it "returns true if the process exited successfully" do - -> { exit 0 }.should raise_error(SystemExit) { |e| + -> { exit 0 }.should.raise(SystemExit) { |e| e.should.success? } end it "returns false if the process exited unsuccessfully" do - -> { exit(-1) }.should raise_error(SystemExit) { |e| + -> { exit(-1) }.should.raise(SystemExit) { |e| e.should_not.success? } end diff --git a/spec/ruby/core/exception/syntax_error_spec.rb b/spec/ruby/core/exception/syntax_error_spec.rb index 4c713a35077d2a..66eb5649aa4049 100644 --- a/spec/ruby/core/exception/syntax_error_spec.rb +++ b/spec/ruby/core/exception/syntax_error_spec.rb @@ -6,7 +6,7 @@ -> { eval("if true", TOPLEVEL_BINDING, filename) - }.should raise_error(SyntaxError) { |e| + }.should.raise(SyntaxError) { |e| e.path.should == filename } end @@ -16,7 +16,7 @@ -> { require_relative "fixtures/syntax_error" - }.should raise_error(SyntaxError) { |e| e.path.should == expected_path } + }.should.raise(SyntaxError) { |e| e.path.should == expected_path } end it "returns nil when constructed directly" do diff --git a/spec/ruby/core/exception/system_call_error_spec.rb b/spec/ruby/core/exception/system_call_error_spec.rb index 4fe51901c84241..da01c5b6b0ffde 100644 --- a/spec/ruby/core/exception/system_call_error_spec.rb +++ b/spec/ruby/core/exception/system_call_error_spec.rb @@ -14,8 +14,8 @@ def initialize end exc = ExceptionSpecs::SCESub.new - ScratchPad.recorded.should equal(:initialize) - exc.should be_an_instance_of(ExceptionSpecs::SCESub) + ScratchPad.recorded.should.equal?(:initialize) + exc.should.instance_of?(ExceptionSpecs::SCESub) ensure ExceptionSpecs.send(:remove_const, :SCESub) end @@ -31,7 +31,7 @@ def initialize end it "requires at least one argument" do - -> { SystemCallError.new }.should raise_error(ArgumentError) + -> { SystemCallError.new }.should.raise(ArgumentError) end it "accepts single Integer argument as errno" do @@ -44,16 +44,16 @@ def initialize end it "constructs a SystemCallError for an unknown error number" do - SystemCallError.new(-2**24).should be_an_instance_of(SystemCallError) - SystemCallError.new(-1).should be_an_instance_of(SystemCallError) - SystemCallError.new(@unknown_errno).should be_an_instance_of(SystemCallError) - SystemCallError.new(2**24).should be_an_instance_of(SystemCallError) + SystemCallError.new(-2**24).should.instance_of?(SystemCallError) + SystemCallError.new(-1).should.instance_of?(SystemCallError) + SystemCallError.new(@unknown_errno).should.instance_of?(SystemCallError) + SystemCallError.new(2**24).should.instance_of?(SystemCallError) end it "constructs the appropriate Errno class" do e = SystemCallError.new(@example_errno) - e.should be_kind_of(SystemCallError) - e.should be_an_instance_of(@example_errno_class) + e.should.is_a?(SystemCallError) + e.should.instance_of?(@example_errno_class) end it "sets an error message corresponding to an appropriate Errno class" do @@ -63,14 +63,14 @@ def initialize it "accepts an optional custom message preceding the errno" do exc = SystemCallError.new("custom message", @example_errno) - exc.should be_an_instance_of(@example_errno_class) + exc.should.instance_of?(@example_errno_class) exc.errno.should == @example_errno exc.message.should == 'Invalid argument - custom message' end it "accepts an optional third argument specifying the location" do exc = SystemCallError.new("custom message", @example_errno, "location") - exc.should be_an_instance_of(@example_errno_class) + exc.should.instance_of?(@example_errno_class) exc.errno.should == @example_errno exc.message.should == 'Invalid argument @ location - custom message' end @@ -90,7 +90,7 @@ def initialize end it "treats nil errno as unknown error value" do - SystemCallError.new(nil).should be_an_instance_of(SystemCallError) + SystemCallError.new(nil).should.instance_of?(SystemCallError) end it "treats nil custom message as if it is not passed at all" do @@ -111,15 +111,15 @@ def initialize end it "raises TypeError if message is not a String" do - -> { SystemCallError.new(:foo, 1) }.should raise_error(TypeError, /no implicit conversion of Symbol into String/) + -> { SystemCallError.new(:foo, 1) }.should.raise(TypeError, /no implicit conversion of Symbol into String/) end it "raises TypeError if errno is not an Integer" do - -> { SystemCallError.new('foo', 'bar') }.should raise_error(TypeError, /no implicit conversion of String into Integer/) + -> { SystemCallError.new('foo', 'bar') }.should.raise(TypeError, /no implicit conversion of String into Integer/) end it "raises RangeError if errno is a Complex not convertible to Integer" do - -> { SystemCallError.new('foo', Complex(2.9, 1)) }.should raise_error(RangeError, /can't convert/) + -> { SystemCallError.new('foo', Complex(2.9, 1)) }.should.raise(RangeError, /can't convert/) end end diff --git a/spec/ruby/core/false/dup_spec.rb b/spec/ruby/core/false/dup_spec.rb index 1a569a2f4fdb1f..b0eb85529ec5ad 100644 --- a/spec/ruby/core/false/dup_spec.rb +++ b/spec/ruby/core/false/dup_spec.rb @@ -2,6 +2,6 @@ describe "FalseClass#dup" do it "returns self" do - false.dup.should equal(false) + false.dup.should.equal?(false) end end diff --git a/spec/ruby/core/false/falseclass_spec.rb b/spec/ruby/core/false/falseclass_spec.rb index c018ef2421ef8e..8dfe5ae891ecaf 100644 --- a/spec/ruby/core/false/falseclass_spec.rb +++ b/spec/ruby/core/false/falseclass_spec.rb @@ -4,12 +4,12 @@ it ".allocate raises a TypeError" do -> do FalseClass.allocate - end.should raise_error(TypeError) + end.should.raise(TypeError) end it ".new is undefined" do -> do FalseClass.new - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/false/singleton_method_spec.rb b/spec/ruby/core/false/singleton_method_spec.rb index 16dc85d67c64b7..72aee8609a942d 100644 --- a/spec/ruby/core/false/singleton_method_spec.rb +++ b/spec/ruby/core/false/singleton_method_spec.rb @@ -2,10 +2,10 @@ describe "FalseClass#singleton_method" do it "raises regardless of whether FalseClass defines the method" do - -> { false.singleton_method(:foo) }.should raise_error(NameError) + -> { false.singleton_method(:foo) }.should.raise(NameError) begin def (false).foo; end - -> { false.singleton_method(:foo) }.should raise_error(NameError) + -> { false.singleton_method(:foo) }.should.raise(NameError) ensure FalseClass.send(:remove_method, :foo) end diff --git a/spec/ruby/core/false/to_s_spec.rb b/spec/ruby/core/false/to_s_spec.rb index 62f67f6f55c722..9e24be26a20253 100644 --- a/spec/ruby/core/false/to_s_spec.rb +++ b/spec/ruby/core/false/to_s_spec.rb @@ -10,6 +10,6 @@ end it "always returns the same string" do - false.to_s.should equal(false.to_s) + false.to_s.should.equal?(false.to_s) end end diff --git a/spec/ruby/core/fiber/alive_spec.rb b/spec/ruby/core/fiber/alive_spec.rb index a1df5824356d69..6fb1229d950589 100644 --- a/spec/ruby/core/fiber/alive_spec.rb +++ b/spec/ruby/core/fiber/alive_spec.rb @@ -3,18 +3,18 @@ describe "Fiber#alive?" do it "returns true for a Fiber that hasn't had #resume called" do fiber = Fiber.new { true } - fiber.alive?.should be_true + fiber.alive?.should == true end # FIXME: Better description? it "returns true for a Fiber that's yielded to the caller" do fiber = Fiber.new { Fiber.yield } fiber.resume - fiber.alive?.should be_true + fiber.alive?.should == true end it "returns true when called from its Fiber" do - fiber = Fiber.new { fiber.alive?.should be_true } + fiber = Fiber.new { fiber.alive?.should == true } fiber.resume end @@ -28,17 +28,17 @@ it "returns false for a Fiber that's dead" do fiber = Fiber.new { true } fiber.resume - -> { fiber.resume }.should raise_error(FiberError) - fiber.alive?.should be_false + -> { fiber.resume }.should.raise(FiberError) + fiber.alive?.should == false end it "always returns false for a dead Fiber" do fiber = Fiber.new { true } fiber.resume - -> { fiber.resume }.should raise_error(FiberError) - fiber.alive?.should be_false - -> { fiber.resume }.should raise_error(FiberError) - fiber.alive?.should be_false - fiber.alive?.should be_false + -> { fiber.resume }.should.raise(FiberError) + fiber.alive?.should == false + -> { fiber.resume }.should.raise(FiberError) + fiber.alive?.should == false + fiber.alive?.should == false end end diff --git a/spec/ruby/core/fiber/current_spec.rb b/spec/ruby/core/fiber/current_spec.rb index b93df77a8996a4..cc5c9117b62438 100644 --- a/spec/ruby/core/fiber/current_spec.rb +++ b/spec/ruby/core/fiber/current_spec.rb @@ -3,20 +3,20 @@ describe "Fiber.current" do it "returns the root Fiber when called outside of a Fiber" do root = Fiber.current - root.should be_an_instance_of(Fiber) + root.should.instance_of?(Fiber) # We can always transfer to the root Fiber; it will never die 5.times do - root.transfer.should be_nil - root.alive?.should be_true + root.transfer.should == nil + root.alive?.should == true end end it "returns the current Fiber when called from a Fiber" do fiber = Fiber.new do this = Fiber.current - this.should be_an_instance_of(Fiber) + this.should.instance_of?(Fiber) this.should == fiber - this.alive?.should be_true + this.alive?.should == true end fiber.resume end @@ -26,9 +26,9 @@ fiber = Fiber.new do states << :fiber this = Fiber.current - this.should be_an_instance_of(Fiber) + this.should.instance_of?(Fiber) this.should == fiber - this.alive?.should be_true + this.alive?.should == true end fiber2 = Fiber.new do diff --git a/spec/ruby/core/fiber/new_spec.rb b/spec/ruby/core/fiber/new_spec.rb index b43c1386be9631..d31167496d0d4e 100644 --- a/spec/ruby/core/fiber/new_spec.rb +++ b/spec/ruby/core/fiber/new_spec.rb @@ -4,7 +4,7 @@ it "creates a fiber from the given block" do fiber = Fiber.new {} fiber.resume - fiber.should be_an_instance_of(Fiber) + fiber.should.instance_of?(Fiber) end it "creates a fiber from a subclass" do @@ -12,17 +12,17 @@ class MyFiber < Fiber end fiber = MyFiber.new {} fiber.resume - fiber.should be_an_instance_of(MyFiber) + fiber.should.instance_of?(MyFiber) end it "raises an ArgumentError if called without a block" do - -> { Fiber.new }.should raise_error(ArgumentError) + -> { Fiber.new }.should.raise(ArgumentError) end it "does not invoke the block" do invoked = false fiber = Fiber.new { invoked = true } - invoked.should be_false + invoked.should == false fiber.resume end diff --git a/spec/ruby/core/fiber/raise_spec.rb b/spec/ruby/core/fiber/raise_spec.rb index 51d64bba549900..107e5bd4ce007b 100644 --- a/spec/ruby/core/fiber/raise_spec.rb +++ b/spec/ruby/core/fiber/raise_spec.rb @@ -4,7 +4,7 @@ describe "Fiber#raise" do it "is a public method" do - Fiber.public_instance_methods.should include(:raise) + Fiber.public_instance_methods.should.include?(:raise) end it_behaves_like :kernel_raise, :raise, FiberSpecs::NewFiberToRaise @@ -14,51 +14,51 @@ end it 'raises RuntimeError by default' do - -> { FiberSpecs::NewFiberToRaise.raise }.should raise_error(RuntimeError) + -> { FiberSpecs::NewFiberToRaise.raise }.should.raise(RuntimeError) end it "raises FiberError if Fiber is not born" do fiber = Fiber.new { true } - -> { fiber.raise }.should raise_error(FiberError, "cannot raise exception on unborn fiber") + -> { fiber.raise }.should.raise(FiberError, "cannot raise exception on unborn fiber") end it "raises FiberError if Fiber is dead" do fiber = Fiber.new { true } fiber.resume - -> { fiber.raise }.should raise_error(FiberError, /dead fiber called|attempt to resume a terminated fiber/) + -> { fiber.raise }.should.raise(FiberError, /dead fiber called|attempt to resume a terminated fiber/) end it 'accepts error class' do - -> { FiberSpecs::NewFiberToRaise.raise FiberSpecs::CustomError }.should raise_error(FiberSpecs::CustomError) + -> { FiberSpecs::NewFiberToRaise.raise FiberSpecs::CustomError }.should.raise(FiberSpecs::CustomError) end it 'accepts error message' do - -> { FiberSpecs::NewFiberToRaise.raise "error message" }.should raise_error(RuntimeError, "error message") + -> { FiberSpecs::NewFiberToRaise.raise "error message" }.should.raise(RuntimeError, "error message") end it 'does not accept array of backtrace information only' do - -> { FiberSpecs::NewFiberToRaise.raise ['foo'] }.should raise_error(TypeError) + -> { FiberSpecs::NewFiberToRaise.raise ['foo'] }.should.raise(TypeError) end it 'does not accept integer' do - -> { FiberSpecs::NewFiberToRaise.raise 100 }.should raise_error(TypeError) + -> { FiberSpecs::NewFiberToRaise.raise 100 }.should.raise(TypeError) end it 'accepts error class with error message' do - -> { FiberSpecs::NewFiberToRaise.raise FiberSpecs::CustomError, 'test error' }.should raise_error(FiberSpecs::CustomError, 'test error') + -> { FiberSpecs::NewFiberToRaise.raise FiberSpecs::CustomError, 'test error' }.should.raise(FiberSpecs::CustomError, 'test error') end it 'accepts error class with error message and backtrace information' do -> { FiberSpecs::NewFiberToRaise.raise FiberSpecs::CustomError, 'test error', ['foo', 'boo'] - }.should raise_error(FiberSpecs::CustomError) { |e| + }.should.raise(FiberSpecs::CustomError) { |e| e.message.should == 'test error' e.backtrace.should == ['foo', 'boo'] } end it 'does not accept only error message and backtrace information' do - -> { FiberSpecs::NewFiberToRaise.raise 'test error', ['foo', 'boo'] }.should raise_error(TypeError) + -> { FiberSpecs::NewFiberToRaise.raise 'test error', ['foo', 'boo'] }.should.raise(TypeError) end it "raises a FiberError if invoked from a different Thread" do @@ -67,15 +67,15 @@ Thread.new do -> { fiber.raise - }.should raise_error(FiberError, "fiber called across threads") + }.should.raise(FiberError, "fiber called across threads") end.join end it "kills Fiber" do fiber = Fiber.new { Fiber.yield :first; :second } fiber.resume - -> { fiber.raise }.should raise_error - -> { fiber.resume }.should raise_error(FiberError, /dead fiber called|attempt to resume a terminated fiber/) + -> { fiber.raise }.should.raise + -> { fiber.resume }.should.raise(FiberError, /dead fiber called|attempt to resume a terminated fiber/) end it "returns to calling fiber after raise" do @@ -107,13 +107,13 @@ -> do f2.raise(RuntimeError, "Expected error") - end.should raise_error(RuntimeError, "Expected error") + end.should.raise(RuntimeError, "Expected error") end it "raises on itself" do -> do Fiber.current.raise(RuntimeError, "Expected error") - end.should raise_error(RuntimeError, "Expected error") + end.should.raise(RuntimeError, "Expected error") end it "should raise on parent fiber" do @@ -128,7 +128,7 @@ -> do f2.resume - end.should raise_error(RuntimeError, "Expected error") + end.should.raise(RuntimeError, "Expected error") end end @@ -136,6 +136,6 @@ root = Fiber.current fiber = Fiber.new { root.transfer } fiber.transfer - -> { fiber.raise "msg" }.should raise_error(RuntimeError, "msg") + -> { fiber.raise "msg" }.should.raise(RuntimeError, "msg") end end diff --git a/spec/ruby/core/fiber/resume_spec.rb b/spec/ruby/core/fiber/resume_spec.rb index 4b20f4b4bfba18..e183cc10d99c5b 100644 --- a/spec/ruby/core/fiber/resume_spec.rb +++ b/spec/ruby/core/fiber/resume_spec.rb @@ -30,7 +30,7 @@ it "raises a FiberError if the Fiber tries to resume itself" do fiber = Fiber.new { fiber.resume } - -> { fiber.resume }.should raise_error(FiberError, /current fiber/) + -> { fiber.resume }.should.raise(FiberError, /current fiber/) end it "returns control to the calling Fiber if called from one" do @@ -78,6 +78,6 @@ 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/) + -> { fiber1.resume }.should.raise(FiberError, /attempt to resume a resuming fiber/) end end diff --git a/spec/ruby/core/fiber/shared/resume.rb b/spec/ruby/core/fiber/shared/resume.rb index 5ee27d1d24f281..ff4bb72c73c0eb 100644 --- a/spec/ruby/core/fiber/shared/resume.rb +++ b/spec/ruby/core/fiber/shared/resume.rb @@ -9,7 +9,7 @@ Thread.new do -> { fiber.send(@method) - }.should raise_error(FiberError) + }.should.raise(FiberError) end.join # Check the Fiber can still be used @@ -20,12 +20,12 @@ invoked = false fiber = Fiber.new { invoked = true } fiber.send(@method) - invoked.should be_true + invoked.should == true end it "returns the last value encountered on first invocation" do fiber = Fiber.new { 1+1; true } - fiber.send(@method).should be_true + fiber.send(@method).should == true end it "runs until the end of the block" do @@ -37,22 +37,22 @@ it "accepts any number of arguments" do fiber = Fiber.new { |a| } - -> { fiber.send(@method, *(1..10).to_a) }.should_not raise_error + -> { fiber.send(@method, *(1..10).to_a) }.should_not.raise end it "raises a FiberError if the Fiber is dead" do fiber = Fiber.new { true } fiber.send(@method) - -> { fiber.send(@method) }.should raise_error(FiberError) + -> { fiber.send(@method) }.should.raise(FiberError) end it "raises a LocalJumpError if the block includes a return statement" do fiber = Fiber.new { return; } - -> { fiber.send(@method) }.should raise_error(LocalJumpError) + -> { fiber.send(@method) }.should.raise(LocalJumpError) end it "raises a LocalJumpError if the block includes a break statement" do fiber = Fiber.new { break; } - -> { fiber.send(@method) }.should raise_error(LocalJumpError) + -> { fiber.send(@method) }.should.raise(LocalJumpError) end end diff --git a/spec/ruby/core/fiber/shared/scheduler.rb b/spec/ruby/core/fiber/shared/scheduler.rb index 19bfb75e3e1313..04bdded53a04bb 100644 --- a/spec/ruby/core/fiber/shared/scheduler.rb +++ b/spec/ruby/core/fiber/shared/scheduler.rb @@ -8,7 +8,7 @@ end -> { suppress_warning { Fiber.set_scheduler(scheduler) } - }.should raise_error(ArgumentError, /Scheduler must implement ##{missing_method}/) + }.should.raise(ArgumentError, /Scheduler must implement ##{missing_method}/) end end @@ -40,12 +40,12 @@ end suppress_warning { Fiber.set_scheduler(scheduler) } Fiber.set_scheduler(nil) - Fiber.scheduler.should be_nil + Fiber.scheduler.should == nil end it "can assign a nil scheduler multiple times" do Fiber.set_scheduler(nil) Fiber.set_scheduler(nil) - Fiber.scheduler.should be_nil + Fiber.scheduler.should == nil end end diff --git a/spec/ruby/core/fiber/storage_spec.rb b/spec/ruby/core/fiber/storage_spec.rb index def8af46cec414..a3f6bf9cad07c8 100644 --- a/spec/ruby/core/fiber/storage_spec.rb +++ b/spec/ruby/core/fiber/storage_spec.rb @@ -19,15 +19,15 @@ end it "cannot create a fiber with non-hash storage" do - -> { Fiber.new(storage: 42) {} }.should raise_error(TypeError) + -> { Fiber.new(storage: 42) {} }.should.raise(TypeError) end it "cannot create a fiber with a frozen hash as storage" do - -> { Fiber.new(storage: {life: 43}.freeze) {} }.should raise_error(FrozenError) + -> { Fiber.new(storage: {life: 43}.freeze) {} }.should.raise(FrozenError) end it "cannot create a fiber with a storage hash with non-symbol keys" do - -> { Fiber.new(storage: {life: 43, Object.new => 44}) {} }.should raise_error(TypeError) + -> { Fiber.new(storage: {life: 43, Object.new => 44}) {} }.should.raise(TypeError) end end @@ -36,7 +36,7 @@ f = Fiber.new(storage: {life: 42}) { nil } -> { f.storage - }.should raise_error(ArgumentError, /Fiber storage can only be accessed from the Fiber it belongs to/) + }.should.raise(ArgumentError, /Fiber storage can only be accessed from the Fiber it belongs to/) end end @@ -59,15 +59,15 @@ end it "can't set the storage of the fiber to non-hash" do - -> { Fiber.current.storage = 42 }.should raise_error(TypeError) + -> { Fiber.current.storage = 42 }.should.raise(TypeError) end it "can't set the storage of the fiber to a frozen hash" do - -> { Fiber.current.storage = {life: 43}.freeze }.should raise_error(FrozenError) + -> { Fiber.current.storage = {life: 43}.freeze }.should.raise(FrozenError) end it "can't set the storage of the fiber to a hash with non-symbol keys" do - -> { Fiber.current.storage = {life: 43, Object.new => 44} }.should raise_error(TypeError) + -> { Fiber.current.storage = {life: 43, Object.new => 44} }.should.raise(TypeError) end end @@ -77,11 +77,11 @@ end it "returns nil if the key is not present in the storage of the current fiber" do - Fiber.new(storage: {life: 42}) { Fiber[:death] }.resume.should be_nil + Fiber.new(storage: {life: 42}) { Fiber[:death] }.resume.should == nil end it "returns nil if the current fiber has no storage" do - Fiber.new { Fiber[:life] }.resume.should be_nil + Fiber.new { Fiber[:life] }.resume.should == nil end it "can use dynamically defined keys" do @@ -92,7 +92,7 @@ it "can't use invalid keys" do invalid_keys = [Object.new, 12] invalid_keys.each do |key| - -> { Fiber[key] }.should raise_error(TypeError) + -> { Fiber[key] }.should.raise(TypeError) end end @@ -118,7 +118,7 @@ def key.to_str; "Foo"; end it "does not call #to_sym on the key" do key = mock("key") key.should_not_receive(:to_sym) - -> { Fiber[key] }.should raise_error(TypeError) + -> { Fiber[key] }.should.raise(TypeError) end it "can access the storage of the parent fiber" do @@ -129,7 +129,7 @@ def key.to_str; "Foo"; end end it "can't access the storage of the fiber with non-symbol keys" do - -> { Fiber[Object.new] }.should raise_error(TypeError) + -> { Fiber[Object.new] }.should.raise(TypeError) end end @@ -156,7 +156,7 @@ def key.to_str; "Foo"; end end it "can't access the storage of the fiber with non-symbol keys" do - -> { Fiber[Object.new] = 44 }.should raise_error(TypeError) + -> { Fiber[Object.new] = 44 }.should.raise(TypeError) end it "deletes the fiber storage key when assigning nil" do diff --git a/spec/ruby/core/fiber/transfer_spec.rb b/spec/ruby/core/fiber/transfer_spec.rb index 238721475dd84b..d8737aeeb3bbb8 100644 --- a/spec/ruby/core/fiber/transfer_spec.rb +++ b/spec/ruby/core/fiber/transfer_spec.rb @@ -37,12 +37,12 @@ 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) + -> { fiber2.transfer }.should.raise(FiberError) end it "raises a FiberError when transferring to a Fiber which resumes itself" do fiber = Fiber.new { fiber.resume } - -> { fiber.transfer }.should raise_error(FiberError) + -> { fiber.transfer }.should.raise(FiberError) end it "works if Fibers in different Threads each transfer to a Fiber in the same Thread" do @@ -58,7 +58,7 @@ end io_fiber.transfer(Fiber.current) value = Object.new - io_fiber.transfer(value).should equal value + io_fiber.transfer(value).should.equal? value end.join end end diff --git a/spec/ruby/core/fiber/yield_spec.rb b/spec/ruby/core/fiber/yield_spec.rb index b010912c8726f3..12ec6ebcef7350 100644 --- a/spec/ruby/core/fiber/yield_spec.rb +++ b/spec/ruby/core/fiber/yield_spec.rb @@ -18,7 +18,7 @@ it "returns nil to the caller if given no arguments" do fiber = Fiber.new { true; Fiber.yield; true } - fiber.resume.should be_nil + fiber.resume.should == nil fiber.resume end @@ -44,6 +44,6 @@ end it "raises a FiberError if called from the root Fiber" do - ->{ Fiber.yield }.should raise_error(FiberError) + ->{ Fiber.yield }.should.raise(FiberError) end end diff --git a/spec/ruby/core/file/absolute_path_spec.rb b/spec/ruby/core/file/absolute_path_spec.rb index 315eead34fe934..fc12985a75b734 100644 --- a/spec/ruby/core/file/absolute_path_spec.rb +++ b/spec/ruby/core/file/absolute_path_spec.rb @@ -6,47 +6,47 @@ end it "returns true if it's an absolute pathname" do - File.absolute_path?(@abs).should be_true + File.absolute_path?(@abs).should == true end it "returns false if it's a relative path" do - File.absolute_path?(File.basename(__FILE__)).should be_false + File.absolute_path?(File.basename(__FILE__)).should == false end it "returns false if it's a tricky relative path" do - File.absolute_path?("C:foo\\bar").should be_false + File.absolute_path?("C:foo\\bar").should == false end it "does not expand '~' to a home directory." do - File.absolute_path?('~').should be_false + File.absolute_path?('~').should == false end it "does not expand '~user' to a home directory." do path = File.dirname(@abs) Dir.chdir(path) do - File.absolute_path?('~user').should be_false + File.absolute_path?('~user').should == false end end it "calls #to_path on its argument" do mock = mock_to_path(File.expand_path(__FILE__)) - File.absolute_path?(mock).should be_true + File.absolute_path?(mock).should == true end platform_is_not :windows do it "takes into consideration the platform's root" do - File.absolute_path?("C:\\foo\\bar").should be_false - File.absolute_path?("C:/foo/bar").should be_false - File.absolute_path?("/foo/bar\\baz").should be_true + File.absolute_path?("C:\\foo\\bar").should == false + File.absolute_path?("C:/foo/bar").should == false + File.absolute_path?("/foo/bar\\baz").should == true end end platform_is :windows do it "takes into consideration the platform path separator(s)" do - File.absolute_path?("C:\\foo\\bar").should be_true - File.absolute_path?("C:/foo/bar").should be_true - File.absolute_path?("/foo/bar\\baz").should be_false + File.absolute_path?("C:\\foo\\bar").should == true + File.absolute_path?("C:/foo/bar").should == true + File.absolute_path?("/foo/bar\\baz").should == false end end end diff --git a/spec/ruby/core/file/atime_spec.rb b/spec/ruby/core/file/atime_spec.rb index e47e70e5acf35b..5c6c110eec43f3 100644 --- a/spec/ruby/core/file/atime_spec.rb +++ b/spec/ruby/core/file/atime_spec.rb @@ -12,7 +12,7 @@ it "returns the last access time for the named file as a Time object" do File.atime(@file) - File.atime(@file).should be_kind_of(Time) + File.atime(@file).should.is_a?(Time) end platform_is :linux, :windows do @@ -35,7 +35,7 @@ end it "raises an Errno::ENOENT exception if the file is not found" do - -> { File.atime('a_fake_file') }.should raise_error(Errno::ENOENT) + -> { File.atime('a_fake_file') }.should.raise(Errno::ENOENT) end it "accepts an object that has a #to_path method" do @@ -55,6 +55,6 @@ it "returns the last access time to self" do @file.atime - @file.atime.should be_kind_of(Time) + @file.atime.should.is_a?(Time) end end diff --git a/spec/ruby/core/file/basename_spec.rb b/spec/ruby/core/file/basename_spec.rb index 66a5b56ed9a11a..77afe5c22fbf4e 100644 --- a/spec/ruby/core/file/basename_spec.rb +++ b/spec/ruby/core/file/basename_spec.rb @@ -42,7 +42,7 @@ end it "returns an string" do - File.basename("foo").should be_kind_of(String) + File.basename("foo").should.is_a?(String) end it "returns the basename for unix format" do @@ -105,10 +105,10 @@ end it "raises a TypeError if the arguments are not String types" do - -> { File.basename(nil) }.should raise_error(TypeError) - -> { File.basename(1) }.should raise_error(TypeError) - -> { File.basename("bar.txt", 1) }.should raise_error(TypeError) - -> { File.basename(true) }.should raise_error(TypeError) + -> { File.basename(nil) }.should.raise(TypeError) + -> { File.basename(1) }.should.raise(TypeError) + -> { File.basename("bar.txt", 1) }.should.raise(TypeError) + -> { File.basename(true) }.should.raise(TypeError) end it "accepts an object that has a #to_path method" do @@ -116,7 +116,7 @@ end it "raises an ArgumentError if passed more than two arguments" do - -> { File.basename('bar.txt', '.txt', '.txt') }.should raise_error(ArgumentError) + -> { File.basename('bar.txt', '.txt', '.txt') }.should.raise(ArgumentError) end # specific to MS Windows @@ -155,7 +155,7 @@ it "handles Shift JIS 0x5C (\\) as second byte of a multi-byte sequence" do # dir\fileソname.txt path = "dir\\file\x83\x5cname.txt".b.force_encoding(Encoding::SHIFT_JIS) - path.valid_encoding?.should be_true + path.valid_encoding?.should == true File.basename(path).should == "file\x83\x5cname.txt".b.force_encoding(Encoding::SHIFT_JIS) end end @@ -166,7 +166,7 @@ -> { File.basename(path) - }.should raise_error(Encoding::CompatibilityError) + }.should.raise(Encoding::CompatibilityError) end end @@ -196,7 +196,7 @@ else File.basename(original) end - result.should_not equal(original) + result.should_not.equal?(original) result.frozen?.should == false end end diff --git a/spec/ruby/core/file/birthtime_spec.rb b/spec/ruby/core/file/birthtime_spec.rb index f82eaf7ccaf6a2..039fd7572c2fc5 100644 --- a/spec/ruby/core/file/birthtime_spec.rb +++ b/spec/ruby/core/file/birthtime_spec.rb @@ -17,7 +17,7 @@ it "returns the birth time for the named file as a Time object" do File.birthtime(@file) - File.birthtime(@file).should be_kind_of(Time) + File.birthtime(@file).should.is_a?(Time) rescue NotImplementedError => e e.message.should.start_with?(*not_implemented_messages) end @@ -30,7 +30,7 @@ end it "raises an Errno::ENOENT exception if the file is not found" do - -> { File.birthtime('bogus') }.should raise_error(Errno::ENOENT) + -> { File.birthtime('bogus') }.should.raise(Errno::ENOENT) rescue NotImplementedError => e e.message.should.start_with?(*not_implemented_messages) end @@ -48,7 +48,7 @@ it "returns the birth time for self" do @file.birthtime - @file.birthtime.should be_kind_of(Time) + @file.birthtime.should.is_a?(Time) rescue NotImplementedError => e e.message.should.start_with?(*not_implemented_messages) end diff --git a/spec/ruby/core/file/chmod_spec.rb b/spec/ruby/core/file/chmod_spec.rb index 5ca15c97486d4b..e0fd10ceb1e004 100644 --- a/spec/ruby/core/file/chmod_spec.rb +++ b/spec/ruby/core/file/chmod_spec.rb @@ -16,8 +16,8 @@ end it "raises RangeError with too large values" do - -> { @file.chmod(2**64) }.should raise_error(RangeError) - -> { @file.chmod(-2**63 - 1) }.should raise_error(RangeError) + -> { @file.chmod(2**64) }.should.raise(RangeError) + -> { @file.chmod(-2**63 - 1) }.should.raise(RangeError) end it "invokes to_int on non-integer argument" do @@ -97,8 +97,8 @@ end it "raises RangeError with too large values" do - -> { File.chmod(2**64, @file) }.should raise_error(RangeError) - -> { File.chmod(-2**63 - 1, @file) }.should raise_error(RangeError) + -> { File.chmod(2**64, @file) }.should.raise(RangeError) + -> { File.chmod(-2**63 - 1, @file) }.should.raise(RangeError) end it "accepts an object that has a #to_path method" do @@ -106,13 +106,13 @@ end it "throws a TypeError if the given path is not coercible into a string" do - -> { File.chmod(0, []) }.should raise_error(TypeError) + -> { File.chmod(0, []) }.should.raise(TypeError) end it "raises an error for a non existent path" do -> { File.chmod(0644, "#{@file}.not.existing") - }.should raise_error(Errno::ENOENT) + }.should.raise(Errno::ENOENT) end it "invokes to_int on non-integer argument" do diff --git a/spec/ruby/core/file/chown_spec.rb b/spec/ruby/core/file/chown_spec.rb index 4db0e3712c2152..3353aafc700e75 100644 --- a/spec/ruby/core/file/chown_spec.rb +++ b/spec/ruby/core/file/chown_spec.rb @@ -68,7 +68,7 @@ it "raises an error for a non existent path" do -> { File.chown(nil, nil, "#{@fname}_not_existing") - }.should raise_error(Errno::ENOENT) + }.should.raise(Errno::ENOENT) end end diff --git a/spec/ruby/core/file/constants/constants_spec.rb b/spec/ruby/core/file/constants/constants_spec.rb index bba248c21e20ad..9d9c1c3b250933 100644 --- a/spec/ruby/core/file/constants/constants_spec.rb +++ b/spec/ruby/core/file/constants/constants_spec.rb @@ -7,7 +7,7 @@ "RDWR", "TRUNC", "WRONLY", "SHARE_DELETE"].each do |const| describe "File::Constants::#{const}" do it "is defined" do - File::Constants.const_defined?(const).should be_true + File::Constants.const_defined?(const).should == true end end end @@ -15,7 +15,7 @@ platform_is :windows do describe "File::Constants::BINARY" do it "is defined" do - File::Constants.const_defined?(:BINARY).should be_true + File::Constants.const_defined?(:BINARY).should == true end end end @@ -24,7 +24,7 @@ ["NOCTTY", "SYNC"].each do |const| describe "File::Constants::#{const}" do it "is defined" do - File::Constants.const_defined?(const).should be_true + File::Constants.const_defined?(const).should == true end end end diff --git a/spec/ruby/core/file/ctime_spec.rb b/spec/ruby/core/file/ctime_spec.rb index 718f26d5cc9f8d..cf37d1f4eeca96 100644 --- a/spec/ruby/core/file/ctime_spec.rb +++ b/spec/ruby/core/file/ctime_spec.rb @@ -11,7 +11,7 @@ it "returns the change time for the named file (the time at which directory information about the file was changed, not the file itself)." do File.ctime(@file) - File.ctime(@file).should be_kind_of(Time) + File.ctime(@file).should.is_a?(Time) end platform_is :linux, :windows do @@ -33,7 +33,7 @@ end it "raises an Errno::ENOENT exception if the file is not found" do - -> { File.ctime('bogus') }.should raise_error(Errno::ENOENT) + -> { File.ctime('bogus') }.should.raise(Errno::ENOENT) end end @@ -49,6 +49,6 @@ it "returns the change time for the named file (the time at which directory information about the file was changed, not the file itself)." do @file.ctime - @file.ctime.should be_kind_of(Time) + @file.ctime.should.is_a?(Time) end end diff --git a/spec/ruby/core/file/dirname_spec.rb b/spec/ruby/core/file/dirname_spec.rb index 1b006af7839f17..855148a6844739 100644 --- a/spec/ruby/core/file/dirname_spec.rb +++ b/spec/ruby/core/file/dirname_spec.rb @@ -25,7 +25,7 @@ it "raises ArgumentError if the level is negative" do -> { File.dirname('/home/jason', -1) - }.should raise_error(ArgumentError, "negative level: -1") + }.should.raise(ArgumentError, "negative level: -1") end it "returns '/' when level exceeds the number of segments in the path" do @@ -41,7 +41,7 @@ def object.to_int; 2; end end it "returns a String" do - File.dirname("foo").should be_kind_of(String) + File.dirname("foo").should.is_a?(String) end it "does not modify its argument" do @@ -83,7 +83,7 @@ def object.to_int; 2; end path = "/foo/bar".encode(enc) -> { File.dirname(path) - }.should raise_error(Encoding::CompatibilityError) + }.should.raise(Encoding::CompatibilityError) end end @@ -96,7 +96,7 @@ def object.to_int; 2; end it "handles Shift JIS 0x5C (\\) as second byte of a multi-byte sequence" do # dir/fileソname.txt path = "dir/file\x83\x5cname.txt".b.force_encoding(Encoding::SHIFT_JIS) - path.valid_encoding?.should be_true + path.valid_encoding?.should == true File.dirname(path).should == "dir" end @@ -124,7 +124,7 @@ def object.to_int; 2; end it "handles Shift JIS 0x5C (\\) as second byte of a multi-byte sequence (windows)" do # dir\fileソname.txt path = "dir\\file\x83\x5cname.txt".b.force_encoding(Encoding::SHIFT_JIS) - path.valid_encoding?.should be_true + path.valid_encoding?.should == true File.dirname(path).should == "dir" end end @@ -134,10 +134,10 @@ def object.to_int; 2; end end it "raises a TypeError if not passed a String type" do - -> { File.dirname(nil) }.should raise_error(TypeError) - -> { File.dirname(0) }.should raise_error(TypeError) - -> { File.dirname(true) }.should raise_error(TypeError) - -> { File.dirname(false) }.should raise_error(TypeError) + -> { File.dirname(nil) }.should.raise(TypeError) + -> { File.dirname(0) }.should.raise(TypeError) + -> { File.dirname(true) }.should.raise(TypeError) + -> { File.dirname(false) }.should.raise(TypeError) end # Windows specific tests diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb index 1abcf93900c3a8..160494f1453fe0 100644 --- a/spec/ruby/core/file/expand_path_spec.rb +++ b/spec/ruby/core/file/expand_path_spec.rb @@ -92,7 +92,7 @@ end it "raises an ArgumentError if the path is not valid" do - -> { File.expand_path("~a_not_existing_user") }.should raise_error(ArgumentError) + -> { File.expand_path("~a_not_existing_user") }.should.raise(ArgumentError) end it "expands ~ENV['USER'] to the user's home directory" do @@ -117,9 +117,9 @@ end it "raises a TypeError if not passed a String type" do - -> { File.expand_path(1) }.should raise_error(TypeError) - -> { File.expand_path(nil) }.should raise_error(TypeError) - -> { File.expand_path(true) }.should raise_error(TypeError) + -> { File.expand_path(1) }.should.raise(TypeError) + -> { File.expand_path(nil) }.should.raise(TypeError) + -> { File.expand_path(true) }.should.raise(TypeError) end platform_is_not :windows do @@ -138,10 +138,10 @@ Encoding.default_external = Encoding::SHIFT_JIS path = "./a".dup.force_encoding Encoding::CP1251 - File.expand_path(path).encoding.should equal(Encoding::CP1251) + File.expand_path(path).encoding.should.equal?(Encoding::CP1251) weird_path = [222, 173, 190, 175].pack('C*') - File.expand_path(weird_path).encoding.should equal(Encoding::BINARY) + File.expand_path(weird_path).encoding.should.equal?(Encoding::BINARY) end platform_is_not :windows do @@ -159,7 +159,7 @@ platform_is_not :windows do it "raises an Encoding::CompatibilityError if the external encoding is not compatible" do Encoding.default_external = Encoding::UTF_16BE - -> { File.expand_path("./a") }.should raise_error(Encoding::CompatibilityError) + -> { File.expand_path("./a") }.should.raise(Encoding::CompatibilityError) end end @@ -179,7 +179,7 @@ str = FileSpecs::SubString.new "./a/b/../c" path = File.expand_path(str, @base) path.should == "#{@base}/a/c" - path.should be_an_instance_of(String) + path.should.instance_of?(String) end end @@ -244,7 +244,7 @@ it "raises an ArgumentError when passed '~' if HOME == ''" do ENV["HOME"] = "" - -> { File.expand_path("~") }.should raise_error(ArgumentError) + -> { File.expand_path("~") }.should.raise(ArgumentError) end end @@ -259,7 +259,7 @@ it "raises an ArgumentError" do ENV["HOME"] = "non-absolute" - -> { File.expand_path("~") }.should raise_error(ArgumentError, 'non-absolute home') + -> { File.expand_path("~") }.should.raise(ArgumentError, 'non-absolute home') end end end diff --git a/spec/ruby/core/file/extname_spec.rb b/spec/ruby/core/file/extname_spec.rb index d20cf813d9c451..995d0ea31a0910 100644 --- a/spec/ruby/core/file/extname_spec.rb +++ b/spec/ruby/core/file/extname_spec.rb @@ -57,15 +57,15 @@ end it "raises a TypeError if not passed a String type" do - -> { File.extname(nil) }.should raise_error(TypeError) - -> { File.extname(0) }.should raise_error(TypeError) - -> { File.extname(true) }.should raise_error(TypeError) - -> { File.extname(false) }.should raise_error(TypeError) + -> { File.extname(nil) }.should.raise(TypeError) + -> { File.extname(0) }.should.raise(TypeError) + -> { File.extname(true) }.should.raise(TypeError) + -> { File.extname(false) }.should.raise(TypeError) end it "raises an ArgumentError if not passed one argument" do - -> { File.extname }.should raise_error(ArgumentError) - -> { File.extname("foo.bar", "foo.baz") }.should raise_error(ArgumentError) + -> { File.extname }.should.raise(ArgumentError) + -> { File.extname("foo.bar", "foo.baz") }.should.raise(ArgumentError) end diff --git a/spec/ruby/core/file/ftype_spec.rb b/spec/ruby/core/file/ftype_spec.rb index cdddc404dc146f..ab9f76b79b8fb2 100644 --- a/spec/ruby/core/file/ftype_spec.rb +++ b/spec/ruby/core/file/ftype_spec.rb @@ -7,19 +7,19 @@ end it "raises ArgumentError if not given exactly one filename" do - -> { File.ftype }.should raise_error(ArgumentError) - -> { File.ftype('blah', 'bleh') }.should raise_error(ArgumentError) + -> { File.ftype }.should.raise(ArgumentError) + -> { File.ftype('blah', 'bleh') }.should.raise(ArgumentError) end it "raises Errno::ENOENT if the file is not valid" do -> { File.ftype("/#{$$}#{Time.now.to_f}") - }.should raise_error(Errno::ENOENT) + }.should.raise(Errno::ENOENT) end it "returns a String" do FileSpecs.normal_file do |file| - File.ftype(file).should be_kind_of(String) + File.ftype(file).should.is_a?(String) end end diff --git a/spec/ruby/core/file/inspect_spec.rb b/spec/ruby/core/file/inspect_spec.rb index 148e789c62c9c4..fe87429e8dcc65 100644 --- a/spec/ruby/core/file/inspect_spec.rb +++ b/spec/ruby/core/file/inspect_spec.rb @@ -12,6 +12,6 @@ end it "returns a String" do - @file.inspect.should be_an_instance_of(String) + @file.inspect.should.instance_of?(String) end end diff --git a/spec/ruby/core/file/join_spec.rb b/spec/ruby/core/file/join_spec.rb index 0feedbae93c499..0f0911ea310941 100644 --- a/spec/ruby/core/file/join_spec.rb +++ b/spec/ruby/core/file/join_spec.rb @@ -52,7 +52,7 @@ it "returns a duplicate string when given a single argument" do str = "usr" File.join(str).should == str - File.join(str).should_not equal(str) + File.join(str).should_not.equal?(str) end it "supports any number of arguments" do @@ -104,15 +104,15 @@ it "raises an ArgumentError if passed a recursive array" do a = ["a"] a << a - -> { File.join a }.should raise_error(ArgumentError) + -> { File.join a }.should.raise(ArgumentError) end it "raises a TypeError exception when args are nil" do - -> { File.join nil }.should raise_error(TypeError) + -> { File.join nil }.should.raise(TypeError) end it "calls #to_str" do - -> { File.join(mock('x')) }.should raise_error(TypeError) + -> { File.join(mock('x')) }.should.raise(TypeError) bin = mock("bin") bin.should_receive(:to_str).exactly(:twice).and_return("bin") @@ -129,7 +129,7 @@ end it "calls #to_path" do - -> { File.join(mock('x')) }.should raise_error(TypeError) + -> { File.join(mock('x')) }.should.raise(TypeError) bin = mock("bin") bin.should_receive(:to_path).exactly(:twice).and_return("bin") @@ -138,10 +138,10 @@ end it "raises errors for null bytes" do - -> { File.join("\x00x", "metadata.gz") }.should raise_error(ArgumentError) { |e| + -> { File.join("\x00x", "metadata.gz") }.should.raise(ArgumentError) { |e| e.message.should == 'string contains null byte' } - -> { File.join("metadata.gz", "\x00x") }.should raise_error(ArgumentError) { |e| + -> { File.join("metadata.gz", "\x00x") }.should.raise(ArgumentError) { |e| e.message.should == 'string contains null byte' } end diff --git a/spec/ruby/core/file/link_spec.rb b/spec/ruby/core/file/link_spec.rb index a5d5b4815fa32d..768ee4b0face92 100644 --- a/spec/ruby/core/file/link_spec.rb +++ b/spec/ruby/core/file/link_spec.rb @@ -22,18 +22,18 @@ it "raises an Errno::EEXIST if the target already exists" do File.link(@file, @link) - -> { File.link(@file, @link) }.should raise_error(Errno::EEXIST) + -> { File.link(@file, @link) }.should.raise(Errno::EEXIST) end it "raises an ArgumentError if not passed two arguments" do - -> { File.link }.should raise_error(ArgumentError) - -> { File.link(@file) }.should raise_error(ArgumentError) - -> { File.link(@file, @link, @file) }.should raise_error(ArgumentError) + -> { File.link }.should.raise(ArgumentError) + -> { File.link(@file) }.should.raise(ArgumentError) + -> { File.link(@file, @link, @file) }.should.raise(ArgumentError) end it "raises a TypeError if not passed String types" do - -> { File.link(@file, nil) }.should raise_error(TypeError) - -> { File.link(@file, 1) }.should raise_error(TypeError) + -> { File.link(@file, nil) }.should.raise(TypeError) + -> { File.link(@file, 1) }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/file/mkfifo_spec.rb b/spec/ruby/core/file/mkfifo_spec.rb index 19298c967c72f0..ce4a67fe310300 100644 --- a/spec/ruby/core/file/mkfifo_spec.rb +++ b/spec/ruby/core/file/mkfifo_spec.rb @@ -19,13 +19,13 @@ context "when path passed is not a String value" do it "raises a TypeError" do - -> { File.mkfifo(:"/tmp/fifo") }.should raise_error(TypeError) + -> { File.mkfifo(:"/tmp/fifo") }.should.raise(TypeError) end end context "when path does not exist" do it "raises an Errno::ENOENT exception" do - -> { File.mkfifo("/bogus/path") }.should raise_error(Errno::ENOENT) + -> { File.mkfifo("/bogus/path") }.should.raise(Errno::ENOENT) end end diff --git a/spec/ruby/core/file/mtime_spec.rb b/spec/ruby/core/file/mtime_spec.rb index 0e9c95caee310a..d83725e25d9ecc 100644 --- a/spec/ruby/core/file/mtime_spec.rb +++ b/spec/ruby/core/file/mtime_spec.rb @@ -11,7 +11,7 @@ end it "returns the modification Time of the file" do - File.mtime(@filename).should be_kind_of(Time) + File.mtime(@filename).should.is_a?(Time) File.mtime(@filename).should be_close(@mtime, TIME_TOLERANCE) end @@ -34,7 +34,7 @@ end it "raises an Errno::ENOENT exception if the file is not found" do - -> { File.mtime('bogus') }.should raise_error(Errno::ENOENT) + -> { File.mtime('bogus') }.should.raise(Errno::ENOENT) end end @@ -50,7 +50,7 @@ end it "returns the modification Time of the file" do - @f.mtime.should be_kind_of(Time) + @f.mtime.should.is_a?(Time) end end diff --git a/spec/ruby/core/file/new_spec.rb b/spec/ruby/core/file/new_spec.rb index 1e82a070b10dff..4cd2cb5dcb99c3 100644 --- a/spec/ruby/core/file/new_spec.rb +++ b/spec/ruby/core/file/new_spec.rb @@ -16,13 +16,13 @@ it "returns a new File with mode string" do @fh = File.new(@file, 'w') - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "returns a new File with mode num" do @fh = File.new(@file, @flags) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end @@ -30,7 +30,7 @@ rm_r @file File.umask(0011) @fh = File.new(@file, @flags, 0755) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) platform_is_not :windows do File.stat(@file).mode.to_s(8).should == "100744" end @@ -44,7 +44,7 @@ rm_r @file begin f = File.new(@file, "w", 0444) - -> { f.puts("test") }.should_not raise_error(IOError) + -> { f.puts("test") }.should_not.raise(IOError) ensure f.close end @@ -74,14 +74,14 @@ @fh = File.new(@file) fh_copy = File.new(@fh.fileno) fh_copy.autoclose = false - fh_copy.should be_kind_of(File) + fh_copy.should.is_a?(File) File.should.exist?(@file) end it "returns a new read-only File when mode is not specified" do @fh = File.new(@file) - -> { @fh.puts("test") }.should raise_error(IOError) + -> { @fh.puts("test") }.should.raise(IOError) @fh.read.should == "" File.should.exist?(@file) end @@ -89,68 +89,68 @@ it "returns a new read-only File when mode is not specified but flags option is present" do @fh = File.new(@file, flags: File::CREAT) - -> { @fh.puts("test") }.should raise_error(IOError) + -> { @fh.puts("test") }.should.raise(IOError) @fh.read.should == "" File.should.exist?(@file) end it "creates a new file when use File::EXCL mode" do @fh = File.new(@file, File::EXCL) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "raises an Errno::EEXIST if the file exists when create a new file with File::CREAT|File::EXCL" do - -> { @fh = File.new(@file, File::CREAT|File::EXCL) }.should raise_error(Errno::EEXIST) + -> { @fh = File.new(@file, File::CREAT|File::EXCL) }.should.raise(Errno::EEXIST) end it "creates a new file when use File::WRONLY|File::APPEND mode" do @fh = File.new(@file, File::WRONLY|File::APPEND) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "returns a new File when use File::APPEND mode" do @fh = File.new(@file, File::APPEND) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "returns a new File when use File::RDONLY|File::APPEND mode" do @fh = File.new(@file, File::RDONLY|File::APPEND) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "returns a new File when use File::RDONLY|File::WRONLY mode" do @fh = File.new(@file, File::RDONLY|File::WRONLY) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "creates a new file when use File::WRONLY|File::TRUNC mode" do @fh = File.new(@file, File::WRONLY|File::TRUNC) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "returns a new read-only File when use File::RDONLY|File::CREAT mode" do @fh = File.new(@file, File::RDONLY|File::CREAT) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) # it's read-only - -> { @fh.puts("test") }.should raise_error(IOError) + -> { @fh.puts("test") }.should.raise(IOError) @fh.read.should == "" end it "returns a new read-only File when use File::CREAT mode" do @fh = File.new(@file, File::CREAT) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) # it's read-only - -> { @fh.puts("test") }.should raise_error(IOError) + -> { @fh.puts("test") }.should.raise(IOError) @fh.read.should == "" end @@ -170,22 +170,22 @@ it "accepts options as a keyword argument" do @fh = File.new(@file, 'w', 0755, flags: @flags) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) @fh.close -> { @fh = File.new(@file, 'w', 0755, {flags: @flags}) - }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") + }.should.raise(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") end it "bitwise-ORs mode and flags option" do -> { @fh = File.new(@file, 'w', flags: File::EXCL) - }.should raise_error(Errno::EEXIST, /File exists/) + }.should.raise(Errno::EEXIST, /File exists/) -> { @fh = File.new(@file, mode: 'w', flags: File::EXCL) - }.should raise_error(Errno::EEXIST, /File exists/) + }.should.raise(Errno::EEXIST, /File exists/) end it "does not use the given block and warns to use File::open" do @@ -195,16 +195,16 @@ end it "raises a TypeError if the first parameter can't be coerced to a string" do - -> { File.new(true) }.should raise_error(TypeError) - -> { File.new(false) }.should raise_error(TypeError) + -> { File.new(true) }.should.raise(TypeError) + -> { File.new(false) }.should.raise(TypeError) end it "raises a TypeError if the first parameter is nil" do - -> { File.new(nil) }.should raise_error(TypeError) + -> { File.new(nil) }.should.raise(TypeError) end it "raises an Errno::EBADF if the first parameter is an invalid file descriptor" do - -> { File.new(-1) }.should raise_error(Errno::EBADF) + -> { File.new(-1) }.should.raise(Errno::EBADF) end platform_is_not :windows do @@ -213,7 +213,7 @@ -> { f = File.new(@fh.fileno, @flags) f.autoclose = false - }.should raise_error(Errno::EINVAL) + }.should.raise(Errno::EINVAL) end end diff --git a/spec/ruby/core/file/open_spec.rb b/spec/ruby/core/file/open_spec.rb index 6bfc16bbf97782..7318c3163672bd 100644 --- a/spec/ruby/core/file/open_spec.rb +++ b/spec/ruby/core/file/open_spec.rb @@ -40,7 +40,7 @@ it "propagates non-StandardErrors produced by close" do -> { File.open(@file, 'r') { |f| FileSpecs.make_closer f, Exception } - }.should raise_error(Exception) + }.should.raise(Exception) ScratchPad.recorded.should == [:file_opened, :file_closed] end @@ -48,7 +48,7 @@ it "propagates StandardErrors produced by close" do -> { File.open(@file, 'r') { |f| FileSpecs.make_closer f, StandardError } - }.should raise_error(StandardError) + }.should.raise(StandardError) ScratchPad.recorded.should == [:file_opened, :file_closed] end @@ -62,13 +62,13 @@ it "opens the file (basic case)" do @fh = File.open(@file) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "opens the file with unicode characters" do @fh = File.open(@unicode_path, "w") - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@unicode_path) end @@ -79,7 +79,7 @@ it "opens with mode string" do @fh = File.open(@file, 'w') - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end @@ -90,7 +90,7 @@ it "opens a file with mode num" do @fh = File.open(@file, @flags) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end @@ -101,7 +101,7 @@ it "opens a file with mode and permission as nil" do @fh = File.open(@file, nil, nil) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) end # For this test we delete the file first to reset the perms @@ -109,7 +109,7 @@ rm_r @file File.umask(0011) @fh = File.open(@file, @flags, 0755) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) platform_is_not :windows do @fh.lstat.mode.to_s(8).should == "100744" end @@ -161,69 +161,69 @@ @fh = File.open(@file) fh_copy = File.open(@fh.fileno) fh_copy.autoclose = false - fh_copy.should be_kind_of(File) + fh_copy.should.is_a?(File) File.should.exist?(@file) end it "opens a file that no exists when use File::WRONLY mode" do - -> { File.open(@nonexistent, File::WRONLY) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::WRONLY) }.should.raise(Errno::ENOENT) end it "opens a file that no exists when use File::RDONLY mode" do - -> { File.open(@nonexistent, File::RDONLY) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::RDONLY) }.should.raise(Errno::ENOENT) end it "opens a file that no exists when use 'r' mode" do - -> { File.open(@nonexistent, 'r') }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, 'r') }.should.raise(Errno::ENOENT) end it "opens a file that no exists when use File::EXCL mode" do - -> { File.open(@nonexistent, File::EXCL) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::EXCL) }.should.raise(Errno::ENOENT) end it "opens a file that no exists when use File::NONBLOCK mode" do - -> { File.open(@nonexistent, File::NONBLOCK) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::NONBLOCK) }.should.raise(Errno::ENOENT) end platform_is_not :openbsd, :windows do it "opens a file that no exists when use File::TRUNC mode" do - -> { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::TRUNC) }.should.raise(Errno::ENOENT) end end platform_is :openbsd, :windows do it "does not open a file that does no exists when using File::TRUNC mode" do - -> { File.open(@nonexistent, File::TRUNC) }.should raise_error(Errno::EINVAL) + -> { File.open(@nonexistent, File::TRUNC) }.should.raise(Errno::EINVAL) end end platform_is_not :windows do it "opens a file that no exists when use File::NOCTTY mode" do - -> { File.open(@nonexistent, File::NOCTTY) }.should raise_error(Errno::ENOENT) + -> { File.open(@nonexistent, File::NOCTTY) }.should.raise(Errno::ENOENT) end end it "opens a file that no exists when use File::CREAT mode" do @fh = File.open(@nonexistent, File::CREAT) { |f| f } - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "opens a file that no exists when use 'a' mode" do @fh = File.open(@nonexistent, 'a') { |f| f } - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "opens a file that no exists when use 'w' mode" do @fh = File.open(@nonexistent, 'w') { |f| f } - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end # Check the grants associated to the different open modes combinations. it "raises an ArgumentError exception when call with an unknown mode" do - -> { File.open(@file, "q") }.should raise_error(ArgumentError) + -> { File.open(@file, "q") }.should.raise(ArgumentError) end it "can read in a block when call open with RDONLY mode" do @@ -240,13 +240,13 @@ it "raises an IO exception when write in a block opened with RDONLY mode" do File.open(@file, File::RDONLY) do |f| - -> { f.puts "writing ..." }.should raise_error(IOError) + -> { f.puts "writing ..." }.should.raise(IOError) end end it "raises an IO exception when write in a block opened with 'r' mode" do File.open(@file, "r") do |f| - -> { f.puts "writing ..." }.should raise_error(IOError) + -> { f.puts "writing ..." }.should.raise(IOError) end end @@ -261,7 +261,7 @@ File.open(@file, File::WRONLY|File::RDONLY ) do |f| f.gets.should == nil end - }.should raise_error(IOError) + }.should.raise(IOError) end it "can write in a block when call open with WRONLY mode" do @@ -278,39 +278,39 @@ it "raises an IOError when read in a block opened with WRONLY mode" do File.open(@file, File::WRONLY) do |f| - -> { f.gets }.should raise_error(IOError) + -> { f.gets }.should.raise(IOError) end end it "raises an IOError when read in a block opened with 'w' mode" do File.open(@file, "w") do |f| - -> { f.gets }.should raise_error(IOError) + -> { f.gets }.should.raise(IOError) end end it "raises an IOError when read in a block opened with 'a' mode" do File.open(@file, "a") do |f| - -> { f.gets }.should raise_error(IOError) + -> { f.gets }.should.raise(IOError) end end it "raises an IOError when read in a block opened with 'a' mode" do File.open(@file, "a") do |f| f.puts("writing").should == nil - -> { f.gets }.should raise_error(IOError) + -> { f.gets }.should.raise(IOError) end end it "raises an IOError when read in a block opened with 'a' mode" do File.open(@file, File::WRONLY|File::APPEND ) do |f| - -> { f.gets }.should raise_error(IOError) + -> { f.gets }.should.raise(IOError) end end it "raises an IOError when read in a block opened with File::WRONLY|File::APPEND mode" do File.open(@file, File::WRONLY|File::APPEND ) do |f| f.puts("writing").should == nil - -> { f.gets }.should raise_error(IOError) + -> { f.gets }.should.raise(IOError) end end @@ -319,7 +319,7 @@ File.open(@file, File::RDONLY|File::APPEND ) do |f| f.puts("writing") end - }.should raise_error(IOError) + }.should.raise(IOError) end it "can read and write in a block when call open with RDWR mode" do @@ -336,7 +336,7 @@ File.open(@file, File::EXCL) do |f| f.puts("writing").should == nil end - }.should raise_error(IOError) + }.should.raise(IOError) end it "can read in a block when call open with File::EXCL mode" do @@ -359,12 +359,12 @@ File.open(@file, File::CREAT|File::EXCL) do |f| f.puts("writing") end - }.should raise_error(Errno::EEXIST) + }.should.raise(Errno::EEXIST) end it "creates a new file when use File::WRONLY|File::APPEND mode" do @fh = File.open(@file, File::WRONLY|File::APPEND) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end @@ -386,7 +386,7 @@ File.open(@file, File::RDONLY|File::APPEND) do |f| f.puts("writing").should == nil end - }.should raise_error(IOError) + }.should.raise(IOError) end platform_is_not :openbsd, :windows do @@ -407,7 +407,7 @@ fh1 = File.open(@file, "w") begin @fh = File.open(@file, File::WRONLY|File::TRUNC) - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) ensure fh1.close @@ -420,7 +420,7 @@ File.open(@file, File::TRUNC) do |f| f.puts("writing") end - }.should raise_error(IOError) + }.should.raise(IOError) end it "raises an Errno::EEXIST if the file exists when open with File::RDONLY|File::TRUNC" do @@ -428,7 +428,7 @@ File.open(@file, File::RDONLY|File::TRUNC) do |f| f.puts("writing").should == nil end - }.should raise_error(IOError) + }.should.raise(IOError) end end @@ -438,7 +438,7 @@ File.open(@file, File::TRUNC) do |f| f.puts("writing") end - }.should raise_error(Errno::EINVAL) + }.should.raise(Errno::EINVAL) end it "raises an Errno::EEXIST if the file exists when open with File::RDONLY|File::TRUNC" do @@ -446,7 +446,7 @@ File.open(@file, File::RDONLY|File::TRUNC) do |f| f.puts("writing").should == nil end - }.should raise_error(Errno::EINVAL) + }.should.raise(Errno::EINVAL) end end @@ -455,7 +455,7 @@ it "raises an Errno::EACCES when opening non-permitted file" do @fh = File.open(@file, "w") @fh.chmod(000) - -> { fh1 = File.open(@file); fh1.close }.should raise_error(Errno::EACCES) + -> { fh1 = File.open(@file); fh1.close }.should.raise(Errno::EACCES) end end end @@ -464,19 +464,19 @@ it "raises an Errno::EACCES when opening read-only file" do @fh = File.open(@file, "w") @fh.chmod(0444) - -> { File.open(@file, "w") }.should raise_error(Errno::EACCES) + -> { File.open(@file, "w") }.should.raise(Errno::EACCES) end end it "opens a file for binary read" do @fh = File.open(@file, "rb") - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end it "opens a file for binary write" do @fh = File.open(@file, "wb") - @fh.should be_kind_of(File) + @fh.should.is_a?(File) File.should.exist?(@file) end @@ -543,21 +543,21 @@ end it "raises a TypeError if passed a filename that is not a String or Integer type" do - -> { File.open(true) }.should raise_error(TypeError) - -> { File.open(false) }.should raise_error(TypeError) - -> { File.open(nil) }.should raise_error(TypeError) + -> { File.open(true) }.should.raise(TypeError) + -> { File.open(false) }.should.raise(TypeError) + -> { File.open(nil) }.should.raise(TypeError) end it "raises a SystemCallError if passed an invalid Integer type" do - -> { File.open(-1) }.should raise_error(SystemCallError) + -> { File.open(-1) }.should.raise(SystemCallError) end it "raises an ArgumentError if passed the wrong number of arguments" do - -> { File.open(@file, File::CREAT, 0755, 'test') }.should raise_error(ArgumentError) + -> { File.open(@file, File::CREAT, 0755, 'test') }.should.raise(ArgumentError) end it "raises an ArgumentError if passed an invalid string for mode" do - -> { File.open(@file, 'fake') }.should raise_error(ArgumentError) + -> { File.open(@file, 'fake') }.should.raise(ArgumentError) end it "defaults external_encoding to BINARY for binary modes" do @@ -567,16 +567,16 @@ it "accepts options as a keyword argument" do @fh = File.open(@file, 'w', 0755, flags: File::CREAT) - @fh.should be_an_instance_of(File) + @fh.should.instance_of?(File) -> { File.open(@file, 'w', 0755, {flags: File::CREAT}) - }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") + }.should.raise(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") end it "uses the second argument as an options Hash" do @fh = File.open(@file, mode: "r") - @fh.should be_an_instance_of(File) + @fh.should.instance_of?(File) end it "calls #to_hash to convert the second argument to a Hash" do @@ -589,17 +589,17 @@ it "accepts extra flags as a keyword argument and combine with a string mode" do -> { File.open(@file, "w", flags: File::EXCL) { } - }.should raise_error(Errno::EEXIST) + }.should.raise(Errno::EEXIST) -> { File.open(@file, mode: "w", flags: File::EXCL) { } - }.should raise_error(Errno::EEXIST) + }.should.raise(Errno::EEXIST) end it "accepts extra flags as a keyword argument and combine with an integer mode" do -> { File.open(@file, File::WRONLY | File::CREAT, flags: File::EXCL) { } - }.should raise_error(Errno::EEXIST) + }.should.raise(Errno::EEXIST) end platform_is_not :windows do @@ -643,7 +643,7 @@ it "raises ArgumentError if mixing :newline and binary mode" do -> { File.open(@file, "rb", newline: :universal) {} - }.should raise_error(ArgumentError, "newline decorator with binary mode") + }.should.raise(ArgumentError, "newline decorator with binary mode") end context "'x' flag" do @@ -663,12 +663,12 @@ it "throws a Errno::EEXIST error if the file exists" do touch @xfile - -> { File.open(@xfile, "wx") }.should raise_error(Errno::EEXIST) + -> { File.open(@xfile, "wx") }.should.raise(Errno::EEXIST) end it "can't be used with 'r' and 'a' flags" do - -> { File.open(@xfile, "rx") }.should raise_error(ArgumentError, 'invalid access mode rx') - -> { File.open(@xfile, "ax") }.should raise_error(ArgumentError, 'invalid access mode ax') + -> { File.open(@xfile, "rx") }.should.raise(ArgumentError, 'invalid access mode rx') + -> { File.open(@xfile, "ax") }.should.raise(ArgumentError, 'invalid access mode ax') end end end @@ -688,8 +688,8 @@ it "opens a file" do @file = File.open(@fd, "w") - @file.should be_an_instance_of(File) - @file.fileno.should equal(@fd) + @file.should.instance_of?(File) + @file.fileno.should.equal?(@fd) @file.write @content @file.flush File.read(@name).should == @content @@ -697,8 +697,8 @@ it "opens a file when passed a block" do @file = File.open(@fd, "w") do |f| - f.should be_an_instance_of(File) - f.fileno.should equal(@fd) + f.should.instance_of?(File) + f.fileno.should.equal?(@fd) f.write @content f end diff --git a/spec/ruby/core/file/path_spec.rb b/spec/ruby/core/file/path_spec.rb index 726febcc2bd0eb..ce78dbeede3d9b 100644 --- a/spec/ruby/core/file/path_spec.rb +++ b/spec/ruby/core/file/path_spec.rb @@ -41,41 +41,41 @@ it "raises TypeError when #to_path result is not a string" do path = mock("path") path.should_receive(:to_path).and_return(nil) - -> { File.path(path) }.should raise_error TypeError + -> { File.path(path) }.should.raise TypeError path = mock("path") path.should_receive(:to_path).and_return(42) - -> { File.path(path) }.should raise_error TypeError + -> { File.path(path) }.should.raise TypeError end it "raises ArgumentError for string argument contains NUL character" do - -> { File.path("\0") }.should raise_error ArgumentError - -> { File.path("a\0") }.should raise_error ArgumentError - -> { File.path("a\0c") }.should raise_error ArgumentError + -> { File.path("\0") }.should.raise ArgumentError + -> { File.path("a\0") }.should.raise ArgumentError + -> { File.path("a\0c") }.should.raise ArgumentError end it "raises ArgumentError when #to_path result contains NUL character" do path = mock("path") path.should_receive(:to_path).and_return("\0") - -> { File.path(path) }.should raise_error ArgumentError + -> { File.path(path) }.should.raise ArgumentError path = mock("path") path.should_receive(:to_path).and_return("a\0") - -> { File.path(path) }.should raise_error ArgumentError + -> { File.path(path) }.should.raise ArgumentError path = mock("path") path.should_receive(:to_path).and_return("a\0c") - -> { File.path(path) }.should raise_error ArgumentError + -> { File.path(path) }.should.raise ArgumentError end it "raises Encoding::CompatibilityError for ASCII-incompatible string argument" do path = "abc".encode(Encoding::UTF_32BE) - -> { File.path(path) }.should raise_error Encoding::CompatibilityError + -> { File.path(path) }.should.raise Encoding::CompatibilityError end it "raises Encoding::CompatibilityError when #to_path result is ASCII-incompatible" do path = mock("path") path.should_receive(:to_path).and_return("abc".encode(Encoding::UTF_32BE)) - -> { File.path(path) }.should raise_error Encoding::CompatibilityError + -> { File.path(path) }.should.raise Encoding::CompatibilityError end end diff --git a/spec/ruby/core/file/readlink_spec.rb b/spec/ruby/core/file/readlink_spec.rb index 20741ba121fe89..568692b9b62f93 100644 --- a/spec/ruby/core/file/readlink_spec.rb +++ b/spec/ruby/core/file/readlink_spec.rb @@ -26,12 +26,12 @@ it "raises an Errno::ENOENT if there is no such file" do # TODO: missing_file - -> { File.readlink("/this/surely/does/not/exist") }.should raise_error(Errno::ENOENT) + -> { File.readlink("/this/surely/does/not/exist") }.should.raise(Errno::ENOENT) end it "raises an Errno::EINVAL if called with a normal file" do touch @file - -> { File.readlink(@file) }.should raise_error(Errno::EINVAL) + -> { File.readlink(@file) }.should.raise(Errno::EINVAL) end end @@ -49,7 +49,7 @@ it "returns the name of the file referenced by the given link" do touch @file result = File.readlink(@link) - result.encoding.should equal Encoding.find('filesystem') + result.encoding.should.equal? Encoding.find('filesystem') result.should == @file.dup.force_encoding(Encoding.find('filesystem')) end end diff --git a/spec/ruby/core/file/realdirpath_spec.rb b/spec/ruby/core/file/realdirpath_spec.rb index 74053afce392d6..ecf1e0c6d94e33 100644 --- a/spec/ruby/core/file/realdirpath_spec.rb +++ b/spec/ruby/core/file/realdirpath_spec.rb @@ -61,7 +61,7 @@ it "raises an Errno::ELOOP if the symlink points to itself" do File.unlink @link File.symlink(@link, @link) - -> { File.realdirpath(@link) }.should raise_error(Errno::ELOOP) + -> { File.realdirpath(@link) }.should.raise(Errno::ELOOP) end it "returns the real (absolute) pathname if the file is absent" do @@ -69,7 +69,7 @@ end it "raises Errno::ENOENT if the directory is absent" do - -> { File.realdirpath(@fake_file_in_fake_dir) }.should raise_error(Errno::ENOENT) + -> { File.realdirpath(@fake_file_in_fake_dir) }.should.raise(Errno::ENOENT) end it "returns the real (absolute) pathname if the symlink points to an absent file" do @@ -77,7 +77,7 @@ end it "raises Errno::ENOENT if the symlink points to an absent directory" do - -> { File.realdirpath(@fake_link_to_fake_dir) }.should raise_error(Errno::ENOENT) + -> { File.realdirpath(@fake_link_to_fake_dir) }.should.raise(Errno::ENOENT) end end end diff --git a/spec/ruby/core/file/realpath_spec.rb b/spec/ruby/core/file/realpath_spec.rb index bd25bfdecf9ea1..ccb981eff16630 100644 --- a/spec/ruby/core/file/realpath_spec.rb +++ b/spec/ruby/core/file/realpath_spec.rb @@ -61,15 +61,15 @@ it "raises an Errno::ELOOP if the symlink points to itself" do File.unlink @link File.symlink(@link, @link) - -> { File.realpath(@link) }.should raise_error(Errno::ELOOP) + -> { File.realpath(@link) }.should.raise(Errno::ELOOP) end it "raises Errno::ENOENT if the file is absent" do - -> { File.realpath(@fake_file) }.should raise_error(Errno::ENOENT) + -> { File.realpath(@fake_file) }.should.raise(Errno::ENOENT) end it "raises Errno::ENOENT if the symlink points to an absent file" do - -> { File.realpath(@fake_link) }.should raise_error(Errno::ENOENT) + -> { File.realpath(@fake_link) }.should.raise(Errno::ENOENT) end it "converts the argument with #to_path" do diff --git a/spec/ruby/core/file/rename_spec.rb b/spec/ruby/core/file/rename_spec.rb index f2c18d4905b65e..70ea669a68ccaf 100644 --- a/spec/ruby/core/file/rename_spec.rb +++ b/spec/ruby/core/file/rename_spec.rb @@ -23,15 +23,15 @@ it "raises an Errno::ENOENT if the source does not exist" do rm_r @old - -> { File.rename(@old, @new) }.should raise_error(Errno::ENOENT) + -> { File.rename(@old, @new) }.should.raise(Errno::ENOENT) end it "raises an ArgumentError if not passed two arguments" do - -> { File.rename }.should raise_error(ArgumentError) - -> { File.rename(@file) }.should raise_error(ArgumentError) + -> { File.rename }.should.raise(ArgumentError) + -> { File.rename(@file) }.should.raise(ArgumentError) end it "raises a TypeError if not passed String types" do - -> { File.rename(1, 2) }.should raise_error(TypeError) + -> { File.rename(1, 2) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/file/shared/fnmatch.rb b/spec/ruby/core/file/shared/fnmatch.rb index db4b5c5d8c6b30..b9140d027d2320 100644 --- a/spec/ruby/core/file/shared/fnmatch.rb +++ b/spec/ruby/core/file/shared/fnmatch.rb @@ -222,48 +222,48 @@ it "returns false if '/' in pattern do not match '/' in path when flags includes FNM_PATHNAME" do pattern = '*/*' - File.send(@method, pattern, 'dave/.profile', File::FNM_PATHNAME).should be_false + File.send(@method, pattern, 'dave/.profile', File::FNM_PATHNAME).should == false pattern = '**/foo' - File.send(@method, pattern, 'a/.b/c/foo', File::FNM_PATHNAME).should be_false + File.send(@method, pattern, 'a/.b/c/foo', File::FNM_PATHNAME).should == false end it "returns true if '/' in pattern match '/' in path when flags includes FNM_PATHNAME" do pattern = '*/*' - File.send(@method, pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true + File.send(@method, pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == true pattern = '**/foo' - File.send(@method, pattern, 'a/b/c/foo', File::FNM_PATHNAME).should be_true - File.send(@method, pattern, '/a/b/c/foo', File::FNM_PATHNAME).should be_true - File.send(@method, pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME).should be_true - File.send(@method, pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true + File.send(@method, pattern, 'a/b/c/foo', File::FNM_PATHNAME).should == true + File.send(@method, pattern, '/a/b/c/foo', File::FNM_PATHNAME).should == true + File.send(@method, pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME).should == true + File.send(@method, pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == true end it "has special handling for ./ when using * and FNM_PATHNAME" do - File.send(@method, './*', '.', File::FNM_PATHNAME).should be_false - File.send(@method, './*', './', File::FNM_PATHNAME).should be_true - File.send(@method, './*/', './', File::FNM_PATHNAME).should be_false - File.send(@method, './**', './', File::FNM_PATHNAME).should be_true - File.send(@method, './**/', './', File::FNM_PATHNAME).should be_true - File.send(@method, './*', '.', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_false - File.send(@method, './*', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true - File.send(@method, './*/', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_false - File.send(@method, './**', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true - File.send(@method, './**/', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true + File.send(@method, './*', '.', File::FNM_PATHNAME).should == false + File.send(@method, './*', './', File::FNM_PATHNAME).should == true + File.send(@method, './*/', './', File::FNM_PATHNAME).should == false + File.send(@method, './**', './', File::FNM_PATHNAME).should == true + File.send(@method, './**/', './', File::FNM_PATHNAME).should == true + File.send(@method, './*', '.', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == false + File.send(@method, './*', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == true + File.send(@method, './*/', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == false + File.send(@method, './**', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == true + File.send(@method, './**/', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == true end it "matches **/* with FNM_PATHNAME to recurse directories" do - File.send(@method, 'nested/**/*', 'nested/subdir', File::FNM_PATHNAME).should be_true - File.send(@method, 'nested/**/*', 'nested/subdir/file', File::FNM_PATHNAME).should be_true - File.send(@method, 'nested/**/*', 'nested/.dotsubdir', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true - File.send(@method, 'nested/**/*', 'nested/.dotsubir/.dotfile', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true + File.send(@method, 'nested/**/*', 'nested/subdir', File::FNM_PATHNAME).should == true + File.send(@method, 'nested/**/*', 'nested/subdir/file', File::FNM_PATHNAME).should == true + File.send(@method, 'nested/**/*', 'nested/.dotsubdir', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == true + File.send(@method, 'nested/**/*', 'nested/.dotsubir/.dotfile', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == true end it "matches ** with FNM_PATHNAME only in current directory" do - File.send(@method, 'nested/**', 'nested/subdir', File::FNM_PATHNAME).should be_true - File.send(@method, 'nested/**', 'nested/subdir/file', File::FNM_PATHNAME).should be_false - File.send(@method, 'nested/**', 'nested/.dotsubdir', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true - File.send(@method, 'nested/**', 'nested/.dotsubir/.dotfile', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_false + File.send(@method, 'nested/**', 'nested/subdir', File::FNM_PATHNAME).should == true + File.send(@method, 'nested/**', 'nested/subdir/file', File::FNM_PATHNAME).should == false + File.send(@method, 'nested/**', 'nested/.dotsubdir', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == true + File.send(@method, 'nested/**', 'nested/.dotsubir/.dotfile', File::FNM_PATHNAME | File::FNM_DOTMATCH).should == false end it "accepts an object that has a #to_path method" do @@ -271,21 +271,21 @@ end it "raises a TypeError if the first and second arguments are not string-like" do - -> { File.send(@method, nil, nil, 0, 0) }.should raise_error(ArgumentError) - -> { File.send(@method, 1, 'some/thing') }.should raise_error(TypeError) - -> { File.send(@method, 'some/thing', 1) }.should raise_error(TypeError) - -> { File.send(@method, 1, 1) }.should raise_error(TypeError) + -> { File.send(@method, nil, nil, 0, 0) }.should.raise(ArgumentError) + -> { File.send(@method, 1, 'some/thing') }.should.raise(TypeError) + -> { File.send(@method, 'some/thing', 1) }.should.raise(TypeError) + -> { File.send(@method, 1, 1) }.should.raise(TypeError) end it "raises a TypeError if the third argument is not an Integer" do - -> { File.send(@method, "*/place", "path/to/file", "flags") }.should raise_error(TypeError) - -> { File.send(@method, "*/place", "path/to/file", nil) }.should raise_error(TypeError) + -> { File.send(@method, "*/place", "path/to/file", "flags") }.should.raise(TypeError) + -> { File.send(@method, "*/place", "path/to/file", nil) }.should.raise(TypeError) end it "does not raise a TypeError if the third argument can be coerced to an Integer" do flags = mock("flags") flags.should_receive(:to_int).and_return(10) - -> { File.send(@method, "*/place", "path/to/file", flags) }.should_not raise_error + -> { File.send(@method, "*/place", "path/to/file", flags) }.should_not.raise end it "matches multibyte characters" do diff --git a/spec/ruby/core/file/shared/open.rb b/spec/ruby/core/file/shared/open.rb index 677a82a3516ed7..67149235ca959a 100644 --- a/spec/ruby/core/file/shared/open.rb +++ b/spec/ruby/core/file/shared/open.rb @@ -4,7 +4,7 @@ it "opens directories" do file = File.send(@method, tmp("")) begin - file.should be_kind_of(File) + file.should.is_a?(File) ensure file.close end diff --git a/spec/ruby/core/file/shared/path.rb b/spec/ruby/core/file/shared/path.rb index 5a9fe1b0c50e22..6c6f7d4234ab4f 100644 --- a/spec/ruby/core/file/shared/path.rb +++ b/spec/ruby/core/file/shared/path.rb @@ -12,7 +12,7 @@ it "returns a String" do @file = File.new @path - @file.send(@method).should be_an_instance_of(String) + @file.send(@method).should.instance_of?(String) end it "returns a different String on every call" do diff --git a/spec/ruby/core/file/shared/read.rb b/spec/ruby/core/file/shared/read.rb index f2322352984c5b..f60800bb2f3256 100644 --- a/spec/ruby/core/file/shared/read.rb +++ b/spec/ruby/core/file/shared/read.rb @@ -3,13 +3,13 @@ describe :file_read_directory, shared: true do platform_is :darwin, :linux, :freebsd, :openbsd, :windows do it "raises an Errno::EISDIR when passed a path that is a directory" do - -> { @object.send(@method, ".") }.should raise_error(Errno::EISDIR) + -> { @object.send(@method, ".") }.should.raise(Errno::EISDIR) end end platform_is :netbsd do it "does not raises any exception when passed a path that is a directory" do - -> { @object.send(@method, ".") }.should_not raise_error + -> { @object.send(@method, ".") }.should_not.raise end end end diff --git a/spec/ruby/core/file/shared/stat.rb b/spec/ruby/core/file/shared/stat.rb index fdaf97ea61afe0..879a7f11ffc5e7 100644 --- a/spec/ruby/core/file/shared/stat.rb +++ b/spec/ruby/core/file/shared/stat.rb @@ -10,13 +10,13 @@ it "returns a File::Stat object if the given file exists" do st = File.send(@method, @file) - st.should be_an_instance_of(File::Stat) + st.should.instance_of?(File::Stat) end it "returns a File::Stat object when called on an instance of File" do File.open(@file) do |f| st = f.send(@method) - st.should be_an_instance_of(File::Stat) + st.should.instance_of?(File::Stat) end end @@ -27,6 +27,6 @@ it "raises an Errno::ENOENT if the file does not exist" do -> { File.send(@method, "fake_file") - }.should raise_error(Errno::ENOENT) + }.should.raise(Errno::ENOENT) end end diff --git a/spec/ruby/core/file/shared/unlink.rb b/spec/ruby/core/file/shared/unlink.rb index e339e932713497..0032907ba2624d 100644 --- a/spec/ruby/core/file/shared/unlink.rb +++ b/spec/ruby/core/file/shared/unlink.rb @@ -31,11 +31,11 @@ end it "raises a TypeError if not passed a String type" do - -> { File.send(@method, 1) }.should raise_error(TypeError) + -> { File.send(@method, 1) }.should.raise(TypeError) end it "raises an Errno::ENOENT when the given file doesn't exist" do - -> { File.send(@method, 'bogus') }.should raise_error(Errno::ENOENT) + -> { File.send(@method, 'bogus') }.should.raise(Errno::ENOENT) end it "coerces a given parameter into a string if possible" do diff --git a/spec/ruby/core/file/size_spec.rb b/spec/ruby/core/file/size_spec.rb index 11d20cbacbb7f7..784c18c26ef9a7 100644 --- a/spec/ruby/core/file/size_spec.rb +++ b/spec/ruby/core/file/size_spec.rb @@ -56,11 +56,11 @@ end it "is an instance method" do - @file.respond_to?(:size).should be_true + @file.respond_to?(:size).should == true end it "returns the file's size as an Integer" do - @file.size.should be_an_instance_of(Integer) + @file.size.should.instance_of?(Integer) end it "returns the file's size in bytes" do @@ -81,7 +81,7 @@ it "raises an IOError on a closed file" do @file.close - -> { @file.size }.should raise_error(IOError) + -> { @file.size }.should.raise(IOError) end platform_is_not :windows do diff --git a/spec/ruby/core/file/split_spec.rb b/spec/ruby/core/file/split_spec.rb index 7b958621b9ebad..e989a6b86edb66 100644 --- a/spec/ruby/core/file/split_spec.rb +++ b/spec/ruby/core/file/split_spec.rb @@ -44,12 +44,12 @@ end it "raises an ArgumentError when not passed a single argument" do - -> { File.split }.should raise_error(ArgumentError) - -> { File.split('string', 'another string') }.should raise_error(ArgumentError) + -> { File.split }.should.raise(ArgumentError) + -> { File.split('string', 'another string') }.should.raise(ArgumentError) end it "raises a TypeError if the argument is not a String type" do - -> { File.split(1) }.should raise_error(TypeError) + -> { File.split(1) }.should.raise(TypeError) end it "coerces the argument with to_str if it is not a String type" do diff --git a/spec/ruby/core/file/stat/atime_spec.rb b/spec/ruby/core/file/stat/atime_spec.rb index 9f1111ced1ae7d..2fecaed3000e8a 100644 --- a/spec/ruby/core/file/stat/atime_spec.rb +++ b/spec/ruby/core/file/stat/atime_spec.rb @@ -12,7 +12,7 @@ it "returns the atime of a File::Stat object" do st = File.stat(@file) - st.atime.should be_kind_of(Time) + st.atime.should.is_a?(Time) st.atime.should <= Time.now end end diff --git a/spec/ruby/core/file/stat/birthtime_spec.rb b/spec/ruby/core/file/stat/birthtime_spec.rb index 9aa39297b24d3c..728f6353971199 100644 --- a/spec/ruby/core/file/stat/birthtime_spec.rb +++ b/spec/ruby/core/file/stat/birthtime_spec.rb @@ -20,7 +20,7 @@ it "returns the birthtime of a File::Stat object" do st = File.stat(@file) - st.birthtime.should be_kind_of(Time) + st.birthtime.should.is_a?(Time) st.birthtime.should <= Time.now rescue NotImplementedError => e e.message.should.start_with?(*not_implemented_messages) diff --git a/spec/ruby/core/file/stat/blocks_spec.rb b/spec/ruby/core/file/stat/blocks_spec.rb index f3f903d0f72a0c..5e0efc8bc260e9 100644 --- a/spec/ruby/core/file/stat/blocks_spec.rb +++ b/spec/ruby/core/file/stat/blocks_spec.rb @@ -21,7 +21,7 @@ platform_is :windows do it "returns nil" do st = File.stat(@file) - st.blocks.should be_nil + st.blocks.should == nil end end end diff --git a/spec/ruby/core/file/stat/ctime_spec.rb b/spec/ruby/core/file/stat/ctime_spec.rb index fd50487a0a4c62..dbf43a74536ebb 100644 --- a/spec/ruby/core/file/stat/ctime_spec.rb +++ b/spec/ruby/core/file/stat/ctime_spec.rb @@ -12,7 +12,7 @@ it "returns the ctime of a File::Stat object" do st = File.stat(@file) - st.ctime.should be_kind_of(Time) + st.ctime.should.is_a?(Time) st.ctime.should <= Time.now end end diff --git a/spec/ruby/core/file/stat/dev_major_spec.rb b/spec/ruby/core/file/stat/dev_major_spec.rb index 4966d609e29b58..a199eaaa11d234 100644 --- a/spec/ruby/core/file/stat/dev_major_spec.rb +++ b/spec/ruby/core/file/stat/dev_major_spec.rb @@ -11,13 +11,13 @@ platform_is_not :windows do it "returns the major part of File::Stat#dev" do - File.stat(@name).dev_major.should be_kind_of(Integer) + File.stat(@name).dev_major.should.is_a?(Integer) end end platform_is :windows do it "returns nil" do - File.stat(@name).dev_major.should be_nil + File.stat(@name).dev_major.should == nil end end end diff --git a/spec/ruby/core/file/stat/dev_minor_spec.rb b/spec/ruby/core/file/stat/dev_minor_spec.rb index ea79c12b998f35..8ce94778cae08e 100644 --- a/spec/ruby/core/file/stat/dev_minor_spec.rb +++ b/spec/ruby/core/file/stat/dev_minor_spec.rb @@ -11,13 +11,13 @@ platform_is_not :windows do it "returns the minor part of File::Stat#dev" do - File.stat(@name).dev_minor.should be_kind_of(Integer) + File.stat(@name).dev_minor.should.is_a?(Integer) end end platform_is :windows do it "returns nil" do - File.stat(@name).dev_minor.should be_nil + File.stat(@name).dev_minor.should == nil end end end diff --git a/spec/ruby/core/file/stat/dev_spec.rb b/spec/ruby/core/file/stat/dev_spec.rb index e953fcaa582c6d..cd5e3d175e978c 100644 --- a/spec/ruby/core/file/stat/dev_spec.rb +++ b/spec/ruby/core/file/stat/dev_spec.rb @@ -10,6 +10,6 @@ end it "returns the number of the device on which the file exists" do - File.stat(@name).dev.should be_kind_of(Integer) + File.stat(@name).dev.should.is_a?(Integer) end end diff --git a/spec/ruby/core/file/stat/ftype_spec.rb b/spec/ruby/core/file/stat/ftype_spec.rb index eb892eae5fa634..df2e3ada1edab4 100644 --- a/spec/ruby/core/file/stat/ftype_spec.rb +++ b/spec/ruby/core/file/stat/ftype_spec.rb @@ -8,7 +8,7 @@ it "returns a String" do FileSpecs.normal_file do |file| - File.lstat(file).ftype.should be_kind_of(String) + File.lstat(file).ftype.should.is_a?(String) end end diff --git a/spec/ruby/core/file/stat/ino_spec.rb b/spec/ruby/core/file/stat/ino_spec.rb index 42370aecb72973..c09b6448c71cb7 100644 --- a/spec/ruby/core/file/stat/ino_spec.rb +++ b/spec/ruby/core/file/stat/ino_spec.rb @@ -13,7 +13,7 @@ platform_is_not :windows do it "returns the ino of a File::Stat object" do st = File.stat(@file) - st.ino.should be_kind_of(Integer) + st.ino.should.is_a?(Integer) st.ino.should > 0 end end @@ -21,7 +21,7 @@ platform_is :windows do it "returns BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low of a File::Stat object" do st = File.stat(@file) - st.ino.should be_kind_of(Integer) + st.ino.should.is_a?(Integer) st.ino.should > 0 end end diff --git a/spec/ruby/core/file/stat/mtime_spec.rb b/spec/ruby/core/file/stat/mtime_spec.rb index 08a2b83463becd..7844491212b058 100644 --- a/spec/ruby/core/file/stat/mtime_spec.rb +++ b/spec/ruby/core/file/stat/mtime_spec.rb @@ -12,7 +12,7 @@ it "returns the mtime of a File::Stat object" do st = File.stat(@file) - st.mtime.should be_kind_of(Time) + st.mtime.should.is_a?(Time) st.mtime.should <= Time.now end end diff --git a/spec/ruby/core/file/stat/new_spec.rb b/spec/ruby/core/file/stat/new_spec.rb index c0d9432ac81da3..b8c3600028491c 100644 --- a/spec/ruby/core/file/stat/new_spec.rb +++ b/spec/ruby/core/file/stat/new_spec.rb @@ -15,12 +15,12 @@ it "raises an exception if the file doesn't exist" do -> { File::Stat.new(tmp("i_am_a_dummy_file_that_doesnt_exist")) - }.should raise_error(Errno::ENOENT) + }.should.raise(Errno::ENOENT) end it "creates a File::Stat object for the given file" do st = File::Stat.new(@file) - st.should be_kind_of(File::Stat) + st.should.is_a?(File::Stat) st.ftype.should == 'file' end diff --git a/spec/ruby/core/file/stat/rdev_major_spec.rb b/spec/ruby/core/file/stat/rdev_major_spec.rb index e08d19c03ad95e..e1b44fc2d0d609 100644 --- a/spec/ruby/core/file/stat/rdev_major_spec.rb +++ b/spec/ruby/core/file/stat/rdev_major_spec.rb @@ -12,13 +12,13 @@ platform_is_not :windows do it "returns the major part of File::Stat#rdev" do - File.stat(@name).rdev_major.should be_kind_of(Integer) + File.stat(@name).rdev_major.should.is_a?(Integer) end end platform_is :windows do it "returns nil" do - File.stat(@name).rdev_major.should be_nil + File.stat(@name).rdev_major.should == nil end end end diff --git a/spec/ruby/core/file/stat/rdev_minor_spec.rb b/spec/ruby/core/file/stat/rdev_minor_spec.rb index ace5b8a7320e3f..8af3b9f5878c59 100644 --- a/spec/ruby/core/file/stat/rdev_minor_spec.rb +++ b/spec/ruby/core/file/stat/rdev_minor_spec.rb @@ -12,13 +12,13 @@ platform_is_not :windows do it "returns the minor part of File::Stat#rdev" do - File.stat(@name).rdev_minor.should be_kind_of(Integer) + File.stat(@name).rdev_minor.should.is_a?(Integer) end end platform_is :windows do it "returns nil" do - File.stat(@name).rdev_minor.should be_nil + File.stat(@name).rdev_minor.should == nil end end end diff --git a/spec/ruby/core/file/stat/rdev_spec.rb b/spec/ruby/core/file/stat/rdev_spec.rb index 9e1aee692dc06c..7e4252fcc64d57 100644 --- a/spec/ruby/core/file/stat/rdev_spec.rb +++ b/spec/ruby/core/file/stat/rdev_spec.rb @@ -10,6 +10,6 @@ end it "returns the number of the device this file represents which the file exists" do - File.stat(@name).rdev.should be_kind_of(Integer) + File.stat(@name).rdev.should.is_a?(Integer) end end diff --git a/spec/ruby/core/file/stat_spec.rb b/spec/ruby/core/file/stat_spec.rb index 63655000573bd6..d5238b63317200 100644 --- a/spec/ruby/core/file/stat_spec.rb +++ b/spec/ruby/core/file/stat_spec.rb @@ -28,9 +28,9 @@ st.size.should == 8 st.size?.should == 8 st.blksize.should >= 0 - st.atime.should be_kind_of(Time) - st.ctime.should be_kind_of(Time) - st.mtime.should be_kind_of(Time) + st.atime.should.is_a?(Time) + st.ctime.should.is_a?(Time) + st.mtime.should.is_a?(Time) end end @@ -46,9 +46,9 @@ missing_path = "/missingfilepath\xE3E4".b -> { File.stat(missing_path) - }.should raise_error(SystemCallError) { |e| - [Errno::ENOENT, Errno::EILSEQ].should include(e.class) - e.message.should include(missing_path) + }.should.raise(SystemCallError) { |e| + [Errno::ENOENT, Errno::EILSEQ].should.include?(e.class) + e.message.should.include?(missing_path) } end end diff --git a/spec/ruby/core/file/symlink_spec.rb b/spec/ruby/core/file/symlink_spec.rb index 0e8b0a5a201bfd..4ceeb28c8473ee 100644 --- a/spec/ruby/core/file/symlink_spec.rb +++ b/spec/ruby/core/file/symlink_spec.rb @@ -32,18 +32,18 @@ it "raises an Errno::EEXIST if the target already exists" do File.symlink(@file, @link) - -> { File.symlink(@file, @link) }.should raise_error(Errno::EEXIST) + -> { File.symlink(@file, @link) }.should.raise(Errno::EEXIST) end it "raises an ArgumentError if not called with two arguments" do - -> { File.symlink }.should raise_error(ArgumentError) - -> { File.symlink(@file) }.should raise_error(ArgumentError) + -> { File.symlink }.should.raise(ArgumentError) + -> { File.symlink(@file) }.should.raise(ArgumentError) end it "raises a TypeError if not called with String types" do - -> { File.symlink(@file, nil) }.should raise_error(TypeError) - -> { File.symlink(@file, 1) }.should raise_error(TypeError) - -> { File.symlink(1, 1) }.should raise_error(TypeError) + -> { File.symlink(@file, nil) }.should.raise(TypeError) + -> { File.symlink(@file, 1) }.should.raise(TypeError) + -> { File.symlink(1, 1) }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/file/truncate_spec.rb b/spec/ruby/core/file/truncate_spec.rb index b4a2e3e57728c9..5f37f341554d6f 100644 --- a/spec/ruby/core/file/truncate_spec.rb +++ b/spec/ruby/core/file/truncate_spec.rb @@ -54,29 +54,29 @@ rm_r not_existing_file begin - -> { File.truncate(not_existing_file, 5) }.should raise_error(Errno::ENOENT) + -> { File.truncate(not_existing_file, 5) }.should.raise(Errno::ENOENT) ensure rm_r not_existing_file end end it "raises an ArgumentError if not passed two arguments" do - -> { File.truncate }.should raise_error(ArgumentError) - -> { File.truncate(@name) }.should raise_error(ArgumentError) + -> { File.truncate }.should.raise(ArgumentError) + -> { File.truncate(@name) }.should.raise(ArgumentError) end platform_is_not :netbsd, :openbsd do it "raises an Errno::EINVAL if the length argument is not valid" do - -> { File.truncate(@name, -1) }.should raise_error(Errno::EINVAL) # May fail + -> { File.truncate(@name, -1) }.should.raise(Errno::EINVAL) # May fail end end it "raises a TypeError if not passed a String type for the first argument" do - -> { File.truncate(1, 1) }.should raise_error(TypeError) + -> { File.truncate(1, 1) }.should.raise(TypeError) end it "raises a TypeError if not passed an Integer type for the second argument" do - -> { File.truncate(@name, nil) }.should raise_error(TypeError) + -> { File.truncate(@name, nil) }.should.raise(TypeError) end it "accepts an object that has a #to_path method" do @@ -149,29 +149,29 @@ end it "raises an ArgumentError if not passed one argument" do - -> { @file.truncate }.should raise_error(ArgumentError) - -> { @file.truncate(1) }.should_not raise_error(ArgumentError) + -> { @file.truncate }.should.raise(ArgumentError) + -> { @file.truncate(1) }.should_not.raise(ArgumentError) end platform_is_not :netbsd do it "raises an Errno::EINVAL if the length argument is not valid" do - -> { @file.truncate(-1) }.should raise_error(Errno::EINVAL) # May fail + -> { @file.truncate(-1) }.should.raise(Errno::EINVAL) # May fail end end it "raises an IOError if file is closed" do @file.close @file.should.closed? - -> { @file.truncate(42) }.should raise_error(IOError) + -> { @file.truncate(42) }.should.raise(IOError) end it "raises an IOError if file is not opened for writing" do File.open(@name, 'r') do |file| - -> { file.truncate(42) }.should raise_error(IOError) + -> { file.truncate(42) }.should.raise(IOError) end end it "raises a TypeError if not passed an Integer type for the for the argument" do - -> { @file.truncate(nil) }.should raise_error(TypeError) + -> { @file.truncate(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/file/umask_spec.rb b/spec/ruby/core/file/umask_spec.rb index 7f7e40abbc5da7..fea8cf76332e79 100644 --- a/spec/ruby/core/file/umask_spec.rb +++ b/spec/ruby/core/file/umask_spec.rb @@ -13,7 +13,7 @@ end it "returns an Integer" do - File.umask.should be_kind_of(Integer) + File.umask.should.is_a?(Integer) end platform_is_not :windows do @@ -47,11 +47,11 @@ end it "raises RangeError with too large values" do - -> { File.umask(2**64) }.should raise_error(RangeError) - -> { File.umask(-2**63 - 1) }.should raise_error(RangeError) + -> { File.umask(2**64) }.should.raise(RangeError) + -> { File.umask(-2**63 - 1) }.should.raise(RangeError) end it "raises ArgumentError when more than one argument is provided" do - -> { File.umask(022, 022) }.should raise_error(ArgumentError) + -> { File.umask(022, 022) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/file/world_readable_spec.rb b/spec/ruby/core/file/world_readable_spec.rb index 11b8e67d0bfb74..0f5e0b13d7f6fe 100644 --- a/spec/ruby/core/file/world_readable_spec.rb +++ b/spec/ruby/core/file/world_readable_spec.rb @@ -7,6 +7,6 @@ it "returns nil if the file does not exist" do file = rand.to_s + $$.to_s File.should_not.exist?(file) - File.world_readable?(file).should be_nil + File.world_readable?(file).should == nil end end diff --git a/spec/ruby/core/file/world_writable_spec.rb b/spec/ruby/core/file/world_writable_spec.rb index d378cf2eb934be..46ba6832f98223 100644 --- a/spec/ruby/core/file/world_writable_spec.rb +++ b/spec/ruby/core/file/world_writable_spec.rb @@ -7,6 +7,6 @@ it "returns nil if the file does not exist" do file = rand.to_s + $$.to_s File.should_not.exist?(file) - File.world_writable?(file).should be_nil + File.world_writable?(file).should == nil end end diff --git a/spec/ruby/core/filetest/grpowned_spec.rb b/spec/ruby/core/filetest/grpowned_spec.rb index d073cb9770e604..d6bd6abd71da53 100644 --- a/spec/ruby/core/filetest/grpowned_spec.rb +++ b/spec/ruby/core/filetest/grpowned_spec.rb @@ -5,6 +5,6 @@ it_behaves_like :file_grpowned, :grpowned?, FileTest it "returns false if the file doesn't exist" do - FileTest.grpowned?("xxx-tmp-doesnt_exist-blah").should be_false + FileTest.grpowned?("xxx-tmp-doesnt_exist-blah").should == false end end diff --git a/spec/ruby/core/float/ceil_spec.rb b/spec/ruby/core/float/ceil_spec.rb index 5236a133f5de18..efd1e6feb2e0f2 100644 --- a/spec/ruby/core/float/ceil_spec.rb +++ b/spec/ruby/core/float/ceil_spec.rb @@ -7,22 +7,22 @@ end it "returns the smallest Integer greater than or equal to self" do - -1.2.ceil.should eql( -1) - -1.0.ceil.should eql( -1) - 0.0.ceil.should eql( 0 ) - 1.3.ceil.should eql( 2 ) - 3.0.ceil.should eql( 3 ) - -9223372036854775808.1.ceil.should eql(-9223372036854775808) - +9223372036854775808.1.ceil.should eql(+9223372036854775808) + -1.2.ceil.should.eql?( -1) + -1.0.ceil.should.eql?( -1) + 0.0.ceil.should.eql?( 0 ) + 1.3.ceil.should.eql?( 2 ) + 3.0.ceil.should.eql?( 3 ) + -9223372036854775808.1.ceil.should.eql?(-9223372036854775808) + +9223372036854775808.1.ceil.should.eql?(+9223372036854775808) end it "returns the smallest number greater than or equal to self with an optionally given precision" do - 2.1679.ceil(0).should eql(3) - 214.94.ceil(-1).should eql(220) - 7.0.ceil(1).should eql(7.0) - 200.0.ceil(-2).should eql(200) - -1.234.ceil(2).should eql(-1.23) - 5.123812.ceil(4).should eql(5.1239) - 10.00001.ceil(5).should eql(10.00001) + 2.1679.ceil(0).should.eql?(3) + 214.94.ceil(-1).should.eql?(220) + 7.0.ceil(1).should.eql?(7.0) + 200.0.ceil(-2).should.eql?(200) + -1.234.ceil(2).should.eql?(-1.23) + 5.123812.ceil(4).should.eql?(5.1239) + 10.00001.ceil(5).should.eql?(10.00001) end end diff --git a/spec/ruby/core/float/comparison_spec.rb b/spec/ruby/core/float/comparison_spec.rb index 0cd290f4ad4e2d..e9adf2fd6aa5a3 100644 --- a/spec/ruby/core/float/comparison_spec.rb +++ b/spec/ruby/core/float/comparison_spec.rb @@ -29,10 +29,10 @@ end it "returns nil when the given argument is not a Float" do - (1.0 <=> "1").should be_nil - (1.0 <=> "1".freeze).should be_nil - (1.0 <=> :one).should be_nil - (1.0 <=> true).should be_nil + (1.0 <=> "1").should == nil + (1.0 <=> "1".freeze).should == nil + (1.0 <=> :one).should == nil + (1.0 <=> true).should == nil end it "compares using #coerce when argument is not a Float" do @@ -62,7 +62,7 @@ def coerce(other) bad_coercible = klass.new -> { 4.2 <=> bad_coercible - }.should raise_error(TypeError, "coerce must return [x, y]") + }.should.raise(TypeError, "coerce must return [x, y]") end it "returns the correct result when one side is infinite" do diff --git a/spec/ruby/core/float/constants_spec.rb b/spec/ruby/core/float/constants_spec.rb index 497e0ae18846a9..1b71ee8adfd7d6 100644 --- a/spec/ruby/core/float/constants_spec.rb +++ b/spec/ruby/core/float/constants_spec.rb @@ -50,6 +50,6 @@ end it "NAN is 'not a number'" do - Float::NAN.nan?.should be_true + Float::NAN.nan?.should == true end end diff --git a/spec/ruby/core/float/denominator_spec.rb b/spec/ruby/core/float/denominator_spec.rb index 6f4fcfcf2301ae..85beaa98cd14e8 100644 --- a/spec/ruby/core/float/denominator_spec.rb +++ b/spec/ruby/core/float/denominator_spec.rb @@ -12,7 +12,7 @@ it "returns an Integer" do @numbers.each do |number| - number.denominator.should be_kind_of(Integer) + number.denominator.should.is_a?(Integer) end end diff --git a/spec/ruby/core/float/divide_spec.rb b/spec/ruby/core/float/divide_spec.rb index 72ab7527bd52bf..68a2c550a75d0e 100644 --- a/spec/ruby/core/float/divide_spec.rb +++ b/spec/ruby/core/float/divide_spec.rb @@ -16,25 +16,25 @@ end it "returns +Infinity when dividing non-zero by zero of the same sign" do - (1.0 / 0.0).should be_positive_infinity - (-1.0 / -0.0).should be_positive_infinity + (1.0 / 0.0).should.infinite? == 1 + (-1.0 / -0.0).should.infinite? == 1 end it "returns -Infinity when dividing non-zero by zero of opposite sign" do - (-1.0 / 0.0).should be_negative_infinity - (1.0 / -0.0).should be_negative_infinity + (-1.0 / 0.0).should.infinite? == -1 + (1.0 / -0.0).should.infinite? == -1 end it "returns NaN when dividing zero by zero" do - (0.0 / 0.0).should be_nan - (-0.0 / 0.0).should be_nan - (0.0 / -0.0).should be_nan - (-0.0 / -0.0).should be_nan + (0.0 / 0.0).should.nan? + (-0.0 / 0.0).should.nan? + (0.0 / -0.0).should.nan? + (-0.0 / -0.0).should.nan? end it "raises a TypeError when given a non-Numeric" do - -> { 13.0 / "10" }.should raise_error(TypeError) - -> { 13.0 / :symbol }.should raise_error(TypeError) + -> { 13.0 / "10" }.should.raise(TypeError) + -> { 13.0 / :symbol }.should.raise(TypeError) end it "divides correctly by Rational numbers" do diff --git a/spec/ruby/core/float/divmod_spec.rb b/spec/ruby/core/float/divmod_spec.rb index dad45a9b896f13..7ed6cd348701a3 100644 --- a/spec/ruby/core/float/divmod_spec.rb +++ b/spec/ruby/core/float/divmod_spec.rb @@ -3,41 +3,41 @@ describe "Float#divmod" do it "returns an [quotient, modulus] from dividing self by other" do values = 3.14.divmod(2) - values[0].should eql(1) + values[0].should.eql?(1) values[1].should be_close(1.14, TOLERANCE) values = 2.8284.divmod(3.1415) - values[0].should eql(0) + values[0].should.eql?(0) values[1].should be_close(2.8284, TOLERANCE) values = -1.0.divmod(bignum_value) - values[0].should eql(-1) + values[0].should.eql?(-1) values[1].should be_close(18446744073709551616.0, TOLERANCE) values = -1.0.divmod(1) - values[0].should eql(-1) - values[1].should eql(0.0) + values[0].should.eql?(-1) + values[1].should.eql?(0.0) end # Behaviour established as correct in r23953 it "raises a FloatDomainError if self is NaN" do - -> { nan_value.divmod(1) }.should raise_error(FloatDomainError) + -> { nan_value.divmod(1) }.should.raise(FloatDomainError) end # Behaviour established as correct in r23953 it "raises a FloatDomainError if other is NaN" do - -> { 1.0.divmod(nan_value) }.should raise_error(FloatDomainError) + -> { 1.0.divmod(nan_value) }.should.raise(FloatDomainError) end # Behaviour established as correct in r23953 it "raises a FloatDomainError if self is Infinity" do - -> { infinity_value.divmod(1) }.should raise_error(FloatDomainError) + -> { infinity_value.divmod(1) }.should.raise(FloatDomainError) end it "raises a ZeroDivisionError if other is zero" do - -> { 1.0.divmod(0) }.should raise_error(ZeroDivisionError) - -> { 1.0.divmod(0.0) }.should raise_error(ZeroDivisionError) + -> { 1.0.divmod(0) }.should.raise(ZeroDivisionError) + -> { 1.0.divmod(0.0) }.should.raise(ZeroDivisionError) end # redmine #5276" it "returns the correct [quotient, modulus] even for large quotient" do - 0.59.divmod(7.761021455128987e-11).first.should eql(7602092113) + 0.59.divmod(7.761021455128987e-11).first.should.eql?(7602092113) end end diff --git a/spec/ruby/core/float/dup_spec.rb b/spec/ruby/core/float/dup_spec.rb index 294da8e2bcd8b2..b474e21325e6f5 100644 --- a/spec/ruby/core/float/dup_spec.rb +++ b/spec/ruby/core/float/dup_spec.rb @@ -3,6 +3,6 @@ describe "Float#dup" do it "returns self" do float = 2.4 - float.dup.should equal(float) + float.dup.should.equal?(float) end end diff --git a/spec/ruby/core/float/eql_spec.rb b/spec/ruby/core/float/eql_spec.rb index 6b5f91db336b1d..cf1ad8416f5897 100644 --- a/spec/ruby/core/float/eql_spec.rb +++ b/spec/ruby/core/float/eql_spec.rb @@ -2,15 +2,15 @@ describe "Float#eql?" do it "returns true if other is a Float equal to self" do - 0.0.eql?(0.0).should be_true + 0.0.eql?(0.0).should == true end it "returns false if other is a Float not equal to self" do - 1.0.eql?(1.1).should be_false + 1.0.eql?(1.1).should == false end it "returns false if other is not a Float" do - 1.0.eql?(1).should be_false - 1.0.eql?(:one).should be_false + 1.0.eql?(1).should == false + 1.0.eql?(:one).should == false end end diff --git a/spec/ruby/core/float/float_spec.rb b/spec/ruby/core/float/float_spec.rb index 263ae820792a70..46b2eff372b372 100644 --- a/spec/ruby/core/float/float_spec.rb +++ b/spec/ruby/core/float/float_spec.rb @@ -8,12 +8,12 @@ it ".allocate raises a TypeError" do -> do Float.allocate - end.should raise_error(TypeError) + end.should.raise(TypeError) end it ".new is undefined" do -> do Float.new - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/float/floor_spec.rb b/spec/ruby/core/float/floor_spec.rb index 1fafdadee9b6d7..f77300eb048eb3 100644 --- a/spec/ruby/core/float/floor_spec.rb +++ b/spec/ruby/core/float/floor_spec.rb @@ -7,22 +7,22 @@ end it "returns the largest Integer less than or equal to self" do - -1.2.floor.should eql( -2) - -1.0.floor.should eql( -1) - 0.0.floor.should eql( 0 ) - 1.0.floor.should eql( 1 ) - 5.9.floor.should eql( 5 ) - -9223372036854775808.1.floor.should eql(-9223372036854775808) - +9223372036854775808.1.floor.should eql(+9223372036854775808) + -1.2.floor.should.eql?( -2) + -1.0.floor.should.eql?( -1) + 0.0.floor.should.eql?( 0 ) + 1.0.floor.should.eql?( 1 ) + 5.9.floor.should.eql?( 5 ) + -9223372036854775808.1.floor.should.eql?(-9223372036854775808) + +9223372036854775808.1.floor.should.eql?(+9223372036854775808) end it "returns the largest number less than or equal to self with an optionally given precision" do - 2.1679.floor(0).should eql(2) - 214.94.floor(-1).should eql(210) - 7.0.floor(1).should eql(7.0) - 200.0.floor(-2).should eql(200) - -1.234.floor(2).should eql(-1.24) - 5.123812.floor(4).should eql(5.1238) - 10.00001.floor(5).should eql(10.00001) + 2.1679.floor(0).should.eql?(2) + 214.94.floor(-1).should.eql?(210) + 7.0.floor(1).should.eql?(7.0) + 200.0.floor(-2).should.eql?(200) + -1.234.floor(2).should.eql?(-1.24) + 5.123812.floor(4).should.eql?(5.1238) + 10.00001.floor(5).should.eql?(10.00001) end end diff --git a/spec/ruby/core/float/gt_spec.rb b/spec/ruby/core/float/gt_spec.rb index 33078e07ceec93..5194796b468417 100644 --- a/spec/ruby/core/float/gt_spec.rb +++ b/spec/ruby/core/float/gt_spec.rb @@ -11,8 +11,8 @@ end it "raises an ArgumentError when given a non-Numeric" do - -> { 5.0 > "4" }.should raise_error(ArgumentError) - -> { 5.0 > mock('x') }.should raise_error(ArgumentError) + -> { 5.0 > "4" }.should.raise(ArgumentError) + -> { 5.0 > mock('x') }.should.raise(ArgumentError) end it "returns false if one side is NaN" do diff --git a/spec/ruby/core/float/gte_spec.rb b/spec/ruby/core/float/gte_spec.rb index 44c0a81b43cc64..4a62725d539158 100644 --- a/spec/ruby/core/float/gte_spec.rb +++ b/spec/ruby/core/float/gte_spec.rb @@ -11,8 +11,8 @@ end it "raises an ArgumentError when given a non-Numeric" do - -> { 5.0 >= "4" }.should raise_error(ArgumentError) - -> { 5.0 >= mock('x') }.should raise_error(ArgumentError) + -> { 5.0 >= "4" }.should.raise(ArgumentError) + -> { 5.0 >= mock('x') }.should.raise(ArgumentError) end it "returns false if one side is NaN" do diff --git a/spec/ruby/core/float/lt_spec.rb b/spec/ruby/core/float/lt_spec.rb index 94dcfc42f88ce5..0f0e1752bd86ff 100644 --- a/spec/ruby/core/float/lt_spec.rb +++ b/spec/ruby/core/float/lt_spec.rb @@ -11,8 +11,8 @@ end it "raises an ArgumentError when given a non-Numeric" do - -> { 5.0 < "4" }.should raise_error(ArgumentError) - -> { 5.0 < mock('x') }.should raise_error(ArgumentError) + -> { 5.0 < "4" }.should.raise(ArgumentError) + -> { 5.0 < mock('x') }.should.raise(ArgumentError) end it "returns false if one side is NaN" do diff --git a/spec/ruby/core/float/lte_spec.rb b/spec/ruby/core/float/lte_spec.rb index 7b5a86ee76d959..afb64ade097dd9 100644 --- a/spec/ruby/core/float/lte_spec.rb +++ b/spec/ruby/core/float/lte_spec.rb @@ -12,8 +12,8 @@ end it "raises an ArgumentError when given a non-Numeric" do - -> { 5.0 <= "4" }.should raise_error(ArgumentError) - -> { 5.0 <= mock('x') }.should raise_error(ArgumentError) + -> { 5.0 <= "4" }.should.raise(ArgumentError) + -> { 5.0 <= mock('x') }.should.raise(ArgumentError) end it "returns false if one side is NaN" do diff --git a/spec/ruby/core/float/multiply_spec.rb b/spec/ruby/core/float/multiply_spec.rb index 2adb8796cde368..edaaba7e612745 100644 --- a/spec/ruby/core/float/multiply_spec.rb +++ b/spec/ruby/core/float/multiply_spec.rb @@ -11,7 +11,7 @@ end it "raises a TypeError when given a non-Numeric" do - -> { 13.0 * "10" }.should raise_error(TypeError) - -> { 13.0 * :symbol }.should raise_error(TypeError) + -> { 13.0 * "10" }.should.raise(TypeError) + -> { 13.0 * :symbol }.should.raise(TypeError) end end diff --git a/spec/ruby/core/float/negative_spec.rb b/spec/ruby/core/float/negative_spec.rb index 511d92ade6d391..484e636adbc6d4 100644 --- a/spec/ruby/core/float/negative_spec.rb +++ b/spec/ruby/core/float/negative_spec.rb @@ -3,31 +3,31 @@ describe "Float#negative?" do describe "on positive numbers" do it "returns false" do - 0.1.negative?.should be_false + 0.1.negative?.should == false end end describe "on zero" do it "returns false" do - 0.0.negative?.should be_false + 0.0.negative?.should == false end end describe "on negative zero" do it "returns false" do - -0.0.negative?.should be_false + -0.0.negative?.should == false end end describe "on negative numbers" do it "returns true" do - -0.1.negative?.should be_true + -0.1.negative?.should == true end end describe "on NaN" do it "returns false" do - nan_value.negative?.should be_false + nan_value.negative?.should == false end end end diff --git a/spec/ruby/core/float/next_float_spec.rb b/spec/ruby/core/float/next_float_spec.rb index 29e2d311463e0a..59892be343f46e 100644 --- a/spec/ruby/core/float/next_float_spec.rb +++ b/spec/ruby/core/float/next_float_spec.rb @@ -9,7 +9,7 @@ barely_positive.should < barely_positive.next_float midpoint = barely_positive / 2 - [0.0, barely_positive].should include midpoint + [0.0, barely_positive].should.include? midpoint end it "returns Float::INFINITY for Float::INFINITY" do diff --git a/spec/ruby/core/float/numerator_spec.rb b/spec/ruby/core/float/numerator_spec.rb index 7832e8f05650d0..53b32fdd3d63d0 100644 --- a/spec/ruby/core/float/numerator_spec.rb +++ b/spec/ruby/core/float/numerator_spec.rb @@ -15,7 +15,7 @@ it "converts self to a Rational object then returns its numerator" do @numbers.each do |number| - number.infinite?.should be_nil + number.infinite?.should == nil number.numerator.should == Rational(number).numerator end end @@ -25,7 +25,7 @@ end it "returns NaN for NaN" do - nan_value.numerator.nan?.should be_true + nan_value.numerator.nan?.should == true end it "returns Infinity for Infinity" do diff --git a/spec/ruby/core/float/positive_spec.rb b/spec/ruby/core/float/positive_spec.rb index 575f92a720fe55..aa87c03151f991 100644 --- a/spec/ruby/core/float/positive_spec.rb +++ b/spec/ruby/core/float/positive_spec.rb @@ -3,31 +3,31 @@ describe "Float#positive?" do describe "on positive numbers" do it "returns true" do - 0.1.positive?.should be_true + 0.1.positive?.should == true end end describe "on zero" do it "returns false" do - 0.0.positive?.should be_false + 0.0.positive?.should == false end end describe "on negative zero" do it "returns false" do - -0.0.positive?.should be_false + -0.0.positive?.should == false end end describe "on negative numbers" do it "returns false" do - -0.1.positive?.should be_false + -0.1.positive?.should == false end end describe "on NaN" do it "returns false" do - nan_value.positive?.should be_false + nan_value.positive?.should == false end end end diff --git a/spec/ruby/core/float/prev_float_spec.rb b/spec/ruby/core/float/prev_float_spec.rb index 5e50269da76055..2d1f136254a3f0 100644 --- a/spec/ruby/core/float/prev_float_spec.rb +++ b/spec/ruby/core/float/prev_float_spec.rb @@ -9,7 +9,7 @@ barely_negative.should > barely_negative.prev_float midpoint = barely_negative / 2 - [0.0, barely_negative].should include midpoint + [0.0, barely_negative].should.include? midpoint end it "returns -Float::INFINITY for -Float::INFINITY" do diff --git a/spec/ruby/core/float/rationalize_spec.rb b/spec/ruby/core/float/rationalize_spec.rb index 0c5bef7ac44da0..fa8fb5c841ab0b 100644 --- a/spec/ruby/core/float/rationalize_spec.rb +++ b/spec/ruby/core/float/rationalize_spec.rb @@ -29,15 +29,15 @@ end it "raises a FloatDomainError for Infinity" do - -> {infinity_value.rationalize}.should raise_error(FloatDomainError) + -> {infinity_value.rationalize}.should.raise(FloatDomainError) end it "raises a FloatDomainError for NaN" do - -> { nan_value.rationalize }.should raise_error(FloatDomainError) + -> { nan_value.rationalize }.should.raise(FloatDomainError) end it "raises ArgumentError when passed more than one argument" do - -> { 0.3.rationalize(0.1, 0.1) }.should raise_error(ArgumentError) - -> { 0.3.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError) + -> { 0.3.rationalize(0.1, 0.1) }.should.raise(ArgumentError) + -> { 0.3.rationalize(0.1, 0.1, 2) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/float/round_spec.rb b/spec/ruby/core/float/round_spec.rb index 3e6575100bd52a..63c1d5689cb67a 100644 --- a/spec/ruby/core/float/round_spec.rb +++ b/spec/ruby/core/float/round_spec.rb @@ -16,17 +16,17 @@ end it "raises FloatDomainError for exceptional values" do - -> { (+infinity_value).round }.should raise_error(FloatDomainError) - -> { (-infinity_value).round }.should raise_error(FloatDomainError) - -> { nan_value.round }.should raise_error(FloatDomainError) + -> { (+infinity_value).round }.should.raise(FloatDomainError) + -> { (-infinity_value).round }.should.raise(FloatDomainError) + -> { nan_value.round }.should.raise(FloatDomainError) end it "rounds self to an optionally given precision" do - 5.5.round(0).should eql(6) - 5.7.round(1).should eql(5.7) + 5.5.round(0).should.eql?(6) + 5.7.round(1).should.eql?(5.7) 1.2345678.round(2).should == 1.23 - 123456.78.round(-2).should eql(123500) # rounded up - -123456.78.round(-2).should eql(-123500) + 123456.78.round(-2).should.eql?(123500) # rounded up + -123456.78.round(-2).should.eql?(-123500) 12.345678.round(3.999).should == 12.346 end @@ -36,37 +36,37 @@ end it "returns zero when passed a negative argument with magnitude greater than magnitude of the whole number portion of the Float" do - 0.8346268.round(-1).should eql(0) + 0.8346268.round(-1).should.eql?(0) end it "raises a TypeError when its argument can not be converted to an Integer" do - -> { 1.0.round("4") }.should raise_error(TypeError) - -> { 1.0.round(nil) }.should raise_error(TypeError) + -> { 1.0.round("4") }.should.raise(TypeError) + -> { 1.0.round(nil) }.should.raise(TypeError) end it "raises FloatDomainError for exceptional values when passed a non-positive precision" do - -> { Float::INFINITY.round( 0) }.should raise_error(FloatDomainError) - -> { Float::INFINITY.round(-2) }.should raise_error(FloatDomainError) - -> { (-Float::INFINITY).round( 0) }.should raise_error(FloatDomainError) - -> { (-Float::INFINITY).round(-2) }.should raise_error(FloatDomainError) + -> { Float::INFINITY.round( 0) }.should.raise(FloatDomainError) + -> { Float::INFINITY.round(-2) }.should.raise(FloatDomainError) + -> { (-Float::INFINITY).round( 0) }.should.raise(FloatDomainError) + -> { (-Float::INFINITY).round(-2) }.should.raise(FloatDomainError) end it "raises RangeError for NAN when passed a non-positive precision" do - -> { Float::NAN.round(0) }.should raise_error(RangeError) - -> { Float::NAN.round(-2) }.should raise_error(RangeError) + -> { Float::NAN.round(0) }.should.raise(RangeError) + -> { Float::NAN.round(-2) }.should.raise(RangeError) end it "returns self for exceptional values when passed a non-negative precision" do Float::INFINITY.round(2).should == Float::INFINITY (-Float::INFINITY).round(2).should == -Float::INFINITY - Float::NAN.round(2).should be_nan + Float::NAN.round(2).should.nan? end # redmine:5227 it "works for corner cases" do - 42.0.round(308).should eql(42.0) - 1.0e307.round(2).should eql(1.0e307) - 120.0.round(-1).should eql(120) + 42.0.round(308).should.eql?(42.0) + 1.0e307.round(2).should.eql?(1.0e307) + 120.0.round(-1).should.eql?(120) end # redmine:5271 @@ -79,71 +79,71 @@ end it "returns big values rounded to nearest" do - +2.5e20.round(-20).should eql( +3 * 10 ** 20 ) - -2.5e20.round(-20).should eql( -3 * 10 ** 20 ) + +2.5e20.round(-20).should.eql?( +3 * 10 ** 20 ) + -2.5e20.round(-20).should.eql?( -3 * 10 ** 20 ) end # redmine #5272 it "returns rounded values for big values" do - +2.4e20.round(-20).should eql( +2 * 10 ** 20 ) - -2.4e20.round(-20).should eql( -2 * 10 ** 20 ) - +2.5e200.round(-200).should eql( +3 * 10 ** 200 ) - +2.4e200.round(-200).should eql( +2 * 10 ** 200 ) - -2.5e200.round(-200).should eql( -3 * 10 ** 200 ) - -2.4e200.round(-200).should eql( -2 * 10 ** 200 ) + +2.4e20.round(-20).should.eql?( +2 * 10 ** 20 ) + -2.4e20.round(-20).should.eql?( -2 * 10 ** 20 ) + +2.5e200.round(-200).should.eql?( +3 * 10 ** 200 ) + +2.4e200.round(-200).should.eql?( +2 * 10 ** 200 ) + -2.5e200.round(-200).should.eql?( -3 * 10 ** 200 ) + -2.4e200.round(-200).should.eql?( -2 * 10 ** 200 ) end it "returns different rounded values depending on the half option" do - 2.5.round(half: nil).should eql(3) - 2.5.round(half: :up).should eql(3) - 2.5.round(half: :down).should eql(2) - 2.5.round(half: :even).should eql(2) - 3.5.round(half: nil).should eql(4) - 3.5.round(half: :up).should eql(4) - 3.5.round(half: :down).should eql(3) - 3.5.round(half: :even).should eql(4) - (-2.5).round(half: nil).should eql(-3) - (-2.5).round(half: :up).should eql(-3) - (-2.5).round(half: :down).should eql(-2) - (-2.5).round(half: :even).should eql(-2) + 2.5.round(half: nil).should.eql?(3) + 2.5.round(half: :up).should.eql?(3) + 2.5.round(half: :down).should.eql?(2) + 2.5.round(half: :even).should.eql?(2) + 3.5.round(half: nil).should.eql?(4) + 3.5.round(half: :up).should.eql?(4) + 3.5.round(half: :down).should.eql?(3) + 3.5.round(half: :even).should.eql?(4) + (-2.5).round(half: nil).should.eql?(-3) + (-2.5).round(half: :up).should.eql?(-3) + (-2.5).round(half: :down).should.eql?(-2) + (-2.5).round(half: :even).should.eql?(-2) end it "rounds self to an optionally given precision with a half option" do - 5.55.round(1, half: nil).should eql(5.6) - 5.55.round(1, half: :up).should eql(5.6) - 5.55.round(1, half: :down).should eql(5.5) - 5.55.round(1, half: :even).should eql(5.6) - -5.55.round(1, half: nil).should eql(-5.6) - -5.55.round(1, half: :up).should eql(-5.6) - -5.55.round(1, half: :down).should eql(-5.5) - -5.55.round(1, half: :even).should eql(-5.6) + 5.55.round(1, half: nil).should.eql?(5.6) + 5.55.round(1, half: :up).should.eql?(5.6) + 5.55.round(1, half: :down).should.eql?(5.5) + 5.55.round(1, half: :even).should.eql?(5.6) + -5.55.round(1, half: nil).should.eql?(-5.6) + -5.55.round(1, half: :up).should.eql?(-5.6) + -5.55.round(1, half: :down).should.eql?(-5.5) + -5.55.round(1, half: :even).should.eql?(-5.6) end it "preserves cases where neighbouring floating pointer number increase the decimal places" do - 4.8100000000000005.round(5, half: nil).should eql(4.81) - 4.8100000000000005.round(5, half: :up).should eql(4.81) - 4.8100000000000005.round(5, half: :down).should eql(4.81) - 4.8100000000000005.round(5, half: :even).should eql(4.81) - -4.8100000000000005.round(5, half: nil).should eql(-4.81) - -4.8100000000000005.round(5, half: :up).should eql(-4.81) - -4.8100000000000005.round(5, half: :down).should eql(-4.81) - -4.8100000000000005.round(5, half: :even).should eql(-4.81) - 4.81.round(5, half: nil).should eql(4.81) - 4.81.round(5, half: :up).should eql(4.81) - 4.81.round(5, half: :down).should eql(4.81) - 4.81.round(5, half: :even).should eql(4.81) - -4.81.round(5, half: nil).should eql(-4.81) - -4.81.round(5, half: :up).should eql(-4.81) - -4.81.round(5, half: :down).should eql(-4.81) - -4.81.round(5, half: :even).should eql(-4.81) - 4.809999999999999.round(5, half: nil).should eql(4.81) - 4.809999999999999.round(5, half: :up).should eql(4.81) - 4.809999999999999.round(5, half: :down).should eql(4.81) - 4.809999999999999.round(5, half: :even).should eql(4.81) - -4.809999999999999.round(5, half: nil).should eql(-4.81) - -4.809999999999999.round(5, half: :up).should eql(-4.81) - -4.809999999999999.round(5, half: :down).should eql(-4.81) - -4.809999999999999.round(5, half: :even).should eql(-4.81) + 4.8100000000000005.round(5, half: nil).should.eql?(4.81) + 4.8100000000000005.round(5, half: :up).should.eql?(4.81) + 4.8100000000000005.round(5, half: :down).should.eql?(4.81) + 4.8100000000000005.round(5, half: :even).should.eql?(4.81) + -4.8100000000000005.round(5, half: nil).should.eql?(-4.81) + -4.8100000000000005.round(5, half: :up).should.eql?(-4.81) + -4.8100000000000005.round(5, half: :down).should.eql?(-4.81) + -4.8100000000000005.round(5, half: :even).should.eql?(-4.81) + 4.81.round(5, half: nil).should.eql?(4.81) + 4.81.round(5, half: :up).should.eql?(4.81) + 4.81.round(5, half: :down).should.eql?(4.81) + 4.81.round(5, half: :even).should.eql?(4.81) + -4.81.round(5, half: nil).should.eql?(-4.81) + -4.81.round(5, half: :up).should.eql?(-4.81) + -4.81.round(5, half: :down).should.eql?(-4.81) + -4.81.round(5, half: :even).should.eql?(-4.81) + 4.809999999999999.round(5, half: nil).should.eql?(4.81) + 4.809999999999999.round(5, half: :up).should.eql?(4.81) + 4.809999999999999.round(5, half: :down).should.eql?(4.81) + 4.809999999999999.round(5, half: :even).should.eql?(4.81) + -4.809999999999999.round(5, half: nil).should.eql?(-4.81) + -4.809999999999999.round(5, half: :up).should.eql?(-4.81) + -4.809999999999999.round(5, half: :down).should.eql?(-4.81) + -4.809999999999999.round(5, half: :even).should.eql?(-4.81) end # These numbers are neighbouring floating point numbers round a @@ -151,40 +151,40 @@ # round that value and precision is not lost which might cause # incorrect results. it "does not lose precision during the rounding process" do - 767573.1875850001.round(5, half: nil).should eql(767573.18759) - 767573.1875850001.round(5, half: :up).should eql(767573.18759) - 767573.1875850001.round(5, half: :down).should eql(767573.18759) - 767573.1875850001.round(5, half: :even).should eql(767573.18759) - -767573.1875850001.round(5, half: nil).should eql(-767573.18759) - -767573.1875850001.round(5, half: :up).should eql(-767573.18759) - -767573.1875850001.round(5, half: :down).should eql(-767573.18759) - -767573.1875850001.round(5, half: :even).should eql(-767573.18759) - 767573.187585.round(5, half: nil).should eql(767573.18759) - 767573.187585.round(5, half: :up).should eql(767573.18759) - 767573.187585.round(5, half: :down).should eql(767573.18758) - 767573.187585.round(5, half: :even).should eql(767573.18758) - -767573.187585.round(5, half: nil).should eql(-767573.18759) - -767573.187585.round(5, half: :up).should eql(-767573.18759) - -767573.187585.round(5, half: :down).should eql(-767573.18758) - -767573.187585.round(5, half: :even).should eql(-767573.18758) - 767573.1875849998.round(5, half: nil).should eql(767573.18758) - 767573.1875849998.round(5, half: :up).should eql(767573.18758) - 767573.1875849998.round(5, half: :down).should eql(767573.18758) - 767573.1875849998.round(5, half: :even).should eql(767573.18758) - -767573.1875849998.round(5, half: nil).should eql(-767573.18758) - -767573.1875849998.round(5, half: :up).should eql(-767573.18758) - -767573.1875849998.round(5, half: :down).should eql(-767573.18758) - -767573.1875849998.round(5, half: :even).should eql(-767573.18758) + 767573.1875850001.round(5, half: nil).should.eql?(767573.18759) + 767573.1875850001.round(5, half: :up).should.eql?(767573.18759) + 767573.1875850001.round(5, half: :down).should.eql?(767573.18759) + 767573.1875850001.round(5, half: :even).should.eql?(767573.18759) + -767573.1875850001.round(5, half: nil).should.eql?(-767573.18759) + -767573.1875850001.round(5, half: :up).should.eql?(-767573.18759) + -767573.1875850001.round(5, half: :down).should.eql?(-767573.18759) + -767573.1875850001.round(5, half: :even).should.eql?(-767573.18759) + 767573.187585.round(5, half: nil).should.eql?(767573.18759) + 767573.187585.round(5, half: :up).should.eql?(767573.18759) + 767573.187585.round(5, half: :down).should.eql?(767573.18758) + 767573.187585.round(5, half: :even).should.eql?(767573.18758) + -767573.187585.round(5, half: nil).should.eql?(-767573.18759) + -767573.187585.round(5, half: :up).should.eql?(-767573.18759) + -767573.187585.round(5, half: :down).should.eql?(-767573.18758) + -767573.187585.round(5, half: :even).should.eql?(-767573.18758) + 767573.1875849998.round(5, half: nil).should.eql?(767573.18758) + 767573.1875849998.round(5, half: :up).should.eql?(767573.18758) + 767573.1875849998.round(5, half: :down).should.eql?(767573.18758) + 767573.1875849998.round(5, half: :even).should.eql?(767573.18758) + -767573.1875849998.round(5, half: nil).should.eql?(-767573.18758) + -767573.1875849998.round(5, half: :up).should.eql?(-767573.18758) + -767573.1875849998.round(5, half: :down).should.eql?(-767573.18758) + -767573.1875849998.round(5, half: :even).should.eql?(-767573.18758) end it "raises FloatDomainError for exceptional values with a half option" do - -> { (+infinity_value).round(half: :up) }.should raise_error(FloatDomainError) - -> { (-infinity_value).round(half: :down) }.should raise_error(FloatDomainError) - -> { nan_value.round(half: :even) }.should raise_error(FloatDomainError) + -> { (+infinity_value).round(half: :up) }.should.raise(FloatDomainError) + -> { (-infinity_value).round(half: :down) }.should.raise(FloatDomainError) + -> { nan_value.round(half: :even) }.should.raise(FloatDomainError) end it "raise for a non-existent round mode" do - -> { 14.2.round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense") + -> { 14.2.round(half: :nonsense) }.should.raise(ArgumentError, "invalid rounding mode: nonsense") end describe "when 0.0 is given" do diff --git a/spec/ruby/core/float/shared/abs.rb b/spec/ruby/core/float/shared/abs.rb index 607983322d2995..ab21480e24f3cb 100644 --- a/spec/ruby/core/float/shared/abs.rb +++ b/spec/ruby/core/float/shared/abs.rb @@ -16,6 +16,6 @@ end it "returns NaN if NaN" do - nan_value.send(@method).nan?.should be_true + nan_value.send(@method).nan?.should == true end end diff --git a/spec/ruby/core/float/shared/arg.rb b/spec/ruby/core/float/shared/arg.rb index 136cf19ec89655..de0024313da8c8 100644 --- a/spec/ruby/core/float/shared/arg.rb +++ b/spec/ruby/core/float/shared/arg.rb @@ -1,12 +1,12 @@ describe :float_arg, shared: true do it "returns NaN if NaN" do f = nan_value - f.send(@method).nan?.should be_true + f.send(@method).nan?.should == true end it "returns self if NaN" do f = nan_value - f.send(@method).should equal(f) + f.send(@method).should.equal?(f) end it "returns 0 if positive" do diff --git a/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb b/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb index eec92d858ffb72..bd3bf9019fe23f 100644 --- a/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb +++ b/spec/ruby/core/float/shared/arithmetic_exception_in_coerce.rb @@ -6,6 +6,6 @@ b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError) # e.g. 1.0 > b - -> { 1.0.send(@method, b) }.should raise_error(FloatSpecs::CoerceError) + -> { 1.0.send(@method, b) }.should.raise(FloatSpecs::CoerceError) end end diff --git a/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb b/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb index 3e2c1e28dd0417..eec5d8daf9e667 100644 --- a/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb +++ b/spec/ruby/core/float/shared/comparison_exception_in_coerce.rb @@ -6,6 +6,6 @@ b.should_receive(:coerce).and_raise(FloatSpecs::CoerceError) # e.g. 1.0 > b - -> { 1.0.send(@method, b) }.should raise_error(FloatSpecs::CoerceError) + -> { 1.0.send(@method, b) }.should.raise(FloatSpecs::CoerceError) end end diff --git a/spec/ruby/core/float/shared/modulo.rb b/spec/ruby/core/float/shared/modulo.rb index 6700bd4f4ecd44..1efee1476d3c69 100644 --- a/spec/ruby/core/float/shared/modulo.rb +++ b/spec/ruby/core/float/shared/modulo.rb @@ -16,13 +16,13 @@ end it "returns NaN when called on NaN or Infinities" do - Float::NAN.send(@method, 42).should be_nan - Float::INFINITY.send(@method, 42).should be_nan - (-Float::INFINITY).send(@method, 42).should be_nan + Float::NAN.send(@method, 42).should.nan? + Float::INFINITY.send(@method, 42).should.nan? + (-Float::INFINITY).send(@method, 42).should.nan? end it "returns NaN when modulus is NaN" do - 4.2.send(@method, Float::NAN).should be_nan + 4.2.send(@method, Float::NAN).should.nan? end it "returns -0.0 when called on -0.0 with a non zero modulus" do @@ -42,7 +42,7 @@ end it "raises a ZeroDivisionError if other is zero" do - -> { 1.0.send(@method, 0) }.should raise_error(ZeroDivisionError) - -> { 1.0.send(@method, 0.0) }.should raise_error(ZeroDivisionError) + -> { 1.0.send(@method, 0) }.should.raise(ZeroDivisionError) + -> { 1.0.send(@method, 0.0) }.should.raise(ZeroDivisionError) end end diff --git a/spec/ruby/core/float/shared/quo.rb b/spec/ruby/core/float/shared/quo.rb index 0c90171b87d9f6..930187aaf7b40b 100644 --- a/spec/ruby/core/float/shared/quo.rb +++ b/spec/ruby/core/float/shared/quo.rb @@ -12,8 +12,8 @@ end it "returns NaN when the argument is NaN" do - -1819.999999.send(@method, nan_value).nan?.should be_true - 11109.1981271.send(@method, nan_value).nan?.should be_true + -1819.999999.send(@method, nan_value).nan?.should == true + 11109.1981271.send(@method, nan_value).nan?.should == true end it "returns Infinity when the argument is 0.0" do @@ -50,10 +50,10 @@ end it "raises a TypeError when argument isn't numeric" do - -> { 27292.2.send(@method, mock('non-numeric')) }.should raise_error(TypeError) + -> { 27292.2.send(@method, mock('non-numeric')) }.should.raise(TypeError) end it "raises an ArgumentError when passed multiple arguments" do - -> { 272.221.send(@method, 6,0.2) }.should raise_error(ArgumentError) + -> { 272.221.send(@method, 6,0.2) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/float/shared/to_i.rb b/spec/ruby/core/float/shared/to_i.rb index 33b32ca5332d8d..1e6f9414671f80 100644 --- a/spec/ruby/core/float/shared/to_i.rb +++ b/spec/ruby/core/float/shared/to_i.rb @@ -1,14 +1,14 @@ describe :float_to_i, shared: true do it "returns self truncated to an Integer" do - 899.2.send(@method).should eql(899) - -1.122256e-45.send(@method).should eql(0) - 5_213_451.9201.send(@method).should eql(5213451) - 1.233450999123389e+12.send(@method).should eql(1233450999123) - -9223372036854775808.1.send(@method).should eql(-9223372036854775808) - 9223372036854775808.1.send(@method).should eql(9223372036854775808) + 899.2.send(@method).should.eql?(899) + -1.122256e-45.send(@method).should.eql?(0) + 5_213_451.9201.send(@method).should.eql?(5213451) + 1.233450999123389e+12.send(@method).should.eql?(1233450999123) + -9223372036854775808.1.send(@method).should.eql?(-9223372036854775808) + 9223372036854775808.1.send(@method).should.eql?(9223372036854775808) end it "raises a FloatDomainError for NaN" do - -> { nan_value.send(@method) }.should raise_error(FloatDomainError) + -> { nan_value.send(@method) }.should.raise(FloatDomainError) end end diff --git a/spec/ruby/core/float/shared/to_s.rb b/spec/ruby/core/float/shared/to_s.rb index 0925efc0f75fa5..81ffdd9e81464d 100644 --- a/spec/ruby/core/float/shared/to_s.rb +++ b/spec/ruby/core/float/shared/to_s.rb @@ -297,12 +297,12 @@ it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do Encoding.default_internal = nil - 1.23.send(@method).encoding.should equal(Encoding::US_ASCII) + 1.23.send(@method).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 - 5.47.send(@method).encoding.should equal(Encoding::US_ASCII) + 5.47.send(@method).encoding.should.equal?(Encoding::US_ASCII) end end end diff --git a/spec/ruby/core/float/truncate_spec.rb b/spec/ruby/core/float/truncate_spec.rb index 2c80145f9f84cc..1750e3fdbc0822 100644 --- a/spec/ruby/core/float/truncate_spec.rb +++ b/spec/ruby/core/float/truncate_spec.rb @@ -5,10 +5,10 @@ it_behaves_like :float_to_i, :truncate it "returns self truncated to an optionally given precision" do - 2.1679.truncate(0).should eql(2) - 7.1.truncate(1).should eql(7.1) - 214.94.truncate(-1).should eql(210) - -1.234.truncate(2).should eql(-1.23) - 5.123812.truncate(4).should eql(5.1238) + 2.1679.truncate(0).should.eql?(2) + 7.1.truncate(1).should.eql?(7.1) + 214.94.truncate(-1).should.eql?(210) + -1.234.truncate(2).should.eql?(-1.23) + 5.123812.truncate(4).should.eql?(5.1238) end end diff --git a/spec/ruby/core/float/uplus_spec.rb b/spec/ruby/core/float/uplus_spec.rb index 936123558c1d1f..b979b2717a4c21 100644 --- a/spec/ruby/core/float/uplus_spec.rb +++ b/spec/ruby/core/float/uplus_spec.rb @@ -4,6 +4,6 @@ it "returns the same value with same sign (twos complement)" do 34.56.send(:+@).should == 34.56 -34.56.send(:+@).should == -34.56 - 0.0.send(:+@).should eql(0.0) + 0.0.send(:+@).should.eql?(0.0) end end diff --git a/spec/ruby/core/gc/config_spec.rb b/spec/ruby/core/gc/config_spec.rb index db452b0907f58b..57160f122ca0f1 100644 --- a/spec/ruby/core/gc/config_spec.rb +++ b/spec/ruby/core/gc/config_spec.rb @@ -4,12 +4,12 @@ describe "GC.config" do context "without arguments" do it "returns a hash of current settings" do - GC.config.should be_kind_of(Hash) + GC.config.should.is_a?(Hash) end it "includes the name of currently loaded GC implementation as a global key" do - GC.config.should include(:implementation) - GC.config[:implementation].should be_kind_of(String) + GC.config.should.include?(:implementation) + GC.config[:implementation].should.is_a?(String) end end @@ -55,7 +55,7 @@ end it "raises an ArgumentError if options include global keys" do - -> { GC.config(implementation: "default") }.should raise_error(ArgumentError, 'Attempting to set read-only key "Implementation"') + -> { GC.config(implementation: "default") }.should.raise(ArgumentError, 'Attempting to set read-only key "Implementation"') end end @@ -65,9 +65,9 @@ end it "raises ArgumentError for all other arguments" do - -> { GC.config([]) }.should raise_error(ArgumentError) - -> { GC.config("default") }.should raise_error(ArgumentError) - -> { GC.config(1) }.should raise_error(ArgumentError) + -> { GC.config([]) }.should.raise(ArgumentError) + -> { GC.config("default") }.should.raise(ArgumentError) + -> { GC.config(1) }.should.raise(ArgumentError) end end @@ -82,8 +82,8 @@ end it "includes :rgengc_allow_full_mark option, true by default" do - GC.config.should include(:rgengc_allow_full_mark) - GC.config[:rgengc_allow_full_mark].should be_true + GC.config.should.include?(:rgengc_allow_full_mark) + GC.config[:rgengc_allow_full_mark].should == true end it "allows to set :rgengc_allow_full_mark" do diff --git a/spec/ruby/core/gc/count_spec.rb b/spec/ruby/core/gc/count_spec.rb index af2fbbe713d364..fe20c4ed2bf956 100644 --- a/spec/ruby/core/gc/count_spec.rb +++ b/spec/ruby/core/gc/count_spec.rb @@ -2,7 +2,7 @@ describe "GC.count" do it "returns an integer" do - GC.count.should be_kind_of(Integer) + GC.count.should.is_a?(Integer) end it "increases as collections are run" do diff --git a/spec/ruby/core/gc/profiler/enabled_spec.rb b/spec/ruby/core/gc/profiler/enabled_spec.rb index 23677be555fd3b..cfcd0951f0fcc9 100644 --- a/spec/ruby/core/gc/profiler/enabled_spec.rb +++ b/spec/ruby/core/gc/profiler/enabled_spec.rb @@ -11,11 +11,11 @@ it "reports as enabled when enabled" do GC::Profiler.enable - GC::Profiler.enabled?.should be_true + GC::Profiler.enabled?.should == true end it "reports as disabled when disabled" do GC::Profiler.disable - GC::Profiler.enabled?.should be_false + GC::Profiler.enabled?.should == false end end diff --git a/spec/ruby/core/gc/profiler/result_spec.rb b/spec/ruby/core/gc/profiler/result_spec.rb index 2ab46a83710d14..e888f975dc2cf2 100644 --- a/spec/ruby/core/gc/profiler/result_spec.rb +++ b/spec/ruby/core/gc/profiler/result_spec.rb @@ -2,6 +2,6 @@ describe "GC::Profiler.result" do it "returns a string" do - GC::Profiler.result.should be_kind_of(String) + GC::Profiler.result.should.is_a?(String) end end diff --git a/spec/ruby/core/gc/profiler/total_time_spec.rb b/spec/ruby/core/gc/profiler/total_time_spec.rb index 7709f168dd5ee6..a351e922af6a6c 100644 --- a/spec/ruby/core/gc/profiler/total_time_spec.rb +++ b/spec/ruby/core/gc/profiler/total_time_spec.rb @@ -2,6 +2,6 @@ describe "GC::Profiler.total_time" do it "returns an float" do - GC::Profiler.total_time.should be_kind_of(Float) + GC::Profiler.total_time.should.is_a?(Float) end end diff --git a/spec/ruby/core/gc/stat_spec.rb b/spec/ruby/core/gc/stat_spec.rb index 3b43b28a920ae4..6e4800b3e3d965 100644 --- a/spec/ruby/core/gc/stat_spec.rb +++ b/spec/ruby/core/gc/stat_spec.rb @@ -3,7 +3,7 @@ describe "GC.stat" do it "returns hash of values" do stat = GC.stat - stat.should be_kind_of(Hash) + stat.should.is_a?(Hash) stat.keys.should.include?(:count) end @@ -11,18 +11,18 @@ hash = { count: "hello", __other__: "world" } stat = GC.stat(hash) - stat.should be_kind_of(Hash) - stat.should equal hash - stat[:count].should be_kind_of(Integer) + stat.should.is_a?(Hash) + stat.should.equal? hash + stat[:count].should.is_a?(Integer) stat[:__other__].should == "world" end it "the values are all Integer since rb_gc_stat() returns size_t" do - GC.stat.values.each { |value| value.should be_kind_of(Integer) } + GC.stat.values.each { |value| value.should.is_a?(Integer) } end it "can return a single value" do - GC.stat(:count).should be_kind_of(Integer) + GC.stat(:count).should.is_a?(Integer) end it "increases count after GC is run" do @@ -38,25 +38,25 @@ end it "provides some number for count" do - GC.stat(:count).should be_kind_of(Integer) - GC.stat[:count].should be_kind_of(Integer) + GC.stat(:count).should.is_a?(Integer) + GC.stat[:count].should.is_a?(Integer) end it "provides some number for heap_free_slots" do - GC.stat(:heap_free_slots).should be_kind_of(Integer) - GC.stat[:heap_free_slots].should be_kind_of(Integer) + GC.stat(:heap_free_slots).should.is_a?(Integer) + GC.stat[:heap_free_slots].should.is_a?(Integer) end it "provides some number for total_allocated_objects" do - GC.stat(:total_allocated_objects).should be_kind_of(Integer) - GC.stat[:total_allocated_objects].should be_kind_of(Integer) + GC.stat(:total_allocated_objects).should.is_a?(Integer) + GC.stat[:total_allocated_objects].should.is_a?(Integer) end it "raises an error if argument is not nil, a symbol, or a hash" do - -> { GC.stat(7) }.should raise_error(TypeError, "non-hash or symbol given") + -> { GC.stat(7) }.should.raise(TypeError, "non-hash or symbol given") end it "raises an error if an unknown key is given" do - -> { GC.stat(:foo) }.should raise_error(ArgumentError, "unknown key: foo") + -> { GC.stat(:foo) }.should.raise(ArgumentError, "unknown key: foo") end end diff --git a/spec/ruby/core/gc/stress_spec.rb b/spec/ruby/core/gc/stress_spec.rb index ca62c0cb4eb96d..227a795e7f9d02 100644 --- a/spec/ruby/core/gc/stress_spec.rb +++ b/spec/ruby/core/gc/stress_spec.rb @@ -7,11 +7,11 @@ end it "returns current status of GC stress mode" do - GC.stress.should be_false + GC.stress.should == false GC.stress = true - GC.stress.should be_true + GC.stress.should == true GC.stress = false - GC.stress.should be_false + GC.stress.should == false end end @@ -22,6 +22,6 @@ it "sets the stress mode" do GC.stress = true - GC.stress.should be_true + GC.stress.should == true end end diff --git a/spec/ruby/core/gc/total_time_spec.rb b/spec/ruby/core/gc/total_time_spec.rb index a8430fbe9ad76f..f10e0ad742bfa4 100644 --- a/spec/ruby/core/gc/total_time_spec.rb +++ b/spec/ruby/core/gc/total_time_spec.rb @@ -2,7 +2,7 @@ describe "GC.total_time" do it "returns an Integer" do - GC.total_time.should be_kind_of(Integer) + GC.total_time.should.is_a?(Integer) end it "increases as collections are run" do diff --git a/spec/ruby/core/hash/allocate_spec.rb b/spec/ruby/core/hash/allocate_spec.rb index 93420de8668913..a92accc16191c1 100644 --- a/spec/ruby/core/hash/allocate_spec.rb +++ b/spec/ruby/core/hash/allocate_spec.rb @@ -3,7 +3,7 @@ describe "Hash.allocate" do it "returns an instance of Hash" do hsh = Hash.allocate - hsh.should be_an_instance_of(Hash) + hsh.should.instance_of?(Hash) end it "returns a fully-formed instance of Hash" do diff --git a/spec/ruby/core/hash/assoc_spec.rb b/spec/ruby/core/hash/assoc_spec.rb index 62b2a11b30024c..51af51a20f77f2 100644 --- a/spec/ruby/core/hash/assoc_spec.rb +++ b/spec/ruby/core/hash/assoc_spec.rb @@ -6,7 +6,7 @@ end it "returns an Array if the argument is == to a key of the Hash" do - @h.assoc(:apple).should be_an_instance_of(Array) + @h.assoc(:apple).should.instance_of?(Array) end it "returns a 2-element Array if the argument is == to a key of the Hash" do @@ -40,11 +40,11 @@ end it "returns nil if the argument is not a key of the Hash" do - @h.assoc(:green).should be_nil + @h.assoc(:green).should == nil end it "returns nil if the argument is not a key of the Hash even when there is a default" do - Hash.new(42).merge!( foo: :bar ).assoc(42).should be_nil - Hash.new{|h, k| h[k] = 42}.merge!( foo: :bar ).assoc(42).should be_nil + Hash.new(42).merge!( foo: :bar ).assoc(42).should == nil + Hash.new{|h, k| h[k] = 42}.merge!( foo: :bar ).assoc(42).should == nil end end diff --git a/spec/ruby/core/hash/clear_spec.rb b/spec/ruby/core/hash/clear_spec.rb index cf05e36ac9fd45..beff925a63162d 100644 --- a/spec/ruby/core/hash/clear_spec.rb +++ b/spec/ruby/core/hash/clear_spec.rb @@ -4,7 +4,7 @@ describe "Hash#clear" do it "removes all key, value pairs" do h = { 1 => 2, 3 => 4 } - h.clear.should equal(h) + h.clear.should.equal?(h) h.should == {} end @@ -26,7 +26,7 @@ end it "raises a FrozenError if called on a frozen instance" do - -> { HashSpecs.frozen_hash.clear }.should raise_error(FrozenError) - -> { HashSpecs.empty_frozen_hash.clear }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.clear }.should.raise(FrozenError) + -> { HashSpecs.empty_frozen_hash.clear }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/hash/clone_spec.rb b/spec/ruby/core/hash/clone_spec.rb index 6c96fc0c673e0c..d135a844536623 100644 --- a/spec/ruby/core/hash/clone_spec.rb +++ b/spec/ruby/core/hash/clone_spec.rb @@ -7,6 +7,6 @@ clone = hash.clone clone.should == hash - clone.should_not equal hash + clone.should_not.equal? hash end end diff --git a/spec/ruby/core/hash/compact_spec.rb b/spec/ruby/core/hash/compact_spec.rb index 48f8bb7cae166c..de83dabed388d8 100644 --- a/spec/ruby/core/hash/compact_spec.rb +++ b/spec/ruby/core/hash/compact_spec.rb @@ -10,7 +10,7 @@ it "returns new object that rejects pair has nil value" do ret = @hash.compact - ret.should_not equal(@hash) + ret.should_not.equal?(@hash) ret.should == @compact end @@ -50,7 +50,7 @@ end it "returns self" do - @hash.compact!.should equal(@hash) + @hash.compact!.should.equal?(@hash) end it "rejects own pair has nil value" do @@ -64,7 +64,7 @@ end it "returns nil" do - @hash.compact!.should be_nil + @hash.compact!.should == nil end end @@ -74,7 +74,7 @@ end it "keeps pairs and raises a FrozenError" do - ->{ @hash.compact! }.should raise_error(FrozenError) + ->{ @hash.compact! }.should.raise(FrozenError) @hash.should == @initial_pairs end end diff --git a/spec/ruby/core/hash/compare_by_identity_spec.rb b/spec/ruby/core/hash/compare_by_identity_spec.rb index 2975526a97a5f0..1abf9d5666222b 100644 --- a/spec/ruby/core/hash/compare_by_identity_spec.rb +++ b/spec/ruby/core/hash/compare_by_identity_spec.rb @@ -11,7 +11,7 @@ @h[[1]] = :a @h[[1]].should == :a @h.compare_by_identity - @h[[1].dup].should be_nil + @h[[1].dup].should == nil end it "rehashes internally so that old keys can be looked up" do @@ -27,21 +27,21 @@ def o.hash; 123; end it "returns self" do h = {} h[:foo] = :bar - h.compare_by_identity.should equal h + h.compare_by_identity.should.equal? h end it "has no effect on an already compare_by_identity hash" do @idh[:foo] = :bar - @idh.compare_by_identity.should equal @idh + @idh.compare_by_identity.should.equal? @idh @idh.should.compare_by_identity? @idh[:foo].should == :bar end it "uses the semantics of BasicObject#equal? to determine key identity" do - [1].should_not equal([1]) + [1].should_not.equal?([1]) @idh[[1]] = :c @idh[[1]] = :d - :bar.should equal(:bar) + :bar.should.equal?(:bar) @idh[:bar] = :e @idh[:bar] = :f @idh.values.should == [:c, :d, :f] @@ -64,13 +64,13 @@ def o.hash; 123; end it "regards #dup'd objects as having different identities" do key = ['foo'] @idh[key.dup] = :str - @idh[key].should be_nil + @idh[key].should == nil end it "regards #clone'd objects as having different identities" do key = ['foo'] @idh[key.clone] = :str - @idh[key].should be_nil + @idh[key].should == nil end it "regards references to the same object as having the same identity" do @@ -82,7 +82,7 @@ def o.hash; 123; end it "raises a FrozenError on frozen hashes" do @h = @h.freeze - -> { @h.compare_by_identity }.should raise_error(FrozenError) + -> { @h.compare_by_identity }.should.raise(FrozenError) end # Behaviour confirmed in https://bugs.ruby-lang.org/issues/1871 @@ -107,7 +107,7 @@ def o.hash; 123; end @idh[foo] = true @idh[foo] = true @idh.size.should == 1 - @idh.keys.first.should equal foo + @idh.keys.first.should.equal? foo end # Check `#[]=` call with a String literal. @@ -128,20 +128,20 @@ def o.hash; 123; end describe "Hash#compare_by_identity?" do it "returns false by default" do h = {} - h.compare_by_identity?.should be_false + h.compare_by_identity?.should == false end it "returns true once #compare_by_identity has been invoked on self" do h = {} h.compare_by_identity - h.compare_by_identity?.should be_true + h.compare_by_identity?.should == true end it "returns true when called multiple times on the same ident hash" do h = {} h.compare_by_identity - h.compare_by_identity?.should be_true - h.compare_by_identity?.should be_true - h.compare_by_identity?.should be_true + h.compare_by_identity?.should == true + h.compare_by_identity?.should == true + h.compare_by_identity?.should == true end end diff --git a/spec/ruby/core/hash/constructor_spec.rb b/spec/ruby/core/hash/constructor_spec.rb index 301f8675ce27be..c16f373160d65a 100644 --- a/spec/ruby/core/hash/constructor_spec.rb +++ b/spec/ruby/core/hash/constructor_spec.rb @@ -45,22 +45,22 @@ it "raises for elements that are not arrays" do -> { Hash[[:a]] - }.should raise_error(ArgumentError, "wrong element type Symbol at 0 (expected array)") + }.should.raise(ArgumentError, "wrong element type Symbol at 0 (expected array)") -> { Hash[[nil]] - }.should raise_error(ArgumentError, "wrong element type nil at 0 (expected array)") + }.should.raise(ArgumentError, "wrong element type nil at 0 (expected array)") end it "raises an ArgumentError for arrays of more than 2 elements" do ->{ Hash[[[:a, :b, :c]]] - }.should raise_error(ArgumentError, "invalid number of elements (3 for 1..2)") + }.should.raise(ArgumentError, "invalid number of elements (3 for 1..2)") end it "raises an ArgumentError when passed a list of value-invalid-pairs in an array" do -> { Hash[[[:a, 1], [:b], 42, [:d, 2], [:e, 2, 3], []]] - }.should raise_error(ArgumentError, "wrong element type Integer at 2 (expected array)") + }.should.raise(ArgumentError, "wrong element type Integer at 2 (expected array)") end describe "passed a single argument which responds to #to_hash" do @@ -71,13 +71,13 @@ result = Hash[to_hash] result.should == h - result.should_not equal(h) + result.should_not.equal?(h) end end it "raises an ArgumentError when passed an odd number of arguments" do - -> { Hash[1, 2, 3] }.should raise_error(ArgumentError) - -> { Hash[1, 2, { 3 => 4 }] }.should raise_error(ArgumentError) + -> { Hash[1, 2, 3] }.should.raise(ArgumentError) + -> { Hash[1, 2, { 3 => 4 }] }.should.raise(ArgumentError) end it "calls to_hash" do @@ -87,34 +87,34 @@ def obj.to_hash() { 1 => 2, 3 => 4 } end end it "returns an instance of a subclass when passed an Array" do - HashSpecs::MyHash[1,2,3,4].should be_an_instance_of(HashSpecs::MyHash) + HashSpecs::MyHash[1,2,3,4].should.instance_of?(HashSpecs::MyHash) end it "returns instances of subclasses" do - HashSpecs::MyHash[].should be_an_instance_of(HashSpecs::MyHash) + HashSpecs::MyHash[].should.instance_of?(HashSpecs::MyHash) end it "returns an instance of the class it's called on" do Hash[HashSpecs::MyHash[1, 2]].class.should == Hash - HashSpecs::MyHash[Hash[1, 2]].should be_an_instance_of(HashSpecs::MyHash) + HashSpecs::MyHash[Hash[1, 2]].should.instance_of?(HashSpecs::MyHash) end it "does not call #initialize on the subclass instance" do - HashSpecs::MyInitializerHash[Hash[1, 2]].should be_an_instance_of(HashSpecs::MyInitializerHash) + HashSpecs::MyInitializerHash[Hash[1, 2]].should.instance_of?(HashSpecs::MyInitializerHash) end it "does not retain the default value" do hash = Hash.new(1) - Hash[hash].default.should be_nil + Hash[hash].default.should == nil hash[:a] = 1 - Hash[hash].default.should be_nil + Hash[hash].default.should == nil end it "does not retain the default_proc" do hash = Hash.new { |h, k| h[k] = [] } - Hash[hash].default_proc.should be_nil + Hash[hash].default_proc.should == nil hash[:a] = 1 - Hash[hash].default_proc.should be_nil + Hash[hash].default_proc.should == nil end it "does not retain compare_by_identity flag" do diff --git a/spec/ruby/core/hash/deconstruct_keys_spec.rb b/spec/ruby/core/hash/deconstruct_keys_spec.rb index bbcd8932e58eca..f6ff3a2818755f 100644 --- a/spec/ruby/core/hash/deconstruct_keys_spec.rb +++ b/spec/ruby/core/hash/deconstruct_keys_spec.rb @@ -4,13 +4,13 @@ it "returns self" do hash = {a: 1, b: 2} - hash.deconstruct_keys([:a, :b]).should equal hash + hash.deconstruct_keys([:a, :b]).should.equal? hash end it "requires one argument" do -> { {a: 1}.deconstruct_keys - }.should raise_error(ArgumentError, /wrong number of arguments \(given 0, expected 1\)/) + }.should.raise(ArgumentError, /wrong number of arguments \(given 0, expected 1\)/) end it "ignores argument" do diff --git a/spec/ruby/core/hash/default_proc_spec.rb b/spec/ruby/core/hash/default_proc_spec.rb index f4e48036327dd9..4830e02acd248e 100644 --- a/spec/ruby/core/hash/default_proc_spec.rb +++ b/spec/ruby/core/hash/default_proc_spec.rb @@ -25,24 +25,24 @@ h = Hash.new { 'Paris' } obj = mock('to_proc') obj.should_receive(:to_proc).and_return(Proc.new { 'Montreal' }) - (h.default_proc = obj).should equal(obj) + (h.default_proc = obj).should.equal?(obj) h[:cool_city].should == 'Montreal' end it "overrides the static default" do h = Hash.new(42) h.default_proc = Proc.new { 6 } - h.default.should be_nil + h.default.should == nil h.default_proc.call.should == 6 end it "raises an error if passed stuff not convertible to procs" do - ->{{}.default_proc = 42}.should raise_error(TypeError) + ->{{}.default_proc = 42}.should.raise(TypeError) end it "returns the passed Proc" do new_proc = Proc.new {} - ({}.default_proc = new_proc).should equal(new_proc) + ({}.default_proc = new_proc).should.equal?(new_proc) end it "clears the default proc if passed nil" do @@ -53,28 +53,28 @@ end it "returns nil if passed nil" do - ({}.default_proc = nil).should be_nil + ({}.default_proc = nil).should == nil end it "accepts a lambda with an arity of 2" do h = {} -> do h.default_proc = -> a, b { } - end.should_not raise_error(TypeError) + end.should_not.raise(TypeError) end it "raises a TypeError if passed a lambda with an arity other than 2" do h = {} -> do h.default_proc = -> a { } - end.should raise_error(TypeError) + end.should.raise(TypeError) -> do h.default_proc = -> a, b, c { } - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a FrozenError if self is frozen" do - -> { {}.freeze.default_proc = Proc.new {} }.should raise_error(FrozenError) - -> { {}.freeze.default_proc = nil }.should raise_error(FrozenError) + -> { {}.freeze.default_proc = Proc.new {} }.should.raise(FrozenError) + -> { {}.freeze.default_proc = nil }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/hash/default_spec.rb b/spec/ruby/core/hash/default_spec.rb index d8b62ea1960f28..17ee032e2bf06f 100644 --- a/spec/ruby/core/hash/default_spec.rb +++ b/spec/ruby/core/hash/default_spec.rb @@ -40,7 +40,7 @@ end it "raises a FrozenError if called on a frozen instance" do - -> { HashSpecs.frozen_hash.default = nil }.should raise_error(FrozenError) - -> { HashSpecs.empty_frozen_hash.default = nil }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.default = nil }.should.raise(FrozenError) + -> { HashSpecs.empty_frozen_hash.default = nil }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/hash/delete_if_spec.rb b/spec/ruby/core/hash/delete_if_spec.rb index c9e670ffc30482..3090633d88f841 100644 --- a/spec/ruby/core/hash/delete_if_spec.rb +++ b/spec/ruby/core/hash/delete_if_spec.rb @@ -12,13 +12,13 @@ it "removes every entry for which block is true and returns self" do h = { a: 1, b: 2, c: 3, d: 4 } - h.delete_if { |k,v| v % 2 == 1 }.should equal(h) + h.delete_if { |k,v| v % 2 == 1 }.should.equal?(h) h.should == { b: 2, d: 4 } end it "removes all entries if the block is true" do h = { a: 1, b: 2, c: 3 } - h.delete_if { |k,v| true }.should equal(h) + h.delete_if { |k,v| true }.should.equal?(h) h.should == {} end @@ -35,8 +35,8 @@ end it "raises a FrozenError if called on a frozen instance" do - -> { HashSpecs.frozen_hash.delete_if { false } }.should raise_error(FrozenError) - -> { HashSpecs.empty_frozen_hash.delete_if { true } }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.delete_if { false } }.should.raise(FrozenError) + -> { HashSpecs.empty_frozen_hash.delete_if { true } }.should.raise(FrozenError) end it_behaves_like :hash_iteration_no_block, :delete_if diff --git a/spec/ruby/core/hash/delete_spec.rb b/spec/ruby/core/hash/delete_spec.rb index 3e3479c69c9f5a..33ff01bf36539c 100644 --- a/spec/ruby/core/hash/delete_spec.rb +++ b/spec/ruby/core/hash/delete_spec.rb @@ -52,7 +52,7 @@ end it "raises a FrozenError if called on a frozen instance" do - -> { HashSpecs.frozen_hash.delete("foo") }.should raise_error(FrozenError) - -> { HashSpecs.empty_frozen_hash.delete("foo") }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.delete("foo") }.should.raise(FrozenError) + -> { HashSpecs.empty_frozen_hash.delete("foo") }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/hash/dig_spec.rb b/spec/ruby/core/hash/dig_spec.rb index aa0ecadd2f6938..94ac94e8507f5d 100644 --- a/spec/ruby/core/hash/dig_spec.rb +++ b/spec/ruby/core/hash/dig_spec.rb @@ -5,16 +5,16 @@ it "returns #[] with one arg" do h = { 0 => false, a: 1 } h.dig(:a).should == 1 - h.dig(0).should be_false - h.dig(1).should be_nil + h.dig(0).should == false + h.dig(1).should == nil end it "returns the nested value specified by the sequence of keys" do h = { foo: { bar: { baz: 1 } } } h.dig(:foo, :bar, :baz).should == 1 - h.dig(:foo, :bar, :nope).should be_nil - h.dig(:foo, :baz).should be_nil - h.dig(:bar, :baz, :foo).should be_nil + h.dig(:foo, :bar, :nope).should == nil + h.dig(:foo, :baz).should == nil + h.dig(:bar, :baz, :foo).should == nil end it "returns the nested value specified if the sequence includes an index" do @@ -28,7 +28,7 @@ end it "raises an ArgumentError if no arguments provided" do - -> { { the: 'borg' }.dig() }.should raise_error(ArgumentError) + -> { { the: 'borg' }.dig() }.should.raise(ArgumentError) end it "handles type-mixed deep digging" do @@ -47,8 +47,8 @@ def obj.dig(*args); [ 42 ] end it "raises TypeError if an intermediate element does not respond to #dig" do h = {} h[:foo] = [ { bar: [ 1 ] }, [ nil, 'str' ] ] - -> { h.dig(:foo, 0, :bar, 0, 0) }.should raise_error(TypeError) - -> { h.dig(:foo, 1, 1, 0) }.should raise_error(TypeError) + -> { h.dig(:foo, 0, :bar, 0, 0) }.should.raise(TypeError) + -> { h.dig(:foo, 1, 1, 0) }.should.raise(TypeError) end it "calls #dig on the result of #[] with the remaining arguments" do @@ -60,7 +60,7 @@ def obj.dig(*args); [ 42 ] end it "respects Hash's default" do default = {bar: 42} h = Hash.new(default) - h.dig(:foo).should equal default + h.dig(:foo).should.equal? default h.dig(:foo, :bar).should == 42 end end diff --git a/spec/ruby/core/hash/each_key_spec.rb b/spec/ruby/core/hash/each_key_spec.rb index c84dd696d5e24e..5b2e9deb635a0a 100644 --- a/spec/ruby/core/hash/each_key_spec.rb +++ b/spec/ruby/core/hash/each_key_spec.rb @@ -7,7 +7,7 @@ it "calls block once for each key, passing key" do r = {} h = { 1 => -1, 2 => -2, 3 => -3, 4 => -4 } - h.each_key { |k| r[k] = k }.should equal(h) + h.each_key { |k| r[k] = k }.should.equal?(h) r.should == { 1 => 1, 2 => 2, 3 => 3, 4 => 4 } end diff --git a/spec/ruby/core/hash/each_value_spec.rb b/spec/ruby/core/hash/each_value_spec.rb index 19b076730d1156..2df95a8789c2a9 100644 --- a/spec/ruby/core/hash/each_value_spec.rb +++ b/spec/ruby/core/hash/each_value_spec.rb @@ -7,7 +7,7 @@ it "calls block once for each key, passing value" do r = [] h = { a: -5, b: -3, c: -2, d: -1, e: -1 } - h.each_value { |v| r << v }.should equal(h) + h.each_value { |v| r << v }.should.equal?(h) r.sort.should == [-5, -3, -2, -1, -1] end diff --git a/spec/ruby/core/hash/element_reference_spec.rb b/spec/ruby/core/hash/element_reference_spec.rb index d5859cb3427518..3d074b346d06b9 100644 --- a/spec/ruby/core/hash/element_reference_spec.rb +++ b/spec/ruby/core/hash/element_reference_spec.rb @@ -36,7 +36,7 @@ b = h[:b] a << "bar" - a.should equal(b) + a.should.equal?(b) a.should == "foobar" b.should == "foobar" end diff --git a/spec/ruby/core/hash/equal_value_spec.rb b/spec/ruby/core/hash/equal_value_spec.rb index ae13a42679abee..ab14f8148939ea 100644 --- a/spec/ruby/core/hash/equal_value_spec.rb +++ b/spec/ruby/core/hash/equal_value_spec.rb @@ -13,6 +13,6 @@ l_val.should_receive(:==).with(r_val).and_return(true) - ({ 1 => l_val } == { 1 => r_val }).should be_true + ({ 1 => l_val } == { 1 => r_val }).should == true end end diff --git a/spec/ruby/core/hash/except_spec.rb b/spec/ruby/core/hash/except_spec.rb index 026e454b13cabf..77a020e9b7f301 100644 --- a/spec/ruby/core/hash/except_spec.rb +++ b/spec/ruby/core/hash/except_spec.rb @@ -7,7 +7,7 @@ it "returns a new duplicate hash without arguments" do ret = @hash.except - ret.should_not equal(@hash) + ret.should_not.equal?(@hash) ret.should == @hash end @@ -21,17 +21,17 @@ it "does not retain the default value" do h = Hash.new(1) - h.except(:a).default.should be_nil + h.except(:a).default.should == nil h[:a] = 1 - h.except(:a).default.should be_nil + h.except(:a).default.should == nil end it "does not retain the default_proc" do pr = proc { |h, k| h[k] = [] } h = Hash.new(&pr) - h.except(:a).default_proc.should be_nil + h.except(:a).default_proc.should == nil h[:a] = 1 - h.except(:a).default_proc.should be_nil + h.except(:a).default_proc.should == nil end it "retains compare_by_identity flag" do diff --git a/spec/ruby/core/hash/fetch_spec.rb b/spec/ruby/core/hash/fetch_spec.rb index 6e0d20722407f8..f9b80b6c497d37 100644 --- a/spec/ruby/core/hash/fetch_spec.rb +++ b/spec/ruby/core/hash/fetch_spec.rb @@ -12,7 +12,7 @@ it "formats the object with #inspect in the KeyError message" do -> { {}.fetch('foo') - }.should raise_error(KeyError, 'key not found: "foo"') + }.should.raise(KeyError, 'key not found: "foo"') end end @@ -38,7 +38,7 @@ end it "raises an ArgumentError when not passed one or two arguments" do - -> { {}.fetch() }.should raise_error(ArgumentError) - -> { {}.fetch(1, 2, 3) }.should raise_error(ArgumentError) + -> { {}.fetch() }.should.raise(ArgumentError) + -> { {}.fetch(1, 2, 3) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/hash/flatten_spec.rb b/spec/ruby/core/hash/flatten_spec.rb index 825da15bfc586e..18e9a7b56a0c4c 100644 --- a/spec/ruby/core/hash/flatten_spec.rb +++ b/spec/ruby/core/hash/flatten_spec.rb @@ -9,7 +9,7 @@ end it "returns an Array" do - {}.flatten.should be_an_instance_of(Array) + {}.flatten.should.instance_of?(Array) end it "returns an empty Array for an empty Hash" do @@ -57,6 +57,6 @@ it "raises a TypeError if given a non-Integer argument" do -> do @h.flatten(Object.new) - end.should raise_error(TypeError) + end.should.raise(TypeError) end end diff --git a/spec/ruby/core/hash/gt_spec.rb b/spec/ruby/core/hash/gt_spec.rb index cd541d4d831ddd..69d23b7d2939af 100644 --- a/spec/ruby/core/hash/gt_spec.rb +++ b/spec/ruby/core/hash/gt_spec.rb @@ -8,7 +8,7 @@ it "returns false if both hashes are identical" do h = { a: 1, b: 2 } - (h > h).should be_false + (h > h).should == false end end diff --git a/spec/ruby/core/hash/gte_spec.rb b/spec/ruby/core/hash/gte_spec.rb index 99b89e7217800a..be5060ea4f1812 100644 --- a/spec/ruby/core/hash/gte_spec.rb +++ b/spec/ruby/core/hash/gte_spec.rb @@ -8,7 +8,7 @@ it "returns true if both hashes are identical" do h = { a: 1, b: 2 } - (h >= h).should be_true + (h >= h).should == true end end diff --git a/spec/ruby/core/hash/initialize_spec.rb b/spec/ruby/core/hash/initialize_spec.rb index d13496ba3b6f4f..cdba5988138356 100644 --- a/spec/ruby/core/hash/initialize_spec.rb +++ b/spec/ruby/core/hash/initialize_spec.rb @@ -3,7 +3,7 @@ describe "Hash#initialize" do it "is private" do - Hash.should have_private_instance_method("initialize") + Hash.private_instance_methods(false).should.include?(:initialize) end it "can be used to reset default_proc" do @@ -42,20 +42,20 @@ it "returns self" do h = Hash.new - h.send(:initialize).should equal(h) + h.send(:initialize).should.equal?(h) end it "raises a FrozenError if called on a frozen instance" do block = -> { HashSpecs.frozen_hash.instance_eval { initialize() }} - block.should raise_error(FrozenError) + block.should.raise(FrozenError) block = -> { HashSpecs.frozen_hash.instance_eval { initialize(nil) } } - block.should raise_error(FrozenError) + block.should.raise(FrozenError) block = -> { HashSpecs.frozen_hash.instance_eval { initialize(5) } } - block.should raise_error(FrozenError) + block.should.raise(FrozenError) block = -> { HashSpecs.frozen_hash.instance_eval { initialize { 5 } } } - block.should raise_error(FrozenError) + block.should.raise(FrozenError) end end diff --git a/spec/ruby/core/hash/invert_spec.rb b/spec/ruby/core/hash/invert_spec.rb index c06e15ff7cfadf..ea441751f2a3b0 100644 --- a/spec/ruby/core/hash/invert_spec.rb +++ b/spec/ruby/core/hash/invert_spec.rb @@ -27,17 +27,17 @@ it "does not retain the default value" do h = Hash.new(1) - h.invert.default.should be_nil + h.invert.default.should == nil h[:a] = 1 - h.invert.default.should be_nil + h.invert.default.should == nil end it "does not retain the default_proc" do pr = proc { |h, k| h[k] = [] } h = Hash.new(&pr) - h.invert.default_proc.should be_nil + h.invert.default_proc.should == nil h[:a] = 1 - h.invert.default_proc.should be_nil + h.invert.default_proc.should == nil end it "does not retain compare_by_identity flag" do diff --git a/spec/ruby/core/hash/keep_if_spec.rb b/spec/ruby/core/hash/keep_if_spec.rb index d50d9694679260..c975efc5f8479b 100644 --- a/spec/ruby/core/hash/keep_if_spec.rb +++ b/spec/ruby/core/hash/keep_if_spec.rb @@ -12,24 +12,24 @@ it "keeps every entry for which block is true and returns self" do h = { a: 1, b: 2, c: 3, d: 4 } - h.keep_if { |k,v| v % 2 == 0 }.should equal(h) + h.keep_if { |k,v| v % 2 == 0 }.should.equal?(h) h.should == { b: 2, d: 4 } end it "removes all entries if the block is false" do h = { a: 1, b: 2, c: 3 } - h.keep_if { |k,v| false }.should equal(h) + h.keep_if { |k,v| false }.should.equal?(h) h.should == {} end it "returns self even if unmodified" do h = { 1 => 2, 3 => 4 } - h.keep_if { true }.should equal(h) + h.keep_if { true }.should.equal?(h) end it "raises a FrozenError if called on a frozen instance" do - -> { HashSpecs.frozen_hash.keep_if { true } }.should raise_error(FrozenError) - -> { HashSpecs.empty_frozen_hash.keep_if { false } }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.keep_if { true } }.should.raise(FrozenError) + -> { HashSpecs.empty_frozen_hash.keep_if { false } }.should.raise(FrozenError) end it_behaves_like :hash_iteration_no_block, :keep_if diff --git a/spec/ruby/core/hash/keys_spec.rb b/spec/ruby/core/hash/keys_spec.rb index 9a067085e5a138..789c413bee01c5 100644 --- a/spec/ruby/core/hash/keys_spec.rb +++ b/spec/ruby/core/hash/keys_spec.rb @@ -5,11 +5,11 @@ it "returns an array with the keys in the order they were inserted" do {}.keys.should == [] - {}.keys.should be_kind_of(Array) + {}.keys.should.is_a?(Array) Hash.new(5).keys.should == [] Hash.new { 5 }.keys.should == [] { 1 => 2, 4 => 8, 2 => 4 }.keys.should == [1, 4, 2] - { 1 => 2, 2 => 4, 4 => 8 }.keys.should be_kind_of(Array) + { 1 => 2, 2 => 4, 4 => 8 }.keys.should.is_a?(Array) { nil => nil }.keys.should == [nil] end diff --git a/spec/ruby/core/hash/lt_spec.rb b/spec/ruby/core/hash/lt_spec.rb index 221961588030ef..4ca326d07741c8 100644 --- a/spec/ruby/core/hash/lt_spec.rb +++ b/spec/ruby/core/hash/lt_spec.rb @@ -8,7 +8,7 @@ it "returns false if both hashes are identical" do h = { a: 1, b: 2 } - (h < h).should be_false + (h < h).should == false end end diff --git a/spec/ruby/core/hash/lte_spec.rb b/spec/ruby/core/hash/lte_spec.rb index a166e5bca49357..29e60273d17cf5 100644 --- a/spec/ruby/core/hash/lte_spec.rb +++ b/spec/ruby/core/hash/lte_spec.rb @@ -8,7 +8,7 @@ it "returns true if both hashes are identical" do h = { a: 1, b: 2 } - (h <= h).should be_true + (h <= h).should == true end end diff --git a/spec/ruby/core/hash/merge_spec.rb b/spec/ruby/core/hash/merge_spec.rb index 6710d121efb5d7..5fb278ad471809 100644 --- a/spec/ruby/core/hash/merge_spec.rb +++ b/spec/ruby/core/hash/merge_spec.rb @@ -30,7 +30,7 @@ -> { h1.merge(h2) { |k, x, y| raise(IndexError) } - }.should raise_error(IndexError) + }.should.raise(IndexError) r = h1.merge(h1) { |k,x,y| :x } r.should == { a: :x, b: :x, d: :x } @@ -47,8 +47,8 @@ end it "returns subclass instance for subclasses" do - HashSpecs::MyHash[1 => 2, 3 => 4].merge({ 1 => 2 }).should be_an_instance_of(HashSpecs::MyHash) - HashSpecs::MyHash[].merge({ 1 => 2 }).should be_an_instance_of(HashSpecs::MyHash) + HashSpecs::MyHash[1 => 2, 3 => 4].merge({ 1 => 2 }).should.instance_of?(HashSpecs::MyHash) + HashSpecs::MyHash[].merge({ 1 => 2 }).should.instance_of?(HashSpecs::MyHash) { 1 => 2, 3 => 4 }.merge(HashSpecs::MyHash[1 => 2]).class.should == Hash {}.merge(HashSpecs::MyHash[1 => 2]).class.should == Hash @@ -90,8 +90,8 @@ hash = { a: 1 } merged = hash.merge - merged.should eql(hash) - merged.should_not equal(hash) + merged.should.eql?(hash) + merged.should_not.equal?(hash) end it "retains the default value" do diff --git a/spec/ruby/core/hash/new_spec.rb b/spec/ruby/core/hash/new_spec.rb index ca43646ef4b9f1..207fc2931f8c6d 100644 --- a/spec/ruby/core/hash/new_spec.rb +++ b/spec/ruby/core/hash/new_spec.rb @@ -15,7 +15,7 @@ it "does not create a copy of the default argument" do str = "foo" - Hash.new(str).default.should equal(str) + Hash.new(str).default.should.equal?(str) end it "creates a Hash with a default_proc if passed a block" do @@ -27,12 +27,12 @@ end it "raises an ArgumentError if more than one argument is passed" do - -> { Hash.new(5,6) }.should raise_error(ArgumentError) + -> { Hash.new(5,6) }.should.raise(ArgumentError) end it "raises an ArgumentError if passed both default argument and default block" do - -> { Hash.new(5) { 0 } }.should raise_error(ArgumentError) - -> { Hash.new(nil) { 0 } }.should raise_error(ArgumentError) + -> { Hash.new(5) { 0 } }.should.raise(ArgumentError) + -> { Hash.new(nil) { 0 } }.should.raise(ArgumentError) end ruby_version_is ""..."3.4" do @@ -41,8 +41,8 @@ Regexp.new(Regexp.escape("Calling Hash.new with keyword arguments is deprecated and will be removed in Ruby 3.4; use Hash.new({ key: value }) instead")) ) - -> { Hash.new(1, unknown: true) }.should raise_error(ArgumentError) - -> { Hash.new(unknown: true) { 0 } }.should raise_error(ArgumentError) + -> { Hash.new(1, unknown: true) }.should.raise(ArgumentError) + -> { Hash.new(unknown: true) { 0 } }.should.raise(ArgumentError) Hash.new({ unknown: true }).default.should == { unknown: true } end @@ -56,13 +56,13 @@ end it "ignores negative capacity" do - -> { Hash.new(capacity: -42) }.should_not raise_error + -> { Hash.new(capacity: -42) }.should_not.raise end it "raises an error if unknown keyword arguments are passed" do - -> { Hash.new(unknown: true) }.should raise_error(ArgumentError) - -> { Hash.new(1, unknown: true) }.should raise_error(ArgumentError) - -> { Hash.new(unknown: true) { 0 } }.should raise_error(ArgumentError) + -> { Hash.new(unknown: true) }.should.raise(ArgumentError) + -> { Hash.new(1, unknown: true) }.should.raise(ArgumentError) + -> { Hash.new(unknown: true) { 0 } }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/hash/rassoc_spec.rb b/spec/ruby/core/hash/rassoc_spec.rb index f3b2a6de20c81f..73379f6867959a 100644 --- a/spec/ruby/core/hash/rassoc_spec.rb +++ b/spec/ruby/core/hash/rassoc_spec.rb @@ -6,7 +6,7 @@ end it "returns an Array if the argument is a value of the Hash" do - @h.rassoc(:green).should be_an_instance_of(Array) + @h.rassoc(:green).should.instance_of?(Array) end it "returns a 2-element Array if the argument is a value of the Hash" do @@ -28,15 +28,15 @@ it "uses #== to compare the argument to the values" do @h[:key] = 1.0 1.should == 1.0 - @h.rassoc(1).should eql [:key, 1.0] + @h.rassoc(1).should.eql? [:key, 1.0] end it "returns nil if the argument is not a value of the Hash" do - @h.rassoc(:banana).should be_nil + @h.rassoc(:banana).should == nil end it "returns nil if the argument is not a value of the Hash even when there is a default" do - Hash.new(42).merge!( foo: :bar ).rassoc(42).should be_nil - Hash.new{|h, k| h[k] = 42}.merge!( foo: :bar ).rassoc(42).should be_nil + Hash.new(42).merge!( foo: :bar ).rassoc(42).should == nil + Hash.new{|h, k| h[k] = 42}.merge!( foo: :bar ).rassoc(42).should == nil end end diff --git a/spec/ruby/core/hash/rehash_spec.rb b/spec/ruby/core/hash/rehash_spec.rb index db3e91b166ef4a..fcd5a037bdcc88 100644 --- a/spec/ruby/core/hash/rehash_spec.rb +++ b/spec/ruby/core/hash/rehash_spec.rb @@ -20,7 +20,7 @@ def k1.hash; 1; end h.keys.include?(k1).should == true - h.rehash.should equal(h) + h.rehash.should.equal?(h) h.key?(k1).should == true h[k1].should == :v1 end @@ -108,7 +108,7 @@ def eql?(other) end it "raises a FrozenError if called on a frozen instance" do - -> { HashSpecs.frozen_hash.rehash }.should raise_error(FrozenError) - -> { HashSpecs.empty_frozen_hash.rehash }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.rehash }.should.raise(FrozenError) + -> { HashSpecs.empty_frozen_hash.rehash }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/hash/reject_spec.rb b/spec/ruby/core/hash/reject_spec.rb index 8381fc7fc1b743..aa1a0748973619 100644 --- a/spec/ruby/core/hash/reject_spec.rb +++ b/spec/ruby/core/hash/reject_spec.rb @@ -28,8 +28,8 @@ def h.to_a() end context "with extra state" do it "returns Hash instance for subclasses" do - HashSpecs::MyHash[1 => 2, 3 => 4].reject { false }.should be_kind_of(Hash) - HashSpecs::MyHash[1 => 2, 3 => 4].reject { true }.should be_kind_of(Hash) + HashSpecs::MyHash[1 => 2, 3 => 4].reject { false }.should.is_a?(Hash) + HashSpecs::MyHash[1 => 2, 3 => 4].reject { true }.should.is_a?(Hash) end end @@ -46,17 +46,17 @@ def h.to_a() end it "does not retain the default value" do h = Hash.new(1) - h.reject { false }.default.should be_nil + h.reject { false }.default.should == nil h[:a] = 1 - h.reject { false }.default.should be_nil + h.reject { false }.default.should == nil end it "does not retain the default_proc" do pr = proc { |h, k| h[k] = [] } h = Hash.new(&pr) - h.reject { false }.default_proc.should be_nil + h.reject { false }.default_proc.should == nil h[:a] = 1 - h.reject { false }.default_proc.should be_nil + h.reject { false }.default_proc.should == nil end it "retains compare_by_identity flag" do @@ -79,7 +79,7 @@ def h.to_a() end it "removes all entries if the block is true" do h = { a: 1, b: 2, c: 3 } - h.reject! { |k,v| true }.should equal(h) + h.reject! { |k,v| true }.should.equal?(h) h.should == {} end @@ -104,11 +104,11 @@ def h.to_a() end end it "raises a FrozenError if called on a frozen instance that is modified" do - -> { HashSpecs.empty_frozen_hash.reject! { true } }.should raise_error(FrozenError) + -> { HashSpecs.empty_frozen_hash.reject! { true } }.should.raise(FrozenError) end it "raises a FrozenError if called on a frozen instance that would not be modified" do - -> { HashSpecs.frozen_hash.reject! { false } }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.reject! { false } }.should.raise(FrozenError) end it_behaves_like :hash_iteration_no_block, :reject! diff --git a/spec/ruby/core/hash/replace_spec.rb b/spec/ruby/core/hash/replace_spec.rb index db30145e1a7c4a..4dacbf977910e3 100644 --- a/spec/ruby/core/hash/replace_spec.rb +++ b/spec/ruby/core/hash/replace_spec.rb @@ -4,7 +4,7 @@ describe "Hash#replace" do it "replaces the contents of self with other" do h = { a: 1, b: 2 } - h.replace(c: -1, d: -2).should equal(h) + h.replace(c: -1, d: -2).should.equal?(h) h.should == { c: -1, d: -2 } end @@ -25,7 +25,7 @@ it "does not retain the default value" do hash = Hash.new(1) - hash.replace(b: 2).default.should be_nil + hash.replace(b: 2).default.should == nil end it "transfers the default value of an argument" do @@ -36,7 +36,7 @@ it "does not retain the default_proc" do pr = proc { |h, k| h[k] = [] } hash = Hash.new(&pr) - hash.replace(b: 2).default_proc.should be_nil + hash.replace(b: 2).default_proc.should == nil end it "transfers the default_proc of an argument" do @@ -68,12 +68,12 @@ it "raises a FrozenError if called on a frozen instance that would not be modified" do -> do HashSpecs.frozen_hash.replace(HashSpecs.frozen_hash) - end.should raise_error(FrozenError) + end.should.raise(FrozenError) end it "raises a FrozenError if called on a frozen instance that is modified" do -> do HashSpecs.frozen_hash.replace(HashSpecs.empty_frozen_hash) - end.should raise_error(FrozenError) + end.should.raise(FrozenError) end end diff --git a/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb b/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb index ddf9038800005f..609a53f81fc7f4 100644 --- a/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb +++ b/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb @@ -16,7 +16,7 @@ end it "raises TypeError for non-Hash" do - -> { Hash.ruby2_keywords_hash?(nil) }.should raise_error(TypeError) + -> { Hash.ruby2_keywords_hash?(nil) }.should.raise(TypeError) end end @@ -54,7 +54,7 @@ end it "raises TypeError for non-Hash" do - -> { Hash.ruby2_keywords_hash(nil) }.should raise_error(TypeError) + -> { Hash.ruby2_keywords_hash(nil) }.should.raise(TypeError) end it "retains the default value" do diff --git a/spec/ruby/core/hash/shared/comparison.rb b/spec/ruby/core/hash/shared/comparison.rb index 07564e4ceca9df..2b628372320aea 100644 --- a/spec/ruby/core/hash/shared/comparison.rb +++ b/spec/ruby/core/hash/shared/comparison.rb @@ -1,15 +1,15 @@ describe :hash_comparison, shared: true do it "raises a TypeError if the right operand is not a hash" do - -> { { a: 1 }.send(@method, 1) }.should raise_error(TypeError) - -> { { a: 1 }.send(@method, nil) }.should raise_error(TypeError) - -> { { a: 1 }.send(@method, []) }.should raise_error(TypeError) + -> { { a: 1 }.send(@method, 1) }.should.raise(TypeError) + -> { { a: 1 }.send(@method, nil) }.should.raise(TypeError) + -> { { a: 1 }.send(@method, []) }.should.raise(TypeError) end it "returns false if both hashes have the same keys but different values" do h1 = { a: 1 } h2 = { a: 2 } - h1.send(@method, h2).should be_false - h2.send(@method, h1).should be_false + h1.send(@method, h2).should == false + h2.send(@method, h1).should == false end end diff --git a/spec/ruby/core/hash/shared/each.rb b/spec/ruby/core/hash/shared/each.rb index f9839ff58fae0d..657c5d2c529da7 100644 --- a/spec/ruby/core/hash/shared/each.rb +++ b/spec/ruby/core/hash/shared/each.rb @@ -10,7 +10,7 @@ it "yields the key and value of each pair to a block expecting |key, value|" do r = {} h = { a: 1, b: 2, c: 3, d: 5 } - h.send(@method) { |k,v| r[k.to_s] = v.to_s }.should equal(h) + h.send(@method) { |k,v| r[k.to_s] = v.to_s }.should.equal?(h) r.should == { "a" => "1", "b" => "2", "c" => "3", "d" => "5" } end @@ -28,11 +28,11 @@ def obj.foo(key, value) -> { { "a" => 1 }.send(@method, &obj.method(:foo)) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { { "a" => 1 }.send(@method, &-> key, value { }) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "yields an Array of 2 elements when given a callable of arity 1" do @@ -53,7 +53,7 @@ def obj.foo(key, value, extra) -> { { "a" => 1 }.send(@method, &obj.method(:foo)) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "uses the same order as keys() and values()" do diff --git a/spec/ruby/core/hash/shared/eql.rb b/spec/ruby/core/hash/shared/eql.rb index 68db49f76d03d0..512e1ad016a785 100644 --- a/spec/ruby/core/hash/shared/eql.rb +++ b/spec/ruby/core/hash/shared/eql.rb @@ -3,7 +3,7 @@ value = mock('x') value.should_not_receive(:==) value.should_not_receive(:eql?) - { 1 => value }.send(@method, { 2 => value }).should be_false + { 1 => value }.send(@method, { 2 => value }).should == false end it "returns false when the numbers of keys differ without comparing any elements" do @@ -13,8 +13,8 @@ obj.should_not_receive(:==) obj.should_not_receive(:eql?) - {}.send(@method, h).should be_false - h.send(@method, {}).should be_false + {}.send(@method, h).should == false + h.send(@method, {}).should == false end it "first compares keys via hash" do @@ -23,7 +23,7 @@ y = mock('y') y.should_receive(:hash).any_number_of_times.and_return(0) - { x => 1 }.send(@method, { y => 1 }).should be_false + { x => 1 }.send(@method, { y => 1 }).should == false end it "does not compare keys with different hash codes via eql?" do @@ -35,39 +35,39 @@ x.should_receive(:hash).any_number_of_times.and_return(0) y.should_receive(:hash).any_number_of_times.and_return(1) - { x => 1 }.send(@method, { y => 1 }).should be_false + { x => 1 }.send(@method, { y => 1 }).should == false end it "computes equality for recursive hashes" do h = {} h[:a] = h - h.send(@method, h[:a]).should be_true - (h == h[:a]).should be_true + h.send(@method, h[:a]).should == true + (h == h[:a]).should == true end it "doesn't call to_hash on objects" do mock_hash = mock("fake hash") def mock_hash.to_hash() {} end - {}.send(@method, mock_hash).should be_false + {}.send(@method, mock_hash).should == false end it "computes equality for complex recursive hashes" do a, b = {}, {} a.merge! self: a, other: b b.merge! self: b, other: a - a.send(@method, b).should be_true # they both have the same structure! + a.send(@method, b).should == true # they both have the same structure! c = {} c.merge! other: c, self: c - c.send(@method, a).should be_true # subtle, but they both have the same structure! + c.send(@method, a).should == true # subtle, but they both have the same structure! a[:delta] = c[:delta] = a - c.send(@method, a).should be_false # not quite the same structure, as a[:other][:delta] = nil + c.send(@method, a).should == false # not quite the same structure, as a[:other][:delta] = nil c[:delta] = 42 - c.send(@method, a).should be_false + c.send(@method, a).should == false a[:delta] = 42 - c.send(@method, a).should be_false + c.send(@method, a).should == false b[:delta] = 42 - c.send(@method, a).should be_true + c.send(@method, a).should == true end it "computes equality for recursive hashes & arrays" do @@ -76,19 +76,19 @@ def mock_hash.to_hash() {} end x << a y << c z << b - b.send(@method, c).should be_true # they clearly have the same structure! - y.send(@method, z).should be_true - a.send(@method, b).should be_true # subtle, but they both have the same structure! - x.send(@method, y).should be_true + b.send(@method, c).should == true # they clearly have the same structure! + y.send(@method, z).should == true + a.send(@method, b).should == true # subtle, but they both have the same structure! + x.send(@method, y).should == true y << x - y.send(@method, z).should be_false + y.send(@method, z).should == false z << x - y.send(@method, z).should be_true + y.send(@method, z).should == true a[:foo], a[:bar] = a[:bar], a[:foo] - a.send(@method, b).should be_false + a.send(@method, b).should == false b[:bar] = b[:foo] - b.send(@method, c).should be_false + b.send(@method, c).should == false end end @@ -100,7 +100,7 @@ def x.==(o) false end def y.==(o) false end def x.eql?(o) false end def y.eql?(o) false end - { 1 => x }.send(@method, { 1 => y }).should be_false + { 1 => x }.send(@method, { 1 => y }).should == false x = mock('x') y = mock('y') @@ -108,45 +108,45 @@ def x.==(o) true end def y.==(o) true end def x.eql?(o) true end def y.eql?(o) true end - { 1 => x }.send(@method, { 1 => y }).should be_true + { 1 => x }.send(@method, { 1 => y }).should == true end it "compares keys with eql? semantics" do - { 1.0 => "x" }.send(@method, { 1.0 => "x" }).should be_true - { 1.0 => "x" }.send(@method, { 1.0 => "x" }).should be_true - { 1 => "x" }.send(@method, { 1.0 => "x" }).should be_false - { 1.0 => "x" }.send(@method, { 1 => "x" }).should be_false + { 1.0 => "x" }.send(@method, { 1.0 => "x" }).should == true + { 1.0 => "x" }.send(@method, { 1.0 => "x" }).should == true + { 1 => "x" }.send(@method, { 1.0 => "x" }).should == false + { 1.0 => "x" }.send(@method, { 1 => "x" }).should == false end it "returns true if and only if other Hash has the same number of keys and each key-value pair matches" do a = { a: 5 } b = {} - a.send(@method, b).should be_false + a.send(@method, b).should == false b[:a] = 5 - a.send(@method, b).should be_true + a.send(@method, b).should == true not_supported_on :opal do c = { "a" => 5 } - a.send(@method, c).should be_false + a.send(@method, c).should == false end c = { "A" => 5 } - a.send(@method, c).should be_false + a.send(@method, c).should == false c = { a: 6 } - a.send(@method, c).should be_false + a.send(@method, c).should == false end it "does not call to_hash on hash subclasses" do - { 5 => 6 }.send(@method, HashSpecs::ToHashHash[5 => 6]).should be_true + { 5 => 6 }.send(@method, HashSpecs::ToHashHash[5 => 6]).should == true end it "ignores hash class differences" do h = { 1 => 2, 3 => 4 } - HashSpecs::MyHash[h].send(@method, h).should be_true - HashSpecs::MyHash[h].send(@method, HashSpecs::MyHash[h]).should be_true - h.send(@method, HashSpecs::MyHash[h]).should be_true + HashSpecs::MyHash[h].send(@method, h).should == true + HashSpecs::MyHash[h].send(@method, HashSpecs::MyHash[h]).should == true + h.send(@method, HashSpecs::MyHash[h]).should == true end # Why isn't this true of eql? too ? @@ -163,7 +163,7 @@ def obj.eql?(o) obj end - { a[0] => 1 }.send(@method, { a[1] => 1 }).should be_false + { a[0] => 1 }.send(@method, { a[1] => 1 }).should == false a = Array.new(2) do obj = mock('0') @@ -176,7 +176,7 @@ def obj.eql?(o) obj end - { a[0] => 1 }.send(@method, { a[1] => 1 }).should be_true + { a[0] => 1 }.send(@method, { a[1] => 1 }).should == true end it "compares the values in self to values in other hash" do @@ -185,20 +185,20 @@ def obj.eql?(o) l_val.should_receive(:eql?).with(r_val).and_return(true) - { 1 => l_val }.eql?({ 1 => r_val }).should be_true + { 1 => l_val }.eql?({ 1 => r_val }).should == true end end describe :hash_eql_additional_more, shared: true do it "returns true if other Hash has the same number of keys and each key-value pair matches, even though the default-value are not same" do - Hash.new(5).send(@method, Hash.new(1)).should be_true - Hash.new {|h, k| 1}.send(@method, Hash.new {}).should be_true - Hash.new {|h, k| 1}.send(@method, Hash.new(2)).should be_true + Hash.new(5).send(@method, Hash.new(1)).should == true + Hash.new {|h, k| 1}.send(@method, Hash.new {}).should == true + Hash.new {|h, k| 1}.send(@method, Hash.new(2)).should == true d = Hash.new {|h, k| 1} e = Hash.new {} d[1] = 2 e[1] = 2 - d.send(@method, e).should be_true + d.send(@method, e).should == true end end diff --git a/spec/ruby/core/hash/shared/greater_than.rb b/spec/ruby/core/hash/shared/greater_than.rb index 1f8b9fcfb7c2ed..dfe0b802505c80 100644 --- a/spec/ruby/core/hash/shared/greater_than.rb +++ b/spec/ruby/core/hash/shared/greater_than.rb @@ -5,11 +5,11 @@ end it "returns true if the other hash is a subset of self" do - @h1.send(@method, @h2).should be_true + @h1.send(@method, @h2).should == true end it "returns false if the other hash is not a subset of self" do - @h2.send(@method, @h1).should be_false + @h2.send(@method, @h1).should == false end it "converts the right operand to a hash before comparing" do @@ -18,6 +18,6 @@ def o.to_hash { a: 1, b: 2 } end - @h1.send(@method, o).should be_true + @h1.send(@method, o).should == true end end diff --git a/spec/ruby/core/hash/shared/index.rb b/spec/ruby/core/hash/shared/index.rb index 7f6a186464b8a1..dd4e89a9b4752d 100644 --- a/spec/ruby/core/hash/shared/index.rb +++ b/spec/ruby/core/hash/shared/index.rb @@ -10,13 +10,13 @@ it "returns nil if the value is not found" do suppress_warning do # for Hash#index - { a: -1, b: 3.14, c: 2.718 }.send(@method, 1).should be_nil + { a: -1, b: 3.14, c: 2.718 }.send(@method, 1).should == nil end end it "doesn't return default value if the value is not found" do suppress_warning do # for Hash#index - Hash.new(5).send(@method, 5).should be_nil + Hash.new(5).send(@method, 5).should == nil end end diff --git a/spec/ruby/core/hash/shared/iteration.rb b/spec/ruby/core/hash/shared/iteration.rb index d27c2443f8cbf9..322e4b9a2f25a4 100644 --- a/spec/ruby/core/hash/shared/iteration.rb +++ b/spec/ruby/core/hash/shared/iteration.rb @@ -5,15 +5,15 @@ end it "returns an Enumerator if called on a non-empty hash without a block" do - @hsh.send(@method).should be_an_instance_of(Enumerator) + @hsh.send(@method).should.instance_of?(Enumerator) end it "returns an Enumerator if called on an empty hash without a block" do - @empty.send(@method).should be_an_instance_of(Enumerator) + @empty.send(@method).should.instance_of?(Enumerator) end it "returns an Enumerator if called on a frozen instance" do @hsh.freeze - @hsh.send(@method).should be_an_instance_of(Enumerator) + @hsh.send(@method).should.instance_of?(Enumerator) end end diff --git a/spec/ruby/core/hash/shared/less_than.rb b/spec/ruby/core/hash/shared/less_than.rb index cdc6f145466951..071b3e97bb95c5 100644 --- a/spec/ruby/core/hash/shared/less_than.rb +++ b/spec/ruby/core/hash/shared/less_than.rb @@ -5,11 +5,11 @@ end it "returns true if self is a subset of the other hash" do - @h1.send(@method, @h2).should be_true + @h1.send(@method, @h2).should == true end it "returns false if self is not a subset of the other hash" do - @h2.send(@method, @h1).should be_false + @h2.send(@method, @h1).should == false end it "converts the right operand to a hash before comparing" do @@ -18,6 +18,6 @@ def o.to_hash { a: 1, b: 2, c: 3 } end - @h1.send(@method, o).should be_true + @h1.send(@method, o).should == true end end diff --git a/spec/ruby/core/hash/shared/select.rb b/spec/ruby/core/hash/shared/select.rb index fbeff073304225..b4f6d1b3acb2d8 100644 --- a/spec/ruby/core/hash/shared/select.rb +++ b/spec/ruby/core/hash/shared/select.rb @@ -17,7 +17,7 @@ it "returns a Hash of entries for which block is true" do a_pairs = { 'a' => 9, 'c' => 4, 'b' => 5, 'd' => 2 }.send(@method) { |k,v| v % 2 == 0 } - a_pairs.should be_an_instance_of(Hash) + a_pairs.should.instance_of?(Hash) a_pairs.sort.should == [['c', 4], ['d', 2]] end @@ -33,26 +33,26 @@ end it "returns an Enumerator when called on a non-empty hash without a block" do - @hsh.send(@method).should be_an_instance_of(Enumerator) + @hsh.send(@method).should.instance_of?(Enumerator) end it "returns an Enumerator when called on an empty hash without a block" do - @empty.send(@method).should be_an_instance_of(Enumerator) + @empty.send(@method).should.instance_of?(Enumerator) end it "does not retain the default value" do h = Hash.new(1) - h.send(@method) { true }.default.should be_nil + h.send(@method) { true }.default.should == nil h[:a] = 1 - h.send(@method) { true }.default.should be_nil + h.send(@method) { true }.default.should == nil end it "does not retain the default_proc" do pr = proc { |h, k| h[k] = [] } h = Hash.new(&pr) - h.send(@method) { true }.default_proc.should be_nil + h.send(@method) { true }.default_proc.should == nil h[:a] = 1 - h.send(@method) { true }.default_proc.should be_nil + h.send(@method) { true }.default_proc.should == nil end it "retains compare_by_identity flag" do @@ -77,7 +77,7 @@ it "is equivalent to keep_if if changes are made" do h = { a: 2 } - h.send(@method) { |k,v| v <= 1 }.should equal h + h.send(@method) { |k,v| v <= 1 }.should.equal? h h = { 1 => 2, 3 => 4 } all_args_select = [] @@ -87,7 +87,7 @@ it "removes all entries if the block is false" do h = { a: 1, b: 2, c: 3 } - h.send(@method) { |k,v| false }.should equal(h) + h.send(@method) { |k,v| false }.should.equal?(h) h.should == {} end @@ -96,11 +96,11 @@ end it "raises a FrozenError if called on an empty frozen instance" do - -> { HashSpecs.empty_frozen_hash.send(@method) { false } }.should raise_error(FrozenError) + -> { HashSpecs.empty_frozen_hash.send(@method) { false } }.should.raise(FrozenError) end it "raises a FrozenError if called on a frozen instance that would not be modified" do - -> { HashSpecs.frozen_hash.send(@method) { true } }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.send(@method) { true } }.should.raise(FrozenError) end it_should_behave_like :hash_iteration_no_block diff --git a/spec/ruby/core/hash/shared/store.rb b/spec/ruby/core/hash/shared/store.rb index 72a462a42f4fe5..05ef63face67fe 100644 --- a/spec/ruby/core/hash/shared/store.rb +++ b/spec/ruby/core/hash/shared/store.rb @@ -57,7 +57,7 @@ def key.reverse() "bar" end key = "foo".freeze h = {} h.send(@method, key, 0) - h.keys[0].should equal(key) + h.keys[0].should.equal?(key) end it "keeps the existing key in the hash if there is a matching one" do @@ -66,28 +66,28 @@ def key.reverse() "bar" end key2 = HashSpecs::ByValueKey.new(13) h[key1] = 41 key_in_hash = h.keys.last - key_in_hash.should equal(key1) + key_in_hash.should.equal?(key1) h[key2] = 42 last_key = h.keys.last - last_key.should equal(key_in_hash) - last_key.should_not equal(key2) + last_key.should.equal?(key_in_hash) + last_key.should_not.equal?(key2) end it "keeps the existing String key in the hash if there is a matching one" do h = { "a" => 1, "b" => 2, "c" => 3, "d" => 4 } key1 = "foo".dup key2 = "foo".dup - key1.should_not equal(key2) + key1.should_not.equal?(key2) h[key1] = 41 frozen_key = h.keys.last - frozen_key.should_not equal(key1) + frozen_key.should_not.equal?(key1) h[key2] = 42 - h.keys.last.should equal(frozen_key) - h.keys.last.should_not equal(key2) + h.keys.last.should.equal?(frozen_key) + h.keys.last.should_not.equal?(key2) end it "raises a FrozenError if called on a frozen instance" do - -> { HashSpecs.frozen_hash.send(@method, 1, 2) }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.send(@method, 1, 2) }.should.raise(FrozenError) end it "does not raise an exception if changing the value of an existing key during iteration" do diff --git a/spec/ruby/core/hash/shared/to_s.rb b/spec/ruby/core/hash/shared/to_s.rb index 38dd2c44360a95..f88ca738a598e6 100644 --- a/spec/ruby/core/hash/shared/to_s.rb +++ b/spec/ruby/core/hash/shared/to_s.rb @@ -54,7 +54,7 @@ obj.should_receive(:inspect).and_return(obj) obj.should_receive(:to_s).and_raise(Exception) - -> { { a: obj }.send(@method) }.should raise_error(Exception) + -> { { a: obj }.send(@method) }.should.raise(Exception) end it "handles hashes with recursive values" do diff --git a/spec/ruby/core/hash/shared/update.rb b/spec/ruby/core/hash/shared/update.rb index 1b0eb809bf8aa2..6dbad1d6d01b2c 100644 --- a/spec/ruby/core/hash/shared/update.rb +++ b/spec/ruby/core/hash/shared/update.rb @@ -1,14 +1,14 @@ describe :hash_update, shared: true do it "adds the entries from other, overwriting duplicate keys. Returns self" do h = { _1: 'a', _2: '3' } - h.send(@method, _1: '9', _9: 2).should equal(h) + h.send(@method, _1: '9', _9: 2).should.equal?(h) h.should == { _1: "9", _2: "3", _9: 2 } end it "sets any duplicate key to the value of block if passed a block" do h1 = { a: 2, b: -1 } h2 = { a: -2, c: 1 } - h1.send(@method, h2) { |k,x,y| 3.14 }.should equal(h1) + h1.send(@method, h2) { |k,x,y| 3.14 }.should.equal?(h1) h1.should == { c: 1, b: -1, a: 3.14 } h1.send(@method, h1) { nil } @@ -37,7 +37,7 @@ it "raises a FrozenError on a frozen instance that is modified" do -> do HashSpecs.frozen_hash.send(@method, 1 => 2) - end.should raise_error(FrozenError) + end.should.raise(FrozenError) end it "checks frozen status before coercing an object with #to_hash" do @@ -47,14 +47,14 @@ def obj.to_hash() raise Exception, "should not receive #to_hash" end obj.freeze - -> { HashSpecs.frozen_hash.send(@method, obj) }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.send(@method, obj) }.should.raise(FrozenError) end # see redmine #1571 it "raises a FrozenError on a frozen instance that would not be modified" do -> do HashSpecs.frozen_hash.send(@method, HashSpecs.empty_frozen_hash) - end.should raise_error(FrozenError) + end.should.raise(FrozenError) end it "does not raise an exception if changing the value of an existing key during iteration" do @@ -71,6 +71,6 @@ def obj.to_hash() raise Exception, "should not receive #to_hash" end it "accepts zero arguments" do hash = { a: 1 } - hash.send(@method).should eql(hash) + hash.send(@method).should.eql?(hash) end end diff --git a/spec/ruby/core/hash/shared/values_at.rb b/spec/ruby/core/hash/shared/values_at.rb index ef3b0e8ba0098b..4e4e60e7d6bca2 100644 --- a/spec/ruby/core/hash/shared/values_at.rb +++ b/spec/ruby/core/hash/shared/values_at.rb @@ -1,9 +1,9 @@ describe :hash_values_at, shared: true do it "returns an array of values for the given keys" do h = { a: 9, b: 'a', c: -10, d: nil } - h.send(@method).should be_kind_of(Array) + h.send(@method).should.is_a?(Array) h.send(@method).should == [] - h.send(@method, :a, :d, :b).should be_kind_of(Array) + h.send(@method, :a, :d, :b).should.is_a?(Array) h.send(@method, :a, :d, :b).should == [9, nil, 'a'] end end diff --git a/spec/ruby/core/hash/shift_spec.rb b/spec/ruby/core/hash/shift_spec.rb index 3f31b9864cd4dc..6095d2e55f233e 100644 --- a/spec/ruby/core/hash/shift_spec.rb +++ b/spec/ruby/core/hash/shift_spec.rb @@ -8,7 +8,7 @@ h.size.times do |i| r = h.shift - r.should be_kind_of(Array) + r.should.is_a?(Array) h2[r.first].should == r.last h.size.should == h2.size - i - 1 end @@ -57,8 +57,8 @@ def h.default(key) end it "raises a FrozenError if called on a frozen instance" do - -> { HashSpecs.frozen_hash.shift }.should raise_error(FrozenError) - -> { HashSpecs.empty_frozen_hash.shift }.should raise_error(FrozenError) + -> { HashSpecs.frozen_hash.shift }.should.raise(FrozenError) + -> { HashSpecs.empty_frozen_hash.shift }.should.raise(FrozenError) end it "works when the hash is at capacity" do diff --git a/spec/ruby/core/hash/slice_spec.rb b/spec/ruby/core/hash/slice_spec.rb index 4fcc01f9a6f6b9..fd932545178fed 100644 --- a/spec/ruby/core/hash/slice_spec.rb +++ b/spec/ruby/core/hash/slice_spec.rb @@ -7,8 +7,8 @@ it "returns a new empty hash without arguments" do ret = @hash.slice - ret.should_not equal(@hash) - ret.should be_an_instance_of(Hash) + ret.should_not.equal?(@hash) + ret.should.instance_of?(Hash) ret.should == {} end @@ -53,17 +53,17 @@ def [](value) it "does not retain the default value" do h = Hash.new(1) - h.slice(:a).default.should be_nil + h.slice(:a).default.should == nil h[:a] = 1 - h.slice(:a).default.should be_nil + h.slice(:a).default.should == nil end it "does not retain the default_proc" do pr = proc { |h, k| h[k] = [] } h = Hash.new(&pr) - h.slice(:a).default_proc.should be_nil + h.slice(:a).default_proc.should == nil h[:a] = 1 - h.slice(:a).default_proc.should be_nil + h.slice(:a).default_proc.should == nil end it "retains compare_by_identity flag" do diff --git a/spec/ruby/core/hash/to_a_spec.rb b/spec/ruby/core/hash/to_a_spec.rb index 5baf677929fe68..8c638db6c3a490 100644 --- a/spec/ruby/core/hash/to_a_spec.rb +++ b/spec/ruby/core/hash/to_a_spec.rb @@ -10,7 +10,7 @@ pairs << [key, value] end - h.to_a.should be_kind_of(Array) + h.to_a.should.is_a?(Array) h.to_a.should == pairs end @@ -23,7 +23,7 @@ end ent = h.entries - ent.should be_kind_of(Array) + ent.should.is_a?(Array) ent.should == pairs end end diff --git a/spec/ruby/core/hash/to_h_spec.rb b/spec/ruby/core/hash/to_h_spec.rb index f84fd7b503d165..5d5a280dac4eef 100644 --- a/spec/ruby/core/hash/to_h_spec.rb +++ b/spec/ruby/core/hash/to_h_spec.rb @@ -4,7 +4,7 @@ describe "Hash#to_h" do it "returns self for Hash instances" do h = {} - h.to_h.should equal(h) + h.to_h.should.equal?(h) end describe "when called on a subclass of Hash" do @@ -14,7 +14,7 @@ end it "returns a new Hash instance" do - @h.to_h.should be_an_instance_of(Hash) + @h.to_h.should.instance_of?(Hash) @h.to_h.should == @h @h[:foo].should == :bar end @@ -55,17 +55,17 @@ it "raises ArgumentError if block returns longer or shorter array" do -> do { a: 1, b: 2 }.to_h { |k, v| [k.to_s, v*v, 1] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) -> do { a: 1, b: 2 }.to_h { |k, v| [k] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) end it "raises TypeError if block returns something other than Array" do -> do { a: 1, b: 2 }.to_h { |k, v| "not-array" } - end.should raise_error(TypeError, /wrong element type String/) + end.should.raise(TypeError, /wrong element type String/) end it "coerces returned pair to Array with #to_ary" do @@ -81,20 +81,20 @@ -> do { a: 1 }.to_h { |k| x } - end.should raise_error(TypeError, /wrong element type MockObject/) + end.should.raise(TypeError, /wrong element type MockObject/) end it "does not retain the default value" do h = Hash.new(1) h2 = h.to_h { |k, v| [k.to_s, v*v]} - h2.default.should be_nil + h2.default.should == nil end it "does not retain the default_proc" do pr = proc { |h, k| h[k] = [] } h = Hash.new(&pr) h2 = h.to_h { |k, v| [k.to_s, v*v]} - h2.default_proc.should be_nil + h2.default_proc.should == nil end it "does not retain compare_by_identity flag" do diff --git a/spec/ruby/core/hash/to_hash_spec.rb b/spec/ruby/core/hash/to_hash_spec.rb index f479fa1fb284b0..f5622b3d9c3018 100644 --- a/spec/ruby/core/hash/to_hash_spec.rb +++ b/spec/ruby/core/hash/to_hash_spec.rb @@ -4,11 +4,11 @@ describe "Hash#to_hash" do it "returns self for Hash instances" do h = {} - h.to_hash.should equal(h) + h.to_hash.should.equal?(h) end it "returns self for instances of subclasses of Hash" do h = HashSpecs::MyHash.new - h.to_hash.should equal(h) + h.to_hash.should.equal?(h) end end diff --git a/spec/ruby/core/hash/to_proc_spec.rb b/spec/ruby/core/hash/to_proc_spec.rb index 9dbc79e5eba677..bc4756600d32fd 100644 --- a/spec/ruby/core/hash/to_proc_spec.rb +++ b/spec/ruby/core/hash/to_proc_spec.rb @@ -11,7 +11,7 @@ end it "returns an instance of Proc" do - @hash.to_proc.should be_an_instance_of Proc + @hash.to_proc.should.instance_of? Proc end describe "the returned proc" do @@ -30,22 +30,22 @@ it "raises ArgumentError if not passed exactly one argument" do -> { @proc.call - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @proc.call 1, 2 - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end context "with a stored key" do it "returns the paired value" do - @proc.call(@key).should equal(@value) + @proc.call(@key).should.equal?(@value) end end context "passed as a block" do it "retrieves the hash's values" do - [@key].map(&@proc)[0].should equal(@value) + [@key].map(&@proc)[0].should.equal?(@value) end context "to instance_exec" do @@ -63,7 +63,7 @@ context "with no stored key" do it "returns nil" do - @proc.call(@unstored).should be_nil + @proc.call(@unstored).should == nil end context "when the hash has a default value" do @@ -72,7 +72,7 @@ end it "returns the default value" do - @proc.call(@unstored).should equal(@default) + @proc.call(@unstored).should.equal?(@default) end end @@ -85,7 +85,7 @@ end it "raises an ArgumentError when calling #call on the Proc with no arguments" do - -> { @hash.to_proc.call }.should raise_error(ArgumentError) + -> { @hash.to_proc.call }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/hash/transform_keys_spec.rb b/spec/ruby/core/hash/transform_keys_spec.rb index e2eeab1813fade..d37a2b86163be3 100644 --- a/spec/ruby/core/hash/transform_keys_spec.rb +++ b/spec/ruby/core/hash/transform_keys_spec.rb @@ -7,8 +7,8 @@ it "returns new hash" do ret = @hash.transform_keys(&:succ) - ret.should_not equal(@hash) - ret.should be_an_instance_of(Hash) + ret.should_not.equal?(@hash) + ret.should.instance_of?(Hash) end it "sets the result as transformed keys with the given block" do @@ -22,13 +22,13 @@ it "makes both hashes to share values" do value = [1, 2, 3] new_hash = { a: value }.transform_keys(&:upcase) - new_hash[:A].should equal(value) + new_hash[:A].should.equal?(value) end context "when no block is given" do it "returns a sized Enumerator" do enumerator = @hash.transform_keys - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) enumerator.size.should == @hash.size enumerator.each(&:succ).should == { b: 1, c: 2, d: 3 } end @@ -57,17 +57,17 @@ it "does not retain the default value" do h = Hash.new(1) - h.transform_keys(&:succ).default.should be_nil + h.transform_keys(&:succ).default.should == nil h[:a] = 1 - h.transform_keys(&:succ).default.should be_nil + h.transform_keys(&:succ).default.should == nil end it "does not retain the default_proc" do pr = proc { |h, k| h[k] = [] } h = Hash.new(&pr) - h.transform_values(&:succ).default_proc.should be_nil + h.transform_values(&:succ).default_proc.should == nil h[:a] = 1 - h.transform_values(&:succ).default_proc.should be_nil + h.transform_values(&:succ).default_proc.should == nil end it "does not retain compare_by_identity flag" do @@ -84,7 +84,7 @@ end it "returns self" do - @hash.transform_keys!(&:succ).should equal(@hash) + @hash.transform_keys!(&:succ).should.equal?(@hash) end it "updates self as transformed values with the given block" do @@ -112,7 +112,7 @@ context "when no block is given" do it "returns a sized Enumerator" do enumerator = @hash.transform_keys! - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) enumerator.size.should == @hash.size enumerator.each(&:upcase).should == { A: 1, B: 2, C: 3, D: 4 } end @@ -129,21 +129,21 @@ end it "raises a FrozenError on an empty hash" do - ->{ {}.freeze.transform_keys!(&:upcase) }.should raise_error(FrozenError) + ->{ {}.freeze.transform_keys!(&:upcase) }.should.raise(FrozenError) end it "keeps pairs and raises a FrozenError" do - ->{ @hash.transform_keys!(&:upcase) }.should raise_error(FrozenError) + ->{ @hash.transform_keys!(&:upcase) }.should.raise(FrozenError) @hash.should == @initial_pairs end it "raises a FrozenError on hash argument" do - ->{ @hash.transform_keys!({ a: :A, b: :B, c: :C }) }.should raise_error(FrozenError) + ->{ @hash.transform_keys!({ a: :A, b: :B, c: :C }) }.should.raise(FrozenError) end context "when no block is given" do it "does not raise an exception" do - @hash.transform_keys!.should be_an_instance_of(Enumerator) + @hash.transform_keys!.should.instance_of?(Enumerator) end end end diff --git a/spec/ruby/core/hash/transform_values_spec.rb b/spec/ruby/core/hash/transform_values_spec.rb index 4a0ae8a5a5711c..b19543a9f42fa3 100644 --- a/spec/ruby/core/hash/transform_values_spec.rb +++ b/spec/ruby/core/hash/transform_values_spec.rb @@ -7,8 +7,8 @@ it "returns new hash" do ret = @hash.transform_values(&:succ) - ret.should_not equal(@hash) - ret.should be_an_instance_of(Hash) + ret.should_not.equal?(@hash) + ret.should.instance_of?(Hash) end it "sets the result as transformed values with the given block" do @@ -19,13 +19,13 @@ key = [1, 2, 3] new_hash = { key => 1 }.transform_values(&:succ) new_hash[key].should == 2 - new_hash.keys[0].should equal(key) + new_hash.keys[0].should.equal?(key) end context "when no block is given" do it "returns a sized Enumerator" do enumerator = @hash.transform_values - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) enumerator.size.should == @hash.size enumerator.each(&:succ).should == { a: 2, b: 3, c: 4 } end @@ -42,17 +42,17 @@ it "does not retain the default value" do h = Hash.new(1) - h.transform_values(&:succ).default.should be_nil + h.transform_values(&:succ).default.should == nil h[:a] = 1 - h.transform_values(&:succ).default.should be_nil + h.transform_values(&:succ).default.should == nil end it "does not retain the default_proc" do pr = proc { |h, k| h[k] = [] } h = Hash.new(&pr) - h.transform_values(&:succ).default_proc.should be_nil + h.transform_values(&:succ).default_proc.should == nil h[:a] = 1 - h.transform_values(&:succ).default_proc.should be_nil + h.transform_values(&:succ).default_proc.should == nil end it "retains compare_by_identity flag" do @@ -69,7 +69,7 @@ end it "returns self" do - @hash.transform_values!(&:succ).should equal(@hash) + @hash.transform_values!(&:succ).should.equal?(@hash) end it "updates self as transformed values with the given block" do @@ -88,7 +88,7 @@ context "when no block is given" do it "returns a sized Enumerator" do enumerator = @hash.transform_values! - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) enumerator.size.should == @hash.size enumerator.each(&:succ) @hash.should == { a: 2, b: 3, c: 4 } @@ -101,17 +101,17 @@ end it "raises a FrozenError on an empty hash" do - ->{ {}.freeze.transform_values!(&:succ) }.should raise_error(FrozenError) + ->{ {}.freeze.transform_values!(&:succ) }.should.raise(FrozenError) end it "keeps pairs and raises a FrozenError" do - ->{ @hash.transform_values!(&:succ) }.should raise_error(FrozenError) + ->{ @hash.transform_values!(&:succ) }.should.raise(FrozenError) @hash.should == @initial_pairs end context "when no block is given" do it "does not raise an exception" do - @hash.transform_values!.should be_an_instance_of(Enumerator) + @hash.transform_values!.should.instance_of?(Enumerator) end end end diff --git a/spec/ruby/core/hash/try_convert_spec.rb b/spec/ruby/core/hash/try_convert_spec.rb index 3932c8cdfdcdaf..c321183356a74a 100644 --- a/spec/ruby/core/hash/try_convert_spec.rb +++ b/spec/ruby/core/hash/try_convert_spec.rb @@ -4,36 +4,36 @@ describe "Hash.try_convert" do it "returns the argument if it's a Hash" do x = Hash.new - Hash.try_convert(x).should equal(x) + Hash.try_convert(x).should.equal?(x) end it "returns the argument if it's a kind of Hash" do x = HashSpecs::MyHash.new - Hash.try_convert(x).should equal(x) + Hash.try_convert(x).should.equal?(x) end it "returns nil when the argument does not respond to #to_hash" do - Hash.try_convert(Object.new).should be_nil + Hash.try_convert(Object.new).should == nil end it "sends #to_hash to the argument and returns the result if it's nil" do obj = mock("to_hash") obj.should_receive(:to_hash).and_return(nil) - Hash.try_convert(obj).should be_nil + Hash.try_convert(obj).should == nil end it "sends #to_hash to the argument and returns the result if it's a Hash" do x = Hash.new obj = mock("to_hash") obj.should_receive(:to_hash).and_return(x) - Hash.try_convert(obj).should equal(x) + Hash.try_convert(obj).should.equal?(x) end it "sends #to_hash to the argument and returns the result if it's a kind of Hash" do x = HashSpecs::MyHash.new obj = mock("to_hash") obj.should_receive(:to_hash).and_return(x) - Hash.try_convert(obj).should equal(x) + Hash.try_convert(obj).should.equal?(x) end it "sends #to_hash to the argument and raises TypeError if it's not a kind of Hash" do @@ -45,6 +45,6 @@ it "does not rescue exceptions raised by #to_hash" do obj = mock("to_hash") obj.should_receive(:to_hash).and_raise(RuntimeError) - -> { Hash.try_convert obj }.should raise_error(RuntimeError) + -> { Hash.try_convert obj }.should.raise(RuntimeError) end end diff --git a/spec/ruby/core/hash/values_spec.rb b/spec/ruby/core/hash/values_spec.rb index 9f2a481a48585a..1fe5f48ad6235f 100644 --- a/spec/ruby/core/hash/values_spec.rb +++ b/spec/ruby/core/hash/values_spec.rb @@ -4,7 +4,7 @@ describe "Hash#values" do it "returns an array of values" do h = { 1 => :a, 'a' => :a, 'the' => 'lang' } - h.values.should be_kind_of(Array) + h.values.should.is_a?(Array) h.values.sort {|a, b| a.to_s <=> b.to_s}.should == [:a, :a, 'lang'] end end diff --git a/spec/ruby/core/integer/allbits_spec.rb b/spec/ruby/core/integer/allbits_spec.rb index edce4b15e752ea..6023cc32bf22be 100644 --- a/spec/ruby/core/integer/allbits_spec.rb +++ b/spec/ruby/core/integer/allbits_spec.rb @@ -30,8 +30,8 @@ -> { (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10]) 13.allbits?(obj) - }.should raise_error(TypeError) - -> { 13.allbits?("10") }.should raise_error(TypeError) - -> { 13.allbits?(:symbol) }.should raise_error(TypeError) + }.should.raise(TypeError) + -> { 13.allbits?("10") }.should.raise(TypeError) + -> { 13.allbits?(:symbol) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/anybits_spec.rb b/spec/ruby/core/integer/anybits_spec.rb index e0449074a280e7..1ea47b76dc21be 100644 --- a/spec/ruby/core/integer/anybits_spec.rb +++ b/spec/ruby/core/integer/anybits_spec.rb @@ -29,8 +29,8 @@ -> { (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10]) 13.anybits?(obj) - }.should raise_error(TypeError) - -> { 13.anybits?("10") }.should raise_error(TypeError) - -> { 13.anybits?(:symbol) }.should raise_error(TypeError) + }.should.raise(TypeError) + -> { 13.anybits?("10") }.should.raise(TypeError) + -> { 13.anybits?(:symbol) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/bit_and_spec.rb b/spec/ruby/core/integer/bit_and_spec.rb index e7face39ac6589..4098ad7c7b5866 100644 --- a/spec/ruby/core/integer/bit_and_spec.rb +++ b/spec/ruby/core/integer/bit_and_spec.rb @@ -35,14 +35,14 @@ end it "raises a TypeError when passed a Float" do - -> { (3 & 3.4) }.should raise_error(TypeError) + -> { (3 & 3.4) }.should.raise(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("fixnum bit and") obj.should_not_receive(:to_int) - -> { 3 & obj }.should raise_error(TypeError) + -> { 3 & obj }.should.raise(TypeError) end end @@ -84,14 +84,14 @@ end it "raises a TypeError when passed a Float" do - -> { (@bignum & 3.4) }.should raise_error(TypeError) + -> { (@bignum & 3.4) }.should.raise(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("bignum bit and") obj.should_not_receive(:to_int) - -> { @bignum & obj }.should raise_error(TypeError) + -> { @bignum & obj }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/integer/bit_or_spec.rb b/spec/ruby/core/integer/bit_or_spec.rb index fdf8a191e5ad16..c380cd729ef81c 100644 --- a/spec/ruby/core/integer/bit_or_spec.rb +++ b/spec/ruby/core/integer/bit_or_spec.rb @@ -36,14 +36,14 @@ end it "raises a TypeError when passed a Float" do - -> { (3 | 3.4) }.should raise_error(TypeError) + -> { (3 | 3.4) }.should.raise(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("integer bit or") obj.should_not_receive(:to_int) - -> { 3 | obj }.should raise_error(TypeError) + -> { 3 | obj }.should.raise(TypeError) end end @@ -74,16 +74,16 @@ not_supported_on :opal do -> { bignum_value | bignum_value(0xffff).to_f - }.should raise_error(TypeError) + }.should.raise(TypeError) end - -> { @bignum | 9.9 }.should raise_error(TypeError) + -> { @bignum | 9.9 }.should.raise(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("bignum bit or") obj.should_not_receive(:to_int) - -> { @bignum | obj }.should raise_error(TypeError) + -> { @bignum | obj }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/integer/bit_xor_spec.rb b/spec/ruby/core/integer/bit_xor_spec.rb index 1f46bc52f35cfa..c0cf8405f7ef60 100644 --- a/spec/ruby/core/integer/bit_xor_spec.rb +++ b/spec/ruby/core/integer/bit_xor_spec.rb @@ -34,14 +34,14 @@ end it "raises a TypeError when passed a Float" do - -> { (3 ^ 3.4) }.should raise_error(TypeError) + -> { (3 ^ 3.4) }.should.raise(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("integer bit xor") obj.should_not_receive(:to_int) - -> { 3 ^ obj }.should raise_error(TypeError) + -> { 3 ^ obj }.should.raise(TypeError) end end @@ -78,16 +78,16 @@ not_supported_on :opal do -> { bignum_value ^ bignum_value(0xffff).to_f - }.should raise_error(TypeError) + }.should.raise(TypeError) end - -> { @bignum ^ 14.5 }.should raise_error(TypeError) + -> { @bignum ^ 14.5 }.should.raise(TypeError) end it "raises a TypeError and does not call #to_int when defined on an object" do obj = mock("bignum bit xor") obj.should_not_receive(:to_int) - -> { @bignum ^ obj }.should raise_error(TypeError) + -> { @bignum ^ obj }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/integer/ceildiv_spec.rb b/spec/ruby/core/integer/ceildiv_spec.rb index c6e22a457dd2bd..91f63832f8ef93 100644 --- a/spec/ruby/core/integer/ceildiv_spec.rb +++ b/spec/ruby/core/integer/ceildiv_spec.rb @@ -2,19 +2,19 @@ describe "Integer#ceildiv" do it "returns a quotient of division which is rounded up to the nearest integer" do - 0.ceildiv(3).should eql(0) - 1.ceildiv(3).should eql(1) - 3.ceildiv(3).should eql(1) - 4.ceildiv(3).should eql(2) + 0.ceildiv(3).should.eql?(0) + 1.ceildiv(3).should.eql?(1) + 3.ceildiv(3).should.eql?(1) + 4.ceildiv(3).should.eql?(2) - 4.ceildiv(-3).should eql(-1) - -4.ceildiv(3).should eql(-1) - -4.ceildiv(-3).should eql(2) + 4.ceildiv(-3).should.eql?(-1) + -4.ceildiv(3).should.eql?(-1) + -4.ceildiv(-3).should.eql?(2) - 3.ceildiv(1.2).should eql(3) - 3.ceildiv(6/5r).should eql(3) + 3.ceildiv(1.2).should.eql?(3) + 3.ceildiv(6/5r).should.eql?(3) - (10**100-11).ceildiv(10**99-1).should eql(10) - (10**100-9).ceildiv(10**99-1).should eql(11) + (10**100-11).ceildiv(10**99-1).should.eql?(10) + (10**100-9).ceildiv(10**99-1).should.eql?(11) end end diff --git a/spec/ruby/core/integer/chr_spec.rb b/spec/ruby/core/integer/chr_spec.rb index 39cafe287457f9..72784e18334620 100644 --- a/spec/ruby/core/integer/chr_spec.rb +++ b/spec/ruby/core/integer/chr_spec.rb @@ -2,20 +2,20 @@ describe "Integer#chr without argument" do it "returns a String" do - 17.chr.should be_an_instance_of(String) + 17.chr.should.instance_of?(String) end it "returns a new String for each call" do - 82.chr.should_not equal(82.chr) + 82.chr.should_not.equal?(82.chr) end it "raises a RangeError is self is less than 0" do - -> { -1.chr }.should raise_error(RangeError, /-1 out of char range/) - -> { (-bignum_value).chr }.should raise_error(RangeError, /bignum out of char range/) + -> { -1.chr }.should.raise(RangeError, /-1 out of char range/) + -> { (-bignum_value).chr }.should.raise(RangeError, /bignum out of char range/) end it "raises a RangeError if self is too large" do - -> { 2206368128.chr(Encoding::UTF_8) }.should raise_error(RangeError, /2206368128 out of char range/) + -> { 2206368128.chr(Encoding::UTF_8) }.should.raise(RangeError, /2206368128 out of char range/) end describe "when Encoding.default_internal is nil" do @@ -48,8 +48,8 @@ end it "raises a RangeError is self is greater than 255" do - -> { 256.chr }.should raise_error(RangeError, /256 out of char range/) - -> { bignum_value.chr }.should raise_error(RangeError, /bignum out of char range/) + -> { 256.chr }.should.raise(RangeError, /256 out of char range/) + -> { bignum_value.chr }.should.raise(RangeError, /bignum out of char range/) end end @@ -137,7 +137,7 @@ [620, "TIS-620"] ].each do |integer, encoding_name| Encoding.default_internal = Encoding.find(encoding_name) - -> { integer.chr }.should raise_error(RangeError, /(invalid codepoint|out of char range)/) + -> { integer.chr }.should.raise(RangeError, /(invalid codepoint|out of char range)/) end end end @@ -146,15 +146,15 @@ describe "Integer#chr with an encoding argument" do it "returns a String" do - 900.chr(Encoding::UTF_8).should be_an_instance_of(String) + 900.chr(Encoding::UTF_8).should.instance_of?(String) end it "returns a new String for each call" do - 8287.chr(Encoding::UTF_8).should_not equal(8287.chr(Encoding::UTF_8)) + 8287.chr(Encoding::UTF_8).should_not.equal?(8287.chr(Encoding::UTF_8)) end it "accepts a String as an argument" do - -> { 0xA4A2.chr('euc-jp') }.should_not raise_error + -> { 0xA4A2.chr('euc-jp') }.should_not.raise end it "converts a String to an Encoding as Encoding.find does" do @@ -165,12 +165,12 @@ # http://redmine.ruby-lang.org/issues/4869 it "raises a RangeError is self is less than 0" do - -> { -1.chr(Encoding::UTF_8) }.should raise_error(RangeError, /-1 out of char range/) - -> { (-bignum_value).chr(Encoding::EUC_JP) }.should raise_error(RangeError, /bignum out of char range/) + -> { -1.chr(Encoding::UTF_8) }.should.raise(RangeError, /-1 out of char range/) + -> { (-bignum_value).chr(Encoding::EUC_JP) }.should.raise(RangeError, /bignum out of char range/) end it "raises a RangeError if self is too large" do - -> { 2206368128.chr(Encoding::UTF_8) }.should raise_error(RangeError, /2206368128 out of char range/) + -> { 2206368128.chr(Encoding::UTF_8) }.should.raise(RangeError, /2206368128 out of char range/) end it "returns a String with the specified encoding" do @@ -223,25 +223,25 @@ # #5864 it "raises RangeError if self is invalid as a codepoint in the specified encoding" do - -> { 0x80.chr("US-ASCII") }.should raise_error(RangeError) - -> { 0x0100.chr("BINARY") }.should raise_error(RangeError) - -> { 0x0100.chr("EUC-JP") }.should raise_error(RangeError) - -> { 0xA1A0.chr("EUC-JP") }.should raise_error(RangeError) - -> { 0xA1.chr("EUC-JP") }.should raise_error(RangeError) - -> { 0x80.chr("SHIFT_JIS") }.should raise_error(RangeError) - -> { 0xE0.chr("SHIFT_JIS") }.should raise_error(RangeError) - -> { 0x0100.chr("ISO-8859-9") }.should raise_error(RangeError) - -> { 620.chr("TIS-620") }.should raise_error(RangeError) + -> { 0x80.chr("US-ASCII") }.should.raise(RangeError) + -> { 0x0100.chr("BINARY") }.should.raise(RangeError) + -> { 0x0100.chr("EUC-JP") }.should.raise(RangeError) + -> { 0xA1A0.chr("EUC-JP") }.should.raise(RangeError) + -> { 0xA1.chr("EUC-JP") }.should.raise(RangeError) + -> { 0x80.chr("SHIFT_JIS") }.should.raise(RangeError) + -> { 0xE0.chr("SHIFT_JIS") }.should.raise(RangeError) + -> { 0x0100.chr("ISO-8859-9") }.should.raise(RangeError) + -> { 620.chr("TIS-620") }.should.raise(RangeError) # UTF-16 surrogate range - -> { 0xD800.chr("UTF-8") }.should raise_error(RangeError) - -> { 0xDBFF.chr("UTF-8") }.should raise_error(RangeError) - -> { 0xDC00.chr("UTF-8") }.should raise_error(RangeError) - -> { 0xDFFF.chr("UTF-8") }.should raise_error(RangeError) + -> { 0xD800.chr("UTF-8") }.should.raise(RangeError) + -> { 0xDBFF.chr("UTF-8") }.should.raise(RangeError) + -> { 0xDC00.chr("UTF-8") }.should.raise(RangeError) + -> { 0xDFFF.chr("UTF-8") }.should.raise(RangeError) # UTF-16 surrogate range - -> { 0xD800.chr("UTF-16") }.should raise_error(RangeError) - -> { 0xDBFF.chr("UTF-16") }.should raise_error(RangeError) - -> { 0xDC00.chr("UTF-16") }.should raise_error(RangeError) - -> { 0xDFFF.chr("UTF-16") }.should raise_error(RangeError) + -> { 0xD800.chr("UTF-16") }.should.raise(RangeError) + -> { 0xDBFF.chr("UTF-16") }.should.raise(RangeError) + -> { 0xDC00.chr("UTF-16") }.should.raise(RangeError) + -> { 0xDFFF.chr("UTF-16") }.should.raise(RangeError) end it 'returns a String encoding self interpreted as a codepoint in the CESU-8 encoding' do diff --git a/spec/ruby/core/integer/coerce_spec.rb b/spec/ruby/core/integer/coerce_spec.rb index 1d6dc9713f5f78..c0e642da0323fd 100644 --- a/spec/ruby/core/integer/coerce_spec.rb +++ b/spec/ruby/core/integer/coerce_spec.rb @@ -11,7 +11,7 @@ describe "when given a String" do it "raises an ArgumentError when trying to coerce with a non-number String" do - -> { 1.coerce(":)") }.should raise_error(ArgumentError) + -> { 1.coerce(":)") }.should.raise(ArgumentError) end it "returns an array containing two Floats" do @@ -21,7 +21,7 @@ end it "raises a TypeError when trying to coerce with nil" do - -> { 1.coerce(nil) }.should raise_error(TypeError) + -> { 1.coerce(nil) }.should.raise(TypeError) end it "tries to convert the given Object into a Float by using #to_f" do @@ -29,13 +29,13 @@ 2.coerce(obj).should == [1.0, 2.0] (obj = mock('0')).should_receive(:to_f).and_return('0') - -> { 2.coerce(obj).should == [1.0, 2.0] }.should raise_error(TypeError) + -> { 2.coerce(obj).should == [1.0, 2.0] }.should.raise(TypeError) end it "raises a TypeError when given an Object that does not respond to #to_f" do - -> { 1.coerce(mock('x')) }.should raise_error(TypeError) - -> { 1.coerce(1..4) }.should raise_error(TypeError) - -> { 1.coerce(:test) }.should raise_error(TypeError) + -> { 1.coerce(mock('x')) }.should.raise(TypeError) + -> { 1.coerce(1..4) }.should.raise(TypeError) + -> { 1.coerce(:test) }.should.raise(TypeError) end end @@ -44,8 +44,8 @@ a = bignum_value ary = a.coerce(2) - ary[0].should be_kind_of(Integer) - ary[1].should be_kind_of(Integer) + ary[0].should.is_a?(Integer) + ary[1].should.is_a?(Integer) ary.should == [2, a] end @@ -54,18 +54,18 @@ b = bignum_value ary = a.coerce(b) - ary[0].should be_kind_of(Integer) - ary[1].should be_kind_of(Integer) + ary[0].should.is_a?(Integer) + ary[1].should.is_a?(Integer) ary.should == [b, a] end it "raises a TypeError when not passed a Fixnum or Bignum" do a = bignum_value - -> { a.coerce(nil) }.should raise_error(TypeError) - -> { a.coerce(mock('str')) }.should raise_error(TypeError) - -> { a.coerce(1..4) }.should raise_error(TypeError) - -> { a.coerce(:test) }.should raise_error(TypeError) + -> { a.coerce(nil) }.should.raise(TypeError) + -> { a.coerce(mock('str')) }.should.raise(TypeError) + -> { a.coerce(1..4) }.should.raise(TypeError) + -> { a.coerce(:test) }.should.raise(TypeError) end it "coerces both values to Floats and returns [other, self] when passed a Float" do diff --git a/spec/ruby/core/integer/comparison_spec.rb b/spec/ruby/core/integer/comparison_spec.rb index e56f2831806965..cc5cbe2506bf81 100644 --- a/spec/ruby/core/integer/comparison_spec.rb +++ b/spec/ruby/core/integer/comparison_spec.rb @@ -128,17 +128,17 @@ @num.should_receive(:coerce).with(@big).and_raise(RuntimeError.new("my error")) -> { @big <=> @num - }.should raise_error(RuntimeError, "my error") + }.should.raise(RuntimeError, "my error") end it "raises an exception if #coerce raises a non-StandardError exception" do @num.should_receive(:coerce).with(@big).and_raise(Exception) - -> { @big <=> @num }.should raise_error(Exception) + -> { @big <=> @num }.should.raise(Exception) end it "returns nil if #coerce does not return an Array" do @num.should_receive(:coerce).with(@big).and_return(nil) - (@big <=> @num).should be_nil + (@big <=> @num).should == nil end it "returns -1 if the coerced value is larger" do diff --git a/spec/ruby/core/integer/digits_spec.rb b/spec/ruby/core/integer/digits_spec.rb index 3d0a64c25f5a3e..c4ebf2cd886577 100644 --- a/spec/ruby/core/integer/digits_spec.rb +++ b/spec/ruby/core/integer/digits_spec.rb @@ -19,15 +19,15 @@ end it "raises ArgumentError when calling with a radix less than 2" do - -> { 12345.digits(1) }.should raise_error(ArgumentError) + -> { 12345.digits(1) }.should.raise(ArgumentError) end it "raises ArgumentError when calling with a negative radix" do - -> { 12345.digits(-2) }.should raise_error(ArgumentError) + -> { 12345.digits(-2) }.should.raise(ArgumentError) end it "raises Math::DomainError when calling digits on a negative number" do - -> { -12345.digits(7) }.should raise_error(Math::DomainError) + -> { -12345.digits(7) }.should.raise(Math::DomainError) end it "returns integer values > 9 when base is above 10" do diff --git a/spec/ruby/core/integer/div_spec.rb b/spec/ruby/core/integer/div_spec.rb index 2eb9c0623bf6c5..220ca4a73ea1a9 100644 --- a/spec/ruby/core/integer/div_spec.rb +++ b/spec/ruby/core/integer/div_spec.rb @@ -46,21 +46,21 @@ end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - -> { 0.div(0.0) }.should raise_error(ZeroDivisionError) - -> { 10.div(0.0) }.should raise_error(ZeroDivisionError) - -> { -10.div(0.0) }.should raise_error(ZeroDivisionError) + -> { 0.div(0.0) }.should.raise(ZeroDivisionError) + -> { 10.div(0.0) }.should.raise(ZeroDivisionError) + -> { -10.div(0.0) }.should.raise(ZeroDivisionError) end it "raises a ZeroDivisionError when the given argument is 0 and not a Float" do - -> { 13.div(0) }.should raise_error(ZeroDivisionError) - -> { 13.div(-0) }.should raise_error(ZeroDivisionError) + -> { 13.div(0) }.should.raise(ZeroDivisionError) + -> { 13.div(-0) }.should.raise(ZeroDivisionError) end it "raises a TypeError when given a non-numeric argument" do - -> { 13.div(mock('10')) }.should raise_error(TypeError) - -> { 5.div("2") }.should raise_error(TypeError) - -> { 5.div(:"2") }.should raise_error(TypeError) - -> { 5.div([]) }.should raise_error(TypeError) + -> { 13.div(mock('10')) }.should.raise(TypeError) + -> { 5.div("2") }.should.raise(TypeError) + -> { 5.div(:"2") }.should.raise(TypeError) + -> { 5.div([]) }.should.raise(TypeError) end end @@ -118,29 +118,29 @@ end it "raises a TypeError when given a non-numeric" do - -> { @bignum.div(mock("10")) }.should raise_error(TypeError) - -> { @bignum.div("2") }.should raise_error(TypeError) - -> { @bignum.div(:symbol) }.should raise_error(TypeError) + -> { @bignum.div(mock("10")) }.should.raise(TypeError) + -> { @bignum.div("2") }.should.raise(TypeError) + -> { @bignum.div(:symbol) }.should.raise(TypeError) end it "returns a result of integer division of self by a float argument" do - @bignum.div(4294967295.5).should eql(4294967296) + @bignum.div(4294967295.5).should.eql?(4294967296) not_supported_on :opal do - @bignum.div(4294967295.0).should eql(4294967297) - @bignum.div(bignum_value(88).to_f).should eql(1) - @bignum.div((-bignum_value(88)).to_f).should eql(-1) + @bignum.div(4294967295.0).should.eql?(4294967297) + @bignum.div(bignum_value(88).to_f).should.eql?(1) + @bignum.div((-bignum_value(88)).to_f).should.eql?(-1) end end # #5490 it "raises ZeroDivisionError if the argument is 0 and is a Float" do - -> { @bignum.div(0.0) }.should raise_error(ZeroDivisionError) - -> { @bignum.div(-0.0) }.should raise_error(ZeroDivisionError) + -> { @bignum.div(0.0) }.should.raise(ZeroDivisionError) + -> { @bignum.div(-0.0) }.should.raise(ZeroDivisionError) end it "raises ZeroDivisionError if the argument is 0 and is not a Float" do - -> { @bignum.div(0) }.should raise_error(ZeroDivisionError) - -> { @bignum.div(-0) }.should raise_error(ZeroDivisionError) + -> { @bignum.div(0) }.should.raise(ZeroDivisionError) + -> { @bignum.div(-0) }.should.raise(ZeroDivisionError) end end diff --git a/spec/ruby/core/integer/divide_spec.rb b/spec/ruby/core/integer/divide_spec.rb index 0d5e16e986825a..e75432fd83332d 100644 --- a/spec/ruby/core/integer/divide_spec.rb +++ b/spec/ruby/core/integer/divide_spec.rb @@ -32,7 +32,7 @@ end it "raises a ZeroDivisionError if the given argument is zero and not a Float" do - -> { 1 / 0 }.should raise_error(ZeroDivisionError) + -> { 1 / 0 }.should.raise(ZeroDivisionError) end it "does NOT raise ZeroDivisionError if the given argument is zero and is a Float" do @@ -46,9 +46,9 @@ end it "raises a TypeError when given a non-Integer" do - -> { 13 / mock('10') }.should raise_error(TypeError) - -> { 13 / "10" }.should raise_error(TypeError) - -> { 13 / :symbol }.should raise_error(TypeError) + -> { 13 / mock('10') }.should.raise(TypeError) + -> { 13 / "10" }.should.raise(TypeError) + -> { 13 / :symbol }.should.raise(TypeError) end end @@ -97,13 +97,13 @@ end it "raises a ZeroDivisionError if other is zero and not a Float" do - -> { @bignum / 0 }.should raise_error(ZeroDivisionError) + -> { @bignum / 0 }.should.raise(ZeroDivisionError) end it "raises a TypeError when given a non-numeric" do - -> { @bignum / mock('10') }.should raise_error(TypeError) - -> { @bignum / "2" }.should raise_error(TypeError) - -> { @bignum / :symbol }.should raise_error(TypeError) + -> { @bignum / mock('10') }.should.raise(TypeError) + -> { @bignum / "2" }.should.raise(TypeError) + -> { @bignum / :symbol }.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/divmod_spec.rb b/spec/ruby/core/integer/divmod_spec.rb index 7a489e9344157d..db470c57315896 100644 --- a/spec/ruby/core/integer/divmod_spec.rb +++ b/spec/ruby/core/integer/divmod_spec.rb @@ -14,24 +14,24 @@ end it "raises a ZeroDivisionError when the given argument is 0" do - -> { 13.divmod(0) }.should raise_error(ZeroDivisionError) - -> { 0.divmod(0) }.should raise_error(ZeroDivisionError) - -> { -10.divmod(0) }.should raise_error(ZeroDivisionError) + -> { 13.divmod(0) }.should.raise(ZeroDivisionError) + -> { 0.divmod(0) }.should.raise(ZeroDivisionError) + -> { -10.divmod(0) }.should.raise(ZeroDivisionError) end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - -> { 0.divmod(0.0) }.should raise_error(ZeroDivisionError) - -> { 10.divmod(0.0) }.should raise_error(ZeroDivisionError) - -> { -10.divmod(0.0) }.should raise_error(ZeroDivisionError) + -> { 0.divmod(0.0) }.should.raise(ZeroDivisionError) + -> { 10.divmod(0.0) }.should.raise(ZeroDivisionError) + -> { -10.divmod(0.0) }.should.raise(ZeroDivisionError) end it "raises a TypeError when given a non-Integer" do -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13.divmod(obj) - }.should raise_error(TypeError) - -> { 13.divmod("10") }.should raise_error(TypeError) - -> { 13.divmod(:symbol) }.should raise_error(TypeError) + }.should.raise(TypeError) + -> { 13.divmod("10") }.should.raise(TypeError) + -> { 13.divmod(:symbol) }.should.raise(TypeError) end end @@ -94,24 +94,24 @@ end it "raises a ZeroDivisionError when the given argument is 0" do - -> { @bignum.divmod(0) }.should raise_error(ZeroDivisionError) - -> { (-@bignum).divmod(0) }.should raise_error(ZeroDivisionError) + -> { @bignum.divmod(0) }.should.raise(ZeroDivisionError) + -> { (-@bignum).divmod(0) }.should.raise(ZeroDivisionError) end # Behaviour established as correct in r23953 it "raises a FloatDomainError if other is NaN" do - -> { @bignum.divmod(nan_value) }.should raise_error(FloatDomainError) + -> { @bignum.divmod(nan_value) }.should.raise(FloatDomainError) end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - -> { @bignum.divmod(0.0) }.should raise_error(ZeroDivisionError) - -> { (-@bignum).divmod(0.0) }.should raise_error(ZeroDivisionError) + -> { @bignum.divmod(0.0) }.should.raise(ZeroDivisionError) + -> { (-@bignum).divmod(0.0) }.should.raise(ZeroDivisionError) end it "raises a TypeError when the given argument is not an Integer" do - -> { @bignum.divmod(mock('10')) }.should raise_error(TypeError) - -> { @bignum.divmod("10") }.should raise_error(TypeError) - -> { @bignum.divmod(:symbol) }.should raise_error(TypeError) + -> { @bignum.divmod(mock('10')) }.should.raise(TypeError) + -> { @bignum.divmod("10") }.should.raise(TypeError) + -> { @bignum.divmod(:symbol) }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/integer/downto_spec.rb b/spec/ruby/core/integer/downto_spec.rb index 987704b02eaf1f..a244d3df55185c 100644 --- a/spec/ruby/core/integer/downto_spec.rb +++ b/spec/ruby/core/integer/downto_spec.rb @@ -27,8 +27,8 @@ end it "raises an ArgumentError for invalid endpoints" do - -> {1.downto("A") {|x| p x } }.should raise_error(ArgumentError) - -> {1.downto(nil) {|x| p x } }.should raise_error(ArgumentError) + -> {1.downto("A") {|x| p x } }.should.raise(ArgumentError) + -> {1.downto(nil) {|x| p x } }.should.raise(ArgumentError) end describe "when no block is given" do @@ -45,9 +45,9 @@ describe "size" do it "raises an ArgumentError for invalid endpoints" do enum = 1.downto("A") - -> { enum.size }.should raise_error(ArgumentError) + -> { enum.size }.should.raise(ArgumentError) enum = 1.downto(nil) - -> { enum.size }.should raise_error(ArgumentError) + -> { enum.size }.should.raise(ArgumentError) end it "returns self - stop + 1" do diff --git a/spec/ruby/core/integer/dup_spec.rb b/spec/ruby/core/integer/dup_spec.rb index 7f4d5124654e22..3e5739ad37a7be 100644 --- a/spec/ruby/core/integer/dup_spec.rb +++ b/spec/ruby/core/integer/dup_spec.rb @@ -3,11 +3,11 @@ describe "Integer#dup" do it "returns self for small integers" do integer = 1_000 - integer.dup.should equal(integer) + integer.dup.should.equal?(integer) end it "returns self for large integers" do integer = 4_611_686_018_427_387_905 - integer.dup.should equal(integer) + integer.dup.should.equal?(integer) end end diff --git a/spec/ruby/core/integer/element_reference_spec.rb b/spec/ruby/core/integer/element_reference_spec.rb index cb7e0dc9b07645..c69ec2315df043 100644 --- a/spec/ruby/core/integer/element_reference_spec.rb +++ b/spec/ruby/core/integer/element_reference_spec.rb @@ -59,13 +59,13 @@ end it "raises a TypeError when passed a String" do - -> { 3["3"] }.should raise_error(TypeError) + -> { 3["3"] }.should.raise(TypeError) end it "raises a TypeError when #to_int does not return an Integer" do obj = mock('asdf') obj.should_receive(:to_int).and_return("asdf") - -> { 3[obj] }.should raise_error(TypeError) + -> { 3[obj] }.should.raise(TypeError) end it "calls #to_int to coerce a String to a Bignum and returns 0" do @@ -137,8 +137,8 @@ end it "raises FloatDomainError if any boundary is infinity" do - -> { 0x0001[3..Float::INFINITY] }.should raise_error(FloatDomainError, /Infinity/) - -> { 0x0001[-Float::INFINITY..3] }.should raise_error(FloatDomainError, /-Infinity/) + -> { 0x0001[3..Float::INFINITY] }.should.raise(FloatDomainError, /Infinity/) + -> { 0x0001[-Float::INFINITY..3] }.should.raise(FloatDomainError, /-Infinity/) end context "when passed (..i)" do @@ -151,7 +151,7 @@ it "raises ArgumentError if any of i bit equals 1" do -> { eval("0b111110[..3]") - }.should raise_error(ArgumentError, /The beginless range for Integer#\[\] results in infinity/) + }.should.raise(ArgumentError, /The beginless range for Integer#\[\] results in infinity/) end end end @@ -179,10 +179,10 @@ it "raises a TypeError when the given argument can't be converted to Integer" do obj = mock('asdf') - -> { @bignum[obj] }.should raise_error(TypeError) + -> { @bignum[obj] }.should.raise(TypeError) obj.should_receive(:to_int).and_return("asdf") - -> { @bignum[obj] }.should raise_error(TypeError) + -> { @bignum[obj] }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/integer/even_spec.rb b/spec/ruby/core/integer/even_spec.rb index a314cc6b1978ab..578979320eb0a4 100644 --- a/spec/ruby/core/integer/even_spec.rb +++ b/spec/ruby/core/integer/even_spec.rb @@ -3,38 +3,38 @@ describe "Integer#even?" do context "fixnum" do it "returns true for a Fixnum when it is an even number" do - (-2).even?.should be_true - (-1).even?.should be_false + (-2).even?.should == true + (-1).even?.should == false - 0.even?.should be_true - 1.even?.should be_false - 2.even?.should be_true + 0.even?.should == true + 1.even?.should == false + 2.even?.should == true end it "returns true for a Bignum when it is an even number" do - bignum_value(0).even?.should be_true - bignum_value(1).even?.should be_false + bignum_value(0).even?.should == true + bignum_value(1).even?.should == false - (-bignum_value(0)).even?.should be_true - (-bignum_value(1)).even?.should be_false + (-bignum_value(0)).even?.should == true + (-bignum_value(1)).even?.should == false end end context "bignum" do it "returns true if self is even and positive" do - (10000**10).even?.should be_true + (10000**10).even?.should == true end it "returns true if self is even and negative" do - (-10000**10).even?.should be_true + (-10000**10).even?.should == true end it "returns false if self is odd and positive" do - (9879**976).even?.should be_false + (9879**976).even?.should == false end it "returns false if self is odd and negative" do - (-9879**976).even?.should be_false + (-9879**976).even?.should == false end end end diff --git a/spec/ruby/core/integer/fdiv_spec.rb b/spec/ruby/core/integer/fdiv_spec.rb index d9ea2fdf8d57ea..7854d66deceda4 100644 --- a/spec/ruby/core/integer/fdiv_spec.rb +++ b/spec/ruby/core/integer/fdiv_spec.rb @@ -65,8 +65,8 @@ end it "returns NaN when the argument is NaN" do - -1.fdiv(nan_value).nan?.should be_true - 1.fdiv(nan_value).nan?.should be_true + -1.fdiv(nan_value).nan?.should == true + 1.fdiv(nan_value).nan?.should == true end it "returns Infinity when the argument is 0" do @@ -86,11 +86,11 @@ end it "raises a TypeError when argument isn't numeric" do - -> { 1.fdiv(mock('non-numeric')) }.should raise_error(TypeError) + -> { 1.fdiv(mock('non-numeric')) }.should.raise(TypeError) end it "raises an ArgumentError when passed multiple arguments" do - -> { 1.fdiv(6,0.2) }.should raise_error(ArgumentError) + -> { 1.fdiv(6,0.2) }.should.raise(ArgumentError) end it "follows the coercion protocol" do diff --git a/spec/ruby/core/integer/gcd_spec.rb b/spec/ruby/core/integer/gcd_spec.rb index 961f1c5c2e2a66..1fff785927896b 100644 --- a/spec/ruby/core/integer/gcd_spec.rb +++ b/spec/ruby/core/integer/gcd_spec.rb @@ -7,8 +7,8 @@ end it "returns an Integer" do - 36.gcd(6).should be_kind_of(Integer) - 4.gcd(20981).should be_kind_of(Integer) + 36.gcd(6).should.is_a?(Integer) + 4.gcd(20981).should.is_a?(Integer) end it "returns the greatest common divisor of self and argument" do @@ -33,13 +33,13 @@ it "accepts a Bignum argument" do bignum = 9999**99 - bignum.should be_kind_of(Integer) + bignum.should.is_a?(Integer) 99.gcd(bignum).should == 99 end it "works if self is a Bignum" do bignum = 9999**99 - bignum.should be_kind_of(Integer) + bignum.should.is_a?(Integer) bignum.gcd(99).should == 99 end @@ -55,15 +55,15 @@ end it "raises an ArgumentError if not given an argument" do - -> { 12.gcd }.should raise_error(ArgumentError) + -> { 12.gcd }.should.raise(ArgumentError) end it "raises an ArgumentError if given more than one argument" do - -> { 12.gcd(30, 20) }.should raise_error(ArgumentError) + -> { 12.gcd(30, 20) }.should.raise(ArgumentError) end it "raises a TypeError unless the argument is an Integer" do - -> { 39.gcd(3.8) }.should raise_error(TypeError) - -> { 45872.gcd([]) }.should raise_error(TypeError) + -> { 39.gcd(3.8) }.should.raise(TypeError) + -> { 45872.gcd([]) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/gcdlcm_spec.rb b/spec/ruby/core/integer/gcdlcm_spec.rb index ebf45e55a1bcd6..419bf9f275f3ba 100644 --- a/spec/ruby/core/integer/gcdlcm_spec.rb +++ b/spec/ruby/core/integer/gcdlcm_spec.rb @@ -7,8 +7,8 @@ end it "returns an Array" do - 36.gcdlcm(6).should be_kind_of(Array) - 4.gcdlcm(20981).should be_kind_of(Array) + 36.gcdlcm(6).should.is_a?(Array) + 4.gcdlcm(20981).should.is_a?(Array) end it "returns a two-element Array" do @@ -28,26 +28,26 @@ it "accepts a Bignum argument" do bignum = 91999**99 - bignum.should be_kind_of(Integer) + bignum.should.is_a?(Integer) 99.gcdlcm(bignum).should == [99.gcd(bignum), 99.lcm(bignum)] end it "works if self is a Bignum" do bignum = 9999**89 - bignum.should be_kind_of(Integer) + bignum.should.is_a?(Integer) bignum.gcdlcm(99).should == [bignum.gcd(99), bignum.lcm(99)] end it "raises an ArgumentError if not given an argument" do - -> { 12.gcdlcm }.should raise_error(ArgumentError) + -> { 12.gcdlcm }.should.raise(ArgumentError) end it "raises an ArgumentError if given more than one argument" do - -> { 12.gcdlcm(30, 20) }.should raise_error(ArgumentError) + -> { 12.gcdlcm(30, 20) }.should.raise(ArgumentError) end it "raises a TypeError unless the argument is an Integer" do - -> { 39.gcdlcm(3.8) }.should raise_error(TypeError) - -> { 45872.gcdlcm([]) }.should raise_error(TypeError) + -> { 39.gcdlcm(3.8) }.should.raise(TypeError) + -> { 45872.gcdlcm([]) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/gt_spec.rb b/spec/ruby/core/integer/gt_spec.rb index 711c2a79b0acbb..75436144cf3a5c 100644 --- a/spec/ruby/core/integer/gt_spec.rb +++ b/spec/ruby/core/integer/gt_spec.rb @@ -17,8 +17,8 @@ end it "raises an ArgumentError when given a non-Integer" do - -> { 5 > "4" }.should raise_error(ArgumentError) - -> { 5 > mock('x') }.should raise_error(ArgumentError) + -> { 5 > "4" }.should.raise(ArgumentError) + -> { 5 > mock('x') }.should.raise(ArgumentError) end end @@ -36,8 +36,8 @@ end it "raises an ArgumentError when given a non-Integer" do - -> { @bignum > "4" }.should raise_error(ArgumentError) - -> { @bignum > mock('str') }.should raise_error(ArgumentError) + -> { @bignum > "4" }.should.raise(ArgumentError) + -> { @bignum > mock('str') }.should.raise(ArgumentError) end it "dispatches the correct operator after coercion" do diff --git a/spec/ruby/core/integer/gte_spec.rb b/spec/ruby/core/integer/gte_spec.rb index bce043bd5aad2d..e5cb892efdaa52 100644 --- a/spec/ruby/core/integer/gte_spec.rb +++ b/spec/ruby/core/integer/gte_spec.rb @@ -18,8 +18,8 @@ end it "raises an ArgumentError when given a non-Integer" do - -> { 5 >= "4" }.should raise_error(ArgumentError) - -> { 5 >= mock('x') }.should raise_error(ArgumentError) + -> { 5 >= "4" }.should.raise(ArgumentError) + -> { 5 >= mock('x') }.should.raise(ArgumentError) end end @@ -36,8 +36,8 @@ end it "raises an ArgumentError when given a non-Integer" do - -> { @bignum >= "4" }.should raise_error(ArgumentError) - -> { @bignum >= mock('str') }.should raise_error(ArgumentError) + -> { @bignum >= "4" }.should.raise(ArgumentError) + -> { @bignum >= mock('str') }.should.raise(ArgumentError) end it "dispatches the correct operator after coercion" do diff --git a/spec/ruby/core/integer/integer_spec.rb b/spec/ruby/core/integer/integer_spec.rb index 2d5d2e3e92dc2c..19a962d548b091 100644 --- a/spec/ruby/core/integer/integer_spec.rb +++ b/spec/ruby/core/integer/integer_spec.rb @@ -6,8 +6,8 @@ end it "is the class of both small and large integers" do - 42.class.should equal(Integer) - bignum_value.class.should equal(Integer) + 42.class.should.equal?(Integer) + bignum_value.class.should.equal?(Integer) end end diff --git a/spec/ruby/core/integer/lcm_spec.rb b/spec/ruby/core/integer/lcm_spec.rb index 296a001c8cbc96..6659247d1eab00 100644 --- a/spec/ruby/core/integer/lcm_spec.rb +++ b/spec/ruby/core/integer/lcm_spec.rb @@ -7,8 +7,8 @@ end it "returns an Integer" do - 36.lcm(6).should be_kind_of(Integer) - 4.lcm(20981).should be_kind_of(Integer) + 36.lcm(6).should.is_a?(Integer) + 4.lcm(20981).should.is_a?(Integer) end it "returns the least common multiple of self and argument" do @@ -33,26 +33,26 @@ it "accepts a Bignum argument" do bignum = 9999**99 - bignum.should be_kind_of(Integer) + bignum.should.is_a?(Integer) 99.lcm(bignum).should == bignum end it "works if self is a Bignum" do bignum = 9999**99 - bignum.should be_kind_of(Integer) + bignum.should.is_a?(Integer) bignum.lcm(99).should == bignum end it "raises an ArgumentError if not given an argument" do - -> { 12.lcm }.should raise_error(ArgumentError) + -> { 12.lcm }.should.raise(ArgumentError) end it "raises an ArgumentError if given more than one argument" do - -> { 12.lcm(30, 20) }.should raise_error(ArgumentError) + -> { 12.lcm(30, 20) }.should.raise(ArgumentError) end it "raises a TypeError unless the argument is an Integer" do - -> { 39.lcm(3.8) }.should raise_error(TypeError) - -> { 45872.lcm([]) }.should raise_error(TypeError) + -> { 39.lcm(3.8) }.should.raise(TypeError) + -> { 45872.lcm([]) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/left_shift_spec.rb b/spec/ruby/core/integer/left_shift_spec.rb index 86c2b18ae298ba..7eedb91228bfe4 100644 --- a/spec/ruby/core/integer/left_shift_spec.rb +++ b/spec/ruby/core/integer/left_shift_spec.rb @@ -58,13 +58,13 @@ it "returns a Bignum == fixnum_max * 2 when fixnum_max << 1 and n > 0" do result = fixnum_max << 1 - result.should be_an_instance_of(Integer) + result.should.instance_of?(Integer) result.should == fixnum_max * 2 end it "returns a Bignum == fixnum_min * 2 when fixnum_min << 1 and n < 0" do result = fixnum_min << 1 - result.should be_an_instance_of(Integer) + result.should.instance_of?(Integer) result.should == fixnum_min * 2 end @@ -82,15 +82,15 @@ obj = mock("a string") obj.should_receive(:to_int).and_return("asdf") - -> { 3 << obj }.should raise_error(TypeError) + -> { 3 << obj }.should.raise(TypeError) end it "raises a TypeError when passed nil" do - -> { 3 << nil }.should raise_error(TypeError) + -> { 3 << nil }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { 3 << "4" }.should raise_error(TypeError) + -> { 3 << "4" }.should.raise(TypeError) end end @@ -129,13 +129,13 @@ it "returns a Fixnum == fixnum_max when (fixnum_max * 2) << -1 and n > 0" do result = (fixnum_max * 2) << -1 - result.should be_an_instance_of(Integer) + result.should.instance_of?(Integer) result.should == fixnum_max end it "returns a Fixnum == fixnum_min when (fixnum_min * 2) << -1 and n < 0" do result = (fixnum_min * 2) << -1 - result.should be_an_instance_of(Integer) + result.should.instance_of?(Integer) result.should == fixnum_min end @@ -150,15 +150,15 @@ obj = mock("a string") obj.should_receive(:to_int).and_return("asdf") - -> { @bignum << obj }.should raise_error(TypeError) + -> { @bignum << obj }.should.raise(TypeError) end it "raises a TypeError when passed nil" do - -> { @bignum << nil }.should raise_error(TypeError) + -> { @bignum << nil }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { @bignum << "4" }.should raise_error(TypeError) + -> { @bignum << "4" }.should.raise(TypeError) end end @@ -201,10 +201,10 @@ exps << bignum_value << coerce_bignum if bignum_value >= limit exps.each { |exp| - -> { (1 << exp) }.should raise_error(RangeError, 'shift width too big') - -> { (-1 << exp) }.should raise_error(RangeError, 'shift width too big') - -> { (bignum_value << exp) }.should raise_error(RangeError, 'shift width too big') - -> { (-bignum_value << exp) }.should raise_error(RangeError, 'shift width too big') + -> { (1 << exp) }.should.raise(RangeError, 'shift width too big') + -> { (-1 << exp) }.should.raise(RangeError, 'shift width too big') + -> { (bignum_value << exp) }.should.raise(RangeError, 'shift width too big') + -> { (-bignum_value << exp) }.should.raise(RangeError, 'shift width too big') } end end diff --git a/spec/ruby/core/integer/lt_spec.rb b/spec/ruby/core/integer/lt_spec.rb index 6ca9697436ed92..dd1391d09326ed 100644 --- a/spec/ruby/core/integer/lt_spec.rb +++ b/spec/ruby/core/integer/lt_spec.rb @@ -17,8 +17,8 @@ end it "raises an ArgumentError when given a non-Integer" do - -> { 5 < "4" }.should raise_error(ArgumentError) - -> { 5 < mock('x') }.should raise_error(ArgumentError) + -> { 5 < "4" }.should.raise(ArgumentError) + -> { 5 < mock('x') }.should.raise(ArgumentError) end end @@ -38,8 +38,8 @@ end it "raises an ArgumentError when given a non-Integer" do - -> { @bignum < "4" }.should raise_error(ArgumentError) - -> { @bignum < mock('str') }.should raise_error(ArgumentError) + -> { @bignum < "4" }.should.raise(ArgumentError) + -> { @bignum < mock('str') }.should.raise(ArgumentError) end it "dispatches the correct operator after coercion" do diff --git a/spec/ruby/core/integer/lte_spec.rb b/spec/ruby/core/integer/lte_spec.rb index d7bb86ce6f3e15..9ef1c9f6045e0b 100644 --- a/spec/ruby/core/integer/lte_spec.rb +++ b/spec/ruby/core/integer/lte_spec.rb @@ -18,8 +18,8 @@ end it "raises an ArgumentError when given a non-Integer" do - -> { 5 <= "4" }.should raise_error(ArgumentError) - -> { 5 <= mock('x') }.should raise_error(ArgumentError) + -> { 5 <= "4" }.should.raise(ArgumentError) + -> { 5 <= mock('x') }.should.raise(ArgumentError) end end @@ -46,8 +46,8 @@ end it "raises an ArgumentError when given a non-Integer" do - -> { @bignum <= "4" }.should raise_error(ArgumentError) - -> { @bignum <= mock('str') }.should raise_error(ArgumentError) + -> { @bignum <= "4" }.should.raise(ArgumentError) + -> { @bignum <= mock('str') }.should.raise(ArgumentError) end it "dispatches the correct operator after coercion" do diff --git a/spec/ruby/core/integer/minus_spec.rb b/spec/ruby/core/integer/minus_spec.rb index 6072ba7c8b8a24..5fd3a81a722410 100644 --- a/spec/ruby/core/integer/minus_spec.rb +++ b/spec/ruby/core/integer/minus_spec.rb @@ -17,9 +17,9 @@ -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13 - obj - }.should raise_error(TypeError) - -> { 13 - "10" }.should raise_error(TypeError) - -> { 13 - :symbol }.should raise_error(TypeError) + }.should.raise(TypeError) + -> { 13 - "10" }.should.raise(TypeError) + -> { 13 - :symbol }.should.raise(TypeError) end end @@ -35,9 +35,9 @@ end it "raises a TypeError when given a non-Integer" do - -> { @bignum - mock('10') }.should raise_error(TypeError) - -> { @bignum - "10" }.should raise_error(TypeError) - -> { @bignum - :symbol }.should raise_error(TypeError) + -> { @bignum - mock('10') }.should.raise(TypeError) + -> { @bignum - "10" }.should.raise(TypeError) + -> { @bignum - :symbol }.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/multiply_spec.rb b/spec/ruby/core/integer/multiply_spec.rb index 5037d27458a377..7f30eebaa591dd 100644 --- a/spec/ruby/core/integer/multiply_spec.rb +++ b/spec/ruby/core/integer/multiply_spec.rb @@ -18,9 +18,9 @@ -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13 * obj - }.should raise_error(TypeError) - -> { 13 * "10" }.should raise_error(TypeError) - -> { 13 * :symbol }.should raise_error(TypeError) + }.should.raise(TypeError) + -> { 13 * "10" }.should.raise(TypeError) + -> { 13 * :symbol }.should.raise(TypeError) end end @@ -37,9 +37,9 @@ end it "raises a TypeError when given a non-Integer" do - -> { @bignum * mock('10') }.should raise_error(TypeError) - -> { @bignum * "10" }.should raise_error(TypeError) - -> { @bignum * :symbol }.should raise_error(TypeError) + -> { @bignum * mock('10') }.should.raise(TypeError) + -> { @bignum * "10" }.should.raise(TypeError) + -> { @bignum * :symbol }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/integer/nobits_spec.rb b/spec/ruby/core/integer/nobits_spec.rb index 685759ffa360e3..f1a3aca9d5e2f8 100644 --- a/spec/ruby/core/integer/nobits_spec.rb +++ b/spec/ruby/core/integer/nobits_spec.rb @@ -29,8 +29,8 @@ -> { (obj = mock('10')).should_receive(:coerce).any_number_of_times.and_return([42,10]) 13.nobits?(obj) - }.should raise_error(TypeError) - -> { 13.nobits?("10") }.should raise_error(TypeError) - -> { 13.nobits?(:symbol) }.should raise_error(TypeError) + }.should.raise(TypeError) + -> { 13.nobits?("10") }.should.raise(TypeError) + -> { 13.nobits?(:symbol) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/odd_spec.rb b/spec/ruby/core/integer/odd_spec.rb index dd779fa44be798..f9e50ec790cf7c 100644 --- a/spec/ruby/core/integer/odd_spec.rb +++ b/spec/ruby/core/integer/odd_spec.rb @@ -3,36 +3,36 @@ describe "Integer#odd?" do context "fixnum" do it "returns true when self is an odd number" do - (-2).odd?.should be_false - (-1).odd?.should be_true + (-2).odd?.should == false + (-1).odd?.should == true - 0.odd?.should be_false - 1.odd?.should be_true - 2.odd?.should be_false + 0.odd?.should == false + 1.odd?.should == true + 2.odd?.should == false - bignum_value(0).odd?.should be_false - bignum_value(1).odd?.should be_true + bignum_value(0).odd?.should == false + bignum_value(1).odd?.should == true - (-bignum_value(0)).odd?.should be_false - (-bignum_value(1)).odd?.should be_true + (-bignum_value(0)).odd?.should == false + (-bignum_value(1)).odd?.should == true end end context "bignum" do it "returns true if self is odd and positive" do - (987279**19).odd?.should be_true + (987279**19).odd?.should == true end it "returns true if self is odd and negative" do - (-9873389**97).odd?.should be_true + (-9873389**97).odd?.should == true end it "returns false if self is even and positive" do - (10000000**10).odd?.should be_false + (10000000**10).odd?.should == false end it "returns false if self is even and negative" do - (-1000000**100).odd?.should be_false + (-1000000**100).odd?.should == false end end end diff --git a/spec/ruby/core/integer/ord_spec.rb b/spec/ruby/core/integer/ord_spec.rb index bcb57bea989778..8b7dfe460db2aa 100644 --- a/spec/ruby/core/integer/ord_spec.rb +++ b/spec/ruby/core/integer/ord_spec.rb @@ -2,16 +2,16 @@ describe "Integer#ord" do it "returns self" do - 20.ord.should eql(20) - 40.ord.should eql(40) + 20.ord.should.eql?(20) + 40.ord.should.eql?(40) - 0.ord.should eql(0) - (-10).ord.should eql(-10) + 0.ord.should.eql?(0) + (-10).ord.should.eql?(-10) - ?a.ord.should eql(97) - ?Z.ord.should eql(90) + ?a.ord.should.eql?(97) + ?Z.ord.should.eql?(90) - bignum_value.ord.should eql(bignum_value) - (-bignum_value).ord.should eql(-bignum_value) + bignum_value.ord.should.eql?(bignum_value) + (-bignum_value).ord.should.eql?(-bignum_value) end end diff --git a/spec/ruby/core/integer/plus_spec.rb b/spec/ruby/core/integer/plus_spec.rb index 38428e56c5b0c2..b684377bd5a32f 100644 --- a/spec/ruby/core/integer/plus_spec.rb +++ b/spec/ruby/core/integer/plus_spec.rb @@ -17,9 +17,9 @@ -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13 + obj - }.should raise_error(TypeError) - -> { 13 + "10" }.should raise_error(TypeError) - -> { 13 + :symbol }.should raise_error(TypeError) + }.should.raise(TypeError) + -> { 13 + "10" }.should.raise(TypeError) + -> { 13 + :symbol }.should.raise(TypeError) end end @@ -35,9 +35,9 @@ end it "raises a TypeError when given a non-Integer" do - -> { @bignum + mock('10') }.should raise_error(TypeError) - -> { @bignum + "10" }.should raise_error(TypeError) - -> { @bignum + :symbol}.should raise_error(TypeError) + -> { @bignum + mock('10') }.should.raise(TypeError) + -> { @bignum + "10" }.should.raise(TypeError) + -> { @bignum + :symbol}.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/pow_spec.rb b/spec/ruby/core/integer/pow_spec.rb index ecaca01eff3bc2..12a3839c409dda 100644 --- a/spec/ruby/core/integer/pow_spec.rb +++ b/spec/ruby/core/integer/pow_spec.rb @@ -16,10 +16,10 @@ end it "works well with bignums" do - 2.pow(61, 5843009213693951).should eql 3697379018277258 - 2.pow(62, 5843009213693952).should eql 1551748822859776 - 2.pow(63, 5843009213693953).should eql 3103497645717974 - 2.pow(64, 5843009213693954).should eql 363986077738838 + 2.pow(61, 5843009213693951).should.eql? 3697379018277258 + 2.pow(62, 5843009213693952).should.eql? 1551748822859776 + 2.pow(63, 5843009213693953).should.eql? 3103497645717974 + 2.pow(64, 5843009213693954).should.eql? 363986077738838 end it "handles sign like #divmod does" do @@ -30,22 +30,22 @@ end it "ensures all arguments are integers" do - -> { 2.pow(5, 12.0) }.should raise_error(TypeError, /2nd argument not allowed unless all arguments are integers/) - -> { 2.pow(5, Rational(12, 1)) }.should raise_error(TypeError, /2nd argument not allowed unless all arguments are integers/) + -> { 2.pow(5, 12.0) }.should.raise(TypeError, /2nd argument not allowed unless all arguments are integers/) + -> { 2.pow(5, Rational(12, 1)) }.should.raise(TypeError, /2nd argument not allowed unless all arguments are integers/) end it "raises TypeError for non-numeric value" do - -> { 2.pow(5, "12") }.should raise_error(TypeError) - -> { 2.pow(5, []) }.should raise_error(TypeError) - -> { 2.pow(5, nil) }.should raise_error(TypeError) + -> { 2.pow(5, "12") }.should.raise(TypeError) + -> { 2.pow(5, []) }.should.raise(TypeError) + -> { 2.pow(5, nil) }.should.raise(TypeError) end it "raises a ZeroDivisionError when the given argument is 0" do - -> { 2.pow(5, 0) }.should raise_error(ZeroDivisionError) + -> { 2.pow(5, 0) }.should.raise(ZeroDivisionError) end it "raises a RangeError when the first argument is negative and the second argument is present" do - -> { 2.pow(-5, 1) }.should raise_error(RangeError) + -> { 2.pow(-5, 1) }.should.raise(RangeError) end end end diff --git a/spec/ruby/core/integer/pred_spec.rb b/spec/ruby/core/integer/pred_spec.rb index 86750ebfd1a36c..fce536b5a2395e 100644 --- a/spec/ruby/core/integer/pred_spec.rb +++ b/spec/ruby/core/integer/pred_spec.rb @@ -2,10 +2,10 @@ describe "Integer#pred" do it "returns the Integer equal to self - 1" do - 0.pred.should eql(-1) - -1.pred.should eql(-2) - bignum_value.pred.should eql(bignum_value(-1)) - fixnum_min.pred.should eql(fixnum_min - 1) - 20.pred.should eql(19) + 0.pred.should.eql?(-1) + -1.pred.should.eql?(-2) + bignum_value.pred.should.eql?(bignum_value(-1)) + fixnum_min.pred.should.eql?(fixnum_min - 1) + 20.pred.should.eql?(19) end end diff --git a/spec/ruby/core/integer/rationalize_spec.rb b/spec/ruby/core/integer/rationalize_spec.rb index 09d741af3333e7..272eca691109e3 100644 --- a/spec/ruby/core/integer/rationalize_spec.rb +++ b/spec/ruby/core/integer/rationalize_spec.rb @@ -12,7 +12,7 @@ it "returns a Rational object" do @numbers.each do |number| - number.rationalize.should be_an_instance_of(Rational) + number.rationalize.should.instance_of?(Rational) end end @@ -33,7 +33,7 @@ end it "raises ArgumentError when passed more than one argument" do - -> { 1.rationalize(0.1, 0.1) }.should raise_error(ArgumentError) - -> { 1.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError) + -> { 1.rationalize(0.1, 0.1) }.should.raise(ArgumentError) + -> { 1.rationalize(0.1, 0.1, 2) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/integer/remainder_spec.rb b/spec/ruby/core/integer/remainder_spec.rb index 757e42fbe84f69..deb81fb2a56fea 100644 --- a/spec/ruby/core/integer/remainder_spec.rb +++ b/spec/ruby/core/integer/remainder_spec.rb @@ -22,10 +22,10 @@ end it "raises TypeError if passed non-numeric argument" do - -> { 5.remainder("3") }.should raise_error(TypeError) - -> { 5.remainder(:"3") }.should raise_error(TypeError) - -> { 5.remainder([]) }.should raise_error(TypeError) - -> { 5.remainder(nil) }.should raise_error(TypeError) + -> { 5.remainder("3") }.should.raise(TypeError) + -> { 5.remainder(:"3") }.should.raise(TypeError) + -> { 5.remainder([]) }.should.raise(TypeError) + -> { 5.remainder(nil) }.should.raise(TypeError) end end @@ -38,14 +38,14 @@ end it "raises a ZeroDivisionError if other is zero and not a Float" do - -> { bignum_value(66).remainder(0) }.should raise_error(ZeroDivisionError) + -> { bignum_value(66).remainder(0) }.should.raise(ZeroDivisionError) end it "does raises ZeroDivisionError if other is zero and a Float" do a = bignum_value(7) b = bignum_value(32) - -> { a.remainder(0.0) }.should raise_error(ZeroDivisionError) - -> { b.remainder(-0.0) }.should raise_error(ZeroDivisionError) + -> { a.remainder(0.0) }.should.raise(ZeroDivisionError) + -> { b.remainder(-0.0) }.should.raise(ZeroDivisionError) end end end diff --git a/spec/ruby/core/integer/right_shift_spec.rb b/spec/ruby/core/integer/right_shift_spec.rb index c902674e2f3e26..4281d3b7ab38b0 100644 --- a/spec/ruby/core/integer/right_shift_spec.rb +++ b/spec/ruby/core/integer/right_shift_spec.rb @@ -54,13 +54,13 @@ it "returns a Bignum == fixnum_max * 2 when fixnum_max >> -1 and n > 0" do result = fixnum_max >> -1 - result.should be_an_instance_of(Integer) + result.should.instance_of?(Integer) result.should == fixnum_max * 2 end it "returns a Bignum == fixnum_min * 2 when fixnum_min >> -1 and n < 0" do result = fixnum_min >> -1 - result.should be_an_instance_of(Integer) + result.should.instance_of?(Integer) result.should == fixnum_min * 2 end @@ -78,15 +78,15 @@ obj = mock("a string") obj.should_receive(:to_int).and_return("asdf") - -> { 3 >> obj }.should raise_error(TypeError) + -> { 3 >> obj }.should.raise(TypeError) end it "raises a TypeError when passed nil" do - -> { 3 >> nil }.should raise_error(TypeError) + -> { 3 >> nil }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { 3 >> "4" }.should raise_error(TypeError) + -> { 3 >> "4" }.should.raise(TypeError) end end @@ -151,13 +151,13 @@ it "returns a Fixnum == fixnum_max when (fixnum_max * 2) >> 1 and n > 0" do result = (fixnum_max * 2) >> 1 - result.should be_an_instance_of(Integer) + result.should.instance_of?(Integer) result.should == fixnum_max end it "returns a Fixnum == fixnum_min when (fixnum_min * 2) >> 1 and n < 0" do result = (fixnum_min * 2) >> 1 - result.should be_an_instance_of(Integer) + result.should.instance_of?(Integer) result.should == fixnum_min end @@ -172,15 +172,15 @@ obj = mock("a string") obj.should_receive(:to_int).and_return("asdf") - -> { @bignum >> obj }.should raise_error(TypeError) + -> { @bignum >> obj }.should.raise(TypeError) end it "raises a TypeError when passed nil" do - -> { @bignum >> nil }.should raise_error(TypeError) + -> { @bignum >> nil }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { @bignum >> "4" }.should raise_error(TypeError) + -> { @bignum >> "4" }.should.raise(TypeError) end end @@ -223,10 +223,10 @@ exps << -bignum_value << coerce_bignum if bignum_value >= limit exps.each { |exp| - -> { (1 >> exp) }.should raise_error(RangeError, 'shift width too big') - -> { (-1 >> exp) }.should raise_error(RangeError, 'shift width too big') - -> { (bignum_value >> exp) }.should raise_error(RangeError, 'shift width too big') - -> { (-bignum_value >> exp) }.should raise_error(RangeError, 'shift width too big') + -> { (1 >> exp) }.should.raise(RangeError, 'shift width too big') + -> { (-1 >> exp) }.should.raise(RangeError, 'shift width too big') + -> { (bignum_value >> exp) }.should.raise(RangeError, 'shift width too big') + -> { (-bignum_value >> exp) }.should.raise(RangeError, 'shift width too big') } end end diff --git a/spec/ruby/core/integer/round_spec.rb b/spec/ruby/core/integer/round_spec.rb index 189384f11adf88..a3f11e7a7618ff 100644 --- a/spec/ruby/core/integer/round_spec.rb +++ b/spec/ruby/core/integer/round_spec.rb @@ -8,37 +8,37 @@ # redmine:5228 it "returns itself rounded if passed a negative value" do - +249.round(-2).should eql(+200) - -249.round(-2).should eql(-200) - (+25 * 10**70 - 1).round(-71).should eql(+20 * 10**70) - (-25 * 10**70 + 1).round(-71).should eql(-20 * 10**70) + +249.round(-2).should.eql?(+200) + -249.round(-2).should.eql?(-200) + (+25 * 10**70 - 1).round(-71).should.eql?(+20 * 10**70) + (-25 * 10**70 + 1).round(-71).should.eql?(-20 * 10**70) end it "returns itself rounded to nearest if passed a negative value" do - +250.round(-2).should eql(+300) - -250.round(-2).should eql(-300) - (+25 * 10**70).round(-71).should eql(+30 * 10**70) - (-25 * 10**70).round(-71).should eql(-30 * 10**70) + +250.round(-2).should.eql?(+300) + -250.round(-2).should.eql?(-300) + (+25 * 10**70).round(-71).should.eql?(+30 * 10**70) + (-25 * 10**70).round(-71).should.eql?(-30 * 10**70) end it "raises a RangeError when passed a big negative value" do - -> { 42.round(min_long - 1) }.should raise_error(RangeError) + -> { 42.round(min_long - 1) }.should.raise(RangeError) end it "raises a RangeError when passed Float::INFINITY" do - -> { 42.round(Float::INFINITY) }.should raise_error(RangeError) + -> { 42.round(Float::INFINITY) }.should.raise(RangeError) end it "raises a RangeError when passed a beyond signed int" do - -> { 42.round(1<<31) }.should raise_error(RangeError) + -> { 42.round(1<<31) }.should.raise(RangeError) end it "raises a TypeError when passed a String" do - -> { 42.round("4") }.should raise_error(TypeError) + -> { 42.round("4") }.should.raise(TypeError) end it "raises a TypeError when its argument cannot be converted to an Integer" do - -> { 42.round(nil) }.should raise_error(TypeError) + -> { 42.round(nil) }.should.raise(TypeError) end it "calls #to_int on the argument to convert it to an Integer" do @@ -50,32 +50,32 @@ it "raises a TypeError when #to_int does not return an Integer" do obj = mock("Object") obj.stub!(:to_int).and_return([]) - -> { 42.round(obj) }.should raise_error(TypeError) + -> { 42.round(obj) }.should.raise(TypeError) end it "returns different rounded values depending on the half option" do - 25.round(-1, half: :up).should eql(30) - 25.round(-1, half: :down).should eql(20) - 25.round(-1, half: :even).should eql(20) - 25.round(-1, half: nil).should eql(30) - 35.round(-1, half: :up).should eql(40) - 35.round(-1, half: :down).should eql(30) - 35.round(-1, half: :even).should eql(40) - 35.round(-1, half: nil).should eql(40) - (-25).round(-1, half: :up).should eql(-30) - (-25).round(-1, half: :down).should eql(-20) - (-25).round(-1, half: :even).should eql(-20) - (-25).round(-1, half: nil).should eql(-30) + 25.round(-1, half: :up).should.eql?(30) + 25.round(-1, half: :down).should.eql?(20) + 25.round(-1, half: :even).should.eql?(20) + 25.round(-1, half: nil).should.eql?(30) + 35.round(-1, half: :up).should.eql?(40) + 35.round(-1, half: :down).should.eql?(30) + 35.round(-1, half: :even).should.eql?(40) + 35.round(-1, half: nil).should.eql?(40) + (-25).round(-1, half: :up).should.eql?(-30) + (-25).round(-1, half: :down).should.eql?(-20) + (-25).round(-1, half: :even).should.eql?(-20) + (-25).round(-1, half: nil).should.eql?(-30) end it "returns itself if passed a positive precision and the half option" do - 35.round(1, half: :up).should eql(35) - 35.round(1, half: :down).should eql(35) - 35.round(1, half: :even).should eql(35) + 35.round(1, half: :up).should.eql?(35) + 35.round(1, half: :down).should.eql?(35) + 35.round(1, half: :even).should.eql?(35) end it "raises ArgumentError for an unknown rounding mode" do - -> { 42.round(-1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/) - -> { 42.round(1, half: :foo) }.should raise_error(ArgumentError, /invalid rounding mode: foo/) + -> { 42.round(-1, half: :foo) }.should.raise(ArgumentError, /invalid rounding mode: foo/) + -> { 42.round(1, half: :foo) }.should.raise(ArgumentError, /invalid rounding mode: foo/) end end diff --git a/spec/ruby/core/integer/shared/arithmetic_coerce.rb b/spec/ruby/core/integer/shared/arithmetic_coerce.rb index 1260192df19a6f..561b18fe52a3cb 100644 --- a/spec/ruby/core/integer/shared/arithmetic_coerce.rb +++ b/spec/ruby/core/integer/shared/arithmetic_coerce.rb @@ -6,6 +6,6 @@ b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError) # e.g. 1 + b - -> { 1.send(@method, b) }.should raise_error(IntegerSpecs::CoerceError) + -> { 1.send(@method, b) }.should.raise(IntegerSpecs::CoerceError) end end diff --git a/spec/ruby/core/integer/shared/comparison_coerce.rb b/spec/ruby/core/integer/shared/comparison_coerce.rb index af52f5e99b0753..4bb7404183668a 100644 --- a/spec/ruby/core/integer/shared/comparison_coerce.rb +++ b/spec/ruby/core/integer/shared/comparison_coerce.rb @@ -6,6 +6,6 @@ b.should_receive(:coerce).and_raise(IntegerSpecs::CoerceError) # e.g. 1 > b - -> { 1.send(@method, b) }.should raise_error(IntegerSpecs::CoerceError) + -> { 1.send(@method, b) }.should.raise(IntegerSpecs::CoerceError) end end diff --git a/spec/ruby/core/integer/shared/exponent.rb b/spec/ruby/core/integer/shared/exponent.rb index d30c54fd3195d5..0be13859f93df0 100644 --- a/spec/ruby/core/integer/shared/exponent.rb +++ b/spec/ruby/core/integer/shared/exponent.rb @@ -1,51 +1,51 @@ describe :integer_exponent, shared: true do context "fixnum" do it "returns self raised to the given power" do - 2.send(@method, 0).should eql 1 - 2.send(@method, 1).should eql 2 - 2.send(@method, 2).should eql 4 + 2.send(@method, 0).should.eql? 1 + 2.send(@method, 1).should.eql? 2 + 2.send(@method, 2).should.eql? 4 - 9.send(@method, 0.5).should eql 3.0 - 9.send(@method, Rational(1, 2)).should eql 3.0 + 9.send(@method, 0.5).should.eql? 3.0 + 9.send(@method, Rational(1, 2)).should.eql? 3.0 5.send(@method, -1).to_f.to_s.should == '0.2' - 2.send(@method, 40).should eql 1099511627776 + 2.send(@method, 40).should.eql? 1099511627776 end it "overflows the answer to a bignum transparently" do - 2.send(@method, 29).should eql 536870912 - 2.send(@method, 30).should eql 1073741824 - 2.send(@method, 31).should eql 2147483648 - 2.send(@method, 32).should eql 4294967296 + 2.send(@method, 29).should.eql? 536870912 + 2.send(@method, 30).should.eql? 1073741824 + 2.send(@method, 31).should.eql? 2147483648 + 2.send(@method, 32).should.eql? 4294967296 - 2.send(@method, 61).should eql 2305843009213693952 - 2.send(@method, 62).should eql 4611686018427387904 - 2.send(@method, 63).should eql 9223372036854775808 - 2.send(@method, 64).should eql 18446744073709551616 - 8.send(@method, 23).should eql 590295810358705651712 + 2.send(@method, 61).should.eql? 2305843009213693952 + 2.send(@method, 62).should.eql? 4611686018427387904 + 2.send(@method, 63).should.eql? 9223372036854775808 + 2.send(@method, 64).should.eql? 18446744073709551616 + 8.send(@method, 23).should.eql? 590295810358705651712 end it "raises negative numbers to the given power" do - (-2).send(@method, 29).should eql(-536870912) - (-2).send(@method, 30).should eql(1073741824) - (-2).send(@method, 31).should eql(-2147483648) - (-2).send(@method, 32).should eql(4294967296) - (-2).send(@method, 33).should eql(-8589934592) + (-2).send(@method, 29).should.eql?(-536870912) + (-2).send(@method, 30).should.eql?(1073741824) + (-2).send(@method, 31).should.eql?(-2147483648) + (-2).send(@method, 32).should.eql?(4294967296) + (-2).send(@method, 33).should.eql?(-8589934592) - (-2).send(@method, 61).should eql(-2305843009213693952) - (-2).send(@method, 62).should eql(4611686018427387904) - (-2).send(@method, 63).should eql(-9223372036854775808) - (-2).send(@method, 64).should eql(18446744073709551616) - (-2).send(@method, 65).should eql(-36893488147419103232) + (-2).send(@method, 61).should.eql?(-2305843009213693952) + (-2).send(@method, 62).should.eql?(4611686018427387904) + (-2).send(@method, 63).should.eql?(-9223372036854775808) + (-2).send(@method, 64).should.eql?(18446744073709551616) + (-2).send(@method, 65).should.eql?(-36893488147419103232) end it "can raise 1 to a bignum safely" do - 1.send(@method, 4611686018427387904).should eql 1 + 1.send(@method, 4611686018427387904).should.eql? 1 end it "can raise -1 to a bignum safely" do - (-1).send(@method, 4611686018427387904).should eql(1) - (-1).send(@method, 4611686018427387905).should eql(-1) + (-1).send(@method, 4611686018427387904).should.eql?(1) + (-1).send(@method, 4611686018427387905).should.eql?(-1) end ruby_version_is ""..."3.4" do @@ -66,13 +66,13 @@ end it "raises an ArgumentError when the result size exceeds the limit" do - -> { 100000000.send(@method, 1000000000) }.should raise_error(ArgumentError) + -> { 100000000.send(@method, 1000000000) }.should.raise(ArgumentError) end end it "raises a ZeroDivisionError for 0 ** -1" do - -> { 0.send(@method, -1) }.should raise_error(ZeroDivisionError) - -> { 0.send(@method, Rational(-1, 1)) }.should raise_error(ZeroDivisionError) + -> { 0.send(@method, -1) }.should.raise(ZeroDivisionError) + -> { 0.send(@method, Rational(-1, 1)) }.should.raise(ZeroDivisionError) end it "returns Float::INFINITY for 0 ** -1.0" do @@ -80,9 +80,9 @@ end it "raises a TypeError when given a non-numeric power" do - -> { 13.send(@method, "10") }.should raise_error(TypeError) - -> { 13.send(@method, :symbol) }.should raise_error(TypeError) - -> { 13.send(@method, nil) }.should raise_error(TypeError) + -> { 13.send(@method, "10") }.should.raise(TypeError) + -> { 13.send(@method, :symbol) }.should.raise(TypeError) + -> { 13.send(@method, nil) }.should.raise(TypeError) end it "coerces power and calls #**" do @@ -119,9 +119,9 @@ end it "raises a TypeError when given a non-Integer" do - -> { @bignum.send(@method, mock('10')) }.should raise_error(TypeError) - -> { @bignum.send(@method, "10") }.should raise_error(TypeError) - -> { @bignum.send(@method, :symbol) }.should raise_error(TypeError) + -> { @bignum.send(@method, mock('10')) }.should.raise(TypeError) + -> { @bignum.send(@method, "10") }.should.raise(TypeError) + -> { @bignum.send(@method, :symbol) }.should.raise(TypeError) end ruby_version_is ""..."3.4" do @@ -130,7 +130,7 @@ -> { flt = @bignum.send(@method, @bignum) }.should complain(/warning: in a\*\*b, b may be too big/) - flt.should be_kind_of(Float) + flt.should.is_a?(Float) flt.infinite?.should == 1 end end @@ -149,7 +149,7 @@ # @bignum ** @bignum would require enormous memory -> { @bignum.send(@method, @bignum) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/integer/shared/integer_rounding.rb b/spec/ruby/core/integer/shared/integer_rounding.rb index 56d1819f8403e8..92f2a2327c1d0f 100644 --- a/spec/ruby/core/integer/shared/integer_rounding.rb +++ b/spec/ruby/core/integer/shared/integer_rounding.rb @@ -1,19 +1,19 @@ describe :integer_rounding_positive_precision, shared: true do it "returns self if not passed a precision" do [2, -4, 10**70, -10**100].each do |v| - v.send(@method).should eql(v) + v.send(@method).should.eql?(v) end end it "returns self if passed a precision of zero" do [2, -4, 10**70, -10**100].each do |v| - v.send(@method, 0).should eql(v) + v.send(@method, 0).should.eql?(v) end end it "returns itself if passed a positive precision" do [2, -4, 10**70, -10**100].each do |v| - v.send(@method, 42).should eql(v) + v.send(@method, 42).should.eql?(v) end end end diff --git a/spec/ruby/core/integer/shared/modulo.rb b/spec/ruby/core/integer/shared/modulo.rb index d91af1e924176d..d0b5e26ed53600 100644 --- a/spec/ruby/core/integer/shared/modulo.rb +++ b/spec/ruby/core/integer/shared/modulo.rb @@ -41,24 +41,24 @@ end it "raises a ZeroDivisionError when the given argument is 0" do - -> { 13.send(@method, 0) }.should raise_error(ZeroDivisionError) - -> { 0.send(@method, 0) }.should raise_error(ZeroDivisionError) - -> { -10.send(@method, 0) }.should raise_error(ZeroDivisionError) + -> { 13.send(@method, 0) }.should.raise(ZeroDivisionError) + -> { 0.send(@method, 0) }.should.raise(ZeroDivisionError) + -> { -10.send(@method, 0) }.should.raise(ZeroDivisionError) end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - -> { 0.send(@method, 0.0) }.should raise_error(ZeroDivisionError) - -> { 10.send(@method, 0.0) }.should raise_error(ZeroDivisionError) - -> { -10.send(@method, 0.0) }.should raise_error(ZeroDivisionError) + -> { 0.send(@method, 0.0) }.should.raise(ZeroDivisionError) + -> { 10.send(@method, 0.0) }.should.raise(ZeroDivisionError) + -> { -10.send(@method, 0.0) }.should.raise(ZeroDivisionError) end it "raises a TypeError when given a non-Integer" do -> { (obj = mock('10')).should_receive(:to_int).any_number_of_times.and_return(10) 13.send(@method, obj) - }.should raise_error(TypeError) - -> { 13.send(@method, "10") }.should raise_error(TypeError) - -> { 13.send(@method, :symbol) }.should raise_error(TypeError) + }.should.raise(TypeError) + -> { 13.send(@method, "10") }.should.raise(TypeError) + -> { 13.send(@method, :symbol) }.should.raise(TypeError) end end @@ -96,19 +96,19 @@ end it "raises a ZeroDivisionError when the given argument is 0" do - -> { @bignum.send(@method, 0) }.should raise_error(ZeroDivisionError) - -> { (-@bignum).send(@method, 0) }.should raise_error(ZeroDivisionError) + -> { @bignum.send(@method, 0) }.should.raise(ZeroDivisionError) + -> { (-@bignum).send(@method, 0) }.should.raise(ZeroDivisionError) end it "raises a ZeroDivisionError when the given argument is 0 and a Float" do - -> { @bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError) - -> { -@bignum.send(@method, 0.0) }.should raise_error(ZeroDivisionError) + -> { @bignum.send(@method, 0.0) }.should.raise(ZeroDivisionError) + -> { -@bignum.send(@method, 0.0) }.should.raise(ZeroDivisionError) end it "raises a TypeError when given a non-Integer" do - -> { @bignum.send(@method, mock('10')) }.should raise_error(TypeError) - -> { @bignum.send(@method, "10") }.should raise_error(TypeError) - -> { @bignum.send(@method, :symbol) }.should raise_error(TypeError) + -> { @bignum.send(@method, mock('10')) }.should.raise(TypeError) + -> { @bignum.send(@method, "10") }.should.raise(TypeError) + -> { @bignum.send(@method, :symbol) }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/integer/shared/to_i.rb b/spec/ruby/core/integer/shared/to_i.rb index 7b974cd3a7e8f4..2b6a50484a6cb4 100644 --- a/spec/ruby/core/integer/shared/to_i.rb +++ b/spec/ruby/core/integer/shared/to_i.rb @@ -1,8 +1,8 @@ describe :integer_to_i, shared: true do it "returns self" do - 10.send(@method).should eql(10) - (-15).send(@method).should eql(-15) - bignum_value.send(@method).should eql(bignum_value) - (-bignum_value).send(@method).should eql(-bignum_value) + 10.send(@method).should.eql?(10) + (-15).send(@method).should.eql?(-15) + bignum_value.send(@method).should.eql?(bignum_value) + (-bignum_value).send(@method).should.eql?(-bignum_value) end end diff --git a/spec/ruby/core/integer/sqrt_spec.rb b/spec/ruby/core/integer/sqrt_spec.rb index 4149ca2cc9c37e..bf90ea747eded7 100644 --- a/spec/ruby/core/integer/sqrt_spec.rb +++ b/spec/ruby/core/integer/sqrt_spec.rb @@ -2,7 +2,7 @@ describe "Integer.sqrt" do it "returns an integer" do - Integer.sqrt(10).should be_kind_of(Integer) + Integer.sqrt(10).should.is_a?(Integer) end it "returns the integer square root of the argument" do @@ -14,7 +14,7 @@ end it "raises a Math::DomainError if the argument is negative" do - -> { Integer.sqrt(-4) }.should raise_error(Math::DomainError) + -> { Integer.sqrt(-4) }.should.raise(Math::DomainError) end it "accepts any argument that can be coerced to Integer" do @@ -26,6 +26,6 @@ end it "raises a TypeError if the argument cannot be coerced to Integer" do - -> { Integer.sqrt("test") }.should raise_error(TypeError) + -> { Integer.sqrt("test") }.should.raise(TypeError) end end diff --git a/spec/ruby/core/integer/to_f_spec.rb b/spec/ruby/core/integer/to_f_spec.rb index 9f1df9ada9303c..068123609514a4 100644 --- a/spec/ruby/core/integer/to_f_spec.rb +++ b/spec/ruby/core/integer/to_f_spec.rb @@ -11,9 +11,9 @@ context "bignum" do it "returns self converted to a Float" do - bignum_value(0x4000_0aa0_0bb0_0000).to_f.should eql(23_058_441_774_644_068_352.0) - bignum_value(0x8000_0000_0000_0ccc).to_f.should eql(27_670_116_110_564_330_700.0) - (-bignum_value(99)).to_f.should eql(-18_446_744_073_709_551_715.0) + bignum_value(0x4000_0aa0_0bb0_0000).to_f.should.eql?(23_058_441_774_644_068_352.0) + bignum_value(0x8000_0000_0000_0ccc).to_f.should.eql?(27_670_116_110_564_330_700.0) + (-bignum_value(99)).to_f.should.eql?(-18_446_744_073_709_551_715.0) end it "converts number close to Float::MAX without exceeding MAX or producing NaN" do diff --git a/spec/ruby/core/integer/to_r_spec.rb b/spec/ruby/core/integer/to_r_spec.rb index 7732bedca16436..2649c7c78d7491 100644 --- a/spec/ruby/core/integer/to_r_spec.rb +++ b/spec/ruby/core/integer/to_r_spec.rb @@ -2,7 +2,7 @@ describe "Integer#to_r" do it "returns a Rational object" do - 309.to_r.should be_an_instance_of(Rational) + 309.to_r.should.instance_of?(Rational) end it "constructs a rational number with self as the numerator" do @@ -15,12 +15,12 @@ it "works even if self is a Bignum" do bignum = 99999**999 - bignum.should be_an_instance_of(Integer) + bignum.should.instance_of?(Integer) bignum.to_r.should == Rational(bignum, 1) end it "raises an ArgumentError if given any arguments" do - -> { 287.to_r(2) }.should raise_error(ArgumentError) - -> { 9102826.to_r(309, [], 71) }.should raise_error(ArgumentError) + -> { 287.to_r(2) }.should.raise(ArgumentError) + -> { 9102826.to_r(309, [], 71) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/integer/to_s_spec.rb b/spec/ruby/core/integer/to_s_spec.rb index ca08dad95c7711..4970a2a12fb6d6 100644 --- a/spec/ruby/core/integer/to_s_spec.rb +++ b/spec/ruby/core/integer/to_s_spec.rb @@ -13,10 +13,10 @@ end it "raises an ArgumentError if the base is less than 2 or higher than 36" do - -> { 123.to_s(-1) }.should raise_error(ArgumentError) - -> { 123.to_s(0) }.should raise_error(ArgumentError) - -> { 123.to_s(1) }.should raise_error(ArgumentError) - -> { 123.to_s(37) }.should raise_error(ArgumentError) + -> { 123.to_s(-1) }.should.raise(ArgumentError) + -> { 123.to_s(0) }.should.raise(ArgumentError) + -> { 123.to_s(1) }.should.raise(ArgumentError) + -> { 123.to_s(37) }.should.raise(ArgumentError) end end @@ -39,12 +39,12 @@ it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do Encoding.default_internal = nil - 1.to_s.encoding.should equal(Encoding::US_ASCII) + 1.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 - 1.to_s.encoding.should equal(Encoding::US_ASCII) + 1.to_s.encoding.should.equal?(Encoding::US_ASCII) end end @@ -59,10 +59,10 @@ end it "raises an ArgumentError if the base is less than 2 or higher than 36" do - -> { 123.to_s(-1) }.should raise_error(ArgumentError) - -> { 123.to_s(0) }.should raise_error(ArgumentError) - -> { 123.to_s(1) }.should raise_error(ArgumentError) - -> { 123.to_s(37) }.should raise_error(ArgumentError) + -> { 123.to_s(-1) }.should.raise(ArgumentError) + -> { 123.to_s(0) }.should.raise(ArgumentError) + -> { 123.to_s(1) }.should.raise(ArgumentError) + -> { 123.to_s(37) }.should.raise(ArgumentError) end end @@ -84,12 +84,12 @@ it "returns a String in US-ASCII encoding when Encoding.default_internal is nil" do Encoding.default_internal = nil - bignum_value.to_s.encoding.should equal(Encoding::US_ASCII) + bignum_value.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 - bignum_value.to_s.encoding.should equal(Encoding::US_ASCII) + bignum_value.to_s.encoding.should.equal?(Encoding::US_ASCII) end end end diff --git a/spec/ruby/core/integer/truncate_spec.rb b/spec/ruby/core/integer/truncate_spec.rb index db16e74be4d43f..b95c183cf3d590 100644 --- a/spec/ruby/core/integer/truncate_spec.rb +++ b/spec/ruby/core/integer/truncate_spec.rb @@ -8,12 +8,12 @@ context "precision argument specified as part of the truncate method is negative" do it "returns an integer with at least precision.abs trailing zeros" do - 1832.truncate(-1).should eql(1830) - 1832.truncate(-2).should eql(1800) - 1832.truncate(-3).should eql(1000) - -1832.truncate(-1).should eql(-1830) - -1832.truncate(-2).should eql(-1800) - -1832.truncate(-3).should eql(-1000) + 1832.truncate(-1).should.eql?(1830) + 1832.truncate(-2).should.eql?(1800) + 1832.truncate(-3).should.eql?(1000) + -1832.truncate(-1).should.eql?(-1830) + -1832.truncate(-2).should.eql?(-1800) + -1832.truncate(-3).should.eql?(-1000) end end end diff --git a/spec/ruby/core/integer/try_convert_spec.rb b/spec/ruby/core/integer/try_convert_spec.rb index ba14a5aa7e2e70..8c9b4276b944bd 100644 --- a/spec/ruby/core/integer/try_convert_spec.rb +++ b/spec/ruby/core/integer/try_convert_spec.rb @@ -4,24 +4,24 @@ describe "Integer.try_convert" do it "returns the argument if it's an Integer" do x = 42 - Integer.try_convert(x).should equal(x) + Integer.try_convert(x).should.equal?(x) end it "returns nil when the argument does not respond to #to_int" do - Integer.try_convert(Object.new).should be_nil + Integer.try_convert(Object.new).should == nil end it "sends #to_int to the argument and returns the result if it's nil" do obj = mock("to_int") obj.should_receive(:to_int).and_return(nil) - Integer.try_convert(obj).should be_nil + Integer.try_convert(obj).should == nil end it "sends #to_int to the argument and returns the result if it's an Integer" do x = 234 obj = mock("to_int") obj.should_receive(:to_int).and_return(x) - Integer.try_convert(obj).should equal(x) + Integer.try_convert(obj).should.equal?(x) end it "sends #to_int to the argument and raises TypeError if it's not a kind of Integer" do @@ -43,6 +43,6 @@ it "does not rescue exceptions raised by #to_int" do obj = mock("to_int") obj.should_receive(:to_int).and_raise(RuntimeError) - -> { Integer.try_convert obj }.should raise_error(RuntimeError) + -> { Integer.try_convert obj }.should.raise(RuntimeError) end end diff --git a/spec/ruby/core/integer/upto_spec.rb b/spec/ruby/core/integer/upto_spec.rb index dd6995e94b44c7..ba63dcc9ea183a 100644 --- a/spec/ruby/core/integer/upto_spec.rb +++ b/spec/ruby/core/integer/upto_spec.rb @@ -27,8 +27,8 @@ end it "raises an ArgumentError for non-numeric endpoints" do - -> { 1.upto("A") {|x| p x} }.should raise_error(ArgumentError) - -> { 1.upto(nil) {|x| p x} }.should raise_error(ArgumentError) + -> { 1.upto("A") {|x| p x} }.should.raise(ArgumentError) + -> { 1.upto(nil) {|x| p x} }.should.raise(ArgumentError) end describe "when no block is given" do @@ -45,9 +45,9 @@ describe "size" do it "raises an ArgumentError for non-numeric endpoints" do enum = 1.upto("A") - -> { enum.size }.should raise_error(ArgumentError) + -> { enum.size }.should.raise(ArgumentError) enum = 1.upto(nil) - -> { enum.size }.should raise_error(ArgumentError) + -> { enum.size }.should.raise(ArgumentError) end it "returns stop - self + 1" do diff --git a/spec/ruby/core/io/advise_spec.rb b/spec/ruby/core/io/advise_spec.rb index 651fc5237805bf..b77ed53ad4d0dd 100644 --- a/spec/ruby/core/io/advise_spec.rb +++ b/spec/ruby/core/io/advise_spec.rb @@ -14,73 +14,73 @@ it "raises a TypeError if advise is not a Symbol" do -> { @io.advise("normal") - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a TypeError if offset cannot be coerced to an Integer" do -> { @io.advise(:normal, "wat") - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a TypeError if len cannot be coerced to an Integer" do -> { @io.advise(:normal, 0, "wat") - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a RangeError if offset is too big" do -> { @io.advise(:normal, 10 ** 32) - }.should raise_error(RangeError) + }.should.raise(RangeError) end it "raises a RangeError if len is too big" do -> { @io.advise(:normal, 0, 10 ** 32) - }.should raise_error(RangeError) + }.should.raise(RangeError) end it "raises a NotImplementedError if advise is not recognized" do ->{ @io.advise(:foo) - }.should raise_error(NotImplementedError) + }.should.raise(NotImplementedError) end it "supports the normal advice type" do - @io.advise(:normal).should be_nil + @io.advise(:normal).should == nil end it "supports the sequential advice type" do - @io.advise(:sequential).should be_nil + @io.advise(:sequential).should == nil end it "supports the random advice type" do - @io.advise(:random).should be_nil + @io.advise(:random).should == nil end it "supports the dontneed advice type" do - @io.advise(:dontneed).should be_nil + @io.advise(:dontneed).should == nil end it "supports the noreuse advice type" do - @io.advise(:noreuse).should be_nil + @io.advise(:noreuse).should == nil end platform_is_not :linux do it "supports the willneed advice type" do - @io.advise(:willneed).should be_nil + @io.advise(:willneed).should == nil end end guard -> { platform_is :linux and kernel_version_is '3.6' } do # [ruby-core:65355] tmpfs is not supported it "supports the willneed advice type" do - @io.advise(:willneed).should be_nil + @io.advise(:willneed).should == nil end end it "raises an IOError if the stream is closed" do @io.close - -> { @io.advise(:normal) }.should raise_error(IOError) + -> { @io.advise(:normal) }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/autoclose_spec.rb b/spec/ruby/core/io/autoclose_spec.rb index 715ada7c9348f9..596f3d6934ff3d 100644 --- a/spec/ruby/core/io/autoclose_spec.rb +++ b/spec/ruby/core/io/autoclose_spec.rb @@ -17,7 +17,7 @@ it "cannot be queried on a closed IO object" do @io.close - -> { @io.autoclose? }.should raise_error(IOError, /closed stream/) + -> { @io.autoclose? }.should.raise(IOError, /closed stream/) end end @@ -72,6 +72,6 @@ it "cannot be set on a closed IO object" do @io.close - -> { @io.autoclose = false }.should raise_error(IOError, /closed stream/) + -> { @io.autoclose = false }.should.raise(IOError, /closed stream/) end end diff --git a/spec/ruby/core/io/binmode_spec.rb b/spec/ruby/core/io/binmode_spec.rb index 342cac2a9b603d..8117229c91409c 100644 --- a/spec/ruby/core/io/binmode_spec.rb +++ b/spec/ruby/core/io/binmode_spec.rb @@ -13,11 +13,11 @@ it "returns self" do @io = new_io(@name) - @io.binmode.should equal(@io) + @io.binmode.should.equal?(@io) end it "raises an IOError on closed stream" do - -> { IOSpecs.closed_io.binmode }.should raise_error(IOError) + -> { IOSpecs.closed_io.binmode }.should.raise(IOError) end it "sets external encoding to binary" do @@ -47,9 +47,9 @@ end it "is true after a call to IO#binmode" do - @file.binmode?.should be_false + @file.binmode?.should == false @file.binmode - @file.binmode?.should be_true + @file.binmode?.should == true end it "propagates to dup'ed IO objects" do @@ -59,6 +59,6 @@ end it "raises an IOError on closed stream" do - -> { IOSpecs.closed_io.binmode? }.should raise_error(IOError) + -> { IOSpecs.closed_io.binmode? }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/binread_spec.rb b/spec/ruby/core/io/binread_spec.rb index e4576c1aa1e4f3..3023c7f177a7af 100644 --- a/spec/ruby/core/io/binread_spec.rb +++ b/spec/ruby/core/io/binread_spec.rb @@ -38,11 +38,11 @@ end it "raises an ArgumentError when not passed a valid length" do - -> { IO.binread @fname, -1 }.should raise_error(ArgumentError) + -> { IO.binread @fname, -1 }.should.raise(ArgumentError) end it "raises an Errno::EINVAL when not passed a valid offset" do - -> { IO.binread @fname, 0, -1 }.should raise_error(Errno::EINVAL) + -> { IO.binread @fname, 0, -1 }.should.raise(Errno::EINVAL) end ruby_version_is ""..."4.0" do diff --git a/spec/ruby/core/io/buffer/and_spec.rb b/spec/ruby/core/io/buffer/and_spec.rb index 1f3611cfa9d8da..3cea163b0ec00b 100644 --- a/spec/ruby/core/io/buffer/and_spec.rb +++ b/spec/ruby/core/io/buffer/and_spec.rb @@ -23,9 +23,9 @@ it "raises TypeError if mask is not an IO::Buffer" do IO::Buffer.for(+"12345") do |buffer| - -> { buffer.send(@method, "\xF8\x8F") }.should raise_error(TypeError, "wrong argument type String (expected IO::Buffer)") - -> { buffer.send(@method, 0xF8) }.should raise_error(TypeError, "wrong argument type Integer (expected IO::Buffer)") - -> { buffer.send(@method, nil) }.should raise_error(TypeError, "wrong argument type nil (expected IO::Buffer)") + -> { buffer.send(@method, "\xF8\x8F") }.should.raise(TypeError, "wrong argument type String (expected IO::Buffer)") + -> { buffer.send(@method, 0xF8) }.should.raise(TypeError, "wrong argument type Integer (expected IO::Buffer)") + -> { buffer.send(@method, nil) }.should.raise(TypeError, "wrong argument type nil (expected IO::Buffer)") end end end diff --git a/spec/ruby/core/io/buffer/bit_count_spec.rb b/spec/ruby/core/io/buffer/bit_count_spec.rb index dec897da44e21d..62f56f5b985b14 100644 --- a/spec/ruby/core/io/buffer/bit_count_spec.rb +++ b/spec/ruby/core/io/buffer/bit_count_spec.rb @@ -50,14 +50,14 @@ it "raises ArgumentError when offset + length exceeds buffer size" do IO::Buffer.for(+"\xFF") do |buffer| - -> { buffer.bit_count(0, 2) }.should raise_error(ArgumentError) - -> { buffer.bit_count(1, 1) }.should raise_error(ArgumentError) + -> { buffer.bit_count(0, 2) }.should.raise(ArgumentError) + -> { buffer.bit_count(1, 1) }.should.raise(ArgumentError) end end it "returns an Integer" do IO::Buffer.for(+"\xFF") do |buffer| - buffer.bit_count.should be_kind_of(Integer) + buffer.bit_count.should.is_a?(Integer) end end end diff --git a/spec/ruby/core/io/buffer/empty_spec.rb b/spec/ruby/core/io/buffer/empty_spec.rb index 788b23f88f0a48..4cceb4dc0db765 100644 --- a/spec/ruby/core/io/buffer/empty_spec.rb +++ b/spec/ruby/core/io/buffer/empty_spec.rb @@ -11,17 +11,17 @@ it "is true for a 0-length String-backed buffer created with .for" do @buffer = IO::Buffer.for("") - @buffer.empty?.should be_true + @buffer.empty?.should == true end it "is true for a 0-length String-backed buffer created with .string" do IO::Buffer.string(0) do |buffer| - buffer.empty?.should be_true + buffer.empty?.should == true end end it "is true for a 0-length slice of a buffer with size > 0" do @buffer = IO::Buffer.new(4) - @buffer.slice(3, 0).empty?.should be_true + @buffer.slice(3, 0).empty?.should == true end end diff --git a/spec/ruby/core/io/buffer/external_spec.rb b/spec/ruby/core/io/buffer/external_spec.rb index 10bb51053d422d..18b2ee0d06ae67 100644 --- a/spec/ruby/core/io/buffer/external_spec.rb +++ b/spec/ruby/core/io/buffer/external_spec.rb @@ -8,16 +8,16 @@ it "is true for a buffer with externally-managed memory" do @buffer = IO::Buffer.for("string") - @buffer.external?.should be_true + @buffer.external?.should == true end it "is false for a buffer with self-managed memory" do @buffer = IO::Buffer.new(12, IO::Buffer::MAPPED) - @buffer.external?.should be_false + @buffer.external?.should == false end it "is false for a null buffer" do @buffer = IO::Buffer.new(0) - @buffer.external?.should be_false + @buffer.external?.should == false end end diff --git a/spec/ruby/core/io/buffer/for_spec.rb b/spec/ruby/core/io/buffer/for_spec.rb index d59a2a033afb3b..7971ce0b719ef1 100644 --- a/spec/ruby/core/io/buffer/for_spec.rb +++ b/spec/ruby/core/io/buffer/for_spec.rb @@ -20,7 +20,7 @@ @string[0] = "d" @buffer.get_string(0, 1).should == "f".b - -> { @buffer.set_string("d") }.should raise_error(IO::Buffer::AccessError, "Buffer is not writable!") + -> { @buffer.set_string("d") }.should.raise(IO::Buffer::AccessError, "Buffer is not writable!") end it "creates an external, read-only buffer" do @@ -74,7 +74,7 @@ it "locks the original string to prevent modification" do IO::Buffer.for(@string) do |_buffer| - -> { @string[0] = "t" }.should raise_error(RuntimeError, "can't modify string; temporarily locked") + -> { @string[0] = "t" }.should.raise(RuntimeError, "can't modify string; temporarily locked") end @string[1] = "u" @string.should == "fur striñg" @@ -86,7 +86,7 @@ IO::Buffer.for(@string.freeze) do |buffer| buffer.should.readonly? - -> { buffer.set_string("ghost shell") }.should raise_error(IO::Buffer::AccessError, "Buffer is not writable!") + -> { buffer.set_string("ghost shell") }.should.raise(IO::Buffer::AccessError, "Buffer is not writable!") end end end diff --git a/spec/ruby/core/io/buffer/free_spec.rb b/spec/ruby/core/io/buffer/free_spec.rb index 9a141e11f6b728..20fb7b901f4f3d 100644 --- a/spec/ruby/core/io/buffer/free_spec.rb +++ b/spec/ruby/core/io/buffer/free_spec.rb @@ -5,13 +5,13 @@ it "frees internal memory and nullifies the buffer" do buffer = IO::Buffer.new(4) buffer.free - buffer.null?.should be_true + buffer.null?.should == true end it "frees mapped memory and nullifies the buffer" do buffer = IO::Buffer.new(4, IO::Buffer::MAPPED) buffer.free - buffer.null?.should be_true + buffer.null?.should == true end end @@ -20,7 +20,7 @@ File.open(__FILE__, "r") do |file| buffer = IO::Buffer.map(file, nil, 0, IO::Buffer::READONLY) buffer.free - buffer.null?.should be_true + buffer.null?.should == true end end end @@ -32,7 +32,7 @@ buffer = IO::Buffer.for(string) # Read-only buffer, can't modify the string. buffer.free - buffer.null?.should be_true + buffer.null?.should == true end end @@ -42,7 +42,7 @@ IO::Buffer.for(string) do |buffer| buffer.set_string("meat") buffer.free - buffer.null?.should be_true + buffer.null?.should == true end string.should == "meat" end @@ -55,7 +55,7 @@ IO::Buffer.string(4) do |buffer| buffer.set_string("meat") buffer.free - buffer.null?.should be_true + buffer.null?.should == true end string.should == "meat" end @@ -64,18 +64,18 @@ it "can be called repeatedly without an error" do buffer = IO::Buffer.new(4) buffer.free - buffer.null?.should be_true + buffer.null?.should == true buffer.free - buffer.null?.should be_true + buffer.null?.should == true end it "is disallowed while locked, raising IO::Buffer::LockedError" do buffer = IO::Buffer.new(4) buffer.locked do - -> { buffer.free }.should raise_error(IO::Buffer::LockedError, "Buffer is locked!") + -> { buffer.free }.should.raise(IO::Buffer::LockedError, "Buffer is locked!") end buffer.free - buffer.null?.should be_true + buffer.null?.should == true end context "with a slice of a buffer" do @@ -84,8 +84,8 @@ slice = buffer.slice(0, 2) slice.free - slice.null?.should be_true - buffer.null?.should be_false + slice.null?.should == true + buffer.null?.should == false buffer.free end @@ -95,8 +95,8 @@ slice = buffer.slice(0, 2) buffer.free - slice.null?.should be_false - slice.valid?.should be_false + slice.null?.should == false + slice.valid?.should == false end end end diff --git a/spec/ruby/core/io/buffer/initialize_spec.rb b/spec/ruby/core/io/buffer/initialize_spec.rb index 90b501f53d9a92..dba6fddc7994aa 100644 --- a/spec/ruby/core/io/buffer/initialize_spec.rb +++ b/spec/ruby/core/io/buffer/initialize_spec.rb @@ -56,12 +56,12 @@ end it "raises TypeError if size is not an Integer" do - -> { IO::Buffer.new(nil) }.should raise_error(TypeError, "not an Integer") - -> { IO::Buffer.new(10.0) }.should raise_error(TypeError, "not an Integer") + -> { IO::Buffer.new(nil) }.should.raise(TypeError, "not an Integer") + -> { IO::Buffer.new(10.0) }.should.raise(TypeError, "not an Integer") end it "raises ArgumentError if size is negative" do - -> { IO::Buffer.new(-1) }.should raise_error(ArgumentError, "Size can't be negative!") + -> { IO::Buffer.new(-1) }.should.raise(ArgumentError, "Size can't be negative!") end end @@ -104,16 +104,16 @@ end it "raises IO::Buffer::AllocationError if neither IO::Buffer::MAPPED nor IO::Buffer::INTERNAL is given" do - -> { IO::Buffer.new(10, IO::Buffer::READONLY) }.should raise_error(IO::Buffer::AllocationError, "Could not allocate buffer!") - -> { IO::Buffer.new(10, 0) }.should raise_error(IO::Buffer::AllocationError, "Could not allocate buffer!") + -> { IO::Buffer.new(10, IO::Buffer::READONLY) }.should.raise(IO::Buffer::AllocationError, "Could not allocate buffer!") + -> { IO::Buffer.new(10, 0) }.should.raise(IO::Buffer::AllocationError, "Could not allocate buffer!") end it "raises ArgumentError if flags is negative" do - -> { IO::Buffer.new(10, -1) }.should raise_error(ArgumentError, "Flags can't be negative!") + -> { IO::Buffer.new(10, -1) }.should.raise(ArgumentError, "Flags can't be negative!") end it "raises TypeError with non-Integer flags" do - -> { IO::Buffer.new(10, 0.0) }.should raise_error(TypeError, "not an Integer") + -> { IO::Buffer.new(10, 0.0) }.should.raise(TypeError, "not an Integer") end end end diff --git a/spec/ruby/core/io/buffer/internal_spec.rb b/spec/ruby/core/io/buffer/internal_spec.rb index 40dc633d5d7fd0..73e19eb85e6bec 100644 --- a/spec/ruby/core/io/buffer/internal_spec.rb +++ b/spec/ruby/core/io/buffer/internal_spec.rb @@ -8,16 +8,16 @@ it "is true for an internally-allocated buffer" do @buffer = IO::Buffer.new(12) - @buffer.internal?.should be_true + @buffer.internal?.should == true end it "is false for an externally-allocated buffer" do @buffer = IO::Buffer.new(12, IO::Buffer::MAPPED) - @buffer.internal?.should be_false + @buffer.internal?.should == false end it "is false for a null buffer" do @buffer = IO::Buffer.new(0) - @buffer.internal?.should be_false + @buffer.internal?.should == false end end diff --git a/spec/ruby/core/io/buffer/locked_spec.rb b/spec/ruby/core/io/buffer/locked_spec.rb index 4ffa569fd20c5a..249026aa8a9d6f 100644 --- a/spec/ruby/core/io/buffer/locked_spec.rb +++ b/spec/ruby/core/io/buffer/locked_spec.rb @@ -21,7 +21,7 @@ @buffer = IO::Buffer.new(4) @buffer.locked do # Just an example, each method is responsible for checking the lock state. - -> { @buffer.resize(8) }.should raise_error(IO::Buffer::LockedError) + -> { @buffer.resize(8) }.should.raise(IO::Buffer::LockedError) end end end @@ -29,7 +29,7 @@ it "disallows reentrant locking, raising IO::Buffer::LockedError" do @buffer = IO::Buffer.new(4) @buffer.locked do - -> { @buffer.locked {} }.should raise_error(IO::Buffer::LockedError, "Buffer already locked!") + -> { @buffer.locked {} }.should.raise(IO::Buffer::LockedError, "Buffer already locked!") end end @@ -37,9 +37,9 @@ @buffer = IO::Buffer.new(4) slice = @buffer.slice(0, 2) @buffer.locked do - @buffer.locked?.should be_true - slice.locked?.should be_false - slice.locked { slice.locked?.should be_true } + @buffer.locked?.should == true + slice.locked?.should == false + slice.locked { slice.locked?.should == true } end end @@ -47,9 +47,9 @@ @buffer = IO::Buffer.new(4) slice = @buffer.slice(0, 2) slice.locked do - slice.locked?.should be_true - @buffer.locked?.should be_false - @buffer.locked { @buffer.locked?.should be_true } + slice.locked?.should == true + @buffer.locked?.should == false + @buffer.locked { @buffer.locked?.should == true } end end end @@ -62,14 +62,14 @@ it "is false by default" do @buffer = IO::Buffer.new(4) - @buffer.locked?.should be_false + @buffer.locked?.should == false end it "is true only inside of #locked block" do @buffer = IO::Buffer.new(4) @buffer.locked do - @buffer.locked?.should be_true + @buffer.locked?.should == true end - @buffer.locked?.should be_false + @buffer.locked?.should == false end end diff --git a/spec/ruby/core/io/buffer/map_spec.rb b/spec/ruby/core/io/buffer/map_spec.rb index 4543c2d022a7ce..23e837ce078dd1 100644 --- a/spec/ruby/core/io/buffer/map_spec.rb +++ b/spec/ruby/core/io/buffer/map_spec.rb @@ -106,7 +106,7 @@ def open_big_file_fixture file_name = tmp("empty.txt") @file = File.open(file_name, "wb+") @tmp_files << file_name - -> { IO::Buffer.map(@file) }.should raise_error(ArgumentError, "Invalid negative or zero file size!") + -> { IO::Buffer.map(@file) }.should.raise(ArgumentError, "Invalid negative or zero file size!") end end end @@ -114,7 +114,7 @@ def open_big_file_fixture context "with a file opened only for reading" do it "raises a SystemCallError unless read-only" do @file = File.open(fixture(__dir__, "read_text.txt"), "rb") - -> { IO::Buffer.map(@file) }.should raise_error(SystemCallError) + -> { IO::Buffer.map(@file) }.should.raise(SystemCallError) end end @@ -138,20 +138,20 @@ def open_big_file_fixture ruby_version_is "4.0" do it "raises ArgumentError" do @file = open_fixture - -> { IO::Buffer.map(@file, 0) }.should raise_error(ArgumentError, "Size can't be zero!") + -> { IO::Buffer.map(@file, 0) }.should.raise(ArgumentError, "Size can't be zero!") end end end it "raises TypeError if size is not an Integer or nil" do @file = open_fixture - -> { IO::Buffer.map(@file, "10") }.should raise_error(TypeError, "not an Integer") - -> { IO::Buffer.map(@file, 10.0) }.should raise_error(TypeError, "not an Integer") + -> { IO::Buffer.map(@file, "10") }.should.raise(TypeError, "not an Integer") + -> { IO::Buffer.map(@file, 10.0) }.should.raise(TypeError, "not an Integer") end it "raises ArgumentError if size is negative" do @file = open_fixture - -> { IO::Buffer.map(@file, -1) }.should raise_error(ArgumentError, "Size can't be negative!") + -> { IO::Buffer.map(@file, -1) }.should.raise(ArgumentError, "Size can't be negative!") end ruby_version_is ""..."4.0" do @@ -162,7 +162,7 @@ def open_big_file_fixture ruby_version_is "4.0" do it "raises ArgumentError if size is larger than file size" do @file = open_fixture - -> { IO::Buffer.map(@file, 8192) }.should raise_error(ArgumentError, "Size can't be larger than file size!") + -> { IO::Buffer.map(@file, 8192) }.should.raise(ArgumentError, "Size can't be larger than file size!") end end end @@ -232,7 +232,7 @@ def open_big_file_fixture ruby_version_is "4.0" do it "raises ArgumentError if offset+size is larger than file size" do @file = open_big_file_fixture - -> { IO::Buffer.map(@file, 17, IO::Buffer::PAGE_SIZE) }.should raise_error(ArgumentError, "Offset too large!") + -> { IO::Buffer.map(@file, 17, IO::Buffer::PAGE_SIZE) }.should.raise(ArgumentError, "Offset too large!") ensure # Windows requires the file to be closed before deletion. @file.close unless @file.closed? @@ -241,14 +241,14 @@ def open_big_file_fixture it "raises TypeError if offset is not convertible to Integer" do @file = open_fixture - -> { IO::Buffer.map(@file, 4, "4096") }.should raise_error(TypeError, /no implicit conversion/) - -> { IO::Buffer.map(@file, 4, nil) }.should raise_error(TypeError, /no implicit conversion/) + -> { IO::Buffer.map(@file, 4, "4096") }.should.raise(TypeError, /no implicit conversion/) + -> { IO::Buffer.map(@file, 4, nil) }.should.raise(TypeError, /no implicit conversion/) end ruby_version_is "4.0" do it "raises ArgumentError if offset is negative" do @file = open_fixture - -> { IO::Buffer.map(@file, 4, -1) }.should raise_error(ArgumentError, "Offset can't be negative!") + -> { IO::Buffer.map(@file, 4, -1) }.should.raise(ArgumentError, "Offset can't be negative!") end end end @@ -277,7 +277,7 @@ def open_big_file_fixture @file = open_fixture @buffer = IO::Buffer.map(@file, nil, 0, IO::Buffer::READONLY) - -> { @buffer.set_string("test") }.should raise_error(IO::Buffer::AccessError, "Buffer is not writable!") + -> { @buffer.set_string("test") }.should.raise(IO::Buffer::AccessError, "Buffer is not writable!") end end diff --git a/spec/ruby/core/io/buffer/mapped_spec.rb b/spec/ruby/core/io/buffer/mapped_spec.rb index 13dc548ed26e72..0decb97704eb82 100644 --- a/spec/ruby/core/io/buffer/mapped_spec.rb +++ b/spec/ruby/core/io/buffer/mapped_spec.rb @@ -8,16 +8,16 @@ it "is true for a buffer with mapped memory" do @buffer = IO::Buffer.new(12, IO::Buffer::MAPPED) - @buffer.mapped?.should be_true + @buffer.mapped?.should == true end it "is false for a buffer with non-mapped memory" do @buffer = IO::Buffer.for("string") - @buffer.mapped?.should be_false + @buffer.mapped?.should == false end it "is false for a null buffer" do @buffer = IO::Buffer.new(0) - @buffer.mapped?.should be_false + @buffer.mapped?.should == false end end diff --git a/spec/ruby/core/io/buffer/null_spec.rb b/spec/ruby/core/io/buffer/null_spec.rb index 3a0e7f841bf94d..380a98bde1d41b 100644 --- a/spec/ruby/core/io/buffer/null_spec.rb +++ b/spec/ruby/core/io/buffer/null_spec.rb @@ -11,17 +11,17 @@ it "is false for a 0-length String-backed buffer created with .for" do @buffer = IO::Buffer.for("") - @buffer.null?.should be_false + @buffer.null?.should == false end it "is false for a 0-length String-backed buffer created with .string" do IO::Buffer.string(0) do |buffer| - buffer.null?.should be_false + buffer.null?.should == false end end it "is false for a 0-length slice of a buffer with size > 0" do @buffer = IO::Buffer.new(4) - @buffer.slice(3, 0).null?.should be_false + @buffer.slice(3, 0).null?.should == false end end diff --git a/spec/ruby/core/io/buffer/or_spec.rb b/spec/ruby/core/io/buffer/or_spec.rb index 1c9e52a4cac2d4..3e627c216c0f5d 100644 --- a/spec/ruby/core/io/buffer/or_spec.rb +++ b/spec/ruby/core/io/buffer/or_spec.rb @@ -23,9 +23,9 @@ it "raises TypeError if mask is not an IO::Buffer" do IO::Buffer.for(+"12345") do |buffer| - -> { buffer.send(@method, "\xF8\x8F") }.should raise_error(TypeError, "wrong argument type String (expected IO::Buffer)") - -> { buffer.send(@method, 0xF8) }.should raise_error(TypeError, "wrong argument type Integer (expected IO::Buffer)") - -> { buffer.send(@method, nil) }.should raise_error(TypeError, "wrong argument type nil (expected IO::Buffer)") + -> { buffer.send(@method, "\xF8\x8F") }.should.raise(TypeError, "wrong argument type String (expected IO::Buffer)") + -> { buffer.send(@method, 0xF8) }.should.raise(TypeError, "wrong argument type Integer (expected IO::Buffer)") + -> { buffer.send(@method, nil) }.should.raise(TypeError, "wrong argument type nil (expected IO::Buffer)") end end end diff --git a/spec/ruby/core/io/buffer/private_spec.rb b/spec/ruby/core/io/buffer/private_spec.rb index 86b7a7a0d0b391..6e6afee34ca10f 100644 --- a/spec/ruby/core/io/buffer/private_spec.rb +++ b/spec/ruby/core/io/buffer/private_spec.rb @@ -8,16 +8,16 @@ it "is true for a buffer created with PRIVATE flag" do @buffer = IO::Buffer.new(12, IO::Buffer::INTERNAL | IO::Buffer::PRIVATE) - @buffer.private?.should be_true + @buffer.private?.should == true end it "is false for a buffer created without PRIVATE flag" do @buffer = IO::Buffer.new(12, IO::Buffer::INTERNAL) - @buffer.private?.should be_false + @buffer.private?.should == false end it "is false for a null buffer" do @buffer = IO::Buffer.new(0) - @buffer.private?.should be_false + @buffer.private?.should == false end end diff --git a/spec/ruby/core/io/buffer/readonly_spec.rb b/spec/ruby/core/io/buffer/readonly_spec.rb index 2fc7d340b77b80..4eefc9f29fac4a 100644 --- a/spec/ruby/core/io/buffer/readonly_spec.rb +++ b/spec/ruby/core/io/buffer/readonly_spec.rb @@ -8,21 +8,21 @@ it "is true for a buffer created with READONLY flag" do @buffer = IO::Buffer.new(12, IO::Buffer::INTERNAL | IO::Buffer::READONLY) - @buffer.readonly?.should be_true + @buffer.readonly?.should == true end it "is true for a buffer that is non-writable" do @buffer = IO::Buffer.for("string") - @buffer.readonly?.should be_true + @buffer.readonly?.should == true end it "is false for a modifiable buffer" do @buffer = IO::Buffer.new(12) - @buffer.readonly?.should be_false + @buffer.readonly?.should == false end it "is false for a null buffer" do @buffer = IO::Buffer.new(0) - @buffer.readonly?.should be_false + @buffer.readonly?.should == false end end diff --git a/spec/ruby/core/io/buffer/resize_spec.rb b/spec/ruby/core/io/buffer/resize_spec.rb index a5e80439dac653..6e684475f34067 100644 --- a/spec/ruby/core/io/buffer/resize_spec.rb +++ b/spec/ruby/core/io/buffer/resize_spec.rb @@ -11,8 +11,8 @@ @buffer = IO::Buffer.new(4) @buffer.resize(IO::Buffer::PAGE_SIZE) @buffer.size.should == IO::Buffer::PAGE_SIZE - @buffer.internal?.should be_true - @buffer.mapped?.should be_false + @buffer.internal?.should == true + @buffer.mapped?.should == false end platform_is :linux do @@ -20,8 +20,8 @@ @buffer = IO::Buffer.new(IO::Buffer::PAGE_SIZE, IO::Buffer::MAPPED) @buffer.resize(4) @buffer.size.should == 4 - @buffer.internal?.should be_false - @buffer.mapped?.should be_true + @buffer.internal?.should == false + @buffer.mapped?.should == true end end @@ -30,8 +30,8 @@ @buffer = IO::Buffer.new(IO::Buffer::PAGE_SIZE, IO::Buffer::MAPPED) @buffer.resize(4) @buffer.size.should == 4 - @buffer.internal?.should be_true - @buffer.mapped?.should be_false + @buffer.internal?.should == true + @buffer.mapped?.should == false end end end @@ -40,7 +40,7 @@ it "disallows resizing shared buffer, raising IO::Buffer::AccessError" do File.open(__FILE__, "r+") do |file| @buffer = IO::Buffer.map(file) - -> { @buffer.resize(10) }.should raise_error(IO::Buffer::AccessError, "Cannot resize external buffer!") + -> { @buffer.resize(10) }.should.raise(IO::Buffer::AccessError, "Cannot resize external buffer!") end end @@ -61,14 +61,14 @@ context "without a block" do it "disallows resizing, raising IO::Buffer::AccessError" do @buffer = IO::Buffer.for(+"test") - -> { @buffer.resize(10) }.should raise_error(IO::Buffer::AccessError, "Cannot resize external buffer!") + -> { @buffer.resize(10) }.should.raise(IO::Buffer::AccessError, "Cannot resize external buffer!") end end context "with a block" do it "disallows resizing, raising IO::Buffer::AccessError" do IO::Buffer.for(+'test') do |buffer| - -> { buffer.resize(10) }.should raise_error(IO::Buffer::AccessError, "Cannot resize external buffer!") + -> { buffer.resize(10) }.should.raise(IO::Buffer::AccessError, "Cannot resize external buffer!") end end end @@ -77,7 +77,7 @@ context "with a String-backed buffer created with .string" do it "disallows resizing, raising IO::Buffer::AccessError" do IO::Buffer.string(4) do |buffer| - -> { buffer.resize(10) }.should raise_error(IO::Buffer::AccessError, "Cannot resize external buffer!") + -> { buffer.resize(10) }.should.raise(IO::Buffer::AccessError, "Cannot resize external buffer!") end end end @@ -87,8 +87,8 @@ @buffer = IO::Buffer.new(0) @buffer.resize(IO::Buffer::PAGE_SIZE) @buffer.size.should == IO::Buffer::PAGE_SIZE - @buffer.internal?.should be_false - @buffer.mapped?.should be_true + @buffer.internal?.should == false + @buffer.mapped?.should == true end it "allows resizing after a free, creating a regular buffer according to new size" do @@ -96,15 +96,15 @@ @buffer.free @buffer.resize(10) @buffer.size.should == 10 - @buffer.internal?.should be_true - @buffer.mapped?.should be_false + @buffer.internal?.should == true + @buffer.mapped?.should == false end end it "allows resizing to 0, freeing memory" do @buffer = IO::Buffer.new(4) @buffer.resize(0) - @buffer.null?.should be_true + @buffer.null?.should == true end it "can be called repeatedly" do @@ -128,19 +128,19 @@ it "is disallowed while locked, raising IO::Buffer::LockedError" do @buffer = IO::Buffer.new(4) @buffer.locked do - -> { @buffer.resize(10) }.should raise_error(IO::Buffer::LockedError, "Cannot resize locked buffer!") + -> { @buffer.resize(10) }.should.raise(IO::Buffer::LockedError, "Cannot resize locked buffer!") end end it "raises ArgumentError if size is negative" do @buffer = IO::Buffer.new(4) - -> { @buffer.resize(-1) }.should raise_error(ArgumentError, "Size can't be negative!") + -> { @buffer.resize(-1) }.should.raise(ArgumentError, "Size can't be negative!") end it "raises TypeError if size is not an Integer" do @buffer = IO::Buffer.new(4) - -> { @buffer.resize(nil) }.should raise_error(TypeError, "not an Integer") - -> { @buffer.resize(10.0) }.should raise_error(TypeError, "not an Integer") + -> { @buffer.resize(nil) }.should.raise(TypeError, "not an Integer") + -> { @buffer.resize(10.0) }.should.raise(TypeError, "not an Integer") end context "with a slice of a buffer" do diff --git a/spec/ruby/core/io/buffer/shared/null_and_empty.rb b/spec/ruby/core/io/buffer/shared/null_and_empty.rb index 2ff5cf8f410db7..f8abc5f0fcf5e9 100644 --- a/spec/ruby/core/io/buffer/shared/null_and_empty.rb +++ b/spec/ruby/core/io/buffer/shared/null_and_empty.rb @@ -1,57 +1,57 @@ describe :io_buffer_null_and_empty, shared: true do it "is false for a buffer with size > 0" do @buffer = IO::Buffer.new(1) - @buffer.send(@method).should be_false + @buffer.send(@method).should == false end it "is false for a slice with length > 0" do @buffer = IO::Buffer.new(4) - @buffer.slice(1, 2).send(@method).should be_false + @buffer.slice(1, 2).send(@method).should == false end it "is false for a file-mapped buffer" do File.open(__FILE__, "rb") do |file| @buffer = IO::Buffer.map(file, nil, 0, IO::Buffer::READONLY) - @buffer.send(@method).should be_false + @buffer.send(@method).should == false end end it "is false for a non-empty String-backed buffer created with .for" do @buffer = IO::Buffer.for("test") - @buffer.send(@method).should be_false + @buffer.send(@method).should == false end it "is false for a non-empty String-backed buffer created with .string" do IO::Buffer.string(4) do |buffer| - buffer.send(@method).should be_false + buffer.send(@method).should == false end end it "is true for a 0-sized buffer" do @buffer = IO::Buffer.new(0) - @buffer.send(@method).should be_true + @buffer.send(@method).should == true end it "is true for a slice of a 0-sized buffer" do @buffer = IO::Buffer.new(0) - @buffer.slice(0, 0).send(@method).should be_true + @buffer.slice(0, 0).send(@method).should == true end it "is true for a freed buffer" do @buffer = IO::Buffer.new(1) @buffer.free - @buffer.send(@method).should be_true + @buffer.send(@method).should == true end it "is true for a buffer resized to 0" do @buffer = IO::Buffer.new(1) @buffer.resize(0) - @buffer.send(@method).should be_true + @buffer.send(@method).should == true end it "is true for a buffer whose memory was transferred" do buffer = IO::Buffer.new(1) @buffer = buffer.transfer - buffer.send(@method).should be_true + buffer.send(@method).should == true end end diff --git a/spec/ruby/core/io/buffer/shared_spec.rb b/spec/ruby/core/io/buffer/shared_spec.rb index be8c29471af880..daaa66c5ad8b3d 100644 --- a/spec/ruby/core/io/buffer/shared_spec.rb +++ b/spec/ruby/core/io/buffer/shared_spec.rb @@ -8,7 +8,7 @@ it "is true for a buffer created with SHARED flag" do @buffer = IO::Buffer.new(12, IO::Buffer::INTERNAL | IO::Buffer::SHARED) - @buffer.shared?.should be_true + @buffer.shared?.should == true end it "is true for a non-private buffer created with .map" do @@ -16,7 +16,7 @@ File.copy_stream(fixture(__dir__, "read_text.txt"), path) file = File.open(path, "r+") @buffer = IO::Buffer.map(file) - @buffer.shared?.should be_true + @buffer.shared?.should == true ensure @buffer.free file.close @@ -25,11 +25,11 @@ it "is false for an unshared buffer" do @buffer = IO::Buffer.new(12) - @buffer.shared?.should be_false + @buffer.shared?.should == false end it "is false for a null buffer" do @buffer = IO::Buffer.new(0) - @buffer.shared?.should be_false + @buffer.shared?.should == false end end diff --git a/spec/ruby/core/io/buffer/string_spec.rb b/spec/ruby/core/io/buffer/string_spec.rb index bc7a73075e3948..4c73ba5e1e848f 100644 --- a/spec/ruby/core/io/buffer/string_spec.rb +++ b/spec/ruby/core/io/buffer/string_spec.rb @@ -49,14 +49,14 @@ end it "raises ArgumentError if size is negative" do - -> { IO::Buffer.string(-1) {} }.should raise_error(ArgumentError, "negative string size (or size too big)") + -> { IO::Buffer.string(-1) {} }.should.raise(ArgumentError, "negative string size (or size too big)") end it "raises RangeError if size is too large" do - -> { IO::Buffer.string(2 ** 232) {} }.should raise_error(RangeError, /\Abignum too big to convert into [`']long'\z/) + -> { IO::Buffer.string(2 ** 232) {} }.should.raise(RangeError, /\Abignum too big to convert into [`']long'\z/) end it "raises LocalJumpError if no block is given" do - -> { IO::Buffer.string(7) }.should raise_error(LocalJumpError, "no block given") + -> { IO::Buffer.string(7) }.should.raise(LocalJumpError, "no block given") end end diff --git a/spec/ruby/core/io/buffer/transfer_spec.rb b/spec/ruby/core/io/buffer/transfer_spec.rb index 5b7b63e3339991..02e029016ada3b 100644 --- a/spec/ruby/core/io/buffer/transfer_spec.rb +++ b/spec/ruby/core/io/buffer/transfer_spec.rb @@ -12,7 +12,7 @@ info = buffer.to_s @buffer = buffer.transfer @buffer.to_s.should == info - buffer.null?.should be_true + buffer.null?.should == true end it "transfers mapped memory to a new buffer, nullifying the original" do @@ -20,7 +20,7 @@ info = buffer.to_s @buffer = buffer.transfer @buffer.to_s.should == info - buffer.null?.should be_true + buffer.null?.should == true end end @@ -31,7 +31,7 @@ info = buffer.to_s @buffer = buffer.transfer @buffer.to_s.should == info - buffer.null?.should be_true + buffer.null?.should == true end end end @@ -43,7 +43,7 @@ info = buffer.to_s @buffer = buffer.transfer @buffer.to_s.should == info - buffer.null?.should be_true + buffer.null?.should == true end end @@ -53,9 +53,9 @@ info = buffer.to_s @buffer = buffer.transfer @buffer.to_s.should == info - buffer.null?.should be_true + buffer.null?.should == true end - @buffer.null?.should be_false + @buffer.null?.should == false end end end @@ -66,9 +66,9 @@ info = buffer.to_s @buffer = buffer.transfer @buffer.to_s.should == info - buffer.null?.should be_true + buffer.null?.should == true end - @buffer.null?.should be_false + @buffer.null?.should == false end end @@ -76,15 +76,15 @@ buffer_1 = IO::Buffer.new(4) buffer_2 = buffer_1.transfer @buffer = buffer_2.transfer - buffer_1.null?.should be_true - buffer_2.null?.should be_true - @buffer.null?.should be_false + buffer_1.null?.should == true + buffer_2.null?.should == true + @buffer.null?.should == false end it "is disallowed while locked, raising IO::Buffer::LockedError" do @buffer = IO::Buffer.new(4) @buffer.locked do - -> { @buffer.transfer }.should raise_error(IO::Buffer::LockedError, "Cannot transfer ownership of locked buffer!") + -> { @buffer.transfer }.should.raise(IO::Buffer::LockedError, "Cannot transfer ownership of locked buffer!") end end @@ -95,9 +95,9 @@ @buffer.set_string("test") new_slice = slice.transfer - slice.null?.should be_true - new_slice.null?.should be_false - @buffer.null?.should be_false + slice.null?.should == true + new_slice.null?.should == false + @buffer.null?.should == false new_slice.set_string("ea") @buffer.get_string.should == "east" @@ -108,9 +108,9 @@ slice = buffer.slice(0, 2) @buffer = buffer.transfer - slice.null?.should be_false - slice.valid?.should be_false - -> { slice.get_string }.should raise_error(IO::Buffer::InvalidatedError, "Buffer has been invalidated!") + slice.null?.should == false + slice.valid?.should == false + -> { slice.get_string }.should.raise(IO::Buffer::InvalidatedError, "Buffer has been invalidated!") end end end diff --git a/spec/ruby/core/io/buffer/valid_spec.rb b/spec/ruby/core/io/buffer/valid_spec.rb index 680a35ae9ad716..0a401728696861 100644 --- a/spec/ruby/core/io/buffer/valid_spec.rb +++ b/spec/ruby/core/io/buffer/valid_spec.rb @@ -10,34 +10,34 @@ context "with a non-slice buffer" do it "is true for a regular buffer" do @buffer = IO::Buffer.new(4) - @buffer.valid?.should be_true + @buffer.valid?.should == true end it "is true for a 0-size buffer" do @buffer = IO::Buffer.new(0) - @buffer.valid?.should be_true + @buffer.valid?.should == true end it "is true for a freed buffer" do @buffer = IO::Buffer.new(4) @buffer.free - @buffer.valid?.should be_true + @buffer.valid?.should == true end it "is true for a freed file-backed buffer" do File.open(__FILE__, "r") do |file| @buffer = IO::Buffer.map(file, nil, 0, IO::Buffer::READONLY) - @buffer.valid?.should be_true + @buffer.valid?.should == true @buffer.free - @buffer.valid?.should be_true + @buffer.valid?.should == true end end it "is true for a freed string-backed buffer" do @buffer = IO::Buffer.for("hello") - @buffer.valid?.should be_true + @buffer.valid?.should == true @buffer.free - @buffer.valid?.should be_true + @buffer.valid?.should == true end end @@ -47,7 +47,7 @@ it "is true for a slice of a live buffer" do @buffer = IO::Buffer.new(4) slice = @buffer.slice(0, 2) - slice.valid?.should be_true + slice.valid?.should == true end context "when buffer is resized" do @@ -55,7 +55,7 @@ @buffer = IO::Buffer.new(4) slice = @buffer.slice(2, 2) @buffer.resize(3) - slice.valid?.should be_false + slice.valid?.should == false end platform_is_not :linux do @@ -65,7 +65,7 @@ @buffer = IO::Buffer.new(4, IO::Buffer::MAPPED) slice = @buffer.slice(0, 2) @buffer.resize(8) - slice.valid?.should be_false + slice.valid?.should == false end end end @@ -74,32 +74,32 @@ buffer = IO::Buffer.new(4) slice = buffer.slice(0, 2) @buffer = buffer.transfer - slice.valid?.should be_false + slice.valid?.should == false end it "is false for a slice of a freed buffer" do @buffer = IO::Buffer.new(4) slice = @buffer.slice(0, 2) @buffer.free - slice.valid?.should be_false + slice.valid?.should == false end it "is false for a slice of a freed file-backed buffer" do File.open(__FILE__, "r") do |file| @buffer = IO::Buffer.map(file, nil, 0, IO::Buffer::READONLY) slice = @buffer.slice(0, 2) - slice.valid?.should be_true + slice.valid?.should == true @buffer.free - slice.valid?.should be_false + slice.valid?.should == false end end it "is true for a slice of a freed string-backed buffer while string is alive" do @buffer = IO::Buffer.for("alive") slice = @buffer.slice(0, 2) - slice.valid?.should be_true + slice.valid?.should == true @buffer.free - slice.valid?.should be_true + slice.valid?.should == true end # There probably should be a test with a garbage-collected string, diff --git a/spec/ruby/core/io/buffer/xor_spec.rb b/spec/ruby/core/io/buffer/xor_spec.rb index 637f7519d54a00..9287611f7fcb6a 100644 --- a/spec/ruby/core/io/buffer/xor_spec.rb +++ b/spec/ruby/core/io/buffer/xor_spec.rb @@ -23,9 +23,9 @@ it "raises TypeError if mask is not an IO::Buffer" do IO::Buffer.for(+"12345") do |buffer| - -> { buffer.send(@method, "\xF8\x8F") }.should raise_error(TypeError, "wrong argument type String (expected IO::Buffer)") - -> { buffer.send(@method, 0xF8) }.should raise_error(TypeError, "wrong argument type Integer (expected IO::Buffer)") - -> { buffer.send(@method, nil) }.should raise_error(TypeError, "wrong argument type nil (expected IO::Buffer)") + -> { buffer.send(@method, "\xF8\x8F") }.should.raise(TypeError, "wrong argument type String (expected IO::Buffer)") + -> { buffer.send(@method, 0xF8) }.should.raise(TypeError, "wrong argument type Integer (expected IO::Buffer)") + -> { buffer.send(@method, nil) }.should.raise(TypeError, "wrong argument type nil (expected IO::Buffer)") end end end diff --git a/spec/ruby/core/io/close_on_exec_spec.rb b/spec/ruby/core/io/close_on_exec_spec.rb index 4e89e08d61cda7..28cdb967b92acd 100644 --- a/spec/ruby/core/io/close_on_exec_spec.rb +++ b/spec/ruby/core/io/close_on_exec_spec.rb @@ -42,7 +42,7 @@ it "raises IOError if called on a closed IO" do @io.close - -> { @io.close_on_exec = true }.should raise_error(IOError) + -> { @io.close_on_exec = true }.should.raise(IOError) end end end @@ -70,7 +70,7 @@ it "raises IOError if called on a closed IO" do @io.close - -> { @io.close_on_exec? }.should raise_error(IOError) + -> { @io.close_on_exec? }.should.raise(IOError) end end end diff --git a/spec/ruby/core/io/close_read_spec.rb b/spec/ruby/core/io/close_read_spec.rb index e700e85bd99919..c505289d72d4b9 100644 --- a/spec/ruby/core/io/close_read_spec.rb +++ b/spec/ruby/core/io/close_read_spec.rb @@ -17,26 +17,26 @@ it "closes the read end of a duplex I/O stream" do @io.close_read - -> { @io.read }.should raise_error(IOError) + -> { @io.read }.should.raise(IOError) end it "does nothing on subsequent invocations" do @io.close_read - @io.close_read.should be_nil + @io.close_read.should == nil end it "allows subsequent invocation of close" do @io.close_read - -> { @io.close }.should_not raise_error + -> { @io.close }.should_not.raise end it "raises an IOError if the stream is writable and not duplexed" do io = File.open @path, 'w' begin - -> { io.close_read }.should raise_error(IOError) + -> { io.close_read }.should.raise(IOError) ensure io.close unless io.closed? end @@ -56,6 +56,6 @@ it "does nothing on closed stream" do @io.close - @io.close_read.should be_nil + @io.close_read.should == nil end end diff --git a/spec/ruby/core/io/close_spec.rb b/spec/ruby/core/io/close_spec.rb index 3a44cc8b17fd26..afd84ba101bd72 100644 --- a/spec/ruby/core/io/close_spec.rb +++ b/spec/ruby/core/io/close_spec.rb @@ -23,25 +23,25 @@ it "raises an IOError reading from a closed IO" do @io.close - -> { @io.read }.should raise_error(IOError) + -> { @io.read }.should.raise(IOError) end it "raises an IOError writing to a closed IO" do @io.close - -> { @io.write "data" }.should raise_error(IOError) + -> { @io.write "data" }.should.raise(IOError) end it 'does not close the stream if autoclose is false' do other_io = IO.new(@io.fileno) other_io.autoclose = false other_io.close - -> { @io.write "data" }.should_not raise_error(IOError) + -> { @io.write "data" }.should_not.raise(IOError) end it "does nothing if already closed" do @io.close - @io.close.should be_nil + @io.close.should == nil end it "does not call the #flush method but flushes the stream internally" do @@ -80,7 +80,7 @@ matching_exception&.tap {|ex| raise ex} end - end.should raise_error(IOError, IOSpecs::THREAD_CLOSE_ERROR_MESSAGE) + end.should.raise(IOError, IOSpecs::THREAD_CLOSE_ERROR_MESSAGE) end end @@ -93,7 +93,7 @@ io.close - -> { io.pid }.should raise_error(IOError) + -> { io.pid }.should.raise(IOError) end it "sets $?" do diff --git a/spec/ruby/core/io/close_write_spec.rb b/spec/ruby/core/io/close_write_spec.rb index 70610a3e9d6dc9..60b41505c3f926 100644 --- a/spec/ruby/core/io/close_write_spec.rb +++ b/spec/ruby/core/io/close_write_spec.rb @@ -16,26 +16,26 @@ it "closes the write end of a duplex I/O stream" do @io.close_write - -> { @io.write "attempt to write" }.should raise_error(IOError) + -> { @io.write "attempt to write" }.should.raise(IOError) end it "does nothing on subsequent invocations" do @io.close_write - @io.close_write.should be_nil + @io.close_write.should == nil end it "allows subsequent invocation of close" do @io.close_write - -> { @io.close }.should_not raise_error + -> { @io.close }.should_not.raise end it "raises an IOError if the stream is readable and not duplexed" do io = File.open @path, 'w+' begin - -> { io.close_write }.should raise_error(IOError) + -> { io.close_write }.should.raise(IOError) ensure io.close unless io.closed? end @@ -63,6 +63,6 @@ it "does nothing on closed stream" do @io.close - @io.close_write.should be_nil + @io.close_write.should == nil end end diff --git a/spec/ruby/core/io/closed_spec.rb b/spec/ruby/core/io/closed_spec.rb index 7316546a0dda2c..1f10858e288cab 100644 --- a/spec/ruby/core/io/closed_spec.rb +++ b/spec/ruby/core/io/closed_spec.rb @@ -11,10 +11,10 @@ end it "returns true on closed stream" do - IOSpecs.closed_io.closed?.should be_true + IOSpecs.closed_io.closed?.should == true end it "returns false on open stream" do - @io.closed?.should be_false + @io.closed?.should == false end end diff --git a/spec/ruby/core/io/copy_stream_spec.rb b/spec/ruby/core/io/copy_stream_spec.rb index ffa2ea992ce488..31383f9b0f154f 100644 --- a/spec/ruby/core/io/copy_stream_spec.rb +++ b/spec/ruby/core/io/copy_stream_spec.rb @@ -31,7 +31,7 @@ obj = mock("io_copy_stream_to") obj.should_receive(:to_path).and_return(1) - -> { IO.copy_stream(@object.from, obj) }.should raise_error(TypeError) + -> { IO.copy_stream(@object.from, obj) }.should.raise(TypeError) end end @@ -71,7 +71,7 @@ it "raises an IOError if the destination IO is not open for writing" do to_io = new_io __FILE__, "r" begin - -> { IO.copy_stream @object.from, to_io }.should raise_error(IOError) + -> { IO.copy_stream @object.from, to_io }.should.raise(IOError) ensure to_io.close end @@ -79,7 +79,7 @@ it "does not close the destination IO" do IO.copy_stream(@object.from, @to_io) - @to_io.closed?.should be_false + @to_io.closed?.should == false end it "copies only length bytes when specified" do @@ -129,12 +129,12 @@ it "raises an IOError if the source IO is not open for reading" do @from_io.close @from_io = new_io @from_bigfile, "a" - -> { IO.copy_stream @from_io, @to_name }.should raise_error(IOError) + -> { IO.copy_stream @from_io, @to_name }.should.raise(IOError) end it "does not close the source IO" do IO.copy_stream(@from_io, @to_name) - @from_io.closed?.should be_false + @from_io.closed?.should == false end platform_is_not :windows do @@ -206,7 +206,7 @@ obj = mock("io_copy_stream_from") obj.should_receive(:to_path).and_return(1) - -> { IO.copy_stream(obj, @to_name) }.should raise_error(TypeError) + -> { IO.copy_stream(obj, @to_name) }.should.raise(TypeError) end describe "to a file name" do @@ -240,12 +240,12 @@ it "does not close the source IO" do IO.copy_stream(@from_io, @to_name) - @from_io.closed?.should be_false + @from_io.closed?.should == false end platform_is_not :windows do it "raises an error when an offset is specified" do - -> { IO.copy_stream(@from_io, @to_name, 8, 4) }.should raise_error(Errno::ESPIPE) + -> { IO.copy_stream(@from_io, @to_name, 8, 4) }.should.raise(Errno::ESPIPE) end end @@ -300,6 +300,14 @@ @io.should_not_receive(:pos) IO.copy_stream(@io, @to_name) end + + it "does not call #read on the source or #write on the destination if zero length is given" do + from = mock("io_copy_stream_to_object_zero_length_read") + to = mock("io_copy_stream_to_object_zero_length_write") + from.should_not_receive(:read) + to.should_not_receive(:write) + IO.copy_stream(from, to, 0) + end end describe "with a destination that does partial reads" do diff --git a/spec/ruby/core/io/dup_spec.rb b/spec/ruby/core/io/dup_spec.rb index 564e00743871b9..db4e9fe641339f 100644 --- a/spec/ruby/core/io/dup_spec.rb +++ b/spec/ruby/core/io/dup_spec.rb @@ -49,7 +49,7 @@ it "allows closing the new IO without affecting the original" do @i.close - -> { @f.gets }.should_not raise_error(Exception) + -> { @f.gets }.should_not.raise(Exception) @i.should.closed? @f.should_not.closed? @@ -57,14 +57,14 @@ it "allows closing the original IO without affecting the new one" do @f.close - -> { @i.gets }.should_not raise_error(Exception) + -> { @i.gets }.should_not.raise(Exception) @i.should_not.closed? @f.should.closed? end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.dup }.should raise_error(IOError) + -> { IOSpecs.closed_io.dup }.should.raise(IOError) end it "always sets the close-on-exec flag for the new IO object" do diff --git a/spec/ruby/core/io/each_byte_spec.rb b/spec/ruby/core/io/each_byte_spec.rb index ea618e8c0cdae8..fe299f0fba6b52 100644 --- a/spec/ruby/core/io/each_byte_spec.rb +++ b/spec/ruby/core/io/each_byte_spec.rb @@ -12,7 +12,7 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.each_byte {} }.should raise_error(IOError) + -> { IOSpecs.closed_io.each_byte {} }.should.raise(IOError) end it "yields each byte" do @@ -28,7 +28,7 @@ describe "when no block is given" do it "returns an Enumerator" do enum = @io.each_byte - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.first(5).should == [86, 111, 105, 99, 105] end @@ -52,6 +52,6 @@ end it "returns self on an empty stream" do - @io.each_byte { |b| }.should equal(@io) + @io.each_byte { |b| }.should.equal?(@io) end end diff --git a/spec/ruby/core/io/each_codepoint_spec.rb b/spec/ruby/core/io/each_codepoint_spec.rb index 07a4037c8a7086..26cc87fc0e49a9 100644 --- a/spec/ruby/core/io/each_codepoint_spec.rb +++ b/spec/ruby/core/io/each_codepoint_spec.rb @@ -24,7 +24,7 @@ end it "returns self" do - @io.each_codepoint { |l| l }.should equal(@io) + @io.each_codepoint { |l| l }.should.equal?(@io) end end @@ -38,6 +38,6 @@ end it "raises an exception at incomplete character before EOF when conversion takes place" do - -> { @io.each_codepoint {} }.should raise_error(ArgumentError) + -> { @io.each_codepoint {} }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/io/eof_spec.rb b/spec/ruby/core/io/eof_spec.rb index b4850df437e351..c8955abde0ebd4 100644 --- a/spec/ruby/core/io/eof_spec.rb +++ b/spec/ruby/core/io/eof_spec.rb @@ -18,7 +18,7 @@ it "raises IOError on stream not opened for reading" do -> do File.open(@name, "w") { |f| f.eof? } - end.should raise_error(IOError) + end.should.raise(IOError) end end @@ -67,12 +67,12 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.eof? }.should raise_error(IOError) + -> { IOSpecs.closed_io.eof? }.should.raise(IOError) end it "raises IOError on stream closed for reading by close_read" do @io.close_read - -> { @io.eof? }.should raise_error(IOError) + -> { @io.eof? }.should.raise(IOError) end it "returns true on one-byte stream after single-byte read" do diff --git a/spec/ruby/core/io/external_encoding_spec.rb b/spec/ruby/core/io/external_encoding_spec.rb index 7765c6c0f51042..72d246cc2bdb9c 100644 --- a/spec/ruby/core/io/external_encoding_spec.rb +++ b/spec/ruby/core/io/external_encoding_spec.rb @@ -10,19 +10,19 @@ it "returns nil" do @io = new_io @name, @object Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should be_nil + @io.external_encoding.should == nil end it "returns the external encoding specified when the instance was created" do @io = new_io @name, "#{@object}:ibm866" Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should equal(Encoding::IBM866) + @io.external_encoding.should.equal?(Encoding::IBM866) end it "returns the encoding set by #set_encoding" do @io = new_io @name, "#{@object}:ibm866" @io.set_encoding Encoding::EUC_JP, nil - @io.external_encoding.should equal(Encoding::EUC_JP) + @io.external_encoding.should.equal?(Encoding::EUC_JP) end end @@ -35,19 +35,19 @@ it "returns the value of Encoding.default_external when the instance was created" do @io = new_io @name, @object Encoding.default_external = Encoding::UTF_8 - @io.external_encoding.should equal(Encoding::IBM437) + @io.external_encoding.should.equal?(Encoding::IBM437) end it "returns the external encoding specified when the instance was created" do @io = new_io @name, "#{@object}:ibm866" Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should equal(Encoding::IBM866) + @io.external_encoding.should.equal?(Encoding::IBM866) end it "returns the encoding set by #set_encoding" do @io = new_io @name, "#{@object}:ibm866" @io.set_encoding Encoding::EUC_JP, nil - @io.external_encoding.should equal(Encoding::EUC_JP) + @io.external_encoding.should.equal?(Encoding::EUC_JP) end end @@ -60,19 +60,19 @@ it "returns the value of Encoding.default_external when the instance was created" do @io = new_io @name, @object Encoding.default_external = Encoding::UTF_8 - @io.external_encoding.should equal(Encoding::IBM866) + @io.external_encoding.should.equal?(Encoding::IBM866) end it "returns the external encoding specified when the instance was created" do @io = new_io @name, "#{@object}:ibm866" Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should equal(Encoding::IBM866) + @io.external_encoding.should.equal?(Encoding::IBM866) end it "returns the encoding set by #set_encoding" do @io = new_io @name, "#{@object}:ibm866" @io.set_encoding Encoding::EUC_JP, nil - @io.external_encoding.should equal(Encoding::EUC_JP) + @io.external_encoding.should.equal?(Encoding::EUC_JP) end end end @@ -97,7 +97,7 @@ it "can be retrieved from a closed stream" do io = IOSpecs.io_fixture("lines.txt", "r") io.close - io.external_encoding.should equal(Encoding.default_external) + io.external_encoding.should.equal?(Encoding.default_external) end describe "with 'r' mode" do @@ -109,25 +109,25 @@ it "returns Encoding.default_external if the external encoding is not set" do @io = new_io @name, "r" - @io.external_encoding.should equal(Encoding::IBM866) + @io.external_encoding.should.equal?(Encoding::IBM866) end it "returns Encoding.default_external when that encoding is changed after the instance is created" do @io = new_io @name, "r" Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should equal(Encoding::IBM437) + @io.external_encoding.should.equal?(Encoding::IBM437) end it "returns the external encoding specified when the instance was created" do @io = new_io @name, "r:utf-8" Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should equal(Encoding::UTF_8) + @io.external_encoding.should.equal?(Encoding::UTF_8) end it "returns the encoding set by #set_encoding" do @io = new_io @name, "r:utf-8" @io.set_encoding Encoding::EUC_JP, nil - @io.external_encoding.should equal(Encoding::EUC_JP) + @io.external_encoding.should.equal?(Encoding::EUC_JP) end end @@ -140,19 +140,19 @@ it "returns the value of Encoding.default_external when the instance was created" do @io = new_io @name, "r" Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should equal(Encoding::IBM866) + @io.external_encoding.should.equal?(Encoding::IBM866) end it "returns the external encoding specified when the instance was created" do @io = new_io @name, "r:utf-8" Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should equal(Encoding::UTF_8) + @io.external_encoding.should.equal?(Encoding::UTF_8) end it "returns the encoding set by #set_encoding" do @io = new_io @name, "r:utf-8" @io.set_encoding Encoding::EUC_JP, nil - @io.external_encoding.should equal(Encoding::EUC_JP) + @io.external_encoding.should.equal?(Encoding::EUC_JP) end end @@ -166,13 +166,13 @@ it "returns the external encoding specified when the instance was created" do @io = new_io @name, "r:utf-8" Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should equal(Encoding::UTF_8) + @io.external_encoding.should.equal?(Encoding::UTF_8) end it "returns the encoding set by #set_encoding" do @io = new_io @name, "r:utf-8" @io.set_encoding Encoding::EUC_JP, nil - @io.external_encoding.should equal(Encoding::EUC_JP) + @io.external_encoding.should.equal?(Encoding::EUC_JP) end end end @@ -180,12 +180,12 @@ describe "with 'rb' mode" do it "returns Encoding::BINARY" do @io = new_io @name, "rb" - @io.external_encoding.should equal(Encoding::BINARY) + @io.external_encoding.should.equal?(Encoding::BINARY) end it "returns the external encoding specified by the mode argument" do @io = new_io @name, "rb:ibm437" - @io.external_encoding.should equal(Encoding::IBM437) + @io.external_encoding.should.equal?(Encoding::IBM437) end end @@ -200,12 +200,12 @@ describe "with 'wb' mode" do it "returns Encoding::BINARY" do @io = new_io @name, "wb" - @io.external_encoding.should equal(Encoding::BINARY) + @io.external_encoding.should.equal?(Encoding::BINARY) end it "returns the external encoding specified by the mode argument" do @io = new_io @name, "wb:ibm437" - @io.external_encoding.should equal(Encoding::IBM437) + @io.external_encoding.should.equal?(Encoding::IBM437) end end diff --git a/spec/ruby/core/io/fcntl_spec.rb b/spec/ruby/core/io/fcntl_spec.rb index 30b4876fe3e866..be6d06c67211bc 100644 --- a/spec/ruby/core/io/fcntl_spec.rb +++ b/spec/ruby/core/io/fcntl_spec.rb @@ -3,6 +3,6 @@ describe "IO#fcntl" do it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.fcntl(5, 5) }.should raise_error(IOError) + -> { IOSpecs.closed_io.fcntl(5, 5) }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/fileno_spec.rb b/spec/ruby/core/io/fileno_spec.rb index 647609bf42eccf..22fd68d166f562 100644 --- a/spec/ruby/core/io/fileno_spec.rb +++ b/spec/ruby/core/io/fileno_spec.rb @@ -7,6 +7,6 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.fileno }.should raise_error(IOError) + -> { IOSpecs.closed_io.fileno }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/flush_spec.rb b/spec/ruby/core/io/flush_spec.rb index f7d5ba77fce83c..4c3e8d12af78c1 100644 --- a/spec/ruby/core/io/flush_spec.rb +++ b/spec/ruby/core/io/flush_spec.rb @@ -3,7 +3,7 @@ describe "IO#flush" do it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.flush }.should raise_error(IOError) + -> { IOSpecs.closed_io.flush }.should.raise(IOError) end describe "on a pipe" do @@ -29,8 +29,8 @@ @w.write "foo" @r.close - -> { @w.flush }.should raise_error(Errno::EPIPE, /Broken pipe/) - -> { @w.close }.should raise_error(Errno::EPIPE, /Broken pipe/) + -> { @w.flush }.should.raise(Errno::EPIPE, /Broken pipe/) + -> { @w.close }.should.raise(Errno::EPIPE, /Broken pipe/) end end end diff --git a/spec/ruby/core/io/foreach_spec.rb b/spec/ruby/core/io/foreach_spec.rb index 28d6fef7ae5079..015988f9fb1d19 100644 --- a/spec/ruby/core/io/foreach_spec.rb +++ b/spec/ruby/core/io/foreach_spec.rb @@ -73,12 +73,12 @@ it "sets $_ to nil" do $_ = "test" IO.foreach(@name) { } - $_.should be_nil + $_.should == nil end describe "when no block is given" do it "returns an Enumerator" do - IO.foreach(@name).should be_an_instance_of(Enumerator) + IO.foreach(@name).should.instance_of?(Enumerator) IO.foreach(@name).to_a.should == IOSpecs.lines end diff --git a/spec/ruby/core/io/fsync_spec.rb b/spec/ruby/core/io/fsync_spec.rb index 6e6123de94d37b..0317cbc8055578 100644 --- a/spec/ruby/core/io/fsync_spec.rb +++ b/spec/ruby/core/io/fsync_spec.rb @@ -12,7 +12,7 @@ end it "raises an IOError on closed stream" do - -> { IOSpecs.closed_io.fsync }.should raise_error(IOError) + -> { IOSpecs.closed_io.fsync }.should.raise(IOError) end it "writes the buffered data to permanent storage" do diff --git a/spec/ruby/core/io/getbyte_spec.rb b/spec/ruby/core/io/getbyte_spec.rb index b4351160e6b2f8..668d81519c4724 100644 --- a/spec/ruby/core/io/getbyte_spec.rb +++ b/spec/ruby/core/io/getbyte_spec.rb @@ -23,7 +23,7 @@ end it "raises an IOError on closed stream" do - -> { IOSpecs.closed_io.getbyte }.should raise_error(IOError) + -> { IOSpecs.closed_io.getbyte }.should.raise(IOError) end end @@ -53,6 +53,6 @@ end it "raises an IOError if the stream is not readable" do - -> { @io.getbyte }.should raise_error(IOError) + -> { @io.getbyte }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/getc_spec.rb b/spec/ruby/core/io/getc_spec.rb index 3949b5cb28476b..3be86203c01086 100644 --- a/spec/ruby/core/io/getc_spec.rb +++ b/spec/ruby/core/io/getc_spec.rb @@ -19,11 +19,11 @@ it "returns nil when invoked at the end of the stream" do @io.read - @io.getc.should be_nil + @io.getc.should == nil end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.getc }.should raise_error(IOError) + -> { IOSpecs.closed_io.getc }.should.raise(IOError) end end @@ -37,6 +37,6 @@ end it "returns nil on empty stream" do - @io.getc.should be_nil + @io.getc.should == nil end end diff --git a/spec/ruby/core/io/gets_spec.rb b/spec/ruby/core/io/gets_spec.rb index 0587fa07c43289..ce3ee73b944d5e 100644 --- a/spec/ruby/core/io/gets_spec.rb +++ b/spec/ruby/core/io/gets_spec.rb @@ -27,7 +27,7 @@ it "sets $_ to nil after the last line has been read" do while @io.gets end - $_.should be_nil + $_.should == nil end it "returns nil if called at the end of the stream" do @@ -36,7 +36,7 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.gets }.should raise_error(IOError) + -> { IOSpecs.closed_io.gets }.should.raise(IOError) end describe "with no separator" do @@ -156,11 +156,11 @@ end it "raises exception when options passed as Hash" do - -> { @io.gets({ chomp: true }) }.should raise_error(TypeError) + -> { @io.gets({ chomp: true }) }.should.raise(TypeError) -> { @io.gets("\n", 1, { chomp: true }) - }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") + }.should.raise(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") end end end @@ -175,11 +175,11 @@ end it "raises an IOError if the stream is opened for append only" do - -> { File.open(@name, "a:utf-8") { |f| f.gets } }.should raise_error(IOError) + -> { File.open(@name, "a:utf-8") { |f| f.gets } }.should.raise(IOError) end it "raises an IOError if the stream is opened for writing only" do - -> { File.open(@name, "w:utf-8") { |f| f.gets } }.should raise_error(IOError) + -> { File.open(@name, "w:utf-8") { |f| f.gets } }.should.raise(IOError) end end @@ -251,7 +251,7 @@ end it "does not accept limit that doesn't fit in a C off_t" do - -> { @io.gets(2**128) }.should raise_error(RangeError) + -> { @io.gets(2**128) }.should.raise(RangeError) end end diff --git a/spec/ruby/core/io/initialize_spec.rb b/spec/ruby/core/io/initialize_spec.rb index 026252a13d16b1..3425e5ac379ec7 100644 --- a/spec/ruby/core/io/initialize_spec.rb +++ b/spec/ruby/core/io/initialize_spec.rb @@ -35,26 +35,26 @@ -> { @io.send(:initialize, fd, "w", {flags: File::CREAT}) - }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 1..2)") + }.should.raise(ArgumentError, "wrong number of arguments (given 3, expected 1..2)") end it "raises a TypeError when passed an IO" do - -> { @io.send :initialize, STDOUT, 'w' }.should raise_error(TypeError) + -> { @io.send :initialize, STDOUT, 'w' }.should.raise(TypeError) end it "raises a TypeError when passed nil" do - -> { @io.send :initialize, nil, 'w' }.should raise_error(TypeError) + -> { @io.send :initialize, nil, 'w' }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { @io.send :initialize, "4", 'w' }.should raise_error(TypeError) + -> { @io.send :initialize, "4", 'w' }.should.raise(TypeError) end it "raises IOError on closed stream" do - -> { @io.send :initialize, IOSpecs.closed_io.fileno }.should raise_error(IOError) + -> { @io.send :initialize, IOSpecs.closed_io.fileno }.should.raise(IOError) end it "raises an Errno::EBADF when given an invalid file descriptor" do - -> { @io.send :initialize, -1, 'w' }.should raise_error(Errno::EBADF) + -> { @io.send :initialize, -1, 'w' }.should.raise(Errno::EBADF) end end diff --git a/spec/ruby/core/io/inspect_spec.rb b/spec/ruby/core/io/inspect_spec.rb index c653c307c412f8..37dc459f22c0b6 100644 --- a/spec/ruby/core/io/inspect_spec.rb +++ b/spec/ruby/core/io/inspect_spec.rb @@ -8,13 +8,13 @@ it "contains the file descriptor number" do @r, @w = IO.pipe - @r.inspect.should include("fd #{@r.fileno}") + @r.inspect.should.include?("fd #{@r.fileno}") end it "contains \"(closed)\" if the stream is closed" do @r, @w = IO.pipe @r.close - @r.inspect.should include("(closed)") + @r.inspect.should.include?("(closed)") end it "reports IO as its Method object's owner" do diff --git a/spec/ruby/core/io/internal_encoding_spec.rb b/spec/ruby/core/io/internal_encoding_spec.rb index 7a583d4bcb13a6..9963a93f332a0f 100644 --- a/spec/ruby/core/io/internal_encoding_spec.rb +++ b/spec/ruby/core/io/internal_encoding_spec.rb @@ -9,25 +9,25 @@ it "returns nil if the internal encoding is not set" do @io = new_io @name, @object - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end it "returns nil if Encoding.default_internal is changed after the instance is created" do @io = new_io @name, @object Encoding.default_internal = Encoding::IBM437 - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end it "returns the value set when the instance was created" do @io = new_io @name, "#{@object}:utf-8:euc-jp" Encoding.default_internal = Encoding::IBM437 - @io.internal_encoding.should equal(Encoding::EUC_JP) + @io.internal_encoding.should.equal?(Encoding::EUC_JP) end it "returns the value set by #set_encoding" do @io = new_io @name, @object @io.set_encoding(Encoding::US_ASCII, Encoding::IBM437) - @io.internal_encoding.should equal(Encoding::IBM437) + @io.internal_encoding.should.equal?(Encoding::IBM437) end end @@ -39,13 +39,13 @@ it "returns nil" do @io = new_io @name, @object - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end it "returns nil regardless of Encoding.default_internal changes" do @io = new_io @name, @object Encoding.default_internal = Encoding::IBM437 - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end end @@ -57,41 +57,41 @@ it "returns the value of Encoding.default_internal when the instance was created if the internal encoding is not set" do @io = new_io @name, @object - @io.internal_encoding.should equal(Encoding::IBM866) + @io.internal_encoding.should.equal?(Encoding::IBM866) end it "does not change when Encoding.default_internal is changed" do @io = new_io @name, @object Encoding.default_internal = Encoding::IBM437 - @io.internal_encoding.should equal(Encoding::IBM866) + @io.internal_encoding.should.equal?(Encoding::IBM866) end it "returns the internal encoding set when the instance was created" do @io = new_io @name, "#{@object}:utf-8:euc-jp" - @io.internal_encoding.should equal(Encoding::EUC_JP) + @io.internal_encoding.should.equal?(Encoding::EUC_JP) end it "does not change when set and Encoding.default_internal is changed" do @io = new_io @name, "#{@object}:utf-8:euc-jp" Encoding.default_internal = Encoding::IBM437 - @io.internal_encoding.should equal(Encoding::EUC_JP) + @io.internal_encoding.should.equal?(Encoding::EUC_JP) end it "returns the value set by #set_encoding" do @io = new_io @name, @object @io.set_encoding(Encoding::US_ASCII, Encoding::IBM437) - @io.internal_encoding.should equal(Encoding::IBM437) + @io.internal_encoding.should.equal?(Encoding::IBM437) end it "returns nil when Encoding.default_external is BINARY and the internal encoding is not set" do Encoding.default_external = Encoding::BINARY @io = new_io @name, @object - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end it "returns nil when the external encoding is BINARY and the internal encoding is not set" do @io = new_io @name, "#{@object}:binary" - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end end end @@ -116,7 +116,7 @@ it "can be retrieved from a closed stream" do io = IOSpecs.io_fixture("lines.txt", "r") io.close - io.internal_encoding.should equal(Encoding.default_internal) + io.internal_encoding.should.equal?(Encoding.default_internal) end describe "with 'r' mode" do diff --git a/spec/ruby/core/io/ioctl_spec.rb b/spec/ruby/core/io/ioctl_spec.rb index 3f7b5ad5d7cbb6..15a5d6ec22568e 100644 --- a/spec/ruby/core/io/ioctl_spec.rb +++ b/spec/ruby/core/io/ioctl_spec.rb @@ -4,7 +4,7 @@ describe "IO#ioctl" do platform_is_not :windows do it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.ioctl(5, 5) }.should raise_error(IOError) + -> { IOSpecs.closed_io.ioctl(5, 5) }.should.raise(IOError) end end @@ -15,7 +15,7 @@ buffer = +'' # FIONREAD in /usr/include/asm-generic/ioctls.h f.ioctl 0x541B, buffer - buffer.unpack('I').first.should be_kind_of(Integer) + buffer.unpack('I').first.should.is_a?(Integer) end end end @@ -25,7 +25,7 @@ -> { # TIOCGWINSZ in /usr/include/asm-generic/ioctls.h f.ioctl 0x5413, nil - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) end end end diff --git a/spec/ruby/core/io/lineno_spec.rb b/spec/ruby/core/io/lineno_spec.rb index 3439a977292677..93b505652ab769 100644 --- a/spec/ruby/core/io/lineno_spec.rb +++ b/spec/ruby/core/io/lineno_spec.rb @@ -11,14 +11,14 @@ end it "raises an IOError on a closed stream" do - -> { IOSpecs.closed_io.lineno }.should raise_error(IOError) + -> { IOSpecs.closed_io.lineno }.should.raise(IOError) end it "raises an IOError on a write-only stream" do name = tmp("io_lineno.txt") begin File.open(name, 'w') do |f| - -> { f.lineno }.should raise_error(IOError) + -> { f.lineno }.should.raise(IOError) end ensure rm_r name @@ -29,7 +29,7 @@ cmd = platform_is(:windows) ? 'rem' : 'cat' IO.popen(cmd, 'r+') do |p| p.close_read - -> { p.lineno }.should raise_error(IOError) + -> { p.lineno }.should.raise(IOError) end end @@ -56,14 +56,14 @@ end it "raises an IOError on a closed stream" do - -> { IOSpecs.closed_io.lineno = 5 }.should raise_error(IOError) + -> { IOSpecs.closed_io.lineno = 5 }.should.raise(IOError) end it "raises an IOError on a write-only stream" do name = tmp("io_lineno.txt") begin File.open(name, 'w') do |f| - -> { f.lineno = 0 }.should raise_error(IOError) + -> { f.lineno = 0 }.should.raise(IOError) end ensure rm_r name @@ -74,7 +74,7 @@ cmd = platform_is(:windows) ? 'rem' : 'cat' IO.popen(cmd, 'r+') do |p| p.close_read - -> { p.lineno = 0 }.should raise_error(IOError) + -> { p.lineno = 0 }.should.raise(IOError) end end @@ -95,12 +95,12 @@ end it "raises TypeError if cannot convert argument to Integer implicitly" do - -> { @io.lineno = "1" }.should raise_error(TypeError, 'no implicit conversion of String into Integer') + -> { @io.lineno = "1" }.should.raise(TypeError, 'no implicit conversion of String into Integer') -> { @io.lineno = nil }.should raise_consistent_error(TypeError, 'no implicit conversion of nil into Integer') end it "does not accept Integers that don't fit in a C int" do - -> { @io.lineno = 2**32 }.should raise_error(RangeError) + -> { @io.lineno = 2**32 }.should.raise(RangeError) end it "sets the current line number to the given value" do diff --git a/spec/ruby/core/io/open_spec.rb b/spec/ruby/core/io/open_spec.rb index d151da9ce5aea3..ff22d14685857e 100644 --- a/spec/ruby/core/io/open_spec.rb +++ b/spec/ruby/core/io/open_spec.rb @@ -32,7 +32,7 @@ super() ScratchPad.record :called end - io.closed?.should be_false + io.closed?.should == false end ScratchPad.recorded.should == :called end @@ -46,7 +46,7 @@ end raise Exception end - end.should raise_error(Exception) + end.should.raise(Exception) ScratchPad.recorded.should == :called end @@ -59,7 +59,7 @@ raise Exception end end - end.should raise_error(Exception) + end.should.raise(Exception) ScratchPad.recorded.should == :called end @@ -72,7 +72,7 @@ raise StandardError end end - end.should raise_error(StandardError) + end.should.raise(StandardError) ScratchPad.recorded.should == :called end diff --git a/spec/ruby/core/io/output_spec.rb b/spec/ruby/core/io/output_spec.rb index 2aafb305f4b61d..0decf8c95b27aa 100644 --- a/spec/ruby/core/io/output_spec.rb +++ b/spec/ruby/core/io/output_spec.rb @@ -16,7 +16,7 @@ it "raises an error if the stream is closed" do io = IOSpecs.closed_io - -> { io << "test" }.should raise_error(IOError) + -> { io << "test" }.should.raise(IOError) end it "returns self" do diff --git a/spec/ruby/core/io/pid_spec.rb b/spec/ruby/core/io/pid_spec.rb index bc09fe7c3b860b..04956887ffe3f5 100644 --- a/spec/ruby/core/io/pid_spec.rb +++ b/spec/ruby/core/io/pid_spec.rb @@ -25,11 +25,11 @@ end it "returns the ID of a process associated with stream" do - @io.pid.should_not be_nil + @io.pid.should_not == nil end it "raises an IOError on closed stream" do @io.close - -> { @io.pid }.should raise_error(IOError) + -> { @io.pid }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/pipe_spec.rb b/spec/ruby/core/io/pipe_spec.rb index aee0d9003f4e39..9f1b01a5cd8002 100644 --- a/spec/ruby/core/io/pipe_spec.rb +++ b/spec/ruby/core/io/pipe_spec.rb @@ -16,14 +16,14 @@ it "returns two IO objects" do @r, @w = IO.pipe - @r.should be_kind_of(IO) - @w.should be_kind_of(IO) + @r.should.is_a?(IO) + @w.should.is_a?(IO) end it "returns instances of a subclass when called on a subclass" do @r, @w = IOSpecs::SubIO.pipe - @r.should be_an_instance_of(IOSpecs::SubIO) - @w.should be_an_instance_of(IOSpecs::SubIO) + @r.should.instance_of?(IOSpecs::SubIO) + @w.should.instance_of?(IOSpecs::SubIO) end it "does not use IO.new method to create pipes and allows its overriding" do @@ -33,8 +33,8 @@ @r, @w = IOSpecs::SubIOWithRedefinedNew.pipe ScratchPad.recorded.should == [:call_original_initialize, :call_original_initialize] # called 2 times - for each pipe (r and w) - @r.should be_an_instance_of(IOSpecs::SubIOWithRedefinedNew) - @w.should be_an_instance_of(IOSpecs::SubIOWithRedefinedNew) + @r.should.instance_of?(IOSpecs::SubIOWithRedefinedNew) + @w.should.instance_of?(IOSpecs::SubIOWithRedefinedNew) end end @@ -42,8 +42,8 @@ describe "passed a block" do it "yields two IO objects" do IO.pipe do |r, w| - r.should be_kind_of(IO) - w.should be_kind_of(IO) + r.should.is_a?(IO) + w.should.is_a?(IO) end end @@ -67,7 +67,7 @@ w = _w raise RuntimeError end - end.should raise_error(RuntimeError) + end.should.raise(RuntimeError) r.should.closed? w.should.closed? end @@ -100,7 +100,7 @@ IO.pipe do |r, w| r.external_encoding.should == Encoding::ISO_8859_1 - r.internal_encoding.should be_nil + r.internal_encoding.should == nil end end @@ -120,14 +120,14 @@ IO.pipe do |r, w| r.external_encoding.should == Encoding::UTF_8 - r.internal_encoding.should be_nil + r.internal_encoding.should == nil end end it "sets the external encoding of the read end when passed an Encoding argument" do IO.pipe(Encoding::UTF_8) do |r, w| r.external_encoding.should == Encoding::UTF_8 - r.internal_encoding.should be_nil + r.internal_encoding.should == nil end end @@ -141,14 +141,14 @@ it "sets the external encoding of the read end when passed the name of an Encoding" do IO.pipe("UTF-8") do |r, w| r.external_encoding.should == Encoding::UTF_8 - r.internal_encoding.should be_nil + r.internal_encoding.should == nil end end it "accepts 'bom|' prefix for external encoding" do IO.pipe("BOM|UTF-8") do |r, w| r.external_encoding.should == Encoding::UTF_8 - r.internal_encoding.should be_nil + r.internal_encoding.should == nil end end @@ -213,13 +213,13 @@ it "sets no external encoding for the write end" do IO.pipe(Encoding::UTF_8) do |r, w| - w.external_encoding.should be_nil + w.external_encoding.should == nil end end it "sets no internal encoding for the write end" do IO.pipe(Encoding::UTF_8) do |r, w| - w.external_encoding.should be_nil + w.external_encoding.should == nil end end end diff --git a/spec/ruby/core/io/popen_spec.rb b/spec/ruby/core/io/popen_spec.rb index 6043862614bc76..b5747bf255435e 100644 --- a/spec/ruby/core/io/popen_spec.rb +++ b/spec/ruby/core/io/popen_spec.rb @@ -21,7 +21,7 @@ it "returns an open IO" do @io = IO.popen(ruby_cmd('exit'), "r") - @io.closed?.should be_false + @io.closed?.should == false end it "reads a read-only pipe" do @@ -31,7 +31,7 @@ it "raises IOError when writing a read-only pipe" do @io = IO.popen('echo foo', "r") - -> { @io.write('bar') }.should raise_error(IOError) + -> { @io.write('bar') }.should.raise(IOError) @io.read.should == "foo\n" end @@ -52,7 +52,7 @@ it "raises IOError when reading a write-only pipe" do @io = IO.popen(ruby_cmd('IO.copy_stream(STDIN,STDOUT)'), "w") - -> { @io.read }.should raise_error(IOError) + -> { @io.read }.should.raise(IOError) end it "reads and writes a read/write pipe" do @@ -86,7 +86,7 @@ it "returns an instance of a subclass when called on a subclass" do @io = IOSpecs::SubIO.popen(ruby_cmd('exit'), "r") - @io.should be_an_instance_of(IOSpecs::SubIO) + @io.should.instance_of?(IOSpecs::SubIO) end it "coerces mode argument with #to_str" do @@ -114,24 +114,24 @@ describe "with a block" do it "yields an open IO to the block" do IO.popen(ruby_cmd('exit'), "r") do |io| - io.closed?.should be_false + io.closed?.should == false end end it "yields an instance of a subclass when called on a subclass" do IOSpecs::SubIO.popen(ruby_cmd('exit'), "r") do |io| - io.should be_an_instance_of(IOSpecs::SubIO) + io.should.instance_of?(IOSpecs::SubIO) end end it "closes the IO after yielding" do io = IO.popen(ruby_cmd('exit'), "r") { |_io| _io } - io.closed?.should be_true + io.closed?.should == true end it "allows the IO to be closed inside the block" do io = IO.popen(ruby_cmd('exit'), 'r') { |_io| _io.close; _io } - io.closed?.should be_true + io.closed?.should == true end it "returns the value of the block" do @@ -169,7 +169,7 @@ it "sets the internal encoding to nil if it's the same as the external encoding" do @io = IO.popen(ruby_cmd('exit'), external_encoding: Encoding::EUC_JP, internal_encoding: Encoding::EUC_JP) - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end context "with a leading ENV Hash" do diff --git a/spec/ruby/core/io/pread_spec.rb b/spec/ruby/core/io/pread_spec.rb index 8f7d9b2521d9c9..cfb8dc4c68b821 100644 --- a/spec/ruby/core/io/pread_spec.rb +++ b/spec/ruby/core/io/pread_spec.rb @@ -99,40 +99,40 @@ it "raises TypeError if maxlen is not an Integer and cannot be coerced into Integer" do maxlen = Object.new - -> { @file.pread(maxlen, 0) }.should raise_error(TypeError, 'no implicit conversion of Object into Integer') + -> { @file.pread(maxlen, 0) }.should.raise(TypeError, 'no implicit conversion of Object into Integer') end it "raises TypeError if offset is not an Integer and cannot be coerced into Integer" do offset = Object.new - -> { @file.pread(4, offset) }.should raise_error(TypeError, 'no implicit conversion of Object into Integer') + -> { @file.pread(4, offset) }.should.raise(TypeError, 'no implicit conversion of Object into Integer') end it "raises ArgumentError for negative values of maxlen" do - -> { @file.pread(-4, 0) }.should raise_error(ArgumentError, 'negative string size (or size too big)') + -> { @file.pread(-4, 0) }.should.raise(ArgumentError, 'negative string size (or size too big)') end it "raised Errno::EINVAL for negative values of offset" do - -> { @file.pread(4, -1) }.should raise_error(Errno::EINVAL, /Invalid argument/) + -> { @file.pread(4, -1) }.should.raise(Errno::EINVAL, /Invalid argument/) end it "raises TypeError if the buffer is not a String and cannot be coerced into String" do buffer = Object.new - -> { @file.pread(4, 0, buffer) }.should raise_error(TypeError, 'no implicit conversion of Object into String') + -> { @file.pread(4, 0, buffer) }.should.raise(TypeError, 'no implicit conversion of Object into String') end it "raises EOFError if end-of-file is reached" do - -> { @file.pread(1, 10) }.should raise_error(EOFError) + -> { @file.pread(1, 10) }.should.raise(EOFError) end it "raises IOError when file is not open in read mode" do File.open(@fname, "w") do |file| - -> { file.pread(1, 1) }.should raise_error(IOError) + -> { file.pread(1, 1) }.should.raise(IOError) end end it "raises IOError when file is closed" do file = File.open(@fname, "r+") file.close - -> { file.pread(1, 1) }.should raise_error(IOError) + -> { file.pread(1, 1) }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/print_spec.rb b/spec/ruby/core/io/print_spec.rb index 085852024c945a..065cb3b8cb7cdb 100644 --- a/spec/ruby/core/io/print_spec.rb +++ b/spec/ruby/core/io/print_spec.rb @@ -21,7 +21,7 @@ end it "returns nil" do - touch(@name) { |f| f.print.should be_nil } + touch(@name) { |f| f.print.should == nil } end it "writes $_.to_s followed by $\\ (if any) to the stream if no arguments given" do @@ -61,6 +61,6 @@ def o2.to_s(); 'o2'; end end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.print("stuff") }.should raise_error(IOError) + -> { IOSpecs.closed_io.print("stuff") }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/printf_spec.rb b/spec/ruby/core/io/printf_spec.rb index baa00f14cedf73..d5519bdaa387a0 100644 --- a/spec/ruby/core/io/printf_spec.rb +++ b/spec/ruby/core/io/printf_spec.rb @@ -27,6 +27,6 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.printf("stuff") }.should raise_error(IOError) + -> { IOSpecs.closed_io.printf("stuff") }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/puts_spec.rb b/spec/ruby/core/io/puts_spec.rb index a186ddaa5d83a3..df526ea56aa2a1 100644 --- a/spec/ruby/core/io/puts_spec.rb +++ b/spec/ruby/core/io/puts_spec.rb @@ -111,7 +111,7 @@ def @io.write(str) end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.puts("stuff") }.should raise_error(IOError) + -> { IOSpecs.closed_io.puts("stuff") }.should.raise(IOError) end it "writes crlf when IO is opened with newline: :crlf" do diff --git a/spec/ruby/core/io/pwrite_spec.rb b/spec/ruby/core/io/pwrite_spec.rb index fd0b6cf380c463..c318d551bc3e13 100644 --- a/spec/ruby/core/io/pwrite_spec.rb +++ b/spec/ruby/core/io/pwrite_spec.rb @@ -43,25 +43,25 @@ it "raises IOError when file is not open in write mode" do File.open(@fname, "r") do |file| - -> { file.pwrite("foo", 1) }.should raise_error(IOError, "not opened for writing") + -> { file.pwrite("foo", 1) }.should.raise(IOError, "not opened for writing") end end it "raises IOError when file is closed" do file = File.open(@fname, "w+") file.close - -> { file.pwrite("foo", 1) }.should raise_error(IOError, "closed stream") + -> { file.pwrite("foo", 1) }.should.raise(IOError, "closed stream") end it "raises a NoMethodError if object does not respond to #to_s" do -> { @file.pwrite(BasicObject.new, 0) - }.should raise_error(NoMethodError, /undefined method [`']to_s'/) + }.should.raise(NoMethodError, /undefined method [`']to_s'/) end it "raises a TypeError if the offset cannot be converted to an Integer" do -> { @file.pwrite("foo", Object.new) - }.should raise_error(TypeError, "no implicit conversion of Object into Integer") + }.should.raise(TypeError, "no implicit conversion of Object into Integer") end end diff --git a/spec/ruby/core/io/read_nonblock_spec.rb b/spec/ruby/core/io/read_nonblock_spec.rb index 51e7cd6bd2fdd4..511cf03263c497 100644 --- a/spec/ruby/core/io/read_nonblock_spec.rb +++ b/spec/ruby/core/io/read_nonblock_spec.rb @@ -12,12 +12,12 @@ end it "raises an exception extending IO::WaitReadable when there is no data" do - -> { @read.read_nonblock(5) }.should raise_error(IO::WaitReadable) { |e| + -> { @read.read_nonblock(5) }.should.raise(IO::WaitReadable) { |e| platform_is_not :windows do - e.should be_kind_of(Errno::EAGAIN) + e.should.is_a?(Errno::EAGAIN) end platform_is :windows do - e.should be_kind_of(Errno::EWOULDBLOCK) + e.should.is_a?(Errno::EWOULDBLOCK) end } end @@ -36,7 +36,7 @@ @read.read_nonblock(5) - @read.read_nonblock(5, exception: false).should be_nil + @read.read_nonblock(5, exception: false).should == nil end end end @@ -73,7 +73,7 @@ ) c = @read.getc @read.ungetc(c) - -> { @read.read_nonblock(3).should == "foo" }.should raise_error(IOError) + -> { @read.read_nonblock(3).should == "foo" }.should.raise(IOError) end it "returns less data if that is all that is available" do @@ -92,7 +92,7 @@ end it "raises ArgumentError when length is less than 0" do - -> { @read.read_nonblock(-1) }.should raise_error(ArgumentError) + -> { @read.read_nonblock(-1) }.should.raise(ArgumentError) end it "reads into the passed buffer" do @@ -106,7 +106,7 @@ buffer = +"" @write.write("1") output = @read.read_nonblock(1, buffer) - output.should equal(buffer) + output.should.equal?(buffer) end it "discards the existing buffer content upon successful read" do @@ -120,12 +120,12 @@ it "discards the existing buffer content upon error" do buffer = +"existing content" @write.close - -> { @read.read_nonblock(1, buffer) }.should raise_error(EOFError) - buffer.should be_empty + -> { @read.read_nonblock(1, buffer) }.should.raise(EOFError) + buffer.should.empty? end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.read_nonblock(5) }.should raise_error(IOError) + -> { IOSpecs.closed_io.read_nonblock(5) }.should.raise(IOError) end it "raises EOFError when the end is reached" do @@ -134,7 +134,7 @@ @read.read_nonblock(5) - -> { @read.read_nonblock(5) }.should raise_error(EOFError) + -> { @read.read_nonblock(5) }.should.raise(EOFError) end it "preserves the encoding of the given buffer" do diff --git a/spec/ruby/core/io/read_spec.rb b/spec/ruby/core/io/read_spec.rb index dfb42e09db7681..dd787c9b60d85b 100644 --- a/spec/ruby/core/io/read_spec.rb +++ b/spec/ruby/core/io/read_spec.rb @@ -29,7 +29,7 @@ -> { IO.read(@fname, 3, 0, {mode: "r+"}) - }.should raise_error(ArgumentError, /wrong number of arguments/) + }.should.raise(ArgumentError, /wrong number of arguments/) end it "accepts an empty options Hash" do @@ -45,11 +45,11 @@ end it "raises an IOError if the options Hash specifies write mode" do - -> { IO.read(@fname, 3, 0, mode: "w") }.should raise_error(IOError) + -> { IO.read(@fname, 3, 0, mode: "w") }.should.raise(IOError) end it "raises an IOError if the options Hash specifies append only mode" do - -> { IO.read(@fname, mode: "a") }.should raise_error(IOError) + -> { IO.read(@fname, mode: "a") }.should.raise(IOError) end it "reads the file if the options Hash includes read mode" do @@ -115,20 +115,20 @@ it "raises an Errno::ENOENT when the requested file does not exist" do rm_r @fname - -> { IO.read @fname }.should raise_error(Errno::ENOENT) + -> { IO.read @fname }.should.raise(Errno::ENOENT) end it "raises a TypeError when not passed a String type" do - -> { IO.read nil }.should raise_error(TypeError) + -> { IO.read nil }.should.raise(TypeError) end it "raises an ArgumentError when not passed a valid length" do - -> { IO.read @fname, -1 }.should raise_error(ArgumentError) + -> { IO.read @fname, -1 }.should.raise(ArgumentError) end it "raises an ArgumentError when not passed a valid offset" do - -> { IO.read @fname, 0, -1 }.should raise_error(ArgumentError) - -> { IO.read @fname, -1, -1 }.should raise_error(ArgumentError) + -> { IO.read @fname, 0, -1 }.should.raise(ArgumentError) + -> { IO.read @fname, -1, -1 }.should.raise(ArgumentError) end it "uses the external encoding specified via the :external_encoding option" do @@ -196,7 +196,7 @@ suppress_warning do # https://bugs.ruby-lang.org/issues/19630 IO.read("|sh -c 'echo hello'", 1, 1) end - }.should raise_error(Errno::ESPIPE) + }.should.raise(Errno::ESPIPE) end end @@ -209,7 +209,7 @@ suppress_warning do # https://bugs.ruby-lang.org/issues/19630 IO.read("|cmd.exe /C echo hello", 1, 1) end - }.should raise_error(Errno::EINVAL) + }.should.raise(Errno::EINVAL) end end end @@ -270,7 +270,7 @@ end it "raises an ArgumentError when not passed a valid length" do - -> { @io.read(-1) }.should raise_error(ArgumentError) + -> { @io.read(-1) }.should.raise(ArgumentError) end it "clears the output buffer if there is nothing to read" do @@ -297,14 +297,14 @@ it "raise FrozenError if the output buffer is frozen" do @io.read - -> { @io.read(0, 'frozen-string'.freeze) }.should raise_error(FrozenError) - -> { @io.read(1, 'frozen-string'.freeze) }.should raise_error(FrozenError) - -> { @io.read(nil, 'frozen-string'.freeze) }.should raise_error(FrozenError) + -> { @io.read(0, 'frozen-string'.freeze) }.should.raise(FrozenError) + -> { @io.read(1, 'frozen-string'.freeze) }.should.raise(FrozenError) + -> { @io.read(nil, 'frozen-string'.freeze) }.should.raise(FrozenError) end it "raise FrozenError if the output buffer is frozen (2)" do @io.read - -> { @io.read(1, ''.freeze) }.should raise_error(FrozenError) + -> { @io.read(1, ''.freeze) }.should.raise(FrozenError) end it "consumes zero bytes when reading zero bytes" do @@ -374,14 +374,14 @@ it "returns the given buffer" do buf = +"" - @io.read(nil, buf).should equal buf + @io.read(nil, buf).should.equal? buf end it "returns the given buffer when there is nothing to read" do buf = +"" @io.read - @io.read(nil, buf).should equal buf + @io.read(nil, buf).should.equal? buf end it "coerces the second argument to string and uses it as a buffer" do @@ -389,7 +389,7 @@ obj = mock("buff") obj.should_receive(:to_str).any_number_of_times.and_return(buf) - @io.read(15, obj).should_not equal obj + @io.read(15, obj).should_not.equal? obj buf.should == @contents end @@ -423,11 +423,11 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.read }.should raise_error(IOError) + -> { IOSpecs.closed_io.read }.should.raise(IOError) end it "raises ArgumentError when length is less than 0" do - -> { @io.read(-1) }.should raise_error(ArgumentError) + -> { @io.read(-1) }.should.raise(ArgumentError) end platform_is_not :windows do @@ -444,7 +444,7 @@ Thread.pass until t.stop? r.close t.join - t.value.should be_kind_of(IOError) + t.value.should.is_a?(IOError) w.close end end @@ -578,20 +578,20 @@ end it "sets the String encoding to the internal encoding" do - @io.read.encoding.should equal(Encoding::UTF_8) + @io.read.encoding.should.equal?(Encoding::UTF_8) end describe "when passed nil for limit" do it "sets the buffer to a transcoded String" do result = @io.read(nil, buf = +"") - buf.should equal(result) + buf.should.equal?(result) buf.should == "ありがとう\n" end it "sets the buffer's encoding to the internal encoding" do buf = "".dup.force_encoding Encoding::ISO_8859_1 @io.read(nil, buf) - buf.encoding.should equal(Encoding::UTF_8) + buf.encoding.should.equal?(Encoding::UTF_8) end end end @@ -602,24 +602,24 @@ end it "returns a String in BINARY when passed a size" do - @io.read(4).encoding.should equal(Encoding::BINARY) - @io.read(0).encoding.should equal(Encoding::BINARY) + @io.read(4).encoding.should.equal?(Encoding::BINARY) + @io.read(0).encoding.should.equal?(Encoding::BINARY) end it "does not change the buffer's encoding when passed a limit" do buf = "".dup.force_encoding Encoding::ISO_8859_1 @io.read(4, buf) buf.should == [164, 162, 164, 234].pack('C*').force_encoding(Encoding::ISO_8859_1) - buf.encoding.should equal(Encoding::ISO_8859_1) + buf.encoding.should.equal?(Encoding::ISO_8859_1) end it "truncates the buffer but does not change the buffer's encoding when no data remains" do buf = "abc".dup.force_encoding Encoding::ISO_8859_1 @io.read - @io.read(1, buf).should be_nil + @io.read(1, buf).should == nil buf.size.should == 0 - buf.encoding.should equal(Encoding::ISO_8859_1) + buf.encoding.should.equal?(Encoding::ISO_8859_1) end end @@ -637,7 +637,7 @@ end it "sets the String encoding to Encoding.default_external" do - @io.read.encoding.should equal(Encoding.default_external) + @io.read.encoding.should.equal?(Encoding.default_external) end end @@ -656,7 +656,7 @@ end it "sets the String encoding to the external encoding" do - @io.read.encoding.should equal(Encoding::EUC_JP) + @io.read.encoding.should.equal?(Encoding::EUC_JP) end it_behaves_like :io_read_size_internal_encoding, nil diff --git a/spec/ruby/core/io/readbyte_spec.rb b/spec/ruby/core/io/readbyte_spec.rb index 14426c28ac98ab..07da1da919652f 100644 --- a/spec/ruby/core/io/readbyte_spec.rb +++ b/spec/ruby/core/io/readbyte_spec.rb @@ -19,6 +19,6 @@ @io.seek(999999) -> do @io.readbyte - end.should raise_error EOFError + end.should.raise EOFError end end diff --git a/spec/ruby/core/io/readchar_spec.rb b/spec/ruby/core/io/readchar_spec.rb index a66773851ad77d..29d14880fff666 100644 --- a/spec/ruby/core/io/readchar_spec.rb +++ b/spec/ruby/core/io/readchar_spec.rb @@ -7,7 +7,7 @@ end it "sets the String encoding to the internal encoding" do - @io.readchar.encoding.should equal(Encoding::UTF_8) + @io.readchar.encoding.should.equal?(Encoding::UTF_8) end end @@ -31,11 +31,11 @@ it "raises an EOFError when invoked at the end of the stream" do @io.read - -> { @io.readchar }.should raise_error(EOFError) + -> { @io.readchar }.should.raise(EOFError) end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.readchar }.should raise_error(IOError) + -> { IOSpecs.closed_io.readchar }.should.raise(IOError) end end @@ -54,7 +54,7 @@ end it "sets the String encoding to the external encoding" do - @io.readchar.encoding.should equal(Encoding::EUC_JP) + @io.readchar.encoding.should.equal?(Encoding::EUC_JP) end end @@ -105,6 +105,6 @@ end it "raises EOFError on empty stream" do - -> { @io.readchar }.should raise_error(EOFError) + -> { @io.readchar }.should.raise(EOFError) end end diff --git a/spec/ruby/core/io/readline_spec.rb b/spec/ruby/core/io/readline_spec.rb index a814c1be908e9c..009687710a432e 100644 --- a/spec/ruby/core/io/readline_spec.rb +++ b/spec/ruby/core/io/readline_spec.rb @@ -29,11 +29,11 @@ it "raises EOFError on end of stream" do IOSpecs.lines.length.times { @io.readline } - -> { @io.readline }.should raise_error(EOFError) + -> { @io.readline }.should.raise(EOFError) end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.readline }.should raise_error(IOError) + -> { IOSpecs.closed_io.readline }.should.raise(IOError) end it "assigns the returned line to $_" do @@ -53,7 +53,7 @@ end it "does not accept Integers that don't fit in a C off_t" do - -> { @io.readline(2**128) }.should raise_error(RangeError) + -> { @io.readline(2**128) }.should.raise(RangeError) end end @@ -74,11 +74,11 @@ end it "raises exception when options passed as Hash" do - -> { @io.readline({ chomp: true }) }.should raise_error(TypeError) + -> { @io.readline({ chomp: true }) }.should.raise(TypeError) -> { @io.readline("\n", 1, { chomp: true }) - }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") + }.should.raise(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") end end end diff --git a/spec/ruby/core/io/readlines_spec.rb b/spec/ruby/core/io/readlines_spec.rb index 07d29ea5317f2d..640e2532004c6e 100644 --- a/spec/ruby/core/io/readlines_spec.rb +++ b/spec/ruby/core/io/readlines_spec.rb @@ -17,7 +17,7 @@ it "raises an IOError if the stream is closed" do @io.close - -> { @io.readlines }.should raise_error(IOError) + -> { @io.readlines }.should.raise(IOError) end describe "when passed no arguments" do @@ -37,12 +37,12 @@ describe "when passed no arguments" do it "updates self's position" do @io.readlines - @io.pos.should eql(137) + @io.pos.should.eql?(137) end it "updates self's lineno based on the number of lines read" do @io.readlines - @io.lineno.should eql(9) + @io.lineno.should.eql?(9) end it "does not change $_" do @@ -81,12 +81,12 @@ it "updates self's lineno based on the number of lines read" do @io.readlines("r") - @io.lineno.should eql(5) + @io.lineno.should.eql?(5) end it "updates self's position based on the number of characters read" do @io.readlines("r") - @io.pos.should eql(137) + @io.pos.should.eql?(137) end it "does not change $_" do @@ -104,11 +104,11 @@ describe "when passed limit" do it "raises ArgumentError when passed 0 as a limit" do - -> { @io.readlines(0) }.should raise_error(ArgumentError) + -> { @io.readlines(0) }.should.raise(ArgumentError) end it "does not accept Integers that don't fit in a C off_t" do - -> { @io.readlines(2**128) }.should raise_error(RangeError) + -> { @io.readlines(2**128) }.should.raise(RangeError) end end @@ -118,11 +118,11 @@ end it "raises exception when options passed as Hash" do - -> { @io.readlines({ chomp: true }) }.should raise_error(TypeError) + -> { @io.readlines({ chomp: true }) }.should.raise(TypeError) -> { @io.readlines("\n", 1, { chomp: true }) - }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") + }.should.raise(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") end end @@ -145,13 +145,13 @@ it "raises an IOError if the stream is opened for append only" do -> do File.open(@name, "a:utf-8") { |f| f.readlines } - end.should raise_error(IOError) + end.should.raise(IOError) end it "raises an IOError if the stream is opened for write only" do -> do File.open(@name, "w:utf-8") { |f| f.readlines } - end.should raise_error(IOError) + end.should.raise(IOError) end end @@ -237,7 +237,7 @@ it "encodes lines using the default external encoding" do Encoding.default_external = Encoding::UTF_8 lines = IO.readlines(@name) - lines.all? { |s| s.encoding == Encoding::UTF_8 }.should be_true + lines.all? { |s| s.encoding == Encoding::UTF_8 }.should == true end it "encodes lines using the default internal encoding, when set" do @@ -245,13 +245,13 @@ Encoding.default_internal = Encoding::UTF_16 suppress_warning {$/ = $/.encode Encoding::UTF_16} lines = IO.readlines(@name) - lines.all? { |s| s.encoding == Encoding::UTF_16 }.should be_true + lines.all? { |s| s.encoding == Encoding::UTF_16 }.should == true end it "ignores the default internal encoding if the external encoding is BINARY" do Encoding.default_external = Encoding::BINARY Encoding.default_internal = Encoding::UTF_8 lines = IO.readlines(@name) - lines.all? { |s| s.encoding == Encoding::BINARY }.should be_true + lines.all? { |s| s.encoding == Encoding::BINARY }.should == true end end diff --git a/spec/ruby/core/io/readpartial_spec.rb b/spec/ruby/core/io/readpartial_spec.rb index 176c33cf9e43cd..d3f5545c8fc0c8 100644 --- a/spec/ruby/core/io/readpartial_spec.rb +++ b/spec/ruby/core/io/readpartial_spec.rb @@ -15,10 +15,10 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.readpartial(10) }.should raise_error(IOError) + -> { IOSpecs.closed_io.readpartial(10) }.should.raise(IOError) @rd.close - -> { @rd.readpartial(10) }.should raise_error(IOError) + -> { @rd.readpartial(10) }.should.raise(IOError) end it "reads at most the specified number of bytes" do @@ -70,23 +70,23 @@ @wr.write("abc") @wr.close @rd.readpartial(10).should == 'abc' - -> { @rd.readpartial(10) }.should raise_error(EOFError) + -> { @rd.readpartial(10) }.should.raise(EOFError) end it "discards the existing buffer content upon error" do buffer = +'hello' @wr.close - -> { @rd.readpartial(1, buffer) }.should raise_error(EOFError) - buffer.should be_empty + -> { @rd.readpartial(1, buffer) }.should.raise(EOFError) + buffer.should.empty? end it "raises IOError if the stream is closed" do @wr.close - -> { @rd.readpartial(1) }.should raise_error(IOError) + -> { @rd.readpartial(1) }.should.raise(IOError) end it "raises ArgumentError if the negative argument is provided" do - -> { @rd.readpartial(-1) }.should raise_error(ArgumentError) + -> { @rd.readpartial(-1) }.should.raise(ArgumentError) end it "immediately returns an empty string if the length argument is 0" do @@ -95,7 +95,7 @@ it "raises IOError if the stream is closed and the length argument is 0" do @rd.close - -> { @rd.readpartial(0) }.should raise_error(IOError, "closed stream") + -> { @rd.readpartial(0) }.should.raise(IOError, "closed stream") end it "clears and returns the given buffer if the length argument is 0" do diff --git a/spec/ruby/core/io/reopen_spec.rb b/spec/ruby/core/io/reopen_spec.rb index 8ff0f217f4410a..3b972d8978e391 100644 --- a/spec/ruby/core/io/reopen_spec.rb +++ b/spec/ruby/core/io/reopen_spec.rb @@ -27,35 +27,35 @@ it "changes the class of the instance to the class of the object returned by #to_io" do obj = mock("io") obj.should_receive(:to_io).and_return(@other_io) - @io.reopen(obj).should be_an_instance_of(File) + @io.reopen(obj).should.instance_of?(File) end it "raises an IOError if the object returned by #to_io is closed" do obj = mock("io") obj.should_receive(:to_io).and_return(IOSpecs.closed_io) - -> { @io.reopen obj }.should raise_error(IOError) + -> { @io.reopen obj }.should.raise(IOError) end it "raises a TypeError if #to_io does not return an IO instance" do obj = mock("io") obj.should_receive(:to_io).and_return("something else") - -> { @io.reopen obj }.should raise_error(TypeError) + -> { @io.reopen obj }.should.raise(TypeError) end it "raises an IOError when called on a closed stream with an object" do @io.close obj = mock("io") obj.should_not_receive(:to_io) - -> { @io.reopen(STDOUT) }.should raise_error(IOError) + -> { @io.reopen(STDOUT) }.should.raise(IOError) end it "raises an IOError if the IO argument is closed" do - -> { @io.reopen(IOSpecs.closed_io) }.should raise_error(IOError) + -> { @io.reopen(IOSpecs.closed_io) }.should.raise(IOError) end it "raises an IOError when called on a closed stream with an IO" do @io.close - -> { @io.reopen(STDOUT) }.should raise_error(IOError) + -> { @io.reopen(STDOUT) }.should.raise(IOError) end end @@ -77,12 +77,12 @@ it "does not raise an exception when called on a closed stream with a path" do @io.close @io.reopen @name, "r" - @io.closed?.should be_false + @io.closed?.should == false @io.gets.should == "Line 1: One\n" end it "returns self" do - @io.reopen(@name).should equal(@io) + @io.reopen(@name).should.equal?(@io) end it "positions a newly created instance at the beginning of the new stream" do @@ -188,7 +188,7 @@ it "raises an Errno::ENOENT if the file does not exist and the IO is not opened in write mode" do @io = new_io @name, "r" - -> { @io.reopen(@other_name) }.should raise_error(Errno::ENOENT) + -> { @io.reopen(@other_name) }.should.raise(Errno::ENOENT) end end @@ -214,9 +214,9 @@ end it "resets the EOF status to false" do - @io.eof?.should be_true + @io.eof?.should == true @io.reopen @other_io - @io.eof?.should be_false + @io.eof?.should == false end end @@ -244,7 +244,7 @@ # MRI actually changes the class of @io in the call to #reopen # but does not preserve the existing singleton class of @io. def @io.to_io; flunk; end - @io.reopen(@other_io).should be_an_instance_of(IO) + @io.reopen(@other_io).should.instance_of?(IO) end it "does not change the object_id" do @@ -303,7 +303,7 @@ def @io.to_io; flunk; end it "may change the class of the instance" do @io.reopen @other_io - @io.should be_an_instance_of(File) + @io.should.instance_of?(File) end it "sets path equals to the other IO's path if other IO is File" do diff --git a/spec/ruby/core/io/rewind_spec.rb b/spec/ruby/core/io/rewind_spec.rb index 5579cbd9886cea..43834ef3071ded 100644 --- a/spec/ruby/core/io/rewind_spec.rb +++ b/spec/ruby/core/io/rewind_spec.rb @@ -48,6 +48,6 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.rewind }.should raise_error(IOError) + -> { IOSpecs.closed_io.rewind }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/seek_spec.rb b/spec/ruby/core/io/seek_spec.rb index 2fa4a73ac9e661..d26629fb892988 100644 --- a/spec/ruby/core/io/seek_spec.rb +++ b/spec/ruby/core/io/seek_spec.rb @@ -17,7 +17,7 @@ end it "moves the read position relative to the current position with SEEK_CUR" do - -> { @io.seek(-1) }.should raise_error(Errno::EINVAL) + -> { @io.seek(-1) }.should.raise(Errno::EINVAL) @io.seek(10, IO::SEEK_CUR) @io.readline.should == "igne une.\n" @io.seek(-5, IO::SEEK_CUR) diff --git a/spec/ruby/core/io/select_spec.rb b/spec/ruby/core/io/select_spec.rb index 2cc4a02115850c..0a43fc6f5fc2b6 100644 --- a/spec/ruby/core/io/select_spec.rb +++ b/spec/ruby/core/io/select_spec.rb @@ -95,38 +95,38 @@ end it "raises TypeError if supplied objects are not IO" do - -> { IO.select([Object.new]) }.should raise_error(TypeError) - -> { IO.select(nil, [Object.new]) }.should raise_error(TypeError) + -> { IO.select([Object.new]) }.should.raise(TypeError) + -> { IO.select(nil, [Object.new]) }.should.raise(TypeError) obj = mock("io") obj.should_receive(:to_io).any_number_of_times.and_return(nil) - -> { IO.select([obj]) }.should raise_error(TypeError) - -> { IO.select(nil, [obj]) }.should raise_error(TypeError) + -> { IO.select([obj]) }.should.raise(TypeError) + -> { IO.select(nil, [obj]) }.should.raise(TypeError) end it "raises a TypeError if the specified timeout value is not Numeric" do - -> { IO.select([@rd], nil, nil, Object.new) }.should raise_error(TypeError) + -> { IO.select([@rd], nil, nil, Object.new) }.should.raise(TypeError) end it "raises TypeError if the first three arguments are not Arrays" do - -> { IO.select(Object.new)}.should raise_error(TypeError) - -> { IO.select(nil, Object.new)}.should raise_error(TypeError) - -> { IO.select(nil, nil, Object.new)}.should raise_error(TypeError) + -> { IO.select(Object.new)}.should.raise(TypeError) + -> { IO.select(nil, Object.new)}.should.raise(TypeError) + -> { IO.select(nil, nil, Object.new)}.should.raise(TypeError) end it "raises an ArgumentError when passed a negative timeout" do - -> { IO.select(nil, nil, nil, -5)}.should raise_error(ArgumentError, "time interval must not be negative") + -> { IO.select(nil, nil, nil, -5)}.should.raise(ArgumentError, "time interval must not be negative") end ruby_version_is "4.0" do it "raises an ArgumentError when passed negative infinity as timeout" do - -> { IO.select(nil, nil, nil, -Float::INFINITY)}.should raise_error(ArgumentError, "time interval must not be negative") + -> { IO.select(nil, nil, nil, -Float::INFINITY)}.should.raise(ArgumentError, "time interval must not be negative") end end it "raises an RangeError when passed NaN as timeout" do - -> { IO.select(nil, nil, nil, Float::NAN)}.should raise_error(RangeError, "NaN out of Time range") + -> { IO.select(nil, nil, nil, Float::NAN)}.should.raise(RangeError, "NaN out of Time range") end describe "returns the available descriptors when the file descriptor" do diff --git a/spec/ruby/core/io/set_encoding_by_bom_spec.rb b/spec/ruby/core/io/set_encoding_by_bom_spec.rb index 30d5ce5a5af16c..5436879f11a031 100644 --- a/spec/ruby/core/io/set_encoding_by_bom_spec.rb +++ b/spec/ruby/core/io/set_encoding_by_bom_spec.rb @@ -15,7 +15,7 @@ it "returns nil if not readable" do not_readable_io = new_io(@name, 'wb') - not_readable_io.set_encoding_by_bom.should be_nil + not_readable_io.set_encoding_by_bom.should == nil not_readable_io.external_encoding.should == Encoding::ASCII_8BIT ensure not_readable_io.close @@ -102,7 +102,7 @@ end it "returns nil if io is empty" do - @io.set_encoding_by_bom.should be_nil + @io.set_encoding_by_bom.should == nil @io.external_encoding.should == Encoding::ASCII_8BIT end @@ -243,7 +243,7 @@ it 'returns exception if io not in binary mode' do not_binary_io = new_io(@name, 'r') - -> { not_binary_io.set_encoding_by_bom }.should raise_error(ArgumentError, 'ASCII incompatible encoding needs binmode') + -> { not_binary_io.set_encoding_by_bom }.should.raise(ArgumentError, 'ASCII incompatible encoding needs binmode') ensure not_binary_io.close end @@ -251,12 +251,12 @@ it 'returns exception if encoding already set' do @io.set_encoding("utf-8") - -> { @io.set_encoding_by_bom }.should raise_error(ArgumentError, 'encoding is set to UTF-8 already') + -> { @io.set_encoding_by_bom }.should.raise(ArgumentError, 'encoding is set to UTF-8 already') end it 'returns exception if encoding conversion is already set' do @io.set_encoding(Encoding::UTF_8, Encoding::UTF_16BE) - -> { @io.set_encoding_by_bom }.should raise_error(ArgumentError, 'encoding conversion is set') + -> { @io.set_encoding_by_bom }.should.raise(ArgumentError, 'encoding conversion is set') end end diff --git a/spec/ruby/core/io/set_encoding_spec.rb b/spec/ruby/core/io/set_encoding_spec.rb index 22d9017635709f..237251de5b4bc0 100644 --- a/spec/ruby/core/io/set_encoding_spec.rb +++ b/spec/ruby/core/io/set_encoding_spec.rb @@ -5,21 +5,21 @@ @io = new_io @name, "#{@object}:ibm437:ibm866" @io.set_encoding nil, nil - @io.external_encoding.should be_nil - @io.internal_encoding.should be_nil + @io.external_encoding.should == nil + @io.internal_encoding.should == nil end it "sets the encodings to nil when the IO is built with no explicit encoding" do @io = new_io @name, @object # Checking our assumptions first - @io.external_encoding.should be_nil - @io.internal_encoding.should be_nil + @io.external_encoding.should == nil + @io.internal_encoding.should == nil @io.set_encoding nil, nil - @io.external_encoding.should be_nil - @io.internal_encoding.should be_nil + @io.external_encoding.should == nil + @io.internal_encoding.should == nil end it "prevents the encodings from changing when Encoding defaults are changed" do @@ -29,8 +29,8 @@ Encoding.default_external = Encoding::IBM437 Encoding.default_internal = Encoding::IBM866 - @io.external_encoding.should be_nil - @io.internal_encoding.should be_nil + @io.external_encoding.should == nil + @io.internal_encoding.should == nil end it "sets the encodings to the current Encoding defaults" do @@ -75,8 +75,8 @@ Encoding.default_internal = Encoding::IBM866 @io.set_encoding nil, nil - @io.external_encoding.should equal(Encoding::IBM437) - @io.internal_encoding.should equal(Encoding::IBM866) + @io.external_encoding.should.equal?(Encoding::IBM437) + @io.internal_encoding.should.equal?(Encoding::IBM866) end it "prevents the #internal_encoding from changing when Encoding.default_internal is changed" do @@ -85,7 +85,7 @@ Encoding.default_internal = Encoding::IBM437 - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end it "allows the #external_encoding to change when Encoding.default_external is changed" do @@ -94,17 +94,17 @@ Encoding.default_external = Encoding::IBM437 - @io.external_encoding.should equal(Encoding::IBM437) + @io.external_encoding.should.equal?(Encoding::IBM437) end end describe "with 'rb' mode" do it "returns Encoding.default_external" do @io = new_io @name, "rb" - @io.external_encoding.should equal(Encoding::BINARY) + @io.external_encoding.should.equal?(Encoding::BINARY) @io.set_encoding nil, nil - @io.external_encoding.should equal(Encoding.default_external) + @io.external_encoding.should.equal?(Encoding.default_external) end end @@ -158,13 +158,13 @@ end it "returns self" do - @io.set_encoding(Encoding::UTF_8).should equal(@io) + @io.set_encoding(Encoding::UTF_8).should.equal?(@io) end it "sets the external encoding when passed an Encoding argument" do @io.set_encoding(Encoding::UTF_8) @io.external_encoding.should == Encoding::UTF_8 - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end it "sets the external and internal encoding when passed two Encoding arguments" do @@ -176,19 +176,19 @@ it "sets the external encoding when passed the name of an Encoding" do @io.set_encoding("utf-8") @io.external_encoding.should == Encoding::UTF_8 - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end it "ignores the internal encoding if the same as external when passed Encoding objects" do @io.set_encoding(Encoding::UTF_8, Encoding::UTF_8) @io.external_encoding.should == Encoding::UTF_8 - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end it "ignores the internal encoding if the same as external when passed encoding names separated by ':'" do @io.set_encoding("utf-8:utf-8") @io.external_encoding.should == Encoding::UTF_8 - @io.internal_encoding.should be_nil + @io.internal_encoding.should == nil end it "sets the external and internal encoding when passed the names of Encodings separated by ':'" do @@ -229,10 +229,10 @@ end it "raises ArgumentError when no arguments are given" do - -> { @io.set_encoding() }.should raise_error(ArgumentError) + -> { @io.set_encoding() }.should.raise(ArgumentError) end it "raises ArgumentError when too many arguments are given" do - -> { @io.set_encoding(1, 2, 3) }.should raise_error(ArgumentError) + -> { @io.set_encoding(1, 2, 3) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/io/shared/binwrite.rb b/spec/ruby/core/io/shared/binwrite.rb index e51093329b45a6..64793b19365a39 100644 --- a/spec/ruby/core/io/shared/binwrite.rb +++ b/spec/ruby/core/io/shared/binwrite.rb @@ -26,7 +26,7 @@ -> { IO.send(@method, @filename, "hi", 0, {flags: File::CREAT}) - }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 2..3)") + }.should.raise(ArgumentError, "wrong number of arguments (given 4, expected 2..3)") end it "creates a file if missing" do @@ -81,7 +81,7 @@ end it "raises an error if readonly mode is specified" do - -> { IO.send(@method, @filename, "abcde", mode: "r") }.should raise_error(IOError) + -> { IO.send(@method, @filename, "abcde", mode: "r") }.should.raise(IOError) end it "truncates if empty :opts provided and offset skipped" do diff --git a/spec/ruby/core/io/shared/chars.rb b/spec/ruby/core/io/shared/chars.rb index 266566f221e295..efd4d5ee104097 100644 --- a/spec/ruby/core/io/shared/chars.rb +++ b/spec/ruby/core/io/shared/chars.rb @@ -24,7 +24,7 @@ describe "when no block is given" do it "returns an Enumerator" do enum = @io.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.first(5).should == ["V", "o", "i", "c", "i"] end @@ -38,19 +38,19 @@ end it "returns itself" do - @io.send(@method) { |c| }.should equal(@io) + @io.send(@method) { |c| }.should.equal?(@io) end it "returns an enumerator for a closed stream" do - IOSpecs.closed_io.send(@method).should be_an_instance_of(Enumerator) + IOSpecs.closed_io.send(@method).should.instance_of?(Enumerator) end it "raises an IOError when an enumerator created on a closed stream is accessed" do - -> { IOSpecs.closed_io.send(@method).first }.should raise_error(IOError) + -> { IOSpecs.closed_io.send(@method).first }.should.raise(IOError) end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.send(@method) {} }.should raise_error(IOError) + -> { IOSpecs.closed_io.send(@method) {} }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/shared/codepoints.rb b/spec/ruby/core/io/shared/codepoints.rb index 6872846c1a1092..21c756986f6830 100644 --- a/spec/ruby/core/io/shared/codepoints.rb +++ b/spec/ruby/core/io/shared/codepoints.rb @@ -13,7 +13,7 @@ describe "when no block is given" do it "returns an Enumerator" do - @enum.should be_an_instance_of(Enumerator) + @enum.should.instance_of?(Enumerator) end describe "returned Enumerator" do @@ -39,7 +39,7 @@ it "raises an error if reading invalid sequence" do @io.pos = 60 # inside of a multibyte sequence - -> { @enum.first }.should raise_error(ArgumentError) + -> { @enum.first }.should.raise(ArgumentError) end it "does not change $_" do @@ -49,6 +49,6 @@ end it "raises an IOError when self is not readable" do - -> { IOSpecs.closed_io.send(@method).to_a }.should raise_error(IOError) + -> { IOSpecs.closed_io.send(@method).to_a }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/shared/each.rb b/spec/ruby/core/io/shared/each.rb index 0747f31b8a84d3..ae60c3506aae8f 100644 --- a/spec/ruby/core/io/shared/each.rb +++ b/spec/ruby/core/io/shared/each.rb @@ -24,7 +24,7 @@ end it "returns self" do - @io.send(@method) { |l| l }.should equal(@io) + @io.send(@method) { |l| l }.should.equal?(@io) end it "does not change $_" do @@ -34,7 +34,7 @@ end it "raises an IOError when self is not readable" do - -> { IOSpecs.closed_io.send(@method) {} }.should raise_error(IOError) + -> { IOSpecs.closed_io.send(@method) {} }.should.raise(IOError) end it "makes line count accessible via lineno" do @@ -50,7 +50,7 @@ describe "when no block is given" do it "returns an Enumerator" do enum = @io.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each { |l| ScratchPad << l } ScratchPad.recorded.should == IOSpecs.lines @@ -70,12 +70,12 @@ describe "when limit is 0" do it "raises an ArgumentError" do # must pass block so Enumerator is evaluated and raises - -> { @io.send(@method, 0){} }.should raise_error(ArgumentError) + -> { @io.send(@method, 0){} }.should.raise(ArgumentError) end end it "does not accept Integers that don't fit in a C off_t" do - -> { @io.send(@method, 2**128){} }.should raise_error(RangeError) + -> { @io.send(@method, 2**128){} }.should.raise(RangeError) end end @@ -126,7 +126,7 @@ describe "when no block is given" do it "returns an Enumerator" do enum = @io.send(@method, nil, 1024) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each { |l| ScratchPad << l } ScratchPad.recorded.should == [IOSpecs.lines.join] @@ -143,7 +143,7 @@ describe "when a block is given" do it "accepts an empty block" do - @io.send(@method, nil, 1024) {}.should equal(@io) + @io.send(@method, nil, 1024) {}.should.equal?(@io) end describe "when passed nil as a separator" do @@ -179,11 +179,11 @@ it "raises exception when options passed as Hash" do -> { @io.send(@method, { chomp: true }) { |s| } - }.should raise_error(TypeError) + }.should.raise(TypeError) -> { @io.send(@method, "\n", 1, { chomp: true }) { |s| } - }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") + }.should.raise(ArgumentError, "wrong number of arguments (given 3, expected 0..2)") end end @@ -227,7 +227,7 @@ it "raises ArgumentError" do -> { @io.send(@method, "", 1, "excess argument", chomp: true) {} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/io/shared/new.rb b/spec/ruby/core/io/shared/new.rb index e84133493c8c63..6f318ddee50951 100644 --- a/spec/ruby/core/io/shared/new.rb +++ b/spec/ruby/core/io/shared/new.rb @@ -22,7 +22,7 @@ it "creates an IO instance from an Integer argument" do @io = IO.send(@method, @fd, "w") - @io.should be_an_instance_of(IO) + @io.should.instance_of?(IO) end it "creates an IO instance when STDOUT is closed" do @@ -32,7 +32,7 @@ begin @io = IO.send(@method, @fd, "w") - @io.should be_an_instance_of(IO) + @io.should.instance_of?(IO) ensure STDOUT = stdout rm_r stdout_file @@ -49,7 +49,7 @@ begin @io = IO.send(@method, @fd, "w") - @io.should be_an_instance_of(IO) + @io.should.instance_of?(IO) ensure STDERR = stderr rm_r stderr_file @@ -61,7 +61,7 @@ obj = mock("file descriptor") obj.should_receive(:to_int).and_return(@fd) @io = IO.send(@method, obj, "w") - @io.should be_an_instance_of(IO) + @io.should.instance_of?(IO) end it "accepts options as keyword arguments" do @@ -70,7 +70,7 @@ -> { IO.send(@method, @fd, "w", {flags: File::CREAT}) - }.should raise_error(ArgumentError, "wrong number of arguments (given 3, expected 1..2)") + }.should.raise(ArgumentError, "wrong number of arguments (given 3, expected 1..2)") end it "accepts a :mode option" do @@ -231,7 +231,7 @@ it "raises ArgumentError for nil options" do -> { IO.send(@method, @fd, 'w', nil) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "coerces mode with #to_str" do @@ -314,100 +314,100 @@ end it "raises an Errno::EBADF if the file descriptor is not valid" do - -> { IO.send(@method, -1, "w") }.should raise_error(Errno::EBADF) + -> { IO.send(@method, -1, "w") }.should.raise(Errno::EBADF) end it "raises an IOError if passed a closed stream" do - -> { IO.send(@method, IOSpecs.closed_io.fileno, 'w') }.should raise_error(IOError) + -> { IO.send(@method, IOSpecs.closed_io.fileno, 'w') }.should.raise(IOError) end platform_is_not :windows do it "raises an Errno::EINVAL if the new mode is not compatible with the descriptor's current mode" do - -> { IO.send(@method, @fd, "r") }.should raise_error(Errno::EINVAL) + -> { IO.send(@method, @fd, "r") }.should.raise(Errno::EINVAL) end end it "raises ArgumentError if passed an empty mode string" do - -> { IO.send(@method, @fd, "") }.should raise_error(ArgumentError) + -> { IO.send(@method, @fd, "") }.should.raise(ArgumentError) end it "raises an error if passed modes two ways" do -> { IO.send(@method, @fd, "w", mode: "w") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an error if passed encodings two ways" do -> { @io = IO.send(@method, @fd, 'w:ISO-8859-1', encoding: 'ISO-8859-1') - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, 'w:ISO-8859-1', external_encoding: 'ISO-8859-1') - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, 'w:ISO-8859-1', internal_encoding: 'ISO-8859-1') - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, 'w:ISO-8859-1:UTF-8', internal_encoding: 'ISO-8859-1') - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an error if passed matching binary/text mode two ways" do -> { @io = IO.send(@method, @fd, "wb", binmode: true) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, "wt", textmode: true) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, "wb", textmode: false) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, "wt", binmode: false) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an error if passed conflicting binary/text mode two ways" do -> { @io = IO.send(@method, @fd, "wb", binmode: false) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, "wt", textmode: false) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, "wb", textmode: true) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, "wt", binmode: true) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an error when trying to set both binmode and textmode" do -> { @io = IO.send(@method, @fd, "w", textmode: true, binmode: true) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, File::Constants::WRONLY, textmode: true, binmode: true) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises ArgumentError if not passed a hash or nil for options" do -> { @io = IO.send(@method, @fd, 'w', false) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, false, false) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = IO.send(@method, @fd, nil, false) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises ArgumentError if passed a hash for mode and nil for options" do -> { @io = IO.send(@method, @fd, {mode: 'w'}, nil) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/io/shared/pos.rb b/spec/ruby/core/io/shared/pos.rb index 3fdd3eb2b32449..f4d040586378fa 100644 --- a/spec/ruby/core/io/shared/pos.rb +++ b/spec/ruby/core/io/shared/pos.rb @@ -19,7 +19,7 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.send(@method) }.should raise_error(IOError) + -> { IOSpecs.closed_io.send(@method) }.should.raise(IOError) end it "resets #eof?" do @@ -62,17 +62,17 @@ it "raises TypeError when cannot convert implicitly argument to Integer" do File.open @fname do |io| - -> { io.send @method, Object.new }.should raise_error(TypeError, "no implicit conversion of Object into Integer") + -> { io.send @method, Object.new }.should.raise(TypeError, "no implicit conversion of Object into Integer") end end it "does not accept Integers that don't fit in a C off_t" do File.open @fname do |io| - -> { io.send @method, 2**128 }.should raise_error(RangeError) + -> { io.send @method, 2**128 }.should.raise(RangeError) end end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.send @method, 0 }.should raise_error(IOError) + -> { IOSpecs.closed_io.send @method, 0 }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/shared/readlines.rb b/spec/ruby/core/io/shared/readlines.rb index 77eb9cbd65cb8f..f54fccc2e3fe8f 100644 --- a/spec/ruby/core/io/shared/readlines.rb +++ b/spec/ruby/core/io/shared/readlines.rb @@ -1,11 +1,11 @@ describe :io_readlines, shared: true do it "raises TypeError if the first parameter is nil" do - -> { IO.send(@method, nil, &@object) }.should raise_error(TypeError) + -> { IO.send(@method, nil, &@object) }.should.raise(TypeError) end it "raises an Errno::ENOENT if the file does not exist" do name = tmp("nonexistent.txt") - -> { IO.send(@method, name, &@object) }.should raise_error(Errno::ENOENT) + -> { IO.send(@method, name, &@object) }.should.raise(Errno::ENOENT) end it "yields a single string with entire content when the separator is nil" do @@ -80,12 +80,12 @@ end it "does not accept Integers that don't fit in a C off_t" do - -> { IO.send(@method, @name, 2**128, &@object) }.should raise_error(RangeError) + -> { IO.send(@method, @name, 2**128, &@object) }.should.raise(RangeError) end describe "when passed limit" do it "raises ArgumentError when passed 0 as a limit" do - -> { IO.send(@method, @name, 0, &@object) }.should raise_error(ArgumentError) + -> { IO.send(@method, @name, 0, &@object) }.should.raise(ArgumentError) end end end @@ -106,7 +106,7 @@ it "raises TypeError exception" do -> { IO.send(@method, @name, { chomp: true }, &@object) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end @@ -116,7 +116,7 @@ -> { IO.send(@method, @name, obj, &@object) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end end @@ -170,7 +170,7 @@ -> { IO.send(@method, @name, " ", obj, &@object) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end @@ -178,7 +178,7 @@ it "raises TypeError exception" do -> { IO.send(@method, @name, "", { chomp: true }, &@object) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end end @@ -188,7 +188,7 @@ it "uses the keyword arguments as options" do -> do IO.send(@method, @filename, 10, mode: "w", &@object) - end.should raise_error(IOError) + end.should.raise(IOError) end end @@ -196,7 +196,7 @@ it "uses the keyword arguments as options" do -> do IO.send(@method, @filename, " ", mode: "w", &@object) - end.should raise_error(IOError) + end.should.raise(IOError) end end @@ -207,7 +207,7 @@ -> do IO.send(@method, @filename, sep, mode: "w", &@object) - end.should raise_error(IOError) + end.should.raise(IOError) end end end @@ -237,7 +237,7 @@ it "uses the keyword arguments as options" do -> do IO.send(@method, @filename, " ", 10, mode: "w", &@object) - end.should raise_error(IOError) + end.should.raise(IOError) end describe "when passed chomp, nil as a separator, and a limit" do diff --git a/spec/ruby/core/io/shared/tty.rb b/spec/ruby/core/io/shared/tty.rb index 89ac08ec86a49a..1dc0e95739f70e 100644 --- a/spec/ruby/core/io/shared/tty.rb +++ b/spec/ruby/core/io/shared/tty.rb @@ -19,6 +19,6 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.send @method }.should raise_error(IOError) + -> { IOSpecs.closed_io.send @method }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/shared/write.rb b/spec/ruby/core/io/shared/write.rb index 964064746a1bb3..5de9fe433526e5 100644 --- a/spec/ruby/core/io/shared/write.rb +++ b/spec/ruby/core/io/shared/write.rb @@ -23,7 +23,7 @@ end it "checks if the file is writable if writing more than zero bytes" do - -> { @readonly_file.send(@method, "abcde") }.should raise_error(IOError) + -> { @readonly_file.send(@method, "abcde") }.should.raise(IOError) end it "returns the number of bytes written" do @@ -66,7 +66,7 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.send(@method, "hello") }.should raise_error(IOError) + -> { IOSpecs.closed_io.send(@method, "hello") }.should.raise(IOError) end describe "on a pipe" do @@ -92,7 +92,7 @@ guard_not -> { defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? } do it "raises Errno::EPIPE if the read end is closed and does not die from SIGPIPE" do @r.close - -> { @w.send(@method, "foo") }.should raise_error(Errno::EPIPE, /Broken pipe/) + -> { @w.send(@method, "foo") }.should.raise(Errno::EPIPE, /Broken pipe/) end end end @@ -126,7 +126,7 @@ File.open(@transcode_filename, "w", external_encoding: Encoding::UTF_16BE) do |file| file.external_encoding.should == Encoding::UTF_16BE - -> { file.send(@method, str) }.should raise_error(Encoding::UndefinedConversionError) + -> { file.send(@method, str) }.should.raise(Encoding::UndefinedConversionError) end end end diff --git a/spec/ruby/core/io/stat_spec.rb b/spec/ruby/core/io/stat_spec.rb index 717c45d0a3fe6d..f9fc232ee002ff 100644 --- a/spec/ruby/core/io/stat_spec.rb +++ b/spec/ruby/core/io/stat_spec.rb @@ -12,14 +12,14 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.stat }.should raise_error(IOError) + -> { IOSpecs.closed_io.stat }.should.raise(IOError) end it "returns a File::Stat object for the stream" do - STDOUT.stat.should be_an_instance_of(File::Stat) + STDOUT.stat.should.instance_of?(File::Stat) end it "can stat pipes" do - @io.stat.should be_an_instance_of(File::Stat) + @io.stat.should.instance_of?(File::Stat) end end diff --git a/spec/ruby/core/io/sync_spec.rb b/spec/ruby/core/io/sync_spec.rb index 993b7ee244d88b..b537db335bb22a 100644 --- a/spec/ruby/core/io/sync_spec.rb +++ b/spec/ruby/core/io/sync_spec.rb @@ -27,7 +27,7 @@ end it "raises an IOError on closed stream" do - -> { IOSpecs.closed_io.sync = true }.should raise_error(IOError) + -> { IOSpecs.closed_io.sync = true }.should.raise(IOError) end end @@ -45,7 +45,7 @@ end it "raises an IOError on closed stream" do - -> { IOSpecs.closed_io.sync }.should raise_error(IOError) + -> { IOSpecs.closed_io.sync }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/sysopen_spec.rb b/spec/ruby/core/io/sysopen_spec.rb index 7ad379df3ab388..325d51ed23e3d6 100644 --- a/spec/ruby/core/io/sysopen_spec.rb +++ b/spec/ruby/core/io/sysopen_spec.rb @@ -13,16 +13,16 @@ it "returns the file descriptor for a given path" do @fd = IO.sysopen(@filename, "w") - @fd.should be_kind_of(Integer) - @fd.should_not equal(0) + @fd.should.is_a?(Integer) + @fd.should_not.equal?(0) end # opening a directory is not supported on Windows platform_is_not :windows do it "works on directories" do @fd = IO.sysopen(tmp("")) # /tmp - @fd.should be_kind_of(Integer) - @fd.should_not equal(0) + @fd.should.is_a?(Integer) + @fd.should_not.equal?(0) end end @@ -33,18 +33,18 @@ end it "accepts a mode as second argument" do - -> { @fd = IO.sysopen(@filename, "w") }.should_not raise_error - @fd.should_not equal(0) + -> { @fd = IO.sysopen(@filename, "w") }.should_not.raise + @fd.should_not.equal?(0) end it "accepts permissions as third argument" do @fd = IO.sysopen(@filename, "w", 777) - @fd.should_not equal(0) + @fd.should_not.equal?(0) end it "accepts mode & permission that are nil" do touch @filename # create the file @fd = IO.sysopen(@filename, nil, nil) - @fd.should_not equal(0) + @fd.should_not.equal?(0) end end diff --git a/spec/ruby/core/io/sysread_spec.rb b/spec/ruby/core/io/sysread_spec.rb index d56a27b3af3e85..2d58db22504137 100644 --- a/spec/ruby/core/io/sysread_spec.rb +++ b/spec/ruby/core/io/sysread_spec.rb @@ -52,7 +52,7 @@ it "raises an error when called after buffered reads" do @file.readline - -> { @file.sysread(5) }.should raise_error(IOError) + -> { @file.sysread(5) }.should.raise(IOError) end it "reads normally even when called immediately after a buffered IO#read" do @@ -63,13 +63,13 @@ it "does not raise error if called after IO#read followed by IO#write" do @file.read(5) @file.write("abcde") - -> { @file.sysread(5) }.should_not raise_error(IOError) + -> { @file.sysread(5) }.should_not.raise(IOError) end it "does not raise error if called after IO#read followed by IO#syswrite" do @file.read(5) @file.syswrite("abcde") - -> { @file.sysread(5) }.should_not raise_error(IOError) + -> { @file.sysread(5) }.should_not.raise(IOError) end it "reads updated content after the flushed buffered IO#write" do @@ -82,7 +82,7 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.sysread(5) }.should raise_error(IOError) + -> { IOSpecs.closed_io.sysread(5) }.should.raise(IOError) end it "immediately returns an empty string if the length argument is 0" do @@ -104,8 +104,8 @@ it "discards the existing buffer content upon error" do buffer = +"existing content" @file.seek(0, :END) - -> { @file.sysread(1, buffer) }.should raise_error(EOFError) - buffer.should be_empty + -> { @file.sysread(1, buffer) }.should.raise(EOFError) + buffer.should.empty? end it "preserves the encoding of the given buffer" do @@ -132,6 +132,6 @@ end it "raises ArgumentError when length is less than 0" do - -> { @read.sysread(-1) }.should raise_error(ArgumentError) + -> { @read.sysread(-1) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/io/sysseek_spec.rb b/spec/ruby/core/io/sysseek_spec.rb index 002f2a14ebed14..2384895dc5d8fb 100644 --- a/spec/ruby/core/io/sysseek_spec.rb +++ b/spec/ruby/core/io/sysseek_spec.rb @@ -23,7 +23,7 @@ it "raises an error when called after buffered reads" do @io.readline - -> { @io.sysseek(-5, IO::SEEK_CUR) }.should raise_error(IOError) + -> { @io.sysseek(-5, IO::SEEK_CUR) }.should.raise(IOError) end it "seeks normally even when called immediately after a buffered IO#read" do @@ -41,7 +41,7 @@ # this is the safest way of checking the EOF when # sys-* methods are invoked - -> { @io.sysread(1) }.should raise_error(EOFError) + -> { @io.sysread(1) }.should.raise(EOFError) @io.sysseek(-25, IO::SEEK_END) @io.sysread(7).should == "cinco.\n" diff --git a/spec/ruby/core/io/to_i_spec.rb b/spec/ruby/core/io/to_i_spec.rb index acf138c66309ff..1d0cf2a1f6b8b2 100644 --- a/spec/ruby/core/io/to_i_spec.rb +++ b/spec/ruby/core/io/to_i_spec.rb @@ -7,6 +7,6 @@ end it "raises IOError on closed stream" do - -> { IOSpecs.closed_io.to_i }.should raise_error(IOError) + -> { IOSpecs.closed_io.to_i }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/to_io_spec.rb b/spec/ruby/core/io/to_io_spec.rb index 55a097774048aa..0b1809dffa6fd9 100644 --- a/spec/ruby/core/io/to_io_spec.rb +++ b/spec/ruby/core/io/to_io_spec.rb @@ -11,11 +11,11 @@ end it "returns self for open stream" do - @io.to_io.should equal(@io) + @io.to_io.should.equal?(@io) end it "returns self for closed stream" do io = IOSpecs.closed_io - io.to_io.should equal(io) + io.to_io.should.equal?(io) end end diff --git a/spec/ruby/core/io/try_convert_spec.rb b/spec/ruby/core/io/try_convert_spec.rb index 820b13ab50914e..7600b01b7542ca 100644 --- a/spec/ruby/core/io/try_convert_spec.rb +++ b/spec/ruby/core/io/try_convert_spec.rb @@ -13,7 +13,7 @@ end it "returns the passed IO object" do - IO.try_convert(@io).should equal(@io) + IO.try_convert(@io).should.equal?(@io) end it "does not call #to_io on an IO instance" do @@ -24,15 +24,15 @@ it "calls #to_io to coerce an object" do obj = mock("io") obj.should_receive(:to_io).and_return(@io) - IO.try_convert(obj).should equal(@io) + IO.try_convert(obj).should.equal?(@io) end it "returns nil when the passed object does not respond to #to_io" do - IO.try_convert(mock("io")).should be_nil + IO.try_convert(mock("io")).should == nil end it "return nil when BasicObject is passed" do - IO.try_convert(BasicObject.new).should be_nil + IO.try_convert(BasicObject.new).should == nil end it "raises a TypeError if the object does not return an IO from #to_io" do @@ -44,6 +44,6 @@ it "propagates an exception raised by #to_io" do obj = mock("io") obj.should_receive(:to_io).and_raise(TypeError.new) - ->{ IO.try_convert(obj) }.should raise_error(TypeError) + ->{ IO.try_convert(obj) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/io/ungetbyte_spec.rb b/spec/ruby/core/io/ungetbyte_spec.rb index 716743a6aff0f9..e0615cd76c9253 100644 --- a/spec/ruby/core/io/ungetbyte_spec.rb +++ b/spec/ruby/core/io/ungetbyte_spec.rb @@ -13,12 +13,12 @@ end it "does nothing when passed nil" do - @io.ungetbyte(nil).should be_nil + @io.ungetbyte(nil).should == nil @io.getbyte.should == 97 end it "puts back each byte in a String argument" do - @io.ungetbyte("cat").should be_nil + @io.ungetbyte("cat").should == nil @io.getbyte.should == 99 @io.getbyte.should == 97 @io.getbyte.should == 116 @@ -29,7 +29,7 @@ str = mock("io ungetbyte") str.should_receive(:to_str).and_return("dog") - @io.ungetbyte(str).should be_nil + @io.ungetbyte(str).should == nil @io.getbyte.should == 100 @io.getbyte.should == 111 @io.getbyte.should == 103 @@ -38,17 +38,17 @@ it "never raises RangeError" do for i in [4095, 0x4f7574206f6620636861722072616e67ff] do - @io.ungetbyte(i).should be_nil + @io.ungetbyte(i).should == nil @io.getbyte.should == 255 end end it "raises IOError on stream not opened for reading" do - -> { STDOUT.ungetbyte(42) }.should raise_error(IOError, "not opened for reading") + -> { STDOUT.ungetbyte(42) }.should.raise(IOError, "not opened for reading") end it "raises an IOError if the IO is closed" do @io.close - -> { @io.ungetbyte(42) }.should raise_error(IOError) + -> { @io.ungetbyte(42) }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/ungetc_spec.rb b/spec/ruby/core/io/ungetc_spec.rb index 47a4e99ebf499a..4a9e67f126b505 100644 --- a/spec/ruby/core/io/ungetc_spec.rb +++ b/spec/ruby/core/io/ungetc_spec.rb @@ -100,17 +100,17 @@ it "makes subsequent unbuffered operations to raise IOError" do @io.getc @io.ungetc(100) - -> { @io.sysread(1) }.should raise_error(IOError) + -> { @io.sysread(1) }.should.raise(IOError) end it "raises TypeError if passed nil" do @io.getc.should == ?V - proc{@io.ungetc(nil)}.should raise_error(TypeError) + proc{@io.ungetc(nil)}.should.raise(TypeError) end it "puts one or more characters back in the stream" do @io.gets - @io.ungetc("Aquí ").should be_nil + @io.ungetc("Aquí ").should == nil @io.gets.chomp.should == "Aquí Qui è la linea due." end @@ -118,21 +118,21 @@ chars = mock("io ungetc") chars.should_receive(:to_str).and_return("Aquí ") - @io.ungetc(chars).should be_nil + @io.ungetc(chars).should == nil @io.gets.chomp.should == "Aquí Voici la ligne une." end it "returns nil when invoked on stream that was not yet read" do - @io.ungetc(100).should be_nil + @io.ungetc(100).should == nil end it "raises IOError on stream not opened for reading" do - -> { STDOUT.ungetc(100) }.should raise_error(IOError, "not opened for reading") + -> { STDOUT.ungetc(100) }.should.raise(IOError, "not opened for reading") end it "raises IOError on closed stream" do @io.getc @io.close - -> { @io.ungetc(100) }.should raise_error(IOError) + -> { @io.ungetc(100) }.should.raise(IOError) end end diff --git a/spec/ruby/core/io/write_nonblock_spec.rb b/spec/ruby/core/io/write_nonblock_spec.rb index 5bfc690f9bab3d..a6bd43c0581bb6 100644 --- a/spec/ruby/core/io/write_nonblock_spec.rb +++ b/spec/ruby/core/io/write_nonblock_spec.rb @@ -44,7 +44,7 @@ it "checks if the file is writable if writing zero bytes" do -> { @readonly_file.write_nonblock("") - }.should raise_error(IOError) + }.should.raise(IOError) end end @@ -67,12 +67,12 @@ it "raises an exception extending IO::WaitWritable when the write would block" do -> { loop { @write.write_nonblock('a' * 10_000) } - }.should raise_error(IO::WaitWritable) { |e| + }.should.raise(IO::WaitWritable) { |e| platform_is_not :windows do - e.should be_kind_of(Errno::EAGAIN) + e.should.is_a?(Errno::EAGAIN) end platform_is :windows do - e.should be_kind_of(Errno::EWOULDBLOCK) + e.should.is_a?(Errno::EWOULDBLOCK) end } end diff --git a/spec/ruby/core/io/write_spec.rb b/spec/ruby/core/io/write_spec.rb index 95e6371985bf7c..1a745ba0124fce 100644 --- a/spec/ruby/core/io/write_spec.rb +++ b/spec/ruby/core/io/write_spec.rb @@ -21,7 +21,7 @@ end it "does not check if the file is writable if writing zero bytes" do - -> { @readonly_file.write("") }.should_not raise_error + -> { @readonly_file.write("") }.should_not.raise end before :each do @@ -113,7 +113,7 @@ # pack "\xFEhi" to avoid utf-8 conflict xFEhi = ([254].pack('C*') + 'hi').force_encoding('utf-8') File.open(@filename, "w", encoding: Encoding::US_ASCII) do |file| - -> { file.write(xFEhi) }.should raise_error(Encoding::InvalidByteSequenceError) + -> { file.write(xFEhi) }.should.raise(Encoding::InvalidByteSequenceError) end end @@ -157,7 +157,7 @@ it "requires mode to be specified in :open_args" do -> { IO.write(@filename, 'hi', open_args: [{encoding: Encoding::UTF_32LE, binmode: true}]) - }.should raise_error(IOError, "not opened for writing") + }.should.raise(IOError, "not opened for writing") IO.write(@filename, 'hi', open_args: ["w", {encoding: Encoding::UTF_32LE, binmode: true}]).should == 8 IO.write(@filename, 'hi', open_args: [{encoding: Encoding::UTF_32LE, binmode: true, mode: "w"}]).should == 8 @@ -166,7 +166,7 @@ it "requires mode to be specified in :open_args even if flags option passed" do -> { IO.write(@filename, 'hi', open_args: [{encoding: Encoding::UTF_32LE, binmode: true, flags: File::CREAT}]) - }.should raise_error(IOError, "not opened for writing") + }.should.raise(IOError, "not opened for writing") IO.write(@filename, 'hi', open_args: ["w", {encoding: Encoding::UTF_32LE, binmode: true, flags: File::CREAT}]).should == 8 IO.write(@filename, 'hi', open_args: [{encoding: Encoding::UTF_32LE, binmode: true, flags: File::CREAT, mode: "w"}]).should == 8 @@ -179,11 +179,11 @@ it "raises ArgumentError if encoding is specified in mode parameter and is given as :encoding option" do -> { IO.write(@filename, 'hi', mode: "w:UTF-16LE:UTF-16BE", encoding: Encoding::UTF_32LE) - }.should raise_error(ArgumentError, "encoding specified twice") + }.should.raise(ArgumentError, "encoding specified twice") -> { IO.write(@filename, 'hi', mode: "w:UTF-16BE", encoding: Encoding::UTF_32LE) - }.should raise_error(ArgumentError, "encoding specified twice") + }.should.raise(ArgumentError, "encoding specified twice") end it "writes the file with the permissions in the :perm parameter" do diff --git a/spec/ruby/core/kernel/Array_spec.rb b/spec/ruby/core/kernel/Array_spec.rb index b4a8bb759914e4..063faf7097134d 100644 --- a/spec/ruby/core/kernel/Array_spec.rb +++ b/spec/ruby/core/kernel/Array_spec.rb @@ -3,7 +3,7 @@ describe "Kernel" do it "has private instance method Array()" do - Kernel.should have_private_instance_method(:Array) + Kernel.private_instance_methods(false).should.include?(:Array) end end @@ -77,14 +77,14 @@ obj = mock("Array() string") obj.should_receive(:to_ary).and_return("string") - -> { @object.send(@method, obj) }.should raise_error(TypeError) + -> { @object.send(@method, obj) }.should.raise(TypeError) end it "raises a TypeError if #to_a does not return an Array" do obj = mock("Array() string") obj.should_receive(:to_a).and_return("string") - -> { @object.send(@method, obj) }.should raise_error(TypeError) + -> { @object.send(@method, obj) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/kernel/Complex_spec.rb b/spec/ruby/core/kernel/Complex_spec.rb index 346d50ab5e5116..92ce183cc8bef0 100644 --- a/spec/ruby/core/kernel/Complex_spec.rb +++ b/spec/ruby/core/kernel/Complex_spec.rb @@ -19,19 +19,19 @@ describe "when passed [Integer, Integer]" do it "returns a new Complex number" do - Complex(1, 2).should be_an_instance_of(Complex) + Complex(1, 2).should.instance_of?(Complex) Complex(1, 2).real.should == 1 Complex(1, 2).imag.should == 2 - Complex(-3, -5).should be_an_instance_of(Complex) + Complex(-3, -5).should.instance_of?(Complex) Complex(-3, -5).real.should == -3 Complex(-3, -5).imag.should == -5 - Complex(3.5, -4.5).should be_an_instance_of(Complex) + Complex(3.5, -4.5).should.instance_of?(Complex) Complex(3.5, -4.5).real.should == 3.5 Complex(3.5, -4.5).imag.should == -4.5 - Complex(bignum_value, 30).should be_an_instance_of(Complex) + Complex(bignum_value, 30).should.instance_of?(Complex) Complex(bignum_value, 30).real.should == bignum_value Complex(bignum_value, 30).imag.should == 30 end @@ -41,19 +41,19 @@ it "returns a new Complex number with 0 as the imaginary component" do # Guard against the Mathn library guard -> { !defined?(Math.rsqrt) } do - Complex(1).should be_an_instance_of(Complex) + Complex(1).should.instance_of?(Complex) Complex(1).imag.should == 0 Complex(1).real.should == 1 - Complex(-3).should be_an_instance_of(Complex) + Complex(-3).should.instance_of?(Complex) Complex(-3).imag.should == 0 Complex(-3).real.should == -3 - Complex(-4.5).should be_an_instance_of(Complex) + Complex(-4.5).should.instance_of?(Complex) Complex(-4.5).imag.should == 0 Complex(-4.5).real.should == -4.5 - Complex(bignum_value).should be_an_instance_of(Complex) + Complex(bignum_value).should.instance_of?(Complex) Complex(bignum_value).imag.should == 0 Complex(bignum_value).real.should == bignum_value end @@ -67,47 +67,47 @@ it "raises Encoding::CompatibilityError if String is in not ASCII-compatible encoding" do -> { Complex("79+4i".encode("UTF-16")) - }.should raise_error(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16") + }.should.raise(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16") end it "raises ArgumentError for unrecognised Strings" do -> { Complex("ruby") - }.should raise_error(ArgumentError, 'invalid value for convert(): "ruby"') + }.should.raise(ArgumentError, 'invalid value for convert(): "ruby"') end it "raises ArgumentError for trailing garbage" do -> { Complex("79+4iruby") - }.should raise_error(ArgumentError, 'invalid value for convert(): "79+4iruby"') + }.should.raise(ArgumentError, 'invalid value for convert(): "79+4iruby"') end it "does not understand Float::INFINITY" do -> { Complex("Infinity") - }.should raise_error(ArgumentError, 'invalid value for convert(): "Infinity"') + }.should.raise(ArgumentError, 'invalid value for convert(): "Infinity"') -> { Complex("-Infinity") - }.should raise_error(ArgumentError, 'invalid value for convert(): "-Infinity"') + }.should.raise(ArgumentError, 'invalid value for convert(): "-Infinity"') end it "does not understand Float::NAN" do -> { Complex("NaN") - }.should raise_error(ArgumentError, 'invalid value for convert(): "NaN"') + }.should.raise(ArgumentError, 'invalid value for convert(): "NaN"') end it "does not understand a sequence of _" do -> { Complex("7__9+4__0i") - }.should raise_error(ArgumentError, 'invalid value for convert(): "7__9+4__0i"') + }.should.raise(ArgumentError, 'invalid value for convert(): "7__9+4__0i"') end it "does not allow null-byte" do -> { Complex("1-2i\0") - }.should raise_error(ArgumentError, "string contains null byte") + }.should.raise(ArgumentError, "string contains null byte") end end @@ -115,7 +115,7 @@ it "raises Encoding::CompatibilityError if String is in not ASCII-compatible encoding" do -> { Complex("79+4i".encode("UTF-16"), exception: false) - }.should raise_error(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16") + }.should.raise(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16") end it "returns nil for unrecognised Strings" do @@ -160,7 +160,7 @@ it "returns the passed argument" do n = mock_numeric("unreal") n.should_receive(:real?).any_number_of_times.and_return(false) - Complex(n).should equal(n) + Complex(n).should.equal?(n) end end @@ -169,8 +169,8 @@ n = mock_numeric("real") n.should_receive(:real?).any_number_of_times.and_return(true) result = Complex(n) - result.real.should equal(n) - result.imag.should equal(0) + result.real.should.equal?(n) + result.imag.should.equal?(0) end end @@ -185,7 +185,7 @@ n2.should_receive(:real?).any_number_of_times.and_return(r2) n2.should_receive(:*).with(Complex(0, 1)).and_return(n3) n1.should_receive(:+).with(n3).and_return(n4) - Complex(n1, n2).should equal(n4) + Complex(n1, n2).should.equal?(n4) end end end @@ -197,8 +197,8 @@ n1.should_receive(:real?).any_number_of_times.and_return(true) n2.should_receive(:real?).any_number_of_times.and_return(true) result = Complex(n1, n2) - result.real.should equal(n1) - result.imag.should equal(n2) + result.real.should.equal?(n1) + result.imag.should.equal?(n2) end end @@ -207,22 +207,22 @@ n = mock("n") c = Complex(0, 0) n.should_receive(:to_c).and_return(c) - Complex(n).should equal(c) + Complex(n).should.equal?(c) end end describe "when passed a non-Numeric second argument" do it "raises TypeError" do - -> { Complex(:sym, :sym) }.should raise_error(TypeError) - -> { Complex(0, :sym) }.should raise_error(TypeError) + -> { Complex(:sym, :sym) }.should.raise(TypeError) + -> { Complex(0, :sym) }.should.raise(TypeError) end end describe "when passed nil" do it "raises TypeError" do - -> { Complex(nil) }.should raise_error(TypeError, "can't convert nil into Complex") - -> { Complex(0, nil) }.should raise_error(TypeError, "can't convert nil into Complex") - -> { Complex(nil, 0) }.should raise_error(TypeError, "can't convert nil into Complex") + -> { Complex(nil) }.should.raise(TypeError, "can't convert nil into Complex") + -> { Complex(0, nil) }.should.raise(TypeError, "can't convert nil into Complex") + -> { Complex(nil, 0) }.should.raise(TypeError, "can't convert nil into Complex") end end @@ -241,7 +241,7 @@ describe "and [non-Numeric, Numeric] argument" do it "throws a TypeError" do - -> { Complex(:sym, 0, exception: false) }.should raise_error(TypeError, "not a real") + -> { Complex(:sym, 0, exception: false) }.should.raise(TypeError, "not a real") end end diff --git a/spec/ruby/core/kernel/Float_spec.rb b/spec/ruby/core/kernel/Float_spec.rb index 9c436b05f73012..f5566067ba8173 100644 --- a/spec/ruby/core/kernel/Float_spec.rb +++ b/spec/ruby/core/kernel/Float_spec.rb @@ -6,7 +6,7 @@ float = 1.12 float2 = @object.send(:Float, float) float2.should == float - float2.should equal float + float2.should.equal? float end it "returns a Float for Fixnums" do @@ -22,22 +22,22 @@ end it "raises an ArgumentError for nil" do - -> { @object.send(:Float, nil) }.should raise_error(TypeError) + -> { @object.send(:Float, nil) }.should.raise(TypeError) end it "returns the identical NaN for NaN" do nan = nan_value - nan.nan?.should be_true + nan.nan?.should == true nan2 = @object.send(:Float, nan) - nan2.nan?.should be_true - nan2.should equal(nan) + nan2.nan?.should == true + nan2.should.equal?(nan) end it "returns the same Infinity for Infinity" do infinity = infinity_value infinity2 = @object.send(:Float, infinity) infinity2.should == infinity_value - infinity.should equal(infinity2) + infinity.should.equal?(infinity2) end it "converts Strings to floats without calling #to_f" do @@ -51,30 +51,30 @@ end it "raises an ArgumentError for a String of word characters" do - -> { @object.send(:Float, "float") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "float") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String with string in error message" do - -> { @object.send(:Float, "foo") }.should raise_error(ArgumentError) { |e| + -> { @object.send(:Float, "foo") }.should.raise(ArgumentError) { |e| e.message.should == 'invalid value for Float(): "foo"' } end it "raises an ArgumentError if there are two decimal points in the String" do - -> { @object.send(:Float, "10.0.0") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "10.0.0") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String of numbers followed by word characters" do - -> { @object.send(:Float, "10D") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "10D") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String of word characters followed by numbers" do - -> { @object.send(:Float, "D10") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "D10") }.should.raise(ArgumentError) end it "is strict about the string form even across newlines" do - -> { @object.send(:Float, "not a number\n10") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "10\nnot a number") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "not a number\n10") }.should.raise(ArgumentError) + -> { @object.send(:Float, "10\nnot a number") }.should.raise(ArgumentError) end it "converts String subclasses to floats without calling #to_f" do @@ -96,17 +96,17 @@ def to_f() 1.2 end end it "raises an ArgumentError if a + or - is embedded in a String" do - -> { @object.send(:Float, "1+1") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "1-1") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "1+1") }.should.raise(ArgumentError) + -> { @object.send(:Float, "1-1") }.should.raise(ArgumentError) end it "raises an ArgumentError if a String has a trailing + or -" do - -> { @object.send(:Float, "11+") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "11-") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "11+") }.should.raise(ArgumentError) + -> { @object.send(:Float, "11-") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String with a leading _" do - -> { @object.send(:Float, "_1") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "_1") }.should.raise(ArgumentError) end it "returns a value for a String with an embedded _" do @@ -114,31 +114,31 @@ def to_f() 1.2 end end it "raises an ArgumentError for a String with a trailing _" do - -> { @object.send(:Float, "10_") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "10_") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String of \\0" do - -> { @object.send(:Float, "\0") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "\0") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String with a leading \\0" do - -> { @object.send(:Float, "\01") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "\01") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String with an embedded \\0" do - -> { @object.send(:Float, "1\01") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "1\01") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String with a trailing \\0" do - -> { @object.send(:Float, "1\0") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "1\0") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String that is just an empty space" do - -> { @object.send(:Float, " ") }.should raise_error(ArgumentError) + -> { @object.send(:Float, " ") }.should.raise(ArgumentError) end it "raises an ArgumentError for a String that with an embedded space" do - -> { @object.send(:Float, "1 2") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "1 2") }.should.raise(ArgumentError) end it "returns a value for a String with a leading space" do @@ -159,11 +159,11 @@ def to_f() 1.2 end ruby_version_is ""..."3.4" do it "raises ArgumentError if a fractional part is missing" do - -> { @object.send(:Float, "1.") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "+1.") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "-1.") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "1.e+0") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "1.e-2") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "1.") }.should.raise(ArgumentError) + -> { @object.send(:Float, "+1.") }.should.raise(ArgumentError) + -> { @object.send(:Float, "-1.") }.should.raise(ArgumentError) + -> { @object.send(:Float, "1.e+0") }.should.raise(ArgumentError) + -> { @object.send(:Float, "1.e-2") }.should.raise(ArgumentError) end end @@ -179,11 +179,11 @@ def to_f() 1.2 end %w(e E).each do |e| it "raises an ArgumentError if #{e} is the trailing character" do - -> { @object.send(:Float, "2#{e}") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "2#{e}") }.should.raise(ArgumentError) end it "raises an ArgumentError if #{e} is the leading character" do - -> { @object.send(:Float, "#{e}2") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "#{e}2") }.should.raise(ArgumentError) end it "returns Infinity for '2#{e}1000'" do @@ -201,18 +201,18 @@ def to_f() 1.2 end end it "raises an exception if a space is embedded on either side of the '#{e}'" do - -> { @object.send(:Float, "2 0#{e}100") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "20#{e}1 00") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "2 0#{e}100") }.should.raise(ArgumentError) + -> { @object.send(:Float, "20#{e}1 00") }.should.raise(ArgumentError) end it "raises an exception if there's a leading _ on either side of the '#{e}'" do - -> { @object.send(:Float, "_20#{e}100") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "20#{e}_100") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "_20#{e}100") }.should.raise(ArgumentError) + -> { @object.send(:Float, "20#{e}_100") }.should.raise(ArgumentError) end it "raises an exception if there's a trailing _ on either side of the '#{e}'" do - -> { @object.send(:Float, "20_#{e}100") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "20#{e}100_") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "20_#{e}100") }.should.raise(ArgumentError) + -> { @object.send(:Float, "20#{e}100_") }.should.raise(ArgumentError) end it "allows decimal points on the left side of the '#{e}'" do @@ -220,7 +220,7 @@ def to_f() 1.2 end end it "raises an ArgumentError if there's a decimal point on the right side of the '#{e}'" do - -> { @object.send(:Float, "20#{e}2.0") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "20#{e}2.0") }.should.raise(ArgumentError) end end @@ -241,8 +241,8 @@ def to_f() 1.2 end ruby_version_is ""..."3.4.3" do it "does not accept embedded _ if the number contains a-f" do - -> { @object.send(:Float, "0x1_0a") }.should raise_error(ArgumentError) - @object.send(:Float, "0x1_0a", exception: false).should be_nil + -> { @object.send(:Float, "0x1_0a") }.should.raise(ArgumentError) + @object.send(:Float, "0x1_0a", exception: false).should == nil end end @@ -253,12 +253,12 @@ def to_f() 1.2 end end it "does not accept _ before, after or inside the 0x prefix" do - -> { @object.send(:Float, "_0x10") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "0_x10") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "0x_10") }.should raise_error(ArgumentError) - @object.send(:Float, "_0x10", exception: false).should be_nil - @object.send(:Float, "0_x10", exception: false).should be_nil - @object.send(:Float, "0x_10", exception: false).should be_nil + -> { @object.send(:Float, "_0x10") }.should.raise(ArgumentError) + -> { @object.send(:Float, "0_x10") }.should.raise(ArgumentError) + -> { @object.send(:Float, "0x_10") }.should.raise(ArgumentError) + @object.send(:Float, "_0x10", exception: false).should == nil + @object.send(:Float, "0_x10", exception: false).should == nil + @object.send(:Float, "0x_10", exception: false).should == nil end it "parses negative hexadecimal string as negative float" do @@ -282,11 +282,11 @@ def to_f() 1.2 end end it "raises an ArgumentError if #{p} is the trailing character" do - -> { @object.send(:Float, "0x1#{p}") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "0x1#{p}") }.should.raise(ArgumentError) end it "raises an ArgumentError if #{p} is the leading character" do - -> { @object.send(:Float, "0x#{p}1") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "0x#{p}1") }.should.raise(ArgumentError) end it "returns Infinity for '0x1#{p}10000'" do @@ -304,18 +304,18 @@ def to_f() 1.2 end end it "raises an exception if a space is embedded on either side of the '#{p}'" do - -> { @object.send(:Float, "0x1 0#{p}10") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "0x10#{p}1 0") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "0x1 0#{p}10") }.should.raise(ArgumentError) + -> { @object.send(:Float, "0x10#{p}1 0") }.should.raise(ArgumentError) end it "raises an exception if there's a leading _ on either side of the '#{p}'" do - -> { @object.send(:Float, "0x_10#{p}10") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "0x10#{p}_10") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "0x_10#{p}10") }.should.raise(ArgumentError) + -> { @object.send(:Float, "0x10#{p}_10") }.should.raise(ArgumentError) end it "raises an exception if there's a trailing _ on either side of the '#{p}'" do - -> { @object.send(:Float, "0x10_#{p}10") }.should raise_error(ArgumentError) - -> { @object.send(:Float, "0x10#{p}10_") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "0x10_#{p}10") }.should.raise(ArgumentError) + -> { @object.send(:Float, "0x10#{p}10_") }.should.raise(ArgumentError) end it "allows hexadecimal points on the left side of the '#{p}'" do @@ -323,7 +323,7 @@ def to_f() 1.2 end end it "raises an ArgumentError if there's a decimal point on the right side of the '#{p}'" do - -> { @object.send(:Float, "0x1#{p}1.0") }.should raise_error(ArgumentError) + -> { @object.send(:Float, "0x1#{p}1.0") }.should.raise(ArgumentError) end end end @@ -344,34 +344,34 @@ def to_f() 1.2 end nan = nan_value (nan_to_f = mock('NaN')).should_receive(:to_f).once.and_return(nan) nan2 = @object.send(:Float, nan_to_f) - nan2.nan?.should be_true - nan2.should equal(nan) + nan2.nan?.should == true + nan2.should.equal?(nan) end it "returns the identical Infinity if #to_f is called and it returns Infinity" do infinity = infinity_value (infinity_to_f = mock('Infinity')).should_receive(:to_f).once.and_return(infinity) infinity2 = @object.send(:Float, infinity_to_f) - infinity2.should equal(infinity) + infinity2.should.equal?(infinity) end it "raises a TypeError if #to_f is not provided" do - -> { @object.send(:Float, mock('x')) }.should raise_error(TypeError) + -> { @object.send(:Float, mock('x')) }.should.raise(TypeError) end it "raises a TypeError if #to_f returns a String" do (obj = mock('ha!')).should_receive(:to_f).once.and_return('ha!') - -> { @object.send(:Float, obj) }.should raise_error(TypeError) + -> { @object.send(:Float, obj) }.should.raise(TypeError) end it "raises a TypeError if #to_f returns an Integer" do (obj = mock('123')).should_receive(:to_f).once.and_return(123) - -> { @object.send(:Float, obj) }.should raise_error(TypeError) + -> { @object.send(:Float, obj) }.should.raise(TypeError) end it "raises a RangeError when passed a Complex argument" do c = Complex(2, 3) - -> { @object.send(:Float, c) }.should raise_error(RangeError) + -> { @object.send(:Float, c) }.should.raise(RangeError) end describe "when passed exception: false" do @@ -408,6 +408,6 @@ def to_f() 1.2 end describe "Kernel#Float" do it "is a private method" do - Kernel.should have_private_instance_method(:Float) + Kernel.private_instance_methods(false).should.include?(:Float) end end diff --git a/spec/ruby/core/kernel/Hash_spec.rb b/spec/ruby/core/kernel/Hash_spec.rb index cbe098a8ac247a..ee16f56a90e8d9 100644 --- a/spec/ruby/core/kernel/Hash_spec.rb +++ b/spec/ruby/core/kernel/Hash_spec.rb @@ -13,7 +13,7 @@ describe "Kernel" do it "has private instance method Hash()" do - Kernel.should have_private_instance_method(:Hash) + Kernel.private_instance_methods(false).should.include?(:Hash) end end @@ -43,14 +43,14 @@ end it "raises a TypeError if it doesn't respond to #to_hash" do - -> { @object.send(@method, mock("")) }.should raise_error(TypeError) + -> { @object.send(@method, mock("")) }.should.raise(TypeError) end it "raises a TypeError if #to_hash does not return an Hash" do obj = mock("Hash() string") obj.should_receive(:to_hash).and_return("string") - -> { @object.send(@method, obj) }.should raise_error(TypeError) + -> { @object.send(@method, obj) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/kernel/Integer_spec.rb b/spec/ruby/core/kernel/Integer_spec.rb index c62b8b08013898..f61cca74633fcf 100644 --- a/spec/ruby/core/kernel/Integer_spec.rb +++ b/spec/ruby/core/kernel/Integer_spec.rb @@ -14,7 +14,7 @@ obj = mock("object") obj.should_receive(:to_int).and_return("1") obj.should_receive(:to_i).and_return(nil) - -> { Integer(obj) }.should raise_error(TypeError) + -> { Integer(obj) }.should.raise(TypeError) end it "return a result of to_i when to_int does not return an Integer" do @@ -25,12 +25,12 @@ end it "raises a TypeError when passed nil" do - -> { Integer(nil) }.should raise_error(TypeError) + -> { Integer(nil) }.should.raise(TypeError) end it "returns an Integer object" do - Integer(2).should be_an_instance_of(Integer) - Integer(9**99).should be_an_instance_of(Integer) + Integer(2).should.instance_of?(Integer) + Integer(9**99).should.instance_of?(Integer) end it "truncates Floats" do @@ -67,26 +67,26 @@ it "raises a TypeError if to_i returns a value that is not an Integer" do obj = mock("object") obj.should_receive(:to_i).and_return("1") - -> { Integer(obj) }.should raise_error(TypeError) + -> { Integer(obj) }.should.raise(TypeError) end it "raises a TypeError if no to_int or to_i methods exist" do obj = mock("object") - -> { Integer(obj) }.should raise_error(TypeError) + -> { Integer(obj) }.should.raise(TypeError) end it "raises a TypeError if to_int returns nil and no to_i exists" do obj = mock("object") obj.should_receive(:to_i).and_return(nil) - -> { Integer(obj) }.should raise_error(TypeError) + -> { Integer(obj) }.should.raise(TypeError) end it "raises a FloatDomainError when passed NaN" do - -> { Integer(nan_value) }.should raise_error(FloatDomainError) + -> { Integer(nan_value) }.should.raise(FloatDomainError) end it "raises a FloatDomainError when passed Infinity" do - -> { Integer(infinity_value) }.should raise_error(FloatDomainError) + -> { Integer(infinity_value) }.should.raise(FloatDomainError) end describe "when passed exception: false" do @@ -147,19 +147,19 @@ describe :kernel_integer_string, shared: true do it "raises an ArgumentError if the String is a null byte" do - -> { Integer("\0") }.should raise_error(ArgumentError) + -> { Integer("\0") }.should.raise(ArgumentError) end it "raises an ArgumentError if the String starts with a null byte" do - -> { Integer("\01") }.should raise_error(ArgumentError) + -> { Integer("\01") }.should.raise(ArgumentError) end it "raises an ArgumentError if the String ends with a null byte" do - -> { Integer("1\0") }.should raise_error(ArgumentError) + -> { Integer("1\0") }.should.raise(ArgumentError) end it "raises an ArgumentError if the String contains a null byte" do - -> { Integer("1\01") }.should raise_error(ArgumentError) + -> { Integer("1\01") }.should.raise(ArgumentError) end it "ignores leading whitespace" do @@ -175,13 +175,13 @@ end it "raises an ArgumentError if there are leading _s" do - -> { Integer("_1") }.should raise_error(ArgumentError) - -> { Integer("___1") }.should raise_error(ArgumentError) + -> { Integer("_1") }.should.raise(ArgumentError) + -> { Integer("___1") }.should.raise(ArgumentError) end it "raises an ArgumentError if there are trailing _s" do - -> { Integer("1_") }.should raise_error(ArgumentError) - -> { Integer("1___") }.should raise_error(ArgumentError) + -> { Integer("1_") }.should.raise(ArgumentError) + -> { Integer("1___") }.should.raise(ArgumentError) end it "ignores an embedded _" do @@ -189,8 +189,8 @@ end it "raises an ArgumentError if there are multiple embedded _s" do - -> { Integer("1__1") }.should raise_error(ArgumentError) - -> { Integer("1___1") }.should raise_error(ArgumentError) + -> { Integer("1__1") }.should.raise(ArgumentError) + -> { Integer("1___1") }.should.raise(ArgumentError) end it "ignores a single leading +" do @@ -198,17 +198,17 @@ end it "raises an ArgumentError if there is a space between the + and number" do - -> { Integer("+ 1") }.should raise_error(ArgumentError) + -> { Integer("+ 1") }.should.raise(ArgumentError) end it "raises an ArgumentError if there are multiple leading +s" do - -> { Integer("++1") }.should raise_error(ArgumentError) - -> { Integer("+++1") }.should raise_error(ArgumentError) + -> { Integer("++1") }.should.raise(ArgumentError) + -> { Integer("+++1") }.should.raise(ArgumentError) end it "raises an ArgumentError if there are trailing +s" do - -> { Integer("1+") }.should raise_error(ArgumentError) - -> { Integer("1+++") }.should raise_error(ArgumentError) + -> { Integer("1+") }.should.raise(ArgumentError) + -> { Integer("1+++") }.should.raise(ArgumentError) end it "makes the number negative if there's a leading -" do @@ -216,21 +216,21 @@ end it "raises an ArgumentError if there are multiple leading -s" do - -> { Integer("--1") }.should raise_error(ArgumentError) - -> { Integer("---1") }.should raise_error(ArgumentError) + -> { Integer("--1") }.should.raise(ArgumentError) + -> { Integer("---1") }.should.raise(ArgumentError) end it "raises an ArgumentError if there are trailing -s" do - -> { Integer("1-") }.should raise_error(ArgumentError) - -> { Integer("1---") }.should raise_error(ArgumentError) + -> { Integer("1-") }.should.raise(ArgumentError) + -> { Integer("1---") }.should.raise(ArgumentError) end it "raises an ArgumentError if there is a period" do - -> { Integer("0.0") }.should raise_error(ArgumentError) + -> { Integer("0.0") }.should.raise(ArgumentError) end it "raises an ArgumentError for an empty String" do - -> { Integer("") }.should raise_error(ArgumentError) + -> { Integer("") }.should.raise(ArgumentError) end describe "when passed exception: false" do @@ -280,7 +280,7 @@ end it "raises an ArgumentError if the number cannot be parsed as hex" do - -> { Integer("0#{x}g") }.should raise_error(ArgumentError) + -> { Integer("0#{x}g") }.should.raise(ArgumentError) end end @@ -301,7 +301,7 @@ end it "raises an ArgumentError if the number cannot be parsed as binary" do - -> { Integer("0#{b}2") }.should raise_error(ArgumentError) + -> { Integer("0#{b}2") }.should.raise(ArgumentError) end end @@ -322,7 +322,7 @@ end it "raises an ArgumentError if the number cannot be parsed as octal" do - -> { Integer("0#{o}9") }.should raise_error(ArgumentError) + -> { Integer("0#{o}9") }.should.raise(ArgumentError) end end @@ -343,26 +343,26 @@ end it "raises an ArgumentError if the number cannot be parsed as decimal" do - -> { Integer("0#{d}a") }.should raise_error(ArgumentError) + -> { Integer("0#{d}a") }.should.raise(ArgumentError) end end end describe :kernel_integer_string_base, shared: true do it "raises an ArgumentError if the String is a null byte" do - -> { Integer("\0", 2) }.should raise_error(ArgumentError) + -> { Integer("\0", 2) }.should.raise(ArgumentError) end it "raises an ArgumentError if the String starts with a null byte" do - -> { Integer("\01", 3) }.should raise_error(ArgumentError) + -> { Integer("\01", 3) }.should.raise(ArgumentError) end it "raises an ArgumentError if the String ends with a null byte" do - -> { Integer("1\0", 4) }.should raise_error(ArgumentError) + -> { Integer("1\0", 4) }.should.raise(ArgumentError) end it "raises an ArgumentError if the String contains a null byte" do - -> { Integer("1\01", 5) }.should raise_error(ArgumentError) + -> { Integer("1\01", 5) }.should.raise(ArgumentError) end it "ignores leading whitespace" do @@ -378,13 +378,13 @@ end it "raises an ArgumentError if there are leading _s" do - -> { Integer("_1", 7) }.should raise_error(ArgumentError) - -> { Integer("___1", 7) }.should raise_error(ArgumentError) + -> { Integer("_1", 7) }.should.raise(ArgumentError) + -> { Integer("___1", 7) }.should.raise(ArgumentError) end it "raises an ArgumentError if there are trailing _s" do - -> { Integer("1_", 12) }.should raise_error(ArgumentError) - -> { Integer("1___", 12) }.should raise_error(ArgumentError) + -> { Integer("1_", 12) }.should.raise(ArgumentError) + -> { Integer("1___", 12) }.should.raise(ArgumentError) end it "ignores an embedded _" do @@ -392,8 +392,8 @@ end it "raises an ArgumentError if there are multiple embedded _s" do - -> { Integer("1__1", 4) }.should raise_error(ArgumentError) - -> { Integer("1___1", 4) }.should raise_error(ArgumentError) + -> { Integer("1__1", 4) }.should.raise(ArgumentError) + -> { Integer("1___1", 4) }.should.raise(ArgumentError) end it "ignores a single leading +" do @@ -401,17 +401,17 @@ end it "raises an ArgumentError if there is a space between the + and number" do - -> { Integer("+ 1", 3) }.should raise_error(ArgumentError) + -> { Integer("+ 1", 3) }.should.raise(ArgumentError) end it "raises an ArgumentError if there are multiple leading +s" do - -> { Integer("++1", 3) }.should raise_error(ArgumentError) - -> { Integer("+++1", 3) }.should raise_error(ArgumentError) + -> { Integer("++1", 3) }.should.raise(ArgumentError) + -> { Integer("+++1", 3) }.should.raise(ArgumentError) end it "raises an ArgumentError if there are trailing +s" do - -> { Integer("1+", 3) }.should raise_error(ArgumentError) - -> { Integer("1+++", 12) }.should raise_error(ArgumentError) + -> { Integer("1+", 3) }.should.raise(ArgumentError) + -> { Integer("1+++", 12) }.should.raise(ArgumentError) end it "makes the number negative if there's a leading -" do @@ -419,29 +419,29 @@ end it "raises an ArgumentError if there are multiple leading -s" do - -> { Integer("--1", 9) }.should raise_error(ArgumentError) - -> { Integer("---1", 9) }.should raise_error(ArgumentError) + -> { Integer("--1", 9) }.should.raise(ArgumentError) + -> { Integer("---1", 9) }.should.raise(ArgumentError) end it "raises an ArgumentError if there are trailing -s" do - -> { Integer("1-", 12) }.should raise_error(ArgumentError) - -> { Integer("1---", 12) }.should raise_error(ArgumentError) + -> { Integer("1-", 12) }.should.raise(ArgumentError) + -> { Integer("1---", 12) }.should.raise(ArgumentError) end it "raises an ArgumentError if there is a period" do - -> { Integer("0.0", 3) }.should raise_error(ArgumentError) + -> { Integer("0.0", 3) }.should.raise(ArgumentError) end it "raises an ArgumentError for an empty String" do - -> { Integer("", 12) }.should raise_error(ArgumentError) + -> { Integer("", 12) }.should.raise(ArgumentError) end it "raises an ArgumentError for a base of 1" do - -> { Integer("1", 1) }.should raise_error(ArgumentError) + -> { Integer("1", 1) }.should.raise(ArgumentError) end it "raises an ArgumentError for a base of 37" do - -> { Integer("1", 37) }.should raise_error(ArgumentError) + -> { Integer("1", 37) }.should.raise(ArgumentError) end it "accepts wholly lowercase alphabetic strings for bases > 10" do @@ -469,8 +469,8 @@ end it "raises an ArgumentError for letters invalid in the given base" do - -> { Integer('z',19) }.should raise_error(ArgumentError) - -> { Integer('c00o',2) }.should raise_error(ArgumentError) + -> { Integer('z',19) }.should.raise(ArgumentError) + -> { Integer('c00o',2) }.should.raise(ArgumentError) end %w(x X).each do |x| @@ -491,12 +491,12 @@ 2.upto(15) do |base| it "raises an ArgumentError if the number begins with 0#{x} and the base is #{base}" do - -> { Integer("0#{x}1", base) }.should raise_error(ArgumentError) + -> { Integer("0#{x}1", base) }.should.raise(ArgumentError) end end it "raises an ArgumentError if the number cannot be parsed as hex and the base is 16" do - -> { Integer("0#{x}g", 16) }.should raise_error(ArgumentError) + -> { Integer("0#{x}g", 16) }.should.raise(ArgumentError) end end @@ -517,7 +517,7 @@ end it "raises an ArgumentError if the number cannot be parsed as binary and the base is 2" do - -> { Integer("0#{b}2", 2) }.should raise_error(ArgumentError) + -> { Integer("0#{b}2", 2) }.should.raise(ArgumentError) end end @@ -538,12 +538,12 @@ end it "raises an ArgumentError if the number cannot be parsed as octal and the base is 8" do - -> { Integer("0#{o}9", 8) }.should raise_error(ArgumentError) + -> { Integer("0#{o}9", 8) }.should.raise(ArgumentError) end 2.upto(7) do |base| it "raises an ArgumentError if the number begins with 0#{o} and the base is #{base}" do - -> { Integer("0#{o}1", base) }.should raise_error(ArgumentError) + -> { Integer("0#{o}1", base) }.should.raise(ArgumentError) end end end @@ -565,18 +565,18 @@ end it "raises an ArgumentError if the number cannot be parsed as decimal and the base is 10" do - -> { Integer("0#{d}a", 10) }.should raise_error(ArgumentError) + -> { Integer("0#{d}a", 10) }.should.raise(ArgumentError) end 2.upto(9) do |base| it "raises an ArgumentError if the number begins with 0#{d} and the base is #{base}" do - -> { Integer("0#{d}1", base) }.should raise_error(ArgumentError) + -> { Integer("0#{d}1", base) }.should.raise(ArgumentError) end end end it "raises an ArgumentError if a base is given for a non-String value" do - -> { Integer(98, 15) }.should raise_error(ArgumentError) + -> { Integer(98, 15) }.should.raise(ArgumentError) end it "tries to convert the base to an integer using to_int" do @@ -589,7 +589,7 @@ it "raises a TypeError if it is not an integer and does not respond to #to_i" do -> { Integer("777", "8") - }.should raise_error(TypeError, "no implicit conversion of String into Integer") + }.should.raise(TypeError, "no implicit conversion of String into Integer") end describe "when passed exception: false" do @@ -612,176 +612,176 @@ describe :kernel_Integer, shared: true do it "raises an ArgumentError when the String contains digits out of range of radix 2" do str = "23456789abcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 2) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 2) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 3" do str = "3456789abcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 3) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 3) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 4" do str = "456789abcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 4) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 4) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 5" do str = "56789abcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 5) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 5) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 6" do str = "6789abcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 6) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 6) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 7" do str = "789abcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 7) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 7) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 8" do str = "89abcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 8) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 8) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 9" do str = "9abcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 9) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 9) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 10" do str = "abcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 10) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 10) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 11" do str = "bcdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 11) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 11) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 12" do str = "cdefghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 12) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 12) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 13" do str = "defghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 13) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 13) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 14" do str = "efghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 14) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 14) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 15" do str = "fghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 15) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 15) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 16" do str = "ghijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 16) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 16) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 17" do str = "hijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 17) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 17) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 18" do str = "ijklmnopqrstuvwxyz" - -> { @object.send(@method, str, 18) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 18) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 19" do str = "jklmnopqrstuvwxyz" - -> { @object.send(@method, str, 19) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 19) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 20" do str = "klmnopqrstuvwxyz" - -> { @object.send(@method, str, 20) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 20) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 21" do str = "lmnopqrstuvwxyz" - -> { @object.send(@method, str, 21) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 21) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 22" do str = "mnopqrstuvwxyz" - -> { @object.send(@method, str, 22) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 22) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 23" do str = "nopqrstuvwxyz" - -> { @object.send(@method, str, 23) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 23) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 24" do str = "opqrstuvwxyz" - -> { @object.send(@method, str, 24) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 24) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 25" do str = "pqrstuvwxyz" - -> { @object.send(@method, str, 25) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 25) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 26" do str = "qrstuvwxyz" - -> { @object.send(@method, str, 26) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 26) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 27" do str = "rstuvwxyz" - -> { @object.send(@method, str, 27) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 27) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 28" do str = "stuvwxyz" - -> { @object.send(@method, str, 28) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 28) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 29" do str = "tuvwxyz" - -> { @object.send(@method, str, 29) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 29) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 30" do str = "uvwxyz" - -> { @object.send(@method, str, 30) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 30) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 31" do str = "vwxyz" - -> { @object.send(@method, str, 31) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 31) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 32" do str = "wxyz" - -> { @object.send(@method, str, 32) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 32) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 33" do str = "xyz" - -> { @object.send(@method, str, 33) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 33) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 34" do str = "yz" - -> { @object.send(@method, str, 34) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 34) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 35" do str = "z" - -> { @object.send(@method, str, 35) }.should raise_error(ArgumentError) + -> { @object.send(@method, str, 35) }.should.raise(ArgumentError) end it "raises an ArgumentError when the String contains digits out of range of radix 36" do - -> { @object.send(@method, "{", 36) }.should raise_error(ArgumentError) + -> { @object.send(@method, "{", 36) }.should.raise(ArgumentError) end end @@ -809,6 +809,6 @@ it_behaves_like :kernel_integer_string_base, :Integer it "is a private method" do - Kernel.should have_private_instance_method(:Integer) + Kernel.private_instance_methods(false).should.include?(:Integer) end end diff --git a/spec/ruby/core/kernel/Rational_spec.rb b/spec/ruby/core/kernel/Rational_spec.rb index 7e63e0dd573ffb..b13ab4cf551f7c 100644 --- a/spec/ruby/core/kernel/Rational_spec.rb +++ b/spec/ruby/core/kernel/Rational_spec.rb @@ -6,9 +6,9 @@ # Guard against the Mathn library guard -> { !defined?(Math.rsqrt) } do it "returns a new Rational number with 1 as the denominator" do - Rational(1).should eql(Rational(1, 1)) - Rational(-3).should eql(Rational(-3, 1)) - Rational(bignum_value).should eql(Rational(bignum_value, 1)) + Rational(1).should.eql?(Rational(1, 1)) + Rational(-3).should.eql?(Rational(-3, 1)) + Rational(bignum_value).should.eql?(Rational(bignum_value, 1)) end end end @@ -18,17 +18,17 @@ rat = Rational(1, 2) rat.numerator.should == 1 rat.denominator.should == 2 - rat.should be_an_instance_of(Rational) + rat.should.instance_of?(Rational) rat = Rational(-3, -5) rat.numerator.should == 3 rat.denominator.should == 5 - rat.should be_an_instance_of(Rational) + rat.should.instance_of?(Rational) rat = Rational(bignum_value, 3) rat.numerator.should == bignum_value rat.denominator.should == 3 - rat.should be_an_instance_of(Rational) + rat.should.instance_of?(Rational) end it "reduces the Rational" do @@ -82,7 +82,7 @@ end it "raises a RangeError if the imaginary part is not 0" do - -> { Rational(Complex(1, 2)) }.should raise_error(RangeError, "can't convert 1+2i into Rational") + -> { Rational(Complex(1, 2)) }.should.raise(RangeError, "can't convert 1+2i into Rational") end end @@ -113,18 +113,18 @@ def obj.to_int; 1; end end it "raises TypeError if it neither responds to #to_r nor #to_int method" do - -> { Rational([]) }.should raise_error(TypeError, "can't convert Array into Rational") - -> { Rational({}) }.should raise_error(TypeError, "can't convert Hash into Rational") - -> { Rational(nil) }.should raise_error(TypeError, "can't convert nil into Rational") + -> { Rational([]) }.should.raise(TypeError, "can't convert Array into Rational") + -> { Rational({}) }.should.raise(TypeError, "can't convert Hash into Rational") + -> { Rational(nil) }.should.raise(TypeError, "can't convert nil into Rational") end it "swallows exception raised in #to_int method" do object = Object.new def object.to_int() raise NoMethodError; end - -> { Rational(object) }.should raise_error(TypeError) - -> { Rational(object, 1) }.should raise_error(TypeError) - -> { Rational(1, object) }.should raise_error(TypeError) + -> { Rational(object) }.should.raise(TypeError) + -> { Rational(object, 1) }.should.raise(TypeError) + -> { Rational(1, object) }.should.raise(TypeError) end it "raises TypeError if #to_r does not return Rational" do @@ -136,24 +136,24 @@ def obj.to_r; []; end end it "raises a ZeroDivisionError if the second argument is 0" do - -> { Rational(1, 0) }.should raise_error(ZeroDivisionError, "divided by 0") - -> { Rational(1, 0.0) }.should raise_error(ZeroDivisionError, "divided by 0") + -> { Rational(1, 0) }.should.raise(ZeroDivisionError, "divided by 0") + -> { Rational(1, 0.0) }.should.raise(ZeroDivisionError, "divided by 0") end it "raises a TypeError if the first argument is nil" do - -> { Rational(nil) }.should raise_error(TypeError, "can't convert nil into Rational") + -> { Rational(nil) }.should.raise(TypeError, "can't convert nil into Rational") end it "raises a TypeError if the second argument is nil" do - -> { Rational(1, nil) }.should raise_error(TypeError, "can't convert nil into Rational") + -> { Rational(1, nil) }.should.raise(TypeError, "can't convert nil into Rational") end it "raises a TypeError if the first argument is a Symbol" do - -> { Rational(:sym) }.should raise_error(TypeError) + -> { Rational(:sym) }.should.raise(TypeError) end it "raises a TypeError if the second argument is a Symbol" do - -> { Rational(1, :sym) }.should raise_error(TypeError) + -> { Rational(1, :sym) }.should.raise(TypeError) end describe "when passed exception: false" do diff --git a/spec/ruby/core/kernel/String_spec.rb b/spec/ruby/core/kernel/String_spec.rb index 7caec6eda5c384..a9b0758ad70b3f 100644 --- a/spec/ruby/core/kernel/String_spec.rb +++ b/spec/ruby/core/kernel/String_spec.rb @@ -32,7 +32,7 @@ class << obj undef_method :to_s end - -> { @object.send(@method, obj) }.should raise_error(TypeError) + -> { @object.send(@method, obj) }.should.raise(TypeError) end # #5158 @@ -44,7 +44,7 @@ def respond_to?(meth, include_private=false) end end - -> { @object.send(@method, obj) }.should raise_error(TypeError) + -> { @object.send(@method, obj) }.should.raise(TypeError) end it "raises a TypeError if #to_s is not defined, even though #respond_to?(:to_s) returns true" do @@ -57,7 +57,7 @@ def respond_to?(meth, include_private=false) end end - -> { @object.send(@method, obj) }.should raise_error(TypeError) + -> { @object.send(@method, obj) }.should.raise(TypeError) end it "calls #to_s if #respond_to?(:to_s) returns true" do @@ -74,14 +74,14 @@ def method_missing(meth, *args) it "raises a TypeError if #to_s does not return a String" do (obj = mock('123')).should_receive(:to_s).and_return(123) - -> { @object.send(@method, obj) }.should raise_error(TypeError) + -> { @object.send(@method, obj) }.should.raise(TypeError) end it "returns the same object if it is already a String" do string = +"Hello" string.should_not_receive(:to_s) string2 = @object.send(@method, string) - string.should equal(string2) + string.should.equal?(string2) end it "returns the same object if it is an instance of a String subclass" do @@ -89,7 +89,7 @@ def method_missing(meth, *args) string = subklass.new("Hello") string.should_not_receive(:to_s) string2 = @object.send(@method, string) - string.should equal(string2) + string.should.equal?(string2) end end @@ -101,6 +101,6 @@ def method_missing(meth, *args) it_behaves_like :kernel_String, :String, Object.new it "is a private method" do - Kernel.should have_private_instance_method(:String) + Kernel.private_instance_methods(false).should.include?(:String) end end diff --git a/spec/ruby/core/kernel/abort_spec.rb b/spec/ruby/core/kernel/abort_spec.rb index f8152718c5b442..b75138182d43ab 100644 --- a/spec/ruby/core/kernel/abort_spec.rb +++ b/spec/ruby/core/kernel/abort_spec.rb @@ -4,7 +4,7 @@ describe "Kernel#abort" do it "is a private method" do - Kernel.should have_private_instance_method(:abort) + Kernel.private_instance_methods(false).should.include?(:abort) end it_behaves_like :process_abort, :abort, KernelSpecs::Method.new diff --git a/spec/ruby/core/kernel/at_exit_spec.rb b/spec/ruby/core/kernel/at_exit_spec.rb index ebd9a71d15f78c..fdb0eaf34c4c35 100644 --- a/spec/ruby/core/kernel/at_exit_spec.rb +++ b/spec/ruby/core/kernel/at_exit_spec.rb @@ -6,11 +6,11 @@ it_behaves_like :kernel_at_exit, :at_exit it "is a private method" do - Kernel.should have_private_instance_method(:at_exit) + Kernel.private_instance_methods(false).should.include?(:at_exit) end it "raises ArgumentError if called without a block" do - -> { at_exit }.should raise_error(ArgumentError, "called without a block") + -> { at_exit }.should.raise(ArgumentError, "called without a block") end end diff --git a/spec/ruby/core/kernel/autoload_relative_spec.rb b/spec/ruby/core/kernel/autoload_relative_spec.rb index c21e7803a458c2..7d03da8a4073ae 100644 --- a/spec/ruby/core/kernel/autoload_relative_spec.rb +++ b/spec/ruby/core/kernel/autoload_relative_spec.rb @@ -23,15 +23,15 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:autoload_relative) + Kernel.private_instance_methods(false).should.include?(:autoload_relative) end it "registers a file to load relative to the current file" do KernelSpecs.autoload_relative :KSAutoloadRelativeA, "fixtures/autoload_relative_b.rb" path = KernelSpecs.autoload?(:KSAutoloadRelativeA) - path.should_not be_nil + path.should_not == nil path.should.end_with?("autoload_relative_b.rb") - File.exist?(path).should be_true + File.exist?(path).should == true end it "loads the file when the constant is accessed" do @@ -41,7 +41,7 @@ it "sets the autoload constant in the constant table" do KernelSpecs.autoload_relative :KSAutoloadRelativeC, "fixtures/autoload_relative_b.rb" - KernelSpecs.should have_constant(:KSAutoloadRelativeC) + KernelSpecs.should.const_defined?(:KSAutoloadRelativeC, false) end it "can autoload in instance_eval with a file context" do @@ -55,32 +55,32 @@ it "raises LoadError if called from eval without file context" do -> { eval('autoload_relative :Foo, "foo.rb"') - }.should raise_error(LoadError, /autoload_relative called without file context/) + }.should.raise(LoadError, /autoload_relative called without file context/) end it "accepts both string and symbol for constant name" do KernelSpecs.autoload_relative :KSAutoloadRelativeE, "fixtures/autoload_relative_b.rb" KernelSpecs.autoload_relative "KSAutoloadRelativeF", "fixtures/autoload_relative_b.rb" - KernelSpecs.should have_constant(:KSAutoloadRelativeE) - KernelSpecs.should have_constant(:KSAutoloadRelativeF) + KernelSpecs.should.const_defined?(:KSAutoloadRelativeE, false) + KernelSpecs.should.const_defined?(:KSAutoloadRelativeF, false) end it "returns nil" do - KernelSpecs.autoload_relative(:KSAutoloadRelativeG, "fixtures/autoload_relative_b.rb").should be_nil + KernelSpecs.autoload_relative(:KSAutoloadRelativeG, "fixtures/autoload_relative_b.rb").should == nil end it "resolves nested directory paths correctly" do -> { autoload_relative :NestedTest, "../kernel/fixtures/autoload_relative_b.rb" autoload?(:NestedTest) - }.should_not raise_error + }.should_not.raise end it "resolves paths starting with ./" do KernelSpecs.autoload_relative :KSAutoloadRelativeH, "./fixtures/autoload_relative_b.rb" path = KernelSpecs.autoload?(:KSAutoloadRelativeH) - path.should_not be_nil + path.should_not == nil path.should.end_with?("autoload_relative_b.rb") end @@ -90,9 +90,9 @@ begin KernelSpecs.autoload_relative :KSAutoloadRelativeI, "fixtures/autoload_relative_b.rb" path = KernelSpecs.autoload?(:KSAutoloadRelativeI) - path.should_not be_nil + path.should_not == nil # Should still resolve even with empty $LOAD_PATH - File.exist?(path).should be_true + File.exist?(path).should == true ensure $LOAD_PATH.replace(original_load_path) end @@ -100,7 +100,7 @@ describe "when Object is frozen" do it "raises a FrozenError before defining the constant" do - ruby_exe(<<-RUBY).should include("FrozenError") + ruby_exe(<<-RUBY).should.include?("FrozenError") Object.freeze begin autoload_relative :Foo, "autoload_b.rb" diff --git a/spec/ruby/core/kernel/autoload_spec.rb b/spec/ruby/core/kernel/autoload_spec.rb index 5edb70541d1da1..46783734c43a0a 100644 --- a/spec/ruby/core/kernel/autoload_spec.rb +++ b/spec/ruby/core/kernel/autoload_spec.rb @@ -25,7 +25,7 @@ def check_autoload(const) end it "is a private method" do - Kernel.should have_private_instance_method(:autoload) + Kernel.private_instance_methods(false).should.include?(:autoload) end it "registers a file to load the first time the named constant is accessed" do @@ -37,7 +37,7 @@ def check_autoload(const) end it "sets the autoload constant in Object's constant table" do - Object.should have_constant(:KSAutoloadA) + Object.should.const_defined?(:KSAutoloadA, false) end it "loads the file when the constant is accessed" do @@ -49,7 +49,7 @@ def check_autoload(const) main = TOPLEVEL_BINDING.eval("self") main.should_receive(:require).with("main_autoload_not_exist.rb") # The constant won't be defined since require is mocked to do nothing - -> { KSAutoloadCallsRequire }.should raise_error(NameError) + -> { KSAutoloadCallsRequire }.should.raise(NameError) end it "can autoload in instance_eval" do @@ -102,7 +102,7 @@ def go describe "Kernel#autoload?" do it "is a private method" do - Kernel.should have_private_instance_method(:autoload?) + Kernel.private_instance_methods(false).should.include?(:autoload?) end it "returns the name of the file that will be autoloaded" do @@ -110,7 +110,7 @@ def go end it "returns nil if no file has been registered for a constant" do - check_autoload(:Manualload).should be_nil + check_autoload(:Manualload).should == nil end end @@ -137,7 +137,7 @@ def go end it "sets the autoload constant in Object's constant table" do - Object.should have_constant(:KSAutoloadBB) + Object.should.const_defined?(:KSAutoloadBB, false) end it "calls #to_path on non-String filenames" do @@ -173,6 +173,6 @@ def go end it "returns nil if no file has been registered for a constant" do - Kernel.autoload?(:Manualload).should be_nil + Kernel.autoload?(:Manualload).should == nil end end diff --git a/spec/ruby/core/kernel/backtick_spec.rb b/spec/ruby/core/kernel/backtick_spec.rb index 834d5636c1d6cb..42e0f975f598ff 100644 --- a/spec/ruby/core/kernel/backtick_spec.rb +++ b/spec/ruby/core/kernel/backtick_spec.rb @@ -11,7 +11,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:`) + Kernel.private_instance_methods(false).should.include?(:`) end it "returns the standard output of the executed sub-process" do @@ -28,11 +28,11 @@ it "produces a String in the default external encoding" do Encoding.default_external = Encoding::SHIFT_JIS - `echo disc`.encoding.should equal(Encoding::SHIFT_JIS) + `echo disc`.encoding.should.equal?(Encoding::SHIFT_JIS) end it "raises an Errno::ENOENT if the command is not executable" do - -> { `nonexistent_command` }.should raise_error(Errno::ENOENT) + -> { `nonexistent_command` }.should.raise(Errno::ENOENT) end platform_is_not :windows do @@ -43,13 +43,13 @@ it "sets $? to the exit status of the executed sub-process" do ip = 'world' `echo disc #{ip}` - $?.should be_kind_of(Process::Status) + $?.should.is_a?(Process::Status) $?.should_not.stopped? $?.should.exited? $?.exitstatus.should == 0 $?.should.success? `echo disc #{ip}; exit 99` - $?.should be_kind_of(Process::Status) + $?.should.is_a?(Process::Status) $?.should_not.stopped? $?.should.exited? $?.exitstatus.should == 99 @@ -61,13 +61,13 @@ it "sets $? to the exit status of the executed sub-process" do ip = 'world' `echo disc #{ip}` - $?.should be_kind_of(Process::Status) + $?.should.is_a?(Process::Status) $?.should_not.stopped? $?.should.exited? $?.exitstatus.should == 0 $?.should.success? `echo disc #{ip}& exit 99` - $?.should be_kind_of(Process::Status) + $?.should.is_a?(Process::Status) $?.should_not.stopped? $?.should.exited? $?.exitstatus.should == 99 diff --git a/spec/ruby/core/kernel/binding_spec.rb b/spec/ruby/core/kernel/binding_spec.rb index f1c9c6ec9f291c..6f27b26f379ba7 100644 --- a/spec/ruby/core/kernel/binding_spec.rb +++ b/spec/ruby/core/kernel/binding_spec.rb @@ -9,7 +9,7 @@ describe "Kernel#binding" do it "is a private method" do - Kernel.should have_private_instance_method(:binding) + Kernel.private_instance_methods(false).should.include?(:binding) end before :each do @@ -35,7 +35,7 @@ end it "raises a NameError on undefined variable" do - -> { eval("a_fake_variable", @b1) }.should raise_error(NameError) + -> { eval("a_fake_variable", @b1) }.should.raise(NameError) end it "uses the closure's self as self in the binding" do diff --git a/spec/ruby/core/kernel/block_given_spec.rb b/spec/ruby/core/kernel/block_given_spec.rb index aece4c821d1df0..20bb90ae96d5cc 100644 --- a/spec/ruby/core/kernel/block_given_spec.rb +++ b/spec/ruby/core/kernel/block_given_spec.rb @@ -30,7 +30,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:block_given?) + Kernel.private_instance_methods(false).should.include?(:block_given?) end end diff --git a/spec/ruby/core/kernel/caller_locations_spec.rb b/spec/ruby/core/kernel/caller_locations_spec.rb index a917dba504a931..24ee0745321a2f 100644 --- a/spec/ruby/core/kernel/caller_locations_spec.rb +++ b/spec/ruby/core/kernel/caller_locations_spec.rb @@ -3,7 +3,7 @@ describe 'Kernel#caller_locations' do it 'is a private method' do - Kernel.should have_private_instance_method(:caller_locations) + Kernel.private_instance_methods(false).should.include?(:caller_locations) end it 'returns an Array of caller locations' do diff --git a/spec/ruby/core/kernel/caller_spec.rb b/spec/ruby/core/kernel/caller_spec.rb index df051ef07f2d16..5e0c790730211d 100644 --- a/spec/ruby/core/kernel/caller_spec.rb +++ b/spec/ruby/core/kernel/caller_spec.rb @@ -3,7 +3,7 @@ describe 'Kernel#caller' do it 'is a private method' do - Kernel.should have_private_instance_method(:caller) + Kernel.private_instance_methods(false).should.include?(:caller) end it 'returns an Array of caller locations' do @@ -32,7 +32,7 @@ locations = KernelSpecs::CallerTest.locations line = __LINE__ - 1 - locations[0].should include("#{__FILE__}:#{line}:in") + locations[0].should.include?("#{__FILE__}:#{line}:in") end it "returns an Array with the block given to #at_exit at the base of the stack" do diff --git a/spec/ruby/core/kernel/case_compare_spec.rb b/spec/ruby/core/kernel/case_compare_spec.rb index b8d30960e88727..c74bbf63b9d231 100644 --- a/spec/ruby/core/kernel/case_compare_spec.rb +++ b/spec/ruby/core/kernel/case_compare_spec.rb @@ -58,18 +58,18 @@ def equal?(other) end it "returns true if #== returns true even if #equal? is false" do - @o1.should_not equal(@o2) + @o1.should_not.equal?(@o2) (@o1 == @o2).should == true (@o1 === @o2).should == true end it "returns true if #equal? returns true" do - @o1.should equal(@o1) + @o1.should.equal?(@o1) (@o1 === @o1).should == true end it "returns false if neither #== nor #equal? returns true" do - @o1.should_not equal(@o) + @o1.should_not.equal?(@o) (@o1 == @o).should == false (@o1 === @o).should == false end @@ -83,13 +83,13 @@ def equal?(other) end it "returns true if #== returns true even if #equal? is false" do - @o1.should_not equal(@o1) + @o1.should_not.equal?(@o1) (@o1 == @o1).should == true (@o1 === @o1).should == true end it "returns false if neither #== nor #equal? returns true" do - @o1.should_not equal(@o) + @o1.should_not.equal?(@o) (@o1 == @o).should == false (@o1 === @o).should == false end @@ -105,7 +105,7 @@ def equal?(other) it "returns true if the object id is the same even if both #== and #equal? return false" do @o1.object_id.should == @o1.object_id - @o1.should_not equal(@o1) + @o1.should_not.equal?(@o1) (@o1 == @o1).should == false (@o1 === @o1).should == true @@ -114,7 +114,7 @@ def equal?(other) it "returns false if the object id is not the same and both #== and #equal? return false" do @o1.object_id.should_not == @o2.object_id - @o1.should_not equal(@o2) + @o1.should_not.equal?(@o2) (@o1 == @o2).should == false (@o1 === @o2).should == false diff --git a/spec/ruby/core/kernel/catch_spec.rb b/spec/ruby/core/kernel/catch_spec.rb index 9f59d3b384e032..9f023036782827 100644 --- a/spec/ruby/core/kernel/catch_spec.rb +++ b/spec/ruby/core/kernel/catch_spec.rb @@ -31,11 +31,11 @@ end it "raises an ArgumentError if a Symbol is thrown for a String catch value" do - -> { catch("exit") { throw :exit } }.should raise_error(ArgumentError) + -> { catch("exit") { throw :exit } }.should.raise(ArgumentError) end it "raises an ArgumentError if a String with different identity is thrown" do - -> { catch("exit".dup) { throw "exit".dup } }.should raise_error(ArgumentError) + -> { catch("exit".dup) { throw "exit".dup } }.should.raise(ArgumentError) end it "catches a Symbol when thrown a matching Symbol" do @@ -60,7 +60,7 @@ end it "yields an object when called without arguments" do - catch { |tag| tag }.should be_an_instance_of(Object) + catch { |tag| tag }.should.instance_of?(Object) end it "can be used even in a method different from where throw is called" do @@ -116,12 +116,12 @@ def self.catching_method end it "raises LocalJumpError if no block is given" do - -> { catch :blah }.should raise_error(LocalJumpError) + -> { catch :blah }.should.raise(LocalJumpError) end end describe "Kernel#catch" do it "is a private method" do - Kernel.should have_private_instance_method(:catch) + Kernel.private_instance_methods(false).should.include?(:catch) end end diff --git a/spec/ruby/core/kernel/chomp_spec.rb b/spec/ruby/core/kernel/chomp_spec.rb index d30e77c35a71f6..434bf652f98c89 100644 --- a/spec/ruby/core/kernel/chomp_spec.rb +++ b/spec/ruby/core/kernel/chomp_spec.rb @@ -26,7 +26,7 @@ describe :kernel_chomp_private, shared: true do it "is a private method" do - KernelSpecs.has_private_method(@method).should be_true + KernelSpecs.has_private_method(@method).should == true end end diff --git a/spec/ruby/core/kernel/chop_spec.rb b/spec/ruby/core/kernel/chop_spec.rb index 9b91c011bccd23..bbf3c3f7248c98 100644 --- a/spec/ruby/core/kernel/chop_spec.rb +++ b/spec/ruby/core/kernel/chop_spec.rb @@ -14,7 +14,7 @@ describe :kernel_chop_private, shared: true do it "is a private method" do - KernelSpecs.has_private_method(@method).should be_true + KernelSpecs.has_private_method(@method).should == true end end diff --git a/spec/ruby/core/kernel/class_spec.rb b/spec/ruby/core/kernel/class_spec.rb index b1d9df16718bb4..0a7f774d143939 100644 --- a/spec/ruby/core/kernel/class_spec.rb +++ b/spec/ruby/core/kernel/class_spec.rb @@ -3,24 +3,24 @@ describe "Kernel#class" do it "returns the class of the object" do - Object.new.class.should equal(Object) + Object.new.class.should.equal?(Object) - 1.class.should equal(Integer) - 3.14.class.should equal(Float) - :hello.class.should equal(Symbol) - "hello".class.should equal(String) - [1, 2].class.should equal(Array) - { 1 => 2 }.class.should equal(Hash) + 1.class.should.equal?(Integer) + 3.14.class.should.equal?(Float) + :hello.class.should.equal?(Symbol) + "hello".class.should.equal?(String) + [1, 2].class.should.equal?(Array) + { 1 => 2 }.class.should.equal?(Hash) end it "returns Class for a class" do - BasicObject.class.should equal(Class) - String.class.should equal(Class) + BasicObject.class.should.equal?(Class) + String.class.should.equal?(Class) end it "returns the first non-singleton class" do a = +"hello" def a.my_singleton_method; end - a.class.should equal(String) + a.class.should.equal?(String) end end diff --git a/spec/ruby/core/kernel/clone_spec.rb b/spec/ruby/core/kernel/clone_spec.rb index 5adcbbe60332fb..4ddb23d6e6ed84 100644 --- a/spec/ruby/core/kernel/clone_spec.rb +++ b/spec/ruby/core/kernel/clone_spec.rb @@ -25,7 +25,7 @@ def klass.allocate end clone = instance.clone - clone.class.should equal klass + clone.class.should.equal? klass end describe "with no arguments" do @@ -40,7 +40,7 @@ def klass.allocate it 'copies frozen?' do o = ''.freeze.clone - o.frozen?.should be_true + o.frozen?.should == true end end @@ -56,7 +56,7 @@ def klass.allocate it "copies frozen?" do o = "".freeze.clone(freeze: nil) - o.frozen?.should be_true + o.frozen?.should == true end end @@ -78,7 +78,7 @@ def klass.allocate it "calls #initialize_clone with kwargs freeze: true even if #initialize_clone only takes a single argument" do obj = KernelSpecs::Clone.new - -> { obj.clone(freeze: true) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)') + -> { obj.clone(freeze: true) }.should.raise(ArgumentError, 'wrong number of arguments (given 2, expected 1)') end end @@ -100,15 +100,15 @@ def klass.allocate it "calls #initialize_clone with kwargs freeze: false even if #initialize_clone only takes a single argument" do obj = KernelSpecs::Clone.new - -> { obj.clone(freeze: false) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)') + -> { obj.clone(freeze: false) }.should.raise(ArgumentError, 'wrong number of arguments (given 2, expected 1)') end end describe "with freeze: anything else" do it 'raises ArgumentError when passed not true/false/nil' do - -> { @obj.clone(freeze: 1) }.should raise_error(ArgumentError, /unexpected value for freeze: Integer/) - -> { @obj.clone(freeze: "") }.should raise_error(ArgumentError, /unexpected value for freeze: String/) - -> { @obj.clone(freeze: Object.new) }.should raise_error(ArgumentError, /unexpected value for freeze: Object/) + -> { @obj.clone(freeze: 1) }.should.raise(ArgumentError, /unexpected value for freeze: Integer/) + -> { @obj.clone(freeze: "") }.should.raise(ArgumentError, /unexpected value for freeze: String/) + -> { @obj.clone(freeze: Object.new) }.should.raise(ArgumentError, /unexpected value for freeze: Object/) end end diff --git a/spec/ruby/core/kernel/comparison_spec.rb b/spec/ruby/core/kernel/comparison_spec.rb index affdc5c00d2e70..48f17e11727ca6 100644 --- a/spec/ruby/core/kernel/comparison_spec.rb +++ b/spec/ruby/core/kernel/comparison_spec.rb @@ -15,17 +15,17 @@ it "returns nil if self is eql? but not == to the argument" do obj = mock('has eql?') obj.should_not_receive(:eql?) - obj.<=>(Object.new).should be_nil + obj.<=>(Object.new).should == nil end it "returns nil if self.==(arg) returns nil" do obj = mock('wrong ==') obj.should_receive(:==).and_return(nil) - obj.<=>(Object.new).should be_nil + obj.<=>(Object.new).should == nil end it "returns nil if self is not == to the argument" do obj = Object.new - obj.<=>(3.14).should be_nil + obj.<=>(3.14).should == nil end end diff --git a/spec/ruby/core/kernel/define_singleton_method_spec.rb b/spec/ruby/core/kernel/define_singleton_method_spec.rb index 24acec84f59770..ec48581db80d14 100644 --- a/spec/ruby/core/kernel/define_singleton_method_spec.rb +++ b/spec/ruby/core/kernel/define_singleton_method_spec.rb @@ -14,14 +14,14 @@ class DefineSingletonMethodSpecClass end it "adds the new method to the methods list" do - DefineSingletonMethodSpecClass.should have_method(:another_test_method) + DefineSingletonMethodSpecClass.should.respond_to?(:another_test_method) end it "defines any Child class method from any Parent's class methods" do um = KernelSpecs::Parent.method(:parent_class_method).unbind KernelSpecs::Child.send :define_singleton_method, :child_class_method, um KernelSpecs::Child.child_class_method.should == :foo - ->{KernelSpecs::Parent.child_class_method}.should raise_error(NoMethodError) + ->{KernelSpecs::Parent.child_class_method}.should.raise(NoMethodError) end it "will raise when attempting to define an object's singleton method from another object's singleton method" do @@ -33,7 +33,7 @@ def singleton_method end end um = p.method(:singleton_method).unbind - ->{ other.send :define_singleton_method, :other_singleton_method, um }.should raise_error(TypeError) + ->{ other.send :define_singleton_method, :other_singleton_method, um }.should.raise(TypeError) end end @@ -52,11 +52,11 @@ class DefineSingletonMethodSpecClass it "raises a TypeError when the given method is no Method/Proc" do -> { Class.new { define_singleton_method(:test, "self") } - }.should raise_error(TypeError) + }.should.raise(TypeError) -> { Class.new { define_singleton_method(:test, 1234) } - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "defines a new singleton method for objects" do @@ -65,7 +65,7 @@ class DefineSingletonMethodSpecClass obj.test.should == "world!" -> { Object.new.test - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end it "maintains the Proc's scope" do @@ -83,7 +83,7 @@ class DefineMethodByProcClass obj = Object.new -> { obj.define_singleton_method(:test) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "does not use the caller block when no block is given" do @@ -94,7 +94,7 @@ def o.define(name) -> { o.define(:foo) { raise "not used" } - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "always defines the method with public visibility" do @@ -109,12 +109,12 @@ def cls.define(name, &block) cls.define(:foo) { :ok } end cls.foo.should == :ok - }.should_not raise_error(NoMethodError) + }.should_not.raise(NoMethodError) end it "cannot define a singleton method with a frozen singleton class" do o = Object.new o.freeze - -> { o.define_singleton_method(:foo) { 1 } }.should raise_error(FrozenError) + -> { o.define_singleton_method(:foo) { 1 } }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/kernel/dup_spec.rb b/spec/ruby/core/kernel/dup_spec.rb index 70198abdb7554b..99de5e37327c08 100644 --- a/spec/ruby/core/kernel/dup_spec.rb +++ b/spec/ruby/core/kernel/dup_spec.rb @@ -25,7 +25,7 @@ def klass.allocate end dup = instance.dup - dup.class.should equal klass + dup.class.should.equal? klass end it "does not copy frozen state from the original" do @@ -44,7 +44,7 @@ def klass.allocate it "does not copy singleton methods" do def @obj.special() :the_one end dup = @obj.dup - -> { dup.special }.should raise_error(NameError) + -> { dup.special }.should.raise(NameError) end it "does not copy modules included in the singleton class" do @@ -53,7 +53,7 @@ class << @obj end dup = @obj.dup - -> { dup.repr }.should raise_error(NameError) + -> { dup.repr }.should.raise(NameError) end it "does not copy constants defined in the singleton class" do @@ -62,6 +62,6 @@ class << @obj end dup = @obj.dup - -> { class << dup; CLONE; end }.should raise_error(NameError) + -> { class << dup; CLONE; end }.should.raise(NameError) end end diff --git a/spec/ruby/core/kernel/eql_spec.rb b/spec/ruby/core/kernel/eql_spec.rb index e62a601a793f24..b3289090e5cdd2 100644 --- a/spec/ruby/core/kernel/eql_spec.rb +++ b/spec/ruby/core/kernel/eql_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#eql?" do it "is a public instance method" do - Kernel.should have_public_instance_method(:eql?) + Kernel.public_instance_methods(false).should.include?(:eql?) end it_behaves_like :object_equal, :eql? diff --git a/spec/ruby/core/kernel/eval_spec.rb b/spec/ruby/core/kernel/eval_spec.rb index c1136efd699282..f9ca47866e0fe1 100644 --- a/spec/ruby/core/kernel/eval_spec.rb +++ b/spec/ruby/core/kernel/eval_spec.rb @@ -5,7 +5,7 @@ describe "Kernel#eval" do it "is a private method" do - Kernel.should have_private_instance_method(:eval) + Kernel.private_instance_methods(false).should.include?(:eval) end it "is a module function" do @@ -76,12 +76,12 @@ x = 1 bind = proc {} - -> { eval("x", bind) }.should raise_error(TypeError) + -> { eval("x", bind) }.should.raise(TypeError) end it "does not make Proc locals visible to evaluated code" do bind = proc { inner = 4 } - -> { eval("inner", bind.binding) }.should raise_error(NameError) + -> { eval("inner", bind.binding) }.should.raise(NameError) end # REWRITE ME: This obscures the real behavior of where locals are stored @@ -119,7 +119,7 @@ outer_binding = binding eval("if false; a = 1; end", outer_binding) - eval("a", outer_binding).should be_nil + eval("a", outer_binding).should == nil end it "allows creating a new class in a binding" do @@ -136,7 +136,7 @@ expected = 'speccing.rb' -> { eval('if true', TOPLEVEL_BINDING, expected) - }.should raise_error(SyntaxError) { |e| + }.should.raise(SyntaxError) { |e| e.message.should =~ /#{expected}:1:.+/ } end @@ -145,7 +145,7 @@ expected_file = 'speccing.rb' -> { eval('if true', TOPLEVEL_BINDING, expected_file, -100) - }.should raise_error(SyntaxError) { |e| + }.should.raise(SyntaxError) { |e| e.message.should =~ /#{expected_file}:-100:.+/ } end @@ -263,14 +263,14 @@ def foo(a, b:, &block) # See http://jira.codehaus.org/browse/JRUBY-5163 it "uses the receiver as self inside the eval" do - eval("self").should equal(self) - Kernel.eval("self").should equal(Kernel) + eval("self").should.equal?(self) + Kernel.eval("self").should.equal?(Kernel) end it "does not pass the block to the method being eval'ed" do -> { eval('KernelSpecs::EvalTest.call_yield') { "content" } - }.should raise_error(LocalJumpError) + }.should.raise(LocalJumpError) end it "returns from the scope calling #eval when evaluating 'return'" do @@ -308,7 +308,7 @@ def eval_return(n) it "has the correct default definee when called through Method#call" do class EvalSpecs method(:eval).call("def eval_spec_method_call; end") - EvalSpecs.should have_instance_method(:eval_spec_method_call) + EvalSpecs.should.method_defined?(:eval_spec_method_call, false) end end @@ -362,7 +362,7 @@ class EvalSpecs CODE code.encoding.should == Encoding::BINARY eval(code) - EvalSpecs.constants(false).should include(:"Vπ") + EvalSpecs.constants(false).should.include?(:"Vπ") EvalSpecs::Vπ.should == 3.14 ensure EvalSpecs.send(:remove_const, :Vπ) @@ -377,7 +377,7 @@ class EvalSpecs CODE code.encoding.should == Encoding::BINARY eval(code) - EvalSpecs.constants(false).should include(:"Vπemacs") + EvalSpecs.constants(false).should.include?(:"Vπemacs") EvalSpecs::Vπemacs.should == 3.14 ensure EvalSpecs.send(:remove_const, :Vπemacs) @@ -392,7 +392,7 @@ class EvalSpecs CODE code.encoding.should == Encoding::BINARY eval(code) - EvalSpecs.constants(false).should include(:"Vπspaces") + EvalSpecs.constants(false).should.include?(:"Vπspaces") EvalSpecs::Vπspaces.should == 3.14 ensure EvalSpecs.send(:remove_const, :Vπspaces) @@ -408,7 +408,7 @@ class EvalSpecs CODE code.encoding.should == Encoding::BINARY eval(code) - EvalSpecs.constants(false).should include(:"Vπshebang") + EvalSpecs.constants(false).should.include?(:"Vπshebang") EvalSpecs::Vπshebang.should == 3.14 ensure EvalSpecs.send(:remove_const, :Vπshebang) @@ -424,7 +424,7 @@ class EvalSpecs CODE code.encoding.should == Encoding::BINARY eval(code) - EvalSpecs.constants(false).should include(:"Vπshebang_spaces") + EvalSpecs.constants(false).should.include?(:"Vπshebang_spaces") EvalSpecs::Vπshebang_spaces.should == 3.14 ensure EvalSpecs.send(:remove_const, :Vπshebang_spaces) @@ -442,7 +442,7 @@ class EvalSpecs CODE code.encoding.should == Encoding::BINARY eval(code) - EvalSpecs.constants(false).should include(:"Vπstring") + EvalSpecs.constants(false).should.include?(:"Vπstring") EvalSpecs::Vπstring.should == "frozen" EvalSpecs::Vπstring.encoding.should == Encoding::UTF_8 EvalSpecs::Vπstring.frozen?.should == !frozen_string_default @@ -459,10 +459,10 @@ class EvalSpecs CODE code.encoding.should == Encoding::BINARY eval(code) - EvalSpecs.constants(false).should include(:"Vπsame_line") + EvalSpecs.constants(false).should.include?(:"Vπsame_line") EvalSpecs::Vπsame_line.should == "frozen" EvalSpecs::Vπsame_line.encoding.should == Encoding::UTF_8 - EvalSpecs::Vπsame_line.frozen?.should be_true + EvalSpecs::Vπsame_line.frozen?.should == true ensure EvalSpecs.send(:remove_const, :Vπsame_line) end @@ -478,9 +478,9 @@ class EvalSpecs CODE code.encoding.should == Encoding::BINARY eval(code) - EvalSpecs.constants(false).should_not include(:"Vπfrozen_first") + EvalSpecs.constants(false).should_not.include?(:"Vπfrozen_first") binary_constant = "Vπfrozen_first".b.to_sym - EvalSpecs.constants(false).should include(binary_constant) + EvalSpecs.constants(false).should.include?(binary_constant) value = EvalSpecs.const_get(binary_constant) value.should == "frozen" value.encoding.should == Encoding::BINARY diff --git a/spec/ruby/core/kernel/exec_spec.rb b/spec/ruby/core/kernel/exec_spec.rb index 3d9520ad67a6f7..fd8485791a3602 100644 --- a/spec/ruby/core/kernel/exec_spec.rb +++ b/spec/ruby/core/kernel/exec_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#exec" do it "is a private method" do - Kernel.should have_private_instance_method(:exec) + Kernel.private_instance_methods(false).should.include?(:exec) end it "runs the specified command, replacing current process" do diff --git a/spec/ruby/core/kernel/exit_spec.rb b/spec/ruby/core/kernel/exit_spec.rb index 93cec3fee5cde5..864ff84449e104 100644 --- a/spec/ruby/core/kernel/exit_spec.rb +++ b/spec/ruby/core/kernel/exit_spec.rb @@ -4,7 +4,7 @@ describe "Kernel#exit" do it "is a private method" do - Kernel.should have_private_instance_method(:exit) + Kernel.private_instance_methods(false).should.include?(:exit) end it_behaves_like :process_exit, :exit, KernelSpecs::Method.new @@ -16,7 +16,7 @@ describe "Kernel#exit!" do it "is a private method" do - Kernel.should have_private_instance_method(:exit!) + Kernel.private_instance_methods(false).should.include?(:exit!) end it_behaves_like :process_exit!, :exit!, "self" diff --git a/spec/ruby/core/kernel/extend_spec.rb b/spec/ruby/core/kernel/extend_spec.rb index 6342d8cae15871..a344c7b5ca22e8 100644 --- a/spec/ruby/core/kernel/extend_spec.rb +++ b/spec/ruby/core/kernel/extend_spec.rb @@ -53,13 +53,13 @@ def self.append_features(o) end it "raises an ArgumentError when no arguments given" do - -> { Object.new.extend }.should raise_error(ArgumentError) + -> { Object.new.extend }.should.raise(ArgumentError) end it "raises a TypeError when the argument is not a Module" do o = mock('o') klass = Class.new - -> { o.extend(klass) }.should raise_error(TypeError) + -> { o.extend(klass) }.should.raise(TypeError) end describe "on frozen instance" do @@ -69,11 +69,11 @@ def self.append_features(o) end it "raises an ArgumentError when no arguments given" do - -> { @frozen.extend }.should raise_error(ArgumentError) + -> { @frozen.extend }.should.raise(ArgumentError) end it "raises a FrozenError" do - -> { @frozen.extend @module }.should raise_error(FrozenError) + -> { @frozen.extend @module }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/kernel/fail_spec.rb b/spec/ruby/core/kernel/fail_spec.rb index fab622037ebaab..ac379b67d516f1 100644 --- a/spec/ruby/core/kernel/fail_spec.rb +++ b/spec/ruby/core/kernel/fail_spec.rb @@ -3,11 +3,11 @@ describe "Kernel#fail" do it "is a private method" do - Kernel.should have_private_instance_method(:fail) + Kernel.private_instance_methods(false).should.include?(:fail) end it "raises a RuntimeError" do - -> { fail }.should raise_error(RuntimeError) + -> { fail }.should.raise(RuntimeError) end it "accepts an Object with an exception method returning an Exception" do @@ -15,12 +15,12 @@ def obj.exception(msg) StandardError.new msg end - -> { fail obj, "..." }.should raise_error(StandardError, "...") + -> { fail obj, "..." }.should.raise(StandardError, "...") end it "instantiates the specified exception class" do error_class = Class.new(RuntimeError) - -> { fail error_class }.should raise_error(error_class) + -> { fail error_class }.should.raise(error_class) end it "uses the specified message" do @@ -33,7 +33,7 @@ def obj.exception(msg) else raise Exception end - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end end diff --git a/spec/ruby/core/kernel/fork_spec.rb b/spec/ruby/core/kernel/fork_spec.rb index b37f9980e0df7d..4a2c848202095a 100644 --- a/spec/ruby/core/kernel/fork_spec.rb +++ b/spec/ruby/core/kernel/fork_spec.rb @@ -4,7 +4,7 @@ describe "Kernel#fork" do it "is a private method" do - Kernel.should have_private_instance_method(:fork) + Kernel.private_instance_methods(false).should.include?(:fork) end it_behaves_like :process_fork, :fork, KernelSpecs::Method.new diff --git a/spec/ruby/core/kernel/format_spec.rb b/spec/ruby/core/kernel/format_spec.rb index 1d0c000c158761..35c752b1abd9c0 100644 --- a/spec/ruby/core/kernel/format_spec.rb +++ b/spec/ruby/core/kernel/format_spec.rb @@ -4,7 +4,7 @@ # NOTE: most specs are in sprintf_spec.rb, this is just an alias describe "Kernel#format" do it "is a private method" do - Kernel.should have_private_instance_method(:format) + Kernel.private_instance_methods(false).should.include?(:format) end end @@ -20,7 +20,7 @@ format("test", 1) RUBY - ruby_exe(code, args: "2>&1").should include("warning: too many arguments for format string") + ruby_exe(code, args: "2>&1").should.include?("warning: too many arguments for format string") end it "does not warns if too many keyword arguments are passed" do @@ -29,7 +29,7 @@ format("test %{test}", test: 1, unused: 2) RUBY - ruby_exe(code, args: "2>&1").should_not include("warning") + ruby_exe(code, args: "2>&1").should_not.include?("warning") end ruby_bug "#20593", ""..."3.4" do @@ -40,7 +40,7 @@ format("test", {}) RUBY - ruby_exe(code, args: "2>&1").should_not include("warning") + ruby_exe(code, args: "2>&1").should_not.include?("warning") end end end diff --git a/spec/ruby/core/kernel/freeze_spec.rb b/spec/ruby/core/kernel/freeze_spec.rb index fa32d321cffb79..079617dce49174 100644 --- a/spec/ruby/core/kernel/freeze_spec.rb +++ b/spec/ruby/core/kernel/freeze_spec.rb @@ -4,46 +4,46 @@ describe "Kernel#freeze" do it "prevents self from being further modified" do o = mock('o') - o.frozen?.should be_false + o.frozen?.should == false o.freeze - o.frozen?.should be_true + o.frozen?.should == true end it "returns self" do o = Object.new - o.freeze.should equal(o) + o.freeze.should.equal?(o) end describe "on integers" do it "has no effect since they are already frozen" do - 1.frozen?.should be_true + 1.frozen?.should == true 1.freeze bignum = bignum_value - bignum.frozen?.should be_true + bignum.frozen?.should == true bignum.freeze end end describe "on a Float" do it "has no effect since it is already frozen" do - 1.2.frozen?.should be_true + 1.2.frozen?.should == true 1.2.freeze end end describe "on a Symbol" do it "has no effect since it is already frozen" do - :sym.frozen?.should be_true + :sym.frozen?.should == true :sym.freeze end end describe "on true, false and nil" do it "has no effect since they are already frozen" do - nil.frozen?.should be_true - true.frozen?.should be_true - false.frozen?.should be_true + nil.frozen?.should == true + true.frozen?.should == true + false.frozen?.should == true nil.freeze true.freeze @@ -54,7 +54,7 @@ describe "on a Complex" do it "has no effect since it is already frozen" do c = Complex(1.3, 3.1) - c.frozen?.should be_true + c.frozen?.should == true c.freeze end end @@ -62,7 +62,7 @@ describe "on a Rational" do it "has no effect since it is already frozen" do r = Rational(1, 3) - r.frozen?.should be_true + r.frozen?.should == true r.freeze end end @@ -72,13 +72,13 @@ def mutate; @foo = 1; end end.new o.freeze - -> {o.mutate}.should raise_error(RuntimeError) + -> {o.mutate}.should.raise(RuntimeError) end it "causes instance_variable_set to raise RuntimeError" do o = Object.new o.freeze - -> {o.instance_variable_set(:@foo, 1)}.should raise_error(RuntimeError) + -> {o.instance_variable_set(:@foo, 1)}.should.raise(RuntimeError) end it "freezes an object's singleton class" do diff --git a/spec/ruby/core/kernel/frozen_spec.rb b/spec/ruby/core/kernel/frozen_spec.rb index a4cec4263db472..8b8fad3de71bb0 100644 --- a/spec/ruby/core/kernel/frozen_spec.rb +++ b/spec/ruby/core/kernel/frozen_spec.rb @@ -12,9 +12,9 @@ describe "on true, false and nil" do it "returns true" do - true.frozen?.should be_true - false.frozen?.should be_true - nil.frozen?.should be_true + true.frozen?.should == true + false.frozen?.should == true + nil.frozen?.should == true end end @@ -25,8 +25,8 @@ end it "returns true" do - @fixnum.frozen?.should be_true - @bignum.frozen?.should be_true + @fixnum.frozen?.should == true + @bignum.frozen?.should == true end end @@ -36,7 +36,7 @@ end it "returns true" do - @float.frozen?.should be_true + @float.frozen?.should == true end end @@ -46,31 +46,31 @@ end it "returns true" do - @symbol.frozen?.should be_true + @symbol.frozen?.should == true end end describe "on a Complex" do it "returns true" do c = Complex(1.3, 3.1) - c.frozen?.should be_true + c.frozen?.should == true end it "literal returns true" do c = eval "1.3i" - c.frozen?.should be_true + c.frozen?.should == true end end describe "on a Rational" do it "returns true" do r = Rational(1, 3) - r.frozen?.should be_true + r.frozen?.should == true end it "literal returns true" do r = eval "1/3r" - r.frozen?.should be_true + r.frozen?.should == true end end end diff --git a/spec/ruby/core/kernel/gets_spec.rb b/spec/ruby/core/kernel/gets_spec.rb index 104613dbfac17c..1b2b36fbb96457 100644 --- a/spec/ruby/core/kernel/gets_spec.rb +++ b/spec/ruby/core/kernel/gets_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#gets" do it "is a private method" do - Kernel.should have_private_instance_method(:gets) + Kernel.private_instance_methods(false).should.include?(:gets) end it "calls ARGF.gets" do diff --git a/spec/ruby/core/kernel/global_variables_spec.rb b/spec/ruby/core/kernel/global_variables_spec.rb index 8bce8e25b7ef64..d41bdff49a42f7 100644 --- a/spec/ruby/core/kernel/global_variables_spec.rb +++ b/spec/ruby/core/kernel/global_variables_spec.rb @@ -3,7 +3,7 @@ describe "Kernel.global_variables" do it "is a private method" do - Kernel.should have_private_instance_method(:global_variables) + Kernel.private_instance_methods(false).should.include?(:global_variables) end before :all do @@ -11,13 +11,13 @@ end it "finds subset starting with std" do - global_variables.grep(/std/).should include(:$stderr, :$stdin, :$stdout) + global_variables.grep(/std/).to_set.should >= Set[:$stderr, :$stdin, :$stdout] a = global_variables.size gvar_name = "$foolish_global_var#{@i += 1}" global_variables.include?(gvar_name.to_sym).should == false eval("#{gvar_name} = 1") global_variables.size.should == a+1 - global_variables.should include(gvar_name.to_sym) + global_variables.should.include?(gvar_name.to_sym) end end diff --git a/spec/ruby/core/kernel/gsub_spec.rb b/spec/ruby/core/kernel/gsub_spec.rb index a0cb9f2a7068fb..e05349e2b5827f 100644 --- a/spec/ruby/core/kernel/gsub_spec.rb +++ b/spec/ruby/core/kernel/gsub_spec.rb @@ -6,20 +6,20 @@ ruby_version_is ""..."1.9" do describe "Kernel#gsub" do it "is a private method" do - Kernel.should have_private_instance_method(:gsub) + Kernel.private_instance_methods(false).should.include?(:gsub) end it "raises a TypeError if $_ is not a String" do -> { $_ = 123 gsub(/./, "!") - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "when matches sets $_ to a new string, leaving the former value unaltered" do orig_value = $_ = "hello" gsub("ello", "ola") - $_.should_not equal(orig_value) + $_.should_not.equal?(orig_value) $_.should == "hola" orig_value.should == "hello" end @@ -86,7 +86,7 @@ describe "Kernel#gsub!" do it "is a private method" do - Kernel.should have_private_instance_method(:gsub!) + Kernel.private_instance_methods(false).should.include?(:gsub!) end end diff --git a/spec/ruby/core/kernel/initialize_clone_spec.rb b/spec/ruby/core/kernel/initialize_clone_spec.rb index 21a90c19f0e4a7..0033eadffbb1d1 100644 --- a/spec/ruby/core/kernel/initialize_clone_spec.rb +++ b/spec/ruby/core/kernel/initialize_clone_spec.rb @@ -2,7 +2,7 @@ describe "Kernel#initialize_clone" do it "is a private instance method" do - Kernel.should have_private_instance_method(:initialize_clone) + Kernel.private_instance_methods(false).should.include?(:initialize_clone) end it "returns the receiver" do diff --git a/spec/ruby/core/kernel/initialize_copy_spec.rb b/spec/ruby/core/kernel/initialize_copy_spec.rb index d71ca9f60f682b..ebac0c14de4ce0 100644 --- a/spec/ruby/core/kernel/initialize_copy_spec.rb +++ b/spec/ruby/core/kernel/initialize_copy_spec.rb @@ -17,8 +17,8 @@ end it "raises FrozenError if the receiver is frozen" do - -> { Object.new.freeze.send(:initialize_copy, Object.new) }.should raise_error(FrozenError) - -> { 1.send(:initialize_copy, Object.new) }.should raise_error(FrozenError) + -> { Object.new.freeze.send(:initialize_copy, Object.new) }.should.raise(FrozenError) + -> { 1.send(:initialize_copy, Object.new) }.should.raise(FrozenError) end it "raises TypeError if the objects are of different class" do @@ -27,10 +27,10 @@ a = klass.new b = sub.new message = 'initialize_copy should take same class object' - -> { a.send(:initialize_copy, b) }.should raise_error(TypeError, message) - -> { b.send(:initialize_copy, a) }.should raise_error(TypeError, message) + -> { a.send(:initialize_copy, b) }.should.raise(TypeError, message) + -> { b.send(:initialize_copy, a) }.should.raise(TypeError, message) - -> { a.send(:initialize_copy, 1) }.should raise_error(TypeError, message) - -> { a.send(:initialize_copy, 1.0) }.should raise_error(TypeError, message) + -> { a.send(:initialize_copy, 1) }.should.raise(TypeError, message) + -> { a.send(:initialize_copy, 1.0) }.should.raise(TypeError, message) end end diff --git a/spec/ruby/core/kernel/initialize_dup_spec.rb b/spec/ruby/core/kernel/initialize_dup_spec.rb index 6dff34b7ad8fb9..f144647eb8ba1d 100644 --- a/spec/ruby/core/kernel/initialize_dup_spec.rb +++ b/spec/ruby/core/kernel/initialize_dup_spec.rb @@ -2,7 +2,7 @@ describe "Kernel#initialize_dup" do it "is a private instance method" do - Kernel.should have_private_instance_method(:initialize_dup) + Kernel.private_instance_methods(false).should.include?(:initialize_dup) end it "returns the receiver" do diff --git a/spec/ruby/core/kernel/inspect_spec.rb b/spec/ruby/core/kernel/inspect_spec.rb index 1fa66cab98a979..9808341139d220 100644 --- a/spec/ruby/core/kernel/inspect_spec.rb +++ b/spec/ruby/core/kernel/inspect_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#inspect" do it "returns a String" do - Object.new.inspect.should be_an_instance_of(String) + Object.new.inspect.should.instance_of?(String) end it "does not call #to_s if it is defined" do @@ -26,7 +26,7 @@ class << obj undef_method :class end - obj.inspect.should be_kind_of(String) + obj.inspect.should.is_a?(String) end ruby_version_is "4.0" do @@ -84,7 +84,7 @@ class << obj private def instance_variables_to_inspect = {} end - ->{ obj.inspect }.should raise_error(TypeError, "Expected #instance_variables_to_inspect to return an Array or nil, but it returned Hash") + ->{ obj.inspect }.should.raise(TypeError, "Expected #instance_variables_to_inspect to return an Array or nil, but it returned Hash") end end end diff --git a/spec/ruby/core/kernel/instance_of_spec.rb b/spec/ruby/core/kernel/instance_of_spec.rb index d1170d504733d0..8d19974aa31a72 100644 --- a/spec/ruby/core/kernel/instance_of_spec.rb +++ b/spec/ruby/core/kernel/instance_of_spec.rb @@ -33,8 +33,8 @@ end it "raises a TypeError if given an object that is not a Class nor a Module" do - -> { @o.instance_of?(Object.new) }.should raise_error(TypeError) - -> { @o.instance_of?('KernelSpecs::InstanceClass') }.should raise_error(TypeError) - -> { @o.instance_of?(1) }.should raise_error(TypeError) + -> { @o.instance_of?(Object.new) }.should.raise(TypeError) + -> { @o.instance_of?('KernelSpecs::InstanceClass') }.should.raise(TypeError) + -> { @o.instance_of?(1) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/kernel/instance_variable_defined_spec.rb b/spec/ruby/core/kernel/instance_variable_defined_spec.rb index 2ebb582b43d93c..512f811393ea31 100644 --- a/spec/ruby/core/kernel/instance_variable_defined_spec.rb +++ b/spec/ruby/core/kernel/instance_variable_defined_spec.rb @@ -8,21 +8,21 @@ describe "when passed a String" do it "returns false if the instance variable is not defined" do - @instance.instance_variable_defined?("@goodbye").should be_false + @instance.instance_variable_defined?("@goodbye").should == false end it "returns true if the instance variable is defined" do - @instance.instance_variable_defined?("@greeting").should be_true + @instance.instance_variable_defined?("@greeting").should == true end end describe "when passed a Symbol" do it "returns false if the instance variable is not defined" do - @instance.instance_variable_defined?(:@goodbye).should be_false + @instance.instance_variable_defined?(:@goodbye).should == false end it "returns true if the instance variable is defined" do - @instance.instance_variable_defined?(:@greeting).should be_true + @instance.instance_variable_defined?(:@greeting).should == true end end @@ -30,12 +30,12 @@ -> do obj = mock("kernel instance_variable_defined?") @instance.instance_variable_defined? obj - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "returns false if the instance variable is not defined for different types" do [nil, false, true, 1, 2.0, :test, "test"].each do |obj| - obj.instance_variable_defined?("@goodbye").should be_false + obj.instance_variable_defined?("@goodbye").should == false end end end diff --git a/spec/ruby/core/kernel/instance_variable_get_spec.rb b/spec/ruby/core/kernel/instance_variable_get_spec.rb index f1d2a45df8d5c0..8404c94192f7e6 100644 --- a/spec/ruby/core/kernel/instance_variable_get_spec.rb +++ b/spec/ruby/core/kernel/instance_variable_get_spec.rb @@ -20,29 +20,29 @@ end it "returns nil when the referred instance variable does not exist" do - @obj.instance_variable_get(:@does_not_exist).should be_nil + @obj.instance_variable_get(:@does_not_exist).should == nil end it "raises a TypeError when the passed argument does not respond to #to_str" do - -> { @obj.instance_variable_get(Object.new) }.should raise_error(TypeError) + -> { @obj.instance_variable_get(Object.new) }.should.raise(TypeError) end it "raises a TypeError when the passed argument can't be converted to a String" do obj = mock("to_str") obj.stub!(:to_str).and_return(123) - -> { @obj.instance_variable_get(obj) }.should raise_error(TypeError) + -> { @obj.instance_variable_get(obj) }.should.raise(TypeError) end it "raises a NameError when the conversion result does not start with an '@'" do obj = mock("to_str") obj.stub!(:to_str).and_return("test") - -> { @obj.instance_variable_get(obj) }.should raise_error(NameError) + -> { @obj.instance_variable_get(obj) }.should.raise(NameError) end it "raises a NameError when passed just '@'" do obj = mock("to_str") obj.stub!(:to_str).and_return('@') - -> { @obj.instance_variable_get(obj) }.should raise_error(NameError) + -> { @obj.instance_variable_get(obj) }.should.raise(NameError) end end @@ -57,20 +57,20 @@ end it "raises a NameError when passed :@ as an instance variable name" do - -> { @obj.instance_variable_get(:"@") }.should raise_error(NameError) + -> { @obj.instance_variable_get(:"@") }.should.raise(NameError) end it "raises a NameError when the passed Symbol does not start with an '@'" do - -> { @obj.instance_variable_get(:test) }.should raise_error(NameError) + -> { @obj.instance_variable_get(:test) }.should.raise(NameError) end it "raises a NameError when the passed Symbol is an invalid instance variable name" do - -> { @obj.instance_variable_get(:"@0") }.should raise_error(NameError) + -> { @obj.instance_variable_get(:"@0") }.should.raise(NameError) end it "returns nil or raises for frozen objects" do nil.instance_variable_get(:@foo).should == nil - -> { nil.instance_variable_get(:foo) }.should raise_error(NameError) + -> { nil.instance_variable_get(:foo) }.should.raise(NameError) :foo.instance_variable_get(:@foo).should == nil end end @@ -86,15 +86,15 @@ end it "raises a NameError when the passed String does not start with an '@'" do - -> { @obj.instance_variable_get("test") }.should raise_error(NameError) + -> { @obj.instance_variable_get("test") }.should.raise(NameError) end it "raises a NameError when the passed String is an invalid instance variable name" do - -> { @obj.instance_variable_get("@0") }.should raise_error(NameError) + -> { @obj.instance_variable_get("@0") }.should.raise(NameError) end it "raises a NameError when passed '@' as an instance variable name" do - -> { @obj.instance_variable_get("@") }.should raise_error(NameError) + -> { @obj.instance_variable_get("@") }.should.raise(NameError) end end @@ -105,7 +105,7 @@ end it "raises a TypeError" do - -> { @obj.instance_variable_get(10) }.should raise_error(TypeError) - -> { @obj.instance_variable_get(-10) }.should raise_error(TypeError) + -> { @obj.instance_variable_get(10) }.should.raise(TypeError) + -> { @obj.instance_variable_get(-10) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/kernel/instance_variable_set_spec.rb b/spec/ruby/core/kernel/instance_variable_set_spec.rb index 2c25f4366fa39d..bf165a824e9c73 100644 --- a/spec/ruby/core/kernel/instance_variable_set_spec.rb +++ b/spec/ruby/core/kernel/instance_variable_set_spec.rb @@ -18,26 +18,26 @@ def initialize(p1, p2) it "raises a NameError exception if the argument is not of form '@x'" do no_dog = Class.new - -> { no_dog.new.instance_variable_set(:c, "cat") }.should raise_error(NameError) + -> { no_dog.new.instance_variable_set(:c, "cat") }.should.raise(NameError) end it "raises a NameError exception if the argument is an invalid instance variable name" do digit_dog = Class.new - -> { digit_dog.new.instance_variable_set(:"@0", "cat") }.should raise_error(NameError) + -> { digit_dog.new.instance_variable_set(:"@0", "cat") }.should.raise(NameError) end it "raises a NameError when the argument is '@'" do dog_at = Class.new - -> { dog_at.new.instance_variable_set(:"@", "cat") }.should raise_error(NameError) + -> { dog_at.new.instance_variable_set(:"@", "cat") }.should.raise(NameError) end it "raises a TypeError if the instance variable name is an Integer" do - -> { "".instance_variable_set(1, 2) }.should raise_error(TypeError) + -> { "".instance_variable_set(1, 2) }.should.raise(TypeError) end it "raises a TypeError if the instance variable name is an object that does not respond to to_str" do class KernelSpecs::A; end - -> { "".instance_variable_set(KernelSpecs::A.new, 3) }.should raise_error(TypeError) + -> { "".instance_variable_set(KernelSpecs::A.new, 3) }.should.raise(TypeError) end it "raises a NameError if the passed object, when coerced with to_str, does not start with @" do @@ -46,11 +46,11 @@ def to_str ":c" end end - -> { "".instance_variable_set(KernelSpecs::B.new, 4) }.should raise_error(NameError) + -> { "".instance_variable_set(KernelSpecs::B.new, 4) }.should.raise(NameError) end it "raises a NameError if pass an object that cannot be a symbol" do - -> { "".instance_variable_set(:c, 1) }.should raise_error(NameError) + -> { "".instance_variable_set(:c, 1) }.should.raise(NameError) end it "accepts as instance variable name any instance of a class that responds to to_str" do @@ -78,16 +78,16 @@ def initialize end it "keeps stored object after any exceptions" do - -> { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(Exception) - @frozen.ivar.should equal(:origin) + -> { @frozen.instance_variable_set(:@ivar, :replacement) }.should.raise(Exception) + @frozen.ivar.should.equal?(:origin) end it "raises a FrozenError when passed replacement is identical to stored object" do - -> { @frozen.instance_variable_set(:@ivar, :origin) }.should raise_error(FrozenError) + -> { @frozen.instance_variable_set(:@ivar, :origin) }.should.raise(FrozenError) end it "raises a FrozenError when passed replacement is different from stored object" do - -> { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(FrozenError) + -> { @frozen.instance_variable_set(:@ivar, :replacement) }.should.raise(FrozenError) end it "accepts unicode instance variable names" do @@ -97,9 +97,9 @@ def initialize end it "raises for frozen objects" do - -> { nil.instance_variable_set(:@foo, 42) }.should raise_error(FrozenError) - -> { nil.instance_variable_set(:foo, 42) }.should raise_error(NameError) - -> { :foo.instance_variable_set(:@foo, 42) }.should raise_error(FrozenError) + -> { nil.instance_variable_set(:@foo, 42) }.should.raise(FrozenError) + -> { nil.instance_variable_set(:foo, 42) }.should.raise(NameError) + -> { :foo.instance_variable_set(:@foo, 42) }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/kernel/instance_variables_spec.rb b/spec/ruby/core/kernel/instance_variables_spec.rb index 677d8bb7b2bcf3..75c1d8f752f4de 100644 --- a/spec/ruby/core/kernel/instance_variables_spec.rb +++ b/spec/ruby/core/kernel/instance_variables_spec.rb @@ -11,7 +11,7 @@ it "returns the correct array if an instance variable is added" do a = 0 - ->{ a.instance_variable_set("@test", 1) }.should raise_error(RuntimeError) + ->{ a.instance_variable_set("@test", 1) }.should.raise(RuntimeError) end end diff --git a/spec/ruby/core/kernel/itself_spec.rb b/spec/ruby/core/kernel/itself_spec.rb index c906d7c3e888bb..c1f01fdc5e96f2 100644 --- a/spec/ruby/core/kernel/itself_spec.rb +++ b/spec/ruby/core/kernel/itself_spec.rb @@ -4,6 +4,6 @@ describe "Kernel#itself" do it "returns the receiver itself" do foo = Object.new - foo.itself.should equal foo + foo.itself.should.equal? foo end end diff --git a/spec/ruby/core/kernel/lambda_spec.rb b/spec/ruby/core/kernel/lambda_spec.rb index fa0e17b748967d..6ab89c2bbb9e75 100644 --- a/spec/ruby/core/kernel/lambda_spec.rb +++ b/spec/ruby/core/kernel/lambda_spec.rb @@ -8,52 +8,52 @@ it_behaves_like :kernel_lambda, :lambda it "is a private method" do - Kernel.should have_private_instance_method(:lambda) + Kernel.private_instance_methods(false).should.include?(:lambda) end it "creates a lambda-style Proc if given a literal block" do l = lambda { 42 } - l.lambda?.should be_true + l.lambda?.should == true end it "creates a lambda-style Proc if given a literal block via #send" do l = send(:lambda) { 42 } - l.lambda?.should be_true + l.lambda?.should == true end it "creates a lambda-style Proc if given a literal block via #__send__" do l = __send__(:lambda) { 42 } - l.lambda?.should be_true + l.lambda?.should == true end it "checks the arity of the call when no args are specified" do l = lambda { :called } l.call.should == :called - lambda { l.call(1) }.should raise_error(ArgumentError) - lambda { l.call(1, 2) }.should raise_error(ArgumentError) + lambda { l.call(1) }.should.raise(ArgumentError) + lambda { l.call(1, 2) }.should.raise(ArgumentError) end it "checks the arity when 1 arg is specified" do l = lambda { |a| :called } l.call(1).should == :called - lambda { l.call }.should raise_error(ArgumentError) - lambda { l.call(1, 2) }.should raise_error(ArgumentError) + lambda { l.call }.should.raise(ArgumentError) + lambda { l.call(1, 2) }.should.raise(ArgumentError) end it "does not check the arity when passing a Proc with &" do l = lambda { || :called } p = proc { || :called } - lambda { l.call(1) }.should raise_error(ArgumentError) + lambda { l.call(1) }.should.raise(ArgumentError) p.call(1).should == :called end it "accepts 0 arguments when used with ||" do lambda { lambda { || }.call(1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "strictly checks the arity when 0 or 2..inf args are specified" do @@ -61,15 +61,15 @@ lambda { l.call - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) lambda { l.call(1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) lambda { l.call(1,2) - }.should_not raise_error(ArgumentError) + }.should_not.raise(ArgumentError) end it "returns from the lambda itself, not the creation site of the lambda" do @@ -79,7 +79,7 @@ def test @reached_end_of_method = true end test - @reached_end_of_method.should be_true + @reached_end_of_method.should == true end it "allows long returns to flow through it" do @@ -94,13 +94,13 @@ def ret 2 end end - klass.new.lambda { 42 }.should be_an_instance_of Proc + klass.new.lambda { 42 }.should.instance_of? Proc klass.new.ret.should == 1 end context "when called without a literal block" do it "raises when proc isn't a lambda" do - -> { lambda(&proc{}) }.should raise_error(ArgumentError, /the lambda method requires a literal block/) + -> { lambda(&proc{}) }.should.raise(ArgumentError, /the lambda method requires a literal block/) end it "doesn't warn when proc is lambda" do diff --git a/spec/ruby/core/kernel/load_spec.rb b/spec/ruby/core/kernel/load_spec.rb index a165cc4acd451c..890aab8c27b9fe 100644 --- a/spec/ruby/core/kernel/load_spec.rb +++ b/spec/ruby/core/kernel/load_spec.rb @@ -13,7 +13,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:load) + Kernel.private_instance_methods(false).should.include?(:load) end it_behaves_like :kernel_require_basic, :load, CodeLoadingSpecs::Method.new diff --git a/spec/ruby/core/kernel/local_variables_spec.rb b/spec/ruby/core/kernel/local_variables_spec.rb index f6f1e15f52fa8e..40c343f7e46f41 100644 --- a/spec/ruby/core/kernel/local_variables_spec.rb +++ b/spec/ruby/core/kernel/local_variables_spec.rb @@ -7,14 +7,13 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:local_variables) + Kernel.private_instance_methods(false).should.include?(:local_variables) end it "contains locals as they are added" do a = 1 b = 2 - local_variables.should include(:a, :b) - local_variables.length.should == 2 + local_variables.sort.should == [:a, :b] end it "is accessible from bindings" do @@ -25,14 +24,12 @@ def local_var_foo end foo_binding = local_var_foo() res = eval("local_variables",foo_binding) - res.should include(:a, :b) - res.length.should == 2 + res.sort.should == [:a, :b] end it "is accessible in eval" do eval "a=1; b=2; ScratchPad.record local_variables" - ScratchPad.recorded.should include(:a, :b) - ScratchPad.recorded.length.should == 2 + ScratchPad.recorded.sort.should == [:a, :b] end it "includes only unique variable names" do diff --git a/spec/ruby/core/kernel/loop_spec.rb b/spec/ruby/core/kernel/loop_spec.rb index 7c76c7d28edc66..c2976e5cc5bc24 100644 --- a/spec/ruby/core/kernel/loop_spec.rb +++ b/spec/ruby/core/kernel/loop_spec.rb @@ -3,7 +3,7 @@ describe "Kernel.loop" do it "is a private method" do - Kernel.should have_private_instance_method(:loop) + Kernel.private_instance_methods(false).should.include?(:loop) end it "calls block until it is terminated by a break" do @@ -30,7 +30,7 @@ it "returns an enumerator if no block given" do enum = loop - enum.instance_of?(Enumerator).should be_true + enum.instance_of?(Enumerator).should == true cnt = 0 enum.each do |*args| raise "Args should be empty #{args.inspect}" unless args.empty? @@ -55,7 +55,7 @@ end it "does not rescue other errors" do - ->{ loop do raise StandardError end }.should raise_error( StandardError ) + ->{ loop do raise StandardError end }.should.raise( StandardError ) end it "returns StopIteration#result, the result value of a finished iterator" do diff --git a/spec/ruby/core/kernel/method_spec.rb b/spec/ruby/core/kernel/method_spec.rb index 3fc566d6a6fece..9187b8c7e7a33f 100644 --- a/spec/ruby/core/kernel/method_spec.rb +++ b/spec/ruby/core/kernel/method_spec.rb @@ -11,12 +11,12 @@ it "can be called on a private method" do @obj.send(:private_method).should == :private_method - @obj.method(:private_method).should be_an_instance_of(Method) + @obj.method(:private_method).should.instance_of?(Method) end it "can be called on a protected method" do @obj.send(:protected_method).should == :protected_method - @obj.method(:protected_method).should be_an_instance_of(Method) + @obj.method(:protected_method).should.instance_of?(Method) end it "will see an alias of the original method as == when in a derived class" do @@ -31,7 +31,7 @@ it "can be called even if we only respond_to_missing? method, true" do m = KernelSpecs::RespondViaMissing.new.method(:handled_privately) - m.should be_an_instance_of(Method) + m.should.instance_of?(Method) m.call(1, 2, 3).should == "Done handled_privately([1, 2, 3])" end @@ -45,7 +45,7 @@ def method_missing end end m = cls.new.method(:foo) - -> { m.call }.should raise_error(ArgumentError) + -> { m.call }.should.raise(ArgumentError) cls = Class.new do def respond_to_missing?(name, *) @@ -67,14 +67,22 @@ def method_missing(m) end it "raises a TypeError if the given name can't be converted to a String" do - -> { Object.method(nil) }.should raise_error(TypeError) - -> { Object.method([]) }.should raise_error(TypeError) + -> { Object.method(nil) }.should.raise(TypeError) + -> { Object.method([]) }.should.raise(TypeError) end it "raises a NoMethodError if the given argument raises a NoMethodError during type coercion to a String" do name = mock("method-name") name.should_receive(:to_str).and_raise(NoMethodError) - -> { Object.method(name) }.should raise_error(NoMethodError) + -> { Object.method(name) }.should.raise(NoMethodError) + + name = mock("method-name") + name.should_receive(:to_str).and_raise(NoMethodError) + begin + raise RuntimeError.new + rescue => cause + -> { Object.method(name) }.should.raise(NoMethodError, cause:) + end end end end diff --git a/spec/ruby/core/kernel/methods_spec.rb b/spec/ruby/core/kernel/methods_spec.rb index fb7a7e8be94741..cfa22aa05a51c5 100644 --- a/spec/ruby/core/kernel/methods_spec.rb +++ b/spec/ruby/core/kernel/methods_spec.rb @@ -5,67 +5,67 @@ # TODO: rewrite describe "Kernel#methods" do it "returns singleton methods defined by obj.meth" do - KernelSpecs::Methods.methods(false).should include(:ichi) + KernelSpecs::Methods.methods(false).should.include?(:ichi) end it "returns singleton methods defined in 'class << self'" do - KernelSpecs::Methods.methods(false).should include(:san) + KernelSpecs::Methods.methods(false).should.include?(:san) end it "returns private singleton methods defined by obj.meth" do - KernelSpecs::Methods.methods(false).should include(:shi) + KernelSpecs::Methods.methods(false).should.include?(:shi) end it "returns singleton methods defined in 'class << self' when it follows 'private'" do - KernelSpecs::Methods.methods(false).should include(:roku) + KernelSpecs::Methods.methods(false).should.include?(:roku) end it "does not return private singleton methods defined in 'class << self'" do - KernelSpecs::Methods.methods(false).should_not include(:shichi) + KernelSpecs::Methods.methods(false).should_not.include?(:shichi) end it "returns the publicly accessible methods of the object" do meths = KernelSpecs::Methods.methods(false) - meths.should include(:hachi, :ichi, :juu, :juu_ichi, - :juu_ni, :roku, :san, :shi) + meths.to_set.should >= Set[:hachi, :ichi, :juu, :juu_ichi, + :juu_ni, :roku, :san, :shi] KernelSpecs::Methods.new.methods(false).should == [] end it "returns the publicly accessible methods in the object, its ancestors and mixed-in modules" do meths = KernelSpecs::Methods.methods(false) & KernelSpecs::Methods.methods - meths.should include(:hachi, :ichi, :juu, :juu_ichi, - :juu_ni, :roku, :san, :shi) + meths.to_set.should >= Set[:hachi, :ichi, :juu, :juu_ichi, + :juu_ni, :roku, :san, :shi] - KernelSpecs::Methods.new.methods.should include(:ku, :ni, :juu_san) + KernelSpecs::Methods.new.methods.to_set.should >= Set[:ku, :ni, :juu_san] end it "returns methods added to the metaclass through extend" do meth = KernelSpecs::Methods.new - meth.methods.should_not include(:peekaboo) + meth.methods.should_not.include?(:peekaboo) meth.extend(KernelSpecs::Methods::MetaclassMethods) - meth.methods.should include(:peekaboo) + meth.methods.should.include?(:peekaboo) end it "does not return undefined singleton methods defined by obj.meth" do o = KernelSpecs::Child.new def o.single; end - o.methods.should include(:single) + o.methods.should.include?(:single) class << o; self; end.send :undef_method, :single - o.methods.should_not include(:single) + o.methods.should_not.include?(:single) end it "does not return superclass methods undefined in the object's class" do - KernelSpecs::Child.new.methods.should_not include(:parent_method) + KernelSpecs::Child.new.methods.should_not.include?(:parent_method) end it "does not return superclass methods undefined in a superclass" do - KernelSpecs::Grandchild.new.methods.should_not include(:parent_method) + KernelSpecs::Grandchild.new.methods.should_not.include?(:parent_method) end it "does not return included module methods undefined in the object's class" do - KernelSpecs::Grandchild.new.methods.should_not include(:parent_mixin_method) + KernelSpecs::Grandchild.new.methods.should_not.include?(:parent_mixin_method) end end diff --git a/spec/ruby/core/kernel/not_match_spec.rb b/spec/ruby/core/kernel/not_match_spec.rb index 082e56fed7dff6..4ed7ea7b42a1c1 100644 --- a/spec/ruby/core/kernel/not_match_spec.rb +++ b/spec/ruby/core/kernel/not_match_spec.rb @@ -15,7 +15,7 @@ def !~(obj) end it "raises NoMethodError if self does not respond to #=~" do - -> { Object.new !~ :foo }.should raise_error(NoMethodError) + -> { Object.new !~ :foo }.should.raise(NoMethodError) end it 'can be overridden in subclasses' do diff --git a/spec/ruby/core/kernel/open_spec.rb b/spec/ruby/core/kernel/open_spec.rb index 9d3f3760b96b3e..14a3c43cad246b 100644 --- a/spec/ruby/core/kernel/open_spec.rb +++ b/spec/ruby/core/kernel/open_spec.rb @@ -15,12 +15,12 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:open) + Kernel.private_instance_methods(false).should.include?(:open) end it "opens a file when given a valid filename" do @file = open(@name) - @file.should be_kind_of(File) + @file.should.is_a?(File) end it "opens a file when called with a block" do @@ -34,7 +34,7 @@ @io = open("|date") end begin - @io.should be_kind_of(IO) + @io.should.is_a?(IO) @io.read ensure @io.close @@ -64,7 +64,7 @@ @io = open("|date /t") end begin - @io.should be_kind_of(IO) + @io.should.is_a?(IO) @io.read ensure @io.close @@ -89,16 +89,16 @@ end it "raises an ArgumentError if not passed one argument" do - -> { open }.should raise_error(ArgumentError) + -> { open }.should.raise(ArgumentError) end it "accepts options as keyword arguments" do @file = open(@name, "r", 0666, flags: File::CREAT) - @file.should be_kind_of(File) + @file.should.is_a?(File) -> { open(@name, "r", 0666, {flags: File::CREAT}) - }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") + }.should.raise(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") end describe "when given an object that responds to to_open" do @@ -126,7 +126,7 @@ @file = File.open(@name) obj.should_receive(:to_open).and_return(@file) @file = open(obj) - @file.should be_kind_of(File) + @file.should.is_a?(File) end it "returns the value from #to_open" do @@ -167,9 +167,9 @@ def obj.to_open(*args, **kw) it "raises a TypeError if passed a non-String that does not respond to #to_open" do obj = mock('non-fileish') - -> { open(obj) }.should raise_error(TypeError) - -> { open(nil) }.should raise_error(TypeError) - -> { open(7) }.should raise_error(TypeError) + -> { open(obj) }.should.raise(TypeError) + -> { open(nil) }.should.raise(TypeError) + -> { open(7) }.should.raise(TypeError) end it "accepts nil for mode and permission" do diff --git a/spec/ruby/core/kernel/p_spec.rb b/spec/ruby/core/kernel/p_spec.rb index eae191aa54c504..f89716899a847d 100644 --- a/spec/ruby/core/kernel/p_spec.rb +++ b/spec/ruby/core/kernel/p_spec.rb @@ -13,7 +13,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:p) + Kernel.private_instance_methods(false).should.include?(:p) end # TODO: fix diff --git a/spec/ruby/core/kernel/print_spec.rb b/spec/ruby/core/kernel/print_spec.rb index 7e7c9b822db4fe..5473d22f71c8de 100644 --- a/spec/ruby/core/kernel/print_spec.rb +++ b/spec/ruby/core/kernel/print_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#print" do it "is a private method" do - Kernel.should have_private_instance_method(:print) + Kernel.private_instance_methods(false).should.include?(:print) end it "delegates to $stdout" do diff --git a/spec/ruby/core/kernel/printf_spec.rb b/spec/ruby/core/kernel/printf_spec.rb index 61bf955c25959e..50939b3794be0e 100644 --- a/spec/ruby/core/kernel/printf_spec.rb +++ b/spec/ruby/core/kernel/printf_spec.rb @@ -4,7 +4,7 @@ describe "Kernel#printf" do it "is a private method" do - Kernel.should have_private_instance_method(:printf) + Kernel.private_instance_methods(false).should.include?(:printf) end end diff --git a/spec/ruby/core/kernel/private_methods_spec.rb b/spec/ruby/core/kernel/private_methods_spec.rb index 041634d1e52e98..b0e6d042a9799d 100644 --- a/spec/ruby/core/kernel/private_methods_spec.rb +++ b/spec/ruby/core/kernel/private_methods_spec.rb @@ -6,23 +6,23 @@ describe "Kernel#private_methods" do it "returns a list of the names of privately accessible methods in the object" do m = KernelSpecs::Methods.private_methods(false) - m.should include(:shichi) + m.should.include?(:shichi) m = KernelSpecs::Methods.new.private_methods(false) - m.should include(:juu_shi) + m.should.include?(:juu_shi) end it "returns a list of the names of privately accessible methods in the object and its ancestors and mixed-in modules" do m = (KernelSpecs::Methods.private_methods(false) & KernelSpecs::Methods.private_methods) - m.should include(:shichi) + m.should.include?(:shichi) m = KernelSpecs::Methods.new.private_methods - m.should include(:juu_shi) + m.should.include?(:juu_shi) end it "returns private methods mixed in to the metaclass" do m = KernelSpecs::Methods.new m.extend(KernelSpecs::Methods::MetaclassMethods) - m.private_methods.should include(:shoo) + m.private_methods.should.include?(:shoo) end end diff --git a/spec/ruby/core/kernel/proc_spec.rb b/spec/ruby/core/kernel/proc_spec.rb index 6553b8fd04b2d7..1ba662177b2a17 100644 --- a/spec/ruby/core/kernel/proc_spec.rb +++ b/spec/ruby/core/kernel/proc_spec.rb @@ -6,20 +6,20 @@ describe "Kernel.proc" do it "is a private method" do - Kernel.should have_private_instance_method(:proc) + Kernel.private_instance_methods(false).should.include?(:proc) end it "creates a proc-style Proc if given a literal block" do l = proc { 42 } - l.lambda?.should be_false + l.lambda?.should == false end it "returned the passed Proc if given an existing Proc" do some_lambda = -> {} - some_lambda.lambda?.should be_true + some_lambda.lambda?.should == true l = proc(&some_lambda) - l.should equal(some_lambda) - l.lambda?.should be_true + l.should.equal?(some_lambda) + l.lambda?.should == true end it_behaves_like :kernel_lambda, :proc @@ -31,7 +31,7 @@ def test @reached_end_of_method = true end test - @reached_end_of_method.should be_nil + @reached_end_of_method.should == nil end end @@ -43,6 +43,6 @@ def some_method it "raises an ArgumentError when passed no block" do -> { some_method { "hello" } - }.should raise_error(ArgumentError, 'tried to create Proc object without a block') + }.should.raise(ArgumentError, 'tried to create Proc object without a block') end end diff --git a/spec/ruby/core/kernel/protected_methods_spec.rb b/spec/ruby/core/kernel/protected_methods_spec.rb index d3334e886b33fe..aecb9f5ffb3c62 100644 --- a/spec/ruby/core/kernel/protected_methods_spec.rb +++ b/spec/ruby/core/kernel/protected_methods_spec.rb @@ -8,21 +8,21 @@ # You should use have_protected_method() with the exception of this spec. describe "Kernel#protected_methods" do it "returns a list of the names of protected methods accessible in the object" do - KernelSpecs::Methods.protected_methods(false).sort.should include(:juu_ichi) - KernelSpecs::Methods.new.protected_methods(false).should include(:ku) + KernelSpecs::Methods.protected_methods(false).sort.should.include?(:juu_ichi) + KernelSpecs::Methods.new.protected_methods(false).should.include?(:ku) end it "returns a list of the names of protected methods accessible in the object and from its ancestors and mixed-in modules" do l1 = KernelSpecs::Methods.protected_methods(false) l2 = KernelSpecs::Methods.protected_methods - (l1 & l2).should include(:juu_ichi) - KernelSpecs::Methods.new.protected_methods.should include(:ku) + (l1 & l2).should.include?(:juu_ichi) + KernelSpecs::Methods.new.protected_methods.should.include?(:ku) end it "returns methods mixed in to the metaclass" do m = KernelSpecs::Methods.new m.extend(KernelSpecs::Methods::MetaclassMethods) - m.protected_methods.should include(:nopeeking) + m.protected_methods.should.include?(:nopeeking) end end diff --git a/spec/ruby/core/kernel/public_method_spec.rb b/spec/ruby/core/kernel/public_method_spec.rb index c5d54c777ef713..42b8f797d3c9f9 100644 --- a/spec/ruby/core/kernel/public_method_spec.rb +++ b/spec/ruby/core/kernel/public_method_spec.rb @@ -13,20 +13,20 @@ @obj.send(:private_method).should == :private_method -> do @obj.public_method(:private_method) - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError when called on a protected method" do @obj.send(:protected_method).should == :protected_method -> { @obj.public_method(:protected_method) - }.should raise_error(NameError) + }.should.raise(NameError) end it "raises a NameError if we only repond_to_missing? method, true" do obj = KernelSpecs::RespondViaMissing.new -> do obj.public_method(:handled_privately) - end.should raise_error(NameError) + end.should.raise(NameError) end end diff --git a/spec/ruby/core/kernel/public_methods_spec.rb b/spec/ruby/core/kernel/public_methods_spec.rb index a5512784fb97e3..e334ac9a55faff 100644 --- a/spec/ruby/core/kernel/public_methods_spec.rb +++ b/spec/ruby/core/kernel/public_methods_spec.rb @@ -5,31 +5,30 @@ # TODO: rewrite describe "Kernel#public_methods" do it "returns a list of the names of publicly accessible methods in the object" do - KernelSpecs::Methods.public_methods(false).sort.should include(:hachi, - :ichi, :juu, :juu_ni, :roku, :san, :shi) - KernelSpecs::Methods.new.public_methods(false).sort.should include(:juu_san, :ni) + KernelSpecs::Methods.public_methods(false).to_set.should >= Set[:hachi, :ichi, :juu, :juu_ni, :roku, :san, :shi] + KernelSpecs::Methods.new.public_methods(false).to_set.should >= Set[:juu_san, :ni] end it "returns a list of names without protected accessible methods in the object" do - KernelSpecs::Methods.public_methods(false).sort.should_not include(:juu_ichi) - KernelSpecs::Methods.new.public_methods(false).sort.should_not include(:ku) + KernelSpecs::Methods.public_methods(false).sort.should_not.include?(:juu_ichi) + KernelSpecs::Methods.new.public_methods(false).sort.should_not.include?(:ku) end it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do - (KernelSpecs::Methods.public_methods(false) & KernelSpecs::Methods.public_methods).sort.should include( - :hachi, :ichi, :juu, :juu_ni, :roku, :san, :shi) + (KernelSpecs::Methods.public_methods(false) & KernelSpecs::Methods.public_methods).to_set.should >= Set[ + :hachi, :ichi, :juu, :juu_ni, :roku, :san, :shi] m = KernelSpecs::Methods.new.public_methods - m.should include(:ni, :juu_san) + m.to_set.should >= Set[:ni, :juu_san] end it "returns methods mixed in to the metaclass" do m = KernelSpecs::Methods.new m.extend(KernelSpecs::Methods::MetaclassMethods) - m.public_methods.should include(:peekaboo) + m.public_methods.should.include?(:peekaboo) end it "returns public methods for immediates" do - 10.public_methods.should include(:divmod) + 10.public_methods.should.include?(:divmod) end end diff --git a/spec/ruby/core/kernel/public_send_spec.rb b/spec/ruby/core/kernel/public_send_spec.rb index b684b1729c78ed..6a4a969c77f339 100644 --- a/spec/ruby/core/kernel/public_send_spec.rb +++ b/spec/ruby/core/kernel/public_send_spec.rb @@ -29,7 +29,7 @@ def bar 'done' end end - -> { KernelSpecs::Foo.new.public_send(:bar)}.should raise_error(NoMethodError) + -> { KernelSpecs::Foo.new.public_send(:bar)}.should.raise(NoMethodError) end it "raises a NoMethodError if the named method is private" do @@ -41,7 +41,7 @@ def bar end -> { KernelSpecs::Foo.new.public_send(:bar) - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end context 'called from own public method' do @@ -70,11 +70,11 @@ def private_method end it "raises a NoMethodError if the method is protected" do - -> { @receiver.call_protected_method }.should raise_error(NoMethodError) + -> { @receiver.call_protected_method }.should.raise(NoMethodError) end it "raises a NoMethodError if the method is private" do - -> { @receiver.call_private_method }.should raise_error(NoMethodError) + -> { @receiver.call_private_method }.should.raise(NoMethodError) end end @@ -88,7 +88,7 @@ def bar end -> { KernelSpecs::Foo.new.public_send(:aka) - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end it "raises a NoMethodError if the named method is an alias of a protected method" do @@ -101,15 +101,15 @@ def bar end -> { KernelSpecs::Foo.new.public_send(:aka) - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end it "includes `public_send` in the backtrace when passed not enough arguments" do - -> { public_send() }.should raise_error(ArgumentError) { |e| e.backtrace[0].should =~ /[`'](?:Kernel#)?public_send'/ } + -> { public_send() }.should.raise(ArgumentError) { |e| e.backtrace[0].should =~ /[`'](?:Kernel#)?public_send'/ } end it "includes `public_send` in the backtrace when passed a single incorrect argument" do - -> { public_send(Object.new) }.should raise_error(TypeError) { |e| e.backtrace[0].should =~ /[`'](?:Kernel#)?public_send'/ } + -> { public_send(Object.new) }.should.raise(TypeError) { |e| e.backtrace[0].should =~ /[`'](?:Kernel#)?public_send'/ } end it_behaves_like :basicobject_send, :public_send diff --git a/spec/ruby/core/kernel/putc_spec.rb b/spec/ruby/core/kernel/putc_spec.rb index 74bd3765db7611..e6a20a9af184b7 100644 --- a/spec/ruby/core/kernel/putc_spec.rb +++ b/spec/ruby/core/kernel/putc_spec.rb @@ -4,7 +4,7 @@ describe "Kernel#putc" do it "is a private instance method" do - Kernel.should have_private_instance_method(:putc) + Kernel.private_instance_methods(false).should.include?(:putc) end end diff --git a/spec/ruby/core/kernel/puts_spec.rb b/spec/ruby/core/kernel/puts_spec.rb index 6eb38e8fcfdec4..eed18fcd50ecc0 100644 --- a/spec/ruby/core/kernel/puts_spec.rb +++ b/spec/ruby/core/kernel/puts_spec.rb @@ -15,7 +15,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:puts) + Kernel.private_instance_methods(false).should.include?(:puts) end it "delegates to $stdout.puts" do diff --git a/spec/ruby/core/kernel/raise_spec.rb b/spec/ruby/core/kernel/raise_spec.rb index d08303cd830b2f..6162677e170e4e 100644 --- a/spec/ruby/core/kernel/raise_spec.rb +++ b/spec/ruby/core/kernel/raise_spec.rb @@ -4,7 +4,7 @@ describe "Kernel#raise" do it "is a private method" do - Kernel.private_instance_methods.should include(:raise) + Kernel.private_instance_methods.should.include?(:raise) end # Shared specs expect a public #raise method. @@ -33,9 +33,9 @@ class << public_raiser raise ScratchPad.record :no_reraise end - end.should raise_error(Exception, "outer") + end.should.raise(Exception, "outer") - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "re-raises a previously rescued exception without overwriting the cause" do diff --git a/spec/ruby/core/kernel/rand_spec.rb b/spec/ruby/core/kernel/rand_spec.rb index 355e425792eca5..1bf5e225d9f9de 100644 --- a/spec/ruby/core/kernel/rand_spec.rb +++ b/spec/ruby/core/kernel/rand_spec.rb @@ -3,42 +3,42 @@ describe "Kernel#rand" do it "is a private method" do - Kernel.should have_private_instance_method(:rand) + Kernel.private_instance_methods(false).should.include?(:rand) end it "returns a float if no argument is passed" do - rand.should be_kind_of(Float) + rand.should.is_a?(Float) end it "returns an integer for an integer argument" do - rand(77).should be_kind_of(Integer) + rand(77).should.is_a?(Integer) end it "returns an integer for a float argument greater than 1" do - rand(1.3).should be_kind_of(Integer) + rand(1.3).should.is_a?(Integer) end it "returns a float for an argument between -1 and 1" do - rand(-0.999).should be_kind_of(Float) - rand(-0.01).should be_kind_of(Float) - rand(0).should be_kind_of(Float) - rand(0.01).should be_kind_of(Float) - rand(0.999).should be_kind_of(Float) + rand(-0.999).should.is_a?(Float) + rand(-0.01).should.is_a?(Float) + rand(0).should.is_a?(Float) + rand(0.01).should.is_a?(Float) + rand(0.999).should.is_a?(Float) end it "ignores the sign of the argument" do - [0, 1, 2, 3].should include(rand(-4)) + [0, 1, 2, 3].should.include?(rand(-4)) end it "never returns a value greater or equal to 1.0 with no arguments" do 1000.times do - (0...1.0).should include(rand) + (0...1.0).should.include?(rand) end end it "never returns a value greater or equal to any passed in max argument" do 1000.times do - (0...100).to_a.should include(rand(100)) + (0...100).to_a.should.include?(rand(100)) end end @@ -53,32 +53,32 @@ it "returns an Integer between the two Integers" do 1000.times do x = rand(4...6) - x.should be_kind_of(Integer) - (4...6).should include(x) + x.should.is_a?(Integer) + (4...6).should.include?(x) end end it "returns a Float between the given Integer and Float" do 1000.times do x = rand(4...6.5) - x.should be_kind_of(Float) - (4...6.5).should include(x) + x.should.is_a?(Float) + (4...6.5).should.include?(x) end end it "returns a Float between the given Float and Integer" do 1000.times do x = rand(3.5...6) - x.should be_kind_of(Float) - (3.5...6).should include(x) + x.should.is_a?(Float) + (3.5...6).should.include?(x) end end it "returns a Float between the two given Floats" do 1000.times do x = rand(3.5...6.5) - x.should be_kind_of(Float) - (3.5...6.5).should include(x) + x.should.is_a?(Float) + (3.5...6.5).should.include?(x) end end end @@ -87,32 +87,32 @@ it "returns an Integer between the two Integers" do 1000.times do x = rand(4..6) - x.should be_kind_of(Integer) - (4..6).should include(x) + x.should.is_a?(Integer) + (4..6).should.include?(x) end end it "returns a Float between the given Integer and Float" do 1000.times do x = rand(4..6.5) - x.should be_kind_of(Float) - (4..6.5).should include(x) + x.should.is_a?(Float) + (4..6.5).should.include?(x) end end it "returns a Float between the given Float and Integer" do 1000.times do x = rand(3.5..6) - x.should be_kind_of(Float) - (3.5..6).should include(x) + x.should.is_a?(Float) + (3.5..6).should.include?(x) end end it "returns a Float between the two given Floats" do 1000.times do x = rand(3.5..6.5) - x.should be_kind_of(Float) - (3.5..6.5).should include(x) + x.should.is_a?(Float) + (3.5..6.5).should.include?(x) end end end @@ -120,8 +120,8 @@ context "given an inclusive range between 0 and 1" do it "returns an Integer between the two Integers" do x = rand(0..1) - x.should be_kind_of(Integer) - (0..1).should include(x) + x.should.is_a?(Integer) + (0..1).should.include?(x) end it "returns a Float if at least one side is Float" do @@ -130,19 +130,19 @@ x2 = Random.new(seed).rand(0.0..1.0) x3 = Random.new(seed).rand(0.0..1) - x3.should be_kind_of(Float) - x1.should eql(x3) - x2.should eql(x3) + x3.should.is_a?(Float) + x1.should.eql?(x3) + x2.should.eql?(x3) - (0.0..1.0).should include(x3) + (0.0..1.0).should.include?(x3) end end context "given an exclusive range between 0 and 1" do it "returns zero as an Integer" do x = rand(0...1) - x.should be_kind_of(Integer) - x.should eql(0) + x.should.is_a?(Integer) + x.should.eql?(0) end it "returns a Float if at least one side is Float" do @@ -151,34 +151,34 @@ x2 = Random.new(seed).rand(0.0...1.0) x3 = Random.new(seed).rand(0.0...1) - x3.should be_kind_of(Float) - x1.should eql(x3) - x2.should eql(x3) + x3.should.is_a?(Float) + x1.should.eql?(x3) + x2.should.eql?(x3) - (0.0...1.0).should include(x3) + (0.0...1.0).should.include?(x3) end end it "returns a numeric for an range argument where max is < 1" do - rand(0.25..0.75).should be_kind_of(Numeric) + rand(0.25..0.75).should.is_a?(Numeric) end it "returns nil when range is backwards" do - rand(1..0).should be_nil + rand(1..0).should == nil end it "returns the range start/end when Float range is 0" do - rand(1.0..1.0).should eql(1.0) + rand(1.0..1.0).should.eql?(1.0) end it "returns the range start/end when Integer range is 0" do - rand(42..42).should eql(42) + rand(42..42).should.eql?(42) end it "supports custom object types" do - rand(KernelSpecs::CustomRangeInteger.new(1)..KernelSpecs::CustomRangeInteger.new(42)).should be_an_instance_of(KernelSpecs::CustomRangeInteger) - rand(KernelSpecs::CustomRangeFloat.new(1.0)..KernelSpecs::CustomRangeFloat.new(42.0)).should be_an_instance_of(KernelSpecs::CustomRangeFloat) - rand(Time.now..Time.now).should be_an_instance_of(Time) + rand(KernelSpecs::CustomRangeInteger.new(1)..KernelSpecs::CustomRangeInteger.new(42)).should.instance_of?(KernelSpecs::CustomRangeInteger) + rand(KernelSpecs::CustomRangeFloat.new(1.0)..KernelSpecs::CustomRangeFloat.new(42.0)).should.instance_of?(KernelSpecs::CustomRangeFloat) + rand(Time.now..Time.now).should.instance_of?(Time) end it "is random on boot" do diff --git a/spec/ruby/core/kernel/readline_spec.rb b/spec/ruby/core/kernel/readline_spec.rb index dce7b03dc8b5cd..86899d78d26639 100644 --- a/spec/ruby/core/kernel/readline_spec.rb +++ b/spec/ruby/core/kernel/readline_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#readline" do it "is a private method" do - Kernel.should have_private_instance_method(:readline) + Kernel.private_instance_methods(false).should.include?(:readline) end end diff --git a/spec/ruby/core/kernel/readlines_spec.rb b/spec/ruby/core/kernel/readlines_spec.rb index 2b6d65fff2e16f..c758014aabe884 100644 --- a/spec/ruby/core/kernel/readlines_spec.rb +++ b/spec/ruby/core/kernel/readlines_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#readlines" do it "is a private method" do - Kernel.should have_private_instance_method(:readlines) + Kernel.private_instance_methods(false).should.include?(:readlines) end end diff --git a/spec/ruby/core/kernel/remove_instance_variable_spec.rb b/spec/ruby/core/kernel/remove_instance_variable_spec.rb index 4e5ba5e0189cd8..114536064f407b 100644 --- a/spec/ruby/core/kernel/remove_instance_variable_spec.rb +++ b/spec/ruby/core/kernel/remove_instance_variable_spec.rb @@ -9,7 +9,7 @@ it "removes the instance variable" do @instance.send :remove_instance_variable, @object - @instance.instance_variable_defined?(@object).should be_false + @instance.instance_variable_defined?(@object).should == false end end @@ -19,39 +19,39 @@ end it "is a public method" do - Kernel.should have_public_instance_method(:remove_instance_variable, false) + Kernel.public_instance_methods(false).should.include?(:remove_instance_variable) end it "raises a NameError if the instance variable is not defined" do -> do @instance.send :remove_instance_variable, :@unknown - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError if the argument is not a valid instance variable name" do -> do @instance.send :remove_instance_variable, :"@0" - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a TypeError if passed an Object not defining #to_str" do -> do obj = mock("kernel remove_instance_variable") @instance.send :remove_instance_variable, obj - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a FrozenError if self is frozen" do o = Object.new o.freeze - -> { o.remove_instance_variable(:@foo) }.should raise_error(FrozenError) - -> { o.remove_instance_variable(:foo) }.should raise_error(NameError) + -> { o.remove_instance_variable(:@foo) }.should.raise(FrozenError) + -> { o.remove_instance_variable(:foo) }.should.raise(NameError) end it "raises for frozen objects" do - -> { nil.remove_instance_variable(:@foo) }.should raise_error(FrozenError) - -> { nil.remove_instance_variable(:foo) }.should raise_error(NameError) - -> { :foo.remove_instance_variable(:@foo) }.should raise_error(FrozenError) + -> { nil.remove_instance_variable(:@foo) }.should.raise(FrozenError) + -> { nil.remove_instance_variable(:foo) }.should.raise(NameError) + -> { :foo.remove_instance_variable(:@foo) }.should.raise(FrozenError) end describe "when passed a String" do diff --git a/spec/ruby/core/kernel/require_relative_spec.rb b/spec/ruby/core/kernel/require_relative_spec.rb index 6188d13a4e4219..332045b2006f37 100644 --- a/spec/ruby/core/kernel/require_relative_spec.rb +++ b/spec/ruby/core/kernel/require_relative_spec.rb @@ -27,14 +27,14 @@ end it "loads a path relative to current file" do - require_relative(@link).should be_true + require_relative(@link).should == true ScratchPad.recorded.should == [:loaded] end end end it "loads a path relative to the current file" do - require_relative(@path).should be_true + require_relative(@path).should == true ScratchPad.recorded.should == [:loaded] end @@ -42,14 +42,14 @@ it "synthetic file base name loads a file base name relative to the working directory" do Dir.chdir @abs_dir do - Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "foo.rb").should be_true + Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "foo.rb").should == true end ScratchPad.recorded.should == [:loaded] end it "synthetic file path loads a relative path relative to the working directory plus the directory of the synthetic path" do Dir.chdir @abs_dir do - Object.new.instance_eval("require_relative(File.join('..', #{File.basename(@path).inspect}))", "bar/foo.rb").should be_true + Object.new.instance_eval("require_relative(File.join('..', #{File.basename(@path).inspect}))", "bar/foo.rb").should == true end ScratchPad.recorded.should == [:loaded] end @@ -57,14 +57,14 @@ platform_is_not :windows do it "synthetic relative file path with a Windows path separator specified loads a relative path relative to the working directory" do Dir.chdir @abs_dir do - Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "bar\\foo.rb").should be_true + Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "bar\\foo.rb").should == true end ScratchPad.recorded.should == [:loaded] end end it "absolute file path loads a path relative to the absolute path" do - Object.new.instance_eval("require_relative(#{@path.inspect})", __FILE__).should be_true + Object.new.instance_eval("require_relative(#{@path.inspect})", __FILE__).should == true ScratchPad.recorded.should == [:loaded] end @@ -74,34 +74,34 @@ root = File.dirname(root) end root_relative = @abs_path[root.size..-1] - Object.new.instance_eval("require_relative(#{root_relative.inspect})", "/").should be_true + Object.new.instance_eval("require_relative(#{root_relative.inspect})", "/").should == true ScratchPad.recorded.should == [:loaded] end end it "loads a file defining many methods" do - require_relative("#{@dir}/methods_fixture.rb").should be_true + require_relative("#{@dir}/methods_fixture.rb").should == true ScratchPad.recorded.should == [:loaded] end it "raises a LoadError if the file does not exist" do - -> { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError) + -> { require_relative("#{@dir}/nonexistent.rb") }.should.raise(LoadError) ScratchPad.recorded.should == [] end it "raises a LoadError that includes the missing path" do missing_path = "#{@dir}/nonexistent.rb" expanded_missing_path = File.expand_path(missing_path, __dir__) - -> { require_relative(missing_path) }.should raise_error(LoadError) { |e| - e.message.should include(expanded_missing_path) + -> { require_relative(missing_path) }.should.raise(LoadError) { |e| + e.message.should.include?(expanded_missing_path) e.path.should == expanded_missing_path } ScratchPad.recorded.should == [] end it "raises a LoadError if basepath does not exist" do - -> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError) + -> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should.raise(LoadError) end it "stores the missing path in a LoadError object" do @@ -117,34 +117,34 @@ it "calls #to_str on non-String objects" do name = mock("load_fixture.rb mock") name.should_receive(:to_str).and_return(@path) - require_relative(name).should be_true + require_relative(name).should == true ScratchPad.recorded.should == [:loaded] end it "raises a TypeError if argument does not respond to #to_str" do - -> { require_relative(nil) }.should raise_error(TypeError) - -> { require_relative(42) }.should raise_error(TypeError) + -> { require_relative(nil) }.should.raise(TypeError) + -> { require_relative(42) }.should.raise(TypeError) -> { require_relative([@path,@path]) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a TypeError if passed an object that has #to_s but not #to_str" do name = mock("load_fixture.rb mock") name.stub!(:to_s).and_return(@path) - -> { require_relative(name) }.should raise_error(TypeError) + -> { require_relative(name) }.should.raise(TypeError) end it "raises a TypeError if #to_str does not return a String" do name = mock("#to_str returns nil") name.should_receive(:to_str).at_least(1).times.and_return(nil) - -> { require_relative(name) }.should raise_error(TypeError) + -> { require_relative(name) }.should.raise(TypeError) end it "calls #to_path on non-String objects" do name = mock("load_fixture.rb mock") name.should_receive(:to_path).and_return(@path) - require_relative(name).should be_true + require_relative(name).should == true ScratchPad.recorded.should == [:loaded] end @@ -153,13 +153,13 @@ to_path = mock("load_fixture_rb #to_path mock") name.should_receive(:to_path).and_return(to_path) to_path.should_receive(:to_str).and_return(@path) - require_relative(name).should be_true + require_relative(name).should == true ScratchPad.recorded.should == [:loaded] end describe "(file extensions)" do it "loads a .rb extensioned file when passed a non-extensioned path" do - require_relative("#{@dir}/load_fixture").should be_true + require_relative("#{@dir}/load_fixture").should == true ScratchPad.recorded.should == [:loaded] end @@ -168,20 +168,20 @@ $LOADED_FEATURES << "#{@abs_dir}/load_fixture.dylib" $LOADED_FEATURES << "#{@abs_dir}/load_fixture.so" $LOADED_FEATURES << "#{@abs_dir}/load_fixture.dll" - require_relative(@path).should be_true + require_relative(@path).should == true ScratchPad.recorded.should == [:loaded] end it "does not load a C-extension file if a .rb extensioned file is already loaded" do $LOADED_FEATURES << "#{@abs_dir}/load_fixture.rb" - require_relative("#{@dir}/load_fixture").should be_false + require_relative("#{@dir}/load_fixture").should == false ScratchPad.recorded.should == [] end it "loads a .rb extensioned file when passed a non-.rb extensioned path" do - require_relative("#{@dir}/load_fixture.ext").should be_true + require_relative("#{@dir}/load_fixture.ext").should == true ScratchPad.recorded.should == [:loaded] - $LOADED_FEATURES.should include "#{@abs_dir}/load_fixture.ext.rb" + $LOADED_FEATURES.should.include? "#{@abs_dir}/load_fixture.ext.rb" end it "loads a .rb extensioned file when a complex-extensioned C-extension file of the same name is loaded" do @@ -189,22 +189,22 @@ $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.dylib" $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.so" $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.dll" - require_relative("#{@dir}/load_fixture.ext").should be_true + require_relative("#{@dir}/load_fixture.ext").should == true ScratchPad.recorded.should == [:loaded] - $LOADED_FEATURES.should include "#{@abs_dir}/load_fixture.ext.rb" + $LOADED_FEATURES.should.include? "#{@abs_dir}/load_fixture.ext.rb" end it "does not load a C-extension file if a complex-extensioned .rb file is already loaded" do $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.rb" - require_relative("#{@dir}/load_fixture.ext").should be_false + require_relative("#{@dir}/load_fixture.ext").should == false ScratchPad.recorded.should == [] end end describe "($LOADED_FEATURES)" do it "stores an absolute path" do - require_relative(@path).should be_true - $LOADED_FEATURES.should include(@abs_path) + require_relative(@path).should == true + $LOADED_FEATURES.should.include?(@abs_path) end platform_is_not :windows, :wasi do @@ -231,8 +231,8 @@ ScratchPad.recorded.should == [:loaded] features = $LOADED_FEATURES.select { |path| path.end_with?('load_fixture.rb') } - features.should include(absolute_path) - features.should_not include(canonical_path) + features.should.include?(absolute_path) + features.should_not.include?(canonical_path) end it "stores the same path that __FILE__ returns in the required file" do @@ -249,26 +249,26 @@ it "does not store the path if the load fails" do saved_loaded_features = $LOADED_FEATURES.dup - -> { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError) + -> { require_relative("#{@dir}/raise_fixture.rb") }.should.raise(RuntimeError) $LOADED_FEATURES.should == saved_loaded_features end it "does not load an absolute path that is already stored" do $LOADED_FEATURES << @abs_path - require_relative(@path).should be_false + require_relative(@path).should == false ScratchPad.recorded.should == [] end it "adds the suffix of the resolved filename" do - require_relative("#{@dir}/load_fixture").should be_true - $LOADED_FEATURES.should include("#{@abs_dir}/load_fixture.rb") + require_relative("#{@dir}/load_fixture").should == true + $LOADED_FEATURES.should.include?("#{@abs_dir}/load_fixture.rb") end it "loads a path for a file already loaded with a relative path" do $LOAD_PATH << File.expand_path(@dir) $LOADED_FEATURES << "load_fixture.rb" << "load_fixture" - require_relative(@path).should be_true - $LOADED_FEATURES.should include(@abs_path) + require_relative(@path).should == true + $LOADED_FEATURES.should.include?(@abs_path) ScratchPad.recorded.should == [:loaded] end end @@ -288,22 +288,22 @@ end it "loads a path relative to the current file" do - require_relative(@path).should be_true + require_relative(@path).should == true ScratchPad.recorded.should == [:loaded] end it "loads a file defining many methods" do - require_relative("#{@dir}/methods_fixture.rb").should be_true + require_relative("#{@dir}/methods_fixture.rb").should == true ScratchPad.recorded.should == [:loaded] end it "raises a LoadError if the file does not exist" do - -> { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError) + -> { require_relative("#{@dir}/nonexistent.rb") }.should.raise(LoadError) ScratchPad.recorded.should == [] end it "raises a LoadError if basepath does not exist" do - -> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError) + -> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should.raise(LoadError) end it "stores the missing path in a LoadError object" do @@ -319,34 +319,34 @@ it "calls #to_str on non-String objects" do name = mock("load_fixture.rb mock") name.should_receive(:to_str).and_return(@path) - require_relative(name).should be_true + require_relative(name).should == true ScratchPad.recorded.should == [:loaded] end it "raises a TypeError if argument does not respond to #to_str" do - -> { require_relative(nil) }.should raise_error(TypeError) - -> { require_relative(42) }.should raise_error(TypeError) + -> { require_relative(nil) }.should.raise(TypeError) + -> { require_relative(42) }.should.raise(TypeError) -> { require_relative([@path,@path]) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a TypeError if passed an object that has #to_s but not #to_str" do name = mock("load_fixture.rb mock") name.stub!(:to_s).and_return(@path) - -> { require_relative(name) }.should raise_error(TypeError) + -> { require_relative(name) }.should.raise(TypeError) end it "raises a TypeError if #to_str does not return a String" do name = mock("#to_str returns nil") name.should_receive(:to_str).at_least(1).times.and_return(nil) - -> { require_relative(name) }.should raise_error(TypeError) + -> { require_relative(name) }.should.raise(TypeError) end it "calls #to_path on non-String objects" do name = mock("load_fixture.rb mock") name.should_receive(:to_path).and_return(@path) - require_relative(name).should be_true + require_relative(name).should == true ScratchPad.recorded.should == [:loaded] end @@ -355,13 +355,13 @@ to_path = mock("load_fixture_rb #to_path mock") name.should_receive(:to_path).and_return(to_path) to_path.should_receive(:to_str).and_return(@path) - require_relative(name).should be_true + require_relative(name).should == true ScratchPad.recorded.should == [:loaded] end describe "(file extensions)" do it "loads a .rb extensioned file when passed a non-extensioned path" do - require_relative("#{@dir}/load_fixture").should be_true + require_relative("#{@dir}/load_fixture").should == true ScratchPad.recorded.should == [:loaded] end @@ -370,20 +370,20 @@ $LOADED_FEATURES << "#{@abs_dir}/load_fixture.dylib" $LOADED_FEATURES << "#{@abs_dir}/load_fixture.so" $LOADED_FEATURES << "#{@abs_dir}/load_fixture.dll" - require_relative(@path).should be_true + require_relative(@path).should == true ScratchPad.recorded.should == [:loaded] end it "does not load a C-extension file if a .rb extensioned file is already loaded" do $LOADED_FEATURES << "#{@abs_dir}/load_fixture.rb" - require_relative("#{@dir}/load_fixture").should be_false + require_relative("#{@dir}/load_fixture").should == false ScratchPad.recorded.should == [] end it "loads a .rb extensioned file when passed a non-.rb extensioned path" do - require_relative("#{@dir}/load_fixture.ext").should be_true + require_relative("#{@dir}/load_fixture.ext").should == true ScratchPad.recorded.should == [:loaded] - $LOADED_FEATURES.should include "#{@abs_dir}/load_fixture.ext.rb" + $LOADED_FEATURES.should.include? "#{@abs_dir}/load_fixture.ext.rb" end it "loads a .rb extensioned file when a complex-extensioned C-extension file of the same name is loaded" do @@ -391,46 +391,46 @@ $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.dylib" $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.so" $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.dll" - require_relative("#{@dir}/load_fixture.ext").should be_true + require_relative("#{@dir}/load_fixture.ext").should == true ScratchPad.recorded.should == [:loaded] - $LOADED_FEATURES.should include "#{@abs_dir}/load_fixture.ext.rb" + $LOADED_FEATURES.should.include? "#{@abs_dir}/load_fixture.ext.rb" end it "does not load a C-extension file if a complex-extensioned .rb file is already loaded" do $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.rb" - require_relative("#{@dir}/load_fixture.ext").should be_false + require_relative("#{@dir}/load_fixture.ext").should == false ScratchPad.recorded.should == [] end end describe "($LOAD_FEATURES)" do it "stores an absolute path" do - require_relative(@path).should be_true - $LOADED_FEATURES.should include(@abs_path) + require_relative(@path).should == true + $LOADED_FEATURES.should.include?(@abs_path) end it "does not store the path if the load fails" do saved_loaded_features = $LOADED_FEATURES.dup - -> { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError) + -> { require_relative("#{@dir}/raise_fixture.rb") }.should.raise(RuntimeError) $LOADED_FEATURES.should == saved_loaded_features end it "does not load an absolute path that is already stored" do $LOADED_FEATURES << @abs_path - require_relative(@path).should be_false + require_relative(@path).should == false ScratchPad.recorded.should == [] end it "adds the suffix of the resolved filename" do - require_relative("#{@dir}/load_fixture").should be_true - $LOADED_FEATURES.should include("#{@abs_dir}/load_fixture.rb") + require_relative("#{@dir}/load_fixture").should == true + $LOADED_FEATURES.should.include?("#{@abs_dir}/load_fixture.rb") end it "loads a path for a file already loaded with a relative path" do $LOAD_PATH << File.expand_path(@dir) $LOADED_FEATURES << "load_fixture.rb" << "load_fixture" - require_relative(@path).should be_true - $LOADED_FEATURES.should include(@abs_path) + require_relative(@path).should == true + $LOADED_FEATURES.should.include?(@abs_path) ScratchPad.recorded.should == [:loaded] end end diff --git a/spec/ruby/core/kernel/require_spec.rb b/spec/ruby/core/kernel/require_spec.rb index c609809df55e92..19c19e55948777 100644 --- a/spec/ruby/core/kernel/require_spec.rb +++ b/spec/ruby/core/kernel/require_spec.rb @@ -13,7 +13,7 @@ # if this fails, update your rubygems it "is a private method" do - Kernel.should have_private_instance_method(:require) + Kernel.private_instance_methods(false).should.include?(:require) end it "provided features are already required" do diff --git a/spec/ruby/core/kernel/respond_to_missing_spec.rb b/spec/ruby/core/kernel/respond_to_missing_spec.rb index cc82031e26b7c5..08c9184fb49825 100644 --- a/spec/ruby/core/kernel/respond_to_missing_spec.rb +++ b/spec/ruby/core/kernel/respond_to_missing_spec.rb @@ -7,7 +7,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:respond_to_missing?, false) + Kernel.private_instance_methods(false).should.include?(:respond_to_missing?) end it "is only an instance method" do @@ -18,7 +18,7 @@ obj = mock('object') obj.stub!(:glark) obj.should_not_receive(:respond_to_missing?) - obj.respond_to?(:glark).should be_true + obj.respond_to?(:glark).should == true end it "is called with a 2nd argument of false when #respond_to? is" do @@ -48,39 +48,39 @@ it "causes #respond_to? to return true if called and not returning false" do obj = mock('object') obj.should_receive(:respond_to_missing?).with(:undefined_method, false).and_return(:glark) - obj.respond_to?(:undefined_method).should be_true + obj.respond_to?(:undefined_method).should == true end it "causes #respond_to? to return false if called and returning false" do obj = mock('object') obj.should_receive(:respond_to_missing?).with(:undefined_method, false).and_return(false) - obj.respond_to?(:undefined_method).should be_false + obj.respond_to?(:undefined_method).should == false end it "causes #respond_to? to return false if called and returning nil" do obj = mock('object') obj.should_receive(:respond_to_missing?).with(:undefined_method, false).and_return(nil) - obj.respond_to?(:undefined_method).should be_false + obj.respond_to?(:undefined_method).should == false end it "isn't called when obj responds to the given public method" do @a.should_not_receive(:respond_to_missing?) - @a.respond_to?(:pub_method).should be_true + @a.respond_to?(:pub_method).should == true end it "isn't called when obj responds to the given public method, include_private = true" do @a.should_not_receive(:respond_to_missing?) - @a.respond_to?(:pub_method, true).should be_true + @a.respond_to?(:pub_method, true).should == true end it "is called when obj responds to the given protected method, include_private = false" do @a.should_receive(:respond_to_missing?) - @a.respond_to?(:protected_method, false).should be_false + @a.respond_to?(:protected_method, false).should == false end it "isn't called when obj responds to the given protected method, include_private = true" do @a.should_not_receive(:respond_to_missing?) - @a.respond_to?(:protected_method, true).should be_true + @a.respond_to?(:protected_method, true).should == true end it "is called when obj responds to the given private method, include_private = false" do @@ -90,7 +90,7 @@ it "isn't called when obj responds to the given private method, include_private = true" do @a.should_not_receive(:respond_to_missing?) - @a.respond_to?(:private_method, true).should be_true + @a.respond_to?(:private_method, true).should == true end it "is called for missing class methods" do diff --git a/spec/ruby/core/kernel/respond_to_spec.rb b/spec/ruby/core/kernel/respond_to_spec.rb index f256767a5657f0..72ab4eebe14f39 100644 --- a/spec/ruby/core/kernel/respond_to_spec.rb +++ b/spec/ruby/core/kernel/respond_to_spec.rb @@ -7,7 +7,7 @@ end it "is a public method" do - Kernel.should have_public_instance_method(:respond_to?, false) + Kernel.public_instance_methods(false).should.include?(:respond_to?) end it "is only an instance method" do @@ -25,7 +25,7 @@ end it "throws a type error if argument can't be coerced into a Symbol" do - -> { @a.respond_to?(Object.new) }.should raise_error(TypeError, /is not a symbol nor a string/) + -> { @a.respond_to?(Object.new) }.should.raise(TypeError, /is not a symbol nor a string/) end it "returns false if obj responds to the given protected method" do @@ -61,7 +61,7 @@ it "does not change method visibility when finding private method" do KernelSpecs::VisibilityChange.respond_to?(:new, false).should == false KernelSpecs::VisibilityChange.respond_to?(:new, true).should == true - -> { KernelSpecs::VisibilityChange.new }.should raise_error(NoMethodError) + -> { KernelSpecs::VisibilityChange.new }.should.raise(NoMethodError) end it "indicates if an object responds to a particular message" do diff --git a/spec/ruby/core/kernel/select_spec.rb b/spec/ruby/core/kernel/select_spec.rb index df23414b2848e7..58c963c1a4a974 100644 --- a/spec/ruby/core/kernel/select_spec.rb +++ b/spec/ruby/core/kernel/select_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#select" do it "is a private method" do - Kernel.should have_private_instance_method(:select) + Kernel.private_instance_methods(false).should.include?(:select) end end diff --git a/spec/ruby/core/kernel/set_trace_func_spec.rb b/spec/ruby/core/kernel/set_trace_func_spec.rb index 1f43e7a009807e..5201812f2f5234 100644 --- a/spec/ruby/core/kernel/set_trace_func_spec.rb +++ b/spec/ruby/core/kernel/set_trace_func_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#set_trace_func" do it "is a private method" do - Kernel.should have_private_instance_method(:set_trace_func) + Kernel.private_instance_methods(false).should.include?(:set_trace_func) end end diff --git a/spec/ruby/core/kernel/shared/dup_clone.rb b/spec/ruby/core/kernel/shared/dup_clone.rb index 4fac6006e106c5..3fbf918283dfab 100644 --- a/spec/ruby/core/kernel/shared/dup_clone.rb +++ b/spec/ruby/core/kernel/shared/dup_clone.rb @@ -40,7 +40,7 @@ def initialize_copy(original) o.obj = array o2 = o.send(@method) - o2.obj.should equal(o.obj) + o2.obj.should.equal?(o.obj) end it "calls #initialize_copy on the NEW object if available, passing in original object" do @@ -49,7 +49,7 @@ def initialize_copy(original) o.obj.should == :original o2.obj.should == :init_copy - o2.original.should equal(o) + o2.original.should.equal?(o) end it "does not preserve the object_id" do @@ -81,11 +81,11 @@ def initialize_copy(original) it "returns self for Complex" do c = Complex(1.3, 3.1) - c.send(@method).should equal c + c.send(@method).should.equal? c end it "returns self for Rational" do r = Rational(1, 3) - r.send(@method).should equal r + r.send(@method).should.equal? r end end diff --git a/spec/ruby/core/kernel/shared/kind_of.rb b/spec/ruby/core/kernel/shared/kind_of.rb index aef6f1c1d867c7..a5e0eab08f8fe1 100644 --- a/spec/ruby/core/kernel/shared/kind_of.rb +++ b/spec/ruby/core/kernel/shared/kind_of.rb @@ -40,10 +40,10 @@ end it "raises a TypeError if given an object that is not a Class nor a Module" do - -> { @o.send(@method, 1) }.should raise_error(TypeError) - -> { @o.send(@method, 'KindaClass') }.should raise_error(TypeError) - -> { @o.send(@method, :KindaClass) }.should raise_error(TypeError) - -> { @o.send(@method, Object.new) }.should raise_error(TypeError) + -> { @o.send(@method, 1) }.should.raise(TypeError) + -> { @o.send(@method, 'KindaClass') }.should.raise(TypeError) + -> { @o.send(@method, :KindaClass) }.should.raise(TypeError) + -> { @o.send(@method, Object.new) }.should.raise(TypeError) end it "does not take into account `class` method overriding" do diff --git a/spec/ruby/core/kernel/shared/lambda.rb b/spec/ruby/core/kernel/shared/lambda.rb index c70640082a1312..83de06bb417920 100644 --- a/spec/ruby/core/kernel/shared/lambda.rb +++ b/spec/ruby/core/kernel/shared/lambda.rb @@ -5,7 +5,7 @@ it "raises an ArgumentError when no block is given" do suppress_warning do - -> { send(@method) }.should raise_error(ArgumentError) + -> { send(@method) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/kernel/shared/load.rb b/spec/ruby/core/kernel/shared/load.rb index 62c5c7be9bf55c..20d23a623e60f7 100644 --- a/spec/ruby/core/kernel/shared/load.rb +++ b/spec/ruby/core/kernel/shared/load.rb @@ -15,19 +15,19 @@ # This behavior is specific to Kernel#load, it differs for Kernel#require it "loads a non-extensioned file as a Ruby source file" do path = File.expand_path "load_fixture", CODE_LOADING_DIR - @object.load(path).should be_true + @object.load(path).should == true ScratchPad.recorded.should == [:no_ext] end it "loads a non .rb extensioned file as a Ruby source file" do path = File.expand_path "load_fixture.ext", CODE_LOADING_DIR - @object.load(path).should be_true + @object.load(path).should == true ScratchPad.recorded.should == [:no_rb_ext] end it "loads from the current working directory" do Dir.chdir CODE_LOADING_DIR do - @object.load("load_fixture.rb").should be_true + @object.load("load_fixture.rb").should == true ScratchPad.recorded.should == [:loaded] end end @@ -35,88 +35,88 @@ # This behavior is specific to Kernel#load, it differs for Kernel#require it "does not look for a c-extension file when passed a path without extension (when no .rb is present)" do path = File.join CODE_LOADING_DIR, "a", "load_fixture" - -> { @object.send(@method, path) }.should raise_error(LoadError) + -> { @object.send(@method, path) }.should.raise(LoadError) end end it "loads a file that recursively requires itself" do path = File.expand_path "recursive_require_fixture.rb", CODE_LOADING_DIR -> { - @object.load(path).should be_true + @object.load(path).should == true }.should complain(/circular require considered harmful/, verbose: true) ScratchPad.recorded.should == [:loaded, :loaded] end it "loads a file that recursively loads itself" do path = File.expand_path "recursive_load_fixture.rb", CODE_LOADING_DIR - @object.load(path).should be_true + @object.load(path).should == true ScratchPad.recorded.should == [:loaded, :loaded] end it "loads a file each time the method is called" do - @object.load(@path).should be_true - @object.load(@path).should be_true + @object.load(@path).should == true + @object.load(@path).should == true ScratchPad.recorded.should == [:loaded, :loaded] end it "loads a file even when the name appears in $LOADED_FEATURES" do $LOADED_FEATURES << @path - @object.load(@path).should be_true + @object.load(@path).should == true ScratchPad.recorded.should == [:loaded] end it "loads a file that has been loaded by #require" do - @object.require(@path).should be_true - @object.load(@path).should be_true + @object.require(@path).should == true + @object.load(@path).should == true ScratchPad.recorded.should == [:loaded, :loaded] end it "loads file even after $LOAD_PATH change" do $LOAD_PATH << CODE_LOADING_DIR - @object.load("load_fixture.rb").should be_true + @object.load("load_fixture.rb").should == true $LOAD_PATH.unshift CODE_LOADING_DIR + "/gem" - @object.load("load_fixture.rb").should be_true + @object.load("load_fixture.rb").should == true ScratchPad.recorded.should == [:loaded, :loaded_gem] end it "does not cause #require with the same path to fail" do - @object.load(@path).should be_true - @object.require(@path).should be_true + @object.load(@path).should == true + @object.require(@path).should == true ScratchPad.recorded.should == [:loaded, :loaded] end it "does not add the loaded path to $LOADED_FEATURES" do saved_loaded_features = $LOADED_FEATURES.dup - @object.load(@path).should be_true + @object.load(@path).should == true $LOADED_FEATURES.should == saved_loaded_features end it "raises a LoadError if passed a non-extensioned path that does not exist but a .rb extensioned path does exist" do path = File.expand_path "load_ext_fixture", CODE_LOADING_DIR - -> { @object.load(path) }.should raise_error(LoadError) + -> { @object.load(path) }.should.raise(LoadError) end describe "when passed true for 'wrap'" do it "loads from an existing path" do path = File.expand_path "load_wrap_fixture.rb", CODE_LOADING_DIR - @object.load(path, true).should be_true + @object.load(path, true).should == true end it "sets the enclosing scope to an anonymous module" do path = File.expand_path "load_wrap_fixture.rb", CODE_LOADING_DIR @object.load(path, true) - Object.const_defined?(:LoadSpecWrap).should be_false + Object.const_defined?(:LoadSpecWrap).should == false wrap_module = ScratchPad.recorded[1] - wrap_module.should be_an_instance_of(Module) + wrap_module.should.instance_of?(Module) end it "allows referencing outside namespaces" do path = File.expand_path "load_wrap_fixture.rb", CODE_LOADING_DIR @object.load(path, true) - ScratchPad.recorded[0].should equal(String) + ScratchPad.recorded[0].should.equal?(String) end it "sets self as a copy of the top-level main" do @@ -126,8 +126,8 @@ top_level = ScratchPad.recorded[2] top_level.to_s.should == "main" top_level.method(:to_s).owner.should == top_level.singleton_class - top_level.should_not equal(main) - top_level.should be_an_instance_of(Object) + top_level.should_not.equal?(main) + top_level.should.instance_of?(Object) end it "includes modules included in main's singleton class in self's class" do @@ -159,7 +159,7 @@ end it "does not pollute the receiver" do - -> { @object.send(:top_level_method) }.should raise_error(NameError) + -> { @object.send(:top_level_method) }.should.raise(NameError) end end end @@ -170,8 +170,8 @@ mod = Module.new @object.load(path, mod) - Object.const_defined?(:LoadSpecWrap).should be_false - mod.const_defined?(:LoadSpecWrap).should be_true + Object.const_defined?(:LoadSpecWrap).should == false + mod.const_defined?(:LoadSpecWrap).should == true wrap_module = ScratchPad.recorded[1] wrap_module.should == mod @@ -208,7 +208,7 @@ end it "expands a tilde to the HOME environment variable as the path to load" do - @object.require("~/load_fixture.rb").should be_true + @object.require("~/load_fixture.rb").should == true ScratchPad.recorded.should == [:loaded] end end diff --git a/spec/ruby/core/kernel/shared/method.rb b/spec/ruby/core/kernel/shared/method.rb index 8b6ab23fd399d2..82abc287d10e95 100644 --- a/spec/ruby/core/kernel/shared/method.rb +++ b/spec/ruby/core/kernel/shared/method.rb @@ -4,26 +4,26 @@ it "returns a method object for a valid method" do class KernelSpecs::Foo; def bar; 'done'; end; end m = KernelSpecs::Foo.new.send(@method, :bar) - m.should be_an_instance_of Method + m.should.instance_of? Method m.call.should == 'done' end it "returns a method object for a valid singleton method" do class KernelSpecs::Foo; def self.bar; 'class done'; end; end m = KernelSpecs::Foo.send(@method, :bar) - m.should be_an_instance_of Method + m.should.instance_of? Method m.call.should == 'class done' end it "returns a method object if respond_to_missing?(method) is true" do m = KernelSpecs::RespondViaMissing.new.send(@method, :handled_publicly) - m.should be_an_instance_of Method + m.should.instance_of? Method m.call(42).should == "Done handled_publicly([42])" end it "the returned method object if respond_to_missing?(method) calls #method_missing with a Symbol name" do m = KernelSpecs::RespondViaMissing.new.send(@method, "handled_publicly") - m.should be_an_instance_of Method + m.should.instance_of? Method m.call(42).should == "Done handled_publicly([42])" end @@ -31,12 +31,12 @@ class KernelSpecs::Foo; def self.bar; 'class done'; end; end class KernelSpecs::Foo; def bar; 'done'; end; end -> { KernelSpecs::Foo.new.send(@method, :invalid_and_silly_method_name) - }.should raise_error(NameError) + }.should.raise(NameError) end it "raises a NameError for an invalid singleton method name" do class KernelSpecs::Foo; def self.bar; 'done'; end; end - -> { KernelSpecs::Foo.send(@method, :baz) }.should raise_error(NameError) + -> { KernelSpecs::Foo.send(@method, :baz) }.should.raise(NameError) end it "changes the method called for super on a target aliased method" do diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb index ef5b9486c6157d..6272b00665d4e9 100644 --- a/spec/ruby/core/kernel/shared/require.rb +++ b/spec/ruby/core/kernel/shared/require.rb @@ -2,26 +2,26 @@ describe "(path resolution)" do it "loads an absolute path" do path = File.expand_path "load_fixture.rb", CODE_LOADING_DIR - @object.send(@method, path).should be_true + @object.send(@method, path).should == true ScratchPad.recorded.should == [:loaded] end it "loads a non-canonical absolute path" do path = File.join CODE_LOADING_DIR, "..", "code", "load_fixture.rb" - @object.send(@method, path).should be_true + @object.send(@method, path).should == true ScratchPad.recorded.should == [:loaded] end it "loads a file defining many methods" do path = File.expand_path "methods_fixture.rb", CODE_LOADING_DIR - @object.send(@method, path).should be_true + @object.send(@method, path).should == true ScratchPad.recorded.should == [:loaded] end it "raises a LoadError if the file does not exist" do path = File.expand_path "nonexistent.rb", CODE_LOADING_DIR File.should_not.exist?(path) - -> { @object.send(@method, path) }.should raise_error(LoadError) + -> { @object.send(@method, path) }.should.raise(LoadError) ScratchPad.recorded.should == [] end @@ -42,7 +42,7 @@ it "raises a LoadError" do File.should.exist?(@path) - -> { @object.send(@method, @path) }.should raise_error(LoadError) + -> { @object.send(@method, @path) }.should.raise(LoadError) end end end @@ -52,24 +52,24 @@ path = File.expand_path "load_fixture.rb", CODE_LOADING_DIR name = mock("load_fixture.rb mock") name.should_receive(:to_str).and_return(path) - @object.send(@method, name).should be_true + @object.send(@method, name).should == true ScratchPad.recorded.should == [:loaded] end it "raises a TypeError if passed nil" do - -> { @object.send(@method, nil) }.should raise_error(TypeError) + -> { @object.send(@method, nil) }.should.raise(TypeError) end it "raises a TypeError if passed an Integer" do - -> { @object.send(@method, 42) }.should raise_error(TypeError) + -> { @object.send(@method, 42) }.should.raise(TypeError) end it "raises a TypeError if passed an Array" do - -> { @object.send(@method, []) }.should raise_error(TypeError) + -> { @object.send(@method, []) }.should.raise(TypeError) end it "raises a TypeError if passed an object that does not provide #to_str" do - -> { @object.send(@method, mock("not a filename")) }.should raise_error(TypeError) + -> { @object.send(@method, mock("not a filename")) }.should.raise(TypeError) end it "raises a TypeError if passed an object that has #to_s but not #to_str" do @@ -77,14 +77,14 @@ name.stub!(:to_s).and_return("load_fixture.rb") $LOAD_PATH << "." Dir.chdir CODE_LOADING_DIR do - -> { @object.send(@method, name) }.should raise_error(TypeError) + -> { @object.send(@method, name) }.should.raise(TypeError) end end it "raises a TypeError if #to_str does not return a String" do name = mock("#to_str returns nil") name.should_receive(:to_str).at_least(1).times.and_return(nil) - -> { @object.send(@method, name) }.should raise_error(TypeError) + -> { @object.send(@method, name) }.should.raise(TypeError) end it "calls #to_path on non-String objects" do @@ -92,7 +92,7 @@ name.stub!(:to_path).and_return("load_fixture.rb") $LOAD_PATH << "." Dir.chdir CODE_LOADING_DIR do - @object.send(@method, name).should be_true + @object.send(@method, name).should == true end ScratchPad.recorded.should == [:loaded] end @@ -101,7 +101,7 @@ path = File.expand_path "load_fixture.rb", CODE_LOADING_DIR str = mock("load_fixture.rb mock") str.should_receive(:to_path).and_return(path) - @object.send(@method, str).should be_true + @object.send(@method, str).should == true ScratchPad.recorded.should == [:loaded] end @@ -111,21 +111,21 @@ to_path = mock("load_fixture_rb #to_path mock") name.should_receive(:to_path).and_return(to_path) to_path.should_receive(:to_str).and_return(path) - @object.send(@method, name).should be_true + @object.send(@method, name).should == true ScratchPad.recorded.should == [:loaded] end # "http://redmine.ruby-lang.org/issues/show/2578" it "loads a ./ relative path from the current working directory with empty $LOAD_PATH" do Dir.chdir CODE_LOADING_DIR do - @object.send(@method, "./load_fixture.rb").should be_true + @object.send(@method, "./load_fixture.rb").should == true end ScratchPad.recorded.should == [:loaded] end it "loads a ../ relative path from the current working directory with empty $LOAD_PATH" do Dir.chdir CODE_LOADING_DIR do - @object.send(@method, "../code/load_fixture.rb").should be_true + @object.send(@method, "../code/load_fixture.rb").should == true end ScratchPad.recorded.should == [:loaded] end @@ -133,7 +133,7 @@ it "loads a ./ relative path from the current working directory with non-empty $LOAD_PATH" do $LOAD_PATH << "an_irrelevant_dir" Dir.chdir CODE_LOADING_DIR do - @object.send(@method, "./load_fixture.rb").should be_true + @object.send(@method, "./load_fixture.rb").should == true end ScratchPad.recorded.should == [:loaded] end @@ -141,7 +141,7 @@ it "loads a ../ relative path from the current working directory with non-empty $LOAD_PATH" do $LOAD_PATH << "an_irrelevant_dir" Dir.chdir CODE_LOADING_DIR do - @object.send(@method, "../code/load_fixture.rb").should be_true + @object.send(@method, "../code/load_fixture.rb").should == true end ScratchPad.recorded.should == [:loaded] end @@ -149,14 +149,14 @@ it "loads a non-canonical path from the current working directory with non-empty $LOAD_PATH" do $LOAD_PATH << "an_irrelevant_dir" Dir.chdir CODE_LOADING_DIR do - @object.send(@method, "../code/../code/load_fixture.rb").should be_true + @object.send(@method, "../code/../code/load_fixture.rb").should == true end ScratchPad.recorded.should == [:loaded] end it "resolves a filename against $LOAD_PATH entries" do $LOAD_PATH << CODE_LOADING_DIR - @object.send(@method, "load_fixture.rb").should be_true + @object.send(@method, "load_fixture.rb").should == true ScratchPad.recorded.should == [:loaded] end @@ -164,15 +164,15 @@ obj = mock("to_path") obj.should_receive(:to_path).at_least(:once).and_return(CODE_LOADING_DIR) $LOAD_PATH << obj - @object.send(@method, "load_fixture.rb").should be_true + @object.send(@method, "load_fixture.rb").should == true ScratchPad.recorded.should == [:loaded] end it "does not require file twice after $LOAD_PATH change" do $LOAD_PATH << CODE_LOADING_DIR - @object.require("load_fixture.rb").should be_true + @object.require("load_fixture.rb").should == true $LOAD_PATH.push CODE_LOADING_DIR + "/gem" - @object.require("load_fixture.rb").should be_false + @object.require("load_fixture.rb").should == false ScratchPad.recorded.should == [:loaded] end @@ -180,7 +180,7 @@ $LOAD_PATH << CODE_LOADING_DIR -> do @object.send(@method, "./load_fixture.rb") - end.should raise_error(LoadError) + end.should.raise(LoadError) ScratchPad.recorded.should == [] end @@ -188,13 +188,13 @@ $LOAD_PATH << CODE_LOADING_DIR -> do @object.send(@method, "../code/load_fixture.rb") - end.should raise_error(LoadError) + end.should.raise(LoadError) ScratchPad.recorded.should == [] end it "resolves a non-canonical path against $LOAD_PATH entries" do $LOAD_PATH << File.dirname(CODE_LOADING_DIR) - @object.send(@method, "code/../code/load_fixture.rb").should be_true + @object.send(@method, "code/../code/load_fixture.rb").should == true ScratchPad.recorded.should == [:loaded] end @@ -203,7 +203,7 @@ sep = File::Separator + File::Separator path = ["..", "code", "load_fixture.rb"].join(sep) Dir.chdir CODE_LOADING_DIR do - @object.send(@method, path).should be_true + @object.send(@method, path).should == true end ScratchPad.recorded.should == [:loaded] end @@ -214,7 +214,7 @@ describe "(path resolution)" do it "loads .rb file when passed absolute path without extension" do path = File.expand_path "load_fixture", CODE_LOADING_DIR - @object.send(@method, path).should be_true + @object.send(@method, path).should == true # This should _not_ be [:no_ext] ScratchPad.recorded.should == [:loaded] end @@ -223,7 +223,7 @@ it "loads c-extension file when passed absolute path without extension when no .rb is present" do # the error message is specific to what dlerror() returns path = File.join CODE_LOADING_DIR, "a", "load_fixture" - -> { @object.send(@method, path) }.should raise_error(LoadError) + -> { @object.send(@method, path) }.should.raise(LoadError) end end @@ -231,20 +231,20 @@ it "loads .bundle file when passed absolute path with .so" do # the error message is specific to what dlerror() returns path = File.join CODE_LOADING_DIR, "a", "load_fixture.so" - -> { @object.send(@method, path) }.should raise_error(LoadError) + -> { @object.send(@method, path) }.should.raise(LoadError) end end it "does not try an extra .rb if the path already ends in .rb" do path = File.join CODE_LOADING_DIR, "d", "load_fixture.rb" - -> { @object.send(@method, path) }.should raise_error(LoadError) + -> { @object.send(@method, path) }.should.raise(LoadError) end # For reference see [ruby-core:24155] in which matz confirms this feature is # intentional for security reasons. it "does not load a bare filename unless the current working directory is in $LOAD_PATH" do Dir.chdir CODE_LOADING_DIR do - -> { @object.require("load_fixture.rb") }.should raise_error(LoadError) + -> { @object.require("load_fixture.rb") }.should.raise(LoadError) ScratchPad.recorded.should == [] end end @@ -253,7 +253,7 @@ Dir.chdir File.dirname(CODE_LOADING_DIR) do -> do @object.require("code/load_fixture.rb") - end.should raise_error(LoadError) + end.should.raise(LoadError) ScratchPad.recorded.should == [] end end @@ -261,7 +261,7 @@ it "loads a file that recursively requires itself" do path = File.expand_path "recursive_require_fixture.rb", CODE_LOADING_DIR -> { - @object.require(path).should be_true + @object.require(path).should == true }.should complain(/circular require considered harmful/, verbose: true) ScratchPad.recorded.should == [:loaded] end @@ -284,15 +284,15 @@ end it "loads a .rb extensioned file when a C-extension file exists on an earlier load path" do - @object.require("load_fixture").should be_true + @object.require("load_fixture").should == true ScratchPad.recorded.should == [:loaded] end it "does not load a feature twice when $LOAD_PATH has been modified" do $LOAD_PATH.replace [CODE_LOADING_DIR] - @object.require("load_fixture").should be_true + @object.require("load_fixture").should == true $LOAD_PATH.replace [File.expand_path("b", CODE_LOADING_DIR), CODE_LOADING_DIR] - @object.require("load_fixture").should be_false + @object.require("load_fixture").should == false end it "stores the missing path in a LoadError object" do @@ -300,7 +300,7 @@ -> { @object.send(@method, path) - }.should raise_error(LoadError) { |e| + }.should.raise(LoadError) { |e| e.path.should == path } end @@ -310,7 +310,7 @@ it "loads a .rb extensioned file when passed a non-extensioned path" do path = File.expand_path "load_fixture", CODE_LOADING_DIR File.should.exist?(path) - @object.require(path).should be_true + @object.require(path).should == true ScratchPad.recorded.should == [:loaded] end @@ -320,21 +320,21 @@ $LOADED_FEATURES << File.expand_path("load_fixture.so", CODE_LOADING_DIR) $LOADED_FEATURES << File.expand_path("load_fixture.dll", CODE_LOADING_DIR) path = File.expand_path "load_fixture", CODE_LOADING_DIR - @object.require(path).should be_true + @object.require(path).should == true ScratchPad.recorded.should == [:loaded] end it "does not load a C-extension file if a .rb extensioned file is already loaded" do $LOADED_FEATURES << File.expand_path("load_fixture.rb", CODE_LOADING_DIR) path = File.expand_path "load_fixture", CODE_LOADING_DIR - @object.require(path).should be_false + @object.require(path).should == false ScratchPad.recorded.should == [] end it "loads a .rb extensioned file when passed a non-.rb extensioned path" do path = File.expand_path "load_fixture.ext", CODE_LOADING_DIR File.should.exist?(path) - @object.require(path).should be_true + @object.require(path).should == true ScratchPad.recorded.should == [:loaded] end @@ -344,14 +344,14 @@ $LOADED_FEATURES << File.expand_path("load_fixture.ext.so", CODE_LOADING_DIR) $LOADED_FEATURES << File.expand_path("load_fixture.ext.dll", CODE_LOADING_DIR) path = File.expand_path "load_fixture.ext", CODE_LOADING_DIR - @object.require(path).should be_true + @object.require(path).should == true ScratchPad.recorded.should == [:loaded] end it "does not load a C-extension file if a complex-extensioned .rb file is already loaded" do $LOADED_FEATURES << File.expand_path("load_fixture.ext.rb", CODE_LOADING_DIR) path = File.expand_path "load_fixture.ext", CODE_LOADING_DIR - @object.require(path).should be_false + @object.require(path).should == false ScratchPad.recorded.should == [] end end @@ -362,8 +362,8 @@ end it "stores an absolute path" do - @object.require(@path).should be_true - $LOADED_FEATURES.should include(@path) + @object.require(@path).should == true + $LOADED_FEATURES.should.include?(@path) end platform_is_not :windows do @@ -383,23 +383,23 @@ it "does not canonicalize the path and stores a path with symlinks" do symlink_path = "#{@symlink_to_code_dir}/load_fixture.rb" canonical_path = "#{CODE_LOADING_DIR}/load_fixture.rb" - @object.require(symlink_path).should be_true + @object.require(symlink_path).should == true ScratchPad.recorded.should == [:loaded] features = $LOADED_FEATURES.select { |path| path.end_with?('load_fixture.rb') } - features.should include(symlink_path) - features.should_not include(canonical_path) + features.should.include?(symlink_path) + features.should_not.include?(canonical_path) end it "stores the same path that __FILE__ returns in the required file" do symlink_path = "#{@symlink_to_code_dir}/load_fixture_and__FILE__.rb" - @object.require(symlink_path).should be_true + @object.require(symlink_path).should == true loaded_feature = $LOADED_FEATURES.last ScratchPad.recorded.should == [loaded_feature] end it "requires only once when a new matching file added to path" do - @object.require('load_fixture').should be_true + @object.require('load_fixture').should == true ScratchPad.recorded.should == [:loaded] symlink_to_code_dir_two = tmp("codesymlinktwo") @@ -407,7 +407,7 @@ begin $LOAD_PATH.unshift(symlink_to_code_dir_two) - @object.require('load_fixture').should be_false + @object.require('load_fixture').should == false ensure rm_r symlink_to_code_dir_two end @@ -433,7 +433,7 @@ it "canonicalizes the entry in $LOAD_PATH but not the filename passed to #require" do $LOAD_PATH.unshift(@symlink_to_dir) - @object.require("symfile").should be_true + @object.require("symfile").should == true loaded_feature = "#{@dir}/symfile.rb" ScratchPad.recorded.should == [loaded_feature] $".last.should == loaded_feature @@ -445,20 +445,20 @@ it "does not store the path if the load fails" do $LOAD_PATH << CODE_LOADING_DIR saved_loaded_features = $LOADED_FEATURES.dup - -> { @object.require("raise_fixture.rb") }.should raise_error(RuntimeError) + -> { @object.require("raise_fixture.rb") }.should.raise(RuntimeError) $LOADED_FEATURES.should == saved_loaded_features end it "does not load an absolute path that is already stored" do $LOADED_FEATURES << @path - @object.require(@path).should be_false + @object.require(@path).should == false ScratchPad.recorded.should == [] end it "does not load a ./ relative path that is already stored" do $LOADED_FEATURES << "./load_fixture.rb" Dir.chdir CODE_LOADING_DIR do - @object.require("./load_fixture.rb").should be_false + @object.require("./load_fixture.rb").should == false end ScratchPad.recorded.should == [] end @@ -466,7 +466,7 @@ it "does not load a ../ relative path that is already stored" do $LOADED_FEATURES << "../load_fixture.rb" Dir.chdir CODE_LOADING_DIR do - @object.require("../load_fixture.rb").should be_false + @object.require("../load_fixture.rb").should == false end ScratchPad.recorded.should == [] end @@ -474,27 +474,27 @@ it "does not load a non-canonical path that is already stored" do $LOADED_FEATURES << "code/../code/load_fixture.rb" $LOAD_PATH << File.dirname(CODE_LOADING_DIR) - @object.require("code/../code/load_fixture.rb").should be_false + @object.require("code/../code/load_fixture.rb").should == false ScratchPad.recorded.should == [] end it "respects being replaced with a new array" do prev = $LOADED_FEATURES.dup - @object.require(@path).should be_true - $LOADED_FEATURES.should include(@path) + @object.require(@path).should == true + $LOADED_FEATURES.should.include?(@path) $LOADED_FEATURES.replace(prev) - $LOADED_FEATURES.should_not include(@path) - @object.require(@path).should be_true - $LOADED_FEATURES.should include(@path) + $LOADED_FEATURES.should_not.include?(@path) + @object.require(@path).should == true + $LOADED_FEATURES.should.include?(@path) end it "does not load twice the same file with and without extension" do $LOAD_PATH << CODE_LOADING_DIR - @object.require("load_fixture.rb").should be_true - @object.require("load_fixture").should be_false + @object.require("load_fixture.rb").should == true + @object.require("load_fixture").should == false end describe "when a non-extensioned file is in $LOADED_FEATURES" do @@ -504,19 +504,19 @@ it "loads a .rb extensioned file when a non extensioned file is in $LOADED_FEATURES" do $LOAD_PATH << CODE_LOADING_DIR - @object.require("load_fixture").should be_true + @object.require("load_fixture").should == true ScratchPad.recorded.should == [:loaded] end it "loads a .rb extensioned file from a subdirectory" do $LOAD_PATH << File.dirname(CODE_LOADING_DIR) - @object.require("code/load_fixture").should be_true + @object.require("code/load_fixture").should == true ScratchPad.recorded.should == [:loaded] end it "returns false if the file is not found" do Dir.chdir File.dirname(CODE_LOADING_DIR) do - @object.require("load_fixture").should be_false + @object.require("load_fixture").should == false ScratchPad.recorded.should == [] end end @@ -524,7 +524,7 @@ it "returns false when passed a path and the file is not found" do $LOADED_FEATURES << "code/load_fixture" Dir.chdir CODE_LOADING_DIR do - @object.require("code/load_fixture").should be_false + @object.require("code/load_fixture").should == false ScratchPad.recorded.should == [] end end @@ -532,16 +532,16 @@ it "stores ../ relative paths as absolute paths" do Dir.chdir CODE_LOADING_DIR do - @object.require("../code/load_fixture.rb").should be_true + @object.require("../code/load_fixture.rb").should == true end - $LOADED_FEATURES.should include(@path) + $LOADED_FEATURES.should.include?(@path) end it "stores ./ relative paths as absolute paths" do Dir.chdir CODE_LOADING_DIR do - @object.require("./load_fixture.rb").should be_true + @object.require("./load_fixture.rb").should == true end - $LOADED_FEATURES.should include(@path) + $LOADED_FEATURES.should.include?(@path) end it "collapses duplicate path separators" do @@ -549,27 +549,27 @@ sep = File::Separator + File::Separator path = ["..", "code", "load_fixture.rb"].join(sep) Dir.chdir CODE_LOADING_DIR do - @object.require(path).should be_true + @object.require(path).should == true end - $LOADED_FEATURES.should include(@path) + $LOADED_FEATURES.should.include?(@path) end it "expands absolute paths containing .." do path = File.join CODE_LOADING_DIR, "..", "code", "load_fixture.rb" - @object.require(path).should be_true - $LOADED_FEATURES.should include(@path) + @object.require(path).should == true + $LOADED_FEATURES.should.include?(@path) end it "adds the suffix of the resolved filename" do $LOAD_PATH << CODE_LOADING_DIR - @object.require("load_fixture").should be_true - $LOADED_FEATURES.should include(@path) + @object.require("load_fixture").should == true + $LOADED_FEATURES.should.include?(@path) end it "does not load a non-canonical path for a file already loaded" do $LOADED_FEATURES << @path $LOAD_PATH << File.dirname(CODE_LOADING_DIR) - @object.require("code/../code/load_fixture.rb").should be_false + @object.require("code/../code/load_fixture.rb").should == false ScratchPad.recorded.should == [] end @@ -577,7 +577,7 @@ $LOADED_FEATURES << @path $LOAD_PATH << "an_irrelevant_dir" Dir.chdir CODE_LOADING_DIR do - @object.require("./load_fixture.rb").should be_false + @object.require("./load_fixture.rb").should == false end ScratchPad.recorded.should == [] end @@ -586,7 +586,7 @@ $LOADED_FEATURES << @path $LOAD_PATH << "an_irrelevant_dir" Dir.chdir CODE_LOADING_DIR do - @object.require("../code/load_fixture.rb").should be_false + @object.require("../code/load_fixture.rb").should == false end ScratchPad.recorded.should == [] end @@ -594,26 +594,26 @@ it "unicode_normalize is part of core and not $LOADED_FEATURES" do features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems') features.lines.each { |feature| - feature.should_not include("unicode_normalize") + feature.should_not.include?("unicode_normalize") } - -> { @object.require("unicode_normalize") }.should raise_error(LoadError) + -> { @object.require("unicode_normalize") }.should.raise(LoadError) end it "does not load a file earlier on the $LOAD_PATH when other similar features were already loaded" do Dir.chdir CODE_LOADING_DIR do - @object.send(@method, "../code/load_fixture").should be_true + @object.send(@method, "../code/load_fixture").should == true end ScratchPad.recorded.should == [:loaded] $LOAD_PATH.unshift "#{CODE_LOADING_DIR}/b" # This loads because the above load was not on the $LOAD_PATH - @object.send(@method, "load_fixture").should be_true + @object.send(@method, "load_fixture").should == true ScratchPad.recorded.should == [:loaded, :loaded] $LOAD_PATH.unshift "#{CODE_LOADING_DIR}/c" # This does not load because the above load was on the $LOAD_PATH - @object.send(@method, "load_fixture").should be_false + @object.send(@method, "load_fixture").should == false ScratchPad.recorded.should == [:loaded, :loaded] end end @@ -631,13 +631,13 @@ # "#3171" it "performs tilde expansion on a .rb file before storing paths in $LOADED_FEATURES" do - @object.require("~/load_fixture.rb").should be_true - $LOADED_FEATURES.should include(@path) + @object.require("~/load_fixture.rb").should == true + $LOADED_FEATURES.should.include?(@path) end it "performs tilde expansion on a non-extensioned file before storing paths in $LOADED_FEATURES" do - @object.require("~/load_fixture").should be_true - $LOADED_FEATURES.should include(@path) + @object.require("~/load_fixture").should == true + $LOADED_FEATURES.should.include?(@path) end end @@ -694,8 +694,8 @@ t1.join t2.join - t1_res.should be_true - t2_res.should be_false + t1_res.should == true + t2_res.should == false ScratchPad.recorded.should == [:con_pre, :con_post, :t2_post, :t1_post] end @@ -719,8 +719,8 @@ t1.join t2.join - t1_res.should be_true - t2_res.should be_true + t1_res.should == true + t2_res.should == true ScratchPad.recorded.should == [:con2_pre, :con3, :con2_post] end @@ -738,7 +738,7 @@ -> { @object.require(@path) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) Thread.pass until fin ScratchPad.recorded << :t1_post @@ -759,7 +759,7 @@ t1.join t2.join - t2_res.should be_true + t2_res.should == true ScratchPad.recorded.should == [:con_pre, :con_pre, :con_post, :t2_post, :t1_post] end @@ -779,7 +779,7 @@ -> { @object.require(@path) - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) raised = true @@ -807,8 +807,8 @@ t1.join t2.join - t1_res.should be_false - t2_res.should be_true + t1_res.should == false + t2_res.should == true ScratchPad.recorded.should == [:con_pre, :con_pre, :con_post, :t2_post, :t1_post] end @@ -819,7 +819,7 @@ -> { @object.send(@method, path) - }.should raise_error(LoadError) { |e| + }.should.raise(LoadError) { |e| e.path.should == path } end @@ -828,7 +828,7 @@ it "does not store the missing path in a LoadError object when c-extension file exists but loading fails and passed absolute path without extension" do # the error message is specific to what dlerror() returns path = File.join CODE_LOADING_DIR, "a", "load_fixture" - -> { @object.send(@method, path) }.should raise_error(LoadError) { |e| + -> { @object.send(@method, path) }.should.raise(LoadError) { |e| e.path.should == nil } end @@ -838,7 +838,7 @@ it "does not store the missing path in a LoadError object when c-extension file exists but loading fails and passed absolute path with extension" do # the error message is specific to what dlerror() returns path = File.join CODE_LOADING_DIR, "a", "load_fixture.bundle" - -> { @object.send(@method, path) }.should raise_error(LoadError) { |e| + -> { @object.send(@method, path) }.should.raise(LoadError) { |e| e.path.should == nil } end diff --git a/spec/ruby/core/kernel/shared/sprintf.rb b/spec/ruby/core/kernel/shared/sprintf.rb index e18747e6b851cc..fe77b5f45bc4bf 100644 --- a/spec/ruby/core/kernel/shared/sprintf.rb +++ b/spec/ruby/core/kernel/shared/sprintf.rb @@ -28,7 +28,7 @@ def obj.to_i; 10; end it "raises TypeError exception if cannot convert to Integer" do -> { @method.call("%b", Object.new) - }.should raise_error(TypeError) + }.should.raise(TypeError) end ["b", "B"].each do |f| @@ -122,7 +122,7 @@ def obj.to_i; 10; end it "raises TypeError exception if cannot convert to Float" do -> { @method.call("%f", Object.new) - }.should raise_error(TypeError) + }.should.raise(TypeError) end {"e" => "e", "E" => "E"}.each_pair do |f, exp| @@ -391,7 +391,7 @@ def obj.to_str -> { @method.call("%s", obj) - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end it "formats a partial substring without including omitted characters" do @@ -444,7 +444,7 @@ def obj.to_str it "alone raises an ArgumentError" do -> { @method.call("%") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "is escaped by %" do @@ -551,7 +551,7 @@ def obj.to_str it "raises exception if argument number is bigger than actual arguments list" do -> { @method.call("%4$d", 1, 2, 3) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "ignores '-' sign" do @@ -562,7 +562,7 @@ def obj.to_str it "raises ArgumentError exception when absolute and relative argument numbers are mixed" do -> { @method.call("%1$d %d", 1, 2) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -812,7 +812,7 @@ def obj.to_str it "raises ArgumentError when is mixed with width" do -> { @method.call("%*10d", 10, 112) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end end @@ -911,7 +911,7 @@ def obj.to_str it "cannot be mixed with unnamed style" do -> { @method.call("%d %d", 1, foo: "123") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -931,7 +931,7 @@ def obj.to_str it "cannot be mixed with unnamed style" do -> { @method.call("%d %{foo}", 1, foo: "123") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "respects Hash#default when there is no set key" do @@ -942,15 +942,15 @@ def obj.to_str it "raises KeyError when Hash#default returns nil" do -> { @method.call("%{foo}", {}) - }.should raise_error(KeyError, 'key{foo} not found') + }.should.raise(KeyError, 'key{foo} not found') -> { @method.call("%{foo}", Hash.new(nil)) - }.should raise_error(KeyError, 'key{foo} not found') + }.should.raise(KeyError, 'key{foo} not found') -> { @method.call("%{foo}", Hash.new { nil }) - }.should raise_error(KeyError, 'key{foo} not found') + }.should.raise(KeyError, 'key{foo} not found') end it "accepts a nil value for an existing key" do @@ -978,21 +978,21 @@ def obj.to_str; end it "raises a KeyError" do -> { @method.call("%s", @object) - }.should raise_error(KeyError) + }.should.raise(KeyError) end it "sets the Hash as the receiver of KeyError" do -> { @method.call("%s", @object) - }.should raise_error(KeyError) { |err| - err.receiver.should equal(@object) + }.should.raise(KeyError) { |err| + err.receiver.should.equal?(@object) } end it "sets the unmatched key as the key of KeyError" do -> { @method.call("%s", @object) - }.should raise_error(KeyError) { |err| + }.should.raise(KeyError) { |err| err.key.to_s.should == 'foo' } end diff --git a/spec/ruby/core/kernel/shared/sprintf_encoding.rb b/spec/ruby/core/kernel/shared/sprintf_encoding.rb index 7ec0fe4c48cfd4..849c95cbb76864 100644 --- a/spec/ruby/core/kernel/shared/sprintf_encoding.rb +++ b/spec/ruby/core/kernel/shared/sprintf_encoding.rb @@ -4,19 +4,19 @@ it "can produce a string with valid encoding" do string = @method.call("good day %{valid}", valid: "e") string.encoding.should == Encoding::UTF_8 - string.valid_encoding?.should be_true + string.valid_encoding?.should == true end it "can produce a string with invalid encoding" do string = @method.call("good day %{invalid}", invalid: "\x80") string.encoding.should == Encoding::UTF_8 - string.valid_encoding?.should be_false + string.valid_encoding?.should == false end it "returns a String in the same encoding as the format String if compatible" do string = "%s".dup.force_encoding(Encoding::KOI8_U) result = @method.call(string, "dogs") - result.encoding.should equal(Encoding::KOI8_U) + result.encoding.should.equal?(Encoding::KOI8_U) end it "returns a String in the argument's encoding if format encoding is more restrictive" do @@ -24,7 +24,7 @@ argument = "b\303\274r".dup.force_encoding(Encoding::UTF_8) result = @method.call(string, argument) - result.encoding.should equal(Encoding::UTF_8) + result.encoding.should.equal?(Encoding::UTF_8) end it "raises Encoding::CompatibilityError if both encodings are ASCII compatible and there are not ASCII characters" do @@ -33,7 +33,7 @@ -> { @method.call(string, argument) - }.should raise_error(Encoding::CompatibilityError) + }.should.raise(Encoding::CompatibilityError) end describe "%c" do @@ -52,7 +52,7 @@ -> { @method.call(format, 1286) - }.should raise_error(RangeError, /out of char range/) + }.should.raise(RangeError, /out of char range/) end it "uses the encoding of the format string to interpret codepoints" do diff --git a/spec/ruby/core/kernel/shared/then.rb b/spec/ruby/core/kernel/shared/then.rb index b52075371fcdf8..c71393bf507696 100644 --- a/spec/ruby/core/kernel/shared/then.rb +++ b/spec/ruby/core/kernel/shared/then.rb @@ -1,20 +1,20 @@ describe :kernel_then, shared: true do it "yields self" do object = Object.new - object.send(@method) { |o| o.should equal object } + object.send(@method) { |o| o.should.equal? object } end it "returns the block return value" do object = Object.new - object.send(@method) { 42 }.should equal 42 + object.send(@method) { 42 }.should.equal? 42 end it "returns a sized Enumerator when no block given" do object = Object.new enum = object.send(@method) - enum.should be_an_instance_of Enumerator - enum.size.should equal 1 - enum.peek.should equal object - enum.first.should equal object + enum.should.instance_of? Enumerator + enum.size.should.equal? 1 + enum.peek.should.equal? object + enum.first.should.equal? object end end diff --git a/spec/ruby/core/kernel/singleton_class_spec.rb b/spec/ruby/core/kernel/singleton_class_spec.rb index 23c400f9bd7153..7915272937d4a2 100644 --- a/spec/ruby/core/kernel/singleton_class_spec.rb +++ b/spec/ruby/core/kernel/singleton_class_spec.rb @@ -21,27 +21,27 @@ end it "raises TypeError for Integer" do - -> { 123.singleton_class }.should raise_error(TypeError, "can't define singleton") + -> { 123.singleton_class }.should.raise(TypeError, "can't define singleton") end it "raises TypeError for Float" do - -> { 3.14.singleton_class }.should raise_error(TypeError, "can't define singleton") + -> { 3.14.singleton_class }.should.raise(TypeError, "can't define singleton") end it "raises TypeError for Symbol" do - -> { :foo.singleton_class }.should raise_error(TypeError, "can't define singleton") + -> { :foo.singleton_class }.should.raise(TypeError, "can't define singleton") end it "raises TypeError for a frozen deduplicated String" do - -> { (-"string").singleton_class }.should raise_error(TypeError, "can't define singleton") - -> { a = -"string"; a.singleton_class }.should raise_error(TypeError, "can't define singleton") - -> { a = "string"; (-a).singleton_class }.should raise_error(TypeError, "can't define singleton") + -> { (-"string").singleton_class }.should.raise(TypeError, "can't define singleton") + -> { a = -"string"; a.singleton_class }.should.raise(TypeError, "can't define singleton") + -> { a = "string"; (-a).singleton_class }.should.raise(TypeError, "can't define singleton") end it "returns a frozen singleton class if object is frozen" do obj = Object.new obj.freeze - obj.singleton_class.frozen?.should be_true + obj.singleton_class.frozen?.should == true end context "for an IO object with a replaced singleton class" do diff --git a/spec/ruby/core/kernel/singleton_method_spec.rb b/spec/ruby/core/kernel/singleton_method_spec.rb index 7d63fa7cc61223..fe8e23eb0215aa 100644 --- a/spec/ruby/core/kernel/singleton_method_spec.rb +++ b/spec/ruby/core/kernel/singleton_method_spec.rb @@ -4,7 +4,7 @@ it "finds a method defined on the singleton class" do obj = Object.new def obj.foo; end - obj.singleton_method(:foo).should be_an_instance_of(Method) + obj.singleton_method(:foo).should.instance_of?(Method) end it "returns a Method which can be called" do @@ -23,7 +23,7 @@ def foo obj.foo.should == 42 -> { obj.singleton_method(:foo) - }.should raise_error(NameError) { |e| + }.should.raise(NameError) { |e| # a NameError and not a NoMethodError e.class.should == NameError } @@ -33,7 +33,7 @@ def foo obj = Object.new -> { obj.singleton_method(:not_existing) - }.should raise_error(NameError) { |e| + }.should.raise(NameError) { |e| # a NameError and not a NoMethodError e.class.should == NameError } @@ -50,7 +50,7 @@ def foo obj = Object.new obj.singleton_class.include(m) - obj.singleton_method(:foo).should be_an_instance_of(Method) + obj.singleton_method(:foo).should.instance_of?(Method) obj.singleton_method(:foo).call.should == :foo end @@ -64,7 +64,7 @@ def foo obj = Object.new obj.singleton_class.prepend(m) - obj.singleton_method(:foo).should be_an_instance_of(Method) + obj.singleton_method(:foo).should.instance_of?(Method) obj.singleton_method(:foo).call.should == :foo end @@ -78,7 +78,7 @@ def foo obj = Object.new obj.extend(m) - obj.singleton_method(:foo).should be_an_instance_of(Method) + obj.singleton_method(:foo).should.instance_of?(Method) obj.singleton_method(:foo).call.should == :foo end end diff --git a/spec/ruby/core/kernel/singleton_methods_spec.rb b/spec/ruby/core/kernel/singleton_methods_spec.rb index a127a439de2496..a7f6969519a522 100644 --- a/spec/ruby/core/kernel/singleton_methods_spec.rb +++ b/spec/ruby/core/kernel/singleton_methods_spec.rb @@ -8,33 +8,33 @@ end it "returns the names of module methods for a module" do - ReflectSpecs::M.singleton_methods(*@object).should include(:ms_pro, :ms_pub) + ReflectSpecs::M.singleton_methods(*@object).to_set.should >= Set[:ms_pro, :ms_pub] end it "does not return private module methods for a module" do - ReflectSpecs::M.singleton_methods(*@object).should_not include(:ms_pri) + ReflectSpecs::M.singleton_methods(*@object).should_not.include?(:ms_pri) end it "returns the names of class methods for a class" do - ReflectSpecs::A.singleton_methods(*@object).should include(:as_pro, :as_pub) + ReflectSpecs::A.singleton_methods(*@object).to_set.should >= Set[:as_pro, :as_pub] end it "does not return private class methods for a class" do - ReflectSpecs::A.singleton_methods(*@object).should_not include(:as_pri) + ReflectSpecs::A.singleton_methods(*@object).should_not.include?(:as_pri) end it "returns the names of singleton methods for an object" do - ReflectSpecs.os.singleton_methods(*@object).should include(:os_pro, :os_pub) + ReflectSpecs.os.singleton_methods(*@object).to_set.should >= Set[:os_pro, :os_pub] end end describe :kernel_singleton_methods_modules, shared: true do it "does not return any included methods for a module including a module" do - ReflectSpecs::N.singleton_methods(*@object).should include(:ns_pro, :ns_pub) + ReflectSpecs::N.singleton_methods(*@object).to_set.should >= Set[:ns_pro, :ns_pub] end it "does not return any included methods for a class including a module" do - ReflectSpecs::D.singleton_methods(*@object).should include(:ds_pro, :ds_pub) + ReflectSpecs::D.singleton_methods(*@object).to_set.should >= Set[:ds_pro, :ds_pub] end it "for a module does not return methods in a module prepended to Module itself" do @@ -44,7 +44,7 @@ ancestors = mod.singleton_class.ancestors ancestors[0...2].should == [ mod.singleton_class, mod ] - ancestors.should include(SingletonMethodsSpecs::Prepended) + ancestors.should.include?(SingletonMethodsSpecs::Prepended) # Do not search prepended modules of `Module`, as that's a non-singleton class mod.singleton_methods.should == [] @@ -53,7 +53,7 @@ describe :kernel_singleton_methods_supers, shared: true do it "returns the names of singleton methods for an object extended with a module" do - ReflectSpecs.oe.singleton_methods(*@object).should include(:m_pro, :m_pub) + ReflectSpecs.oe.singleton_methods(*@object).to_set.should >= Set[:m_pro, :m_pub] end it "returns a unique list for an object extended with a module" do @@ -63,15 +63,15 @@ end it "returns the names of singleton methods for an object extended with two modules" do - ReflectSpecs.oee.singleton_methods(*@object).should include(:m_pro, :m_pub, :n_pro, :n_pub) + ReflectSpecs.oee.singleton_methods(*@object).to_set.should >= Set[:m_pro, :m_pub, :n_pro, :n_pub] end it "returns the names of singleton methods for an object extended with a module including a module" do - ReflectSpecs.oei.singleton_methods(*@object).should include(:n_pro, :n_pub, :m_pro, :m_pub) + ReflectSpecs.oei.singleton_methods(*@object).to_set.should >= Set[:n_pro, :n_pub, :m_pro, :m_pub] end it "returns the names of inherited singleton methods for a subclass" do - ReflectSpecs::B.singleton_methods(*@object).should include(:as_pro, :as_pub, :bs_pro, :bs_pub) + ReflectSpecs::B.singleton_methods(*@object).to_set.should >= Set[:as_pro, :as_pub, :bs_pro, :bs_pub] end it "returns a unique list for a subclass" do @@ -81,7 +81,7 @@ end it "returns the names of inherited singleton methods for a subclass including a module" do - ReflectSpecs::C.singleton_methods(*@object).should include(:as_pro, :as_pub, :cs_pro, :cs_pub) + ReflectSpecs::C.singleton_methods(*@object).to_set.should >= Set[:as_pro, :as_pub, :cs_pro, :cs_pub] end it "returns a unique list for a subclass including a module" do @@ -91,57 +91,62 @@ end it "returns the names of inherited singleton methods for a subclass of a class including a module" do - ReflectSpecs::E.singleton_methods(*@object).should include(:ds_pro, :ds_pub, :es_pro, :es_pub) + ReflectSpecs::E.singleton_methods(*@object).to_set.should >= Set[:ds_pro, :ds_pub, :es_pro, :es_pub] end it "returns the names of inherited singleton methods for a subclass of a class that includes a module, where the subclass also includes a module" do - ReflectSpecs::F.singleton_methods(*@object).should include(:ds_pro, :ds_pub, :fs_pro, :fs_pub) + ReflectSpecs::F.singleton_methods(*@object).to_set.should >= Set[:ds_pro, :ds_pub, :fs_pro, :fs_pub] end it "returns the names of inherited singleton methods for a class extended with a module" do - ReflectSpecs::P.singleton_methods(*@object).should include(:m_pro, :m_pub) + ReflectSpecs::P.singleton_methods(*@object).to_set.should >= Set[:m_pro, :m_pub] end end describe :kernel_singleton_methods_private_supers, shared: true do it "does not return private singleton methods for an object extended with a module" do - ReflectSpecs.oe.singleton_methods(*@object).should_not include(:m_pri) + ReflectSpecs.oe.singleton_methods(*@object).should_not.include?(:m_pri) end it "does not return private singleton methods for an object extended with two modules" do - ReflectSpecs.oee.singleton_methods(*@object).should_not include(:m_pri) + ReflectSpecs.oee.singleton_methods(*@object).should_not.include?(:m_pri) end it "does not return private singleton methods for an object extended with a module including a module" do - ReflectSpecs.oei.singleton_methods(*@object).should_not include(:n_pri, :m_pri) + ReflectSpecs.oei.singleton_methods(*@object).should_not.include?(:n_pri) + ReflectSpecs.oei.singleton_methods(*@object).should_not.include?(:m_pri) end it "does not return private singleton methods for a class extended with a module" do - ReflectSpecs::P.singleton_methods(*@object).should_not include(:m_pri) + ReflectSpecs::P.singleton_methods(*@object).should_not.include?(:m_pri) end it "does not return private inherited singleton methods for a module including a module" do - ReflectSpecs::N.singleton_methods(*@object).should_not include(:ns_pri) + ReflectSpecs::N.singleton_methods(*@object).should_not.include?(:ns_pri) end it "does not return private inherited singleton methods for a class including a module" do - ReflectSpecs::D.singleton_methods(*@object).should_not include(:ds_pri) + ReflectSpecs::D.singleton_methods(*@object).should_not.include?(:ds_pri) end it "does not return private inherited singleton methods for a subclass" do - ReflectSpecs::B.singleton_methods(*@object).should_not include(:as_pri, :bs_pri) + ReflectSpecs::B.singleton_methods(*@object).should_not.include?(:as_pri) + ReflectSpecs::B.singleton_methods(*@object).should_not.include?(:bs_pri) end it "does not return private inherited singleton methods for a subclass including a module" do - ReflectSpecs::C.singleton_methods(*@object).should_not include(:as_pri, :cs_pri) + ReflectSpecs::C.singleton_methods(*@object).should_not.include?(:as_pri) + ReflectSpecs::C.singleton_methods(*@object).should_not.include?(:cs_pri) end it "does not return private inherited singleton methods for a subclass of a class including a module" do - ReflectSpecs::E.singleton_methods(*@object).should_not include(:ds_pri, :es_pri) + ReflectSpecs::E.singleton_methods(*@object).should_not.include?(:ds_pri) + ReflectSpecs::E.singleton_methods(*@object).should_not.include?(:es_pri) end it "does not return private inherited singleton methods for a subclass of a class that includes a module, where the subclass also includes a module" do - ReflectSpecs::F.singleton_methods(*@object).should_not include(:ds_pri, :fs_pri) + ReflectSpecs::F.singleton_methods(*@object).should_not.include?(:ds_pri) + ReflectSpecs::F.singleton_methods(*@object).should_not.include?(:fs_pri) end end @@ -178,15 +183,17 @@ end it "returns the names of singleton methods of the subclass" do - ReflectSpecs::B.singleton_methods(false).should include(:bs_pro, :bs_pub) + ReflectSpecs::B.singleton_methods(false).to_set.should >= Set[:bs_pro, :bs_pub] end it "does not return names of inherited singleton methods for a subclass" do - ReflectSpecs::B.singleton_methods(false).should_not include(:as_pro, :as_pub) + ReflectSpecs::B.singleton_methods(false).should_not.include?(:as_pro) + ReflectSpecs::B.singleton_methods(false).should_not.include?(:as_pub) end it "does not return the names of inherited singleton methods for a class extended with a module" do - ReflectSpecs::P.singleton_methods(false).should_not include(:m_pro, :m_pub) + ReflectSpecs::P.singleton_methods(false).should_not.include?(:m_pro) + ReflectSpecs::P.singleton_methods(false).should_not.include?(:m_pub) end end end diff --git a/spec/ruby/core/kernel/sleep_spec.rb b/spec/ruby/core/kernel/sleep_spec.rb index 0b003ad189a48b..61d8cc23804ee0 100644 --- a/spec/ruby/core/kernel/sleep_spec.rb +++ b/spec/ruby/core/kernel/sleep_spec.rb @@ -3,11 +3,11 @@ describe "Kernel#sleep" do it "is a private method" do - Kernel.should have_private_instance_method(:sleep) + Kernel.private_instance_methods(false).should.include?(:sleep) end it "returns an Integer" do - sleep(0.001).should be_kind_of(Integer) + sleep(0.001).should.is_a?(Integer) end it "accepts a Float" do @@ -29,12 +29,12 @@ def o.divmod(*); [0, 0.001]; end end it "raises an ArgumentError when passed a negative duration" do - -> { sleep(-0.1) }.should raise_error(ArgumentError) - -> { sleep(-1) }.should raise_error(ArgumentError) + -> { sleep(-0.1) }.should.raise(ArgumentError) + -> { sleep(-1) }.should.raise(ArgumentError) end it "raises a TypeError when passed a String" do - -> { sleep('2') }.should raise_error(TypeError) + -> { sleep('2') }.should.raise(TypeError) end it "pauses execution indefinitely if not given a duration" do diff --git a/spec/ruby/core/kernel/spawn_spec.rb b/spec/ruby/core/kernel/spawn_spec.rb index ba05b629d501d6..3432fc31da7b45 100644 --- a/spec/ruby/core/kernel/spawn_spec.rb +++ b/spec/ruby/core/kernel/spawn_spec.rb @@ -6,7 +6,7 @@ # run here as it is redundant and takes too long for little gain. describe "Kernel#spawn" do it "is a private method" do - Kernel.should have_private_instance_method(:spawn) + Kernel.private_instance_methods(false).should.include?(:spawn) end it "executes the given command" do diff --git a/spec/ruby/core/kernel/srand_spec.rb b/spec/ruby/core/kernel/srand_spec.rb index 95bb406f4645af..cbc3a7f4b8048b 100644 --- a/spec/ruby/core/kernel/srand_spec.rb +++ b/spec/ruby/core/kernel/srand_spec.rb @@ -11,7 +11,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:srand) + Kernel.private_instance_methods(false).should.include?(:srand) end it "returns the previous seed value" do @@ -31,7 +31,7 @@ end it "defaults number to a random value" do - -> { srand }.should_not raise_error + -> { srand }.should_not.raise srand.should_not == 0 end @@ -60,11 +60,11 @@ end it "raises a TypeError when passed nil" do - -> { srand(nil) }.should raise_error(TypeError) + -> { srand(nil) }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { srand("7") }.should raise_error(TypeError) + -> { srand("7") }.should.raise(TypeError) end end diff --git a/spec/ruby/core/kernel/sub_spec.rb b/spec/ruby/core/kernel/sub_spec.rb index 9130bd159c9bcd..b175e371dc6036 100644 --- a/spec/ruby/core/kernel/sub_spec.rb +++ b/spec/ruby/core/kernel/sub_spec.rb @@ -6,13 +6,13 @@ ruby_version_is ""..."1.9" do describe "Kernel#sub" do it "is a private method" do - Kernel.should have_private_instance_method(:sub) + Kernel.private_instance_methods(false).should.include?(:sub) end end describe "Kernel#sub!" do it "is a private method" do - Kernel.should have_private_instance_method(:sub!) + Kernel.private_instance_methods(false).should.include?(:sub!) end end diff --git a/spec/ruby/core/kernel/syscall_spec.rb b/spec/ruby/core/kernel/syscall_spec.rb index 32d07b3ae29017..63943cdad5d2b1 100644 --- a/spec/ruby/core/kernel/syscall_spec.rb +++ b/spec/ruby/core/kernel/syscall_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#syscall" do it "is a private method" do - Kernel.should have_private_instance_method(:syscall) + Kernel.private_instance_methods(false).should.include?(:syscall) end end diff --git a/spec/ruby/core/kernel/system_spec.rb b/spec/ruby/core/kernel/system_spec.rb index 9bc03924dd883d..b24956104ab2c4 100644 --- a/spec/ruby/core/kernel/system_spec.rb +++ b/spec/ruby/core/kernel/system_spec.rb @@ -5,14 +5,14 @@ it "executes the specified command in a subprocess" do -> { @object.system("echo a") }.should output_to_fd("a\n") - $?.should be_an_instance_of Process::Status + $?.should.instance_of? Process::Status $?.should.success? end it "returns true when the command exits with a zero exit status" do @object.system(ruby_cmd('exit 0')).should == true - $?.should be_an_instance_of Process::Status + $?.should.instance_of? Process::Status $?.should.success? $?.exitstatus.should == 0 end @@ -20,24 +20,24 @@ it "returns false when the command exits with a non-zero exit status" do @object.system(ruby_cmd('exit 1')).should == false - $?.should be_an_instance_of Process::Status + $?.should.instance_of? Process::Status $?.should_not.success? $?.exitstatus.should == 1 end it "raises RuntimeError when `exception: true` is given and the command exits with a non-zero exit status" do - -> { @object.system(ruby_cmd('exit 1'), exception: true) }.should raise_error(RuntimeError) + -> { @object.system(ruby_cmd('exit 1'), exception: true) }.should.raise(RuntimeError) end it "raises Errno::ENOENT when `exception: true` is given and the specified command does not exist" do - -> { @object.system('feature_14386', exception: true) }.should raise_error(Errno::ENOENT) + -> { @object.system('feature_14386', exception: true) }.should.raise(Errno::ENOENT) end it "returns nil when command execution fails" do - @object.system("sad").should be_nil + @object.system("sad").should == nil - $?.should be_an_instance_of Process::Status - $?.pid.should be_kind_of(Integer) + $?.should.instance_of? Process::Status + $?.pid.should.is_a?(Integer) $?.should_not.success? end @@ -121,7 +121,7 @@ describe "Kernel#system" do it "is a private method" do - Kernel.should have_private_instance_method(:system) + Kernel.private_instance_methods(false).should.include?(:system) end it_behaves_like :kernel_system, :system, KernelSpecs::Method.new diff --git a/spec/ruby/core/kernel/tap_spec.rb b/spec/ruby/core/kernel/tap_spec.rb index f7720a6dc7d971..453b9b84d5bccf 100644 --- a/spec/ruby/core/kernel/tap_spec.rb +++ b/spec/ruby/core/kernel/tap_spec.rb @@ -4,10 +4,10 @@ describe "Kernel#tap" do it "always yields self and returns self" do a = KernelSpecs::A.new - a.tap{|o| o.should equal(a); 42}.should equal(a) + a.tap{|o| o.should.equal?(a); 42}.should.equal?(a) end it "raises a LocalJumpError when no block given" do - -> { 3.tap }.should raise_error(LocalJumpError) + -> { 3.tap }.should.raise(LocalJumpError) end end diff --git a/spec/ruby/core/kernel/test_spec.rb b/spec/ruby/core/kernel/test_spec.rb index d26dc06361b43b..30717dfd98e352 100644 --- a/spec/ruby/core/kernel/test_spec.rb +++ b/spec/ruby/core/kernel/test_spec.rb @@ -8,7 +8,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:test) + Kernel.private_instance_methods(false).should.include?(:test) end it "returns true when passed ?f if the argument is a regular file" do @@ -28,7 +28,7 @@ link = tmp("file_symlink.lnk") File.symlink(@file, link) begin - Kernel.test(?l, link).should be_true + Kernel.test(?l, link).should == true ensure rm_r link end @@ -36,11 +36,11 @@ end it "returns true when passed ?r if the argument is readable by the effective uid" do - Kernel.test(?r, @file).should be_true + Kernel.test(?r, @file).should == true end it "returns true when passed ?R if the argument is readable by the real uid" do - Kernel.test(?R, @file).should be_true + Kernel.test(?R, @file).should == true end context "writable test" do @@ -54,11 +54,11 @@ end it "returns true when passed ?w if the argument is readable by the effective uid" do - Kernel.test(?w, @tmp_file).should be_true + Kernel.test(?w, @tmp_file).should == true end it "returns true when passed ?W if the argument is readable by the real uid" do - Kernel.test(?W, @tmp_file).should be_true + Kernel.test(?W, @tmp_file).should == true end end diff --git a/spec/ruby/core/kernel/throw_spec.rb b/spec/ruby/core/kernel/throw_spec.rb index 64bfccb41399cf..1086126176fe93 100644 --- a/spec/ruby/core/kernel/throw_spec.rb +++ b/spec/ruby/core/kernel/throw_spec.rb @@ -7,7 +7,7 @@ :value throw :blah fail("throw didn't transfer the control") - end.should be_nil + end.should == nil end it "transfers control to the innermost catch block waiting for the same symbol" do @@ -42,11 +42,11 @@ end it "raises an ArgumentError if there is no catch block for the symbol" do - -> { throw :blah }.should raise_error(ArgumentError) + -> { throw :blah }.should.raise(ArgumentError) end it "raises an UncaughtThrowError if there is no catch block for the symbol" do - -> { throw :blah }.should raise_error(UncaughtThrowError) + -> { throw :blah }.should.raise(UncaughtThrowError) end it "raises ArgumentError if 3 or more arguments provided" do @@ -54,13 +54,13 @@ catch :blah do throw :blah, :return_value, 2 end - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { catch :blah do throw :blah, :return_value, 2, 3, 4, 5 end - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "can throw an object" do @@ -69,12 +69,12 @@ catch obj do throw obj end - }.should_not raise_error(NameError) + }.should_not.raise(NameError) end end describe "Kernel#throw" do it "is a private method" do - Kernel.should have_private_instance_method(:throw) + Kernel.private_instance_methods(false).should.include?(:throw) end end diff --git a/spec/ruby/core/kernel/trace_var_spec.rb b/spec/ruby/core/kernel/trace_var_spec.rb index 3c84aa5e60305b..150c3da266106c 100644 --- a/spec/ruby/core/kernel/trace_var_spec.rb +++ b/spec/ruby/core/kernel/trace_var_spec.rb @@ -14,7 +14,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:trace_var) + Kernel.private_instance_methods(false).should.include?(:trace_var) end it "hooks assignments to a global variable" do @@ -49,6 +49,6 @@ it "raises ArgumentError if no block or proc is provided" do -> do trace_var :$Kernel_trace_var_global - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/kernel/trap_spec.rb b/spec/ruby/core/kernel/trap_spec.rb index 4c801a7215e3c2..8f44f3af4b6b35 100644 --- a/spec/ruby/core/kernel/trap_spec.rb +++ b/spec/ruby/core/kernel/trap_spec.rb @@ -2,7 +2,7 @@ describe "Kernel#trap" do it "is a private method" do - Kernel.should have_private_instance_method(:trap) + Kernel.private_instance_methods(false).should.include?(:trap) end # Behaviour is specified for Signal.trap diff --git a/spec/ruby/core/kernel/untrace_var_spec.rb b/spec/ruby/core/kernel/untrace_var_spec.rb index 1925a3a8360f7a..8b219801c84933 100644 --- a/spec/ruby/core/kernel/untrace_var_spec.rb +++ b/spec/ruby/core/kernel/untrace_var_spec.rb @@ -3,7 +3,7 @@ describe "Kernel#untrace_var" do it "is a private method" do - Kernel.should have_private_instance_method(:untrace_var) + Kernel.private_instance_methods(false).should.include?(:untrace_var) end end diff --git a/spec/ruby/core/kernel/warn_spec.rb b/spec/ruby/core/kernel/warn_spec.rb index e03498c6dc44de..189129dd313778 100644 --- a/spec/ruby/core/kernel/warn_spec.rb +++ b/spec/ruby/core/kernel/warn_spec.rb @@ -14,7 +14,7 @@ end it "is a private method" do - Kernel.should have_private_instance_method(:warn) + Kernel.private_instance_methods(false).should.include?(:warn) end it "accepts multiple arguments" do @@ -161,7 +161,7 @@ def o.to_sym; :deprecated; end -> { $VERBOSE = true warn("message", category: Object.new) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "converts first arg using to_s" do @@ -194,19 +194,19 @@ def o.to_sym; :deprecated; end end it "raises ArgumentError if passed negative value" do - -> { warn "", uplevel: -2 }.should raise_error(ArgumentError) - -> { warn "", uplevel: -100 }.should raise_error(ArgumentError) + -> { warn "", uplevel: -2 }.should.raise(ArgumentError) + -> { warn "", uplevel: -100 }.should.raise(ArgumentError) end it "raises ArgumentError if passed -1" do - -> { warn "", uplevel: -1 }.should raise_error(ArgumentError) + -> { warn "", uplevel: -1 }.should.raise(ArgumentError) end it "raises TypeError if passed not Integer" do - -> { warn "", uplevel: "" }.should raise_error(TypeError) - -> { warn "", uplevel: [] }.should raise_error(TypeError) - -> { warn "", uplevel: {} }.should raise_error(TypeError) - -> { warn "", uplevel: Object.new }.should raise_error(TypeError) + -> { warn "", uplevel: "" }.should.raise(TypeError) + -> { warn "", uplevel: [] }.should.raise(TypeError) + -> { warn "", uplevel: {} }.should.raise(TypeError) + -> { warn "", uplevel: Object.new }.should.raise(TypeError) end end diff --git a/spec/ruby/core/main/define_method_spec.rb b/spec/ruby/core/main/define_method_spec.rb index d85c5e81192ff5..5279d078c3ed16 100644 --- a/spec/ruby/core/main/define_method_spec.rb +++ b/spec/ruby/core/main/define_method_spec.rb @@ -14,15 +14,15 @@ it 'creates a public method in TOPLEVEL_BINDING' do eval @code, TOPLEVEL_BINDING - Object.should have_method :boom + Object.should.respond_to? :boom end it 'creates a public method in script binding' do eval @code, script_binding - Object.should have_method :boom + Object.should.respond_to? :boom end it 'returns the method name as symbol' do - eval(@code, TOPLEVEL_BINDING).should equal :boom + eval(@code, TOPLEVEL_BINDING).should.equal? :boom end end diff --git a/spec/ruby/core/main/include_spec.rb b/spec/ruby/core/main/include_spec.rb index 9f5a5f54eafa3b..09f8d4d3b5d537 100644 --- a/spec/ruby/core/main/include_spec.rb +++ b/spec/ruby/core/main/include_spec.rb @@ -4,13 +4,13 @@ describe "main#include" do it "includes the given Module in Object" do eval "include MainSpecs::Module", TOPLEVEL_BINDING - Object.ancestors.should include(MainSpecs::Module) + Object.ancestors.should.include?(MainSpecs::Module) end context "in a file loaded with wrapping" do it "includes the given Module in the load wrapper" do load(File.expand_path("../fixtures/wrapped_include.rb", __FILE__), true) - Object.ancestors.should_not include(MainSpecs::WrapIncludeModule) + Object.ancestors.should_not.include?(MainSpecs::WrapIncludeModule) end end end diff --git a/spec/ruby/core/main/private_spec.rb b/spec/ruby/core/main/private_spec.rb index 76895fd6493d5e..56a39ae3c15e20 100644 --- a/spec/ruby/core/main/private_spec.rb +++ b/spec/ruby/core/main/private_spec.rb @@ -10,33 +10,33 @@ context "when single argument is passed and it is not an array" do it "sets the visibility of the given methods to private" do eval "private :main_public_method", TOPLEVEL_BINDING - Object.should have_private_method(:main_public_method) + Object.private_methods(true).should.include?(:main_public_method) end end context "when multiple arguments are passed" do it "sets the visibility of the given methods to private" do eval "private :main_public_method, :main_public_method2", TOPLEVEL_BINDING - Object.should have_private_method(:main_public_method) - Object.should have_private_method(:main_public_method2) + Object.private_methods(true).should.include?(:main_public_method) + Object.private_methods(true).should.include?(:main_public_method2) end end context "when single argument is passed and is an array" do it "sets the visibility of the given methods to private" do eval "private [:main_public_method, :main_public_method2]", TOPLEVEL_BINDING - Object.should have_private_method(:main_public_method) - Object.should have_private_method(:main_public_method2) + Object.private_methods(true).should.include?(:main_public_method) + Object.private_methods(true).should.include?(:main_public_method2) end end it "returns argument" do - eval("private :main_public_method", TOPLEVEL_BINDING).should equal(:main_public_method) + eval("private :main_public_method", TOPLEVEL_BINDING).should.equal?(:main_public_method) end it "raises a NameError when at least one of given method names is undefined" do -> do eval "private :main_public_method, :main_undefined_method", TOPLEVEL_BINDING - end.should raise_error(NameError) + end.should.raise(NameError) end end diff --git a/spec/ruby/core/main/public_spec.rb b/spec/ruby/core/main/public_spec.rb index 3c77798fbcf016..89368ebb0db426 100644 --- a/spec/ruby/core/main/public_spec.rb +++ b/spec/ruby/core/main/public_spec.rb @@ -10,34 +10,34 @@ context "when single argument is passed and it is not an array" do it "sets the visibility of the given methods to public" do eval "public :main_private_method", TOPLEVEL_BINDING - Object.should_not have_private_method(:main_private_method) + Object.private_methods(true).should_not.include?(:main_private_method) end end context "when multiple arguments are passed" do it "sets the visibility of the given methods to public" do eval "public :main_private_method, :main_private_method2", TOPLEVEL_BINDING - Object.should_not have_private_method(:main_private_method) - Object.should_not have_private_method(:main_private_method2) + Object.private_methods(true).should_not.include?(:main_private_method) + Object.private_methods(true).should_not.include?(:main_private_method2) end end context "when single argument is passed and is an array" do it "sets the visibility of the given methods to public" do eval "public [:main_private_method, :main_private_method2]", TOPLEVEL_BINDING - Object.should_not have_private_method(:main_private_method) - Object.should_not have_private_method(:main_private_method2) + Object.private_methods(true).should_not.include?(:main_private_method) + Object.private_methods(true).should_not.include?(:main_private_method2) end end it "returns argument" do - eval("public :main_private_method", TOPLEVEL_BINDING).should equal(:main_private_method) + eval("public :main_private_method", TOPLEVEL_BINDING).should.equal?(:main_private_method) end it "raises a NameError when given an undefined name" do -> do eval "public :main_undefined_method", TOPLEVEL_BINDING - end.should raise_error(NameError) + end.should.raise(NameError) end end diff --git a/spec/ruby/core/main/ruby2_keywords_spec.rb b/spec/ruby/core/main/ruby2_keywords_spec.rb index 27ceae3253f7dd..d12c0ed4e4368b 100644 --- a/spec/ruby/core/main/ruby2_keywords_spec.rb +++ b/spec/ruby/core/main/ruby2_keywords_spec.rb @@ -4,6 +4,6 @@ describe "main.ruby2_keywords" do it "is the same as Object.ruby2_keywords" do main = TOPLEVEL_BINDING.receiver - main.should have_private_method(:ruby2_keywords) + main.private_methods(false).should.include?(:ruby2_keywords) end end diff --git a/spec/ruby/core/main/using_spec.rb b/spec/ruby/core/main/using_spec.rb index 5b9a75159544f7..314a6be4161784 100644 --- a/spec/ruby/core/main/using_spec.rb +++ b/spec/ruby/core/main/using_spec.rb @@ -5,11 +5,11 @@ it "requires one Module argument" do -> do eval('using', TOPLEVEL_BINDING) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) -> do eval('using "foo"', TOPLEVEL_BINDING) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "uses refinements from the given module only in the target file" do @@ -19,7 +19,7 @@ MainSpecs::DATA[:toplevel].should == 'foo' -> do 'hello'.foo - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end it "uses refinements from the given module for method calls in the target file" do @@ -27,7 +27,7 @@ load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__) -> do 'hello'.foo - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) MainSpecs.call_foo('hello').should == 'foo' end @@ -133,18 +133,18 @@ def bar; 'quux'; end it "raises error when called from method in wrapped script" do -> do load File.expand_path('../fixtures/using_in_method.rb', __FILE__), true - end.should raise_error(RuntimeError) + end.should.raise(RuntimeError) end it "raises error when called on toplevel from module" do -> do load File.expand_path('../fixtures/using_in_main.rb', __FILE__), true - end.should raise_error(RuntimeError) + end.should.raise(RuntimeError) end it "does not raise error when wrapped with module" do -> do load File.expand_path('../fixtures/using.rb', __FILE__), true - end.should_not raise_error + end.should_not.raise end end diff --git a/spec/ruby/core/marshal/dump_spec.rb b/spec/ruby/core/marshal/dump_spec.rb index 0de6d8c7e65263..9bbb7809af3ada 100644 --- a/spec/ruby/core/marshal/dump_spec.rb +++ b/spec/ruby/core/marshal/dump_spec.rb @@ -116,7 +116,7 @@ end it "raises TypeError if an Object is an instance of an anonymous class" do - -> { Marshal.dump(Class.new(UserMarshal).new) }.should raise_error(TypeError, /can't dump anonymous class/) + -> { Marshal.dump(Class.new(UserMarshal).new) }.should.raise(TypeError, /can't dump anonymous class/) end it "uses object links for objects repeatedly dumped" do @@ -157,11 +157,11 @@ it "raises a TypeError if _dump returns a non-string" do m = mock("marshaled") m.should_receive(:_dump).and_return(0) - -> { Marshal.dump(m) }.should raise_error(TypeError) + -> { Marshal.dump(m) }.should.raise(TypeError) end it "raises TypeError if an Object is an instance of an anonymous class" do - -> { Marshal.dump(Class.new(UserDefined).new) }.should raise_error(TypeError, /can't dump anonymous class/) + -> { Marshal.dump(Class.new(UserDefined).new) }.should.raise(TypeError, /can't dump anonymous class/) end it "favors marshal_dump over _dump" do @@ -244,11 +244,11 @@ def _dump(level) end it "raises TypeError with an anonymous Class" do - -> { Marshal.dump(Class.new) }.should raise_error(TypeError, /can't dump anonymous class/) + -> { Marshal.dump(Class.new) }.should.raise(TypeError, /can't dump anonymous class/) end it "raises TypeError with a singleton Class" do - -> { Marshal.dump(class << self; self end) }.should raise_error(TypeError) + -> { Marshal.dump(class << self; self end) }.should.raise(TypeError) end end @@ -274,7 +274,7 @@ def _dump(level) end it "raises TypeError with an anonymous Module" do - -> { Marshal.dump(Module.new) }.should raise_error(TypeError, /can't dump anonymous module/) + -> { Marshal.dump(Module.new) }.should.raise(TypeError, /can't dump anonymous module/) end end @@ -388,7 +388,7 @@ def _dump(level) end it "raises TypeError with an anonymous Struct" do - -> { Marshal.dump(Data.define(:a).new(1)) }.should raise_error(TypeError, /can't dump anonymous class/) + -> { Marshal.dump(Data.define(:a).new(1)) }.should.raise(TypeError, /can't dump anonymous class/) end end @@ -630,7 +630,7 @@ def _dump(level) end it "raises a TypeError with hash having default proc" do - -> { Marshal.dump(Hash.new {}) }.should raise_error(TypeError, "can't dump hash with default proc") + -> { Marshal.dump(Hash.new {}) }.should.raise(TypeError, "can't dump hash with default proc") end it "dumps a Hash with instance variables" do @@ -706,7 +706,7 @@ def _dump(level) end it "raises TypeError with an anonymous Struct" do - -> { Marshal.dump(Struct.new(:a).new(1)) }.should raise_error(TypeError, /can't dump anonymous class/) + -> { Marshal.dump(Struct.new(:a).new(1)) }.should.raise(TypeError, /can't dump anonymous class/) end it "adds instance variables after the object itself into the objects table" do @@ -765,7 +765,7 @@ def _dump(level) def obj.foo; end -> { Marshal.dump(obj) - }.should raise_error(TypeError, "singleton can't be dumped") + }.should.raise(TypeError, "singleton can't be dumped") end it "raises TypeError if an Object has a singleton class and singleton instance variables" do @@ -776,14 +776,14 @@ class << obj -> { Marshal.dump(obj) - }.should raise_error(TypeError, "singleton can't be dumped") + }.should.raise(TypeError, "singleton can't be dumped") end it "raises TypeError if an Object is an instance of an anonymous class" do anonymous_class = Class.new obj = anonymous_class.new - -> { Marshal.dump(obj) }.should raise_error(TypeError, /can't dump anonymous class/) + -> { Marshal.dump(obj) }.should.raise(TypeError, /can't dump anonymous class/) end it "raises TypeError if an Object extends an anonymous module" do @@ -791,7 +791,7 @@ class << obj obj = Object.new obj.extend(anonymous_module) - -> { Marshal.dump(obj) }.should raise_error(TypeError, /can't dump anonymous class/) + -> { Marshal.dump(obj) }.should.raise(TypeError, /can't dump anonymous class/) end it "dumps a BasicObject subclass if it defines respond_to?" do @@ -847,7 +847,7 @@ def finalizer.noop(_) end it "raises TypeError with an anonymous Range subclass" do - -> { Marshal.dump(Class.new(Range).new(1, 2)) }.should raise_error(TypeError, /can't dump anonymous class/) + -> { Marshal.dump(Class.new(Range).new(1, 2)) }.should.raise(TypeError, /can't dump anonymous class/) end end @@ -877,7 +877,7 @@ def finalizer.noop(_) base = "\x04\bIu:\tTime\r#{@t_dump}\a" offset = ":\voffseti\x020*" zone = ":\tzoneI\"\bAST\x06:\x06EF" # Last is 'F' (US-ASCII) - [ "#{base}#{offset}#{zone}", "#{base}#{zone}#{offset}" ].should include(dump) + [ "#{base}#{offset}#{zone}", "#{base}#{zone}#{offset}" ].should.include?(dump) end end @@ -889,7 +889,7 @@ def finalizer.noop(_) it "ignores overridden name method" do obj = MarshalSpec::TimeWithOverriddenName.new - Marshal.dump(obj).should include("MarshalSpec::TimeWithOverriddenName") + Marshal.dump(obj).should.include?("MarshalSpec::TimeWithOverriddenName") end ruby_version_is "4.0" do @@ -921,7 +921,7 @@ def finalizer.noop(_) end it "raises TypeError with an anonymous Time subclass" do - -> { Marshal.dump(Class.new(Time).now) }.should raise_error(TypeError) + -> { Marshal.dump(Class.new(Time).now) }.should.raise(TypeError) end end @@ -954,13 +954,13 @@ def finalizer.noop(_) begin raise RuntimeError, "the consequence" rescue RuntimeError => e - e.cause.should equal(cause) + e.cause.should.equal?(cause) exc = e end end reloaded = Marshal.load(Marshal.dump(exc)) - reloaded.cause.should be_an_instance_of(StandardError) + reloaded.cause.should.instance_of?(StandardError) reloaded.cause.message.should == "the cause" end @@ -993,7 +993,7 @@ def finalizer.noop(_) anonymous_class = Class.new(Exception) obj = anonymous_class.new - -> { Marshal.dump(obj) }.should raise_error(TypeError, /can't dump anonymous class/) + -> { Marshal.dump(obj) }.should.raise(TypeError, /can't dump anonymous class/) end end @@ -1014,10 +1014,10 @@ def finalizer.noop(_) it "raises an ArgumentError when the recursion limit is exceeded" do h = {'one' => {'two' => {'three' => 0}}} - -> { Marshal.dump(h, 3) }.should raise_error(ArgumentError) - -> { Marshal.dump([h], 4) }.should raise_error(ArgumentError) - -> { Marshal.dump([], 0) }.should raise_error(ArgumentError) - -> { Marshal.dump([[[]]], 1) }.should raise_error(ArgumentError) + -> { Marshal.dump(h, 3) }.should.raise(ArgumentError) + -> { Marshal.dump([h], 4) }.should.raise(ArgumentError) + -> { Marshal.dump([], 0) }.should.raise(ArgumentError) + -> { Marshal.dump([[[]]], 1) }.should.raise(ArgumentError) end it "ignores the recursion limit if the limit is negative" do @@ -1039,7 +1039,7 @@ def finalizer.noop(_) it "raises an Error when the IO-Object does not respond to #write" do obj = mock('test') - -> { Marshal.dump("test", obj) }.should raise_error(TypeError) + -> { Marshal.dump("test", obj) }.should.raise(TypeError) end @@ -1054,29 +1054,29 @@ def finalizer.noop(_) describe "when passed a StringIO" do it "should raise an error" do require "stringio" - -> { Marshal.dump(StringIO.new) }.should raise_error(TypeError) + -> { Marshal.dump(StringIO.new) }.should.raise(TypeError) end end it "raises a TypeError if marshalling a Method instance" do - -> { Marshal.dump(Marshal.method(:dump)) }.should raise_error(TypeError) + -> { Marshal.dump(Marshal.method(:dump)) }.should.raise(TypeError) end it "raises a TypeError if marshalling a Proc" do - -> { Marshal.dump(proc {}) }.should raise_error(TypeError) + -> { Marshal.dump(proc {}) }.should.raise(TypeError) end it "raises a TypeError if dumping a IO/File instance" do - -> { Marshal.dump(STDIN) }.should raise_error(TypeError) - -> { File.open(__FILE__) { |f| Marshal.dump(f) } }.should raise_error(TypeError) + -> { Marshal.dump(STDIN) }.should.raise(TypeError) + -> { File.open(__FILE__) { |f| Marshal.dump(f) } }.should.raise(TypeError) end it "raises a TypeError if dumping a MatchData instance" do - -> { Marshal.dump(/(.)/.match("foo")) }.should raise_error(TypeError) + -> { Marshal.dump(/(.)/.match("foo")) }.should.raise(TypeError) end it "raises a TypeError if dumping a Mutex instance" do m = Mutex.new - -> { Marshal.dump(m) }.should raise_error(TypeError) + -> { Marshal.dump(m) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/marshal/float_spec.rb b/spec/ruby/core/marshal/float_spec.rb index 5793bbd564976d..5b2d68d6e1ca81 100644 --- a/spec/ruby/core/marshal/float_spec.rb +++ b/spec/ruby/core/marshal/float_spec.rb @@ -40,7 +40,7 @@ describe "Marshal.load with Float" do it "loads NaN" do - Marshal.load("\004\bf\bnan").should be_nan + Marshal.load("\004\bf\bnan").should.nan? end it "loads +Infinity" do diff --git a/spec/ruby/core/marshal/shared/load.rb b/spec/ruby/core/marshal/shared/load.rb index edc430e522a8dd..02c8e7f0b17d31 100644 --- a/spec/ruby/core/marshal/shared/load.rb +++ b/spec/ruby/core/marshal/shared/load.rb @@ -8,11 +8,11 @@ it "raises an ArgumentError when the dumped data is truncated" do obj = {first: 1, second: 2, third: 3} - -> { Marshal.send(@method, Marshal.dump(obj)[0, 5]) }.should raise_error(ArgumentError, "marshal data too short") + -> { Marshal.send(@method, Marshal.dump(obj)[0, 5]) }.should.raise(ArgumentError, "marshal data too short") end it "raises an ArgumentError when the argument is empty String" do - -> { Marshal.send(@method, "") }.should raise_error(ArgumentError, "marshal data too short") + -> { Marshal.send(@method, "") }.should.raise(ArgumentError, "marshal data too short") end it "raises an ArgumentError when the dumped class is missing" do @@ -20,7 +20,7 @@ kaboom = Marshal.dump(KaBoom.new) Object.send(:remove_const, :KaBoom) - -> { Marshal.send(@method, kaboom) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, kaboom) }.should.raise(ArgumentError) end describe "when called with freeze: true" do @@ -111,7 +111,7 @@ source_object = ["foo" + "bar", "foobar"] object = Marshal.send(@method, Marshal.dump(source_object), freeze: true) - object[0].should equal(object[1]) + object[0].should.equal?(object[1]) end end @@ -297,9 +297,9 @@ UserPreviouslyDefinedWithInitializedIvar.should_receive(:_load).and_return(UserPreviouslyDefinedWithInitializedIvar.new) marshaled_obj = Marshal.send(@method, dump_str) - marshaled_obj.should be_an_instance_of(UserPreviouslyDefinedWithInitializedIvar) - marshaled_obj.field1.should be_nil - marshaled_obj.field2.should be_nil + marshaled_obj.should.instance_of?(UserPreviouslyDefinedWithInitializedIvar) + marshaled_obj.field1.should == nil + marshaled_obj.field2.should == nil end it "loads the String in non US-ASCII and non UTF-8 encoding" do @@ -403,20 +403,20 @@ marshal_data[0] = (Marshal::MAJOR_VERSION).chr marshal_data[1] = (Marshal::MINOR_VERSION + 1).chr - -> { Marshal.send(@method, marshal_data) }.should raise_error(TypeError) + -> { Marshal.send(@method, marshal_data) }.should.raise(TypeError) marshal_data = +'\xff\xff' marshal_data[0] = (Marshal::MAJOR_VERSION - 1).chr marshal_data[1] = (Marshal::MINOR_VERSION).chr - -> { Marshal.send(@method, marshal_data) }.should raise_error(TypeError) + -> { Marshal.send(@method, marshal_data) }.should.raise(TypeError) end it "raises EOFError on loading an empty file" do temp_file = tmp("marshal.rubyspec.tmp.#{Process.pid}") file = File.new(temp_file, "w+") begin - -> { Marshal.send(@method, file) }.should raise_error(EOFError) + -> { Marshal.send(@method, file) }.should.raise(EOFError) ensure file.close rm_r temp_file @@ -462,7 +462,7 @@ obj.instance_variable_set(:@mix, s) new_obj = Marshal.send(@method, "\004\bI[\b\"\0065I\"\twell\006:\t@fooi\017\"\ahi\006:\t@mix@\a") new_obj.should == obj - new_obj.instance_variable_get(:@mix).should equal new_obj[1] + new_obj.instance_variable_get(:@mix).should.equal? new_obj[1] new_obj[1].instance_variable_get(:@foo).should == 10 end @@ -613,7 +613,7 @@ -> { Marshal.send(@method, "\x04\b:\nhel") - }.should raise_error(ArgumentError, "marshal data too short") + }.should.raise(ArgumentError, "marshal data too short") end end @@ -633,7 +633,7 @@ it "sets binmode if it is loading through StringIO stream" do io = StringIO.new("\004\b:\vsymbol") def io.binmode; raise "binmode"; end - -> { Marshal.load(io) }.should raise_error(RuntimeError, "binmode") + -> { Marshal.load(io) }.should.raise(RuntimeError, "binmode") end it "loads a string with an ivar" do @@ -643,7 +643,7 @@ def io.binmode; raise "binmode"; end it "loads a String subclass with custom constructor" do str = Marshal.send(@method, "\x04\bC: UserCustomConstructorString\"\x00") - str.should be_an_instance_of(UserCustomConstructorString) + str.should.instance_of?(UserCustomConstructorString) end it "loads a US-ASCII String" do @@ -651,7 +651,7 @@ def io.binmode; raise "binmode"; end data = "\x04\bI\"\babc\x06:\x06EF" result = Marshal.send(@method, data) result.should == str - result.encoding.should equal(Encoding::US_ASCII) + result.encoding.should.equal?(Encoding::US_ASCII) end it "loads a UTF-8 String" do @@ -659,7 +659,7 @@ def io.binmode; raise "binmode"; end data = "\x04\bI\"\vm\xC3\xB6hre\x06:\x06ET" result = Marshal.send(@method, data) result.should == str - result.encoding.should equal(Encoding::UTF_8) + result.encoding.should.equal?(Encoding::UTF_8) end it "loads a String in another encoding" do @@ -667,7 +667,7 @@ def io.binmode; raise "binmode"; end data = "\x04\bI\"\x0Fm\x00\xF6\x00h\x00r\x00e\x00\x06:\rencoding\"\rUTF-16LE" result = Marshal.send(@method, data) result.should == str - result.encoding.should equal(Encoding::UTF_16LE) + result.encoding.should.equal?(Encoding::UTF_16LE) end it "loads a String as BINARY if no encoding is specified at the end" do @@ -683,7 +683,7 @@ def io.binmode; raise "binmode"; end -> { Marshal.send(@method, "\x04\b\"\nhel") - }.should raise_error(ArgumentError, "marshal data too short") + }.should.raise(ArgumentError, "marshal data too short") end end @@ -807,7 +807,7 @@ def io.binmode; raise "binmode"; end describe "for an Object" do it "loads an object" do - Marshal.send(@method, "\004\bo:\vObject\000").should be_kind_of(Object) + Marshal.send(@method, "\004\bo:\vObject\000").should.is_a?(Object) end it "loads an extended Object" do @@ -843,7 +843,7 @@ def io.binmode; raise "binmode"; end it "raises ArgumentError if the object from an 'o' stream is not dumpable as 'o' type user class" do -> do Marshal.send(@method, "\x04\bo:\tFile\001\001:\001\005@path\"\x10/etc/passwd") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises ArgumentError when end of byte sequence reached before class name end" do @@ -851,7 +851,7 @@ def io.binmode; raise "binmode"; end -> { Marshal.send(@method, "\x04\bo:\vObj") - }.should raise_error(ArgumentError, "marshal data too short") + }.should.raise(ArgumentError, "marshal data too short") end end @@ -879,7 +879,7 @@ def io.binmode; raise "binmode"; end end it "loads a UserObject" do - Marshal.send(@method, "\004\bo:\017UserObject\000").should be_kind_of(UserObject) + Marshal.send(@method, "\004\bo:\017UserObject\000").should.is_a?(UserObject) end describe "that extends a core type other than Object or BasicObject" do @@ -892,10 +892,10 @@ def io.binmode; raise "binmode"; end data = Marshal.dump(MarshalSpec::SwappedClass.new) MarshalSpec.set_swapped_class(Class.new(Array)) - -> { Marshal.send(@method, data) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, data) }.should.raise(ArgumentError) MarshalSpec.set_swapped_class(Class.new) - -> { Marshal.send(@method, data) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, data) }.should.raise(ArgumentError) end end end @@ -905,13 +905,13 @@ def io.binmode; raise "binmode"; end it "raises FrozenError for an extended Regexp" do -> { Marshal.send(@method, "\004\be:\nMethse:\016MethsMore/\n[a-z]\000") - }.should raise_error(FrozenError) + }.should.raise(FrozenError) end it "raises FrozenError when regexp has instance variables" do -> { Marshal.send(@method, "\x04\bI/\nhello\x00\a:\x06EF:\x11@regexp_ivar[\x06i/") - }.should raise_error(FrozenError) + }.should.raise(FrozenError) end end @@ -975,7 +975,7 @@ def io.binmode; raise "binmode"; end -> { Marshal.send(@method, "\x04\bI/\x10hel") - }.should raise_error(ArgumentError, "marshal data too short") + }.should.raise(ArgumentError, "marshal data too short") end end @@ -1004,7 +1004,7 @@ def io.binmode; raise "binmode"; end -> { Marshal.send(@method, "\004\bf\v1") - }.should raise_error(ArgumentError, "marshal data too short") + }.should.raise(ArgumentError, "marshal data too short") end end @@ -1058,7 +1058,7 @@ def io.binmode; raise "binmode"; end "\004\bi\004\0", "\004\bi\004\0\0", "\004\bi\004\0\0\0"].each do |invalid| - -> { Marshal.send(@method, invalid) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, invalid) }.should.raise(ArgumentError) end end @@ -1119,7 +1119,7 @@ def io.binmode; raise "binmode"; end t = Time.new t1, t2 = Marshal.send(@method, Marshal.dump([t, t])) - t1.should equal t2 + t1.should.equal? t2 end it "keeps the local zone" do @@ -1167,19 +1167,19 @@ def io.binmode; raise "binmode"; end describe "for nil" do it "loads" do - Marshal.send(@method, "\x04\b0").should be_nil + Marshal.send(@method, "\x04\b0").should == nil end end describe "for true" do it "loads" do - Marshal.send(@method, "\x04\bT").should be_true + Marshal.send(@method, "\x04\bT").should == true end end describe "for false" do it "loads" do - Marshal.send(@method, "\x04\bF").should be_false + Marshal.send(@method, "\x04\bF").should == false end end @@ -1189,11 +1189,11 @@ def io.binmode; raise "binmode"; end end it "raises ArgumentError if given the name of a non-Module" do - -> { Marshal.send(@method, "\x04\bc\vKernel") }.should raise_error(ArgumentError) + -> { Marshal.send(@method, "\x04\bc\vKernel") }.should.raise(ArgumentError) end it "raises ArgumentError if given a nonexistent class" do - -> { Marshal.send(@method, "\x04\bc\vStrung") }.should raise_error(ArgumentError) + -> { Marshal.send(@method, "\x04\bc\vStrung") }.should.raise(ArgumentError) end it "raises ArgumentError when end of byte sequence reached before class name end" do @@ -1201,7 +1201,7 @@ def io.binmode; raise "binmode"; end -> { Marshal.send(@method, "\x04\bc\vStr") - }.should raise_error(ArgumentError, "marshal data too short") + }.should.raise(ArgumentError, "marshal data too short") end end @@ -1211,7 +1211,7 @@ def io.binmode; raise "binmode"; end end it "raises ArgumentError if given the name of a non-Class" do - -> { Marshal.send(@method, "\x04\bm\vString") }.should raise_error(ArgumentError) + -> { Marshal.send(@method, "\x04\bm\vString") }.should.raise(ArgumentError) end it "loads an old module" do @@ -1223,7 +1223,7 @@ def io.binmode; raise "binmode"; end -> { Marshal.send(@method, "\x04\bm\vKer") - }.should raise_error(ArgumentError, "marshal data too short") + }.should.raise(ArgumentError, "marshal data too short") end end @@ -1258,13 +1258,13 @@ def _dump_data data = "\x04\bd:\x1AUnloadableDumpableDirI\"\x06.\x06:\x06ET" - -> { Marshal.send(@method, data) }.should raise_error(TypeError) + -> { Marshal.send(@method, data) }.should.raise(TypeError) end it "raises ArgumentError when the local class is a regular object" do data = "\004\bd:\020UserDefined\0" - -> { Marshal.send(@method, data) }.should raise_error(ArgumentError) + -> { Marshal.send(@method, data) }.should.raise(ArgumentError) end end @@ -1277,7 +1277,7 @@ def _dump_data it "raises an ArgumentError" do message = "undefined class/module NamespaceTest::SameName" - -> { Marshal.send(@method, @data) }.should raise_error(ArgumentError, message) + -> { Marshal.send(@method, @data) }.should.raise(ArgumentError, message) end end @@ -1286,6 +1286,6 @@ def _dump_data @data = Marshal.dump(NamespaceTest::KaBoom.new) NamespaceTest.send(:remove_const, :KaBoom) - -> { Marshal.send(@method, @data) }.should raise_error(ArgumentError, /NamespaceTest::KaBoom/) + -> { Marshal.send(@method, @data) }.should.raise(ArgumentError, /NamespaceTest::KaBoom/) end end diff --git a/spec/ruby/core/matchdata/allocate_spec.rb b/spec/ruby/core/matchdata/allocate_spec.rb index 142ce639c20965..f41e2d54810d27 100644 --- a/spec/ruby/core/matchdata/allocate_spec.rb +++ b/spec/ruby/core/matchdata/allocate_spec.rb @@ -3,6 +3,6 @@ describe "MatchData.allocate" do it "is undefined" do # https://bugs.ruby-lang.org/issues/16294 - -> { MatchData.allocate }.should raise_error(NoMethodError) + -> { MatchData.allocate }.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/matchdata/begin_spec.rb b/spec/ruby/core/matchdata/begin_spec.rb index 54b4e0a33fe47b..b4be077ae4199e 100644 --- a/spec/ruby/core/matchdata/begin_spec.rb +++ b/spec/ruby/core/matchdata/begin_spec.rb @@ -12,7 +12,7 @@ it "returns nil when the nth match isn't found" do match_data = /something is( not)? (right)/.match("something is right") - match_data.begin(1).should be_nil + match_data.begin(1).should == nil end it "returns the character offset for multi-byte strings" do @@ -42,11 +42,11 @@ -> { match_data.begin(-1) - }.should raise_error(IndexError, "index -1 out of matches") + }.should.raise(IndexError, "index -1 out of matches") -> { match_data.begin(3) - }.should raise_error(IndexError, "index 3 out of matches") + }.should.raise(IndexError, "index 3 out of matches") end end @@ -86,7 +86,7 @@ -> { match_data.begin("y") - }.should raise_error(IndexError, "undefined group name reference: y") + }.should.raise(IndexError, "undefined group name reference: y") end end @@ -126,7 +126,7 @@ -> { match_data.begin(:y) - }.should raise_error(IndexError, "undefined group name reference: y") + }.should.raise(IndexError, "undefined group name reference: y") end end end diff --git a/spec/ruby/core/matchdata/bytebegin_spec.rb b/spec/ruby/core/matchdata/bytebegin_spec.rb index 08c1fd6d1ea499..fa44ec3b41e769 100644 --- a/spec/ruby/core/matchdata/bytebegin_spec.rb +++ b/spec/ruby/core/matchdata/bytebegin_spec.rb @@ -11,7 +11,7 @@ it "returns nil when the nth match isn't found" do match_data = /something is( not)? (right)/.match("something is right") - match_data.bytebegin(1).should be_nil + match_data.bytebegin(1).should == nil end it "returns the byte-based offset for multi-byte strings" do @@ -41,11 +41,11 @@ -> { match_data.bytebegin(-1) - }.should raise_error(IndexError, "index -1 out of matches") + }.should.raise(IndexError, "index -1 out of matches") -> { match_data.bytebegin(3) - }.should raise_error(IndexError, "index 3 out of matches") + }.should.raise(IndexError, "index 3 out of matches") end end @@ -85,7 +85,7 @@ -> { match_data.bytebegin("y") - }.should raise_error(IndexError, "undefined group name reference: y") + }.should.raise(IndexError, "undefined group name reference: y") end end @@ -125,7 +125,7 @@ -> { match_data.bytebegin(:y) - }.should raise_error(IndexError, "undefined group name reference: y") + }.should.raise(IndexError, "undefined group name reference: y") end end end diff --git a/spec/ruby/core/matchdata/byteend_spec.rb b/spec/ruby/core/matchdata/byteend_spec.rb index 98015e287d5b7f..e77cbf8b0d8b1b 100644 --- a/spec/ruby/core/matchdata/byteend_spec.rb +++ b/spec/ruby/core/matchdata/byteend_spec.rb @@ -11,7 +11,7 @@ it "returns nil when the nth match isn't found" do match_data = /something is( not)? (right)/.match("something is right") - match_data.byteend(1).should be_nil + match_data.byteend(1).should == nil end it "returns the byte-based offset for multi-byte strings" do diff --git a/spec/ruby/core/matchdata/byteoffset_spec.rb b/spec/ruby/core/matchdata/byteoffset_spec.rb index fb8f5fb67d4e6a..062e84027ccdf3 100644 --- a/spec/ruby/core/matchdata/byteoffset_spec.rb +++ b/spec/ruby/core/matchdata/byteoffset_spec.rb @@ -64,11 +64,11 @@ def obj.to_int; 2; end -> { m.byteoffset("y") - }.should raise_error(IndexError, "undefined group name reference: y") + }.should.raise(IndexError, "undefined group name reference: y") -> { m.byteoffset(:y) - }.should raise_error(IndexError, "undefined group name reference: y") + }.should.raise(IndexError, "undefined group name reference: y") end it "raises IndexError if index is out of bounds" do @@ -76,11 +76,11 @@ def obj.to_int; 2; end -> { m.byteoffset(-1) - }.should raise_error(IndexError, "index -1 out of matches") + }.should.raise(IndexError, "index -1 out of matches") -> { m.byteoffset(3) - }.should raise_error(IndexError, "index 3 out of matches") + }.should.raise(IndexError, "index 3 out of matches") end it "raises TypeError if can't convert argument into Integer" do @@ -88,6 +88,6 @@ def obj.to_int; 2; end -> { m.byteoffset([]) - }.should raise_error(TypeError, "no implicit conversion of Array into Integer") + }.should.raise(TypeError, "no implicit conversion of Array into Integer") end end diff --git a/spec/ruby/core/matchdata/deconstruct_keys_spec.rb b/spec/ruby/core/matchdata/deconstruct_keys_spec.rb index 2648340ee2ff8b..9126d203944902 100644 --- a/spec/ruby/core/matchdata/deconstruct_keys_spec.rb +++ b/spec/ruby/core/matchdata/deconstruct_keys_spec.rb @@ -18,16 +18,16 @@ -> { m.deconstruct_keys - }.should raise_error(ArgumentError, "wrong number of arguments (given 0, expected 1)") + }.should.raise(ArgumentError, "wrong number of arguments (given 0, expected 1)") end it "it raises error when argument is neither nil nor array" do m = /(?foo)(?bar)/.match("foobar") - -> { m.deconstruct_keys(1) }.should raise_error(TypeError, "wrong argument type Integer (expected Array)") - -> { m.deconstruct_keys("asd") }.should raise_error(TypeError, "wrong argument type String (expected Array)") - -> { m.deconstruct_keys(:x) }.should raise_error(TypeError, "wrong argument type Symbol (expected Array)") - -> { m.deconstruct_keys({}) }.should raise_error(TypeError, "wrong argument type Hash (expected Array)") + -> { m.deconstruct_keys(1) }.should.raise(TypeError, "wrong argument type Integer (expected Array)") + -> { m.deconstruct_keys("asd") }.should.raise(TypeError, "wrong argument type String (expected Array)") + -> { m.deconstruct_keys(:x) }.should.raise(TypeError, "wrong argument type Symbol (expected Array)") + -> { m.deconstruct_keys({}) }.should.raise(TypeError, "wrong argument type Hash (expected Array)") end it "returns {} when passed []" do @@ -41,7 +41,7 @@ -> { m.deconstruct_keys(['year', :foo]) - }.should raise_error(TypeError, "wrong argument type String (expected Symbol)") + }.should.raise(TypeError, "wrong argument type String (expected Symbol)") end it "process keys till the first non-existing one" do diff --git a/spec/ruby/core/matchdata/element_reference_spec.rb b/spec/ruby/core/matchdata/element_reference_spec.rb index 0924be0aaec4cf..5509371cd21d5b 100644 --- a/spec/ruby/core/matchdata/element_reference_spec.rb +++ b/spec/ruby/core/matchdata/element_reference_spec.rb @@ -55,7 +55,7 @@ it "returns instances of String when given a String subclass" do str = MatchDataSpecs::MyString.new("THX1138.") - /(.)(.)(\d+)(\d)/.match(str)[0..-1].each { |m| m.should be_an_instance_of(String) } + /(.)(.)(\d+)(\d)/.match(str)[0..-1].each { |m| m.should.instance_of?(String) } end end @@ -108,12 +108,12 @@ it "raises an IndexError if there is no named match corresponding to the Symbol" do md = 'haystack'.match(/(?t(?ack))/) - -> { md[:baz] }.should raise_error(IndexError, /baz/) + -> { md[:baz] }.should.raise(IndexError, /baz/) end it "raises an IndexError if there is no named match corresponding to the String" do md = 'haystack'.match(/(?t(?ack))/) - -> { md['baz'] }.should raise_error(IndexError, /baz/) + -> { md['baz'] }.should.raise(IndexError, /baz/) end it "returns matches in the String's encoding" do diff --git a/spec/ruby/core/matchdata/end_spec.rb b/spec/ruby/core/matchdata/end_spec.rb index d01b0a8b304f89..4fee24a763fe1b 100644 --- a/spec/ruby/core/matchdata/end_spec.rb +++ b/spec/ruby/core/matchdata/end_spec.rb @@ -12,7 +12,7 @@ it "returns nil when the nth match isn't found" do match_data = /something is( not)? (right)/.match("something is right") - match_data.end(1).should be_nil + match_data.end(1).should == nil end it "returns the character offset for multi-byte strings" do diff --git a/spec/ruby/core/matchdata/inspect_spec.rb b/spec/ruby/core/matchdata/inspect_spec.rb index 53152576770557..cacbe10c5dbe4e 100644 --- a/spec/ruby/core/matchdata/inspect_spec.rb +++ b/spec/ruby/core/matchdata/inspect_spec.rb @@ -6,7 +6,7 @@ end it "returns a String" do - @match_data.inspect.should be_kind_of(String) + @match_data.inspect.should.is_a?(String) end it "returns a human readable representation that contains entire matched string and the captures" do diff --git a/spec/ruby/core/matchdata/names_spec.rb b/spec/ruby/core/matchdata/names_spec.rb index 25ca06ced9fe95..dca15985b081c5 100644 --- a/spec/ruby/core/matchdata/names_spec.rb +++ b/spec/ruby/core/matchdata/names_spec.rb @@ -3,12 +3,12 @@ describe "MatchData#names" do it "returns an Array" do md = 'haystack'.match(/(?hay)/) - md.names.should be_an_instance_of(Array) + md.names.should.instance_of?(Array) end it "sets each element to a String" do 'haystack'.match(/(?hay)/).names.all? do |e| - e.should be_an_instance_of(String) + e.should.instance_of?(String) end end diff --git a/spec/ruby/core/matchdata/offset_spec.rb b/spec/ruby/core/matchdata/offset_spec.rb index a03d58aad15ead..5a923d6ce0ee74 100644 --- a/spec/ruby/core/matchdata/offset_spec.rb +++ b/spec/ruby/core/matchdata/offset_spec.rb @@ -73,11 +73,11 @@ def obj.to_int; 2; end -> { m.offset("y") - }.should raise_error(IndexError, "undefined group name reference: y") + }.should.raise(IndexError, "undefined group name reference: y") -> { m.offset(:y) - }.should raise_error(IndexError, "undefined group name reference: y") + }.should.raise(IndexError, "undefined group name reference: y") end it "raises IndexError if index is out of bounds" do @@ -85,11 +85,11 @@ def obj.to_int; 2; end -> { m.offset(-1) - }.should raise_error(IndexError, "index -1 out of matches") + }.should.raise(IndexError, "index -1 out of matches") -> { m.offset(3) - }.should raise_error(IndexError, "index 3 out of matches") + }.should.raise(IndexError, "index 3 out of matches") end it "raises TypeError if can't convert argument into Integer" do @@ -97,6 +97,6 @@ def obj.to_int; 2; end -> { m.offset([]) - }.should raise_error(TypeError, "no implicit conversion of Array into Integer") + }.should.raise(TypeError, "no implicit conversion of Array into Integer") end end diff --git a/spec/ruby/core/matchdata/post_match_spec.rb b/spec/ruby/core/matchdata/post_match_spec.rb index 7bfe6df119b299..b50d637124d1a6 100644 --- a/spec/ruby/core/matchdata/post_match_spec.rb +++ b/spec/ruby/core/matchdata/post_match_spec.rb @@ -9,16 +9,16 @@ it "sets the encoding to the encoding of the source String" do str = "abc".dup.force_encoding Encoding::EUC_JP - str.match(/b/).post_match.encoding.should equal(Encoding::EUC_JP) + str.match(/b/).post_match.encoding.should.equal?(Encoding::EUC_JP) end it "sets an empty result to the encoding of the source String" do str = "abc".dup.force_encoding Encoding::ISO_8859_1 - str.match(/c/).post_match.encoding.should equal(Encoding::ISO_8859_1) + str.match(/c/).post_match.encoding.should.equal?(Encoding::ISO_8859_1) end it "returns an instance of String when given a String subclass" do str = MatchDataSpecs::MyString.new("THX1138: The Movie") - /(.)(.)(\d+)(\d)/.match(str).post_match.should be_an_instance_of(String) + /(.)(.)(\d+)(\d)/.match(str).post_match.should.instance_of?(String) end end diff --git a/spec/ruby/core/matchdata/pre_match_spec.rb b/spec/ruby/core/matchdata/pre_match_spec.rb index 2f1ba9b8f64702..106612a4f70fa1 100644 --- a/spec/ruby/core/matchdata/pre_match_spec.rb +++ b/spec/ruby/core/matchdata/pre_match_spec.rb @@ -9,16 +9,16 @@ it "sets the encoding to the encoding of the source String" do str = "abc".dup.force_encoding Encoding::EUC_JP - str.match(/b/).pre_match.encoding.should equal(Encoding::EUC_JP) + str.match(/b/).pre_match.encoding.should.equal?(Encoding::EUC_JP) end it "sets an empty result to the encoding of the source String" do str = "abc".dup.force_encoding Encoding::ISO_8859_1 - str.match(/a/).pre_match.encoding.should equal(Encoding::ISO_8859_1) + str.match(/a/).pre_match.encoding.should.equal?(Encoding::ISO_8859_1) end it "returns an instance of String when given a String subclass" do str = MatchDataSpecs::MyString.new("THX1138: The Movie") - /(.)(.)(\d+)(\d)/.match(str).pre_match.should be_an_instance_of(String) + /(.)(.)(\d+)(\d)/.match(str).pre_match.should.instance_of?(String) end end diff --git a/spec/ruby/core/matchdata/regexp_spec.rb b/spec/ruby/core/matchdata/regexp_spec.rb index 099b59c55918ee..7dcb0e62db5d21 100644 --- a/spec/ruby/core/matchdata/regexp_spec.rb +++ b/spec/ruby/core/matchdata/regexp_spec.rb @@ -3,7 +3,7 @@ describe "MatchData#regexp" do it "returns a Regexp object" do m = 'haystack'.match(/hay/) - m.regexp.should be_an_instance_of(Regexp) + m.regexp.should.instance_of?(Regexp) end it "returns the pattern used in the match" do diff --git a/spec/ruby/core/matchdata/shared/captures.rb b/spec/ruby/core/matchdata/shared/captures.rb index 33f834561af374..de5870f543ab51 100644 --- a/spec/ruby/core/matchdata/shared/captures.rb +++ b/spec/ruby/core/matchdata/shared/captures.rb @@ -8,6 +8,6 @@ it "returns instances of String when given a String subclass" do str = MatchDataSpecs::MyString.new("THX1138: The Movie") - /(.)(.)(\d+)(\d)/.match(str).send(@method).each { |c| c.should be_an_instance_of(String) } + /(.)(.)(\d+)(\d)/.match(str).send(@method).each { |c| c.should.instance_of?(String) } end end diff --git a/spec/ruby/core/matchdata/shared/eql.rb b/spec/ruby/core/matchdata/shared/eql.rb index e021baa1784c3a..e4bb8797b7d637 100644 --- a/spec/ruby/core/matchdata/shared/eql.rb +++ b/spec/ruby/core/matchdata/shared/eql.rb @@ -4,23 +4,23 @@ it "returns true if both operands have equal target strings, patterns, and match positions" do a = 'haystack'.match(/hay/) b = 'haystack'.match(/hay/) - a.send(@method, b).should be_true + a.send(@method, b).should == true end it "returns false if the operands have different target strings" do a = 'hay'.match(/hay/) b = 'haystack'.match(/hay/) - a.send(@method, b).should be_false + a.send(@method, b).should == false end it "returns false if the operands have different patterns" do a = 'haystack'.match(/h.y/) b = 'haystack'.match(/hay/) - a.send(@method, b).should be_false + a.send(@method, b).should == false end it "returns false if the argument is not a MatchData object" do a = 'haystack'.match(/hay/) - a.send(@method, Object.new).should be_false + a.send(@method, Object.new).should == false end end diff --git a/spec/ruby/core/matchdata/string_spec.rb b/spec/ruby/core/matchdata/string_spec.rb index 952e95331849c1..50bbb5a64f0624 100644 --- a/spec/ruby/core/matchdata/string_spec.rb +++ b/spec/ruby/core/matchdata/string_spec.rb @@ -14,7 +14,7 @@ it "returns the same frozen string for every call" do md = /(.)(.)(\d+)(\d)/.match("THX1138.") - md.string.should equal(md.string) + md.string.should.equal?(md.string) end it "returns a frozen copy of the matched string for gsub!(String)" do diff --git a/spec/ruby/core/matchdata/to_a_spec.rb b/spec/ruby/core/matchdata/to_a_spec.rb index 4fa11ff604140d..c77fc4ab37bc94 100644 --- a/spec/ruby/core/matchdata/to_a_spec.rb +++ b/spec/ruby/core/matchdata/to_a_spec.rb @@ -8,6 +8,6 @@ it "returns instances of String when given a String subclass" do str = MatchDataSpecs::MyString.new("THX1138.") - /(.)(.)(\d+)(\d)/.match(str)[0..-1].to_a.each { |m| m.should be_an_instance_of(String) } + /(.)(.)(\d+)(\d)/.match(str)[0..-1].to_a.each { |m| m.should.instance_of?(String) } end end diff --git a/spec/ruby/core/matchdata/to_s_spec.rb b/spec/ruby/core/matchdata/to_s_spec.rb index cd1c4dbca2825b..cbcc5e8a214851 100644 --- a/spec/ruby/core/matchdata/to_s_spec.rb +++ b/spec/ruby/core/matchdata/to_s_spec.rb @@ -8,6 +8,6 @@ it "returns an instance of String when given a String subclass" do str = MatchDataSpecs::MyString.new("THX1138.") - /(.)(.)(\d+)(\d)/.match(str).to_s.should be_an_instance_of(String) + /(.)(.)(\d+)(\d)/.match(str).to_s.should.instance_of?(String) end end diff --git a/spec/ruby/core/matchdata/values_at_spec.rb b/spec/ruby/core/matchdata/values_at_spec.rb index 535719a2ee38c6..ba5b0e662cf8b2 100644 --- a/spec/ruby/core/matchdata/values_at_spec.rb +++ b/spec/ruby/core/matchdata/values_at_spec.rb @@ -26,7 +26,7 @@ end it "raises RangeError if any element of the range is negative and out of range" do - -> { /(.)(.)(\d+)(\d)/.match("THX1138: The Movie").values_at(-6..3) }.should raise_error(RangeError, "-6..3 out of range") + -> { /(.)(.)(\d+)(\d)/.match("THX1138: The Movie").values_at(-6..3) }.should.raise(RangeError, "-6..3 out of range") end it "supports endless Range" do @@ -71,6 +71,6 @@ it "fails when passed arguments of unsupported types" do -> { /(.)(.)(\d+)(\d)/.match("THX1138: The Movie").values_at(Object.new) - }.should raise_error(TypeError, "no implicit conversion of Object into Integer") + }.should.raise(TypeError, "no implicit conversion of Object into Integer") end end diff --git a/spec/ruby/core/math/acos_spec.rb b/spec/ruby/core/math/acos_spec.rb index 8b321ab29bed56..4649dc527c4ef4 100644 --- a/spec/ruby/core/math/acos_spec.rb +++ b/spec/ruby/core/math/acos_spec.rb @@ -8,7 +8,7 @@ end it "returns a float" do - Math.acos(1).should be_kind_of(Float ) + Math.acos(1).should.is_a?(Float ) end it "returns the arccosine of the argument" do @@ -21,27 +21,27 @@ end it "raises an Math::DomainError if the argument is greater than 1.0" do - -> { Math.acos(1.0001) }.should raise_error(Math::DomainError) + -> { Math.acos(1.0001) }.should.raise(Math::DomainError) end it "raises an Math::DomainError if the argument is less than -1.0" do - -> { Math.acos(-1.0001) }.should raise_error(Math::DomainError) + -> { Math.acos(-1.0001) }.should.raise(Math::DomainError) end it "raises a TypeError if the string argument cannot be coerced with Float()" do - -> { Math.acos("test") }.should raise_error(TypeError) + -> { Math.acos("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.acos(nan_value).nan?.should be_true + Math.acos(nan_value).nan?.should == true end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.acos(MathSpecs::UserClass.new) }.should raise_error(TypeError) + -> { Math.acos(MathSpecs::UserClass.new) }.should.raise(TypeError) end it "raises a TypeError if the argument is nil" do - -> { Math.acos(nil) }.should raise_error(TypeError) + -> { Math.acos(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/acosh_spec.rb b/spec/ruby/core/math/acosh_spec.rb index 6707de95d32cdd..ccacda37e08ecb 100644 --- a/spec/ruby/core/math/acosh_spec.rb +++ b/spec/ruby/core/math/acosh_spec.rb @@ -3,7 +3,7 @@ describe "Math.acosh" do it "returns a float" do - Math.acosh(1.0).should be_kind_of(Float) + Math.acosh(1.0).should.is_a?(Float) end it "returns the principle value of the inverse hyperbolic cosine of the argument" do @@ -12,21 +12,21 @@ end it "raises Math::DomainError if the passed argument is less than -1.0 or greater than 1.0" do - -> { Math.acosh(1.0 - TOLERANCE) }.should raise_error(Math::DomainError) - -> { Math.acosh(0) }.should raise_error(Math::DomainError) - -> { Math.acosh(-1.0) }.should raise_error(Math::DomainError) + -> { Math.acosh(1.0 - TOLERANCE) }.should.raise(Math::DomainError) + -> { Math.acosh(0) }.should.raise(Math::DomainError) + -> { Math.acosh(-1.0) }.should.raise(Math::DomainError) end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.acosh("test") }.should raise_error(TypeError) + -> { Math.acosh("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.acosh(nan_value).nan?.should be_true + Math.acosh(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.acosh(nil) }.should raise_error(TypeError) + -> { Math.acosh(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/asin_spec.rb b/spec/ruby/core/math/asin_spec.rb index 3a674a1147a97c..1386bccc063fc3 100644 --- a/spec/ruby/core/math/asin_spec.rb +++ b/spec/ruby/core/math/asin_spec.rb @@ -4,7 +4,7 @@ # arcsine : (-1.0, 1.0) --> (-PI/2, PI/2) describe "Math.asin" do it "returns a float" do - Math.asin(1).should be_kind_of(Float) + Math.asin(1).should.is_a?(Float) end it "returns the arcsine of the argument" do @@ -17,23 +17,23 @@ end it "raises an Math::DomainError if the argument is greater than 1.0" do - -> { Math.asin(1.0001) }.should raise_error( Math::DomainError) + -> { Math.asin(1.0001) }.should.raise( Math::DomainError) end it "raises an Math::DomainError if the argument is less than -1.0" do - -> { Math.asin(-1.0001) }.should raise_error( Math::DomainError) + -> { Math.asin(-1.0001) }.should.raise( Math::DomainError) end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.asin("test") }.should raise_error(TypeError) + -> { Math.asin("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.asin(nan_value).nan?.should be_true + Math.asin(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.asin(nil) }.should raise_error(TypeError) + -> { Math.asin(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/asinh_spec.rb b/spec/ruby/core/math/asinh_spec.rb index ff8210df0a17fb..8aa019f05f4899 100644 --- a/spec/ruby/core/math/asinh_spec.rb +++ b/spec/ruby/core/math/asinh_spec.rb @@ -3,7 +3,7 @@ describe "Math.asinh" do it "returns a float" do - Math.asinh(1.5).should be_kind_of(Float) + Math.asinh(1.5).should.is_a?(Float) end it "returns the inverse hyperbolic sin of the argument" do @@ -19,15 +19,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.asinh("test") }.should raise_error(TypeError) + -> { Math.asinh("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.asinh(nan_value).nan?.should be_true + Math.asinh(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.asinh(nil) }.should raise_error(TypeError) + -> { Math.asinh(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/atan2_spec.rb b/spec/ruby/core/math/atan2_spec.rb index d4ef369d2af67f..1f1de506c58a36 100644 --- a/spec/ruby/core/math/atan2_spec.rb +++ b/spec/ruby/core/math/atan2_spec.rb @@ -3,7 +3,7 @@ describe "Math.atan2" do it "returns a float" do - Math.atan2(1.2, 0.5).should be_kind_of(Float) + Math.atan2(1.2, 0.5).should.is_a?(Float) end it "returns the arc tangent of y, x" do @@ -14,15 +14,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.atan2(1.0, "test") }.should raise_error(TypeError) - -> { Math.atan2("test", 0.0) }.should raise_error(TypeError) - -> { Math.atan2("test", "this") }.should raise_error(TypeError) + -> { Math.atan2(1.0, "test") }.should.raise(TypeError) + -> { Math.atan2("test", 0.0) }.should.raise(TypeError) + -> { Math.atan2("test", "this") }.should.raise(TypeError) end it "raises a TypeError if the argument is nil" do - -> { Math.atan2(nil, 1.0) }.should raise_error(TypeError) - -> { Math.atan2(-1.0, nil) }.should raise_error(TypeError) - -> { Math.atan2(nil, nil) }.should raise_error(TypeError) + -> { Math.atan2(nil, 1.0) }.should.raise(TypeError) + -> { Math.atan2(-1.0, nil) }.should.raise(TypeError) + -> { Math.atan2(nil, nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/atan_spec.rb b/spec/ruby/core/math/atan_spec.rb index 15edf68c051f1d..07d04cdf824a6b 100644 --- a/spec/ruby/core/math/atan_spec.rb +++ b/spec/ruby/core/math/atan_spec.rb @@ -4,7 +4,7 @@ # arctangent : (-Inf, Inf) --> (-PI/2, PI/2) describe "Math.atan" do it "returns a float" do - Math.atan(1).should be_kind_of(Float) + Math.atan(1).should.is_a?(Float) end it "returns the arctangent of the argument" do @@ -17,15 +17,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.atan("test") }.should raise_error(TypeError) + -> { Math.atan("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.atan(nan_value).nan?.should be_true + Math.atan(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.atan(nil) }.should raise_error(TypeError) + -> { Math.atan(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/cbrt_spec.rb b/spec/ruby/core/math/cbrt_spec.rb index 01cf923c71cfef..4e2383043b5f5a 100644 --- a/spec/ruby/core/math/cbrt_spec.rb +++ b/spec/ruby/core/math/cbrt_spec.rb @@ -3,7 +3,7 @@ describe "Math.cbrt" do it "returns a float" do - Math.cbrt(1).should be_an_instance_of(Float) + Math.cbrt(1).should.instance_of?(Float) end it "returns the cubic root of the argument" do @@ -14,11 +14,11 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.cbrt("foobar") }.should raise_error(TypeError) + -> { Math.cbrt("foobar") }.should.raise(TypeError) end it "raises a TypeError if the argument is nil" do - -> { Math.cbrt(nil) }.should raise_error(TypeError) + -> { Math.cbrt(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/cos_spec.rb b/spec/ruby/core/math/cos_spec.rb index 006afeb2ccb1a2..e8602cde3c395e 100644 --- a/spec/ruby/core/math/cos_spec.rb +++ b/spec/ruby/core/math/cos_spec.rb @@ -4,7 +4,7 @@ # cosine : (-Inf, Inf) --> (-1.0, 1.0) describe "Math.cos" do it "returns a float" do - Math.cos(Math::PI).should be_kind_of(Float) + Math.cos(Math::PI).should.is_a?(Float) end it "returns the cosine of the argument expressed in radians" do @@ -16,11 +16,11 @@ end it "raises a TypeError unless the argument is Numeric and has #to_f" do - -> { Math.cos("test") }.should raise_error(TypeError) + -> { Math.cos("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.cos(nan_value).nan?.should be_true + Math.cos(nan_value).nan?.should == true end describe "coerces its argument with #to_f" do @@ -31,14 +31,14 @@ end it "raises a TypeError if the given argument can't be converted to a Float" do - -> { Math.cos(nil) }.should raise_error(TypeError) - -> { Math.cos(:abc) }.should raise_error(TypeError) + -> { Math.cos(nil) }.should.raise(TypeError) + -> { Math.cos(:abc) }.should.raise(TypeError) end it "raises a NoMethodError if the given argument raises a NoMethodError during type coercion to a Float" do object = mock_numeric('mock-float') object.should_receive(:to_f).and_raise(NoMethodError) - -> { Math.cos(object) }.should raise_error(NoMethodError) + -> { Math.cos(object) }.should.raise(NoMethodError) end end end diff --git a/spec/ruby/core/math/cosh_spec.rb b/spec/ruby/core/math/cosh_spec.rb index 049e117e56e91a..2093d8a74a1032 100644 --- a/spec/ruby/core/math/cosh_spec.rb +++ b/spec/ruby/core/math/cosh_spec.rb @@ -3,7 +3,7 @@ describe "Math.cosh" do it "returns a float" do - Math.cosh(1.0).should be_kind_of(Float) + Math.cosh(1.0).should.is_a?(Float) end it "returns the hyperbolic cosine of the argument" do @@ -14,15 +14,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.cosh("test") }.should raise_error(TypeError) + -> { Math.cosh("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.cosh(nan_value).nan?.should be_true + Math.cosh(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.cosh(nil) }.should raise_error(TypeError) + -> { Math.cosh(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/erf_spec.rb b/spec/ruby/core/math/erf_spec.rb index b4e6248e43d882..5384e73ae98690 100644 --- a/spec/ruby/core/math/erf_spec.rb +++ b/spec/ruby/core/math/erf_spec.rb @@ -5,7 +5,7 @@ # distribution (which is a normalized form of the Gaussian function). describe "Math.erf" do it "returns a float" do - Math.erf(1).should be_kind_of(Float) + Math.erf(1).should.is_a?(Float) end it "returns the error function of the argument" do @@ -21,15 +21,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.erf("test") }.should raise_error(TypeError) + -> { Math.erf("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.erf(nan_value).nan?.should be_true + Math.erf(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.erf(nil) }.should raise_error(TypeError) + -> { Math.erf(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/erfc_spec.rb b/spec/ruby/core/math/erfc_spec.rb index e465f5cf586829..4e09a68d1ef24d 100644 --- a/spec/ruby/core/math/erfc_spec.rb +++ b/spec/ruby/core/math/erfc_spec.rb @@ -4,7 +4,7 @@ # erfc is the complementary error function describe "Math.erfc" do it "returns a float" do - Math.erf(1).should be_kind_of(Float) + Math.erf(1).should.is_a?(Float) end it "returns the complementary error function of the argument" do @@ -20,15 +20,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.erfc("test") }.should raise_error(TypeError) + -> { Math.erfc("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.erfc(nan_value).nan?.should be_true + Math.erfc(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.erfc(nil) }.should raise_error(TypeError) + -> { Math.erfc(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/exp_spec.rb b/spec/ruby/core/math/exp_spec.rb index 36eb49a8c713f2..3688482457ec51 100644 --- a/spec/ruby/core/math/exp_spec.rb +++ b/spec/ruby/core/math/exp_spec.rb @@ -3,7 +3,7 @@ describe "Math.exp" do it "returns a float" do - Math.exp(1.0).should be_kind_of(Float) + Math.exp(1.0).should.is_a?(Float) end it "returns the base-e exponential of the argument" do @@ -14,15 +14,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.exp("test") }.should raise_error(TypeError) + -> { Math.exp("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.exp(nan_value).nan?.should be_true + Math.exp(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.exp(nil) }.should raise_error(TypeError) + -> { Math.exp(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/expm1_spec.rb b/spec/ruby/core/math/expm1_spec.rb index 5725319abbb458..35f62b5dbd40da 100644 --- a/spec/ruby/core/math/expm1_spec.rb +++ b/spec/ruby/core/math/expm1_spec.rb @@ -13,15 +13,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.expm1("test") }.should raise_error(TypeError, "can't convert String into Float") + -> { Math.expm1("test") }.should.raise(TypeError, "can't convert String into Float") end it "returns NaN given NaN" do - Math.expm1(nan_value).nan?.should be_true + Math.expm1(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.expm1(nil) }.should raise_error(TypeError, "can't convert nil into Float") + -> { Math.expm1(nil) }.should.raise(TypeError, "can't convert nil into Float") end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/frexp_spec.rb b/spec/ruby/core/math/frexp_spec.rb index 7dfb493d20af67..6853e4672fedd9 100644 --- a/spec/ruby/core/math/frexp_spec.rb +++ b/spec/ruby/core/math/frexp_spec.rb @@ -9,16 +9,16 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.frexp("test") }.should raise_error(TypeError) + -> { Math.frexp("test") }.should.raise(TypeError) end it "returns NaN given NaN" do frac, _exp = Math.frexp(nan_value) - frac.nan?.should be_true + frac.nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.frexp(nil) }.should raise_error(TypeError) + -> { Math.frexp(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/gamma_spec.rb b/spec/ruby/core/math/gamma_spec.rb index 386162a087518d..9a0b14448a7afd 100644 --- a/spec/ruby/core/math/gamma_spec.rb +++ b/spec/ruby/core/math/gamma_spec.rb @@ -51,7 +51,7 @@ end it "raises Math::DomainError given -1" do - -> { Math.gamma(-1) }.should raise_error(Math::DomainError) + -> { Math.gamma(-1) }.should.raise(Math::DomainError) end # See https://bugs.ruby-lang.org/issues/10642 @@ -60,10 +60,10 @@ end it "raises Math::DomainError given negative infinity" do - -> { Math.gamma(-Float::INFINITY) }.should raise_error(Math::DomainError) + -> { Math.gamma(-Float::INFINITY) }.should.raise(Math::DomainError) end it "returns NaN given NaN" do - Math.gamma(nan_value).nan?.should be_true + Math.gamma(nan_value).nan?.should == true end end diff --git a/spec/ruby/core/math/hypot_spec.rb b/spec/ruby/core/math/hypot_spec.rb index 3e0ce7459740f9..4ab5bd4e88bd1c 100644 --- a/spec/ruby/core/math/hypot_spec.rb +++ b/spec/ruby/core/math/hypot_spec.rb @@ -3,7 +3,7 @@ describe "Math.hypot" do it "returns a float" do - Math.hypot(3, 4).should be_kind_of(Float) + Math.hypot(3, 4).should.is_a?(Float) end it "returns the length of the hypotenuse of a right triangle with legs given by the arguments" do @@ -16,17 +16,17 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.hypot("test", "this") }.should raise_error(TypeError) + -> { Math.hypot("test", "this") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.hypot(nan_value, 0).nan?.should be_true - Math.hypot(0, nan_value).nan?.should be_true - Math.hypot(nan_value, nan_value).nan?.should be_true + Math.hypot(nan_value, 0).nan?.should == true + Math.hypot(0, nan_value).nan?.should == true + Math.hypot(nan_value, nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.hypot(nil, nil) }.should raise_error(TypeError) + -> { Math.hypot(nil, nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/ldexp_spec.rb b/spec/ruby/core/math/ldexp_spec.rb index 6dcf94a663cc43..1864b7455adb97 100644 --- a/spec/ruby/core/math/ldexp_spec.rb +++ b/spec/ruby/core/math/ldexp_spec.rb @@ -3,7 +3,7 @@ describe "Math.ldexp" do it "returns a float" do - Math.ldexp(1.0, 2).should be_kind_of(Float) + Math.ldexp(1.0, 2).should.is_a?(Float) end it "returns the argument multiplied by 2**n" do @@ -15,27 +15,27 @@ end it "raises a TypeError if the first argument cannot be coerced with Float()" do - -> { Math.ldexp("test", 2) }.should raise_error(TypeError) + -> { Math.ldexp("test", 2) }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.ldexp(nan_value, 0).nan?.should be_true + Math.ldexp(nan_value, 0).nan?.should == true end it "raises RangeError if NaN is given as the second arg" do - -> { Math.ldexp(0, nan_value) }.should raise_error(RangeError) + -> { Math.ldexp(0, nan_value) }.should.raise(RangeError) end it "raises a TypeError if the second argument cannot be coerced with Integer()" do - -> { Math.ldexp(3.2, "this") }.should raise_error(TypeError) + -> { Math.ldexp(3.2, "this") }.should.raise(TypeError) end it "raises a TypeError if the first argument is nil" do - -> { Math.ldexp(nil, 2) }.should raise_error(TypeError) + -> { Math.ldexp(nil, 2) }.should.raise(TypeError) end it "raises a TypeError if the second argument is nil" do - -> { Math.ldexp(3.1, nil) }.should raise_error(TypeError) + -> { Math.ldexp(3.1, nil) }.should.raise(TypeError) end it "accepts any first argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/lgamma_spec.rb b/spec/ruby/core/math/lgamma_spec.rb index 2bf350993e57f8..38f07d0bf87666 100644 --- a/spec/ruby/core/math/lgamma_spec.rb +++ b/spec/ruby/core/math/lgamma_spec.rb @@ -38,7 +38,7 @@ end it "raises Math::DomainError when passed -Infinity" do - -> { Math.lgamma(-infinity_value) }.should raise_error(Math::DomainError) + -> { Math.lgamma(-infinity_value) }.should.raise(Math::DomainError) end it "returns [Infinity, 1] when passed Infinity" do diff --git a/spec/ruby/core/math/log10_spec.rb b/spec/ruby/core/math/log10_spec.rb index f3bd7fd4b86474..7576a67002722c 100644 --- a/spec/ruby/core/math/log10_spec.rb +++ b/spec/ruby/core/math/log10_spec.rb @@ -4,7 +4,7 @@ # The common logarithm, having base 10 describe "Math.log10" do it "returns a float" do - Math.log10(1).should be_kind_of(Float) + Math.log10(1).should.is_a?(Float) end it "returns the base-10 logarithm of the argument" do @@ -16,23 +16,23 @@ end it "raises an Math::DomainError if the argument is less than 0" do - -> { Math.log10(-1e-15) }.should raise_error(Math::DomainError) + -> { Math.log10(-1e-15) }.should.raise(Math::DomainError) end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.log10("test") }.should raise_error(TypeError) + -> { Math.log10("test") }.should.raise(TypeError) end it "raises a TypeError if passed a numerical argument as a string" do - -> { Math.log10("1.0") }.should raise_error(TypeError) + -> { Math.log10("1.0") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.log10(nan_value).nan?.should be_true + Math.log10(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.log10(nil) }.should raise_error(TypeError) + -> { Math.log10(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/log1p_spec.rb b/spec/ruby/core/math/log1p_spec.rb index 216358a3c47802..181b462dede1ee 100644 --- a/spec/ruby/core/math/log1p_spec.rb +++ b/spec/ruby/core/math/log1p_spec.rb @@ -13,27 +13,27 @@ end it "raises an Math::DomainError if the argument is less than 1" do - -> { Math.log1p(-1-1e-15) }.should raise_error(Math::DomainError, "Numerical argument is out of domain - log1p") + -> { Math.log1p(-1-1e-15) }.should.raise(Math::DomainError, "Numerical argument is out of domain - log1p") end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.log1p("test") }.should raise_error(TypeError, "can't convert String into Float") + -> { Math.log1p("test") }.should.raise(TypeError, "can't convert String into Float") end it "raises a TypeError for numerical values passed as string" do - -> { Math.log1p("10") }.should raise_error(TypeError, "can't convert String into Float") + -> { Math.log1p("10") }.should.raise(TypeError, "can't convert String into Float") end it "does not accept a second argument for the base" do - -> { Math.log1p(9, 3) }.should raise_error(ArgumentError, "wrong number of arguments (given 2, expected 1)") + -> { Math.log1p(9, 3) }.should.raise(ArgumentError, "wrong number of arguments (given 2, expected 1)") end it "returns NaN given NaN" do - Math.log1p(nan_value).nan?.should be_true + Math.log1p(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.log1p(nil) }.should raise_error(TypeError, "can't convert nil into Float") + -> { Math.log1p(nil) }.should.raise(TypeError, "can't convert nil into Float") end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/log2_spec.rb b/spec/ruby/core/math/log2_spec.rb index 3d4d41d1305f43..e38a8bb67fa445 100644 --- a/spec/ruby/core/math/log2_spec.rb +++ b/spec/ruby/core/math/log2_spec.rb @@ -16,23 +16,23 @@ end it "raises Math::DomainError if the argument is less than 0" do - -> { Math.log2(-1e-15) }.should raise_error( Math::DomainError) + -> { Math.log2(-1e-15) }.should.raise( Math::DomainError) end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.log2("test") }.should raise_error(TypeError) + -> { Math.log2("test") }.should.raise(TypeError) end it "raises a TypeError if passed a numerical argument as a string" do - -> { Math.log2("1.0") }.should raise_error(TypeError) + -> { Math.log2("1.0") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.log2(nan_value).nan?.should be_true + Math.log2(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.log2(nil) }.should raise_error(TypeError) + -> { Math.log2(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/log_spec.rb b/spec/ruby/core/math/log_spec.rb index 6c5036ba81c6ce..7e0bc13bc62a40 100644 --- a/spec/ruby/core/math/log_spec.rb +++ b/spec/ruby/core/math/log_spec.rb @@ -4,7 +4,7 @@ # The natural logarithm, having base Math::E describe "Math.log" do it "returns a float" do - Math.log(1).should be_kind_of(Float) + Math.log(1).should.is_a?(Float) end it "returns the natural logarithm of the argument" do @@ -16,15 +16,15 @@ end it "raises an Math::DomainError if the argument is less than 0" do - -> { Math.log(-1e-15) }.should raise_error(Math::DomainError) + -> { Math.log(-1e-15) }.should.raise(Math::DomainError) end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.log("test") }.should raise_error(TypeError) + -> { Math.log("test") }.should.raise(TypeError) end it "raises a TypeError for numerical values passed as string" do - -> { Math.log("10") }.should raise_error(TypeError) + -> { Math.log("10") }.should.raise(TypeError) end it "accepts a second argument for the base" do @@ -33,16 +33,16 @@ end it "raises a TypeError when the numerical base cannot be coerced to a float" do - -> { Math.log(10, "2") }.should raise_error(TypeError) - -> { Math.log(10, nil) }.should raise_error(TypeError) + -> { Math.log(10, "2") }.should.raise(TypeError) + -> { Math.log(10, nil) }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.log(nan_value).nan?.should be_true + Math.log(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.log(nil) }.should raise_error(TypeError) + -> { Math.log(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/shared/atanh.rb b/spec/ruby/core/math/shared/atanh.rb index 3fb64153a0c059..48a6bf836ebf68 100644 --- a/spec/ruby/core/math/shared/atanh.rb +++ b/spec/ruby/core/math/shared/atanh.rb @@ -1,6 +1,6 @@ describe :math_atanh_base, shared: true do it "returns a float" do - @object.send(@method, 0.5).should be_an_instance_of(Float) + @object.send(@method, 0.5).should.instance_of?(Float) end it "returns the inverse hyperbolic tangent of the argument" do @@ -11,11 +11,11 @@ end it "raises a TypeError if the argument is nil" do - -> { @object.send(@method, nil) }.should raise_error(TypeError) + -> { @object.send(@method, nil) }.should.raise(TypeError) end it "raises a TypeError if the argument is not a Numeric" do - -> { @object.send(@method, "test") }.should raise_error(TypeError) + -> { @object.send(@method, "test") }.should.raise(TypeError) end it "returns Infinity if x == 1.0" do @@ -29,16 +29,16 @@ describe :math_atanh_private, shared: true do it "is a private instance method" do - Math.should have_private_instance_method(@method) + Math.private_instance_methods(false).should.include?(@method) end end describe :math_atanh_no_complex, shared: true do it "raises a Math::DomainError for arguments greater than 1.0" do - -> { @object.send(@method, 1.0 + Float::EPSILON) }.should raise_error(Math::DomainError) + -> { @object.send(@method, 1.0 + Float::EPSILON) }.should.raise(Math::DomainError) end it "raises a Math::DomainError for arguments less than -1.0" do - -> { @object.send(@method, -1.0 - Float::EPSILON) }.should raise_error(Math::DomainError) + -> { @object.send(@method, -1.0 - Float::EPSILON) }.should.raise(Math::DomainError) end end diff --git a/spec/ruby/core/math/sin_spec.rb b/spec/ruby/core/math/sin_spec.rb index 8e944bc95fc1b3..a9479e3aec52a0 100644 --- a/spec/ruby/core/math/sin_spec.rb +++ b/spec/ruby/core/math/sin_spec.rb @@ -4,7 +4,7 @@ # sine : (-Inf, Inf) --> (-1.0, 1.0) describe "Math.sin" do it "returns a float" do - Math.sin(Math::PI).should be_kind_of(Float) + Math.sin(Math::PI).should.is_a?(Float) end it "returns the sine of the argument expressed in radians" do @@ -16,15 +16,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.sin("test") }.should raise_error(TypeError) + -> { Math.sin("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.sin(nan_value).nan?.should be_true + Math.sin(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.sin(nil) }.should raise_error(TypeError) + -> { Math.sin(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/sinh_spec.rb b/spec/ruby/core/math/sinh_spec.rb index 027c2395a71889..de0f06affaf2bc 100644 --- a/spec/ruby/core/math/sinh_spec.rb +++ b/spec/ruby/core/math/sinh_spec.rb @@ -3,7 +3,7 @@ describe "Math.sinh" do it "returns a float" do - Math.sinh(1.2).should be_kind_of(Float) + Math.sinh(1.2).should.is_a?(Float) end it "returns the hyperbolic sin of the argument" do @@ -14,15 +14,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.sinh("test") }.should raise_error(TypeError) + -> { Math.sinh("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.sinh(nan_value).nan?.should be_true + Math.sinh(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.sinh(nil) }.should raise_error(TypeError) + -> { Math.sinh(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/sqrt_spec.rb b/spec/ruby/core/math/sqrt_spec.rb index 918e7c3a17e607..545fa4d1c263f7 100644 --- a/spec/ruby/core/math/sqrt_spec.rb +++ b/spec/ruby/core/math/sqrt_spec.rb @@ -3,7 +3,7 @@ describe "Math.sqrt" do it "returns a float" do - Math.sqrt(1).should be_kind_of(Float) + Math.sqrt(1).should.is_a?(Float) end it "returns the square root of the argument" do @@ -13,15 +13,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.sqrt("test") }.should raise_error(TypeError) + -> { Math.sqrt("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.sqrt(nan_value).nan?.should be_true + Math.sqrt(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.sqrt(nil) }.should raise_error(TypeError) + -> { Math.sqrt(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do @@ -29,7 +29,7 @@ end it "raises a Math::DomainError when given a negative number" do - -> { Math.sqrt(-1) }.should raise_error(Math::DomainError) + -> { Math.sqrt(-1) }.should.raise(Math::DomainError) end end diff --git a/spec/ruby/core/math/tan_spec.rb b/spec/ruby/core/math/tan_spec.rb index 67307f1e6e3be7..c3e773f318b50e 100644 --- a/spec/ruby/core/math/tan_spec.rb +++ b/spec/ruby/core/math/tan_spec.rb @@ -3,7 +3,7 @@ describe "Math.tan" do it "returns a float" do - Math.tan(1.35).should be_kind_of(Float) + Math.tan(1.35).should.is_a?(Float) end it "returns the tangent of the argument" do @@ -19,15 +19,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.tan("test") }.should raise_error(TypeError) + -> { Math.tan("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.tan(nan_value).nan?.should be_true + Math.tan(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.tan(nil) }.should raise_error(TypeError) + -> { Math.tan(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/math/tanh_spec.rb b/spec/ruby/core/math/tanh_spec.rb index 568f8dfa775def..74a938ffd8e6d2 100644 --- a/spec/ruby/core/math/tanh_spec.rb +++ b/spec/ruby/core/math/tanh_spec.rb @@ -3,7 +3,7 @@ describe "Math.tanh" do it "returns a float" do - Math.tanh(0.5).should be_kind_of(Float) + Math.tanh(0.5).should.is_a?(Float) end it "returns the hyperbolic tangent of the argument" do @@ -16,15 +16,15 @@ end it "raises a TypeError if the argument cannot be coerced with Float()" do - -> { Math.tanh("test") }.should raise_error(TypeError) + -> { Math.tanh("test") }.should.raise(TypeError) end it "returns NaN given NaN" do - Math.tanh(nan_value).nan?.should be_true + Math.tanh(nan_value).nan?.should == true end it "raises a TypeError if the argument is nil" do - -> { Math.tanh(nil) }.should raise_error(TypeError) + -> { Math.tanh(nil) }.should.raise(TypeError) end it "accepts any argument that can be coerced with Float()" do diff --git a/spec/ruby/core/method/curry_spec.rb b/spec/ruby/core/method/curry_spec.rb index 219de0f6b56626..79c5d7c662ed3b 100644 --- a/spec/ruby/core/method/curry_spec.rb +++ b/spec/ruby/core/method/curry_spec.rb @@ -7,7 +7,7 @@ def x.foo(a,b,c); [a,b,c]; end c = x.method(:foo).curry - c.should be_kind_of(Proc) + c.should.is_a?(Proc) c.call(1).call(2, 3).should == [1,2,3] end @@ -17,20 +17,20 @@ def x.foo(a,b,c); [a,b,c]; end end it "returns a curried proc when given correct arity" do - @obj.method(:one_req).curry(1).should be_kind_of(Proc) - @obj.method(:zero_with_splat).curry(100).should be_kind_of(Proc) - @obj.method(:two_req_with_splat).curry(2).should be_kind_of(Proc) + @obj.method(:one_req).curry(1).should.is_a?(Proc) + @obj.method(:zero_with_splat).curry(100).should.is_a?(Proc) + @obj.method(:two_req_with_splat).curry(2).should.is_a?(Proc) end it "raises ArgumentError when the method requires less arguments than the given arity" do - -> { @obj.method(:zero).curry(1) }.should raise_error(ArgumentError) - -> { @obj.method(:one_req_one_opt).curry(3) }.should raise_error(ArgumentError) - -> { @obj.method(:two_req_one_opt_with_block).curry(4) }.should raise_error(ArgumentError) + -> { @obj.method(:zero).curry(1) }.should.raise(ArgumentError) + -> { @obj.method(:one_req_one_opt).curry(3) }.should.raise(ArgumentError) + -> { @obj.method(:two_req_one_opt_with_block).curry(4) }.should.raise(ArgumentError) end it "raises ArgumentError when the method requires more arguments than the given arity" do - -> { @obj.method(:two_req_with_splat).curry(1) }.should raise_error(ArgumentError) - -> { @obj.method(:one_req).curry(0) }.should raise_error(ArgumentError) + -> { @obj.method(:two_req_with_splat).curry(1) }.should.raise(ArgumentError) + -> { @obj.method(:one_req).curry(0) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/method/fixtures/classes.rb b/spec/ruby/core/method/fixtures/classes.rb index 464a519aeacbac..41904df1d1656c 100644 --- a/spec/ruby/core/method/fixtures/classes.rb +++ b/spec/ruby/core/method/fixtures/classes.rb @@ -27,6 +27,7 @@ def foo alias bar foo alias baz bar + alias qux baz def same_as_foo true diff --git a/spec/ruby/core/method/original_name_spec.rb b/spec/ruby/core/method/original_name_spec.rb index 676fdaedb4621f..8fec0e7c33cee5 100644 --- a/spec/ruby/core/method/original_name_spec.rb +++ b/spec/ruby/core/method/original_name_spec.rb @@ -19,4 +19,25 @@ obj.method(:baz).original_name.should == :foo obj.method(:baz).unbind.bind(obj).original_name.should == :foo end + + it "returns the original name even when aliased thrice" do + obj = MethodSpecs::Methods.new + obj.method(:qux).original_name.should == :foo + obj.method(:qux).unbind.bind(obj).original_name.should == :foo + end + + it "returns the source UnboundMethod's name (not the name given to define_method)" do + klass = Class.new { define_method(:my_inspect, ::Kernel.instance_method(:inspect)) } + klass.new.method(:my_inspect).original_name.should == :inspect + end + + it "preserves the source method's name through define_method and alias" do + source = Class.new { def my_method; end } + klass = Class.new(source) do + define_method(:renamed, source.instance_method(:my_method)) + alias aliased renamed + end + klass.new.method(:renamed).original_name.should == :my_method + klass.new.method(:aliased).original_name.should == :my_method + end end diff --git a/spec/ruby/core/method/parameters_spec.rb b/spec/ruby/core/method/parameters_spec.rb index 41b9cd8d12b895..fd88e8dcb8684e 100644 --- a/spec/ruby/core/method/parameters_spec.rb +++ b/spec/ruby/core/method/parameters_spec.rb @@ -308,7 +308,7 @@ def object.foo(&) [ [[:rest]], [[:opt]] - ].should include([].method(:pop).parameters) + ].should.include?([].method(:pop).parameters) end it "returns [[:req]] for each parameter for core methods with fixed-length argument lists" do diff --git a/spec/ruby/core/method/receiver_spec.rb b/spec/ruby/core/method/receiver_spec.rb index 2b2e11dd2e40a8..315a08d2885229 100644 --- a/spec/ruby/core/method/receiver_spec.rb +++ b/spec/ruby/core/method/receiver_spec.rb @@ -4,19 +4,19 @@ describe "Method#receiver" do it "returns the receiver of the method" do s = "abc" - s.method(:upcase).receiver.should equal(s) + s.method(:upcase).receiver.should.equal?(s) end it "returns the right receiver even when aliased" do obj = MethodSpecs::Methods.new - obj.method(:foo).receiver.should equal(obj) - obj.method(:bar).receiver.should equal(obj) + obj.method(:foo).receiver.should.equal?(obj) + obj.method(:bar).receiver.should.equal?(obj) end describe "for a Method generated by respond_to_missing?" do it "returns the receiver of the method" do m = MethodSpecs::Methods.new - m.method(:handled_via_method_missing).receiver.should equal(m) + m.method(:handled_via_method_missing).receiver.should.equal?(m) end end end diff --git a/spec/ruby/core/method/shared/call.rb b/spec/ruby/core/method/shared/call.rb index f26e373695d28a..41ee2b06cb99c4 100644 --- a/spec/ruby/core/method/shared/call.rb +++ b/spec/ruby/core/method/shared/call.rb @@ -11,10 +11,10 @@ it "raises an ArgumentError when given incorrect number of arguments" do -> { MethodSpecs::Methods.new.method(:two_req).send(@method, 1, 2, 3) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { MethodSpecs::Methods.new.method(:two_req).send(@method, 1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end describe "for a Method generated by respond_to_missing?" do diff --git a/spec/ruby/core/method/shared/dup.rb b/spec/ruby/core/method/shared/dup.rb index c74847083f807d..eee790890a2a01 100644 --- a/spec/ruby/core/method/shared/dup.rb +++ b/spec/ruby/core/method/shared/dup.rb @@ -4,7 +4,7 @@ b = a.send(@method) a.should == b - a.should_not equal(b) + a.should_not.equal?(b) end ruby_version_is "3.4" do diff --git a/spec/ruby/core/method/shared/eql.rb b/spec/ruby/core/method/shared/eql.rb index 5c720cbac15b87..3c340202b7536b 100644 --- a/spec/ruby/core/method/shared/eql.rb +++ b/spec/ruby/core/method/shared/eql.rb @@ -12,54 +12,54 @@ it "returns true if methods are the same" do m2 = @m.method(:foo) - @m_foo.send(@method, @m_foo).should be_true - @m_foo.send(@method, m2).should be_true + @m_foo.send(@method, @m_foo).should == true + @m_foo.send(@method, m2).should == true end it "returns true on aliased methods" do m_bar = @m.method(:bar) - m_bar.send(@method, @m_foo).should be_true + m_bar.send(@method, @m_foo).should == true end it "returns true if the two core methods are aliases" do s = "hello" a = s.method(:size) b = s.method(:length) - a.send(@method, b).should be_true + a.send(@method, b).should == true end it "returns false on a method which is neither aliased nor the same method" do m2 = @m.method(:zero) - @m_foo.send(@method, m2).should be_false + @m_foo.send(@method, m2).should == false end it "returns false for a method which is not bound to the same object" do m2_foo = @m2.method(:foo) a_baz = @a.method(:baz) - @m_foo.send(@method, m2_foo).should be_false - @m_foo.send(@method, a_baz).should be_false + @m_foo.send(@method, m2_foo).should == false + @m_foo.send(@method, a_baz).should == false end it "returns false if the two methods are bound to the same object but were defined independently" do m2 = @m.method(:same_as_foo) - @m_foo.send(@method, m2).should be_false + @m_foo.send(@method, m2).should == false end it "returns true if a method was defined using the other one" do MethodSpecs::Methods.send :define_method, :defined_foo, MethodSpecs::Methods.instance_method(:foo) m2 = @m.method(:defined_foo) - @m_foo.send(@method, m2).should be_true + @m_foo.send(@method, m2).should == true end it "returns false if comparing a method defined via define_method and def" do defn = @m.method(:zero) defined = @m.method(:zero_defined_method) - defn.send(@method, defined).should be_false - defined.send(@method, defn).should be_false + defn.send(@method, defined).should == false + defined.send(@method, defn).should == false end describe 'missing methods' do @@ -68,8 +68,8 @@ miss1bis = @m.method(:handled_via_method_missing) miss2 = @m.method(:also_handled) - miss1.send(@method, miss1bis).should be_true - miss1.send(@method, miss2).should be_false + miss1.send(@method, miss1bis).should == true + miss1.send(@method, miss2).should == false end it 'calls respond_to_missing? with true to include private methods' do @@ -81,14 +81,14 @@ it "returns false if the two methods are bound to different objects, have the same names, and identical bodies" do a = MethodSpecs::Eql.instance_method(:same_body) b = MethodSpecs::Eql2.instance_method(:same_body) - a.send(@method, b).should be_false + a.send(@method, b).should == false end it "returns false if the argument is not a Method object" do - String.instance_method(:size).send(@method, 7).should be_false + String.instance_method(:size).send(@method, 7).should == false end it "returns false if the argument is an unbound version of self" do - method(:load).send(@method, method(:load).unbind).should be_false + method(:load).send(@method, method(:load).unbind).should == false end end diff --git a/spec/ruby/core/method/shared/to_s.rb b/spec/ruby/core/method/shared/to_s.rb index b2d27d370f1216..bfb58e6896cc79 100644 --- a/spec/ruby/core/method/shared/to_s.rb +++ b/spec/ruby/core/method/shared/to_s.rb @@ -8,12 +8,12 @@ end it "returns a String" do - @m.send(@method).should be_kind_of(String) + @m.send(@method).should.is_a?(String) end it "returns a String for methods defined with attr_accessor" do m = MethodSpecs::Methods.new.method :attr - m.send(@method).should be_kind_of(String) + m.send(@method).should.is_a?(String) end it "returns a String containing 'Method'" do diff --git a/spec/ruby/core/method/source_location_spec.rb b/spec/ruby/core/method/source_location_spec.rb index c5b296f6e2a7b0..22fcb98c742960 100644 --- a/spec/ruby/core/method/source_location_spec.rb +++ b/spec/ruby/core/method/source_location_spec.rb @@ -7,18 +7,18 @@ end it "returns an Array" do - @method.source_location.should be_an_instance_of(Array) + @method.source_location.should.instance_of?(Array) end it "sets the first value to the path of the file in which the method was defined" do file = @method.source_location.first - file.should be_an_instance_of(String) + file.should.instance_of?(String) file.should == File.realpath('fixtures/classes.rb', __dir__) end it "sets the last value to an Integer representing the line on which the method was defined" do line = @method.source_location.last - line.should be_an_instance_of(Integer) + line.should.instance_of?(Integer) line.should == 5 end @@ -92,7 +92,7 @@ def f loc.should == nil else loc[0].should.start_with?(' { @object.private_one }.should raise_error(NameError) - -> { @object.private_ichi }.should raise_error(NameError) + -> { @object.private_one }.should.raise(NameError) + -> { @object.private_ichi }.should.raise(NameError) @class.make_alias :public_ichi, :public_one @object.public_ichi.should == @object.public_one @class.make_alias :protected_ichi, :protected_one - -> { @object.protected_ichi }.should raise_error(NameError) + -> { @object.protected_ichi }.should.raise(NameError) end it "handles aliasing a stub that changes visibility" do @@ -55,7 +55,7 @@ def uno_refined_method end it "fails if origin method not found" do - -> { @class.make_alias :ni, :san }.should raise_error(NameError) { |e| + -> { @class.make_alias :ni, :san }.should.raise(NameError) { |e| # a NameError and not a NoMethodError e.class.should == NameError } @@ -63,7 +63,7 @@ def uno_refined_method it "raises FrozenError if frozen" do @class.freeze - -> { @class.make_alias :uno, :public_one }.should raise_error(FrozenError) + -> { @class.make_alias :uno, :public_one }.should.raise(FrozenError) end it "converts the names using #to_str" do @@ -78,23 +78,23 @@ def uno_refined_method end it "raises a TypeError when the given name can't be converted using to_str" do - -> { @class.make_alias mock('x'), :public_one }.should raise_error(TypeError) + -> { @class.make_alias mock('x'), :public_one }.should.raise(TypeError) end it "raises a NoMethodError if the given name raises a NoMethodError during type coercion using to_str" do obj = mock("mock-name") obj.should_receive(:to_str).and_raise(NoMethodError) - -> { @class.make_alias obj, :public_one }.should raise_error(NoMethodError) + -> { @class.make_alias obj, :public_one }.should.raise(NoMethodError) end it "is a public method" do - Module.should have_public_instance_method(:alias_method, false) + Module.public_instance_methods(false).should.include?(:alias_method) end describe "returned value" do it "returns symbol of the defined method name" do - @class.send(:alias_method, :checking_return_value, :public_one).should equal(:checking_return_value) - @class.send(:alias_method, 'checking_return_value', :public_one).should equal(:checking_return_value) + @class.send(:alias_method, :checking_return_value, :public_one).should.equal?(:checking_return_value) + @class.send(:alias_method, 'checking_return_value', :public_one).should.equal?(:checking_return_value) end end @@ -104,14 +104,14 @@ def uno_refined_method it "works on private module methods in a module that has been reopened" do ModuleSpecs::ReopeningModule.foo.should == true - -> { ModuleSpecs::ReopeningModule.foo2 }.should_not raise_error(NoMethodError) + -> { ModuleSpecs::ReopeningModule.foo2 }.should_not.raise(NoMethodError) end it "accesses a method defined on Object from Kernel" do - Kernel.should_not have_public_instance_method(:module_specs_public_method_on_object) + Kernel.public_instance_methods(true).should_not.include?(:module_specs_public_method_on_object) - Kernel.should have_public_instance_method(:module_specs_alias_on_kernel) - Object.should have_public_instance_method(:module_specs_alias_on_kernel) + Kernel.public_instance_methods(false).should.include?(:module_specs_alias_on_kernel) + Object.public_instance_methods(true).should.include?(:module_specs_alias_on_kernel) end it "can call a method with super aliased twice" do @@ -130,42 +130,42 @@ def uno_refined_method it "keeps initialize private when aliasing" do @class.make_alias(:initialize, :public_one) - @class.private_instance_methods.include?(:initialize).should be_true + @class.private_instance_methods.include?(:initialize).should == true @subclass.make_alias(:initialize, :public_one) - @subclass.private_instance_methods.include?(:initialize).should be_true + @subclass.private_instance_methods.include?(:initialize).should == true end it "keeps initialize_copy private when aliasing" do @class.make_alias(:initialize_copy, :public_one) - @class.private_instance_methods.include?(:initialize_copy).should be_true + @class.private_instance_methods.include?(:initialize_copy).should == true @subclass.make_alias(:initialize_copy, :public_one) - @subclass.private_instance_methods.include?(:initialize_copy).should be_true + @subclass.private_instance_methods.include?(:initialize_copy).should == true end it "keeps initialize_clone private when aliasing" do @class.make_alias(:initialize_clone, :public_one) - @class.private_instance_methods.include?(:initialize_clone).should be_true + @class.private_instance_methods.include?(:initialize_clone).should == true @subclass.make_alias(:initialize_clone, :public_one) - @subclass.private_instance_methods.include?(:initialize_clone).should be_true + @subclass.private_instance_methods.include?(:initialize_clone).should == true end it "keeps initialize_dup private when aliasing" do @class.make_alias(:initialize_dup, :public_one) - @class.private_instance_methods.include?(:initialize_dup).should be_true + @class.private_instance_methods.include?(:initialize_dup).should == true @subclass.make_alias(:initialize_dup, :public_one) - @subclass.private_instance_methods.include?(:initialize_dup).should be_true + @subclass.private_instance_methods.include?(:initialize_dup).should == true end it "keeps respond_to_missing? private when aliasing" do @class.make_alias(:respond_to_missing?, :public_one) - @class.private_instance_methods.include?(:respond_to_missing?).should be_true + @class.private_instance_methods.include?(:respond_to_missing?).should == true @subclass.make_alias(:respond_to_missing?, :public_one) - @subclass.private_instance_methods.include?(:respond_to_missing?).should be_true + @subclass.private_instance_methods.include?(:respond_to_missing?).should == true end end end diff --git a/spec/ruby/core/module/ancestors_spec.rb b/spec/ruby/core/module/ancestors_spec.rb index 90c26941d14a1b..f85884a4f3e05c 100644 --- a/spec/ruby/core/module/ancestors_spec.rb +++ b/spec/ruby/core/module/ancestors_spec.rb @@ -21,7 +21,7 @@ end it "returns only modules and classes" do - class << ModuleSpecs::Child; self; end.ancestors.should include(ModuleSpecs::Internal, Class, Module, Object, Kernel) + class << ModuleSpecs::Child; self; end.ancestors.to_set.should >= Set[ModuleSpecs::Internal, Class, Module, Object, Kernel] end it "has 1 entry per module or class" do @@ -45,7 +45,7 @@ class << ModuleSpecs::Child; self; end.ancestors.should include(ModuleSpecs::Int child = Class.new(parent) schild = child.singleton_class - schild.ancestors.should include(schild, + schild.ancestors.to_set.should >= Set[schild, parent.singleton_class, Object.singleton_class, BasicObject.singleton_class, @@ -53,14 +53,14 @@ class << ModuleSpecs::Child; self; end.ancestors.should include(ModuleSpecs::Int Module, Object, Kernel, - BasicObject) + BasicObject] end describe 'for a standalone module' do it 'does not include Class' do s_mod = ModuleSpecs.singleton_class - s_mod.ancestors.should_not include(Class) + s_mod.ancestors.should_not.include?(Class) end it 'does not include other singleton classes' do @@ -69,19 +69,19 @@ class << ModuleSpecs::Child; self; end.ancestors.should include(ModuleSpecs::Int s_object = Object.singleton_class s_basic_object = BasicObject.singleton_class - s_standalone_mod.ancestors.should_not include(s_module, s_object, s_basic_object) + (s_standalone_mod.ancestors & [s_module, s_object, s_basic_object]).should.empty? end it 'includes its own singleton class' do s_mod = ModuleSpecs.singleton_class - s_mod.ancestors.should include(s_mod) + s_mod.ancestors.should.include?(s_mod) end it 'includes standard chain' do s_mod = ModuleSpecs.singleton_class - s_mod.ancestors.should include(Module, Object, Kernel, BasicObject) + s_mod.ancestors.to_set.should >= Set[Module, Object, Kernel, BasicObject] end end end diff --git a/spec/ruby/core/module/append_features_spec.rb b/spec/ruby/core/module/append_features_spec.rb index 1724cde5d60ab9..4d2207330d6852 100644 --- a/spec/ruby/core/module/append_features_spec.rb +++ b/spec/ruby/core/module/append_features_spec.rb @@ -3,18 +3,18 @@ describe "Module#append_features" do it "is a private method" do - Module.should have_private_instance_method(:append_features) + Module.private_instance_methods(false).should.include?(:append_features) end describe "on Class" do it "is undefined" do - Class.should_not have_private_instance_method(:append_features, true) + Class.private_instance_methods(true).should_not.include?(:append_features) end it "raises a TypeError if calling after rebinded to Class" do -> { Module.instance_method(:append_features).bind(Class.new).call Module.new - }.should raise_error(TypeError) + }.should.raise(TypeError) end end @@ -39,11 +39,11 @@ def self.append_features(mod) it "raises an ArgumentError on a cyclic include" do -> { ModuleSpecs::CyclicAppendA.send(:append_features, ModuleSpecs::CyclicAppendA) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { ModuleSpecs::CyclicAppendB.send(:append_features, ModuleSpecs::CyclicAppendA) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end @@ -54,8 +54,8 @@ def self.append_features(mod) end it "raises a FrozenError before appending self" do - -> { @receiver.send(:append_features, @other) }.should raise_error(FrozenError) - @other.ancestors.should_not include(@receiver) + -> { @receiver.send(:append_features, @other) }.should.raise(FrozenError) + @other.ancestors.should_not.include?(@receiver) end end end diff --git a/spec/ruby/core/module/attr_accessor_spec.rb b/spec/ruby/core/module/attr_accessor_spec.rb index 503dccc61ede1d..a608760cf25df5 100644 --- a/spec/ruby/core/module/attr_accessor_spec.rb +++ b/spec/ruby/core/module/attr_accessor_spec.rb @@ -34,7 +34,7 @@ class TrueClass attr_accessor :spec_attr_accessor end - -> { true.spec_attr_accessor = "a" }.should raise_error(FrozenError) + -> { true.spec_attr_accessor = "a" }.should.raise(FrozenError) end it "raises FrozenError if the receiver if frozen" do @@ -46,7 +46,7 @@ class TrueClass obj.foo.should == 1 obj.freeze - -> { obj.foo = 42 }.should raise_error(FrozenError) + -> { obj.foo = 42 }.should.raise(FrozenError) obj.foo.should == 1 end @@ -62,9 +62,9 @@ class TrueClass it "raises a TypeError when the given names can't be converted to strings using to_str" do o = mock('o') - -> { Class.new { attr_accessor o } }.should raise_error(TypeError) + -> { Class.new { attr_accessor o } }.should.raise(TypeError) (o = mock('123')).should_receive(:to_str).and_return(123) - -> { Class.new { attr_accessor o } }.should raise_error(TypeError) + -> { Class.new { attr_accessor o } }.should.raise(TypeError) end it "applies current visibility to methods created" do @@ -73,12 +73,12 @@ class TrueClass attr_accessor :foo end - -> { c.new.foo }.should raise_error(NoMethodError) - -> { c.new.foo=1 }.should raise_error(NoMethodError) + -> { c.new.foo }.should.raise(NoMethodError) + -> { c.new.foo=1 }.should.raise(NoMethodError) end it "is a public method" do - Module.should have_public_instance_method(:attr_accessor, false) + Module.public_instance_methods(false).should.include?(:attr_accessor) end it "returns an array of defined method names as symbols" do @@ -104,7 +104,7 @@ class Integer end it "can read through the accessor" do - 1.foobar.should be_nil + 1.foobar.should == nil end end diff --git a/spec/ruby/core/module/attr_reader_spec.rb b/spec/ruby/core/module/attr_reader_spec.rb index 37fd537ff5c990..2b4ca2100e5545 100644 --- a/spec/ruby/core/module/attr_reader_spec.rb +++ b/spec/ruby/core/module/attr_reader_spec.rb @@ -30,7 +30,7 @@ class TrueClass attr_reader :spec_attr_reader end - -> { true.instance_variable_set("@spec_attr_reader", "a") }.should raise_error(RuntimeError) + -> { true.instance_variable_set("@spec_attr_reader", "a") }.should.raise(RuntimeError) end it "converts non string/symbol names to strings using to_str" do @@ -45,9 +45,9 @@ class TrueClass it "raises a TypeError when the given names can't be converted to strings using to_str" do o = mock('o') - -> { Class.new { attr_reader o } }.should raise_error(TypeError) + -> { Class.new { attr_reader o } }.should.raise(TypeError) (o = mock('123')).should_receive(:to_str).and_return(123) - -> { Class.new { attr_reader o } }.should raise_error(TypeError) + -> { Class.new { attr_reader o } }.should.raise(TypeError) end it "applies current visibility to methods created" do @@ -56,11 +56,11 @@ class TrueClass attr_reader :foo end - -> { c.new.foo }.should raise_error(NoMethodError) + -> { c.new.foo }.should.raise(NoMethodError) end it "is a public method" do - Module.should have_public_instance_method(:attr_reader, false) + Module.public_instance_methods(false).should.include?(:attr_reader) end it "returns an array of defined method names as symbols" do diff --git a/spec/ruby/core/module/attr_spec.rb b/spec/ruby/core/module/attr_spec.rb index 2f9f4e26dc54e6..d69686495582a2 100644 --- a/spec/ruby/core/module/attr_spec.rb +++ b/spec/ruby/core/module/attr_spec.rb @@ -90,8 +90,8 @@ def initialize attr :foo, true end - -> { c.new.foo }.should raise_error(NoMethodError) - -> { c.new.foo=1 }.should raise_error(NoMethodError) + -> { c.new.foo }.should.raise(NoMethodError) + -> { c.new.foo=1 }.should.raise(NoMethodError) end it "creates a getter but no setter for all given attribute names" do @@ -121,8 +121,8 @@ def initialize attr :foo, :bar end - -> { c.new.foo }.should raise_error(NoMethodError) - -> { c.new.bar }.should raise_error(NoMethodError) + -> { c.new.foo }.should.raise(NoMethodError) + -> { c.new.bar }.should.raise(NoMethodError) end it "converts non string/symbol names to strings using to_str" do @@ -132,9 +132,9 @@ def initialize it "raises a TypeError when the given names can't be converted to strings using to_str" do o = mock('o') - -> { Class.new { attr o } }.should raise_error(TypeError) + -> { Class.new { attr o } }.should.raise(TypeError) (o = mock('123')).should_receive(:to_str).and_return(123) - -> { Class.new { attr o } }.should raise_error(TypeError) + -> { Class.new { attr o } }.should.raise(TypeError) end it "with a boolean argument emits a warning when $VERBOSE is true" do @@ -144,7 +144,7 @@ def initialize end it "is a public method" do - Module.should have_public_instance_method(:attr, false) + Module.public_instance_methods(false).should.include?(:attr) end it "returns an array of defined method names as symbols" do diff --git a/spec/ruby/core/module/attr_writer_spec.rb b/spec/ruby/core/module/attr_writer_spec.rb index 5b863ef88c1624..6089b52495bc7e 100644 --- a/spec/ruby/core/module/attr_writer_spec.rb +++ b/spec/ruby/core/module/attr_writer_spec.rb @@ -30,7 +30,7 @@ class TrueClass attr_writer :spec_attr_writer end - -> { true.spec_attr_writer = "a" }.should raise_error(FrozenError) + -> { true.spec_attr_writer = "a" }.should.raise(FrozenError) end it "raises FrozenError if the receiver if frozen" do @@ -40,7 +40,7 @@ class TrueClass obj = c.new obj.freeze - -> { obj.foo = 42 }.should raise_error(FrozenError) + -> { obj.foo = 42 }.should.raise(FrozenError) end it "converts non string/symbol names to strings using to_str" do @@ -55,9 +55,9 @@ class TrueClass it "raises a TypeError when the given names can't be converted to strings using to_str" do o = mock('test1') - -> { Class.new { attr_writer o } }.should raise_error(TypeError) + -> { Class.new { attr_writer o } }.should.raise(TypeError) (o = mock('123')).should_receive(:to_str).and_return(123) - -> { Class.new { attr_writer o } }.should raise_error(TypeError) + -> { Class.new { attr_writer o } }.should.raise(TypeError) end it "applies current visibility to methods created" do @@ -66,11 +66,11 @@ class TrueClass attr_writer :foo end - -> { c.new.foo=1 }.should raise_error(NoMethodError) + -> { c.new.foo=1 }.should.raise(NoMethodError) end it "is a public method" do - Module.should have_public_instance_method(:attr_writer, false) + Module.public_instance_methods(false).should.include?(:attr_writer) end it "returns an array of defined method names as symbols" do diff --git a/spec/ruby/core/module/autoload_relative_spec.rb b/spec/ruby/core/module/autoload_relative_spec.rb index ecbab9b4d56eea..2e7d85496b6b61 100644 --- a/spec/ruby/core/module/autoload_relative_spec.rb +++ b/spec/ruby/core/module/autoload_relative_spec.rb @@ -19,24 +19,24 @@ module AutoloadRelative end it "is a public method" do - Module.should have_public_instance_method(:autoload_relative, false) + Module.public_instance_methods(false).should.include?(:autoload_relative) end it "registers a file to load relative to the current file the first time the named constant is accessed" do ModuleSpecs::Autoload.autoload_relative :AutoloadRelativeA, "fixtures/autoload_relative_a.rb" path = ModuleSpecs::Autoload.autoload?(:AutoloadRelativeA) - path.should_not be_nil + path.should_not == nil path.should.end_with?("autoload_relative_a.rb") - File.exist?(path).should be_true + File.exist?(path).should == true end it "loads the registered file when the constant is accessed" do ModuleSpecs::Autoload.autoload_relative :AutoloadRelativeB, "fixtures/autoload_relative_a.rb" - ModuleSpecs::Autoload::AutoloadRelativeB.should be_kind_of(Module) + ModuleSpecs::Autoload::AutoloadRelativeB.should.is_a?(Module) end it "returns nil" do - ModuleSpecs::Autoload.autoload_relative(:AutoloadRelativeC, "fixtures/autoload_relative_a.rb").should be_nil + ModuleSpecs::Autoload.autoload_relative(:AutoloadRelativeC, "fixtures/autoload_relative_a.rb").should == nil end it "registers a file to load the first time the named constant is accessed" do @@ -44,51 +44,51 @@ module ModuleSpecs::Autoload::AutoloadRelativeTest autoload_relative :D, "fixtures/autoload_relative_a.rb" end path = ModuleSpecs::Autoload::AutoloadRelativeTest.autoload?(:D) - path.should_not be_nil + path.should_not == nil path.should.end_with?("autoload_relative_a.rb") end it "sets the autoload constant in the constants table" do ModuleSpecs::Autoload.autoload_relative :AutoloadRelativeTableTest, "fixtures/autoload_relative_a.rb" - ModuleSpecs::Autoload.should have_constant(:AutoloadRelativeTableTest) + ModuleSpecs::Autoload.should.const_defined?(:AutoloadRelativeTableTest, false) end it "calls #to_path on non-String filenames" do name = mock("autoload_relative mock") name.should_receive(:to_path).and_return("fixtures/autoload_relative_a.rb") ModuleSpecs::Autoload.autoload_relative :AutoloadRelativeToPath, name - ModuleSpecs::Autoload.autoload?(:AutoloadRelativeToPath).should_not be_nil + ModuleSpecs::Autoload.autoload?(:AutoloadRelativeToPath).should_not == nil end it "calls #to_str on non-String filenames" do name = mock("autoload_relative mock") name.should_receive(:to_str).and_return("fixtures/autoload_relative_a.rb") ModuleSpecs::Autoload.autoload_relative :AutoloadRelativeToStr, name - ModuleSpecs::Autoload.autoload?(:AutoloadRelativeToStr).should_not be_nil + ModuleSpecs::Autoload.autoload?(:AutoloadRelativeToStr).should_not == nil end it "raises a TypeError if the filename argument is not a String or pathname" do -> { ModuleSpecs::Autoload.autoload_relative :AutoloadRelativeTypError, nil - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a NameError if the constant name is not valid" do -> { ModuleSpecs::Autoload.autoload_relative :invalid_name, "fixtures/autoload_relative_a.rb" - }.should raise_error(NameError) + }.should.raise(NameError) end it "raises an ArgumentError if the constant name starts with a lowercase letter" do -> { ModuleSpecs::Autoload.autoload_relative :autoload, "fixtures/autoload_relative_a.rb" - }.should raise_error(NameError) + }.should.raise(NameError) end it "raises LoadError if called from eval without file context" do -> { ModuleSpecs::Autoload.module_eval('autoload_relative :EvalTest, "fixtures/autoload_relative_a.rb"') - }.should raise_error(LoadError, /autoload_relative called without file context/) + }.should.raise(LoadError, /autoload_relative called without file context/) end it "can autoload in instance_eval with a file context" do @@ -97,7 +97,7 @@ module ModuleSpecs::Autoload::AutoloadRelativeTest autoload_relative :InstanceEvalTest, "fixtures/autoload_relative_a.rb" path = autoload?(:InstanceEvalTest) CODE - path.should_not be_nil + path.should_not == nil path.should.end_with?("autoload_relative_a.rb") end @@ -112,8 +112,8 @@ module ModuleSpecs::Autoload::AutoloadRelativeTest it "can load nested directory paths" do ModuleSpecs::Autoload.autoload_relative :NestedPath, "fixtures/autoload_relative_a.rb" path = ModuleSpecs::Autoload.autoload?(:NestedPath) - path.should_not be_nil - File.exist?(path).should be_true + path.should_not == nil + File.exist?(path).should == true end describe "interoperability with autoload?" do @@ -121,7 +121,7 @@ module ModuleSpecs::Autoload::AutoloadRelativeTest ModuleSpecs::Autoload.autoload_relative :QueryTest, "fixtures/autoload_relative_a.rb" path = ModuleSpecs::Autoload.autoload?(:QueryTest) # Should be an absolute path - Pathname.new(path).absolute?.should be_true + Pathname.new(path).absolute?.should == true end end end diff --git a/spec/ruby/core/module/autoload_spec.rb b/spec/ruby/core/module/autoload_spec.rb index 87b1d520555cd7..057237a92fd5c0 100644 --- a/spec/ruby/core/module/autoload_spec.rb +++ b/spec/ruby/core/module/autoload_spec.rb @@ -9,7 +9,7 @@ end it "returns nil if no file has been registered for a constant" do - ModuleSpecs::Autoload.autoload?(:Manualload).should be_nil + ModuleSpecs::Autoload.autoload?(:Manualload).should == nil end it "returns the name of the file that will be autoloaded if an ancestor defined that autoload" do @@ -19,7 +19,7 @@ it "returns nil if an ancestor defined that autoload but recursion is disabled" do ModuleSpecs::Autoload::Parent.autoload :InheritedAutoload, "inherited_autoload.rb" - ModuleSpecs::Autoload::Child.autoload?(:InheritedAutoload, false).should be_nil + ModuleSpecs::Autoload::Child.autoload?(:InheritedAutoload, false).should == nil end it "returns the name of the file that will be loaded if recursion is disabled but the autoload is defined on the class itself" do @@ -55,7 +55,7 @@ it "sets the autoload constant in the constants table" do ModuleSpecs::Autoload.autoload :B, @non_existent - ModuleSpecs::Autoload.should have_constant(:B) + ModuleSpecs::Autoload.should.const_defined?(:B, false) end it "can be overridden with a second autoload on the same constant" do @@ -71,7 +71,7 @@ end it "loads the registered constant when it is accessed" do - ModuleSpecs::Autoload.should_not have_constant(:X) + ModuleSpecs::Autoload.should_not.const_defined?(:X) ModuleSpecs::Autoload.autoload :X, fixture(__FILE__, "autoload_x.rb") @remove << :X ModuleSpecs::Autoload::X.should == :x @@ -82,7 +82,7 @@ ModuleSpecs::Autoload::DynClass = cls @remove << :DynClass - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil ModuleSpecs::Autoload::DynClass::C.new.loaded.should == :dynclass_c ScratchPad.recorded.should == :loaded end @@ -92,7 +92,7 @@ ModuleSpecs::Autoload::DynModule = mod @remove << :DynModule - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil ModuleSpecs::Autoload::DynModule::D.new.loaded.should == :dynmodule_d ScratchPad.recorded.should == :loaded end @@ -131,7 +131,7 @@ class ModuleSpecs::Autoload::HClass @remove << :I ModuleSpecs::Autoload.const_set :I, 3 ModuleSpecs::Autoload::I.should == 3 - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "loads a file with .rb extension when passed the name without the extension" do @@ -144,7 +144,7 @@ class ModuleSpecs::Autoload::HClass main = TOPLEVEL_BINDING.eval("self") main.should_receive(:require).with("module_autoload_not_exist.rb") # The constant won't be defined since require is mocked to do nothing - -> { ModuleSpecs::Autoload::ModuleAutoloadCallsRequire }.should raise_error(NameError) + -> { ModuleSpecs::Autoload::ModuleAutoloadCallsRequire }.should.raise(NameError) end it "does not load the file if the file is manually required" do @@ -156,9 +156,9 @@ class ModuleSpecs::Autoload::HClass ScratchPad.recorded.should == :loaded ScratchPad.clear - ModuleSpecs::Autoload::KHash.should be_kind_of(Class) + ModuleSpecs::Autoload::KHash.should.is_a?(Class) ModuleSpecs::Autoload::KHash::K.should == :autoload_k - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "ignores the autoload request if the file is already loaded" do @@ -171,7 +171,7 @@ class ModuleSpecs::Autoload::HClass ModuleSpecs::Autoload.autoload :S, filename @remove << :S - ModuleSpecs::Autoload.autoload?(:S).should be_nil + ModuleSpecs::Autoload.autoload?(:S).should == nil end it "retains the autoload even if the request to require fails" do @@ -182,7 +182,7 @@ class ModuleSpecs::Autoload::HClass -> { require filename - }.should raise_error(LoadError) + }.should.raise(LoadError) ModuleSpecs::Autoload.autoload?(:NotThere).should == filename end @@ -205,7 +205,7 @@ class ModuleSpecs::Autoload::HClass filename = fixture(__FILE__, "autoload_during_require_current_file.rb") require filename - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end describe "interacting with defined?" do @@ -215,9 +215,9 @@ module ModuleSpecs::Autoload::Dog end defined?(ModuleSpecs::Autoload::Dog::R).should == "constant" - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil - ModuleSpecs::Autoload::Dog.should have_constant(:R) + ModuleSpecs::Autoload::Dog.should.const_defined?(:R, false) end it "loads an autoloaded parent when referencing a nested constant" do @@ -235,7 +235,7 @@ module ModuleSpecs::Autoload autoload :BadParent, fixture(__FILE__, "autoload_exception.rb") end - defined?(ModuleSpecs::Autoload::BadParent::Nested).should be_nil + defined?(ModuleSpecs::Autoload::BadParent::Nested).should == nil ScratchPad.recorded.should == :exception end end @@ -454,16 +454,16 @@ def check_before_during_thread_after(const, &check) ModuleSpecs::Autoload.autoload :Fail, @non_existent ModuleSpecs::Autoload.const_defined?(:Fail).should == true - ModuleSpecs::Autoload.should have_constant(:Fail) + ModuleSpecs::Autoload.should.const_defined?(:Fail, false) ModuleSpecs::Autoload.autoload?(:Fail).should == @non_existent - -> { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError) + -> { ModuleSpecs::Autoload::Fail }.should.raise(LoadError) - ModuleSpecs::Autoload.should have_constant(:Fail) + ModuleSpecs::Autoload.should.const_defined?(:Fail, false) ModuleSpecs::Autoload.const_defined?(:Fail).should == true ModuleSpecs::Autoload.autoload?(:Fail).should == @non_existent - -> { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError) + -> { ModuleSpecs::Autoload::Fail }.should.raise(LoadError) end it "does not remove the constant from Module#constants if load raises a RuntimeError and keeps it as an autoload" do @@ -472,17 +472,17 @@ def check_before_during_thread_after(const, &check) ModuleSpecs::Autoload.autoload :Raise, path ModuleSpecs::Autoload.const_defined?(:Raise).should == true - ModuleSpecs::Autoload.should have_constant(:Raise) + ModuleSpecs::Autoload.should.const_defined?(:Raise, false) ModuleSpecs::Autoload.autoload?(:Raise).should == path - -> { ModuleSpecs::Autoload::Raise }.should raise_error(RuntimeError) + -> { ModuleSpecs::Autoload::Raise }.should.raise(RuntimeError) ScratchPad.recorded.should == [:raise] - ModuleSpecs::Autoload.should have_constant(:Raise) + ModuleSpecs::Autoload.should.const_defined?(:Raise, false) ModuleSpecs::Autoload.const_defined?(:Raise).should == true ModuleSpecs::Autoload.autoload?(:Raise).should == path - -> { ModuleSpecs::Autoload::Raise }.should raise_error(RuntimeError) + -> { ModuleSpecs::Autoload::Raise }.should.raise(RuntimeError) ScratchPad.recorded.should == [:raise, :raise] end @@ -492,15 +492,15 @@ def check_before_during_thread_after(const, &check) ModuleSpecs::Autoload.autoload :O, path ModuleSpecs::Autoload.const_defined?(:O).should == true - ModuleSpecs::Autoload.should have_constant(:O) + ModuleSpecs::Autoload.should.const_defined?(:O, false) ModuleSpecs::Autoload.autoload?(:O).should == path - -> { ModuleSpecs::Autoload::O }.should raise_error(NameError) + -> { ModuleSpecs::Autoload::O }.should.raise(NameError) ModuleSpecs::Autoload.const_defined?(:O).should == false - ModuleSpecs::Autoload.should_not have_constant(:O) + ModuleSpecs::Autoload.should_not.const_defined?(:O) ModuleSpecs::Autoload.autoload?(:O).should == nil - -> { ModuleSpecs::Autoload.const_get(:O) }.should raise_error(NameError) + -> { ModuleSpecs::Autoload.const_get(:O) }.should.raise(NameError) end it "does not try to load the file again if the loaded file did not define the constant" do @@ -508,13 +508,13 @@ def check_before_during_thread_after(const, &check) ScratchPad.record [] ModuleSpecs::Autoload.autoload :NotDefinedByFile, path - -> { ModuleSpecs::Autoload::NotDefinedByFile }.should raise_error(NameError) + -> { ModuleSpecs::Autoload::NotDefinedByFile }.should.raise(NameError) ScratchPad.recorded.should == [:loaded] - -> { ModuleSpecs::Autoload::NotDefinedByFile }.should raise_error(NameError) + -> { ModuleSpecs::Autoload::NotDefinedByFile }.should.raise(NameError) ScratchPad.recorded.should == [:loaded] Thread.new { - -> { ModuleSpecs::Autoload::NotDefinedByFile }.should raise_error(NameError) + -> { ModuleSpecs::Autoload::NotDefinedByFile }.should.raise(NameError) }.join ScratchPad.recorded.should == [:loaded] end @@ -524,7 +524,7 @@ module ModuleSpecs::Autoload::Q autoload :R, fixture(__FILE__, "autoload.rb") defined?(R).should == 'constant' end - ModuleSpecs::Autoload::Q.should have_constant(:R) + ModuleSpecs::Autoload::Q.should.const_defined?(:R, false) end it "does not load the file when removing an autoload constant" do @@ -532,13 +532,13 @@ module ModuleSpecs::Autoload::Q autoload :R, fixture(__FILE__, "autoload.rb") remove_const :R end - ModuleSpecs::Autoload::Q.should_not have_constant(:R) + ModuleSpecs::Autoload::Q.should_not.const_defined?(:R) end it "does not load the file when accessing the constants table of the module" do ModuleSpecs::Autoload.autoload :P, @non_existent - ModuleSpecs::Autoload.const_defined?(:P).should be_true - ModuleSpecs::Autoload.const_defined?("P").should be_true + ModuleSpecs::Autoload.const_defined?(:P).should == true + ModuleSpecs::Autoload.const_defined?("P").should == true end it "loads the file when opening a module that is the autoloaded constant" do @@ -573,8 +573,8 @@ class LexicalScope DeclaredAndDefinedInParent.should == :declared_and_defined_in_parent # The constant is really in Autoload, not Autoload::LexicalScope - self.should_not have_constant(:DeclaredAndDefinedInParent) - -> { const_get(:DeclaredAndDefinedInParent) }.should raise_error(NameError) + self.should_not.const_defined?(:DeclaredAndDefinedInParent) + -> { const_get(:DeclaredAndDefinedInParent) }.should.raise(NameError) end DeclaredAndDefinedInParent.should == :declared_and_defined_in_parent end @@ -597,7 +597,7 @@ class LexicalScope # Basically, the parent autoload constant remains in a "undefined" state self.autoload?(:DeclaredInParentDefinedInCurrent).should == nil const_defined?(:DeclaredInParentDefinedInCurrent).should == false - -> { DeclaredInParentDefinedInCurrent }.should raise_error(NameError) + -> { DeclaredInParentDefinedInCurrent }.should.raise(NameError) ModuleSpecs::Autoload::LexicalScope.send(:remove_const, :DeclaredInParentDefinedInCurrent) end @@ -640,11 +640,11 @@ module ModuleSpecs::Autoload class LexicalScope autoload :DeclaredInCurrentDefinedInParent, fixture(__FILE__, "autoload_callback.rb") - -> { DeclaredInCurrentDefinedInParent }.should_not raise_error(NameError) + -> { DeclaredInCurrentDefinedInParent }.should_not.raise(NameError) # Basically, the autoload constant remains in a "undefined" state self.autoload?(:DeclaredInCurrentDefinedInParent).should == nil const_defined?(:DeclaredInCurrentDefinedInParent).should == false - -> { const_get(:DeclaredInCurrentDefinedInParent) }.should raise_error(NameError) + -> { const_get(:DeclaredInCurrentDefinedInParent) }.should.raise(NameError) end DeclaredInCurrentDefinedInParent.should == :declared_in_current_defined_in_parent @@ -714,7 +714,7 @@ def r end end end - ModuleSpecs::Autoload.r.should be_kind_of(ModuleSpecs::Autoload::MetaScope) + ModuleSpecs::Autoload.r.should.is_a?(ModuleSpecs::Autoload::MetaScope) end end @@ -724,13 +724,13 @@ module ModuleSpecs::Autoload autoload :DynClass, fixture(__FILE__, "autoload_c.rb") private_constant :DynClass - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil DynClass::C.new.loaded.should == :dynclass_c ScratchPad.recorded.should == :loaded end - -> { ModuleSpecs::Autoload::DynClass }.should raise_error(NameError, /private constant/) + -> { ModuleSpecs::Autoload::DynClass }.should.raise(NameError, /private constant/) end # [ruby-core:19127] [ruby-core:29941] @@ -745,7 +745,7 @@ class Y end @remove << :W - ModuleSpecs::Autoload::W::Y.should be_kind_of(Class) + ModuleSpecs::Autoload::W::Y.should.is_a?(Class) ScratchPad.recorded.should == :loaded end @@ -760,7 +760,7 @@ module ModuleSpecs::Autoload -> { Kernel.require fixture(__FILE__, "autoload_during_require.rb") }.should_not complain(verbose: true) - ModuleSpecs::Autoload::AutoloadDuringRequire.should be_kind_of(Class) + ModuleSpecs::Autoload::AutoloadDuringRequire.should.is_a?(Class) end it "does not call #require a second time and does not warn if feature sets and trigger autoload on itself" do @@ -770,15 +770,15 @@ module ModuleSpecs::Autoload -> { Kernel.require fixture(__FILE__, "autoload_self_during_require.rb") }.should_not complain(verbose: true) - ModuleSpecs::Autoload::AutoloadSelfDuringRequire.should be_kind_of(Class) + ModuleSpecs::Autoload::AutoloadSelfDuringRequire.should.is_a?(Class) end it "handles multiple autoloads in the same file" do $LOAD_PATH.unshift(File.expand_path('../fixtures/multi', __FILE__)) begin require 'foo/bar_baz' - ModuleSpecs::Autoload::Foo::Bar.should be_kind_of(Class) - ModuleSpecs::Autoload::Foo::Baz.should be_kind_of(Class) + ModuleSpecs::Autoload::Foo::Bar.should.is_a?(Class) + ModuleSpecs::Autoload::Foo::Baz.should.is_a?(Class) ensure $LOAD_PATH.shift end @@ -791,19 +791,19 @@ module ModuleSpecs::Autoload end it "raises an ArgumentError when an empty filename is given" do - -> { ModuleSpecs.autoload :A, "" }.should raise_error(ArgumentError) + -> { ModuleSpecs.autoload :A, "" }.should.raise(ArgumentError) end it "raises a NameError when the constant name starts with a lower case letter" do - -> { ModuleSpecs.autoload "a", @non_existent }.should raise_error(NameError) + -> { ModuleSpecs.autoload "a", @non_existent }.should.raise(NameError) end it "raises a NameError when the constant name starts with a number" do - -> { ModuleSpecs.autoload "1two", @non_existent }.should raise_error(NameError) + -> { ModuleSpecs.autoload "1two", @non_existent }.should.raise(NameError) end it "raises a NameError when the constant name has a space in it" do - -> { ModuleSpecs.autoload "a name", @non_existent }.should raise_error(NameError) + -> { ModuleSpecs.autoload "a name", @non_existent }.should.raise(NameError) end it "shares the autoload request across dup'ed copies of modules" do @@ -820,7 +820,7 @@ module ModuleSpecs::Autoload mod2.autoload?(:T).should == filename mod1::T.should == :autoload_t - -> { mod2::T }.should raise_error(NameError) + -> { mod2::T }.should.raise(NameError) end it "raises a TypeError if opening a class with a different superclass than the class defined in the autoload file" do @@ -831,27 +831,27 @@ class ModuleSpecs::Autoload::ZZ -> do class ModuleSpecs::Autoload::Z < ModuleSpecs::Autoload::ZZ end - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if not passed a String or object responding to #to_path for the filename" do name = mock("autoload_name.rb") - -> { ModuleSpecs::Autoload.autoload :Str, name }.should raise_error(TypeError) + -> { ModuleSpecs::Autoload.autoload :Str, name }.should.raise(TypeError) end it "calls #to_path on non-String filename arguments" do name = mock("autoload_name.rb") name.should_receive(:to_path).and_return("autoload_name.rb") - -> { ModuleSpecs::Autoload.autoload :Str, name }.should_not raise_error + -> { ModuleSpecs::Autoload.autoload :Str, name }.should_not.raise end describe "on a frozen module" do it "raises a FrozenError before setting the name" do frozen_module = Module.new.freeze - -> { frozen_module.autoload :Foo, @non_existent }.should raise_error(FrozenError) - frozen_module.should_not have_constant(:Foo) + -> { frozen_module.autoload :Foo, @non_existent }.should.raise(FrozenError) + frozen_module.should_not.const_defined?(:Foo) end end @@ -916,7 +916,7 @@ class ModuleSpecs::Autoload::Z < ModuleSpecs::Autoload::ZZ t1_val.should == 1 t2_val.should == t1_val - t2_exc.should be_nil + t2_exc.should == nil end # https://bugs.ruby-lang.org/issues/10892 @@ -957,7 +957,7 @@ class ModuleSpecs::Autoload::Z < ModuleSpecs::Autoload::ZZ end # check that no thread got a NameError or NoMethodError because of partially loaded module - threads.all? {|t| t.value}.should be_true + threads.all? {|t| t.value}.should == true # check that the autoloaded file was evaled exactly once ScratchPad.recorded.get.should == mod_count @@ -990,7 +990,7 @@ class ModuleSpecs::Autoload::Z < ModuleSpecs::Autoload::ZZ start = true threads.each { |t| - t.value.should be_an_instance_of(NameError) + t.value.should.instance_of?(NameError) } end @@ -1015,7 +1015,7 @@ class ModuleSpecs::Autoload::Z < ModuleSpecs::Autoload::ZZ start = true threads.each { |t| - t.value.should be_an_instance_of(LoadError) + t.value.should.instance_of?(LoadError) } end end diff --git a/spec/ruby/core/module/class_variable_defined_spec.rb b/spec/ruby/core/module/class_variable_defined_spec.rb index c0f2072a3717f6..dedce9589aaee4 100644 --- a/spec/ruby/core/module/class_variable_defined_spec.rb +++ b/spec/ruby/core/module/class_variable_defined_spec.rb @@ -19,13 +19,13 @@ obj = mock("metaclass class variable") meta = obj.singleton_class meta.send :class_variable_set, :@@var, 1 - meta.send(:class_variable_defined?, :@@var).should be_true + meta.send(:class_variable_defined?, :@@var).should == true end it "returns false if the class variable is not defined in a metaclass" do obj = mock("metaclass class variable") meta = obj.singleton_class - meta.class_variable_defined?(:@@var).should be_false + meta.class_variable_defined?(:@@var).should == false end it "returns true if a class variables with the given name is defined in an included module" do @@ -44,11 +44,11 @@ -> { c.class_variable_defined?(:invalid_name) - }.should raise_error(NameError) + }.should.raise(NameError) -> { c.class_variable_defined?("@invalid_name") - }.should raise_error(NameError) + }.should.raise(NameError) end it "converts a non string/symbol name to string using to_str" do @@ -62,11 +62,11 @@ o = mock('123') -> { c.class_variable_defined?(o) - }.should raise_error(TypeError) + }.should.raise(TypeError) o.should_receive(:to_str).and_return(123) -> { c.class_variable_defined?(o) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end diff --git a/spec/ruby/core/module/class_variable_get_spec.rb b/spec/ruby/core/module/class_variable_get_spec.rb index e5d06731ec4beb..13f06cb94ad63c 100644 --- a/spec/ruby/core/module/class_variable_get_spec.rb +++ b/spec/ruby/core/module/class_variable_get_spec.rb @@ -15,8 +15,8 @@ it "raises a NameError for a class variable named '@@'" do c = Class.new - -> { c.send(:class_variable_get, "@@") }.should raise_error(NameError) - -> { c.send(:class_variable_get, :"@@") }.should raise_error(NameError) + -> { c.send(:class_variable_get, "@@") }.should.raise(NameError) + -> { c.send(:class_variable_get, :"@@") }.should.raise(NameError) end it "raises a NameError for a class variables with the given name defined in an extended module" do @@ -24,7 +24,7 @@ c.extend ModuleSpecs::MVars -> { c.send(:class_variable_get, "@@mvar") - }.should raise_error(NameError) + }.should.raise(NameError) end it "returns class variables defined in the class body and accessed in the metaclass" do @@ -49,15 +49,15 @@ it "raises a NameError when an uninitialized class variable is accessed" do c = Class.new [:@@no_class_var, "@@no_class_var"].each do |cvar| - -> { c.send(:class_variable_get, cvar) }.should raise_error(NameError) + -> { c.send(:class_variable_get, cvar) }.should.raise(NameError) end end it "raises a NameError when the given name is not allowed" do c = Class.new - -> { c.send(:class_variable_get, :invalid_name) }.should raise_error(NameError) - -> { c.send(:class_variable_get, "@invalid_name") }.should raise_error(NameError) + -> { c.send(:class_variable_get, :invalid_name) }.should.raise(NameError) + -> { c.send(:class_variable_get, "@invalid_name") }.should.raise(NameError) end it "converts a non string/symbol name to string using to_str" do @@ -69,8 +69,8 @@ it "raises a TypeError when the given names can't be converted to strings using to_str" do c = Class.new { class_variable_set :@@class_var, "test" } o = mock('123') - -> { c.send(:class_variable_get, o) }.should raise_error(TypeError) + -> { c.send(:class_variable_get, o) }.should.raise(TypeError) o.should_receive(:to_str).and_return(123) - -> { c.send(:class_variable_get, o) }.should raise_error(TypeError) + -> { c.send(:class_variable_get, o) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/module/class_variable_set_spec.rb b/spec/ruby/core/module/class_variable_set_spec.rb index 63f32f5389d6d5..a3d759767b05eb 100644 --- a/spec/ruby/core/module/class_variable_set_spec.rb +++ b/spec/ruby/core/module/class_variable_set_spec.rb @@ -28,10 +28,10 @@ it "raises a FrozenError when self is frozen" do -> { Class.new.freeze.send(:class_variable_set, :@@test, "test") - }.should raise_error(FrozenError) + }.should.raise(FrozenError) -> { Module.new.freeze.send(:class_variable_set, :@@test, "test") - }.should raise_error(FrozenError) + }.should.raise(FrozenError) end it "raises a NameError when the given name is not allowed" do @@ -39,10 +39,10 @@ -> { c.send(:class_variable_set, :invalid_name, "test") - }.should raise_error(NameError) + }.should.raise(NameError) -> { c.send(:class_variable_set, "@invalid_name", "test") - }.should raise_error(NameError) + }.should.raise(NameError) end it "converts a non string/symbol name to string using to_str" do @@ -55,8 +55,8 @@ it "raises a TypeError when the given names can't be converted to strings using to_str" do c = Class.new { class_variable_set :@@class_var, "test" } o = mock('123') - -> { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError) + -> { c.send(:class_variable_set, o, "test") }.should.raise(TypeError) o.should_receive(:to_str).and_return(123) - -> { c.send(:class_variable_set, o, "test") }.should raise_error(TypeError) + -> { c.send(:class_variable_set, o, "test") }.should.raise(TypeError) end end diff --git a/spec/ruby/core/module/class_variables_spec.rb b/spec/ruby/core/module/class_variables_spec.rb index e155f1deac25d3..9529df48aecad4 100644 --- a/spec/ruby/core/module/class_variables_spec.rb +++ b/spec/ruby/core/module/class_variables_spec.rb @@ -3,8 +3,8 @@ describe "Module#class_variables" do it "returns an Array with the names of class variables of self" do - ModuleSpecs::ClassVars::A.class_variables.should include(:@@a_cvar) - ModuleSpecs::ClassVars::M.class_variables.should include(:@@m_cvar) + ModuleSpecs::ClassVars::A.class_variables.should.include?(:@@a_cvar) + ModuleSpecs::ClassVars::M.class_variables.should.include?(:@@m_cvar) end it "returns an Array of Symbols of class variable names defined in a metaclass" do @@ -15,13 +15,13 @@ end it "returns an Array with names of class variables defined in metaclasses" do - ModuleSpecs::CVars.class_variables.should include(:@@cls, :@@meta) + ModuleSpecs::CVars.class_variables.to_set.should >= Set[:@@cls, :@@meta] end it "does not return class variables defined in extended modules" do c = Class.new c.extend ModuleSpecs::MVars - c.class_variables.should_not include(:@@mvar) + c.class_variables.should_not.include?(:@@mvar) end it "returns the correct class variables when inherit is given" do diff --git a/spec/ruby/core/module/const_added_spec.rb b/spec/ruby/core/module/const_added_spec.rb index 90cd36551aa7b7..b60af7a2e818af 100644 --- a/spec/ruby/core/module/const_added_spec.rb +++ b/spec/ruby/core/module/const_added_spec.rb @@ -4,7 +4,7 @@ describe "Module#const_added" do it "is a private instance method" do - Module.should have_private_instance_method(:const_added) + Module.private_instance_methods(false).should.include?(:const_added) end it "returns nil in the default implementation" do diff --git a/spec/ruby/core/module/const_defined_spec.rb b/spec/ruby/core/module/const_defined_spec.rb index 8b137cd1340c50..9d973c2b2b1394 100644 --- a/spec/ruby/core/module/const_defined_spec.rb +++ b/spec/ruby/core/module/const_defined_spec.rb @@ -14,40 +14,40 @@ it "returns true if the constant is defined in the receiver's superclass" do # CS_CONST4 is defined in the superclass of ChildA - ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4).should be_true + ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4).should == true end it "returns true if the constant is defined in a mixed-in module of the receiver's parent" do # CS_CONST10 is defined in a module included by ChildA - ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST10).should be_true + ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST10).should == true end it "returns true if the constant is defined in a mixed-in module (with prepends) of the receiver" do # CS_CONST11 is defined in the module included by ContainerPrepend - ConstantSpecs::ContainerPrepend.const_defined?(:CS_CONST11).should be_true + ConstantSpecs::ContainerPrepend.const_defined?(:CS_CONST11).should == true end it "returns true if the constant is defined in Object and the receiver is a module" do # CS_CONST1 is defined in Object - ConstantSpecs::ModuleA.const_defined?(:CS_CONST1).should be_true + ConstantSpecs::ModuleA.const_defined?(:CS_CONST1).should == true end it "returns true if the constant is defined in Object and the receiver is a class that has Object among its ancestors" do # CS_CONST1 is defined in Object - ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST1).should be_true + ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST1).should == true end it "returns false if the constant is defined in the receiver's superclass and the inherit flag is false" do - ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4, false).should be_false + ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4, false).should == false end it "returns true if the constant is defined in the receiver's superclass and the inherit flag is true" do - ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4, true).should be_true + ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4, true).should == true end it "coerces the inherit flag to a boolean" do - ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4, nil).should be_false - ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4, :true).should be_true + ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4, nil).should == false + ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4, :true).should == true end it "returns true if the given String names a constant defined in the receiver" do @@ -58,23 +58,23 @@ end it "returns true when passed a constant name with unicode characters" do - ConstantUnicodeSpecs.const_defined?("CS_CONSTλ").should be_true + ConstantUnicodeSpecs.const_defined?("CS_CONSTλ").should == true end it "returns true when passed a constant name with EUC-JP characters" do str = "CS_CONSTλ".encode("euc-jp") ConstantSpecs.const_set str, 1 - ConstantSpecs.const_defined?(str).should be_true + ConstantSpecs.const_defined?(str).should == true ensure ConstantSpecs.send(:remove_const, str) end it "returns false if the constant is not defined in the receiver, its superclass, or any included modules" do # The following constant isn't defined at all. - ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4726).should be_false + ConstantSpecs::ContainerA::ChildA.const_defined?(:CS_CONST4726).should == false # DETACHED_CONSTANT is defined in ConstantSpecs::Detached, which isn't # included by or inherited from ParentA - ConstantSpecs::ParentA.const_defined?(:DETACHED_CONSTANT).should be_false + ConstantSpecs::ParentA.const_defined?(:DETACHED_CONSTANT).should == false end it "does not call #const_missing if the constant is not defined in the receiver" do @@ -90,59 +90,59 @@ end it "raises a TypeError if the given name can't be converted to a String" do - -> { ConstantSpecs.const_defined?(nil) }.should raise_error(TypeError) - -> { ConstantSpecs.const_defined?([]) }.should raise_error(TypeError) + -> { ConstantSpecs.const_defined?(nil) }.should.raise(TypeError) + -> { ConstantSpecs.const_defined?([]) }.should.raise(TypeError) end it "raises a NoMethodError if the given argument raises a NoMethodError during type coercion to a String" do name = mock("classA") name.should_receive(:to_str).and_raise(NoMethodError) - -> { ConstantSpecs.const_defined?(name) }.should raise_error(NoMethodError) + -> { ConstantSpecs.const_defined?(name) }.should.raise(NoMethodError) end end it "special cases Object and checks it's included Modules" do - Object.const_defined?(:CS_CONST10).should be_true + Object.const_defined?(:CS_CONST10).should == true end it "returns true for toplevel constant when the name begins with '::'" do - ConstantSpecs.const_defined?("::Array").should be_true + ConstantSpecs.const_defined?("::Array").should == true end it "returns true when passed a scoped constant name" do - ConstantSpecs.const_defined?("ClassC::CS_CONST1").should be_true + ConstantSpecs.const_defined?("ClassC::CS_CONST1").should == true end it "returns true when passed a scoped constant name for a constant in the inheritance hierarchy and the inherited flag is default" do - ConstantSpecs::ClassD.const_defined?("ClassE::CS_CONST2").should be_true + ConstantSpecs::ClassD.const_defined?("ClassE::CS_CONST2").should == true end it "returns true when passed a scoped constant name for a constant in the inheritance hierarchy and the inherited flag is true" do - ConstantSpecs::ClassD.const_defined?("ClassE::CS_CONST2", true).should be_true + ConstantSpecs::ClassD.const_defined?("ClassE::CS_CONST2", true).should == true end it "returns false when passed a scoped constant name for a constant in the inheritance hierarchy and the inherited flag is false" do - ConstantSpecs::ClassD.const_defined?("ClassE::CS_CONST2", false).should be_false + ConstantSpecs::ClassD.const_defined?("ClassE::CS_CONST2", false).should == false end it "returns false when the name begins with '::' and the toplevel constant does not exist" do - ConstantSpecs.const_defined?("::Name").should be_false + ConstantSpecs.const_defined?("::Name").should == false end it "raises a NameError if the name does not start with a capital letter" do - -> { ConstantSpecs.const_defined? "name" }.should raise_error(NameError) + -> { ConstantSpecs.const_defined? "name" }.should.raise(NameError) end it "raises a NameError if the name starts with '_'" do - -> { ConstantSpecs.const_defined? "__CONSTX__" }.should raise_error(NameError) + -> { ConstantSpecs.const_defined? "__CONSTX__" }.should.raise(NameError) end it "raises a NameError if the name starts with '@'" do - -> { ConstantSpecs.const_defined? "@Name" }.should raise_error(NameError) + -> { ConstantSpecs.const_defined? "@Name" }.should.raise(NameError) end it "raises a NameError if the name starts with '!'" do - -> { ConstantSpecs.const_defined? "!Name" }.should raise_error(NameError) + -> { ConstantSpecs.const_defined? "!Name" }.should.raise(NameError) end it "returns true or false for the nested name" do @@ -155,15 +155,15 @@ it "raises a NameError if the name contains non-alphabetic characters except '_'" do ConstantSpecs.const_defined?("CS_CONSTX").should == false - -> { ConstantSpecs.const_defined? "Name=" }.should raise_error(NameError) - -> { ConstantSpecs.const_defined? "Name?" }.should raise_error(NameError) + -> { ConstantSpecs.const_defined? "Name=" }.should.raise(NameError) + -> { ConstantSpecs.const_defined? "Name?" }.should.raise(NameError) end it "raises a TypeError if conversion to a String by calling #to_str fails" do name = mock('123') - -> { ConstantSpecs.const_defined? name }.should raise_error(TypeError) + -> { ConstantSpecs.const_defined? name }.should.raise(TypeError) name.should_receive(:to_str).and_return(123) - -> { ConstantSpecs.const_defined? name }.should raise_error(TypeError) + -> { ConstantSpecs.const_defined? name }.should.raise(TypeError) end end diff --git a/spec/ruby/core/module/const_get_spec.rb b/spec/ruby/core/module/const_get_spec.rb index 4b53cbe7b3fe4e..68b5594faa6f17 100644 --- a/spec/ruby/core/module/const_get_spec.rb +++ b/spec/ruby/core/module/const_get_spec.rb @@ -9,28 +9,28 @@ end it "raises a NameError if no constant is defined in the search path" do - -> { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError) + -> { ConstantSpecs.const_get :CS_CONSTX }.should.raise(NameError) end it "raises a NameError with the not found constant symbol" do error_inspection = -> e { e.name.should == :CS_CONSTX } - -> { ConstantSpecs.const_get :CS_CONSTX }.should raise_error(NameError, &error_inspection) + -> { ConstantSpecs.const_get :CS_CONSTX }.should.raise(NameError, &error_inspection) end it "raises a NameError if the name does not start with a capital letter" do - -> { ConstantSpecs.const_get "name" }.should raise_error(NameError) + -> { ConstantSpecs.const_get "name" }.should.raise(NameError) end it "raises a NameError if the name starts with a non-alphabetic character" do - -> { ConstantSpecs.const_get "__CONSTX__" }.should raise_error(NameError) - -> { ConstantSpecs.const_get "@CS_CONST1" }.should raise_error(NameError) - -> { ConstantSpecs.const_get "!CS_CONST1" }.should raise_error(NameError) + -> { ConstantSpecs.const_get "__CONSTX__" }.should.raise(NameError) + -> { ConstantSpecs.const_get "@CS_CONST1" }.should.raise(NameError) + -> { ConstantSpecs.const_get "!CS_CONST1" }.should.raise(NameError) end it "raises a NameError if the name contains non-alphabetic characters except '_'" do Object.const_get("CS_CONST1").should == :const1 - -> { ConstantSpecs.const_get "CS_CONST1=" }.should raise_error(NameError) - -> { ConstantSpecs.const_get "CS_CONST1?" }.should raise_error(NameError) + -> { ConstantSpecs.const_get "CS_CONST1=" }.should.raise(NameError) + -> { ConstantSpecs.const_get "CS_CONST1?" }.should.raise(NameError) end it "calls #to_str to convert the given name to a String" do @@ -41,10 +41,10 @@ it "raises a TypeError if conversion to a String by calling #to_str fails" do name = mock('123') - -> { ConstantSpecs.const_get(name) }.should raise_error(TypeError) + -> { ConstantSpecs.const_get(name) }.should.raise(TypeError) name.should_receive(:to_str).and_return(123) - -> { ConstantSpecs.const_get(name) }.should raise_error(TypeError) + -> { ConstantSpecs.const_get(name) }.should.raise(TypeError) end it "calls #const_missing on the receiver if unable to locate the constant" do @@ -55,21 +55,21 @@ it "does not search the singleton class of a Class or Module" do -> do ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST14) - end.should raise_error(NameError) - -> { ConstantSpecs.const_get(:CS_CONST14) }.should raise_error(NameError) + end.should.raise(NameError) + -> { ConstantSpecs.const_get(:CS_CONST14) }.should.raise(NameError) end it "does not search the containing scope" do ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST20).should == :const20_2 -> do ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST5) - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError if the constant is defined in the receiver's superclass and the inherit flag is false" do -> do ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST4, false) - end.should raise_error(NameError) + end.should.raise(NameError) end it "searches into the receiver superclasses if the inherit flag is true" do @@ -79,13 +79,13 @@ it "raises a NameError when the receiver is a Module, the constant is defined at toplevel and the inherit flag is false" do -> do ConstantSpecs::ModuleA.const_get(:CS_CONST1, false) - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError when the receiver is a Class, the constant is defined at toplevel and the inherit flag is false" do -> do ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST1, false) - end.should raise_error(NameError) + end.should.raise(NameError) end it "coerces the inherit flag to a boolean" do @@ -93,7 +93,7 @@ -> do ConstantSpecs::ContainerA::ChildA.const_get(:CS_CONST1, nil) - end.should raise_error(NameError) + end.should.raise(NameError) end it "accepts a toplevel scope qualifier" do @@ -102,7 +102,7 @@ it "accepts a toplevel scope qualifier when inherit is false" do ConstantSpecs.const_get("::CS_CONST1", false).should == :const1 - -> { ConstantSpecs.const_get("CS_CONST1", false) }.should raise_error(NameError) + -> { ConstantSpecs.const_get("CS_CONST1", false) }.should.raise(NameError) end it "returns a constant whose module is defined the toplevel" do @@ -115,19 +115,19 @@ end it "raises a NameError if the name includes two successive scope separators" do - -> { ConstantSpecs.const_get("ClassA::::CS_CONST10") }.should raise_error(NameError) + -> { ConstantSpecs.const_get("ClassA::::CS_CONST10") }.should.raise(NameError) end it "raises a NameError if only '::' is passed" do - -> { ConstantSpecs.const_get("::") }.should raise_error(NameError) + -> { ConstantSpecs.const_get("::") }.should.raise(NameError) end it "raises a NameError if a Symbol has a toplevel scope qualifier" do - -> { ConstantSpecs.const_get(:'::CS_CONST1') }.should raise_error(NameError) + -> { ConstantSpecs.const_get(:'::CS_CONST1') }.should.raise(NameError) end it "raises a NameError if a Symbol is a scoped constant name" do - -> { ConstantSpecs.const_get(:'ClassA::CS_CONST10') }.should raise_error(NameError) + -> { ConstantSpecs.const_get(:'ClassA::CS_CONST10') }.should.raise(NameError) end it "does read private constants" do @@ -151,7 +151,7 @@ end it "raises a NameError when the nested constant does not exist on the module but exists in Object" do - -> { Object.const_get('ConstantSpecs::CS_CONST1') }.should raise_error(NameError) + -> { Object.const_get('ConstantSpecs::CS_CONST1') }.should.raise(NameError) end describe "with statically assigned constants" do diff --git a/spec/ruby/core/module/const_missing_spec.rb b/spec/ruby/core/module/const_missing_spec.rb index 742218281c7098..80a2caccabdca3 100644 --- a/spec/ruby/core/module/const_missing_spec.rb +++ b/spec/ruby/core/module/const_missing_spec.rb @@ -13,7 +13,7 @@ it "raises NameError and includes the name of the value that wasn't found" do -> { ConstantSpecs.const_missing("HelloMissing") - }.should raise_error(NameError, /ConstantSpecs::HelloMissing/) + }.should.raise(NameError, /ConstantSpecs::HelloMissing/) end it "raises NameError and does not include toplevel Object" do diff --git a/spec/ruby/core/module/const_set_spec.rb b/spec/ruby/core/module/const_set_spec.rb index 823768b882a74b..aa3c6bbcfc4504 100644 --- a/spec/ruby/core/module/const_set_spec.rb +++ b/spec/ruby/core/module/const_set_spec.rb @@ -50,20 +50,20 @@ end it "raises a NameError if the name does not start with a capital letter" do - -> { ConstantSpecs.const_set "name", 1 }.should raise_error(NameError) + -> { ConstantSpecs.const_set "name", 1 }.should.raise(NameError) end it "raises a NameError if the name starts with a non-alphabetic character" do - -> { ConstantSpecs.const_set "__CONSTX__", 1 }.should raise_error(NameError) - -> { ConstantSpecs.const_set "@Name", 1 }.should raise_error(NameError) - -> { ConstantSpecs.const_set "!Name", 1 }.should raise_error(NameError) - -> { ConstantSpecs.const_set "::Name", 1 }.should raise_error(NameError) + -> { ConstantSpecs.const_set "__CONSTX__", 1 }.should.raise(NameError) + -> { ConstantSpecs.const_set "@Name", 1 }.should.raise(NameError) + -> { ConstantSpecs.const_set "!Name", 1 }.should.raise(NameError) + -> { ConstantSpecs.const_set "::Name", 1 }.should.raise(NameError) end it "raises a NameError if the name contains non-alphabetic characters except '_'" do ConstantSpecs.const_set("CS_CONST404", :const404).should == :const404 - -> { ConstantSpecs.const_set "Name=", 1 }.should raise_error(NameError) - -> { ConstantSpecs.const_set "Name?", 1 }.should raise_error(NameError) + -> { ConstantSpecs.const_set "Name=", 1 }.should.raise(NameError) + -> { ConstantSpecs.const_set "Name?", 1 }.should.raise(NameError) ensure ConstantSpecs.send(:remove_const, :CS_CONST404) end @@ -79,10 +79,10 @@ it "raises a TypeError if conversion to a String by calling #to_str fails" do name = mock('123') - -> { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError) + -> { ConstantSpecs.const_set name, 1 }.should.raise(TypeError) name.should_receive(:to_str).and_return(123) - -> { ConstantSpecs.const_set name, 1 }.should raise_error(TypeError) + -> { ConstantSpecs.const_set name, 1 }.should.raise(TypeError) end describe "when overwriting an existing constant" do @@ -110,7 +110,7 @@ mod = Module.new mod.autoload :Foo, path - -> { mod::Foo }.should raise_error(NameError) + -> { mod::Foo }.should.raise(NameError) mod.const_defined?(:Foo).should == false mod.autoload?(:Foo).should == nil @@ -138,8 +138,8 @@ end it "raises a FrozenError before setting the name" do - -> { @frozen.const_set @name, nil }.should raise_error(FrozenError) - @frozen.should_not have_constant(@name) + -> { @frozen.const_set @name, nil }.should.raise(FrozenError) + @frozen.should_not.const_defined?(@name) end end end diff --git a/spec/ruby/core/module/const_source_location_spec.rb b/spec/ruby/core/module/const_source_location_spec.rb index 96649ea10bdfb7..e6cef727e27bd2 100644 --- a/spec/ruby/core/module/const_source_location_spec.rb +++ b/spec/ruby/core/module/const_source_location_spec.rb @@ -142,19 +142,19 @@ end it "raises a NameError if the name does not start with a capital letter" do - -> { ConstantSpecs.const_source_location "name" }.should raise_error(NameError) + -> { ConstantSpecs.const_source_location "name" }.should.raise(NameError) end it "raises a NameError if the name starts with a non-alphabetic character" do - -> { ConstantSpecs.const_source_location "__CONSTX__" }.should raise_error(NameError) - -> { ConstantSpecs.const_source_location "@CS_CONST1" }.should raise_error(NameError) - -> { ConstantSpecs.const_source_location "!CS_CONST1" }.should raise_error(NameError) + -> { ConstantSpecs.const_source_location "__CONSTX__" }.should.raise(NameError) + -> { ConstantSpecs.const_source_location "@CS_CONST1" }.should.raise(NameError) + -> { ConstantSpecs.const_source_location "!CS_CONST1" }.should.raise(NameError) end it "raises a NameError if the name contains non-alphabetic characters except '_'" do Object.const_source_location("CS_CONST1").should == [@constants_fixture_path, CS_CONST1_LINE] - -> { ConstantSpecs.const_source_location "CS_CONST1=" }.should raise_error(NameError) - -> { ConstantSpecs.const_source_location "CS_CONST1?" }.should raise_error(NameError) + -> { ConstantSpecs.const_source_location "CS_CONST1=" }.should.raise(NameError) + -> { ConstantSpecs.const_source_location "CS_CONST1?" }.should.raise(NameError) end it "calls #to_str to convert the given name to a String" do @@ -165,10 +165,10 @@ it "raises a TypeError if conversion to a String by calling #to_str fails" do name = mock('123') - -> { ConstantSpecs.const_source_location(name) }.should raise_error(TypeError) + -> { ConstantSpecs.const_source_location(name) }.should.raise(TypeError) name.should_receive(:to_str).and_return(123) - -> { ConstantSpecs.const_source_location(name) }.should raise_error(TypeError) + -> { ConstantSpecs.const_source_location(name) }.should.raise(TypeError) end it "does not search the singleton class of a Class or Module" do @@ -213,19 +213,19 @@ end it "raises a NameError if the name includes two successive scope separators" do - -> { ConstantSpecs.const_source_location("ClassA::::CS_CONST10") }.should raise_error(NameError) + -> { ConstantSpecs.const_source_location("ClassA::::CS_CONST10") }.should.raise(NameError) end it "raises a NameError if only '::' is passed" do - -> { ConstantSpecs.const_source_location("::") }.should raise_error(NameError) + -> { ConstantSpecs.const_source_location("::") }.should.raise(NameError) end it "raises a NameError if a Symbol has a toplevel scope qualifier" do - -> { ConstantSpecs.const_source_location(:'::CS_CONST1') }.should raise_error(NameError) + -> { ConstantSpecs.const_source_location(:'::CS_CONST1') }.should.raise(NameError) end it "raises a NameError if a Symbol is a scoped constant name" do - -> { ConstantSpecs.const_source_location(:'ClassA::CS_CONST10') }.should raise_error(NameError) + -> { ConstantSpecs.const_source_location(:'ClassA::CS_CONST10') }.should.raise(NameError) end it "does search private constants path" do diff --git a/spec/ruby/core/module/constants_spec.rb b/spec/ruby/core/module/constants_spec.rb index 330da1cc88f40a..f2f12761e33fc6 100644 --- a/spec/ruby/core/module/constants_spec.rb +++ b/spec/ruby/core/module/constants_spec.rb @@ -13,12 +13,13 @@ module ConstantSpecsAdded it "returns an array of Symbol names" do # This in NOT an exhaustive list - Module.constants.should include(:Array, :Class, :Comparable, :Dir, + Module.constants.to_set.should >= Set[ + :Array, :Class, :Comparable, :Dir, :Enumerable, :ENV, :Exception, :FalseClass, :File, :Float, :Hash, :Integer, :IO, :Kernel, :Math, :Method, :Module, :NilClass, :Numeric, :Object, :Range, :Regexp, :String, - :Symbol, :Thread, :Time, :TrueClass) + :Symbol, :Thread, :Time, :TrueClass] end it "returns Module's constants when given a parameter" do @@ -92,6 +93,6 @@ class Module end it "includes names of constants defined after a module is included" do - ConstantSpecs::ContainerA.constants.should include(:CS_CONST251) + ConstantSpecs::ContainerA.constants.should.include?(:CS_CONST251) end end diff --git a/spec/ruby/core/module/define_method_spec.rb b/spec/ruby/core/module/define_method_spec.rb index a4fe4fad187b83..f838e2b85fe4e5 100644 --- a/spec/ruby/core/module/define_method_spec.rb +++ b/spec/ruby/core/module/define_method_spec.rb @@ -12,7 +12,7 @@ class DefineMethodSpecClass end it "raises an ArgumentError when passed zero arguments" do - -> { @klass.new.m }.should raise_error(ArgumentError) + -> { @klass.new.m }.should.raise(ArgumentError) end it "has a default value for b when passed one argument" do @@ -24,7 +24,7 @@ class DefineMethodSpecClass end it "raises an ArgumentError when passed three arguments" do - -> { @klass.new.m(1, 2, 3) }.should raise_error(ArgumentError) + -> { @klass.new.m(1, 2, 3) }.should.raise(ArgumentError) end end @@ -47,7 +47,7 @@ def test_method(arg1, arg2) end define_method(:another_test_method, instance_method(:test_method)) end - klass.new.should have_method(:another_test_method) + klass.new.should.respond_to?(:another_test_method) end describe "defining a method on a singleton class" do @@ -83,7 +83,7 @@ def ziggy define_method :piggy, instance_method(:ziggy) end - -> { foo.new.ziggy }.should raise_error(NoMethodError) + -> { foo.new.ziggy }.should.raise(NoMethodError) foo.new.piggy.should == 'piggy' end end @@ -115,8 +115,8 @@ class << klass define_method(:baz, ModuleSpecs::EmptyFooMethod) end - klass.should have_public_instance_method(:bar) - klass.should have_private_instance_method(:baz) + klass.public_instance_methods(false).should.include?(:bar) + klass.private_instance_methods(false).should.include?(:baz) end end @@ -129,8 +129,8 @@ class << klass klass.send(:define_method, :baz, ModuleSpecs::EmptyFooMethod) end - klass.should have_public_instance_method(:bar) - klass.should have_public_instance_method(:baz) + klass.public_instance_methods(false).should.include?(:bar) + klass.public_instance_methods(false).should.include?(:baz) end end @@ -155,8 +155,8 @@ def bar; end define_method(:baz) {} end - klass.should have_public_instance_method(:bar) - klass.should have_private_instance_method(:baz) + klass.public_instance_methods(false).should.include?(:bar) + klass.private_instance_methods(false).should.include?(:baz) end end @@ -169,8 +169,8 @@ def bar; end klass.send(:define_method, :baz) {} end - klass.should have_public_instance_method(:bar) - klass.should have_public_instance_method(:baz) + klass.public_instance_methods(false).should.include?(:bar) + klass.public_instance_methods(false).should.include?(:baz) end end end @@ -182,7 +182,7 @@ def bar; end klass = Class.new do define_method(:initialize) { } end - klass.should have_private_instance_method(:initialize) + klass.private_instance_methods(false).should.include?(:initialize) end end @@ -193,7 +193,7 @@ def test_method end define_method(:initialize, instance_method(:test_method)) end - klass.should have_private_instance_method(:initialize) + klass.private_instance_methods(false).should.include?(:initialize) end end end @@ -233,11 +233,11 @@ class DefineMethodSpecClass it "raises TypeError if name cannot converted to String" do -> { Class.new { define_method(1001, -> {}) } - }.should raise_error(TypeError, /is not a symbol nor a string/) + }.should.raise(TypeError, /is not a symbol nor a string/) -> { Class.new { define_method([], -> {}) } - }.should raise_error(TypeError, /is not a symbol nor a string/) + }.should.raise(TypeError, /is not a symbol nor a string/) end it "converts non-String name to String with #to_str" do @@ -260,15 +260,15 @@ def obj.to_str() [] end it "raises a TypeError when the given method is no Method/Proc" do -> { Class.new { define_method(:test, "self") } - }.should raise_error(TypeError, "wrong argument type String (expected Proc/Method/UnboundMethod)") + }.should.raise(TypeError, "wrong argument type String (expected Proc/Method/UnboundMethod)") -> { Class.new { define_method(:test, 1234) } - }.should raise_error(TypeError, "wrong argument type Integer (expected Proc/Method/UnboundMethod)") + }.should.raise(TypeError, "wrong argument type Integer (expected Proc/Method/UnboundMethod)") -> { Class.new { define_method(:test, nil) } - }.should raise_error(TypeError, "wrong argument type NilClass (expected Proc/Method/UnboundMethod)") + }.should.raise(TypeError, "wrong argument type NilClass (expected Proc/Method/UnboundMethod)") end it "uses provided Method/Proc even if block is specified" do @@ -284,7 +284,7 @@ def obj.to_str() [] end it "raises an ArgumentError when no block is given" do -> { Class.new { define_method(:test) } - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "does not use the caller block when no block is given" do @@ -297,7 +297,7 @@ def o.define(name) -> { o.define(:foo) { raise "not used" } - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "does not change the arity check style of the original proc" do @@ -307,13 +307,13 @@ class DefineMethodSpecClass end obj = DefineMethodSpecClass.new - -> { obj.proc_style_test :arg }.should raise_error(ArgumentError) + -> { obj.proc_style_test :arg }.should.raise(ArgumentError) end it "raises a FrozenError if frozen" do -> { Class.new { freeze; define_method(:foo) {} } - }.should raise_error(FrozenError) + }.should.raise(FrozenError) end it "accepts a Method (still bound)" do @@ -326,13 +326,13 @@ def inspect_data o = DefineMethodSpecClass.new o.data = :foo m = o.method(:inspect_data) - m.should be_an_instance_of(Method) + m.should.instance_of?(Method) klass = Class.new(DefineMethodSpecClass) klass.send(:define_method,:other_inspect, m) c = klass.new c.data = :bar c.other_inspect.should == "data is bar" - ->{o.other_inspect}.should raise_error(NoMethodError) + ->{o.other_inspect}.should.raise(NoMethodError) end it "raises a TypeError when a Method from a singleton class is defined on another class" do @@ -346,7 +346,7 @@ def foo -> { Class.new { define_method :bar, m } - }.should raise_error(TypeError, /can't bind singleton method to a different class/) + }.should.raise(TypeError, /can't bind singleton method to a different class/) end it "raises a TypeError when a Method from one class is defined on an unrelated class" do @@ -358,7 +358,7 @@ def foo -> { Class.new { define_method :bar, m } - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "accepts an UnboundMethod from an attr_accessor method" do @@ -370,7 +370,7 @@ class DefineMethodSpecClass o = DefineMethodSpecClass.new DefineMethodSpecClass.send(:undef_method, :accessor_method) - -> { o.accessor_method }.should raise_error(NoMethodError) + -> { o.accessor_method }.should.raise(NoMethodError) DefineMethodSpecClass.send(:define_method, :accessor_method, m) @@ -415,7 +415,7 @@ class DefineMethodByProcClass end o = DefineMethodByProcClass.new - o.proc_test.should be_true + o.proc_test.should == true end it "accepts a String method name" do @@ -429,7 +429,7 @@ class DefineMethodByProcClass end it "is a public method" do - Module.should have_public_instance_method(:define_method) + Module.public_instance_methods(false).should.include?(:define_method) end it "returns its symbol" do @@ -443,7 +443,7 @@ class DefineMethodSpecClass klass = Class.new { define_method :bar, ModuleSpecs::UnboundMethodTest.instance_method(:foo) } - klass.new.should respond_to(:bar) + klass.new.should.respond_to?(:bar) end it "allows an UnboundMethod from a parent class to be defined on a child class" do @@ -451,7 +451,7 @@ class DefineMethodSpecClass child = Class.new(parent) { define_method :baz, parent.instance_method(:foo) } - child.new.should respond_to(:baz) + child.new.should.respond_to?(:baz) end it "allows an UnboundMethod from a module to be defined on another unrelated module" do @@ -459,7 +459,7 @@ class DefineMethodSpecClass define_method :bar, ModuleSpecs::UnboundMethodTest.instance_method(:foo) } klass = Class.new { include mod } - klass.new.should respond_to(:bar) + klass.new.should.respond_to?(:bar) end @@ -475,7 +475,7 @@ class DefineMethodSpecClass ParentClass = Class.new { define_method(:foo) { :bar } } ChildClass = Class.new(ParentClass) { define_method(:foo) { :baz } } ParentClass.send :define_method, :foo, ChildClass.instance_method(:foo) - }.should raise_error(TypeError, /bind argument must be a subclass of ChildClass/) + }.should.raise(TypeError, /bind argument must be a subclass of ChildClass/) ensure Object.send(:remove_const, :ParentClass) Object.send(:remove_const, :ChildClass) @@ -486,7 +486,7 @@ class DefineMethodSpecClass DestinationClass = Class.new { define_method :bar, ModuleSpecs::InstanceMeth.instance_method(:foo) } - }.should raise_error(TypeError, /bind argument must be a subclass of ModuleSpecs::InstanceMeth/) + }.should.raise(TypeError, /bind argument must be a subclass of ModuleSpecs::InstanceMeth/) end it "raises a TypeError when an UnboundMethod from a singleton class is defined on another class" do @@ -500,7 +500,7 @@ def foo -> { Class.new { define_method :bar, m } - }.should raise_error(TypeError, /can't bind singleton method to a different class/) + }.should.raise(TypeError, /can't bind singleton method to a different class/) end it "defines a new method with public visibility when a Method passed and the class/module of the context isn't equal to the receiver of #define_method" do @@ -527,7 +527,7 @@ def foo; end define_method(:bar, c.new.method(:foo)) end - -> { object.bar }.should raise_error(NoMethodError) + -> { object.bar }.should.raise(NoMethodError) end end @@ -544,11 +544,11 @@ def foo; end end it "raises an ArgumentError when passed one argument" do - -> { @klass.new.m 1 }.should raise_error(ArgumentError) + -> { @klass.new.m 1 }.should.raise(ArgumentError) end it "raises an ArgumentError when passed two arguments" do - -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError) + -> { @klass.new.m 1, 2 }.should.raise(ArgumentError) end end @@ -564,11 +564,11 @@ def foo; end end it "raises an ArgumentError when passed one argument" do - -> { @klass.new.m 1 }.should raise_error(ArgumentError) + -> { @klass.new.m 1 }.should.raise(ArgumentError) end it "raises an ArgumentError when passed two arguments" do - -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError) + -> { @klass.new.m 1, 2 }.should.raise(ArgumentError) end end @@ -580,15 +580,15 @@ def foo; end end it "raises an ArgumentError when passed zero arguments" do - -> { @klass.new.m }.should raise_error(ArgumentError) + -> { @klass.new.m }.should.raise(ArgumentError) end it "raises an ArgumentError when passed zero arguments and a block" do - -> { @klass.new.m { :computed } }.should raise_error(ArgumentError) + -> { @klass.new.m { :computed } }.should.raise(ArgumentError) end it "raises an ArgumentError when passed two arguments" do - -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError) + -> { @klass.new.m 1, 2 }.should.raise(ArgumentError) end it "receives the value passed as the argument when passed one argument" do @@ -604,15 +604,15 @@ def foo; end end it "raises an ArgumentError when passed zero arguments" do - -> { @klass.new.m }.should raise_error(ArgumentError) + -> { @klass.new.m }.should.raise(ArgumentError) end it "raises an ArgumentError when passed zero arguments and a block" do - -> { @klass.new.m { :computed } }.should raise_error(ArgumentError) + -> { @klass.new.m { :computed } }.should.raise(ArgumentError) end it "raises an ArgumentError when passed two arguments" do - -> { @klass.new.m 1, 2 }.should raise_error(ArgumentError) + -> { @klass.new.m 1, 2 }.should.raise(ArgumentError) end it "receives the value passed as the argument when passed one argument" do @@ -654,7 +654,7 @@ def foo; end end it "raises an ArgumentError when passed zero arguments" do - -> { @klass.new.m }.should raise_error(ArgumentError) + -> { @klass.new.m }.should.raise(ArgumentError) end it "returns the value computed by the block when passed one argument" do @@ -682,19 +682,19 @@ def foo; end end it "raises an ArgumentError when passed zero arguments" do - -> { @klass.new.m }.should raise_error(ArgumentError) + -> { @klass.new.m }.should.raise(ArgumentError) end it "raises an ArgumentError when passed one argument" do - -> { @klass.new.m 1 }.should raise_error(ArgumentError) + -> { @klass.new.m 1 }.should.raise(ArgumentError) end it "raises an ArgumentError when passed one argument and a block" do - -> { @klass.new.m(1) { } }.should raise_error(ArgumentError) + -> { @klass.new.m(1) { } }.should.raise(ArgumentError) end it "raises an ArgumentError when passed three arguments" do - -> { @klass.new.m 1, 2, 3 }.should raise_error(ArgumentError) + -> { @klass.new.m 1, 2, 3 }.should.raise(ArgumentError) end end @@ -706,15 +706,15 @@ def foo; end end it "raises an ArgumentError when passed zero arguments" do - -> { @klass.new.m }.should raise_error(ArgumentError) + -> { @klass.new.m }.should.raise(ArgumentError) end it "raises an ArgumentError when passed one argument" do - -> { @klass.new.m 1 }.should raise_error(ArgumentError) + -> { @klass.new.m 1 }.should.raise(ArgumentError) end it "raises an ArgumentError when passed one argument and a block" do - -> { @klass.new.m(1) { } }.should raise_error(ArgumentError) + -> { @klass.new.m(1) { } }.should.raise(ArgumentError) end it "receives an empty array as the third argument when passed two arguments" do @@ -795,7 +795,7 @@ def nested_method_in_proc_for_define_method o = c.new o.test - o.should_not have_method :nested_method_in_proc_for_define_method + o.should_not.respond_to? :nested_method_in_proc_for_define_method t.new.nested_method_in_proc_for_define_method.should == 42 end diff --git a/spec/ruby/core/module/deprecate_constant_spec.rb b/spec/ruby/core/module/deprecate_constant_spec.rb index ec0de6782ffaf5..597379eb87b559 100644 --- a/spec/ruby/core/module/deprecate_constant_spec.rb +++ b/spec/ruby/core/module/deprecate_constant_spec.rb @@ -19,9 +19,9 @@ -> { value = @module::PUBLIC1 }.should complain(/warning: constant .+::PUBLIC1 is deprecated/) - value.should equal(@value) + value.should.equal?(@value) - -> { @module::PRIVATE }.should raise_error(NameError) + -> { @module::PRIVATE }.should.raise(NameError) end it "warns with a message" do @@ -61,10 +61,10 @@ end it "returns self" do - @module.deprecate_constant(:PUBLIC1).should equal(@module) + @module.deprecate_constant(:PUBLIC1).should.equal?(@module) end it "raises a NameError when given an undefined name" do - -> { @module.deprecate_constant :UNDEFINED }.should raise_error(NameError) + -> { @module.deprecate_constant :UNDEFINED }.should.raise(NameError) end end diff --git a/spec/ruby/core/module/extend_object_spec.rb b/spec/ruby/core/module/extend_object_spec.rb index 1fd1abc0b52d97..b428eb7924fb85 100644 --- a/spec/ruby/core/module/extend_object_spec.rb +++ b/spec/ruby/core/module/extend_object_spec.rb @@ -7,18 +7,18 @@ end it "is a private method" do - Module.should have_private_instance_method(:extend_object) + Module.private_instance_methods(false).should.include?(:extend_object) end describe "on Class" do it "is undefined" do - Class.should_not have_private_instance_method(:extend_object, true) + Class.private_instance_methods(true).should_not.include?(:extend_object) end it "raises a TypeError if calling after rebinded to Class" do -> { Module.instance_method(:extend_object).bind(Class.new).call Object.new - }.should raise_error(TypeError) + }.should.raise(TypeError) end end @@ -49,8 +49,8 @@ end it "raises a RuntimeError before extending the object" do - -> { @receiver.send(:extend_object, @object) }.should raise_error(RuntimeError) - @object.should_not be_kind_of(@receiver) + -> { @receiver.send(:extend_object, @object) }.should.raise(RuntimeError) + @object.should_not.is_a?(@receiver) end end end diff --git a/spec/ruby/core/module/extended_spec.rb b/spec/ruby/core/module/extended_spec.rb index c6300ffa0bb538..a4ec5a4ba7f40f 100644 --- a/spec/ruby/core/module/extended_spec.rb +++ b/spec/ruby/core/module/extended_spec.rb @@ -39,6 +39,6 @@ def self.extended(o) end it "is private in its default implementation" do - Module.new.private_methods.should include(:extended) + Module.new.private_methods.should.include?(:extended) end end diff --git a/spec/ruby/core/module/gt_spec.rb b/spec/ruby/core/module/gt_spec.rb index b8a73c9ff93f80..04cdd90efb04ab 100644 --- a/spec/ruby/core/module/gt_spec.rb +++ b/spec/ruby/core/module/gt_spec.rb @@ -3,10 +3,10 @@ describe "Module#>" do it "returns false if self is a subclass of or includes the given module" do - (ModuleSpecs::Child > ModuleSpecs::Parent).should be_false - (ModuleSpecs::Child > ModuleSpecs::Basic).should be_false - (ModuleSpecs::Child > ModuleSpecs::Super).should be_false - (ModuleSpecs::Super > ModuleSpecs::Basic).should be_false + (ModuleSpecs::Child > ModuleSpecs::Parent).should == false + (ModuleSpecs::Child > ModuleSpecs::Basic).should == false + (ModuleSpecs::Child > ModuleSpecs::Super).should == false + (ModuleSpecs::Super > ModuleSpecs::Basic).should == false end it "returns true if self is a superclass of or included by the given module" do @@ -31,6 +31,6 @@ end it "raises a TypeError if the argument is not a class/module" do - -> { ModuleSpecs::Parent > mock('x') }.should raise_error(TypeError) + -> { ModuleSpecs::Parent > mock('x') }.should.raise(TypeError) end end diff --git a/spec/ruby/core/module/gte_spec.rb b/spec/ruby/core/module/gte_spec.rb index 18c60ba5864efc..b19fc9fac34827 100644 --- a/spec/ruby/core/module/gte_spec.rb +++ b/spec/ruby/core/module/gte_spec.rb @@ -28,6 +28,6 @@ end it "raises a TypeError if the argument is not a class/module" do - -> { ModuleSpecs::Parent >= mock('x') }.should raise_error(TypeError) + -> { ModuleSpecs::Parent >= mock('x') }.should.raise(TypeError) end end diff --git a/spec/ruby/core/module/include_spec.rb b/spec/ruby/core/module/include_spec.rb index 210918b2e7ac6a..b6201550e42523 100644 --- a/spec/ruby/core/module/include_spec.rb +++ b/spec/ruby/core/module/include_spec.rb @@ -3,7 +3,7 @@ describe "Module#include" do it "is a public method" do - Module.should have_public_instance_method(:include, false) + Module.public_instance_methods(false).should.include?(:include) end it "calls #append_features(self) in reversed order on each module" do @@ -33,20 +33,20 @@ def self.append_features(mod) end it "adds all ancestor modules when a previously included module is included again" do - ModuleSpecs::MultipleIncludes.ancestors.should include(ModuleSpecs::MA, ModuleSpecs::MB) + ModuleSpecs::MultipleIncludes.ancestors.to_set.should >= Set[ModuleSpecs::MA, ModuleSpecs::MB] ModuleSpecs::MB.include(ModuleSpecs::MC) ModuleSpecs::MultipleIncludes.include(ModuleSpecs::MB) - ModuleSpecs::MultipleIncludes.ancestors.should include(ModuleSpecs::MA, ModuleSpecs::MB, ModuleSpecs::MC) + ModuleSpecs::MultipleIncludes.ancestors.to_set.should >= Set[ModuleSpecs::MA, ModuleSpecs::MB, ModuleSpecs::MC] end it "raises a TypeError when the argument is not a Module" do - -> { ModuleSpecs::Basic.include(Class.new) }.should raise_error(TypeError) + -> { ModuleSpecs::Basic.include(Class.new) }.should.raise(TypeError) end it "does not raise a TypeError when the argument is an instance of a subclass of Module" do class ModuleSpecs::SubclassSpec::AClass end - -> { ModuleSpecs::SubclassSpec::AClass.include(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError) + -> { ModuleSpecs::SubclassSpec::AClass.include(ModuleSpecs::Subclass.new) }.should_not.raise(TypeError) ensure ModuleSpecs::SubclassSpec.send(:remove_const, :AClass) end @@ -60,13 +60,13 @@ class ModuleSpecs::SubclassSpec::AClass end end - -> { ModuleSpecs::Basic.include(refinement) }.should raise_error(TypeError, "Cannot include refinement") + -> { ModuleSpecs::Basic.include(refinement) }.should.raise(TypeError, "Cannot include refinement") end it "imports constants to modules and classes" do - ModuleSpecs::A.constants.should include(:CONSTANT_A) - ModuleSpecs::B.constants.should include(:CONSTANT_A, :CONSTANT_B) - ModuleSpecs::C.constants.should include(:CONSTANT_A, :CONSTANT_B) + ModuleSpecs::A.constants.should.include?(:CONSTANT_A) + ModuleSpecs::B.constants.to_set.should >= Set[:CONSTANT_A, :CONSTANT_B] + ModuleSpecs::C.constants.to_set.should >= Set[:CONSTANT_A, :CONSTANT_B] end it "shadows constants from ancestors" do @@ -84,9 +84,9 @@ class ModuleSpecs::SubclassSpec::AClass end it "imports instance methods to modules and classes" do - ModuleSpecs::A.instance_methods.should include(:ma) - ModuleSpecs::B.instance_methods.should include(:ma,:mb) - ModuleSpecs::C.instance_methods.should include(:ma,:mb) + ModuleSpecs::A.instance_methods.should.include?(:ma) + ModuleSpecs::B.instance_methods.to_set.should >= Set[:ma,:mb] + ModuleSpecs::C.instance_methods.to_set.should >= Set[:ma,:mb] end it "does not import methods to modules and classes" do @@ -146,7 +146,7 @@ module V; include X, U, Y; end anc = B.ancestors [B, U, V, W, A, X].each do |i| - anc.include?(i).should be_true + anc.include?(i).should == true end class B; include V; end @@ -154,7 +154,7 @@ class B; include V; end # the only new module is Y, it is added after U since it follows U in V mixin list: anc = B.ancestors [B, U, Y, V, W, A, X].each do |i| - anc.include?(i).should be_true + anc.include?(i).should == true end end end @@ -178,7 +178,7 @@ module M3; include M2; end module ModuleSpecs::M include ModuleSpecs::M end - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "doesn't accept no-arguments" do @@ -186,7 +186,7 @@ module ModuleSpecs::M Module.new do include end - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "returns the class it's included into" do @@ -622,7 +622,7 @@ def m4; [:m4]; end end it "raises a TypeError when no module was given" do - -> { ModuleSpecs::Child.include?("Test") }.should raise_error(TypeError) - -> { ModuleSpecs::Child.include?(ModuleSpecs::Parent) }.should raise_error(TypeError) + -> { ModuleSpecs::Child.include?("Test") }.should.raise(TypeError) + -> { ModuleSpecs::Child.include?(ModuleSpecs::Parent) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/module/included_modules_spec.rb b/spec/ruby/core/module/included_modules_spec.rb index ce94ed12855729..e22ee5e6cf431c 100644 --- a/spec/ruby/core/module/included_modules_spec.rb +++ b/spec/ruby/core/module/included_modules_spec.rb @@ -5,10 +5,10 @@ it "returns a list of modules included in self" do ModuleSpecs.included_modules.should == [] - ModuleSpecs::Child.included_modules.should include(ModuleSpecs::Super, ModuleSpecs::Basic, Kernel) - ModuleSpecs::Parent.included_modules.should include(Kernel) + ModuleSpecs::Child.included_modules.to_set.should >= Set[ModuleSpecs::Super, ModuleSpecs::Basic, Kernel] + ModuleSpecs::Parent.included_modules.should.include?(Kernel) ModuleSpecs::Basic.included_modules.should == [] - ModuleSpecs::Super.included_modules.should include(ModuleSpecs::Basic) - ModuleSpecs::WithPrependedModule.included_modules.should include(ModuleSpecs::ModuleWithPrepend) + ModuleSpecs::Super.included_modules.should.include?(ModuleSpecs::Basic) + ModuleSpecs::WithPrependedModule.included_modules.should.include?(ModuleSpecs::ModuleWithPrepend) end end diff --git a/spec/ruby/core/module/included_spec.rb b/spec/ruby/core/module/included_spec.rb index 2fdd4325f2ddd7..d8a6c3f839a486 100644 --- a/spec/ruby/core/module/included_spec.rb +++ b/spec/ruby/core/module/included_spec.rb @@ -34,7 +34,7 @@ def test end it "is private in its default implementation" do - Module.should have_private_instance_method(:included) + Module.private_instance_methods(false).should.include?(:included) end it "works with super using a singleton class" do diff --git a/spec/ruby/core/module/instance_method_spec.rb b/spec/ruby/core/module/instance_method_spec.rb index c6bc20152002b0..8615e352f63f48 100644 --- a/spec/ruby/core/module/instance_method_spec.rb +++ b/spec/ruby/core/module/instance_method_spec.rb @@ -9,7 +9,7 @@ end it "is a public method" do - Module.should have_public_instance_method(:instance_method, false) + Module.public_instance_methods(false).should.include?(:instance_method) end it "requires an argument" do @@ -17,26 +17,26 @@ end it "returns an UnboundMethod corresponding to the given name" do - @parent_um.should be_kind_of(UnboundMethod) + @parent_um.should.is_a?(UnboundMethod) @parent_um.bind(ModuleSpecs::InstanceMeth.new).call.should == :foo end it "returns an UnboundMethod corresponding to the given name from a superclass" do - @child_um.should be_kind_of(UnboundMethod) + @child_um.should.is_a?(UnboundMethod) @child_um.bind(ModuleSpecs::InstanceMethChild.new).call.should == :foo end it "returns an UnboundMethod corresponding to the given name from an included Module" do - @mod_um.should be_kind_of(UnboundMethod) + @mod_um.should.is_a?(UnboundMethod) @mod_um.bind(ModuleSpecs::InstanceMethChild.new).call.should == :bar end it "returns an UnboundMethod when given a protected method name" do - ModuleSpecs::Basic.instance_method(:protected_module).should be_an_instance_of(UnboundMethod) + ModuleSpecs::Basic.instance_method(:protected_module).should.instance_of?(UnboundMethod) end it "returns an UnboundMethod when given a private method name" do - ModuleSpecs::Basic.instance_method(:private_module).should be_an_instance_of(UnboundMethod) + ModuleSpecs::Basic.instance_method(:private_module).should.instance_of?(UnboundMethod) end it "gives UnboundMethod method name, Module defined in and Module extracted from" do @@ -51,20 +51,20 @@ end it "raises a TypeError if the given name is not a String/Symbol" do - -> { Object.instance_method([]) }.should raise_error(TypeError, /is not a symbol nor a string/) - -> { Object.instance_method(0) }.should raise_error(TypeError, /is not a symbol nor a string/) - -> { Object.instance_method(nil) }.should raise_error(TypeError, /is not a symbol nor a string/) - -> { Object.instance_method(mock('x')) }.should raise_error(TypeError, /is not a symbol nor a string/) + -> { Object.instance_method([]) }.should.raise(TypeError, /is not a symbol nor a string/) + -> { Object.instance_method(0) }.should.raise(TypeError, /is not a symbol nor a string/) + -> { Object.instance_method(nil) }.should.raise(TypeError, /is not a symbol nor a string/) + -> { Object.instance_method(mock('x')) }.should.raise(TypeError, /is not a symbol nor a string/) end it "accepts String name argument" do method = ModuleSpecs::InstanceMeth.instance_method(:foo) - method.should be_kind_of(UnboundMethod) + method.should.is_a?(UnboundMethod) end it "accepts Symbol name argument" do method = ModuleSpecs::InstanceMeth.instance_method("foo") - method.should be_kind_of(UnboundMethod) + method.should.is_a?(UnboundMethod) end it "converts non-String name by calling #to_str method" do @@ -72,7 +72,7 @@ def obj.to_str() "foo" end method = ModuleSpecs::InstanceMeth.instance_method(obj) - method.should be_kind_of(UnboundMethod) + method.should.is_a?(UnboundMethod) end it "raises TypeError when passed non-String name and #to_str returns non-String value" do @@ -89,11 +89,11 @@ def obj.to_str() [] end um.should == @parent_um -> do child.instance_method(:foo) - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError if the method does not exist" do - -> { Object.instance_method(:missing) }.should raise_error(NameError) + -> { Object.instance_method(:missing) }.should.raise(NameError) end it "sets the NameError#name attribute to the name of the missing method" do diff --git a/spec/ruby/core/module/instance_methods_spec.rb b/spec/ruby/core/module/instance_methods_spec.rb index d2d38cdda2fb6f..dbb6df8c34e08f 100644 --- a/spec/ruby/core/module/instance_methods_spec.rb +++ b/spec/ruby/core/module/instance_methods_spec.rb @@ -4,21 +4,22 @@ describe "Module#instance_methods" do it "does not return methods undefined in a superclass" do methods = ModuleSpecs::Parent.instance_methods(false) - methods.should_not include(:undefed_method) + methods.should_not.include?(:undefed_method) end it "only includes module methods on an included module" do methods = ModuleSpecs::Basic.instance_methods(false) - methods.should include(:public_module) + methods.should.include?(:public_module) # Child is an including class methods = ModuleSpecs::Child.instance_methods(false) - methods.should include(:public_child) - methods.should_not include(:public_module) + methods.should.include?(:public_child) + methods.should_not.include?(:public_module) end it "does not return methods undefined in a subclass" do methods = ModuleSpecs::Grandchild.instance_methods - methods.should_not include(:parent_method, :another_parent_method) + methods.should_not.include?(:parent_method) + methods.should_not.include?(:another_parent_method) end it "does not return methods undefined in the current class" do @@ -28,34 +29,35 @@ def undefed_child end ModuleSpecs::Child.send(:undef_method, :undefed_child) methods = ModuleSpecs::Child.instance_methods - methods.should_not include(:undefed_method, :undefed_child) + methods.should_not.include?(:undefed_method) + methods.should_not.include?(:undefed_child) end it "does not return methods from an included module that are undefined in the class" do - ModuleSpecs::Grandchild.instance_methods.should_not include(:super_included_method) + ModuleSpecs::Grandchild.instance_methods.should_not.include?(:super_included_method) end it "returns the public and protected methods of self if include_super is false" do methods = ModuleSpecs::Parent.instance_methods(false) - methods.should include(:protected_parent, :public_parent) + methods.to_set.should >= Set[:protected_parent, :public_parent] methods = ModuleSpecs::Child.instance_methods(false) - methods.should include(:protected_child, :public_child) + methods.to_set.should >= Set[:protected_child, :public_child] end it "returns the public and protected methods of self and it's ancestors" do methods = ModuleSpecs::Basic.instance_methods - methods.should include(:protected_module, :public_module) + methods.to_set.should >= Set[:protected_module, :public_module] methods = ModuleSpecs::Super.instance_methods - methods.should include(:protected_module, :protected_super_module, - :public_module, :public_super_module) + methods.to_set.should >= Set[:protected_module, :protected_super_module, + :public_module, :public_super_module] end it "makes a private Object instance method public in Kernel" do methods = Kernel.instance_methods - methods.should include(:module_specs_private_method_on_object_for_kernel_public) + methods.should.include?(:module_specs_private_method_on_object_for_kernel_public) methods = Object.instance_methods - methods.should_not include(:module_specs_private_method_on_object_for_kernel_public) + methods.should_not.include?(:module_specs_private_method_on_object_for_kernel_public) end end diff --git a/spec/ruby/core/module/lt_spec.rb b/spec/ruby/core/module/lt_spec.rb index d7771e07a8712e..8567a249938fc8 100644 --- a/spec/ruby/core/module/lt_spec.rb +++ b/spec/ruby/core/module/lt_spec.rb @@ -10,10 +10,10 @@ end it "returns false if self is a superclass of or included by the given module" do - (ModuleSpecs::Parent < ModuleSpecs::Child).should be_false - (ModuleSpecs::Basic < ModuleSpecs::Child).should be_false - (ModuleSpecs::Super < ModuleSpecs::Child).should be_false - (ModuleSpecs::Basic < ModuleSpecs::Super).should be_false + (ModuleSpecs::Parent < ModuleSpecs::Child).should == false + (ModuleSpecs::Basic < ModuleSpecs::Child).should == false + (ModuleSpecs::Super < ModuleSpecs::Child).should == false + (ModuleSpecs::Basic < ModuleSpecs::Super).should == false end it "returns false if self is the same as the given module" do @@ -31,6 +31,6 @@ end it "raises a TypeError if the argument is not a class/module" do - -> { ModuleSpecs::Parent < mock('x') }.should raise_error(TypeError) + -> { ModuleSpecs::Parent < mock('x') }.should.raise(TypeError) end end diff --git a/spec/ruby/core/module/lte_spec.rb b/spec/ruby/core/module/lte_spec.rb index 7a0e8496b859bf..c6aab94e9f49e4 100644 --- a/spec/ruby/core/module/lte_spec.rb +++ b/spec/ruby/core/module/lte_spec.rb @@ -28,6 +28,6 @@ end it "raises a TypeError if the argument is not a class/module" do - -> { ModuleSpecs::Parent <= mock('x') }.should raise_error(TypeError) + -> { ModuleSpecs::Parent <= mock('x') }.should.raise(TypeError) end end diff --git a/spec/ruby/core/module/method_added_spec.rb b/spec/ruby/core/module/method_added_spec.rb index ec92cddc1e4f28..996a14eb868fe2 100644 --- a/spec/ruby/core/module/method_added_spec.rb +++ b/spec/ruby/core/module/method_added_spec.rb @@ -7,7 +7,7 @@ end it "is a private instance method" do - Module.should have_private_instance_method(:method_added) + Module.private_instance_methods(false).should.include?(:method_added) end it "returns nil in the default implementation" do @@ -57,7 +57,7 @@ def self.method_added(name) undef_method :method_to_undef end - m.should_not have_method(:method_to_undef) + m.should_not.respond_to?(:method_to_undef) end it "is not called when a method changes visibility" do diff --git a/spec/ruby/core/module/method_defined_spec.rb b/spec/ruby/core/module/method_defined_spec.rb index bc5b420e118f95..e6b4c7b8176fcf 100644 --- a/spec/ruby/core/module/method_defined_spec.rb +++ b/spec/ruby/core/module/method_defined_spec.rb @@ -27,17 +27,17 @@ it "does not search Object or Kernel when called on a module" do m = Module.new - m.method_defined?(:module_specs_public_method_on_kernel).should be_false + m.method_defined?(:module_specs_public_method_on_kernel).should == false end it "raises a TypeError when the given object is not a string/symbol" do c = Class.new o = mock('123') - -> { c.method_defined?(o) }.should raise_error(TypeError) + -> { c.method_defined?(o) }.should.raise(TypeError) o.should_receive(:to_str).and_return(123) - -> { c.method_defined?(o) }.should raise_error(TypeError) + -> { c.method_defined?(o) }.should.raise(TypeError) end it "converts the given name to a string using to_str" do diff --git a/spec/ruby/core/module/method_removed_spec.rb b/spec/ruby/core/module/method_removed_spec.rb index 9b39eb77a60a1a..80e546406c9db9 100644 --- a/spec/ruby/core/module/method_removed_spec.rb +++ b/spec/ruby/core/module/method_removed_spec.rb @@ -3,7 +3,7 @@ describe "Module#method_removed" do it "is a private instance method" do - Module.should have_private_instance_method(:method_removed) + Module.private_instance_methods(false).should.include?(:method_removed) end it "returns nil in the default implementation" do diff --git a/spec/ruby/core/module/method_undefined_spec.rb b/spec/ruby/core/module/method_undefined_spec.rb index a94388fe0ad39a..596c5c50e2646e 100644 --- a/spec/ruby/core/module/method_undefined_spec.rb +++ b/spec/ruby/core/module/method_undefined_spec.rb @@ -3,7 +3,7 @@ describe "Module#method_undefined" do it "is a private instance method" do - Module.should have_private_instance_method(:method_undefined) + Module.private_instance_methods(false).should.include?(:method_undefined) end it "returns nil in the default implementation" do diff --git a/spec/ruby/core/module/module_function_spec.rb b/spec/ruby/core/module/module_function_spec.rb index 51f647142e72e0..41bd152608b1f2 100644 --- a/spec/ruby/core/module/module_function_spec.rb +++ b/spec/ruby/core/module/module_function_spec.rb @@ -3,22 +3,22 @@ describe "Module#module_function" do it "is a private method" do - Module.should have_private_instance_method(:module_function) + Module.private_instance_methods(false).should.include?(:module_function) end describe "on Class" do it "is undefined" do - Class.should_not have_private_instance_method(:module_function, true) + Class.private_instance_methods(true).should_not.include?(:module_function) end it "raises a TypeError if calling after rebinded to Class" do -> { Module.instance_method(:module_function).bind(Class.new).call - }.should raise_error(TypeError) + }.should.raise(TypeError) -> { Module.instance_method(:module_function).bind(Class.new).call :foo - }.should raise_error(TypeError) + }.should.raise(TypeError) end end end @@ -41,7 +41,7 @@ def test3() end it "returns argument or arguments if given" do Module.new do def foo; end - module_function(:foo).should equal(:foo) + module_function(:foo).should.equal?(:foo) module_function(:foo, :foo).should == [:foo, :foo] end end @@ -83,9 +83,9 @@ def test() "hello" end (o = mock('x')).extend(m) o.respond_to?(:test).should == false - m.should have_private_instance_method(:test) + m.private_instance_methods(false).should.include?(:test) o.send(:test).should == "hello" - -> { o.test }.should raise_error(NoMethodError) + -> { o.test }.should.raise(NoMethodError) end it "makes the new Module methods public" do @@ -114,17 +114,17 @@ def test2() end it "raises a TypeError when the given names can't be converted to string using to_str" do o = mock('123') - -> { Module.new { module_function(o) } }.should raise_error(TypeError) + -> { Module.new { module_function(o) } }.should.raise(TypeError) o.should_receive(:to_str).and_return(123) - -> { Module.new { module_function(o) } }.should raise_error(TypeError) + -> { Module.new { module_function(o) } }.should.raise(TypeError) end it "can make accessible private methods" do # JRUBY-4214 m = Module.new do module_function :require end - m.respond_to?(:require).should be_true + m.respond_to?(:require).should == true end it "creates Module methods that super up the singleton class of the module" do @@ -207,7 +207,7 @@ def test2() end it "returns nil" do Module.new do - module_function.should equal(nil) + module_function.should.equal?(nil) end end diff --git a/spec/ruby/core/module/name_spec.rb b/spec/ruby/core/module/name_spec.rb index d3318e16451485..332c08d782ee31 100644 --- a/spec/ruby/core/module/name_spec.rb +++ b/spec/ruby/core/module/name_spec.rb @@ -3,7 +3,7 @@ describe "Module#name" do it "is nil for an anonymous module" do - Module.new.name.should be_nil + Module.new.name.should == nil end it "is not nil when assigned to a constant in an anonymous module" do @@ -19,9 +19,9 @@ module m::N; end end it "returns nil for a singleton class" do - Module.new.singleton_class.name.should be_nil - String.singleton_class.name.should be_nil - Object.new.singleton_class.name.should be_nil + Module.new.singleton_class.name.should == nil + String.singleton_class.name.should == nil + Object.new.singleton_class.name.should == nil end it "changes when the module is reachable through a constant path" do @@ -148,7 +148,7 @@ module ModuleSpecs::Anonymous "ModuleSpecs::Anonymous::StoredInMultiplePlaces::N", "ModuleSpecs::Anonymous::StoredInMultiplePlaces::O" ] - valid_names.should include(m::N.name) # You get one of the two, but you don't know which one. + valid_names.should.include?(m::N.name) # You get one of the two, but you don't know which one. ensure ModuleSpecs::Anonymous.send(:remove_const, :StoredInMultiplePlaces) end @@ -200,6 +200,6 @@ module self::B it "always returns the same String for a given Module" do s1 = ModuleSpecs.name s2 = ModuleSpecs.name - s1.should equal(s2) + s1.should.equal?(s2) end end diff --git a/spec/ruby/core/module/new_spec.rb b/spec/ruby/core/module/new_spec.rb index ec521360bd7f84..ec7a0cfa778086 100644 --- a/spec/ruby/core/module/new_spec.rb +++ b/spec/ruby/core/module/new_spec.rb @@ -7,7 +7,7 @@ end it "creates a module without a name" do - Module.new.name.should be_nil + Module.new.name.should == nil end it "creates a new Module and passes it to the provided block" do diff --git a/spec/ruby/core/module/prepend_features_spec.rb b/spec/ruby/core/module/prepend_features_spec.rb index 09c15c5c155c37..3a50f2c2a43687 100644 --- a/spec/ruby/core/module/prepend_features_spec.rb +++ b/spec/ruby/core/module/prepend_features_spec.rb @@ -3,7 +3,7 @@ describe "Module#prepend_features" do it "is a private method" do - Module.should have_private_instance_method(:prepend_features, true) + Module.private_instance_methods(false).should.include?(:prepend_features) end it "gets called when self is included in another module/class" do @@ -25,7 +25,7 @@ def self.prepend_features(mod) it "raises an ArgumentError on a cyclic prepend" do -> { ModuleSpecs::CyclicPrepend.send(:prepend_features, ModuleSpecs::CyclicPrepend) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "clears caches of the given module" do @@ -52,13 +52,13 @@ def foo; :fooo; end describe "on Class" do it "is undefined" do - Class.should_not have_private_instance_method(:prepend_features, true) + Class.private_instance_methods(true).should_not.include?(:prepend_features) end it "raises a TypeError if calling after rebinded to Class" do -> { Module.instance_method(:prepend_features).bind(Class.new).call Module.new - }.should raise_error(TypeError) + }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/module/prepend_spec.rb b/spec/ruby/core/module/prepend_spec.rb index 71e82c513ea169..f7887e6d6ab01a 100644 --- a/spec/ruby/core/module/prepend_spec.rb +++ b/spec/ruby/core/module/prepend_spec.rb @@ -3,7 +3,7 @@ describe "Module#prepend" do it "is a public method" do - Module.should have_public_instance_method(:prepend, false) + Module.public_instance_methods(false).should.include?(:prepend) end it "does not affect the superclass" do @@ -444,13 +444,13 @@ module M end it "raises a TypeError when the argument is not a Module" do - -> { ModuleSpecs::Basic.prepend(Class.new) }.should raise_error(TypeError) + -> { ModuleSpecs::Basic.prepend(Class.new) }.should.raise(TypeError) end it "does not raise a TypeError when the argument is an instance of a subclass of Module" do class ModuleSpecs::SubclassSpec::AClass end - -> { ModuleSpecs::SubclassSpec::AClass.prepend(ModuleSpecs::Subclass.new) }.should_not raise_error(TypeError) + -> { ModuleSpecs::SubclassSpec::AClass.prepend(ModuleSpecs::Subclass.new) }.should_not.raise(TypeError) ensure ModuleSpecs::SubclassSpec.send(:remove_const, :AClass) end @@ -464,22 +464,22 @@ class ModuleSpecs::SubclassSpec::AClass end end - -> { ModuleSpecs::Basic.prepend(refinement) }.should raise_error(TypeError, "Cannot prepend refinement") + -> { ModuleSpecs::Basic.prepend(refinement) }.should.raise(TypeError, "Cannot prepend refinement") end it "imports constants" do m1 = Module.new m1::MY_CONSTANT = 1 m2 = Module.new { prepend(m1) } - m2.constants.should include(:MY_CONSTANT) + m2.constants.should.include?(:MY_CONSTANT) end it "imports instance methods" do - Module.new { prepend ModuleSpecs::A }.instance_methods.should include(:ma) + Module.new { prepend ModuleSpecs::A }.instance_methods.should.include?(:ma) end it "does not import methods to modules and classes" do - Module.new { prepend ModuleSpecs::A }.methods.should_not include(:ma) + Module.new { prepend ModuleSpecs::A }.methods.should_not.include?(:ma) end it "allows wrapping methods" do @@ -505,7 +505,7 @@ class ModuleSpecs::SubclassSpec::AClass it "includes prepended modules in ancestors" do m = Module.new - Class.new { prepend(m) }.ancestors.should include(m) + Class.new { prepend(m) }.ancestors.should.include?(m) end it "reports the prepended module as the method owner" do @@ -542,13 +542,13 @@ class ModuleSpecs::SubclassSpec::AClass it "sees an instance of a prepended class as kind of the prepended module" do m = Module.new c = Class.new { prepend(m) } - c.new.should be_kind_of(m) + c.new.should.is_a?(m) end it "keeps the module in the chain when dupping the class" do m = Module.new c = Class.new { prepend(m) } - c.dup.new.should be_kind_of(m) + c.dup.new.should.is_a?(m) end it "uses only new module when dupping the module" do @@ -559,14 +559,14 @@ class ModuleSpecs::SubclassSpec::AClass m2dup.ancestors.should == [m1,m2dup] c2 = Class.new { prepend(m2dup) } c1.ancestors[0,3].should == [m1,m2,c1] - c1.new.should be_kind_of(m1) + c1.new.should.is_a?(m1) c2.ancestors[0,3].should == [m1,m2dup,c2] - c2.new.should be_kind_of(m1) + c2.new.should.is_a?(m1) end it "depends on prepend_features to add the module" do m = Module.new { def self.prepend_features(mod) end } - Class.new { prepend(m) }.ancestors.should_not include(m) + Class.new { prepend(m) }.ancestors.should_not.include?(m) end it "adds the module in the subclass chains" do @@ -627,7 +627,7 @@ def chain super << :class end end - -> { c.new.chain }.should raise_error(NoMethodError) + -> { c.new.chain }.should.raise(NoMethodError) end it "calls prepended after prepend_features" do @@ -663,7 +663,7 @@ class B < A; prepend M; end module ModuleSpecs::P prepend ModuleSpecs::P end - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "doesn't accept no-arguments" do @@ -671,7 +671,7 @@ module ModuleSpecs::P Module.new do prepend end - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "returns the class it's included into" do @@ -817,7 +817,7 @@ def foo; end pre = Module.new mod.prepend pre - cls.instance_methods.should include(:foo) + cls.instance_methods.should.include?(:foo) end end end diff --git a/spec/ruby/core/module/prepended_spec.rb b/spec/ruby/core/module/prepended_spec.rb index bd95d8fd051b30..ccd450d668f9a5 100644 --- a/spec/ruby/core/module/prepended_spec.rb +++ b/spec/ruby/core/module/prepended_spec.rb @@ -8,7 +8,7 @@ end it "is a private method" do - Module.should have_private_instance_method(:prepended, true) + Module.private_instance_methods(false).should.include?(:prepended) end it "is invoked when self is prepended to another module or class" do diff --git a/spec/ruby/core/module/private_class_method_spec.rb b/spec/ruby/core/module/private_class_method_spec.rb index f899c71a57e3ec..7ce07f160049ff 100644 --- a/spec/ruby/core/module/private_class_method_spec.rb +++ b/spec/ruby/core/module/private_class_method_spec.rb @@ -22,11 +22,11 @@ class << ModuleSpecs::Parent it "makes an existing class method private" do ModuleSpecs::Parent.private_method_1.should == nil ModuleSpecs::Parent.private_class_method :private_method_1 - -> { ModuleSpecs::Parent.private_method_1 }.should raise_error(NoMethodError) + -> { ModuleSpecs::Parent.private_method_1 }.should.raise(NoMethodError) # Technically above we're testing the Singleton classes, class method(right?). # Try a "real" class method set private. - -> { ModuleSpecs::Parent.private_method }.should raise_error(NoMethodError) + -> { ModuleSpecs::Parent.private_method }.should.raise(NoMethodError) end it "makes an existing class method private up the inheritance tree" do @@ -34,8 +34,8 @@ class << ModuleSpecs::Parent ModuleSpecs::Child.private_method_1.should == nil ModuleSpecs::Child.private_class_method :private_method_1 - -> { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError) - -> { ModuleSpecs::Child.private_method }.should raise_error(NoMethodError) + -> { ModuleSpecs::Child.private_method_1 }.should.raise(NoMethodError) + -> { ModuleSpecs::Child.private_method }.should.raise(NoMethodError) end it "accepts more than one method at a time" do @@ -44,14 +44,14 @@ class << ModuleSpecs::Parent ModuleSpecs::Child.private_class_method :private_method_1, :private_method_2 - -> { ModuleSpecs::Child.private_method_1 }.should raise_error(NoMethodError) - -> { ModuleSpecs::Child.private_method_2 }.should raise_error(NoMethodError) + -> { ModuleSpecs::Child.private_method_1 }.should.raise(NoMethodError) + -> { ModuleSpecs::Child.private_method_2 }.should.raise(NoMethodError) end it "raises a NameError if class method doesn't exist" do -> do ModuleSpecs.private_class_method :no_method_here - end.should raise_error(NameError) + end.should.raise(NameError) end it "makes a class method private" do @@ -59,7 +59,7 @@ class << ModuleSpecs::Parent def self.foo() "foo" end private_class_method :foo end - -> { c.foo }.should raise_error(NoMethodError) + -> { c.foo }.should.raise(NoMethodError) end it "raises a NameError when the given name is not a method" do @@ -67,7 +67,7 @@ def self.foo() "foo" end Class.new do private_class_method :foo end - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError when the given name is an instance method" do @@ -76,7 +76,7 @@ def self.foo() "foo" end def foo() "foo" end private_class_method :foo end - end.should raise_error(NameError) + end.should.raise(NameError) end context "when single argument is passed and is an array" do @@ -85,7 +85,7 @@ def foo() "foo" end def self.foo() "foo" end private_class_method [:foo] end - -> { c.foo }.should raise_error(NoMethodError) + -> { c.foo }.should.raise(NoMethodError) end end end diff --git a/spec/ruby/core/module/private_constant_spec.rb b/spec/ruby/core/module/private_constant_spec.rb index 3a91b3c3cda9c9..ca0df48c0b0444 100644 --- a/spec/ruby/core/module/private_constant_spec.rb +++ b/spec/ruby/core/module/private_constant_spec.rb @@ -8,7 +8,7 @@ -> do cls2.send :private_constant, :Foo - end.should raise_error(NameError) + end.should.raise(NameError) end it "accepts strings as constant names" do @@ -16,7 +16,7 @@ cls.const_set :Foo, true cls.send :private_constant, "Foo" - -> { cls::Foo }.should raise_error(NameError) + -> { cls::Foo }.should.raise(NameError) end it "accepts multiple names" do @@ -26,7 +26,7 @@ mod.send :private_constant, :Foo, :Bar - -> {mod::Foo}.should raise_error(NameError) - -> {mod::Bar}.should raise_error(NameError) + -> {mod::Foo}.should.raise(NameError) + -> {mod::Bar}.should.raise(NameError) end end diff --git a/spec/ruby/core/module/private_instance_methods_spec.rb b/spec/ruby/core/module/private_instance_methods_spec.rb index cce0f001bfbc20..ae0f21d1ddab0f 100644 --- a/spec/ruby/core/module/private_instance_methods_spec.rb +++ b/spec/ruby/core/module/private_instance_methods_spec.rb @@ -5,20 +5,20 @@ # TODO: rewrite describe "Module#private_instance_methods" do it "returns a list of private methods in module and its ancestors" do - ModuleSpecs::CountsMixin.should have_private_instance_method(:private_3) + ModuleSpecs::CountsMixin.private_instance_methods(false).should.include?(:private_3) - ModuleSpecs::CountsParent.should have_private_instance_method(:private_2) - ModuleSpecs::CountsParent.should have_private_instance_method(:private_3) + ModuleSpecs::CountsParent.private_instance_methods(false).should.include?(:private_2) + ModuleSpecs::CountsParent.private_instance_methods(true).should.include?(:private_3) - ModuleSpecs::CountsChild.should have_private_instance_method(:private_1) - ModuleSpecs::CountsChild.should have_private_instance_method(:private_2) - ModuleSpecs::CountsChild.should have_private_instance_method(:private_3) + ModuleSpecs::CountsChild.private_instance_methods(false).should.include?(:private_1) + ModuleSpecs::CountsChild.private_instance_methods(true).should.include?(:private_2) + ModuleSpecs::CountsChild.private_instance_methods(true).should.include?(:private_3) end it "when passed false as a parameter, should return only methods defined in that module" do - ModuleSpecs::CountsMixin.should have_private_instance_method(:private_3, false) - ModuleSpecs::CountsParent.should have_private_instance_method(:private_2, false) - ModuleSpecs::CountsChild.should have_private_instance_method(:private_1, false) + ModuleSpecs::CountsMixin.private_instance_methods(false).should.include?(:private_3) + ModuleSpecs::CountsParent.private_instance_methods(false).should.include?(:private_2) + ModuleSpecs::CountsChild.private_instance_methods(false).should.include?(:private_1) end it "default list should be the same as passing true as an argument" do diff --git a/spec/ruby/core/module/private_method_defined_spec.rb b/spec/ruby/core/module/private_method_defined_spec.rb index 01fc8f8fb99f5e..f730decc0a7da7 100644 --- a/spec/ruby/core/module/private_method_defined_spec.rb +++ b/spec/ruby/core/module/private_method_defined_spec.rb @@ -34,25 +34,25 @@ it "raises a TypeError if passed an Integer" do -> do ModuleSpecs::CountsMixin.private_method_defined?(1) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed nil" do -> do ModuleSpecs::CountsMixin.private_method_defined?(nil) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed false" do -> do ModuleSpecs::CountsMixin.private_method_defined?(false) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed an object that does not defined #to_str" do -> do ModuleSpecs::CountsMixin.private_method_defined?(mock('x')) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed an object that defines #to_sym" do @@ -61,7 +61,7 @@ def sym.to_sym() :private_3 end -> do ModuleSpecs::CountsMixin.private_method_defined?(sym) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "calls #to_str to convert an Object" do diff --git a/spec/ruby/core/module/private_spec.rb b/spec/ruby/core/module/private_spec.rb index 9e1a297eea1d64..e60fdb24ccd744 100644 --- a/spec/ruby/core/module/private_spec.rb +++ b/spec/ruby/core/module/private_spec.rb @@ -17,7 +17,7 @@ class << obj private :foo end - -> { obj.foo }.should raise_error(NoMethodError) + -> { obj.foo }.should.raise(NoMethodError) end it "makes a public Object instance method private in a new module" do @@ -25,33 +25,33 @@ class << obj private :module_specs_public_method_on_object end - m.should have_private_instance_method(:module_specs_public_method_on_object) + m.private_instance_methods(false).should.include?(:module_specs_public_method_on_object) # Ensure we did not change Object's method - Object.should_not have_private_instance_method(:module_specs_public_method_on_object) + Object.private_instance_methods(true).should_not.include?(:module_specs_public_method_on_object) end it "makes a public Object instance method private in Kernel" do - Kernel.should have_private_instance_method( + Kernel.private_instance_methods(false).should.include?( :module_specs_public_method_on_object_for_kernel_private) - Object.should_not have_private_instance_method( + Object.private_instance_methods(true).should_not.include?( :module_specs_public_method_on_object_for_kernel_private) end it "returns argument or arguments if given" do (class << Object.new; self; end).class_eval do def foo; end - private(:foo).should equal(:foo) + private(:foo).should.equal?(:foo) private([:foo, :foo]).should == [:foo, :foo] private(:foo, :foo).should == [:foo, :foo] - private.should equal(nil) + private.should.equal?(nil) end end it "raises a NameError when given an undefined name" do -> do Module.new.send(:private, :undefined) - end.should raise_error(NameError) + end.should.raise(NameError) end it "only makes the method private in the class it is called on" do @@ -71,7 +71,7 @@ def wrapped base.new.wrapped.should == 1 -> do klass.new.wrapped - end.should raise_error(NameError) + end.should.raise(NameError) end it "continues to allow a prepended module method to call super" do diff --git a/spec/ruby/core/module/protected_instance_methods_spec.rb b/spec/ruby/core/module/protected_instance_methods_spec.rb index 78ce7e788f43b4..ea7ded030ebcaf 100644 --- a/spec/ruby/core/module/protected_instance_methods_spec.rb +++ b/spec/ruby/core/module/protected_instance_methods_spec.rb @@ -6,16 +6,16 @@ describe "Module#protected_instance_methods" do it "returns a list of protected methods in module and its ancestors" do methods = ModuleSpecs::CountsMixin.protected_instance_methods - methods.should include(:protected_3) + methods.should.include?(:protected_3) methods = ModuleSpecs::CountsParent.protected_instance_methods - methods.should include(:protected_3) - methods.should include(:protected_2) + methods.should.include?(:protected_3) + methods.should.include?(:protected_2) methods = ModuleSpecs::CountsChild.protected_instance_methods - methods.should include(:protected_3) - methods.should include(:protected_2) - methods.should include(:protected_1) + methods.should.include?(:protected_3) + methods.should.include?(:protected_2) + methods.should.include?(:protected_1) end it "when passed false as a parameter, should return only methods defined in that module" do diff --git a/spec/ruby/core/module/protected_method_defined_spec.rb b/spec/ruby/core/module/protected_method_defined_spec.rb index 31e24a16c1cd9b..78ba120c2fb073 100644 --- a/spec/ruby/core/module/protected_method_defined_spec.rb +++ b/spec/ruby/core/module/protected_method_defined_spec.rb @@ -34,25 +34,25 @@ it "raises a TypeError if passed an Integer" do -> do ModuleSpecs::CountsMixin.protected_method_defined?(1) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed nil" do -> do ModuleSpecs::CountsMixin.protected_method_defined?(nil) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed false" do -> do ModuleSpecs::CountsMixin.protected_method_defined?(false) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed an object that does not defined #to_str" do -> do ModuleSpecs::CountsMixin.protected_method_defined?(mock('x')) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed an object that defines #to_sym" do @@ -61,7 +61,7 @@ def sym.to_sym() :protected_3 end -> do ModuleSpecs::CountsMixin.protected_method_defined?(sym) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "calls #to_str to convert an Object" do diff --git a/spec/ruby/core/module/protected_spec.rb b/spec/ruby/core/module/protected_spec.rb index 9e37223e18112b..3ef6c76fae7d91 100644 --- a/spec/ruby/core/module/protected_spec.rb +++ b/spec/ruby/core/module/protected_spec.rb @@ -18,7 +18,7 @@ class << ModuleSpecs::Parent protected :protected_method_1 end - -> { ModuleSpecs::Parent.protected_method_1 }.should raise_error(NoMethodError) + -> { ModuleSpecs::Parent.protected_method_1 }.should.raise(NoMethodError) end it "makes a public Object instance method protected in a new module" do @@ -26,32 +26,32 @@ class << ModuleSpecs::Parent protected :module_specs_public_method_on_object end - m.should have_protected_instance_method(:module_specs_public_method_on_object) + m.protected_instance_methods(false).should.include?(:module_specs_public_method_on_object) # Ensure we did not change Object's method - Object.should_not have_protected_instance_method(:module_specs_public_method_on_object) + Object.protected_instance_methods(true).should_not.include?(:module_specs_public_method_on_object) end it "makes a public Object instance method protected in Kernel" do - Kernel.should have_protected_instance_method( + Kernel.protected_instance_methods(false).should.include?( :module_specs_public_method_on_object_for_kernel_protected) - Object.should_not have_protected_instance_method( + Object.protected_instance_methods(true).should_not.include?( :module_specs_public_method_on_object_for_kernel_protected) end it "returns argument or arguments if given" do (class << Object.new; self; end).class_eval do def foo; end - protected(:foo).should equal(:foo) + protected(:foo).should.equal?(:foo) protected([:foo, :foo]).should == [:foo, :foo] protected(:foo, :foo).should == [:foo, :foo] - protected.should equal(nil) + protected.should.equal?(nil) end end it "raises a NameError when given an undefined name" do -> do Module.new.send(:protected, :undefined) - end.should raise_error(NameError) + end.should.raise(NameError) end end diff --git a/spec/ruby/core/module/public_class_method_spec.rb b/spec/ruby/core/module/public_class_method_spec.rb index 71b20acda50b8c..4aca4d431199f4 100644 --- a/spec/ruby/core/module/public_class_method_spec.rb +++ b/spec/ruby/core/module/public_class_method_spec.rb @@ -18,7 +18,7 @@ class << ModuleSpecs::Parent end it "makes an existing class method public" do - -> { ModuleSpecs::Parent.public_method_1 }.should raise_error(NoMethodError) + -> { ModuleSpecs::Parent.public_method_1 }.should.raise(NoMethodError) ModuleSpecs::Parent.public_class_method :public_method_1 ModuleSpecs::Parent.public_method_1.should == nil @@ -29,7 +29,7 @@ class << ModuleSpecs::Parent it "makes an existing class method public up the inheritance tree" do ModuleSpecs::Child.private_class_method :public_method_1 - -> { ModuleSpecs::Child.public_method_1 }.should raise_error(NoMethodError) + -> { ModuleSpecs::Child.public_method_1 }.should.raise(NoMethodError) ModuleSpecs::Child.public_class_method :public_method_1 ModuleSpecs::Child.public_method_1.should == nil @@ -37,8 +37,8 @@ class << ModuleSpecs::Parent end it "accepts more than one method at a time" do - -> { ModuleSpecs::Parent.public_method_1 }.should raise_error(NameError) - -> { ModuleSpecs::Parent.public_method_2 }.should raise_error(NameError) + -> { ModuleSpecs::Parent.public_method_1 }.should.raise(NameError) + -> { ModuleSpecs::Parent.public_method_2 }.should.raise(NameError) ModuleSpecs::Child.public_class_method :public_method_1, :public_method_2 @@ -49,7 +49,7 @@ class << ModuleSpecs::Parent it "raises a NameError if class method doesn't exist" do -> do ModuleSpecs.public_class_method :no_method_here - end.should raise_error(NameError) + end.should.raise(NameError) end it "makes a class method public" do @@ -66,7 +66,7 @@ def self.foo() "foo" end Class.new do public_class_method :foo end - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError when the given name is an instance method" do @@ -75,7 +75,7 @@ def self.foo() "foo" end def foo() "foo" end public_class_method :foo end - end.should raise_error(NameError) + end.should.raise(NameError) end context "when single argument is passed and is an array" do diff --git a/spec/ruby/core/module/public_constant_spec.rb b/spec/ruby/core/module/public_constant_spec.rb index e624d45fd22151..87a051f1250d77 100644 --- a/spec/ruby/core/module/public_constant_spec.rb +++ b/spec/ruby/core/module/public_constant_spec.rb @@ -8,7 +8,7 @@ -> do cls2.send :public_constant, :Foo - end.should raise_error(NameError) + end.should.raise(NameError) end it "accepts strings as constant names" do diff --git a/spec/ruby/core/module/public_instance_method_spec.rb b/spec/ruby/core/module/public_instance_method_spec.rb index ba19ad0404d0d0..87c1bae5995527 100644 --- a/spec/ruby/core/module/public_instance_method_spec.rb +++ b/spec/ruby/core/module/public_instance_method_spec.rb @@ -3,7 +3,7 @@ describe "Module#public_instance_method" do it "is a public method" do - Module.should have_public_instance_method(:public_instance_method, false) + Module.public_instance_methods(false).should.include?(:public_instance_method) end it "requires an argument" do @@ -13,12 +13,12 @@ describe "when given a public method name" do it "returns an UnboundMethod corresponding to the defined Module" do ret = ModuleSpecs::Super.public_instance_method(:public_module) - ret.should be_an_instance_of(UnboundMethod) - ret.owner.should equal(ModuleSpecs::Basic) + ret.should.instance_of?(UnboundMethod) + ret.owner.should.equal?(ModuleSpecs::Basic) ret = ModuleSpecs::Super.public_instance_method(:public_super_module) - ret.should be_an_instance_of(UnboundMethod) - ret.owner.should equal(ModuleSpecs::Super) + ret.should.instance_of?(UnboundMethod) + ret.owner.should.equal?(ModuleSpecs::Super) end it "accepts if the name is a Symbol or String" do @@ -28,31 +28,31 @@ end it "raises a TypeError when given a name is not Symbol or String" do - -> { Module.new.public_instance_method(nil) }.should raise_error(TypeError) + -> { Module.new.public_instance_method(nil) }.should.raise(TypeError) end it "raises a NameError when given a protected method name" do -> do ModuleSpecs::Basic.public_instance_method(:protected_module) - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError if the method is private" do -> do ModuleSpecs::Basic.public_instance_method(:private_module) - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError if the method has been undefined" do -> do ModuleSpecs::Parent.public_instance_method(:undefed_method) - end.should raise_error(NameError) + end.should.raise(NameError) end it "raises a NameError if the method does not exist" do -> do Module.new.public_instance_method(:missing) - end.should raise_error(NameError) + end.should.raise(NameError) end it "sets the NameError#name attribute to the name of the missing method" do diff --git a/spec/ruby/core/module/public_instance_methods_spec.rb b/spec/ruby/core/module/public_instance_methods_spec.rb index ae7d9b5ffb489e..edea00d9271269 100644 --- a/spec/ruby/core/module/public_instance_methods_spec.rb +++ b/spec/ruby/core/module/public_instance_methods_spec.rb @@ -7,19 +7,19 @@ describe "Module#public_instance_methods" do it "returns a list of public methods in module and its ancestors" do methods = ModuleSpecs::CountsMixin.public_instance_methods - methods.should include(:public_3) + methods.should.include?(:public_3) methods = ModuleSpecs::CountsParent.public_instance_methods - methods.should include(:public_3) - methods.should include(:public_2) + methods.should.include?(:public_3) + methods.should.include?(:public_2) methods = ModuleSpecs::CountsChild.public_instance_methods - methods.should include(:public_3) - methods.should include(:public_2) - methods.should include(:public_1) + methods.should.include?(:public_3) + methods.should.include?(:public_2) + methods.should.include?(:public_1) methods = ModuleSpecs::Child2.public_instance_methods - methods.should include(:foo) + methods.should.include?(:foo) end it "when passed false as a parameter, should return only methods defined in that module" do diff --git a/spec/ruby/core/module/public_method_defined_spec.rb b/spec/ruby/core/module/public_method_defined_spec.rb index 5c9bdf1ccc69a6..70cd9923581499 100644 --- a/spec/ruby/core/module/public_method_defined_spec.rb +++ b/spec/ruby/core/module/public_method_defined_spec.rb @@ -34,25 +34,25 @@ it "raises a TypeError if passed an Integer" do -> do ModuleSpecs::CountsMixin.public_method_defined?(1) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed nil" do -> do ModuleSpecs::CountsMixin.public_method_defined?(nil) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed false" do -> do ModuleSpecs::CountsMixin.public_method_defined?(false) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed an object that does not defined #to_str" do -> do ModuleSpecs::CountsMixin.public_method_defined?(mock('x')) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if passed an object that defines #to_sym" do @@ -61,7 +61,7 @@ def sym.to_sym() :public_3 end -> do ModuleSpecs::CountsMixin.public_method_defined?(sym) - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "calls #to_str to convert an Object" do diff --git a/spec/ruby/core/module/public_spec.rb b/spec/ruby/core/module/public_spec.rb index ce31eb5d0e7a6a..f35c64143b827a 100644 --- a/spec/ruby/core/module/public_spec.rb +++ b/spec/ruby/core/module/public_spec.rb @@ -14,32 +14,32 @@ public :module_specs_private_method_on_object end - m.should have_public_instance_method(:module_specs_private_method_on_object) + m.public_instance_methods(false).should.include?(:module_specs_private_method_on_object) # Ensure we did not change Object's method - Object.should_not have_public_instance_method(:module_specs_private_method_on_object) + Object.public_instance_methods(true).should_not.include?(:module_specs_private_method_on_object) end it "makes a private Object instance method public in Kernel" do - Kernel.should have_public_instance_method( + Kernel.public_instance_methods(false).should.include?( :module_specs_private_method_on_object_for_kernel_public) - Object.should_not have_public_instance_method( + Object.public_instance_methods(true).should_not.include?( :module_specs_private_method_on_object_for_kernel_public) end it "returns argument or arguments if given" do (class << Object.new; self; end).class_eval do def foo; end - public(:foo).should equal(:foo) + public(:foo).should.equal?(:foo) public([:foo, :foo]).should == [:foo, :foo] public(:foo, :foo).should == [:foo, :foo] - public.should equal(nil) + public.should.equal?(nil) end end it "raises a NameError when given an undefined name" do -> do Module.new.send(:public, :undefined) - end.should raise_error(NameError) + end.should.raise(NameError) end end diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb index d219b98825023f..d0fc7015f8b640 100644 --- a/spec/ruby/core/module/refine_spec.rb +++ b/spec/ruby/core/module/refine_spec.rb @@ -11,7 +11,7 @@ end mod.should_not == inner_self - inner_self.should be_kind_of(Module) + inner_self.should.is_a?(Module) inner_self.name.should == nil end @@ -43,7 +43,7 @@ def blah end end - inner_self.public_instance_methods.should include(:blah) + inner_self.public_instance_methods.should.include?(:blah) end it "returns created anonymous module" do @@ -63,7 +63,7 @@ def blah Module.new do refine {} end - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises TypeError if not passed a class" do @@ -71,7 +71,7 @@ def blah Module.new do refine("foo") {} end - end.should raise_error(TypeError, "wrong argument type String (expected Class or Module)") + end.should.raise(TypeError, "wrong argument type String (expected Class or Module)") end it "accepts a module as argument" do @@ -84,7 +84,7 @@ def blah end end - inner_self.public_instance_methods.should include(:blah) + inner_self.public_instance_methods.should.include?(:blah) end it "applies refinements to the module" do @@ -117,7 +117,7 @@ def result Module.new do refine String end - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "applies refinements to calls in the refine block" do @@ -136,7 +136,7 @@ def foo; "foo"; end refine(String) {def foo; "foo"; end} -> { "hello".foo - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end end @@ -145,7 +145,7 @@ def foo; "foo"; end refine(String) {def foo; 'foo'; end} end - -> {"hello".foo}.should raise_error(NoMethodError) + -> {"hello".foo}.should.raise(NoMethodError) end # When defining multiple refinements in the same module, @@ -209,7 +209,7 @@ def to_json_format [1, 2].to_json_format end - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end # method lookup: @@ -596,7 +596,7 @@ def bar using refinement_with_super -> { refined_class.new.bar - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end end end @@ -610,7 +610,7 @@ def bar } [1,2].orig_count.should == 2 end - -> { [1,2].orig_count }.should raise_error(NoMethodError) + -> { [1,2].orig_count }.should.raise(NoMethodError) end it 'and alias_method aliases a method within a refinement module, but not outside it' do @@ -622,7 +622,7 @@ def bar } [1,2].orig_count.should == 2 end - -> { [1,2].orig_count }.should raise_error(NoMethodError) + -> { [1,2].orig_count }.should.raise(NoMethodError) end it "and instance_methods returns a list of methods including those of the refined module" do @@ -704,11 +704,10 @@ def refinement_only_method end end end - spec = self - klass = Class.new { instance_methods.should_not spec.send(:include, :refinement_only_method) } + klass = Class.new { instance_methods.should_not.include?(:refinement_only_method) } instance = klass.new - instance.methods.should_not include :refinement_only_method + instance.methods.should_not.include? :refinement_only_method instance.respond_to?(:refinement_only_method).should == false - -> { instance.method :refinement_only_method }.should raise_error(NameError) + -> { instance.method :refinement_only_method }.should.raise(NameError) end end diff --git a/spec/ruby/core/module/remove_class_variable_spec.rb b/spec/ruby/core/module/remove_class_variable_spec.rb index ab9514adf66e8e..fccb29f52d12fc 100644 --- a/spec/ruby/core/module/remove_class_variable_spec.rb +++ b/spec/ruby/core/module/remove_class_variable_spec.rb @@ -18,27 +18,27 @@ meta = obj.singleton_class meta.send :class_variable_set, :@@var, 1 meta.send(:remove_class_variable, :@@var).should == 1 - meta.class_variable_defined?(:@@var).should be_false + meta.class_variable_defined?(:@@var).should == false end it "raises a NameError when removing class variable declared in included module" do c = ModuleSpecs::RemoveClassVariable.new { include ModuleSpecs::MVars.dup } - -> { c.send(:remove_class_variable, :@@mvar) }.should raise_error(NameError) + -> { c.send(:remove_class_variable, :@@mvar) }.should.raise(NameError) end it "raises a NameError when passed a symbol with one leading @" do - -> { ModuleSpecs::MVars.send(:remove_class_variable, :@mvar) }.should raise_error(NameError) + -> { ModuleSpecs::MVars.send(:remove_class_variable, :@mvar) }.should.raise(NameError) end it "raises a NameError when passed a symbol with no leading @" do - -> { ModuleSpecs::MVars.send(:remove_class_variable, :mvar) }.should raise_error(NameError) + -> { ModuleSpecs::MVars.send(:remove_class_variable, :mvar) }.should.raise(NameError) end it "raises a NameError when an uninitialized class variable is given" do - -> { ModuleSpecs::MVars.send(:remove_class_variable, :@@nonexisting_class_variable) }.should raise_error(NameError) + -> { ModuleSpecs::MVars.send(:remove_class_variable, :@@nonexisting_class_variable) }.should.raise(NameError) end it "is public" do - Module.should_not have_private_instance_method(:remove_class_variable) + Module.private_instance_methods(true).should_not.include?(:remove_class_variable) end end diff --git a/spec/ruby/core/module/remove_const_spec.rb b/spec/ruby/core/module/remove_const_spec.rb index 35a9d65105dc2d..4e4b9fcb45cd55 100644 --- a/spec/ruby/core/module/remove_const_spec.rb +++ b/spec/ruby/core/module/remove_const_spec.rb @@ -7,13 +7,13 @@ ConstantSpecs::ModuleM::CS_CONST252.should == :const252 ConstantSpecs::ModuleM.send :remove_const, :CS_CONST252 - -> { ConstantSpecs::ModuleM::CS_CONST252 }.should raise_error(NameError) + -> { ConstantSpecs::ModuleM::CS_CONST252 }.should.raise(NameError) ConstantSpecs::ModuleM::CS_CONST253 = :const253 ConstantSpecs::ModuleM::CS_CONST253.should == :const253 ConstantSpecs::ModuleM.send :remove_const, "CS_CONST253" - -> { ConstantSpecs::ModuleM::CS_CONST253 }.should raise_error(NameError) + -> { ConstantSpecs::ModuleM::CS_CONST253 }.should.raise(NameError) end it "returns the value of the removed constant" do @@ -23,7 +23,7 @@ it "raises a NameError and does not call #const_missing if the constant is not defined" do ConstantSpecs.should_not_receive(:const_missing) - -> { ConstantSpecs.send(:remove_const, :Nonexistent) }.should raise_error(NameError) + -> { ConstantSpecs.send(:remove_const, :Nonexistent) }.should.raise(NameError) end it "raises a NameError and does not call #const_missing if the constant is not defined directly in the module" do @@ -34,28 +34,28 @@ -> do ConstantSpecs::ContainerA.send :remove_const, :CS_CONST255 - end.should raise_error(NameError) + end.should.raise(NameError) ensure ConstantSpecs::ModuleM.send :remove_const, "CS_CONST255" end end it "raises a NameError if the name does not start with a capital letter" do - -> { ConstantSpecs.send :remove_const, "name" }.should raise_error(NameError) + -> { ConstantSpecs.send :remove_const, "name" }.should.raise(NameError) end it "raises a NameError if the name starts with a non-alphabetic character" do - -> { ConstantSpecs.send :remove_const, "__CONSTX__" }.should raise_error(NameError) - -> { ConstantSpecs.send :remove_const, "@Name" }.should raise_error(NameError) - -> { ConstantSpecs.send :remove_const, "!Name" }.should raise_error(NameError) - -> { ConstantSpecs.send :remove_const, "::Name" }.should raise_error(NameError) + -> { ConstantSpecs.send :remove_const, "__CONSTX__" }.should.raise(NameError) + -> { ConstantSpecs.send :remove_const, "@Name" }.should.raise(NameError) + -> { ConstantSpecs.send :remove_const, "!Name" }.should.raise(NameError) + -> { ConstantSpecs.send :remove_const, "::Name" }.should.raise(NameError) end it "raises a NameError if the name contains non-alphabetic characters except '_'" do ConstantSpecs::ModuleM::CS_CONST256 = :const256 ConstantSpecs::ModuleM.send :remove_const, "CS_CONST256" - -> { ConstantSpecs.send :remove_const, "Name=" }.should raise_error(NameError) - -> { ConstantSpecs.send :remove_const, "Name?" }.should raise_error(NameError) + -> { ConstantSpecs.send :remove_const, "Name=" }.should.raise(NameError) + -> { ConstantSpecs.send :remove_const, "Name?" }.should.raise(NameError) end it "calls #to_str to convert the given name to a String" do @@ -67,19 +67,19 @@ it "raises a TypeError if conversion to a String by calling #to_str fails" do name = mock('123') - -> { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError) + -> { ConstantSpecs.send :remove_const, name }.should.raise(TypeError) name.should_receive(:to_str).and_return(123) - -> { ConstantSpecs.send :remove_const, name }.should raise_error(TypeError) + -> { ConstantSpecs.send :remove_const, name }.should.raise(TypeError) end it "is a private method" do - Module.private_methods.should include(:remove_const) + Module.private_methods.should.include?(:remove_const) end it "returns nil when removing autoloaded constant" do ConstantSpecs.autoload :AutoloadedConstant, 'a_file' - ConstantSpecs.send(:remove_const, :AutoloadedConstant).should be_nil + ConstantSpecs.send(:remove_const, :AutoloadedConstant).should == nil end it "updates the constant value" do diff --git a/spec/ruby/core/module/remove_method_spec.rb b/spec/ruby/core/module/remove_method_spec.rb index 94b255df620856..39add01e360b40 100644 --- a/spec/ruby/core/module/remove_method_spec.rb +++ b/spec/ruby/core/module/remove_method_spec.rb @@ -21,7 +21,7 @@ def method_to_remove; 2; end end it "is a public method" do - Module.should have_public_instance_method(:remove_method, false) + Module.public_instance_methods(false).should.include?(:remove_method) end it "removes the method from a class" do @@ -88,14 +88,14 @@ def method_to_remove_2; 2; end end it "returns self" do - @module.send(:remove_method, :method_to_remove).should equal(@module) + @module.send(:remove_method, :method_to_remove).should.equal?(@module) end it "raises a NameError when attempting to remove method further up the inheritance tree" do Class.new(ModuleSpecs::Second) do -> { remove_method :method_to_remove - }.should raise_error(NameError) + }.should.raise(NameError) end end @@ -103,7 +103,7 @@ def method_to_remove_2; 2; end Class.new(ModuleSpecs::Second) do -> { remove_method :blah - }.should raise_error(NameError) + }.should.raise(NameError) end end @@ -113,19 +113,19 @@ def method_to_remove_2; 2; end end it "raises a FrozenError when passed a name" do - -> { @frozen.send :remove_method, :method_to_remove }.should raise_error(FrozenError) + -> { @frozen.send :remove_method, :method_to_remove }.should.raise(FrozenError) end it "raises a FrozenError when passed a missing name" do - -> { @frozen.send :remove_method, :not_exist }.should raise_error(FrozenError) + -> { @frozen.send :remove_method, :not_exist }.should.raise(FrozenError) end it "raises a TypeError when passed a not name" do - -> { @frozen.send :remove_method, Object.new }.should raise_error(TypeError) + -> { @frozen.send :remove_method, Object.new }.should.raise(TypeError) end it "does not raise exceptions when no arguments given" do - @frozen.send(:remove_method).should equal(@frozen) + @frozen.send(:remove_method).should.equal?(@frozen) end end end diff --git a/spec/ruby/core/module/ruby2_keywords_spec.rb b/spec/ruby/core/module/ruby2_keywords_spec.rb index 652f9f70839643..e3926429784013 100644 --- a/spec/ruby/core/module/ruby2_keywords_spec.rb +++ b/spec/ruby/core/module/ruby2_keywords_spec.rb @@ -175,7 +175,7 @@ def foo(*a) end obj.singleton_class.class_exec do ruby2_keywords :not_existing end - }.should raise_error(NameError, /undefined method [`']not_existing'/) + }.should.raise(NameError, /undefined method [`']not_existing'/) end it "accepts String as well" do @@ -197,7 +197,7 @@ def foo(*a) a.last end obj.singleton_class.class_exec do ruby2_keywords Object.new end - }.should raise_error(TypeError, /is not a symbol nor a string/) + }.should.raise(TypeError, /is not a symbol nor a string/) end it "prints warning when a method does not accept argument splat" do diff --git a/spec/ruby/core/module/set_temporary_name_spec.rb b/spec/ruby/core/module/set_temporary_name_spec.rb index 0b96b869c90c51..7c159121fae7e6 100644 --- a/spec/ruby/core/module/set_temporary_name_spec.rb +++ b/spec/ruby/core/module/set_temporary_name_spec.rb @@ -4,13 +4,13 @@ describe "Module#set_temporary_name" do it "can assign a temporary name" do m = Module.new - m.name.should be_nil + m.name.should == nil m.set_temporary_name("fake_name") m.name.should == "fake_name" m.set_temporary_name(nil) - m.name.should be_nil + m.name.should == nil end it "returns self" do @@ -45,23 +45,23 @@ it "can't assign empty string as name" do m = Module.new - -> { m.set_temporary_name("") }.should raise_error(ArgumentError, "empty class/module name") + -> { m.set_temporary_name("") }.should.raise(ArgumentError, "empty class/module name") end it "can't assign a constant name as a temporary name" do m = Module.new - -> { m.set_temporary_name("Object") }.should raise_error(ArgumentError, "the temporary name must not be a constant path to avoid confusion") + -> { m.set_temporary_name("Object") }.should.raise(ArgumentError, "the temporary name must not be a constant path to avoid confusion") end it "can't assign a constant path as a temporary name" do m = Module.new - -> { m.set_temporary_name("A::B") }.should raise_error(ArgumentError, "the temporary name must not be a constant path to avoid confusion") - -> { m.set_temporary_name("::A") }.should raise_error(ArgumentError, "the temporary name must not be a constant path to avoid confusion") - -> { m.set_temporary_name("::A::B") }.should raise_error(ArgumentError, "the temporary name must not be a constant path to avoid confusion") + -> { m.set_temporary_name("A::B") }.should.raise(ArgumentError, "the temporary name must not be a constant path to avoid confusion") + -> { m.set_temporary_name("::A") }.should.raise(ArgumentError, "the temporary name must not be a constant path to avoid confusion") + -> { m.set_temporary_name("::A::B") }.should.raise(ArgumentError, "the temporary name must not be a constant path to avoid confusion") end it "can't assign name to permanent module" do - -> { Object.set_temporary_name("fake_name") }.should raise_error(RuntimeError, "can't change permanent name") + -> { Object.set_temporary_name("fake_name") }.should.raise(RuntimeError, "can't change permanent name") end it "can assign a temporary name to a module nested into an anonymous module" do @@ -73,7 +73,7 @@ module m::N; end m::N.name.should == "fake_name" m::N.set_temporary_name(nil) - m::N.name.should be_nil + m::N.name.should == nil end it "discards a temporary name when an outer anonymous module gets a permanent name" do diff --git a/spec/ruby/core/module/shared/class_eval.rb b/spec/ruby/core/module/shared/class_eval.rb index b6e653a2acbf54..ee2860449ae8d2 100644 --- a/spec/ruby/core/module/shared/class_eval.rb +++ b/spec/ruby/core/module/shared/class_eval.rb @@ -14,7 +14,7 @@ def foo 'foo' end end - -> {42.foo}.should raise_error(NoMethodError) + -> {42.foo}.should.raise(NoMethodError) end it "resolves constants in the caller scope" do @@ -45,7 +45,7 @@ def foo ModuleSpecs.send(@method) do |block_parameter| given = block_parameter end - given.should equal ModuleSpecs + given.should.equal? ModuleSpecs end it "uses the optional filename and lineno parameters for error messages" do @@ -82,26 +82,26 @@ def foo it "raises a TypeError when the given eval-string can't be converted to string using to_str" do o = mock('x') - -> { ModuleSpecs.send(@method, o) }.should raise_error(TypeError, "no implicit conversion of MockObject into String") + -> { ModuleSpecs.send(@method, o) }.should.raise(TypeError, "no implicit conversion of MockObject into String") (o = mock('123')).should_receive(:to_str).and_return(123) -> { ModuleSpecs.send(@method, o) }.should raise_consistent_error(TypeError, /can't convert MockObject into String/) end it "raises an ArgumentError when no arguments and no block are given" do - -> { ModuleSpecs.send(@method) }.should raise_error(ArgumentError, "wrong number of arguments (given 0, expected 1..3)") + -> { ModuleSpecs.send(@method) }.should.raise(ArgumentError, "wrong number of arguments (given 0, expected 1..3)") end it "raises an ArgumentError when more than 3 arguments are given" do -> { ModuleSpecs.send(@method, "1 + 1", "some file", 0, "bogus") - }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") + }.should.raise(ArgumentError, "wrong number of arguments (given 4, expected 1..3)") end it "raises an ArgumentError when a block and normal arguments are given" do -> { ModuleSpecs.send(@method, "1 + 1") { 1 + 1 } - }.should raise_error(ArgumentError, "wrong number of arguments (given 1, expected 0)") + }.should.raise(ArgumentError, "wrong number of arguments (given 1, expected 0)") end # This case was found because Rubinius was caching the compiled diff --git a/spec/ruby/core/module/shared/class_exec.rb b/spec/ruby/core/module/shared/class_exec.rb index c7a9e5297f5140..e51af1966dd328 100644 --- a/spec/ruby/core/module/shared/class_exec.rb +++ b/spec/ruby/core/module/shared/class_exec.rb @@ -5,7 +5,7 @@ def foo 'foo' end end - -> {42.foo}.should raise_error(NoMethodError) + -> {42.foo}.should.raise(NoMethodError) end it "defines method in the receiver's scope" do @@ -19,11 +19,17 @@ def foo end it "raises a LocalJumpError when no block is given" do - -> { ModuleSpecs::Subclass.send(@method) }.should raise_error(LocalJumpError) + -> { ModuleSpecs::Subclass.send(@method) }.should.raise(LocalJumpError) end it "passes arguments to the block" do a = ModuleSpecs::Subclass - a.send(@method, 1) { |b| b }.should equal(1) + a.send(@method, 1) { |b| b }.should.equal?(1) + end + + describe "with optional argument" do + it "does not destructure a single array argument" do + ModuleSpecs::Subclass.send(@method, [1, 2, 3]) { |a = 99| a }.should == [1, 2, 3] + end end end diff --git a/spec/ruby/core/module/shared/set_visibility.rb b/spec/ruby/core/module/shared/set_visibility.rb index a1586dd2bda75b..38cc2ad260d758 100644 --- a/spec/ruby/core/module/shared/set_visibility.rb +++ b/spec/ruby/core/module/shared/set_visibility.rb @@ -2,7 +2,7 @@ describe :set_visibility, shared: true do it "is a private method" do - Module.should have_private_instance_method(@method, false) + Module.private_instance_methods(false).should.include?(@method) end describe "with argument" do @@ -17,8 +17,8 @@ def test1() end def test2() end send visibility, :test1, :test2 } - mod.should send(:"have_#{visibility}_instance_method", :test1, false) - mod.should send(:"have_#{visibility}_instance_method", :test2, false) + mod.send(:"#{visibility}_instance_methods", false).should.include?(:test1) + mod.send(:"#{visibility}_instance_methods", false).should.include?(:test2) end end @@ -33,8 +33,8 @@ def test1() end def test2() end send visibility, [:test1, :test2] } - mod.should send(:"have_#{visibility}_instance_method", :test1, false) - mod.should send(:"have_#{visibility}_instance_method", :test2, false) + mod.send(:"#{visibility}_instance_methods", false).should.include?(:test1) + mod.send(:"#{visibility}_instance_methods", false).should.include?(:test2) end end @@ -50,7 +50,7 @@ def test_method; end send(visibility, :test_method) } - child.should_not send(:"have_#{visibility}_instance_method", :test_method, false) + child.send(:"#{visibility}_instance_methods", false).should_not.include?(:test_method) end end @@ -64,8 +64,8 @@ def test1() end def test2() end } - mod.should send(:"have_#{@method}_instance_method", :test1, false) - mod.should send(:"have_#{@method}_instance_method", :test2, false) + mod.send(:"#{@method}_instance_methods", false).should.include?(:test1) + mod.send(:"#{@method}_instance_methods", false).should.include?(:test2) end it "stops setting visibility if the body encounters other visibility setters without arguments" do @@ -78,7 +78,7 @@ def test2() end def test1() end } - mod.should send(:"have_#{new_visibility}_instance_method", :test1, false) + mod.send(:"#{new_visibility}_instance_methods", false).should.include?(:test1) end it "continues setting visibility if the body encounters other visibility setters with arguments" do @@ -90,7 +90,7 @@ def test1() end def test2() end } - mod.should send(:"have_#{@method}_instance_method", :test2, false) + mod.send(:"#{@method}_instance_methods", false).should.include?(:test2) end it "does not affect module_evaled method definitions when itself is outside the eval" do @@ -102,8 +102,8 @@ def test2() end module_eval " def test2() end " } - mod.should have_public_instance_method(:test1, false) - mod.should have_public_instance_method(:test2, false) + mod.public_instance_methods(false).should.include?(:test1) + mod.public_instance_methods(false).should.include?(:test2) end it "does not affect outside method definitions when itself is inside a module_eval" do @@ -114,7 +114,7 @@ def test2() end def test1() end } - mod.should have_public_instance_method(:test1, false) + mod.public_instance_methods(false).should.include?(:test1) end it "affects normally if itself and method definitions are inside a module_eval" do @@ -127,7 +127,7 @@ def test1() end } } - mod.should send(:"have_#{@method}_instance_method", :test1, false) + mod.send(:"#{@method}_instance_methods", false).should.include?(:test1) end it "does not affect method definitions when itself is inside an eval and method definitions are outside" do @@ -140,7 +140,7 @@ def test1() end def test1() end } - mod.should send(:"have_#{initialized_visibility}_instance_method", :test1, false) + mod.send(:"#{initialized_visibility}_instance_methods", false).should.include?(:test1) end it "affects evaled method definitions when itself is outside the eval" do @@ -151,7 +151,7 @@ def test1() end eval "def test1() end" } - mod.should send(:"have_#{@method}_instance_method", :test1, false) + mod.send(:"#{@method}_instance_methods", false).should.include?(:test1) end it "affects normally if itself and following method definitions are inside a eval" do @@ -164,7 +164,7 @@ def test1() end CODE } - mod.should send(:"have_#{@method}_instance_method", :test1, false) + mod.send(:"#{@method}_instance_methods", false).should.include?(:test1) end describe "within a closure" do @@ -177,7 +177,7 @@ def test1() end def test1() end } - mod.should send(:"have_#{@method}_instance_method", :test1, false) + mod.send(:"#{@method}_instance_methods", false).should.include?(:test1) end end end diff --git a/spec/ruby/core/module/undef_method_spec.rb b/spec/ruby/core/module/undef_method_spec.rb index d4efcd51cbe411..d77640cb7e6d88 100644 --- a/spec/ruby/core/module/undef_method_spec.rb +++ b/spec/ruby/core/module/undef_method_spec.rb @@ -19,7 +19,7 @@ def another_method_to_undef() 1 end end it "is a public method" do - Module.should have_public_instance_method(:undef_method, false) + Module.public_instance_methods(false).should.include?(:undef_method) end it "requires multiple arguments" do @@ -34,8 +34,8 @@ def another_method_to_undef() 1 end x = klass.new klass.send(:undef_method, :method_to_undef, :another_method_to_undef) - -> { x.method_to_undef }.should raise_error(NoMethodError) - -> { x.another_method_to_undef }.should raise_error(NoMethodError) + -> { x.method_to_undef }.should.raise(NoMethodError) + -> { x.another_method_to_undef }.should.raise(NoMethodError) end it "does not undef any instance methods when argument not given" do @@ -46,11 +46,11 @@ def another_method_to_undef() 1 end end it "returns self" do - @module.send(:undef_method, :method_to_undef).should equal(@module) + @module.send(:undef_method, :method_to_undef).should.equal?(@module) end it "raises a NameError when passed a missing name for a module" do - -> { @module.send :undef_method, :not_exist }.should raise_error(NameError, /undefined method [`']not_exist' for module [`']#{@module}'/) { |e| + -> { @module.send :undef_method, :not_exist }.should.raise(NameError, /undefined method [`']not_exist' for module [`']#{@module}'/) { |e| # a NameError and not a NoMethodError e.class.should == NameError } @@ -58,7 +58,7 @@ def another_method_to_undef() 1 end it "raises a NameError when passed a missing name for a class" do klass = Class.new - -> { klass.send :undef_method, :not_exist }.should raise_error(NameError, /undefined method [`']not_exist' for class [`']#{klass}'/) { |e| + -> { klass.send :undef_method, :not_exist }.should.raise(NameError, /undefined method [`']not_exist' for class [`']#{klass}'/) { |e| # a NameError and not a NoMethodError e.class.should == NameError } @@ -69,7 +69,7 @@ def another_method_to_undef() 1 end obj = klass.new sclass = obj.singleton_class - -> { sclass.send :undef_method, :not_exist }.should raise_error(NameError, /undefined method [`']not_exist' for class [`']#{sclass}'/) { |e| + -> { sclass.send :undef_method, :not_exist }.should.raise(NameError, /undefined method [`']not_exist' for class [`']#{sclass}'/) { |e| e.message.should =~ /[`']# { klass.send :undef_method, :not_exist }.should raise_error(NameError, /undefined method [`']not_exist' for class [`']String'/) { |e| + -> { klass.send :undef_method, :not_exist }.should.raise(NameError, /undefined method [`']not_exist' for class [`']String'/) { |e| # a NameError and not a NoMethodError e.class.should == NameError } @@ -91,19 +91,19 @@ def another_method_to_undef() 1 end end it "raises a FrozenError when passed a name" do - -> { @frozen.send :undef_method, :method_to_undef }.should raise_error(FrozenError) + -> { @frozen.send :undef_method, :method_to_undef }.should.raise(FrozenError) end it "raises a FrozenError when passed a missing name" do - -> { @frozen.send :undef_method, :not_exist }.should raise_error(FrozenError) + -> { @frozen.send :undef_method, :not_exist }.should.raise(FrozenError) end it "raises a TypeError when passed a not name" do - -> { @frozen.send :undef_method, Object.new }.should raise_error(TypeError) + -> { @frozen.send :undef_method, Object.new }.should.raise(TypeError) end it "does not raise exceptions when no arguments given" do - @frozen.send(:undef_method).should equal(@frozen) + @frozen.send(:undef_method).should.equal?(@frozen) end end end @@ -120,7 +120,7 @@ def another_method_to_undef() 1 end klass.send :undef_method, :method_to_undef - -> { x.method_to_undef }.should raise_error(NoMethodError) + -> { x.method_to_undef }.should.raise(NoMethodError) end it "removes a method defined in a super class" do @@ -130,7 +130,7 @@ def another_method_to_undef() 1 end child_class.send :undef_method, :method_to_undef - -> { child.method_to_undef }.should raise_error(NoMethodError) + -> { child.method_to_undef }.should.raise(NoMethodError) end it "does not remove a method defined in a super class when removed from a subclass" do @@ -156,7 +156,7 @@ def another_method_to_undef() 1 end klass.send :undef_method, 'another_method_to_undef' - -> { x.another_method_to_undef }.should raise_error(NoMethodError) + -> { x.another_method_to_undef }.should.raise(NoMethodError) end it "removes a method defined in a super class" do @@ -166,7 +166,7 @@ def another_method_to_undef() 1 end child_class.send :undef_method, 'another_method_to_undef' - -> { child.another_method_to_undef }.should raise_error(NoMethodError) + -> { child.another_method_to_undef }.should.raise(NoMethodError) end it "does not remove a method defined in a super class when removed from a subclass" do diff --git a/spec/ruby/core/module/undefined_instance_methods_spec.rb b/spec/ruby/core/module/undefined_instance_methods_spec.rb index d33ee93fc11177..9f731c6adfd62a 100644 --- a/spec/ruby/core/module/undefined_instance_methods_spec.rb +++ b/spec/ruby/core/module/undefined_instance_methods_spec.rb @@ -9,16 +9,17 @@ it "returns inherited methods undefined in the class" do methods = ModuleSpecs::UndefinedInstanceMethods::Child.undefined_instance_methods - methods.should include(:parent_method, :another_parent_method) + methods.to_set.should >= Set[:parent_method, :another_parent_method] end it "returns methods from an included module that are undefined in the class" do methods = ModuleSpecs::UndefinedInstanceMethods::Grandchild.undefined_instance_methods - methods.should include(:super_included_method) + methods.should.include?(:super_included_method) end it "does not returns ancestors undefined methods" do methods = ModuleSpecs::UndefinedInstanceMethods::Grandchild.undefined_instance_methods - methods.should_not include(:parent_method, :another_parent_method) + methods.should_not.include?(:parent_method) + methods.should_not.include?(:another_parent_method) end end diff --git a/spec/ruby/core/module/using_spec.rb b/spec/ruby/core/module/using_spec.rb index a908363c960114..cff0edef284869 100644 --- a/spec/ruby/core/module/using_spec.rb +++ b/spec/ruby/core/module/using_spec.rb @@ -28,7 +28,7 @@ def foo; "foo"; end Module.new do using refinement end - }.should_not raise_error + }.should_not.raise end it "accepts module without refinements" do @@ -38,7 +38,7 @@ def foo; "foo"; end Module.new do using mod end - }.should_not raise_error + }.should_not.raise end it "does not accept class" do @@ -48,7 +48,7 @@ def foo; "foo"; end Module.new do using klass end - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises TypeError if passed something other than module" do @@ -56,7 +56,7 @@ def foo; "foo"; end Module.new do using "foo" end - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "returns self" do @@ -67,7 +67,7 @@ def foo; "foo"; end result = using refinement end - result.should equal(mod) + result.should.equal?(mod) end it "works in classes too" do @@ -95,7 +95,7 @@ def self.foo -> { mod.foo - }.should raise_error(RuntimeError, /Module#using is not permitted in methods/) + }.should.raise(RuntimeError, /Module#using is not permitted in methods/) end it "activates refinement even for existed objects" do diff --git a/spec/ruby/core/mutex/lock_spec.rb b/spec/ruby/core/mutex/lock_spec.rb index c1501e8ec26865..4fee29091aaa6b 100644 --- a/spec/ruby/core/mutex/lock_spec.rb +++ b/spec/ruby/core/mutex/lock_spec.rb @@ -25,7 +25,7 @@ m.lock -> { m.lock - }.should raise_error(ThreadError, /deadlock/) + }.should.raise(ThreadError, /deadlock/) end it "raises a deadlock ThreadError when multiple fibers from the same thread try to lock" do @@ -35,7 +35,7 @@ f0 = Fiber.new do m.lock end - -> { f0.resume }.should raise_error(ThreadError, /deadlock/) + -> { f0.resume }.should.raise(ThreadError, /deadlock/) m.unlock f1 = Fiber.new do @@ -46,7 +46,7 @@ m.lock end f1.resume - -> { f2.resume }.should raise_error(ThreadError, /deadlock/) + -> { f2.resume }.should.raise(ThreadError, /deadlock/) end it "does not raise deadlock if a fiber's attempt to lock was interrupted" do @@ -75,7 +75,7 @@ Fiber.new do -> do lock.synchronize {} - end.should_not raise_error(ThreadError) + end.should_not.raise(ThreadError) end.resume rescue RuntimeError retry diff --git a/spec/ruby/core/mutex/locked_spec.rb b/spec/ruby/core/mutex/locked_spec.rb index 1bf3ed63943b63..1818cdb4f3c836 100644 --- a/spec/ruby/core/mutex/locked_spec.rb +++ b/spec/ruby/core/mutex/locked_spec.rb @@ -4,12 +4,12 @@ it "returns true if locked" do m = Mutex.new m.lock - m.locked?.should be_true + m.locked?.should == true end it "returns false if unlocked" do m = Mutex.new - m.locked?.should be_false + m.locked?.should == false end it "returns the status of the lock" do @@ -27,10 +27,10 @@ Thread.pass until m1_locked - m1.locked?.should be_true + m1.locked?.should == true m2.unlock # release th th.join # A Thread releases its locks upon termination - m1.locked?.should be_false + m1.locked?.should == false end end diff --git a/spec/ruby/core/mutex/owned_spec.rb b/spec/ruby/core/mutex/owned_spec.rb index 7bfc7d8f833081..ea7d5faf1c11c4 100644 --- a/spec/ruby/core/mutex/owned_spec.rb +++ b/spec/ruby/core/mutex/owned_spec.rb @@ -4,7 +4,7 @@ describe "when unlocked" do it "returns false" do m = Mutex.new - m.owned?.should be_false + m.owned?.should == false end end @@ -12,7 +12,7 @@ it "returns true" do m = Mutex.new m.lock - m.owned?.should be_true + m.owned?.should == true end end @@ -37,7 +37,7 @@ end Thread.pass until locked - m.owned?.should be_false + m.owned?.should == false end end diff --git a/spec/ruby/core/mutex/sleep_spec.rb b/spec/ruby/core/mutex/sleep_spec.rb index 9832e3125e25de..a78e4c4b623db8 100644 --- a/spec/ruby/core/mutex/sleep_spec.rb +++ b/spec/ruby/core/mutex/sleep_spec.rb @@ -4,21 +4,21 @@ describe "when not locked by the current thread" do it "raises a ThreadError" do m = Mutex.new - -> { m.sleep }.should raise_error(ThreadError) + -> { m.sleep }.should.raise(ThreadError) end it "raises an ArgumentError if passed a negative duration" do m = Mutex.new - -> { m.sleep(-0.1) }.should raise_error(ArgumentError) - -> { m.sleep(-1) }.should raise_error(ArgumentError) + -> { m.sleep(-0.1) }.should.raise(ArgumentError) + -> { m.sleep(-1) }.should.raise(ArgumentError) end end it "raises an ArgumentError if passed a negative duration" do m = Mutex.new m.lock - -> { m.sleep(-0.1) }.should raise_error(ArgumentError) - -> { m.sleep(-1) }.should raise_error(ArgumentError) + -> { m.sleep(-0.1) }.should.raise(ArgumentError) + -> { m.sleep(-1) }.should.raise(ArgumentError) end it "pauses execution for approximately the duration requested" do @@ -38,7 +38,7 @@ th = Thread.new { m.lock; locked = true; m.sleep } Thread.pass until locked Thread.pass until th.stop? - m.locked?.should be_false + m.locked?.should == false th.run th.join end @@ -47,7 +47,7 @@ m = Mutex.new m.lock m.sleep(0.001) - m.locked?.should be_true + m.locked?.should == true end it "relocks the mutex when woken by an exception being raised" do @@ -65,7 +65,7 @@ Thread.pass until locked Thread.pass until th.stop? th.raise(Exception) - th.value.should be_true + th.value.should == true end it "returns the rounded number of seconds asleep" do @@ -79,7 +79,7 @@ Thread.pass until locked Thread.pass until th.stop? th.wakeup - th.value.should be_kind_of(Integer) + th.value.should.is_a?(Integer) end it "wakes up when requesting sleep times near or equal to zero" do @@ -97,7 +97,7 @@ m.lock times.each do |time| # just testing that sleep completes - -> {m.sleep(time)}.should_not raise_error + -> {m.sleep(time)}.should_not.raise end end end diff --git a/spec/ruby/core/mutex/synchronize_spec.rb b/spec/ruby/core/mutex/synchronize_spec.rb index 7942885197c98f..823f29a6342f20 100644 --- a/spec/ruby/core/mutex/synchronize_spec.rb +++ b/spec/ruby/core/mutex/synchronize_spec.rb @@ -14,15 +14,15 @@ m2.lock raise Exception end - end.should raise_error(Exception) + end.should.raise(Exception) end Thread.pass until synchronized - m1.locked?.should be_true + m1.locked?.should == true m2.unlock th.join - m1.locked?.should be_false + m1.locked?.should == false end it "blocks the caller if already locked" do @@ -60,7 +60,7 @@ m = Mutex.new m.synchronize do - -> { m.synchronize { } }.should raise_error(ThreadError) + -> { m.synchronize { } }.should.raise(ThreadError) end end end diff --git a/spec/ruby/core/mutex/try_lock_spec.rb b/spec/ruby/core/mutex/try_lock_spec.rb index 8d521f4c6b765b..1da0735d6a415b 100644 --- a/spec/ruby/core/mutex/try_lock_spec.rb +++ b/spec/ruby/core/mutex/try_lock_spec.rb @@ -4,13 +4,13 @@ describe "when unlocked" do it "returns true" do m = Mutex.new - m.try_lock.should be_true + m.try_lock.should == true end it "locks the mutex" do m = Mutex.new m.try_lock - m.locked?.should be_true + m.locked?.should == true end end @@ -18,7 +18,7 @@ it "returns false" do m = Mutex.new m.lock - m.try_lock.should be_false + m.try_lock.should == false end end @@ -26,7 +26,7 @@ it "returns false" do m = Mutex.new m.lock - Thread.new { m.try_lock }.value.should be_false + Thread.new { m.try_lock }.value.should == false end end end diff --git a/spec/ruby/core/mutex/unlock_spec.rb b/spec/ruby/core/mutex/unlock_spec.rb index d999e6684260c2..ed493cf84a5b58 100644 --- a/spec/ruby/core/mutex/unlock_spec.rb +++ b/spec/ruby/core/mutex/unlock_spec.rb @@ -3,7 +3,7 @@ describe "Mutex#unlock" do it "raises ThreadError unless Mutex is locked" do mutex = Mutex.new - -> { mutex.unlock }.should raise_error(ThreadError) + -> { mutex.unlock }.should.raise(ThreadError) end it "raises ThreadError unless thread owns Mutex" do @@ -19,7 +19,7 @@ Thread.pass until mutex.locked? Thread.pass until th.stop? - -> { mutex.unlock }.should raise_error(ThreadError) + -> { mutex.unlock }.should.raise(ThreadError) wait.unlock th.join @@ -33,6 +33,6 @@ th.join - -> { mutex.unlock }.should raise_error(ThreadError) + -> { mutex.unlock }.should.raise(ThreadError) end end diff --git a/spec/ruby/core/nil/dup_spec.rb b/spec/ruby/core/nil/dup_spec.rb index 0324b3f1f4453f..e0be9540a623c3 100644 --- a/spec/ruby/core/nil/dup_spec.rb +++ b/spec/ruby/core/nil/dup_spec.rb @@ -2,6 +2,6 @@ describe "NilClass#dup" do it "returns self" do - nil.dup.should equal(nil) + nil.dup.should.equal?(nil) end end diff --git a/spec/ruby/core/nil/match_spec.rb b/spec/ruby/core/nil/match_spec.rb index bc1c591793d3b4..27ebc53c3d2ceb 100644 --- a/spec/ruby/core/nil/match_spec.rb +++ b/spec/ruby/core/nil/match_spec.rb @@ -5,13 +5,13 @@ o = nil suppress_warning do - (o =~ /Object/).should be_nil - (o =~ 'Object').should be_nil - (o =~ Object).should be_nil - (o =~ Object.new).should be_nil - (o =~ nil).should be_nil - (o =~ false).should be_nil - (o =~ true).should be_nil + (o =~ /Object/).should == nil + (o =~ 'Object').should == nil + (o =~ Object).should == nil + (o =~ Object.new).should == nil + (o =~ nil).should == nil + (o =~ false).should == nil + (o =~ true).should == nil end end diff --git a/spec/ruby/core/nil/nilclass_spec.rb b/spec/ruby/core/nil/nilclass_spec.rb index 7f6d8af25d0261..55c5d0eba7f879 100644 --- a/spec/ruby/core/nil/nilclass_spec.rb +++ b/spec/ruby/core/nil/nilclass_spec.rb @@ -4,12 +4,12 @@ it ".allocate raises a TypeError" do -> do NilClass.allocate - end.should raise_error(TypeError) + end.should.raise(TypeError) end it ".new is undefined" do -> do NilClass.new - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/nil/rationalize_spec.rb b/spec/ruby/core/nil/rationalize_spec.rb index 84d6e6f056f165..69fb257a7fe2cc 100644 --- a/spec/ruby/core/nil/rationalize_spec.rb +++ b/spec/ruby/core/nil/rationalize_spec.rb @@ -10,7 +10,7 @@ end it "raises ArgumentError when passed more than one argument" do - -> { nil.rationalize(0.1, 0.1) }.should raise_error(ArgumentError) - -> { nil.rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError) + -> { nil.rationalize(0.1, 0.1) }.should.raise(ArgumentError) + -> { nil.rationalize(0.1, 0.1, 2) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/nil/singleton_method_spec.rb b/spec/ruby/core/nil/singleton_method_spec.rb index fb47af0c3e8c5d..f121b42f8155a7 100644 --- a/spec/ruby/core/nil/singleton_method_spec.rb +++ b/spec/ruby/core/nil/singleton_method_spec.rb @@ -2,10 +2,10 @@ describe "NilClass#singleton_method" do it "raises regardless of whether NilClass defines the method" do - -> { nil.singleton_method(:foo) }.should raise_error(NameError) + -> { nil.singleton_method(:foo) }.should.raise(NameError) begin def (nil).foo; end - -> { nil.singleton_method(:foo) }.should raise_error(NameError) + -> { nil.singleton_method(:foo) }.should.raise(NameError) ensure NilClass.send(:remove_method, :foo) end diff --git a/spec/ruby/core/nil/to_c_spec.rb b/spec/ruby/core/nil/to_c_spec.rb index e0052be5bd9de9..f449ddb6a3d320 100644 --- a/spec/ruby/core/nil/to_c_spec.rb +++ b/spec/ruby/core/nil/to_c_spec.rb @@ -2,6 +2,6 @@ describe "NilClass#to_c" do it "returns Complex(0, 0)" do - nil.to_c.should eql(Complex(0, 0)) + nil.to_c.should.eql?(Complex(0, 0)) end end diff --git a/spec/ruby/core/nil/to_s_spec.rb b/spec/ruby/core/nil/to_s_spec.rb index fa0b9296779a45..016ba4165a318d 100644 --- a/spec/ruby/core/nil/to_s_spec.rb +++ b/spec/ruby/core/nil/to_s_spec.rb @@ -10,6 +10,6 @@ end it "always returns the same string" do - nil.to_s.should equal(nil.to_s) + nil.to_s.should.equal?(nil.to_s) end end diff --git a/spec/ruby/core/numeric/abs2_spec.rb b/spec/ruby/core/numeric/abs2_spec.rb index 0e60cd0ae70523..12866f9c47cc71 100644 --- a/spec/ruby/core/numeric/abs2_spec.rb +++ b/spec/ruby/core/numeric/abs2_spec.rb @@ -18,7 +18,7 @@ it "returns the square of the absolute value of self" do @numbers.each do |number| - number.abs2.should eql(number.abs ** 2) + number.abs2.should.eql?(number.abs ** 2) end end @@ -29,6 +29,6 @@ end it "returns NaN when self is NaN" do - nan_value.abs2.nan?.should be_true + nan_value.abs2.nan?.should == true end end diff --git a/spec/ruby/core/numeric/clone_spec.rb b/spec/ruby/core/numeric/clone_spec.rb index 423cec85dddacd..1d06fdb050615e 100644 --- a/spec/ruby/core/numeric/clone_spec.rb +++ b/spec/ruby/core/numeric/clone_spec.rb @@ -3,11 +3,11 @@ describe "Numeric#clone" do it "returns self" do value = 1 - value.clone.should equal(value) + value.clone.should.equal?(value) subclass = Class.new(Numeric) value = subclass.new - value.clone.should equal(value) + value.clone.should.equal?(value) end it "does not change frozen status" do @@ -16,15 +16,15 @@ it "accepts optional keyword argument :freeze" do value = 1 - value.clone(freeze: true).should equal(value) + value.clone(freeze: true).should.equal?(value) end it "raises ArgumentError if passed freeze: false" do - -> { 1.clone(freeze: false) }.should raise_error(ArgumentError, /can't unfreeze/) + -> { 1.clone(freeze: false) }.should.raise(ArgumentError, /can't unfreeze/) end it "does not change frozen status if passed freeze: nil" do value = 1 - value.clone(freeze: nil).should equal(value) + value.clone(freeze: nil).should.equal?(value) end end diff --git a/spec/ruby/core/numeric/coerce_spec.rb b/spec/ruby/core/numeric/coerce_spec.rb index 4c4416d30b6e01..9344d99ee62cff 100644 --- a/spec/ruby/core/numeric/coerce_spec.rb +++ b/spec/ruby/core/numeric/coerce_spec.rb @@ -25,7 +25,7 @@ class << a; true; end # watch it explode - -> { a.coerce(b) }.should raise_error(TypeError) + -> { a.coerce(b) }.should.raise(TypeError) end end @@ -38,22 +38,22 @@ class << a; true; end it "raise TypeError if they are instances of different classes and other does not respond to #to_f" do other = mock("numeric") - -> { @obj.coerce(other) }.should raise_error(TypeError) + -> { @obj.coerce(other) }.should.raise(TypeError) end it "raises a TypeError when passed nil" do - -> { @obj.coerce(nil) }.should raise_error(TypeError) + -> { @obj.coerce(nil) }.should.raise(TypeError) end it "raises a TypeError when passed a boolean" do - -> { @obj.coerce(false) }.should raise_error(TypeError) + -> { @obj.coerce(false) }.should.raise(TypeError) end it "raises a TypeError when passed a Symbol" do - -> { @obj.coerce(:symbol) }.should raise_error(TypeError) + -> { @obj.coerce(:symbol) }.should.raise(TypeError) end it "raises an ArgumentError when passed a non-numeric String" do - -> { @obj.coerce("test") }.should raise_error(ArgumentError) + -> { @obj.coerce("test") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/numeric/comparison_spec.rb b/spec/ruby/core/numeric/comparison_spec.rb index 4b4d52501ac3b1..b0a9390cc038a8 100644 --- a/spec/ruby/core/numeric/comparison_spec.rb +++ b/spec/ruby/core/numeric/comparison_spec.rb @@ -26,22 +26,22 @@ end it "is called when instances are compared with #<" do - (@a < @b).should be_false + (@a < @b).should == false ScratchPad.recorded.should == :numeric_comparison end it "is called when instances are compared with #<=" do - (@a <= @b).should be_false + (@a <= @b).should == false ScratchPad.recorded.should == :numeric_comparison end it "is called when instances are compared with #>" do - (@a > @b).should be_true + (@a > @b).should == true ScratchPad.recorded.should == :numeric_comparison end it "is called when instances are compared with #>=" do - (@a >= @b).should be_true + (@a >= @b).should == true ScratchPad.recorded.should == :numeric_comparison end end diff --git a/spec/ruby/core/numeric/div_spec.rb b/spec/ruby/core/numeric/div_spec.rb index 53917b84c9daaa..a17961850cffa1 100644 --- a/spec/ruby/core/numeric/div_spec.rb +++ b/spec/ruby/core/numeric/div_spec.rb @@ -15,8 +15,8 @@ end it "raises ZeroDivisionError for 0" do - -> { @obj.div(0) }.should raise_error(ZeroDivisionError) - -> { @obj.div(0.0) }.should raise_error(ZeroDivisionError) - -> { @obj.div(Complex(0,0)) }.should raise_error(ZeroDivisionError) + -> { @obj.div(0) }.should.raise(ZeroDivisionError) + -> { @obj.div(0.0) }.should.raise(ZeroDivisionError) + -> { @obj.div(Complex(0,0)) }.should.raise(ZeroDivisionError) end end diff --git a/spec/ruby/core/numeric/dup_spec.rb b/spec/ruby/core/numeric/dup_spec.rb index 189a7ef44d9424..c158c618de3a7a 100644 --- a/spec/ruby/core/numeric/dup_spec.rb +++ b/spec/ruby/core/numeric/dup_spec.rb @@ -3,11 +3,11 @@ describe "Numeric#dup" do it "returns self" do value = 1 - value.dup.should equal(value) + value.dup.should.equal?(value) subclass = Class.new(Numeric) value = subclass.new - value.dup.should equal(value) + value.dup.should.equal?(value) end it "does not change frozen status" do diff --git a/spec/ruby/core/numeric/eql_spec.rb b/spec/ruby/core/numeric/eql_spec.rb index b33e00e51ff6d0..80c58caef48659 100644 --- a/spec/ruby/core/numeric/eql_spec.rb +++ b/spec/ruby/core/numeric/eql_spec.rb @@ -7,16 +7,16 @@ end it "returns false if self's and other's types don't match" do - @obj.should_not eql(1) - @obj.should_not eql(-1.5) - @obj.should_not eql(bignum_value) - @obj.should_not eql(:sym) + @obj.should_not.eql?(1) + @obj.should_not.eql?(-1.5) + @obj.should_not.eql?(bignum_value) + @obj.should_not.eql?(:sym) end it "returns the result of calling self#== with other when self's and other's types match" do other = NumericSpecs::Subclass.new @obj.should_receive(:==).with(other).and_return("result", nil) - @obj.should eql(other) - @obj.should_not eql(other) + @obj.should.eql?(other) + @obj.should_not.eql?(other) end end diff --git a/spec/ruby/core/numeric/fdiv_spec.rb b/spec/ruby/core/numeric/fdiv_spec.rb index e97fa77f79a939..2c22c6a86a1407 100644 --- a/spec/ruby/core/numeric/fdiv_spec.rb +++ b/spec/ruby/core/numeric/fdiv_spec.rb @@ -18,7 +18,7 @@ end it "returns a Float" do - bignum_value.fdiv(Float::MAX).should be_an_instance_of(Float) + bignum_value.fdiv(Float::MAX).should.instance_of?(Float) end it "returns Infinity if other is 0" do @@ -26,6 +26,6 @@ end it "returns NaN if other is NaN" do - 3334.fdiv(nan_value).nan?.should be_true + 3334.fdiv(nan_value).nan?.should == true end end diff --git a/spec/ruby/core/numeric/finite_spec.rb b/spec/ruby/core/numeric/finite_spec.rb index 05b5eebbd68916..2c18c894665713 100644 --- a/spec/ruby/core/numeric/finite_spec.rb +++ b/spec/ruby/core/numeric/finite_spec.rb @@ -3,6 +3,6 @@ describe "Numeric#finite?" do it "returns true by default" do o = mock_numeric("finite") - o.finite?.should be_true + o.finite?.should == true end end diff --git a/spec/ruby/core/numeric/i_spec.rb b/spec/ruby/core/numeric/i_spec.rb index 621ecc09ec81ef..f5fb99dfd31063 100644 --- a/spec/ruby/core/numeric/i_spec.rb +++ b/spec/ruby/core/numeric/i_spec.rb @@ -2,7 +2,7 @@ describe "Numeric#i" do it "returns a Complex object" do - 34.i.should be_an_instance_of(Complex) + 34.i.should.instance_of?(Complex) end it "sets the real part to 0" do diff --git a/spec/ruby/core/numeric/negative_spec.rb b/spec/ruby/core/numeric/negative_spec.rb index 9c6f95fd873f55..f2d8a847da4599 100644 --- a/spec/ruby/core/numeric/negative_spec.rb +++ b/spec/ruby/core/numeric/negative_spec.rb @@ -4,22 +4,22 @@ describe "Numeric#negative?" do describe "on positive numbers" do it "returns false" do - 1.negative?.should be_false - 0.1.negative?.should be_false + 1.negative?.should == false + 0.1.negative?.should == false end end describe "on zero" do it "returns false" do - 0.negative?.should be_false - 0.0.negative?.should be_false + 0.negative?.should == false + 0.0.negative?.should == false end end describe "on negative numbers" do it "returns true" do - -1.negative?.should be_true - -0.1.negative?.should be_true + -1.negative?.should == true + -0.1.negative?.should == true end end end diff --git a/spec/ruby/core/numeric/polar_spec.rb b/spec/ruby/core/numeric/polar_spec.rb index b594e408b287af..0695d7afb24e7d 100644 --- a/spec/ruby/core/numeric/polar_spec.rb +++ b/spec/ruby/core/numeric/polar_spec.rb @@ -17,7 +17,7 @@ it "returns a two-element Array" do @numbers.each do |number| - number.polar.should be_an_instance_of(Array) + number.polar.should.instance_of?(Array) number.polar.size.should == 2 end end @@ -44,7 +44,7 @@ it "returns [NaN, NaN] if self is NaN" do nan_value.polar.size.should == 2 - nan_value.polar.first.nan?.should be_true - nan_value.polar.last.nan?.should be_true + nan_value.polar.first.nan?.should == true + nan_value.polar.last.nan?.should == true end end diff --git a/spec/ruby/core/numeric/positive_spec.rb b/spec/ruby/core/numeric/positive_spec.rb index 3b831b4d3417b2..7c8d15cd9fac19 100644 --- a/spec/ruby/core/numeric/positive_spec.rb +++ b/spec/ruby/core/numeric/positive_spec.rb @@ -4,22 +4,22 @@ describe "Numeric#positive?" do describe "on positive numbers" do it "returns true" do - 1.positive?.should be_true - 0.1.positive?.should be_true + 1.positive?.should == true + 0.1.positive?.should == true end end describe "on zero" do it "returns false" do - 0.positive?.should be_false - 0.0.positive?.should be_false + 0.positive?.should == false + 0.0.positive?.should == false end end describe "on negative numbers" do it "returns false" do - -1.positive?.should be_false - -0.1.positive?.should be_false + -1.positive?.should == false + -0.1.positive?.should == false end end end diff --git a/spec/ruby/core/numeric/quo_spec.rb b/spec/ruby/core/numeric/quo_spec.rb index 6e3ce7a3745fb8..66ff0192311f35 100644 --- a/spec/ruby/core/numeric/quo_spec.rb +++ b/spec/ruby/core/numeric/quo_spec.rb @@ -3,11 +3,11 @@ describe "Numeric#quo" do it "returns the result of self divided by the given Integer as a Rational" do - 5.quo(2).should eql(Rational(5,2)) + 5.quo(2).should.eql?(Rational(5,2)) end it "returns the result of self divided by the given Float as a Float" do - 2.quo(2.5).should eql(0.8) + 2.quo(2.5).should.eql?(0.8) end it "returns the result of self divided by the given Bignum as a Float" do @@ -15,11 +15,11 @@ end it "raises a ZeroDivisionError when the given Integer is 0" do - -> { 0.quo(0) }.should raise_error(ZeroDivisionError) - -> { 10.quo(0) }.should raise_error(ZeroDivisionError) - -> { -10.quo(0) }.should raise_error(ZeroDivisionError) - -> { bignum_value.quo(0) }.should raise_error(ZeroDivisionError) - -> { (-bignum_value).quo(0) }.should raise_error(ZeroDivisionError) + -> { 0.quo(0) }.should.raise(ZeroDivisionError) + -> { 10.quo(0) }.should.raise(ZeroDivisionError) + -> { -10.quo(0) }.should.raise(ZeroDivisionError) + -> { bignum_value.quo(0) }.should.raise(ZeroDivisionError) + -> { (-bignum_value).quo(0) }.should.raise(ZeroDivisionError) end it "calls #to_r to convert the object to a Rational" do @@ -33,16 +33,16 @@ obj = NumericSpecs::Subclass.new obj.should_receive(:to_r).and_return(1) - -> { obj.quo(19) }.should raise_error(TypeError) + -> { obj.quo(19) }.should.raise(TypeError) end it "raises a TypeError when given a non-Integer" do -> { (obj = mock('x')).should_not_receive(:to_int) 13.quo(obj) - }.should raise_error(TypeError) - -> { 13.quo("10") }.should raise_error(TypeError) - -> { 13.quo(:symbol) }.should raise_error(TypeError) + }.should.raise(TypeError) + -> { 13.quo("10") }.should.raise(TypeError) + -> { 13.quo(:symbol) }.should.raise(TypeError) end it "returns the result of calling self#/ with other" do @@ -53,7 +53,7 @@ end it "raises a ZeroDivisionError if the given argument is zero and not a Float" do - -> { 1.quo(0) }.should raise_error(ZeroDivisionError) + -> { 1.quo(0) }.should.raise(ZeroDivisionError) end it "returns infinity if the given argument is zero and is a Float" do diff --git a/spec/ruby/core/numeric/real_spec.rb b/spec/ruby/core/numeric/real_spec.rb index 2d2499bcce5193..09d482a6917676 100644 --- a/spec/ruby/core/numeric/real_spec.rb +++ b/spec/ruby/core/numeric/real_spec.rb @@ -16,7 +16,7 @@ it "returns self" do @numbers.each do |number| if number.to_f.nan? - number.real.nan?.should be_true + number.real.nan?.should == true else number.real.should == number end @@ -25,7 +25,7 @@ it "raises an ArgumentError if given any arguments" do @numbers.each do |number| - -> { number.real(number) }.should raise_error(ArgumentError) + -> { number.real(number) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/numeric/remainder_spec.rb b/spec/ruby/core/numeric/remainder_spec.rb index 29654310d231e2..bdf7358b21a65a 100644 --- a/spec/ruby/core/numeric/remainder_spec.rb +++ b/spec/ruby/core/numeric/remainder_spec.rb @@ -13,7 +13,7 @@ @obj.should_receive(:%).with(@other).and_return(@result) @result.should_receive(:==).with(0).and_return(true) - @obj.remainder(@other).should equal(@result) + @obj.remainder(@other).should.equal?(@result) end it "returns the result of calling self#% with other if self and other are greater than 0" do @@ -25,7 +25,7 @@ @obj.should_receive(:>).with(0).and_return(true) @other.should_receive(:<).with(0).and_return(false) - @obj.remainder(@other).should equal(@result) + @obj.remainder(@other).should.equal?(@result) end it "returns the result of calling self#% with other if self and other are less than 0" do @@ -37,7 +37,7 @@ @obj.should_receive(:>).with(0).and_return(false) - @obj.remainder(@other).should equal(@result) + @obj.remainder(@other).should.equal?(@result) end it "returns the result of calling self#% with other - other if self is greater than 0 and other is less than 0" do diff --git a/spec/ruby/core/numeric/shared/conj.rb b/spec/ruby/core/numeric/shared/conj.rb index 6d5197ecabe86d..1a661fbbe86a31 100644 --- a/spec/ruby/core/numeric/shared/conj.rb +++ b/spec/ruby/core/numeric/shared/conj.rb @@ -14,7 +14,7 @@ it "returns self" do @numbers.each do |number| - number.send(@method).should equal(number) + number.send(@method).should.equal?(number) end end end diff --git a/spec/ruby/core/numeric/shared/imag.rb b/spec/ruby/core/numeric/shared/imag.rb index 4f117e243ad7db..605a23d8c64f60 100644 --- a/spec/ruby/core/numeric/shared/imag.rb +++ b/spec/ruby/core/numeric/shared/imag.rb @@ -20,7 +20,7 @@ it "raises an ArgumentError if given any arguments" do @numbers.each do |number| - -> { number.send(@method, number) }.should raise_error(ArgumentError) + -> { number.send(@method, number) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/numeric/shared/rect.rb b/spec/ruby/core/numeric/shared/rect.rb index 120a69b1c48fbf..32d03e45d2e026 100644 --- a/spec/ruby/core/numeric/shared/rect.rb +++ b/spec/ruby/core/numeric/shared/rect.rb @@ -14,7 +14,7 @@ it "returns an Array" do @numbers.each do |number| - number.send(@method).should be_an_instance_of(Array) + number.send(@method).should.instance_of?(Array) end end @@ -27,7 +27,7 @@ it "returns self as the first element" do @numbers.each do |number| if Float === number and number.nan? - number.send(@method).first.nan?.should be_true + number.send(@method).first.nan?.should == true else number.send(@method).first.should == number end @@ -42,7 +42,7 @@ it "raises an ArgumentError if given any arguments" do @numbers.each do |number| - -> { number.send(@method, number) }.should raise_error(ArgumentError) + -> { number.send(@method, number) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/numeric/shared/step.rb b/spec/ruby/core/numeric/shared/step.rb index 977ec6de02554c..66b8c1af0d9f46 100644 --- a/spec/ruby/core/numeric/shared/step.rb +++ b/spec/ruby/core/numeric/shared/step.rb @@ -13,7 +13,7 @@ it "defaults to step = 1" do @step.call(1, 5, &@prc) - ScratchPad.recorded.should eql [1, 2, 3, 4, 5] + ScratchPad.recorded.should.eql? [1, 2, 3, 4, 5] end it "defaults to an infinite limit with a step size of 1 for Integers" do @@ -26,35 +26,35 @@ describe "when self, stop and step are Integers" do it "yields only Integers" do - @step.call(1, 5, 1) { |x| x.should be_an_instance_of(Integer) } + @step.call(1, 5, 1) { |x| x.should.instance_of?(Integer) } end describe "with a positive step" do it "yields while increasing self by step until stop is reached" do @step.call(1, 5, 1, &@prc) - ScratchPad.recorded.should eql [1, 2, 3, 4, 5] + ScratchPad.recorded.should.eql? [1, 2, 3, 4, 5] end it "yields once when self equals stop" do @step.call(1, 1, 1, &@prc) - ScratchPad.recorded.should eql [1] + ScratchPad.recorded.should.eql? [1] end it "does not yield when self is greater than stop" do @step.call(2, 1, 1, &@prc) - ScratchPad.recorded.should eql [] + ScratchPad.recorded.should.eql? [] end end describe "with a negative step" do it "yields while decreasing self by step until stop is reached" do @step.call(5, 1, -1, &@prc) - ScratchPad.recorded.should eql [5, 4, 3, 2, 1] + ScratchPad.recorded.should.eql? [5, 4, 3, 2, 1] end it "yields once when self equals stop" do @step.call(5, 5, -1, &@prc) - ScratchPad.recorded.should eql [5] + ScratchPad.recorded.should.eql? [5] end it "does not yield when self is less than stop" do @@ -66,26 +66,26 @@ describe "when at least one of self, stop or step is a Float" do it "yields Floats even if only self is a Float" do - @step.call(1.5, 5, 1) { |x| x.should be_an_instance_of(Float) } + @step.call(1.5, 5, 1) { |x| x.should.instance_of?(Float) } end it "yields Floats even if only stop is a Float" do - @step.call(1, 5.0, 1) { |x| x.should be_an_instance_of(Float) } + @step.call(1, 5.0, 1) { |x| x.should.instance_of?(Float) } end it "yields Floats even if only step is a Float" do - @step.call(1, 5, 1.0) { |x| x.should be_an_instance_of(Float) } + @step.call(1, 5, 1.0) { |x| x.should.instance_of?(Float) } end describe "with a positive step" do it "yields while increasing self by step while < stop" do @step.call(1.5, 5, 1, &@prc) - ScratchPad.recorded.should eql [1.5, 2.5, 3.5, 4.5] + ScratchPad.recorded.should.eql? [1.5, 2.5, 3.5, 4.5] end it "yields once when self equals stop" do @step.call(1.5, 1.5, 1, &@prc) - ScratchPad.recorded.should eql [1.5] + ScratchPad.recorded.should.eql? [1.5] end it "does not yield when self is greater than stop" do @@ -96,19 +96,19 @@ it "is careful about not yielding a value greater than limit" do # As 9*1.3+1.0 == 12.700000000000001 > 12.7, we test: @step.call(1.0, 12.7, 1.3, &@prc) - ScratchPad.recorded.should eql [1.0, 2.3, 3.6, 4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7] + ScratchPad.recorded.should.eql? [1.0, 2.3, 3.6, 4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7] end end describe "with a negative step" do it "yields while decreasing self by step while self > stop" do @step.call(5, 1.5, -1, &@prc) - ScratchPad.recorded.should eql [5.0, 4.0, 3.0, 2.0] + ScratchPad.recorded.should.eql? [5.0, 4.0, 3.0, 2.0] end it "yields once when self equals stop" do @step.call(1.5, 1.5, -1, &@prc) - ScratchPad.recorded.should eql [1.5] + ScratchPad.recorded.should.eql? [1.5] end it "does not yield when self is less than stop" do @@ -119,24 +119,24 @@ it "is careful about not yielding a value smaller than limit" do # As -9*1.3-1.0 == -12.700000000000001 < -12.7, we test: @step.call(-1.0, -12.7, -1.3, &@prc) - ScratchPad.recorded.should eql [-1.0, -2.3, -3.6, -4.9, -6.2, -7.5, -8.8, -10.1, -11.4, -12.7] + ScratchPad.recorded.should.eql? [-1.0, -2.3, -3.6, -4.9, -6.2, -7.5, -8.8, -10.1, -11.4, -12.7] end end describe "with a positive Infinity step" do it "yields once if self < stop" do @step.call(42, 100, infinity_value, &@prc) - ScratchPad.recorded.should eql [42.0] + ScratchPad.recorded.should.eql? [42.0] end it "yields once when stop is Infinity" do @step.call(42, infinity_value, infinity_value, &@prc) - ScratchPad.recorded.should eql [42.0] + ScratchPad.recorded.should.eql? [42.0] end it "yields once when self equals stop" do @step.call(42, 42, infinity_value, &@prc) - ScratchPad.recorded.should eql [42.0] + ScratchPad.recorded.should.eql? [42.0] end it "yields once when self and stop are Infinity" do @@ -159,17 +159,17 @@ describe "with a negative Infinity step" do it "yields once if self > stop" do @step.call(42, 6, -infinity_value, &@prc) - ScratchPad.recorded.should eql [42.0] + ScratchPad.recorded.should.eql? [42.0] end it "yields once if stop is -Infinity" do @step.call(42, -infinity_value, -infinity_value, &@prc) - ScratchPad.recorded.should eql [42.0] + ScratchPad.recorded.should.eql? [42.0] end it "yields once when self equals stop" do @step.call(42, 42, -infinity_value, &@prc) - ScratchPad.recorded.should eql [42.0] + ScratchPad.recorded.should.eql? [42.0] end it "yields once when self and stop are Infinity" do @@ -226,60 +226,60 @@ describe "when step is a String" do describe "with self and stop as Integers" do it "raises an ArgumentError when step is a numeric representation" do - -> { @step.call(1, 5, "1") {} }.should raise_error(ArgumentError) - -> { @step.call(1, 5, "0.1") {} }.should raise_error(ArgumentError) - -> { @step.call(1, 5, "1/3") {} }.should raise_error(ArgumentError) + -> { @step.call(1, 5, "1") {} }.should.raise(ArgumentError) + -> { @step.call(1, 5, "0.1") {} }.should.raise(ArgumentError) + -> { @step.call(1, 5, "1/3") {} }.should.raise(ArgumentError) end it "raises an ArgumentError with step as an alphanumeric string" do - -> { @step.call(1, 5, "foo") {} }.should raise_error(ArgumentError) + -> { @step.call(1, 5, "foo") {} }.should.raise(ArgumentError) end end describe "with self and stop as Floats" do it "raises an ArgumentError when step is a numeric representation" do - -> { @step.call(1.1, 5.1, "1") {} }.should raise_error(ArgumentError) - -> { @step.call(1.1, 5.1, "0.1") {} }.should raise_error(ArgumentError) - -> { @step.call(1.1, 5.1, "1/3") {} }.should raise_error(ArgumentError) + -> { @step.call(1.1, 5.1, "1") {} }.should.raise(ArgumentError) + -> { @step.call(1.1, 5.1, "0.1") {} }.should.raise(ArgumentError) + -> { @step.call(1.1, 5.1, "1/3") {} }.should.raise(ArgumentError) end it "raises an ArgumentError with step as an alphanumeric string" do - -> { @step.call(1.1, 5.1, "foo") {} }.should raise_error(ArgumentError) + -> { @step.call(1.1, 5.1, "foo") {} }.should.raise(ArgumentError) end end end it "does not rescue ArgumentError exceptions" do - -> { @step.call(1, 2) { raise ArgumentError, "" }}.should raise_error(ArgumentError) + -> { @step.call(1, 2) { raise ArgumentError, "" }}.should.raise(ArgumentError) end it "does not rescue TypeError exceptions" do - -> { @step.call(1, 2) { raise TypeError, "" } }.should raise_error(TypeError) + -> { @step.call(1, 2) { raise TypeError, "" } }.should.raise(TypeError) end describe "when no block is given" do step_enum_class = Enumerator::ArithmeticSequence it "returns an #{step_enum_class} when not passed a block and self > stop" do - @step.call(1, 0, 2).should be_an_instance_of(step_enum_class) + @step.call(1, 0, 2).should.instance_of?(step_enum_class) end it "returns an #{step_enum_class} when not passed a block and self < stop" do - @step.call(1, 2, 3).should be_an_instance_of(step_enum_class) + @step.call(1, 2, 3).should.instance_of?(step_enum_class) end it "returns an #{step_enum_class} that uses the given step" do - @step.call(0, 5, 2).to_a.should eql [0, 2, 4] + @step.call(0, 5, 2).to_a.should.eql? [0, 2, 4] end describe "when step is a String" do describe "with self and stop as Integers" do it "returns an Enumerator" do - @step.call(1, 5, "foo").should be_an_instance_of(Enumerator) + @step.call(1, 5, "foo").should.instance_of?(Enumerator) end end describe "with self and stop as Floats" do it "returns an Enumerator" do - @step.call(1.1, 5.1, "foo").should be_an_instance_of(Enumerator) + @step.call(1.1, 5.1, "foo").should.instance_of?(Enumerator) end end end @@ -289,23 +289,23 @@ describe "when step is a String" do describe "with self and stop as Integers" do it "raises an ArgumentError when step is a numeric representation" do - -> { @step.call(1, 5, "1").size }.should raise_error(ArgumentError) - -> { @step.call(1, 5, "0.1").size }.should raise_error(ArgumentError) - -> { @step.call(1, 5, "1/3").size }.should raise_error(ArgumentError) + -> { @step.call(1, 5, "1").size }.should.raise(ArgumentError) + -> { @step.call(1, 5, "0.1").size }.should.raise(ArgumentError) + -> { @step.call(1, 5, "1/3").size }.should.raise(ArgumentError) end it "raises an ArgumentError with step as an alphanumeric string" do - -> { @step.call(1, 5, "foo").size }.should raise_error(ArgumentError) + -> { @step.call(1, 5, "foo").size }.should.raise(ArgumentError) end end describe "with self and stop as Floats" do it "raises an ArgumentError when step is a numeric representation" do - -> { @step.call(1.1, 5.1, "1").size }.should raise_error(ArgumentError) - -> { @step.call(1.1, 5.1, "0.1").size }.should raise_error(ArgumentError) - -> { @step.call(1.1, 5.1, "1/3").size }.should raise_error(ArgumentError) + -> { @step.call(1.1, 5.1, "1").size }.should.raise(ArgumentError) + -> { @step.call(1.1, 5.1, "0.1").size }.should.raise(ArgumentError) + -> { @step.call(1.1, 5.1, "1/3").size }.should.raise(ArgumentError) end it "raises an ArgumentError with step as an alphanumeric string" do - -> { @step.call(1.1, 5.1, "foo").size }.should raise_error(ArgumentError) + -> { @step.call(1.1, 5.1, "foo").size }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/numeric/singleton_method_added_spec.rb b/spec/ruby/core/numeric/singleton_method_added_spec.rb index 2091398e5dd2e1..327bb5662a752a 100644 --- a/spec/ruby/core/numeric/singleton_method_added_spec.rb +++ b/spec/ruby/core/numeric/singleton_method_added_spec.rb @@ -21,21 +21,21 @@ def singleton_method_added(val) -> do a = NumericSpecs::Subclass.new def a.test; end - end.should raise_error(TypeError) + end.should.raise(TypeError) -> do a = 1 def a.test; end - end.should raise_error(TypeError) + end.should.raise(TypeError) -> do a = 1.5 def a.test; end - end.should raise_error(TypeError) + end.should.raise(TypeError) -> do a = bignum_value def a.test; end - end.should raise_error(TypeError) + end.should.raise(TypeError) end end diff --git a/spec/ruby/core/numeric/step_spec.rb b/spec/ruby/core/numeric/step_spec.rb index 1705fb1b4ed6b1..6896009eb66518 100644 --- a/spec/ruby/core/numeric/step_spec.rb +++ b/spec/ruby/core/numeric/step_spec.rb @@ -6,11 +6,11 @@ describe 'with positional args' do it "raises an ArgumentError when step is 0" do - -> { 1.step(5, 0) {} }.should raise_error(ArgumentError) + -> { 1.step(5, 0) {} }.should.raise(ArgumentError) end it "raises an ArgumentError when step is 0.0" do - -> { 1.step(2, 0.0) {} }.should raise_error(ArgumentError) + -> { 1.step(2, 0.0) {} }.should.raise(ArgumentError) end before :all do @@ -81,19 +81,19 @@ describe 'with mixed arguments' do it " raises an ArgumentError when step is 0" do - -> { 1.step(5, by: 0) { break } }.should raise_error(ArgumentError) + -> { 1.step(5, by: 0) { break } }.should.raise(ArgumentError) end it "raises an ArgumentError when step is 0.0" do - -> { 1.step(2, by: 0.0) { break } }.should raise_error(ArgumentError) + -> { 1.step(2, by: 0.0) { break } }.should.raise(ArgumentError) end it "raises a ArgumentError when limit and to are defined" do - -> { 1.step(5, 1, to: 5) { break } }.should raise_error(ArgumentError) + -> { 1.step(5, 1, to: 5) { break } }.should.raise(ArgumentError) end it "raises a ArgumentError when step and by are defined" do - -> { 1.step(5, 1, by: 5) { break } }.should raise_error(ArgumentError) + -> { 1.step(5, 1, by: 5) { break } }.should.raise(ArgumentError) end describe "when no block is given" do diff --git a/spec/ruby/core/numeric/to_c_spec.rb b/spec/ruby/core/numeric/to_c_spec.rb index 75245a612e15d8..70b7a9dd0c5cba 100644 --- a/spec/ruby/core/numeric/to_c_spec.rb +++ b/spec/ruby/core/numeric/to_c_spec.rb @@ -22,7 +22,7 @@ it "returns a Complex object" do @numbers.each do |number| - number.to_c.should be_an_instance_of(Complex) + number.to_c.should.instance_of?(Complex) end end @@ -30,7 +30,7 @@ @numbers.each do |number| real = number.to_c.real if Float === number and number.nan? - real.nan?.should be_true + real.nan?.should == true else real.should == number end diff --git a/spec/ruby/core/objectspace/_id2ref_spec.rb b/spec/ruby/core/objectspace/_id2ref_spec.rb index 1ae3230bdf3a9d..a9fd526b7d0f68 100644 --- a/spec/ruby/core/objectspace/_id2ref_spec.rb +++ b/spec/ruby/core/objectspace/_id2ref_spec.rb @@ -59,7 +59,7 @@ end it 'raises RangeError when an object could not be found' do - proc { ObjectSpace._id2ref(1 << 60) }.should raise_error(RangeError) + proc { ObjectSpace._id2ref(1 << 60) }.should.raise(RangeError) end end end diff --git a/spec/ruby/core/objectspace/define_finalizer_spec.rb b/spec/ruby/core/objectspace/define_finalizer_spec.rb index 0f4b54c3458553..5441cb4a21824a 100644 --- a/spec/ruby/core/objectspace/define_finalizer_spec.rb +++ b/spec/ruby/core/objectspace/define_finalizer_spec.rb @@ -13,7 +13,7 @@ it "raises an ArgumentError if the action does not respond to call" do -> { ObjectSpace.define_finalizer(Object.new, mock("ObjectSpace.define_finalizer no #call")) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "accepts an object and a proc" do @@ -42,7 +42,7 @@ def handler.call(id) end it "raises ArgumentError trying to define a finalizer on a non-reference" do -> { ObjectSpace.define_finalizer(:blah) { 1 } - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end # see [ruby-core:24095] @@ -57,7 +57,7 @@ def scoped exit 0 RUBY - ruby_exe(code, :args => "2>&1").should include("finalizer run\n") + ruby_exe(code, :args => "2>&1").should.include?("finalizer run\n") end it "warns if the finalizer has the object as the receiver" do @@ -73,7 +73,7 @@ def initialize exit 0 RUBY - ruby_exe(code, :args => "2>&1").should include("warning: finalizer references object to be finalized\n") + ruby_exe(code, :args => "2>&1").should.include?("warning: finalizer references object to be finalized\n") end it "warns if the finalizer is a method bound to the receiver" do @@ -90,7 +90,7 @@ def finalize(id) exit 0 RUBY - ruby_exe(code, :args => "2>&1").should include("warning: finalizer references object to be finalized\n") + ruby_exe(code, :args => "2>&1").should.include?("warning: finalizer references object to be finalized\n") end it "warns if the finalizer was a block in the receiver" do @@ -106,7 +106,7 @@ def initialize exit 0 RUBY - ruby_exe(code, :args => "2>&1").should include("warning: finalizer references object to be finalized\n") + ruby_exe(code, :args => "2>&1").should.include?("warning: finalizer references object to be finalized\n") end it "calls a finalizer at exit even if it is self-referencing" do @@ -117,7 +117,7 @@ def initialize exit 0 RUBY - ruby_exe(code).should include("finalizer run\n") + ruby_exe(code).should.include?("finalizer run\n") end it "calls a finalizer at exit even if it is indirectly self-referencing" do @@ -136,7 +136,7 @@ def finalizer(zelf) exit 0 RUBY - ruby_exe(code, :args => "2>&1").should include("finalizer run\n") + ruby_exe(code, :args => "2>&1").should.include?("finalizer run\n") end it "calls a finalizer defined in a finalizer running at exit" do @@ -152,7 +152,7 @@ def finalizer(zelf) exit 0 RUBY - ruby_exe(code, :args => "2>&1").should include("finalizer 2 run\n") + ruby_exe(code, :args => "2>&1").should.include?("finalizer 2 run\n") end it "allows multiple finalizers with different 'callables' to be defined" do @@ -199,7 +199,9 @@ def finalizer(zelf) ObjectSpace.define_finalizer(Object.new) { raise "finalizing" } RUBY - ruby_exe(code, args: "2>&1").should include("warning: Exception in finalizer", "finalizing") + out = ruby_exe(code, args: "2>&1") + out.should.include?("warning: Exception in finalizer") + out.should.include?("finalizing") end end diff --git a/spec/ruby/core/objectspace/each_object_spec.rb b/spec/ruby/core/objectspace/each_object_spec.rb index 09a582afaf95a4..aee0fd629ca177 100644 --- a/spec/ruby/core/objectspace/each_object_spec.rb +++ b/spec/ruby/core/objectspace/each_object_spec.rb @@ -39,7 +39,7 @@ new_obj = klass.new counter = ObjectSpace.each_object(klass) - counter.should be_an_instance_of(Enumerator) + counter.should.instance_of?(Enumerator) counter.each{}.should == 1 # this is needed to prevent the new_obj from being GC'd too early new_obj.should_not == nil @@ -47,20 +47,20 @@ it "finds an object stored in a global variable" do $object_space_global_variable = ObjectSpaceFixtures::ObjectToBeFound.new(:global) - ObjectSpaceFixtures.to_be_found_symbols.should include(:global) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:global) end it "finds an object stored in a top-level constant" do - ObjectSpaceFixtures.to_be_found_symbols.should include(:top_level_constant) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:top_level_constant) end it "finds an object stored in a second-level constant" do - ObjectSpaceFixtures.to_be_found_symbols.should include(:second_level_constant) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:second_level_constant) end it "finds an object stored in a local variable" do local = ObjectSpaceFixtures::ObjectToBeFound.new(:local) - ObjectSpaceFixtures.to_be_found_symbols.should include(:local) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:local) end it "finds an object stored in a local variable captured in a block explicitly" do @@ -69,7 +69,7 @@ Proc.new { local_in_block } }.call - ObjectSpaceFixtures.to_be_found_symbols.should include(:local_in_block_explicit) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:local_in_block_explicit) end it "finds an object stored in a local variable captured in a block implicitly" do @@ -78,11 +78,11 @@ Proc.new { } }.call - ObjectSpaceFixtures.to_be_found_symbols.should include(:local_in_block_implicit) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:local_in_block_implicit) end it "finds an object stored in a local variable captured in by a method defined with a block" do - ObjectSpaceFixtures.to_be_found_symbols.should include(:captured_by_define_method) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:captured_by_define_method) end it "finds an object stored in a local variable captured in a Proc#binding" do @@ -91,7 +91,7 @@ Proc.new { }.binding }.call - ObjectSpaceFixtures.to_be_found_symbols.should include(:local_in_proc_binding) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:local_in_proc_binding) end it "finds an object stored in a local variable captured in a Kernel#binding" do @@ -100,45 +100,45 @@ binding }.call - ObjectSpaceFixtures.to_be_found_symbols.should include(:local_in_kernel_binding) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:local_in_kernel_binding) end it "finds an object stored in a local variable set in a binding manually" do b = binding b.eval("local = ObjectSpaceFixtures::ObjectToBeFound.new(:local_in_manual_binding)") - ObjectSpaceFixtures.to_be_found_symbols.should include(:local_in_manual_binding) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:local_in_manual_binding) end it "finds an object stored in an array" do array = [ObjectSpaceFixtures::ObjectToBeFound.new(:array)] - ObjectSpaceFixtures.to_be_found_symbols.should include(:array) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:array) end it "finds an object stored in a hash key" do hash = {ObjectSpaceFixtures::ObjectToBeFound.new(:hash_key) => :value} - ObjectSpaceFixtures.to_be_found_symbols.should include(:hash_key) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:hash_key) end it "finds an object stored in a hash value" do hash = {a: ObjectSpaceFixtures::ObjectToBeFound.new(:hash_value)} - ObjectSpaceFixtures.to_be_found_symbols.should include(:hash_value) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:hash_value) end it "finds an object stored in an instance variable" do local = ObjectSpaceFixtures::ObjectWithInstanceVariable.new - ObjectSpaceFixtures.to_be_found_symbols.should include(:instance_variable) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:instance_variable) end it "finds an object stored in a thread local" do thread = Thread.new {} thread.thread_variable_set(:object_space_thread_local, ObjectSpaceFixtures::ObjectToBeFound.new(:thread_local)) - ObjectSpaceFixtures.to_be_found_symbols.should include(:thread_local) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:thread_local) thread.join end it "finds an object stored in a fiber local" do Thread.current[:object_space_fiber_local] = ObjectSpaceFixtures::ObjectToBeFound.new(:fiber_local) - ObjectSpaceFixtures.to_be_found_symbols.should include(:fiber_local) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:fiber_local) end it "finds an object captured in an at_exit handler" do @@ -150,7 +150,7 @@ end }.call - ObjectSpaceFixtures.to_be_found_symbols.should include(:at_exit) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:at_exit) end it "finds an object captured in finalizer" do @@ -164,9 +164,9 @@ }) }.call - ObjectSpaceFixtures.to_be_found_symbols.should include(:finalizer) + ObjectSpaceFixtures.to_be_found_symbols.should.include?(:finalizer) - alive.should_not be_nil + alive.should_not == nil end describe "on singleton classes" do @@ -185,8 +185,8 @@ end it "walks singleton classes" do - @sclass.should be_kind_of(@meta) - ObjectSpace.each_object(@meta).to_a.should include(@sclass) + @sclass.should.is_a?(@meta) + ObjectSpace.each_object(@meta).to_a.should.include?(@sclass) end end @@ -202,7 +202,7 @@ expected = [ a, b, c, d ] expected << c_sclass - c_sclass.should be_kind_of(a.singleton_class) + c_sclass.should.is_a?(a.singleton_class) b.extend Enumerable # included modules should not be walked diff --git a/spec/ruby/core/objectspace/garbage_collect_spec.rb b/spec/ruby/core/objectspace/garbage_collect_spec.rb index 521eaa87858318..d2db22e0aa6a1b 100644 --- a/spec/ruby/core/objectspace/garbage_collect_spec.rb +++ b/spec/ruby/core/objectspace/garbage_collect_spec.rb @@ -3,7 +3,7 @@ describe "ObjectSpace.garbage_collect" do it "can be invoked without any exceptions" do - -> { ObjectSpace.garbage_collect }.should_not raise_error + -> { ObjectSpace.garbage_collect }.should_not.raise end it "accepts keyword arguments" do @@ -11,7 +11,7 @@ end it "ignores the supplied block" do - -> { ObjectSpace.garbage_collect {} }.should_not raise_error + -> { ObjectSpace.garbage_collect {} }.should_not.raise end it "always returns nil" do diff --git a/spec/ruby/core/objectspace/undefine_finalizer_spec.rb b/spec/ruby/core/objectspace/undefine_finalizer_spec.rb index f57d5a78452631..98ffc6a9861a9a 100644 --- a/spec/ruby/core/objectspace/undefine_finalizer_spec.rb +++ b/spec/ruby/core/objectspace/undefine_finalizer_spec.rb @@ -28,6 +28,6 @@ it "should raise when removing finalizers for a frozen object" do obj = Object.new obj.freeze - -> { ObjectSpace.undefine_finalizer(obj) }.should raise_error(FrozenError) + -> { ObjectSpace.undefine_finalizer(obj) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/objectspace/weakkeymap/element_set_spec.rb b/spec/ruby/core/objectspace/weakkeymap/element_set_spec.rb index c480aa661ae2fd..cf59aebc6fa84d 100644 --- a/spec/ruby/core/objectspace/weakkeymap/element_set_spec.rb +++ b/spec/ruby/core/objectspace/weakkeymap/element_set_spec.rb @@ -19,7 +19,7 @@ def should_accept(map, key, value) it "requires the keys to implement #hash" do map = ObjectSpace::WeakKeyMap.new - -> { map[BasicObject.new] = 1 }.should raise_error(NoMethodError, /undefined method [`']hash' for an instance of BasicObject/) + -> { map[BasicObject.new] = 1 }.should.raise(NoMethodError, /undefined method [`']hash' for an instance of BasicObject/) end it "accepts frozen keys or values" do @@ -49,32 +49,32 @@ def should_accept(map, key, value) context "a key cannot be garbage collected" do it "raises ArgumentError when Integer is used as a key" do map = ObjectSpace::WeakKeyMap.new - -> { map[1] = "x" }.should raise_error(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) + -> { map[1] = "x" }.should.raise(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) end it "raises ArgumentError when Float is used as a key" do map = ObjectSpace::WeakKeyMap.new - -> { map[1.0] = "x" }.should raise_error(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) + -> { map[1.0] = "x" }.should.raise(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) end it "raises ArgumentError when Symbol is used as a key" do map = ObjectSpace::WeakKeyMap.new - -> { map[:a] = "x" }.should raise_error(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) + -> { map[:a] = "x" }.should.raise(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) end it "raises ArgumentError when true is used as a key" do map = ObjectSpace::WeakKeyMap.new - -> { map[true] = "x" }.should raise_error(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) + -> { map[true] = "x" }.should.raise(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) end it "raises ArgumentError when false is used as a key" do map = ObjectSpace::WeakKeyMap.new - -> { map[false] = "x" }.should raise_error(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) + -> { map[false] = "x" }.should.raise(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) end it "raises ArgumentError when nil is used as a key" do map = ObjectSpace::WeakKeyMap.new - -> { map[nil] = "x" }.should raise_error(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) + -> { map[nil] = "x" }.should.raise(ArgumentError, /WeakKeyMap (keys )?must be garbage collectable/) end end end diff --git a/spec/ruby/core/objectspace/weakkeymap/getkey_spec.rb b/spec/ruby/core/objectspace/weakkeymap/getkey_spec.rb index 0c8dec8aea5248..798a2e2cda5b21 100644 --- a/spec/ruby/core/objectspace/weakkeymap/getkey_spec.rb +++ b/spec/ruby/core/objectspace/weakkeymap/getkey_spec.rb @@ -6,7 +6,7 @@ key1, key2 = %w[a a].map(&:upcase) map[key1] = true - map.getkey(key2).should equal(key1) + map.getkey(key2).should.equal?(key1) map.getkey("X").should == nil key1.should == "A" # keep the key alive until here to keep the map entry diff --git a/spec/ruby/core/objectspace/weakmap/shared/each.rb b/spec/ruby/core/objectspace/weakmap/shared/each.rb index 3d43a19347971a..771c416dde174d 100644 --- a/spec/ruby/core/objectspace/weakmap/shared/each.rb +++ b/spec/ruby/core/objectspace/weakmap/shared/each.rb @@ -5,6 +5,6 @@ ref = "x" map.send(@method).should == map map[key] = ref - -> { map.send(@method) }.should raise_error(LocalJumpError) + -> { map.send(@method) }.should.raise(LocalJumpError) end end diff --git a/spec/ruby/core/proc/allocate_spec.rb b/spec/ruby/core/proc/allocate_spec.rb index 54e1b69df9f5ff..96c4eb9fa8ff17 100644 --- a/spec/ruby/core/proc/allocate_spec.rb +++ b/spec/ruby/core/proc/allocate_spec.rb @@ -4,6 +4,6 @@ it "raises a TypeError" do -> { Proc.allocate - }.should raise_error(TypeError) + }.should.raise(TypeError) end end diff --git a/spec/ruby/core/proc/binding_spec.rb b/spec/ruby/core/proc/binding_spec.rb index 86ab6bd400bc0c..d643cbf89cf006 100644 --- a/spec/ruby/core/proc/binding_spec.rb +++ b/spec/ruby/core/proc/binding_spec.rb @@ -3,7 +3,7 @@ describe "Proc#binding" do it "returns a Binding instance" do [Proc.new{}, -> {}, proc {}].each { |p| - p.binding.should be_kind_of(Binding) + p.binding.should.is_a?(Binding) } end diff --git a/spec/ruby/core/proc/block_pass_spec.rb b/spec/ruby/core/proc/block_pass_spec.rb index 411c0bf3dbea32..82c08db8a71e71 100644 --- a/spec/ruby/core/proc/block_pass_spec.rb +++ b/spec/ruby/core/proc/block_pass_spec.rb @@ -8,14 +8,14 @@ def revivify(&b) it "remains the same object if re-vivified by the target method" do p = Proc.new {} p2 = revivify(&p) - p.should equal p2 + p.should.equal? p2 p.should == p2 end it "remains the same object if reconstructed with Proc.new" do p = Proc.new {} p2 = Proc.new(&p) - p.should equal p2 + p.should.equal? p2 p.should == p2 end end diff --git a/spec/ruby/core/proc/clone_spec.rb b/spec/ruby/core/proc/clone_spec.rb index 7d47f2cde5b4a5..aee4873e0994ec 100644 --- a/spec/ruby/core/proc/clone_spec.rb +++ b/spec/ruby/core/proc/clone_spec.rb @@ -18,7 +18,7 @@ obj = ProcSpecs::MyProc2.new(:a, 2) { } dup = obj.clone - dup.should_not equal(obj) + dup.should_not.equal?(obj) dup.class.should == ProcSpecs::MyProc2 dup.first.should == :a diff --git a/spec/ruby/core/proc/curry_spec.rb b/spec/ruby/core/proc/curry_spec.rb index 6daabe0ee17051..de13983ca63e86 100644 --- a/spec/ruby/core/proc/curry_spec.rb +++ b/spec/ruby/core/proc/curry_spec.rb @@ -8,12 +8,12 @@ it "returns a Proc when called on a proc" do p = proc { true } - p.curry.should be_an_instance_of(Proc) + p.curry.should.instance_of?(Proc) end it "returns a Proc when called on a lambda" do p = -> { true } - p.curry.should be_an_instance_of(Proc) + p.curry.should.instance_of?(Proc) end it "calls the curried proc with the arguments if sufficient arguments have been given" do @@ -23,11 +23,11 @@ it "returns a Proc that consumes the remainder of the arguments unless sufficient arguments have been given" do proc2 = @proc_add.curry[1][2] - proc2.should be_an_instance_of(Proc) + proc2.should.instance_of?(Proc) proc2.call(3).should == 6 lambda2 = @lambda_add.curry[1][2] - lambda2.should be_an_instance_of(Proc) + lambda2.should.instance_of?(Proc) lambda2.call(3).should == 6 @proc_add.curry.call(1,2,3).should == 6 @@ -36,10 +36,10 @@ it "can be called multiple times on the same Proc" do @proc_add.curry - -> { @proc_add.curry }.should_not raise_error + -> { @proc_add.curry }.should_not.raise @lambda_add.curry - -> { @lambda_add.curry }.should_not raise_error + -> { @lambda_add.curry }.should_not.raise end it "can be passed superfluous arguments if created from a proc" do @@ -49,8 +49,8 @@ end it "raises an ArgumentError if passed superfluous arguments when created from a lambda" do - -> { @lambda_add.curry[1,2,3,4] }.should raise_error(ArgumentError) - -> { @lambda_add.curry[1,2].curry[3,4,5,6] }.should raise_error(ArgumentError) + -> { @lambda_add.curry[1,2,3,4] }.should.raise(ArgumentError) + -> { @lambda_add.curry[1,2].curry[3,4,5,6] }.should.raise(ArgumentError) end it "returns Procs with arities of -1" do @@ -63,7 +63,7 @@ it "produces Procs that raise ArgumentError for #binding" do -> do @proc_add.curry.binding - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "produces Procs that return [[:rest]] for #parameters" do @@ -98,41 +98,41 @@ end it "accepts an optional Integer argument for the arity" do - -> { @proc_add.curry(3) }.should_not raise_error - -> { @lambda_add.curry(3) }.should_not raise_error + -> { @proc_add.curry(3) }.should_not.raise + -> { @lambda_add.curry(3) }.should_not.raise end it "returns a Proc when called on a proc" do - @proc_add.curry(3).should be_an_instance_of(Proc) + @proc_add.curry(3).should.instance_of?(Proc) end it "returns a Proc when called on a lambda" do - @lambda_add.curry(3).should be_an_instance_of(Proc) + @lambda_add.curry(3).should.instance_of?(Proc) end # [ruby-core:24127] it "retains the lambda-ness of the Proc on which its called" do - @lambda_add.curry(3).lambda?.should be_true - @proc_add.curry(3).lambda?.should be_false + @lambda_add.curry(3).lambda?.should == true + @proc_add.curry(3).lambda?.should == false end it "raises an ArgumentError if called on a lambda that requires more than _arity_ arguments" do - -> { @lambda_add.curry(2) }.should raise_error(ArgumentError) - -> { -> x, y, z, *more{}.curry(2) }.should raise_error(ArgumentError) + -> { @lambda_add.curry(2) }.should.raise(ArgumentError) + -> { -> x, y, z, *more{}.curry(2) }.should.raise(ArgumentError) end it 'returns a Proc if called on a lambda that requires fewer than _arity_ arguments but may take more' do - -> a, b, c, d=nil, e=nil {}.curry(4).should be_an_instance_of(Proc) - -> a, b, c, d=nil, *e {}.curry(4).should be_an_instance_of(Proc) - -> a, b, c, *d {}.curry(4).should be_an_instance_of(Proc) + -> a, b, c, d=nil, e=nil {}.curry(4).should.instance_of?(Proc) + -> a, b, c, d=nil, *e {}.curry(4).should.instance_of?(Proc) + -> a, b, c, *d {}.curry(4).should.instance_of?(Proc) end it "raises an ArgumentError if called on a lambda that requires fewer than _arity_ arguments" do - -> { @lambda_add.curry(4) }.should raise_error(ArgumentError) - -> { -> { true }.curry(1) }.should raise_error(ArgumentError) - -> { -> a, b=nil {}.curry(5) }.should raise_error(ArgumentError) - -> { -> a, &b {}.curry(2) }.should raise_error(ArgumentError) - -> { -> a, b=nil, &c {}.curry(3) }.should raise_error(ArgumentError) + -> { @lambda_add.curry(4) }.should.raise(ArgumentError) + -> { -> { true }.curry(1) }.should.raise(ArgumentError) + -> { -> a, b=nil {}.curry(5) }.should.raise(ArgumentError) + -> { -> a, &b {}.curry(2) }.should.raise(ArgumentError) + -> { -> a, b=nil, &c {}.curry(3) }.should.raise(ArgumentError) end it "calls the curried proc with the arguments if _arity_ arguments have been given" do @@ -142,20 +142,20 @@ it "returns a Proc that consumes the remainder of the arguments when fewer than _arity_ arguments are given" do proc2 = @proc_add.curry(3)[1][2] - proc2.should be_an_instance_of(Proc) + proc2.should.instance_of?(Proc) proc2.call(3).should == 6 lambda2 = @lambda_add.curry(3)[1][2] - lambda2.should be_an_instance_of(Proc) + lambda2.should.instance_of?(Proc) lambda2.call(3).should == 6 end it "can be specified multiple times on the same Proc" do @proc_add.curry(2) - -> { @proc_add.curry(1) }.should_not raise_error + -> { @proc_add.curry(1) }.should_not.raise @lambda_add.curry(3) - -> { @lambda_add.curry(3) }.should_not raise_error + -> { @lambda_add.curry(3) }.should_not.raise end it "can be passed more than _arity_ arguments if created from a proc" do @@ -165,8 +165,8 @@ end it "raises an ArgumentError if passed more than _arity_ arguments when created from a lambda" do - -> { @lambda_add.curry(3)[1,2,3,4] }.should raise_error(ArgumentError) - -> { @lambda_add.curry(3)[1,2].curry(3)[3,4,5,6] }.should raise_error(ArgumentError) + -> { @lambda_add.curry(3)[1,2,3,4] }.should.raise(ArgumentError) + -> { @lambda_add.curry(3)[1,2].curry(3)[3,4,5,6] }.should.raise(ArgumentError) end it "returns Procs with arities of -1 regardless of the value of _arity_" do diff --git a/spec/ruby/core/proc/dup_spec.rb b/spec/ruby/core/proc/dup_spec.rb index bdb7d8ab5a4e82..8604389422210b 100644 --- a/spec/ruby/core/proc/dup_spec.rb +++ b/spec/ruby/core/proc/dup_spec.rb @@ -16,7 +16,7 @@ obj = ProcSpecs::MyProc2.new(:a, 2) { } dup = obj.dup - dup.should_not equal(obj) + dup.should_not.equal?(obj) dup.class.should == ProcSpecs::MyProc2 dup.first.should == :a diff --git a/spec/ruby/core/proc/element_reference_spec.rb b/spec/ruby/core/proc/element_reference_spec.rb index 81ceb91af5c40c..ea3a915a11257e 100644 --- a/spec/ruby/core/proc/element_reference_spec.rb +++ b/spec/ruby/core/proc/element_reference_spec.rb @@ -19,9 +19,9 @@ describe "Proc#[] with frozen_string_literal: true/false" do it "doesn't duplicate frozen strings" do - ProcArefSpecs.aref.frozen?.should be_false - ProcArefSpecs.aref_freeze.frozen?.should be_true - ProcArefFrozenSpecs.aref.frozen?.should be_true - ProcArefFrozenSpecs.aref_freeze.frozen?.should be_true + ProcArefSpecs.aref.frozen?.should == false + ProcArefSpecs.aref_freeze.frozen?.should == true + ProcArefFrozenSpecs.aref.frozen?.should == true + ProcArefFrozenSpecs.aref_freeze.frozen?.should == true end end diff --git a/spec/ruby/core/proc/hash_spec.rb b/spec/ruby/core/proc/hash_spec.rb index ebe0fde1a0c7cd..adcb1ccb78e416 100644 --- a/spec/ruby/core/proc/hash_spec.rb +++ b/spec/ruby/core/proc/hash_spec.rb @@ -2,12 +2,12 @@ describe "Proc#hash" do it "is provided" do - proc {}.respond_to?(:hash).should be_true - -> {}.respond_to?(:hash).should be_true + proc {}.respond_to?(:hash).should == true + -> {}.respond_to?(:hash).should == true end it "returns an Integer" do - proc { 1 + 489 }.hash.should be_kind_of(Integer) + proc { 1 + 489 }.hash.should.is_a?(Integer) end it "is stable" do diff --git a/spec/ruby/core/proc/lambda_spec.rb b/spec/ruby/core/proc/lambda_spec.rb index 67ee4645cd1f0a..1ff6147319dfc7 100644 --- a/spec/ruby/core/proc/lambda_spec.rb +++ b/spec/ruby/core/proc/lambda_spec.rb @@ -3,53 +3,53 @@ describe "Proc#lambda?" do it "returns true if the Proc was created from a block with the lambda keyword" do - -> {}.lambda?.should be_true + -> {}.lambda?.should == true end it "returns false if the Proc was created from a block with the proc keyword" do - proc {}.lambda?.should be_false + proc {}.lambda?.should == false end it "returns false if the Proc was created from a block with Proc.new" do - Proc.new {}.lambda?.should be_false + Proc.new {}.lambda?.should == false end it "is preserved when passing a Proc with & to the proc keyword" do - proc(&->{}).lambda?.should be_true - proc(&proc{}).lambda?.should be_false + proc(&->{}).lambda?.should == true + proc(&proc{}).lambda?.should == false end it "is preserved when passing a Proc with & to Proc.new" do - Proc.new(&->{}).lambda?.should be_true - Proc.new(&proc{}).lambda?.should be_false + Proc.new(&->{}).lambda?.should == true + Proc.new(&proc{}).lambda?.should == false end it "returns false if the Proc was created from a block with &" do - ProcSpecs.new_proc_from_amp{}.lambda?.should be_false + ProcSpecs.new_proc_from_amp{}.lambda?.should == false end it "is preserved when the Proc was passed using &" do - ProcSpecs.new_proc_from_amp(&->{}).lambda?.should be_true - ProcSpecs.new_proc_from_amp(&proc{}).lambda?.should be_false - ProcSpecs.new_proc_from_amp(&Proc.new{}).lambda?.should be_false + ProcSpecs.new_proc_from_amp(&->{}).lambda?.should == true + ProcSpecs.new_proc_from_amp(&proc{}).lambda?.should == false + ProcSpecs.new_proc_from_amp(&Proc.new{}).lambda?.should == false end it "returns true for a Method converted to a Proc" do m = :foo.method(:to_s) - m.to_proc.lambda?.should be_true - ProcSpecs.new_proc_from_amp(&m).lambda?.should be_true + m.to_proc.lambda?.should == true + ProcSpecs.new_proc_from_amp(&m).lambda?.should == true end # [ruby-core:24127] it "is preserved when a Proc is curried" do - ->{}.curry.lambda?.should be_true - proc{}.curry.lambda?.should be_false - Proc.new{}.curry.lambda?.should be_false + ->{}.curry.lambda?.should == true + proc{}.curry.lambda?.should == false + Proc.new{}.curry.lambda?.should == false end it "is preserved when a curried Proc is called without enough arguments" do - -> x, y{}.curry.call(42).lambda?.should be_true - proc{|x,y|}.curry.call(42).lambda?.should be_false - Proc.new{|x,y|}.curry.call(42).lambda?.should be_false + -> x, y{}.curry.call(42).lambda?.should == true + proc{|x,y|}.curry.call(42).lambda?.should == false + Proc.new{|x,y|}.curry.call(42).lambda?.should == false end end diff --git a/spec/ruby/core/proc/new_spec.rb b/spec/ruby/core/proc/new_spec.rb index b2b73877561894..f0b817f0cbec78 100644 --- a/spec/ruby/core/proc/new_spec.rb +++ b/spec/ruby/core/proc/new_spec.rb @@ -71,7 +71,7 @@ def some_method end res = some_method() - -> { res.call }.should raise_error(LocalJumpError) + -> { res.call }.should.raise(LocalJumpError) end it "returns from within enclosing method when 'return' is used in the block" do @@ -86,7 +86,7 @@ def some_method it "returns a subclass of Proc" do obj = ProcSpecs::MyProc.new { } - obj.should be_kind_of(ProcSpecs::MyProc) + obj.should.is_a?(ProcSpecs::MyProc) end it "calls initialize on the Proc object" do @@ -101,7 +101,7 @@ def some_method passed_prc = Proc.new { "hello".size } prc = Proc.new(&passed_prc) - prc.should equal(passed_prc) + prc.should.equal?(passed_prc) prc.call.should == 5 end @@ -110,7 +110,7 @@ def some_method passed_prc = Proc.new(&method) prc = Proc.new(&passed_prc) - prc.should equal(passed_prc) + prc.should.equal?(passed_prc) prc.call.should == 5 end @@ -118,7 +118,7 @@ def some_method passed_prc = Proc.new(&:size) prc = Proc.new(&passed_prc) - prc.should equal(passed_prc) + prc.should.equal?(passed_prc) prc.call("hello").should == 5 end end @@ -129,7 +129,7 @@ def some_method passed_prc.class.should == ProcSpecs::MyProc prc = ProcSpecs::MyProc.new(&passed_prc) - prc.should equal(passed_prc) + prc.should.equal?(passed_prc) prc.call.should == 5 end @@ -139,7 +139,7 @@ def some_method passed_prc.class.should == ProcSpecs::MyProc prc = ProcSpecs::MyProc.new(&passed_prc) - prc.should equal(passed_prc) + prc.should.equal?(passed_prc) prc.call.should == 5 end @@ -148,22 +148,22 @@ def some_method passed_prc.class.should == ProcSpecs::MyProc prc = ProcSpecs::MyProc.new(&passed_prc) - prc.should equal(passed_prc) + prc.should.equal?(passed_prc) prc.call("hello").should == 5 end end describe "Proc.new without a block" do it "raises an ArgumentError" do - -> { Proc.new }.should raise_error(ArgumentError) + -> { Proc.new }.should.raise(ArgumentError) end it "raises an ArgumentError if invoked from within a method with no block" do - -> { ProcSpecs.new_proc_in_method }.should raise_error(ArgumentError) + -> { ProcSpecs.new_proc_in_method }.should.raise(ArgumentError) end it "raises an ArgumentError if invoked on a subclass from within a method with no block" do - -> { ProcSpecs.new_proc_subclass_in_method }.should raise_error(ArgumentError) + -> { ProcSpecs.new_proc_subclass_in_method }.should.raise(ArgumentError) end it "raises an ArgumentError when passed no block" do @@ -171,8 +171,8 @@ def some_method Proc.new end - -> { ProcSpecs.new_proc_in_method { "hello" } }.should raise_error(ArgumentError, 'tried to create Proc object without a block') - -> { ProcSpecs.new_proc_subclass_in_method { "hello" } }.should raise_error(ArgumentError, 'tried to create Proc object without a block') - -> { some_method { "hello" } }.should raise_error(ArgumentError, 'tried to create Proc object without a block') + -> { ProcSpecs.new_proc_in_method { "hello" } }.should.raise(ArgumentError, 'tried to create Proc object without a block') + -> { ProcSpecs.new_proc_subclass_in_method { "hello" } }.should.raise(ArgumentError, 'tried to create Proc object without a block') + -> { some_method { "hello" } }.should.raise(ArgumentError, 'tried to create Proc object without a block') end end diff --git a/spec/ruby/core/proc/parameters_spec.rb b/spec/ruby/core/proc/parameters_spec.rb index 0876ad0daf6b3a..ac8c6e35601da4 100644 --- a/spec/ruby/core/proc/parameters_spec.rb +++ b/spec/ruby/core/proc/parameters_spec.rb @@ -7,8 +7,8 @@ it "returns an Array of Arrays for a proc expecting parameters" do p = proc {|x| } - p.parameters.should be_an_instance_of(Array) - p.parameters.first.should be_an_instance_of(Array) + p.parameters.should.instance_of?(Array) + p.parameters.first.should.instance_of?(Array) end it "sets the first element of each sub-Array to :opt for optional arguments" do diff --git a/spec/ruby/core/proc/ruby2_keywords_spec.rb b/spec/ruby/core/proc/ruby2_keywords_spec.rb index d7f8f592e1dc6e..e06fad8693d093 100644 --- a/spec/ruby/core/proc/ruby2_keywords_spec.rb +++ b/spec/ruby/core/proc/ruby2_keywords_spec.rb @@ -27,7 +27,7 @@ it "returns self" do f = -> *a { } - f.ruby2_keywords.should equal f + f.ruby2_keywords.should.equal? f end it "prints warning when a proc does not accept argument splat" do diff --git a/spec/ruby/core/proc/shared/call.rb b/spec/ruby/core/proc/shared/call.rb index dbec34df4bffe6..fae2331b68ed20 100644 --- a/spec/ruby/core/proc/shared/call.rb +++ b/spec/ruby/core/proc/shared/call.rb @@ -70,21 +70,21 @@ it "raises an ArgumentError on excess arguments when self is a lambda" do -> { -> x { x }.send(@method, 1, 2) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { -> x { x }.send(@method, 1, 2, 3) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an ArgumentError on missing arguments when self is a lambda" do -> { -> x { x }.send(@method) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { -> x, y { [x,y] }.send(@method, 1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "treats a single Array argument as a single argument when self is a lambda" do diff --git a/spec/ruby/core/proc/shared/compose.rb b/spec/ruby/core/proc/shared/compose.rb index 3d3f3b310d4699..c004cec7c9344b 100644 --- a/spec/ruby/core/proc/shared/compose.rb +++ b/spec/ruby/core/proc/shared/compose.rb @@ -5,7 +5,7 @@ -> { lhs.send(@method, not_callable) - }.should raise_error(TypeError, "callable object is expected") + }.should.raise(TypeError, "callable object is expected") end @@ -17,6 +17,6 @@ def succ.to_proc(s); s.succ; end -> { lhs.send(@method, succ) - }.should raise_error(TypeError, "callable object is expected") + }.should.raise(TypeError, "callable object is expected") end end diff --git a/spec/ruby/core/proc/shared/dup.rb b/spec/ruby/core/proc/shared/dup.rb index 1266337f94b1e2..2821d2e00f2ce1 100644 --- a/spec/ruby/core/proc/shared/dup.rb +++ b/spec/ruby/core/proc/shared/dup.rb @@ -3,7 +3,7 @@ a = -> { "hello" } b = a.send(@method) - a.should_not equal(b) + a.should_not.equal?(b) a.call.should == b.call end diff --git a/spec/ruby/core/proc/shared/equal.rb b/spec/ruby/core/proc/shared/equal.rb index d0503fb06410db..4f6f6c41be04ec 100644 --- a/spec/ruby/core/proc/shared/equal.rb +++ b/spec/ruby/core/proc/shared/equal.rb @@ -3,29 +3,29 @@ describe :proc_equal, shared: true do it "is a public method" do - Proc.should have_public_instance_method(@method, false) + Proc.public_instance_methods(false).should.include?(@method) end it "returns true if self and other are the same object" do p = proc { :foo } - p.send(@method, p).should be_true + p.send(@method, p).should == true p = Proc.new { :foo } - p.send(@method, p).should be_true + p.send(@method, p).should == true p = -> { :foo } - p.send(@method, p).should be_true + p.send(@method, p).should == true end it "returns true if other is a dup of the original" do p = proc { :foo } - p.send(@method, p.dup).should be_true + p.send(@method, p.dup).should == true p = Proc.new { :foo } - p.send(@method, p.dup).should be_true + p.send(@method, p.dup).should == true p = -> { :foo } - p.send(@method, p.dup).should be_true + p.send(@method, p.dup).should == true end # identical here means the same method invocation. @@ -33,51 +33,51 @@ a = ProcSpecs.proc_for_1 b = ProcSpecs.proc_for_1 - a.send(@method, b).should be_false + a.send(@method, b).should == false end it "returns false if procs are distinct but have the same body and environment" do p = proc { :foo } p2 = proc { :foo } - p.send(@method, p2).should be_false + p.send(@method, p2).should == false end it "returns false if lambdas are distinct but have same body and environment" do x = -> { :foo } x2 = -> { :foo } - x.send(@method, x2).should be_false + x.send(@method, x2).should == false end it "returns false if using comparing lambda to proc, even with the same body and env" do p = -> { :foo } p2 = proc { :foo } - p.send(@method, p2).should be_false + p.send(@method, p2).should == false x = proc { :bar } x2 = -> { :bar } - x.send(@method, x2).should be_false + x.send(@method, x2).should == false end it "returns false if other is not a Proc" do p = proc { :foo } - p.send(@method, []).should be_false + p.send(@method, []).should == false p = Proc.new { :foo } - p.send(@method, Object.new).should be_false + p.send(@method, Object.new).should == false p = -> { :foo } - p.send(@method, :foo).should be_false + p.send(@method, :foo).should == false end it "returns false if self and other are both procs but have different bodies" do p = proc { :bar } p2 = proc { :foo } - p.send(@method, p2).should be_false + p.send(@method, p2).should == false end it "returns false if self and other are both lambdas but have different bodies" do p = -> { :foo } p2 = -> { :bar } - p.send(@method, p2).should be_false + p.send(@method, p2).should == false end end diff --git a/spec/ruby/core/proc/source_location_spec.rb b/spec/ruby/core/proc/source_location_spec.rb index a8b99287d5c380..d27ad0559e1be7 100644 --- a/spec/ruby/core/proc/source_location_spec.rb +++ b/spec/ruby/core/proc/source_location_spec.rb @@ -10,45 +10,45 @@ end it "returns an Array" do - @proc.source_location.should be_an_instance_of(Array) - @proc_new.source_location.should be_an_instance_of(Array) - @lambda.source_location.should be_an_instance_of(Array) - @method.source_location.should be_an_instance_of(Array) + @proc.source_location.should.instance_of?(Array) + @proc_new.source_location.should.instance_of?(Array) + @lambda.source_location.should.instance_of?(Array) + @method.source_location.should.instance_of?(Array) end it "sets the first value to the path of the file in which the proc was defined" do file = @proc.source_location.first - file.should be_an_instance_of(String) + file.should.instance_of?(String) file.should == File.realpath('fixtures/source_location.rb', __dir__) file = @proc_new.source_location.first - file.should be_an_instance_of(String) + file.should.instance_of?(String) file.should == File.realpath('fixtures/source_location.rb', __dir__) file = @lambda.source_location.first - file.should be_an_instance_of(String) + file.should.instance_of?(String) file.should == File.realpath('fixtures/source_location.rb', __dir__) file = @method.source_location.first - file.should be_an_instance_of(String) + file.should.instance_of?(String) file.should == File.realpath('fixtures/source_location.rb', __dir__) end it "sets the last value to an Integer representing the line on which the proc was defined" do line = @proc.source_location.last - line.should be_an_instance_of(Integer) + line.should.instance_of?(Integer) line.should == 4 line = @proc_new.source_location.last - line.should be_an_instance_of(Integer) + line.should.instance_of?(Integer) line.should == 12 line = @lambda.source_location.last - line.should be_an_instance_of(Integer) + line.should.instance_of?(Integer) line.should == 8 line = @method.source_location.last - line.should be_an_instance_of(Integer) + line.should.instance_of?(Integer) line.should == 15 end diff --git a/spec/ruby/core/proc/to_proc_spec.rb b/spec/ruby/core/proc/to_proc_spec.rb index ffaa34929b9f58..7f35a4f19bfc40 100644 --- a/spec/ruby/core/proc/to_proc_spec.rb +++ b/spec/ruby/core/proc/to_proc_spec.rb @@ -3,7 +3,7 @@ describe "Proc#to_proc" do it "returns self" do [Proc.new {}, -> {}, proc {}].each { |p| - p.to_proc.should equal(p) + p.to_proc.should.equal?(p) } end end diff --git a/spec/ruby/core/process/_fork_spec.rb b/spec/ruby/core/process/_fork_spec.rb index e1f45e2656de1a..620f243ce5d984 100644 --- a/spec/ruby/core/process/_fork_spec.rb +++ b/spec/ruby/core/process/_fork_spec.rb @@ -9,7 +9,7 @@ # are that _fork is implemented if and only if fork is (see above). guard_not -> { Process.respond_to?(:fork) } do it "raises a NotImplementedError when called" do - -> { Process._fork }.should raise_error(NotImplementedError) + -> { Process._fork }.should.raise(NotImplementedError) end end @@ -18,7 +18,7 @@ Process.should_receive(:_fork).once.and_return(42) pid = Process.fork {} - pid.should equal(42) + pid.should.equal?(42) end end end diff --git a/spec/ruby/core/process/argv0_spec.rb b/spec/ruby/core/process/argv0_spec.rb index 9cba382c009da4..4c7a2c9ecbfb1f 100644 --- a/spec/ruby/core/process/argv0_spec.rb +++ b/spec/ruby/core/process/argv0_spec.rb @@ -2,7 +2,7 @@ describe "Process.argv0" do it "returns a String" do - Process.argv0.should be_kind_of(String) + Process.argv0.should.is_a?(String) end it "is the path given as the main script and the same as __FILE__" do diff --git a/spec/ruby/core/process/clock_gettime_spec.rb b/spec/ruby/core/process/clock_gettime_spec.rb index 6c1a52f21edd85..88158904e14ca9 100644 --- a/spec/ruby/core/process/clock_gettime_spec.rb +++ b/spec/ruby/core/process/clock_gettime_spec.rb @@ -4,31 +4,31 @@ describe "Process.clock_gettime" do ProcessSpecs.clock_constants.each do |name, value| it "can be called with Process::#{name}" do - Process.clock_gettime(value).should be_an_instance_of(Float) + Process.clock_gettime(value).should.instance_of?(Float) end end describe 'time units' do it 'handles a fixed set of time units' do [:nanosecond, :microsecond, :millisecond, :second].each do |unit| - Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should be_kind_of(Integer) + Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should.is_a?(Integer) end [:float_microsecond, :float_millisecond, :float_second].each do |unit| - Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC, unit).should.instance_of?(Float) end end it 'raises an ArgumentError for an invalid time unit' do - -> { Process.clock_gettime(Process::CLOCK_MONOTONIC, :bad) }.should raise_error(ArgumentError) + -> { Process.clock_gettime(Process::CLOCK_MONOTONIC, :bad) }.should.raise(ArgumentError) end it 'defaults to :float_second' do t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC) t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second) - t1.should be_an_instance_of(Float) - t2.should be_an_instance_of(Float) + t1.should.instance_of?(Float) + t2.should.instance_of?(Float) t2.should be_close(t1, TIME_TOLERANCE) end @@ -36,116 +36,116 @@ t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC, nil) t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC, :float_second) - t1.should be_an_instance_of(Float) - t2.should be_an_instance_of(Float) + t1.should.instance_of?(Float) + t2.should.instance_of?(Float) t2.should be_close(t1, TIME_TOLERANCE) end end describe "supports the platform clocks mentioned in the documentation" do it "CLOCK_REALTIME" do - Process.clock_gettime(Process::CLOCK_REALTIME).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_REALTIME).should.instance_of?(Float) end it "CLOCK_MONOTONIC" do - Process.clock_gettime(Process::CLOCK_MONOTONIC).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC).should.instance_of?(Float) end # These specs need macOS 10.12+ / darwin 16+ guard -> { platform_is_not(:darwin) or kernel_version_is '16' } do platform_is :linux, :openbsd, :darwin do it "CLOCK_PROCESS_CPUTIME_ID" do - Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID).should.instance_of?(Float) end end platform_is :linux, :freebsd, :openbsd, :darwin do it "CLOCK_THREAD_CPUTIME_ID" do - Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID).should.instance_of?(Float) end end platform_is :linux, :darwin do it "CLOCK_MONOTONIC_RAW" do - Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW).should.instance_of?(Float) end end platform_is :darwin do it "CLOCK_MONOTONIC_RAW_APPROX" do - Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW_APPROX).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW_APPROX).should.instance_of?(Float) end it "CLOCK_UPTIME_RAW and CLOCK_UPTIME_RAW_APPROX" do - Process.clock_gettime(Process::CLOCK_UPTIME_RAW).should be_an_instance_of(Float) - Process.clock_gettime(Process::CLOCK_UPTIME_RAW_APPROX).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_UPTIME_RAW).should.instance_of?(Float) + Process.clock_gettime(Process::CLOCK_UPTIME_RAW_APPROX).should.instance_of?(Float) end end end platform_is :freebsd do it "CLOCK_VIRTUAL" do - Process.clock_gettime(Process::CLOCK_VIRTUAL).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_VIRTUAL).should.instance_of?(Float) end it "CLOCK_PROF" do - Process.clock_gettime(Process::CLOCK_PROF).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_PROF).should.instance_of?(Float) end end platform_is :freebsd, :openbsd do it "CLOCK_UPTIME" do - Process.clock_gettime(Process::CLOCK_UPTIME).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_UPTIME).should.instance_of?(Float) end end platform_is :freebsd do it "CLOCK_REALTIME_FAST and CLOCK_REALTIME_PRECISE" do - Process.clock_gettime(Process::CLOCK_REALTIME_FAST).should be_an_instance_of(Float) - Process.clock_gettime(Process::CLOCK_REALTIME_PRECISE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_REALTIME_FAST).should.instance_of?(Float) + Process.clock_gettime(Process::CLOCK_REALTIME_PRECISE).should.instance_of?(Float) end it "CLOCK_MONOTONIC_FAST and CLOCK_MONOTONIC_PRECISE" do - Process.clock_gettime(Process::CLOCK_MONOTONIC_FAST).should be_an_instance_of(Float) - Process.clock_gettime(Process::CLOCK_MONOTONIC_PRECISE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_FAST).should.instance_of?(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_PRECISE).should.instance_of?(Float) end it "CLOCK_UPTIME_FAST and CLOCK_UPTIME_PRECISE" do - Process.clock_gettime(Process::CLOCK_UPTIME_FAST).should be_an_instance_of(Float) - Process.clock_gettime(Process::CLOCK_UPTIME_PRECISE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_UPTIME_FAST).should.instance_of?(Float) + Process.clock_gettime(Process::CLOCK_UPTIME_PRECISE).should.instance_of?(Float) end it "CLOCK_SECOND" do - Process.clock_gettime(Process::CLOCK_SECOND).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_SECOND).should.instance_of?(Float) end end guard -> { platform_is :linux and kernel_version_is '2.6.32' } do it "CLOCK_REALTIME_COARSE" do - Process.clock_gettime(Process::CLOCK_REALTIME_COARSE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_REALTIME_COARSE).should.instance_of?(Float) end it "CLOCK_MONOTONIC_COARSE" do - Process.clock_gettime(Process::CLOCK_MONOTONIC_COARSE).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_MONOTONIC_COARSE).should.instance_of?(Float) end end guard -> { platform_is :linux and kernel_version_is '2.6.39' } do it "CLOCK_BOOTTIME" do skip "No Process::CLOCK_BOOTTIME" unless defined?(Process::CLOCK_BOOTTIME) - Process.clock_gettime(Process::CLOCK_BOOTTIME).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_BOOTTIME).should.instance_of?(Float) end end guard -> { platform_is "x86_64-linux" and kernel_version_is '3.0' } do it "CLOCK_REALTIME_ALARM" do skip "No Process::CLOCK_REALTIME_ALARM" unless defined?(Process::CLOCK_REALTIME_ALARM) - Process.clock_gettime(Process::CLOCK_REALTIME_ALARM).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_REALTIME_ALARM).should.instance_of?(Float) end it "CLOCK_BOOTTIME_ALARM" do skip "No Process::CLOCK_BOOTTIME_ALARM" unless defined?(Process::CLOCK_BOOTTIME_ALARM) - Process.clock_gettime(Process::CLOCK_BOOTTIME_ALARM).should be_an_instance_of(Float) + Process.clock_gettime(Process::CLOCK_BOOTTIME_ALARM).should.instance_of?(Float) end end end diff --git a/spec/ruby/core/process/constants_spec.rb b/spec/ruby/core/process/constants_spec.rb index 57cacadef2ba7b..62e8f2ee4ae910 100644 --- a/spec/ruby/core/process/constants_spec.rb +++ b/spec/ruby/core/process/constants_spec.rb @@ -20,8 +20,8 @@ RLIMIT_NPROC RLIMIT_NOFILE ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -33,8 +33,8 @@ RLIM_SAVED_CUR RLIMIT_AS ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -61,8 +61,8 @@ RLIM_SAVED_MAX RLIM_SAVED_CUR ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -73,8 +73,8 @@ RLIMIT_SBSIZE RLIMIT_AS ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -84,8 +84,8 @@ %i[ RLIMIT_NPTS ].each do |const| - Process.const_defined?(const).should be_true - Process.const_get(const).should be_an_instance_of(Integer) + Process.const_defined?(const).should == true + Process.const_get(const).should.instance_of?(Integer) end end end @@ -107,7 +107,7 @@ RLIM_SAVED_MAX RLIM_SAVED_CUR ].each do |const| - Process.const_defined?(const).should be_false + Process.const_defined?(const).should == false end end end diff --git a/spec/ruby/core/process/daemon_spec.rb b/spec/ruby/core/process/daemon_spec.rb index 20b0d743b9a907..9b7eba14118096 100644 --- a/spec/ruby/core/process/daemon_spec.rb +++ b/spec/ruby/core/process/daemon_spec.rb @@ -112,7 +112,7 @@ it "raises a NotImplementedError" do -> { Process.daemon - }.should raise_error(NotImplementedError) + }.should.raise(NotImplementedError) end end end diff --git a/spec/ruby/core/process/detach_spec.rb b/spec/ruby/core/process/detach_spec.rb index f5f3b263f5de9b..33c674394e2bee 100644 --- a/spec/ruby/core/process/detach_spec.rb +++ b/spec/ruby/core/process/detach_spec.rb @@ -5,7 +5,7 @@ it "returns a thread" do pid = Process.fork { Process.exit! } thr = Process.detach(pid) - thr.should be_kind_of(Thread) + thr.should.is_a?(Thread) thr.join end @@ -15,7 +15,7 @@ thr.join status = thr.value - status.should be_kind_of(Process::Status) + status.should.is_a?(Process::Status) status.pid.should == pid end @@ -23,7 +23,7 @@ it "reaps the child process's status automatically" do pid = Process.fork { Process.exit! } Process.detach(pid).join - -> { Process.waitpid(pid) }.should raise_error(Errno::ECHILD) + -> { Process.waitpid(pid) }.should.raise(Errno::ECHILD) end end @@ -52,12 +52,12 @@ # Command `kill 0 pid`: # - returns "1" if a process exists and # - raises Errno::ESRCH otherwise - -> { Process.kill(0, pid_not_existing) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid_not_existing) }.should.raise(Errno::ESRCH) thr = Process.detach(pid_not_existing) thr.join - thr.should be_kind_of(Thread) + thr.should.is_a?(Thread) end it "calls #to_int to implicitly convert non-Integer pid to Integer" do @@ -68,7 +68,7 @@ end it "raises TypeError when pid argument does not have #to_int method" do - -> { Process.detach(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into Integer") + -> { Process.detach(Object.new) }.should.raise(TypeError, "no implicit conversion of Object into Integer") end it "raises TypeError when #to_int returns non-Integer value" do diff --git a/spec/ruby/core/process/egid_spec.rb b/spec/ruby/core/process/egid_spec.rb index a67b623d5c066c..69c86bebe22384 100644 --- a/spec/ruby/core/process/egid_spec.rb +++ b/spec/ruby/core/process/egid_spec.rb @@ -2,7 +2,7 @@ describe "Process.egid" do it "returns the effective group ID for this process" do - Process.egid.should be_kind_of(Integer) + Process.egid.should.is_a?(Integer) end it "also goes by Process::GID.eid" do @@ -18,7 +18,7 @@ platform_is_not :windows do it "raises TypeError if not passed an Integer or String" do - -> { Process.egid = Object.new }.should raise_error(TypeError) + -> { Process.egid = Object.new }.should.raise(TypeError) end it "sets the effective group id to its own gid if given the username corresponding to its own gid" do @@ -33,12 +33,12 @@ as_user do it "raises Errno::ERPERM if run by a non superuser trying to set the root group id" do - -> { Process.egid = 0 }.should raise_error(Errno::EPERM) + -> { Process.egid = 0 }.should.raise(Errno::EPERM) end platform_is :linux do it "raises Errno::ERPERM if run by a non superuser trying to set the group id from group name" do - -> { Process.egid = "root" }.should raise_error(Errno::EPERM) + -> { Process.egid = "root" }.should.raise(Errno::EPERM) end end end diff --git a/spec/ruby/core/process/euid_spec.rb b/spec/ruby/core/process/euid_spec.rb index c1ec4171d0d242..da76f06e597941 100644 --- a/spec/ruby/core/process/euid_spec.rb +++ b/spec/ruby/core/process/euid_spec.rb @@ -2,7 +2,7 @@ describe "Process.euid" do it "returns the effective user ID for this process" do - Process.euid.should be_kind_of(Integer) + Process.euid.should.is_a?(Integer) end it "also goes by Process::UID.eid" do @@ -18,7 +18,7 @@ platform_is_not :windows do it "raises TypeError if not passed an Integer" do - -> { Process.euid = Object.new }.should raise_error(TypeError) + -> { Process.euid = Object.new }.should.raise(TypeError) end it "sets the effective user id to its own uid if given the username corresponding to its own uid" do @@ -33,11 +33,11 @@ as_user do it "raises Errno::ERPERM if run by a non superuser trying to set the superuser id" do - -> { Process.euid = 0 }.should raise_error(Errno::EPERM) + -> { Process.euid = 0 }.should.raise(Errno::EPERM) end it "raises Errno::ERPERM if run by a non superuser trying to set the superuser id from username" do - -> { Process.euid = "root" }.should raise_error(Errno::EPERM) + -> { Process.euid = "root" }.should.raise(Errno::EPERM) end end diff --git a/spec/ruby/core/process/exec_spec.rb b/spec/ruby/core/process/exec_spec.rb index 0f371b39c81499..a48d461b026d8c 100644 --- a/spec/ruby/core/process/exec_spec.rb +++ b/spec/ruby/core/process/exec_spec.rb @@ -2,35 +2,35 @@ describe "Process.exec" do it "raises Errno::ENOENT for an empty string" do - -> { Process.exec "" }.should raise_error(Errno::ENOENT) + -> { Process.exec "" }.should.raise(Errno::ENOENT) end it "raises Errno::ENOENT for a command which does not exist" do - -> { Process.exec "bogus-noent-script.sh" }.should raise_error(Errno::ENOENT) + -> { Process.exec "bogus-noent-script.sh" }.should.raise(Errno::ENOENT) end it "raises an ArgumentError if the command includes a null byte" do - -> { Process.exec "\000" }.should raise_error(ArgumentError) + -> { Process.exec "\000" }.should.raise(ArgumentError) end unless File.executable?(__FILE__) # Some FS (e.g. vboxfs) locate all files executable platform_is_not :windows do it "raises Errno::EACCES when the file does not have execute permissions" do - -> { Process.exec __FILE__ }.should raise_error(Errno::EACCES) + -> { Process.exec __FILE__ }.should.raise(Errno::EACCES) end end platform_is :windows do it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do - -> { Process.exec __FILE__ }.should raise_error(SystemCallError) { |e| - [Errno::EACCES, Errno::ENOEXEC].should include(e.class) + -> { Process.exec __FILE__ }.should.raise(SystemCallError) { |e| + [Errno::EACCES, Errno::ENOEXEC].should.include?(e.class) } end end end it "raises Errno::EACCES when passed a directory" do - -> { Process.exec __dir__ }.should raise_error(Errno::EACCES) + -> { Process.exec __dir__ }.should.raise(Errno::EACCES) end it "runs the specified command, replacing current process" do @@ -171,9 +171,9 @@ end it "raises an ArgumentError if the Array does not have exactly two elements" do - -> { Process.exec([]) }.should raise_error(ArgumentError) - -> { Process.exec([:a]) }.should raise_error(ArgumentError) - -> { Process.exec([:a, :b, :c]) }.should raise_error(ArgumentError) + -> { Process.exec([]) }.should.raise(ArgumentError) + -> { Process.exec([:a]) }.should.raise(ArgumentError) + -> { Process.exec([:a, :b, :c]) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/process/getpriority_spec.rb b/spec/ruby/core/process/getpriority_spec.rb index a35e5956a5854e..53fe7bfe207e27 100644 --- a/spec/ruby/core/process/getpriority_spec.rb +++ b/spec/ruby/core/process/getpriority_spec.rb @@ -5,19 +5,19 @@ it "coerces arguments to Integers" do ret = Process.getpriority mock_int(Process::PRIO_PROCESS), mock_int(0) - ret.should be_kind_of(Integer) + ret.should.is_a?(Integer) end it "gets the scheduling priority for a specified process" do - Process.getpriority(Process::PRIO_PROCESS, 0).should be_kind_of(Integer) + Process.getpriority(Process::PRIO_PROCESS, 0).should.is_a?(Integer) end it "gets the scheduling priority for a specified process group" do - Process.getpriority(Process::PRIO_PGRP, 0).should be_kind_of(Integer) + Process.getpriority(Process::PRIO_PGRP, 0).should.is_a?(Integer) end it "gets the scheduling priority for a specified user" do - Process.getpriority(Process::PRIO_USER, 0).should be_kind_of(Integer) + Process.getpriority(Process::PRIO_USER, 0).should.is_a?(Integer) end end end diff --git a/spec/ruby/core/process/getrlimit_spec.rb b/spec/ruby/core/process/getrlimit_spec.rb index 883b8fac48b77e..d36d8c3335d778 100644 --- a/spec/ruby/core/process/getrlimit_spec.rb +++ b/spec/ruby/core/process/getrlimit_spec.rb @@ -16,8 +16,8 @@ it "returns a two-element Array of Integers" do result = Process.getrlimit Process::RLIMIT_CORE result.size.should == 2 - result.first.should be_kind_of(Integer) - result.last.should be_kind_of(Integer) + result.first.should.is_a?(Integer) + result.last.should.is_a?(Integer) end context "when passed an Object" do @@ -36,7 +36,7 @@ obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - -> { Process.getrlimit(obj) }.should raise_error(TypeError) + -> { Process.getrlimit(obj) }.should.raise(TypeError) end end @@ -49,7 +49,7 @@ end it "raises ArgumentError when passed an unknown resource" do - -> { Process.getrlimit(:FOO) }.should raise_error(ArgumentError) + -> { Process.getrlimit(:FOO) }.should.raise(ArgumentError) end end @@ -62,7 +62,7 @@ end it "raises ArgumentError when passed an unknown resource" do - -> { Process.getrlimit("FOO") }.should raise_error(ArgumentError) + -> { Process.getrlimit("FOO") }.should.raise(ArgumentError) end end @@ -91,10 +91,10 @@ platform_is :windows do it "is not implemented" do - Process.respond_to?(:getrlimit).should be_false + Process.respond_to?(:getrlimit).should == false -> do Process.getrlimit(nil) - end.should raise_error NotImplementedError + end.should.raise NotImplementedError end end end diff --git a/spec/ruby/core/process/groups_spec.rb b/spec/ruby/core/process/groups_spec.rb index 33e0f9d7b3daee..fa916671a4913f 100644 --- a/spec/ruby/core/process/groups_spec.rb +++ b/spec/ruby/core/process/groups_spec.rb @@ -50,7 +50,7 @@ Process.groups.should == [ Process.gid ] supplementary = groups - [ Process.gid ] if supplementary.length > 0 - -> { Process.groups = supplementary }.should raise_error(Errno::EPERM) + -> { Process.groups = supplementary }.should.raise(Errno::EPERM) end end end @@ -59,7 +59,7 @@ it "raises Errno::EPERM" do -> { Process.groups = [0] - }.should raise_error(Errno::EPERM) + }.should.raise(Errno::EPERM) end end end diff --git a/spec/ruby/core/process/initgroups_spec.rb b/spec/ruby/core/process/initgroups_spec.rb index ffc7f282b69f50..d9f31936cbd5d2 100644 --- a/spec/ruby/core/process/initgroups_spec.rb +++ b/spec/ruby/core/process/initgroups_spec.rb @@ -14,7 +14,7 @@ Process.groups.sort.should == augmented_groups.sort Process.groups = groups else - -> { Process.initgroups(name, gid) }.should raise_error(Errno::EPERM) + -> { Process.initgroups(name, gid) }.should.raise(Errno::EPERM) end end end diff --git a/spec/ruby/core/process/kill_spec.rb b/spec/ruby/core/process/kill_spec.rb index af9c9e6debcb46..885c2bf2b79530 100644 --- a/spec/ruby/core/process/kill_spec.rb +++ b/spec/ruby/core/process/kill_spec.rb @@ -9,18 +9,18 @@ end it "raises an ArgumentError for unknown signals" do - -> { Process.kill("FOO", @pid) }.should raise_error(ArgumentError) + -> { Process.kill("FOO", @pid) }.should.raise(ArgumentError) end it "raises an ArgumentError if passed a lowercase signal name" do - -> { Process.kill("term", @pid) }.should raise_error(ArgumentError) + -> { Process.kill("term", @pid) }.should.raise(ArgumentError) end it "raises an ArgumentError if signal is not an Integer or String" do signal = mock("process kill signal") signal.should_not_receive(:to_int) - -> { Process.kill(signal, @pid) }.should raise_error(ArgumentError) + -> { Process.kill(signal, @pid) }.should.raise(ArgumentError) end it "raises Errno::ESRCH if the process does not exist" do @@ -29,7 +29,7 @@ Process.wait(pid) -> { Process.kill("SIGKILL", pid) - }.should raise_error(Errno::ESRCH) + }.should.raise(Errno::ESRCH) end it "checks for existence and permissions to signal a process, but does not actually signal it, when using signal 0" do diff --git a/spec/ruby/core/process/last_status_spec.rb b/spec/ruby/core/process/last_status_spec.rb index 2372f2aae3bb0b..1bd8adf7989359 100644 --- a/spec/ruby/core/process/last_status_spec.rb +++ b/spec/ruby/core/process/last_status_spec.rb @@ -13,6 +13,6 @@ end it 'raises an ArgumentError if any arguments are provided' do - -> { Process.last_status(1) }.should raise_error(ArgumentError) + -> { Process.last_status(1) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/process/maxgroups_spec.rb b/spec/ruby/core/process/maxgroups_spec.rb index 2549a7a97185be..895b384bd03d74 100644 --- a/spec/ruby/core/process/maxgroups_spec.rb +++ b/spec/ruby/core/process/maxgroups_spec.rb @@ -3,7 +3,7 @@ platform_is_not :windows do describe "Process.maxgroups" do it "returns the maximum number of gids allowed in the supplemental group access list" do - Process.maxgroups.should be_kind_of(Integer) + Process.maxgroups.should.is_a?(Integer) end it "sets the maximum number of gids allowed in the supplemental group access list" do diff --git a/spec/ruby/core/process/pid_spec.rb b/spec/ruby/core/process/pid_spec.rb index 2d008bc4b7485e..42b0b918b94383 100644 --- a/spec/ruby/core/process/pid_spec.rb +++ b/spec/ruby/core/process/pid_spec.rb @@ -3,7 +3,7 @@ describe "Process.pid" do it "returns the process id of this process" do pid = Process.pid - pid.should be_kind_of(Integer) + pid.should.is_a?(Integer) Process.pid.should == pid end end diff --git a/spec/ruby/core/process/set_proctitle_spec.rb b/spec/ruby/core/process/set_proctitle_spec.rb index d022f2021c347b..28a0fa6cee2a86 100644 --- a/spec/ruby/core/process/set_proctitle_spec.rb +++ b/spec/ruby/core/process/set_proctitle_spec.rb @@ -17,7 +17,7 @@ title = 'rubyspec-proctitle-test' Process.setproctitle(title).should == title - `ps -ocommand= -p#{$$}`.should include(title) + `ps -ocommand= -p#{$$}`.should.include?(title) end end end diff --git a/spec/ruby/core/process/setrlimit_spec.rb b/spec/ruby/core/process/setrlimit_spec.rb index ba8d1e04ca011a..f02ab46fca5275 100644 --- a/spec/ruby/core/process/setrlimit_spec.rb +++ b/spec/ruby/core/process/setrlimit_spec.rb @@ -9,196 +9,196 @@ end it "calls #to_int to convert resource to an Integer" do - Process.setrlimit(mock_int(@resource), @limit, @max).should be_nil + Process.setrlimit(mock_int(@resource), @limit, @max).should == nil end it "raises a TypeError if #to_int for resource does not return an Integer" do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - -> { Process.setrlimit(obj, @limit, @max) }.should raise_error(TypeError) + -> { Process.setrlimit(obj, @limit, @max) }.should.raise(TypeError) end it "calls #to_int to convert the soft limit to an Integer" do - Process.setrlimit(@resource, mock_int(@limit), @max).should be_nil + Process.setrlimit(@resource, mock_int(@limit), @max).should == nil end it "raises a TypeError if #to_int for resource does not return an Integer" do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - -> { Process.setrlimit(@resource, obj, @max) }.should raise_error(TypeError) + -> { Process.setrlimit(@resource, obj, @max) }.should.raise(TypeError) end it "calls #to_int to convert the hard limit to an Integer" do - Process.setrlimit(@resource, @limit, mock_int(@max)).should be_nil + Process.setrlimit(@resource, @limit, mock_int(@max)).should == nil end it "raises a TypeError if #to_int for resource does not return an Integer" do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - -> { Process.setrlimit(@resource, @limit, obj) }.should raise_error(TypeError) + -> { Process.setrlimit(@resource, @limit, obj) }.should.raise(TypeError) end end context "when passed a Symbol" do platform_is_not :openbsd do it "coerces :AS into RLIMIT_AS" do - Process.setrlimit(:AS, *Process.getrlimit(Process::RLIMIT_AS)).should be_nil + Process.setrlimit(:AS, *Process.getrlimit(Process::RLIMIT_AS)).should == nil end end it "coerces :CORE into RLIMIT_CORE" do - Process.setrlimit(:CORE, *Process.getrlimit(Process::RLIMIT_CORE)).should be_nil + Process.setrlimit(:CORE, *Process.getrlimit(Process::RLIMIT_CORE)).should == nil end it "coerces :CPU into RLIMIT_CPU" do - Process.setrlimit(:CPU, *Process.getrlimit(Process::RLIMIT_CPU)).should be_nil + Process.setrlimit(:CPU, *Process.getrlimit(Process::RLIMIT_CPU)).should == nil end it "coerces :DATA into RLIMIT_DATA" do - Process.setrlimit(:DATA, *Process.getrlimit(Process::RLIMIT_DATA)).should be_nil + Process.setrlimit(:DATA, *Process.getrlimit(Process::RLIMIT_DATA)).should == nil end it "coerces :FSIZE into RLIMIT_FSIZE" do - Process.setrlimit(:FSIZE, *Process.getrlimit(Process::RLIMIT_FSIZE)).should be_nil + Process.setrlimit(:FSIZE, *Process.getrlimit(Process::RLIMIT_FSIZE)).should == nil end it "coerces :NOFILE into RLIMIT_NOFILE" do - Process.setrlimit(:NOFILE, *Process.getrlimit(Process::RLIMIT_NOFILE)).should be_nil + Process.setrlimit(:NOFILE, *Process.getrlimit(Process::RLIMIT_NOFILE)).should == nil end it "coerces :STACK into RLIMIT_STACK" do - Process.setrlimit(:STACK, *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil + Process.setrlimit(:STACK, *Process.getrlimit(Process::RLIMIT_STACK)).should == nil end platform_is_not :aix do it "coerces :MEMLOCK into RLIMIT_MEMLOCK" do - Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil + Process.setrlimit(:MEMLOCK, *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should == nil end end it "coerces :NPROC into RLIMIT_NPROC" do - Process.setrlimit(:NPROC, *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil + Process.setrlimit(:NPROC, *Process.getrlimit(Process::RLIMIT_NPROC)).should == nil end it "coerces :RSS into RLIMIT_RSS" do - Process.setrlimit(:RSS, *Process.getrlimit(Process::RLIMIT_RSS)).should be_nil + Process.setrlimit(:RSS, *Process.getrlimit(Process::RLIMIT_RSS)).should == nil end platform_is :netbsd, :freebsd do it "coerces :SBSIZE into RLIMIT_SBSIZE" do - Process.setrlimit(:SBSIZE, *Process.getrlimit(Process::RLIMIT_SBSIZE)).should be_nil + Process.setrlimit(:SBSIZE, *Process.getrlimit(Process::RLIMIT_SBSIZE)).should == nil end end platform_is :linux do it "coerces :RTPRIO into RLIMIT_RTPRIO" do - Process.setrlimit(:RTPRIO, *Process.getrlimit(Process::RLIMIT_RTPRIO)).should be_nil + Process.setrlimit(:RTPRIO, *Process.getrlimit(Process::RLIMIT_RTPRIO)).should == nil end guard -> { defined?(Process::RLIMIT_RTTIME) } do it "coerces :RTTIME into RLIMIT_RTTIME" do - Process.setrlimit(:RTTIME, *Process.getrlimit(Process::RLIMIT_RTTIME)).should be_nil + Process.setrlimit(:RTTIME, *Process.getrlimit(Process::RLIMIT_RTTIME)).should == nil end end it "coerces :SIGPENDING into RLIMIT_SIGPENDING" do - Process.setrlimit(:SIGPENDING, *Process.getrlimit(Process::RLIMIT_SIGPENDING)).should be_nil + Process.setrlimit(:SIGPENDING, *Process.getrlimit(Process::RLIMIT_SIGPENDING)).should == nil end it "coerces :MSGQUEUE into RLIMIT_MSGQUEUE" do - Process.setrlimit(:MSGQUEUE, *Process.getrlimit(Process::RLIMIT_MSGQUEUE)).should be_nil + Process.setrlimit(:MSGQUEUE, *Process.getrlimit(Process::RLIMIT_MSGQUEUE)).should == nil end it "coerces :NICE into RLIMIT_NICE" do - Process.setrlimit(:NICE, *Process.getrlimit(Process::RLIMIT_NICE)).should be_nil + Process.setrlimit(:NICE, *Process.getrlimit(Process::RLIMIT_NICE)).should == nil end end it "raises ArgumentError when passed an unknown resource" do - -> { Process.setrlimit(:FOO, 1, 1) }.should raise_error(ArgumentError) + -> { Process.setrlimit(:FOO, 1, 1) }.should.raise(ArgumentError) end end context "when passed a String" do platform_is_not :openbsd do it "coerces 'AS' into RLIMIT_AS" do - Process.setrlimit("AS", *Process.getrlimit(Process::RLIMIT_AS)).should be_nil + Process.setrlimit("AS", *Process.getrlimit(Process::RLIMIT_AS)).should == nil end end it "coerces 'CORE' into RLIMIT_CORE" do - Process.setrlimit("CORE", *Process.getrlimit(Process::RLIMIT_CORE)).should be_nil + Process.setrlimit("CORE", *Process.getrlimit(Process::RLIMIT_CORE)).should == nil end it "coerces 'CPU' into RLIMIT_CPU" do - Process.setrlimit("CPU", *Process.getrlimit(Process::RLIMIT_CPU)).should be_nil + Process.setrlimit("CPU", *Process.getrlimit(Process::RLIMIT_CPU)).should == nil end it "coerces 'DATA' into RLIMIT_DATA" do - Process.setrlimit("DATA", *Process.getrlimit(Process::RLIMIT_DATA)).should be_nil + Process.setrlimit("DATA", *Process.getrlimit(Process::RLIMIT_DATA)).should == nil end it "coerces 'FSIZE' into RLIMIT_FSIZE" do - Process.setrlimit("FSIZE", *Process.getrlimit(Process::RLIMIT_FSIZE)).should be_nil + Process.setrlimit("FSIZE", *Process.getrlimit(Process::RLIMIT_FSIZE)).should == nil end it "coerces 'NOFILE' into RLIMIT_NOFILE" do - Process.setrlimit("NOFILE", *Process.getrlimit(Process::RLIMIT_NOFILE)).should be_nil + Process.setrlimit("NOFILE", *Process.getrlimit(Process::RLIMIT_NOFILE)).should == nil end it "coerces 'STACK' into RLIMIT_STACK" do - Process.setrlimit("STACK", *Process.getrlimit(Process::RLIMIT_STACK)).should be_nil + Process.setrlimit("STACK", *Process.getrlimit(Process::RLIMIT_STACK)).should == nil end platform_is_not :aix do it "coerces 'MEMLOCK' into RLIMIT_MEMLOCK" do - Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should be_nil + Process.setrlimit("MEMLOCK", *Process.getrlimit(Process::RLIMIT_MEMLOCK)).should == nil end end it "coerces 'NPROC' into RLIMIT_NPROC" do - Process.setrlimit("NPROC", *Process.getrlimit(Process::RLIMIT_NPROC)).should be_nil + Process.setrlimit("NPROC", *Process.getrlimit(Process::RLIMIT_NPROC)).should == nil end it "coerces 'RSS' into RLIMIT_RSS" do - Process.setrlimit("RSS", *Process.getrlimit(Process::RLIMIT_RSS)).should be_nil + Process.setrlimit("RSS", *Process.getrlimit(Process::RLIMIT_RSS)).should == nil end platform_is :netbsd, :freebsd do it "coerces 'SBSIZE' into RLIMIT_SBSIZE" do - Process.setrlimit("SBSIZE", *Process.getrlimit(Process::RLIMIT_SBSIZE)).should be_nil + Process.setrlimit("SBSIZE", *Process.getrlimit(Process::RLIMIT_SBSIZE)).should == nil end end platform_is :linux do it "coerces 'RTPRIO' into RLIMIT_RTPRIO" do - Process.setrlimit("RTPRIO", *Process.getrlimit(Process::RLIMIT_RTPRIO)).should be_nil + Process.setrlimit("RTPRIO", *Process.getrlimit(Process::RLIMIT_RTPRIO)).should == nil end guard -> { defined?(Process::RLIMIT_RTTIME) } do it "coerces 'RTTIME' into RLIMIT_RTTIME" do - Process.setrlimit("RTTIME", *Process.getrlimit(Process::RLIMIT_RTTIME)).should be_nil + Process.setrlimit("RTTIME", *Process.getrlimit(Process::RLIMIT_RTTIME)).should == nil end end it "coerces 'SIGPENDING' into RLIMIT_SIGPENDING" do - Process.setrlimit("SIGPENDING", *Process.getrlimit(Process::RLIMIT_SIGPENDING)).should be_nil + Process.setrlimit("SIGPENDING", *Process.getrlimit(Process::RLIMIT_SIGPENDING)).should == nil end it "coerces 'MSGQUEUE' into RLIMIT_MSGQUEUE" do - Process.setrlimit("MSGQUEUE", *Process.getrlimit(Process::RLIMIT_MSGQUEUE)).should be_nil + Process.setrlimit("MSGQUEUE", *Process.getrlimit(Process::RLIMIT_MSGQUEUE)).should == nil end it "coerces 'NICE' into RLIMIT_NICE" do - Process.setrlimit("NICE", *Process.getrlimit(Process::RLIMIT_NICE)).should be_nil + Process.setrlimit("NICE", *Process.getrlimit(Process::RLIMIT_NICE)).should == nil end end it "raises ArgumentError when passed an unknown resource" do - -> { Process.setrlimit("FOO", 1, 1) }.should raise_error(ArgumentError) + -> { Process.setrlimit("FOO", 1, 1) }.should.raise(ArgumentError) end end @@ -213,7 +213,7 @@ obj.should_receive(:to_str).and_return("CORE") obj.should_not_receive(:to_int) - Process.setrlimit(obj, @limit, @max).should be_nil + Process.setrlimit(obj, @limit, @max).should == nil end it "calls #to_int if #to_str does not return a String" do @@ -221,17 +221,17 @@ obj.should_receive(:to_str).and_return(nil) obj.should_receive(:to_int).and_return(@resource) - Process.setrlimit(obj, @limit, @max).should be_nil + Process.setrlimit(obj, @limit, @max).should == nil end end end platform_is :windows do it "is not implemented" do - Process.respond_to?(:setrlimit).should be_false + Process.respond_to?(:setrlimit).should == false -> do Process.setrlimit(nil, nil) - end.should raise_error NotImplementedError + end.should.raise NotImplementedError end end end diff --git a/spec/ruby/core/process/spawn_spec.rb b/spec/ruby/core/process/spawn_spec.rb index 6153d7783cdb5d..fb619dce4278d5 100644 --- a/spec/ruby/core/process/spawn_spec.rb +++ b/spec/ruby/core/process/spawn_spec.rb @@ -51,7 +51,7 @@ it "returns the process ID of the new process as an Integer" do pid = Process.spawn(*ruby_exe, "-e", "exit") Process.wait pid - pid.should be_an_instance_of(Integer) + pid.should.instance_of?(Integer) end it "returns immediately" do @@ -93,11 +93,11 @@ end it "raises an ArgumentError if the command includes a null byte" do - -> { Process.spawn "\000" }.should raise_error(ArgumentError) + -> { Process.spawn "\000" }.should.raise(ArgumentError) end it "raises a TypeError if the argument does not respond to #to_str" do - -> { Process.spawn :echo }.should raise_error(TypeError) + -> { Process.spawn :echo }.should.raise(TypeError) end end @@ -122,11 +122,11 @@ end it "raises an ArgumentError if an argument includes a null byte" do - -> { Process.spawn "echo", "\000" }.should raise_error(ArgumentError) + -> { Process.spawn "echo", "\000" }.should.raise(ArgumentError) end it "raises a TypeError if an argument does not respond to #to_str" do - -> { Process.spawn "echo", :foo }.should raise_error(TypeError) + -> { Process.spawn "echo", :foo }.should.raise(TypeError) end end @@ -178,19 +178,19 @@ end it "raises an ArgumentError if the Array does not have exactly two elements" do - -> { Process.spawn([]) }.should raise_error(ArgumentError) - -> { Process.spawn([:a]) }.should raise_error(ArgumentError) - -> { Process.spawn([:a, :b, :c]) }.should raise_error(ArgumentError) + -> { Process.spawn([]) }.should.raise(ArgumentError) + -> { Process.spawn([:a]) }.should.raise(ArgumentError) + -> { Process.spawn([:a, :b, :c]) }.should.raise(ArgumentError) end it "raises an ArgumentError if the Strings in the Array include a null byte" do - -> { Process.spawn ["\000", "echo"] }.should raise_error(ArgumentError) - -> { Process.spawn ["echo", "\000"] }.should raise_error(ArgumentError) + -> { Process.spawn ["\000", "echo"] }.should.raise(ArgumentError) + -> { Process.spawn ["echo", "\000"] }.should.raise(ArgumentError) end it "raises a TypeError if an element in the Array does not respond to #to_str" do - -> { Process.spawn ["echo", :echo] }.should raise_error(TypeError) - -> { Process.spawn [:echo, "echo"] }.should raise_error(TypeError) + -> { Process.spawn ["echo", :echo] }.should.raise(TypeError) + -> { Process.spawn [:echo, "echo"] }.should.raise(TypeError) end end @@ -256,19 +256,19 @@ it "raises an ArgumentError if an environment key includes an equals sign" do -> do Process.spawn({"FOO=" => "BAR"}, "echo #{@var}>#{@name}") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises an ArgumentError if an environment key includes a null byte" do -> do Process.spawn({"\000" => "BAR"}, "echo #{@var}>#{@name}") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises an ArgumentError if an environment value includes a null byte" do -> do Process.spawn({"FOO" => "\000"}, "echo #{@var}>#{@name}") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end # :unsetenv_others @@ -285,7 +285,7 @@ it "unsets other environment variables when given a true :unsetenv_others option" do ENV["FOO"] = "BAR" Process.wait Process.spawn(*@common_env_spawn_args, unsetenv_others: true) - $?.success?.should be_true + $?.success?.should == true File.read(@name).should == "\n" end end @@ -293,7 +293,7 @@ it "does not unset other environment variables when given a false :unsetenv_others option" do ENV["FOO"] = "BAR" Process.wait Process.spawn(*@common_env_spawn_args, unsetenv_others: false) - $?.success?.should be_true + $?.success?.should == true File.read(@name).should == "BAR\n" end @@ -301,7 +301,7 @@ it "does not unset environment variables included in the environment hash" do env = @minimal_env.merge({"FOO" => "BAR"}) Process.wait Process.spawn(env, "echo #{@var}>#{@name}", unsetenv_others: true) - $?.success?.should be_true + $?.success?.should == true File.read(@name).should == "BAR\n" end end @@ -363,17 +363,17 @@ end it "raises an ArgumentError if given a negative :pgroup option" do - -> { Process.spawn("echo", pgroup: -1) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", pgroup: -1) }.should.raise(ArgumentError) end it "raises a TypeError if given a symbol as :pgroup option" do - -> { Process.spawn("echo", pgroup: :true) }.should raise_error(TypeError) + -> { Process.spawn("echo", pgroup: :true) }.should.raise(TypeError) end end platform_is :windows do it "raises an ArgumentError if given :pgroup option" do - -> { Process.spawn("echo", pgroup: false) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", pgroup: false) }.should.raise(ArgumentError) end end @@ -452,7 +452,7 @@ def child_pids(pid) children.each do |child| -> do Process.kill("TERM", child) - end.should raise_error(Errno::ESRCH) + end.should.raise(Errno::ESRCH) end end end @@ -678,23 +678,23 @@ def child_pids(pid) # error handling it "raises an ArgumentError if passed no command arguments" do - -> { Process.spawn }.should raise_error(ArgumentError) + -> { Process.spawn }.should.raise(ArgumentError) end it "raises an ArgumentError if passed env or options but no command arguments" do - -> { Process.spawn({}) }.should raise_error(ArgumentError) + -> { Process.spawn({}) }.should.raise(ArgumentError) end it "raises an ArgumentError if passed env and options but no command arguments" do - -> { Process.spawn({}, {}) }.should raise_error(ArgumentError) + -> { Process.spawn({}, {}) }.should.raise(ArgumentError) end it "raises an Errno::ENOENT for an empty string" do - -> { Process.spawn "" }.should raise_error(Errno::ENOENT) + -> { Process.spawn "" }.should.raise(Errno::ENOENT) end it "raises an Errno::ENOENT if the command does not exist" do - -> { Process.spawn "nonesuch" }.should raise_error(Errno::ENOENT, "No such file or directory - nonesuch") + -> { Process.spawn "nonesuch" }.should.raise(Errno::ENOENT, "No such file or directory - nonesuch") end it "sets $? to exit status 127 when the command does not exist" do @@ -703,7 +703,7 @@ def child_pids(pid) end it "raises an Errno::ENOENT if the file does not exist" do - -> { Process.spawn "./nonesuch" }.should raise_error(Errno::ENOENT, "No such file or directory - ./nonesuch") + -> { Process.spawn "./nonesuch" }.should.raise(Errno::ENOENT, "No such file or directory - ./nonesuch") end it "sets $? to exit status 127 when the file does not exist" do @@ -713,14 +713,14 @@ def child_pids(pid) platform_is_not :windows do it "raises an Errno::EACCES when the path is a directory" do - -> { Process.spawn "./" }.should raise_error(Errno::EACCES, "Permission denied - ./") + -> { Process.spawn "./" }.should.raise(Errno::EACCES, "Permission denied - ./") end end unless File.executable?(__FILE__) # Some FS (e.g. vboxfs) locate all files executable platform_is_not :windows do it "raises an Errno::EACCES when the file does not have execute permissions" do - -> { Process.spawn __FILE__ }.should raise_error(Errno::EACCES, "Permission denied - #{__FILE__}") + -> { Process.spawn __FILE__ }.should.raise(Errno::EACCES, "Permission denied - #{__FILE__}") end it "sets $? to exit status 127 when the file does not have execute permissions" do @@ -736,7 +736,7 @@ def child_pids(pid) File.write("#{dir}/#{exe}", "#!/bin/sh\necho hi") File.chmod(0644, "#{dir}/#{exe}") env = { "PATH" => "#{dir}#{File::PATH_SEPARATOR}#{ENV['PATH']}" } - -> { Process.spawn(env, exe) }.should raise_error(Errno::ENOENT, "No such file or directory - #{exe}") + -> { Process.spawn(env, exe) }.should.raise(Errno::ENOENT, "No such file or directory - #{exe}") $?.exitstatus.should == 127 ensure rm_r dir @@ -746,25 +746,25 @@ def child_pids(pid) platform_is :windows do it "raises Errno::EACCES or Errno::ENOEXEC when the file is not an executable file" do - -> { Process.spawn __FILE__ }.should raise_error(SystemCallError) { |e| - [Errno::EACCES, Errno::ENOEXEC].should include(e.class) + -> { Process.spawn __FILE__ }.should.raise(SystemCallError) { |e| + [Errno::EACCES, Errno::ENOEXEC].should.include?(e.class) } end end end it "raises an Errno::EACCES or Errno::EISDIR when passed a directory" do - -> { Process.spawn __dir__ }.should raise_error(SystemCallError) { |e| - [Errno::EACCES, Errno::EISDIR].should include(e.class) + -> { Process.spawn __dir__ }.should.raise(SystemCallError) { |e| + [Errno::EACCES, Errno::EISDIR].should.include?(e.class) } end it "raises an ArgumentError when passed a string key in options" do - -> { Process.spawn("echo", "chdir" => Dir.pwd) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", "chdir" => Dir.pwd) }.should.raise(ArgumentError) end it "raises an ArgumentError when passed an unknown option key" do - -> { Process.spawn("echo", nonesuch: :foo) }.should raise_error(ArgumentError) + -> { Process.spawn("echo", nonesuch: :foo) }.should.raise(ArgumentError) end platform_is_not :windows, :aix do diff --git a/spec/ruby/core/process/status/bit_and_spec.rb b/spec/ruby/core/process/status/bit_and_spec.rb index 9fd1425a97600e..a5b1123e9072a1 100644 --- a/spec/ruby/core/process/status/bit_and_spec.rb +++ b/spec/ruby/core/process/status/bit_and_spec.rb @@ -23,7 +23,7 @@ ruby_exe("exit(0)") -> { $? & -1 - }.should raise_error(ArgumentError, 'negative mask value: -1') + }.should.raise(ArgumentError, 'negative mask value: -1') end end diff --git a/spec/ruby/core/process/status/exited_spec.rb b/spec/ruby/core/process/status/exited_spec.rb index a61292b146af5d..ad14b35000dd4c 100644 --- a/spec/ruby/core/process/status/exited_spec.rb +++ b/spec/ruby/core/process/status/exited_spec.rb @@ -7,7 +7,7 @@ end it "returns true" do - $?.exited?.should be_true + $?.exited?.should == true end end @@ -19,13 +19,13 @@ platform_is_not :windows do it "returns false" do - $?.exited?.should be_false + $?.exited?.should == false end end platform_is :windows do it "always returns true" do - $?.exited?.should be_true + $?.exited?.should == true end end end diff --git a/spec/ruby/core/process/status/right_shift_spec.rb b/spec/ruby/core/process/status/right_shift_spec.rb index 3eaedf50550e1d..5689526f547eb8 100644 --- a/spec/ruby/core/process/status/right_shift_spec.rb +++ b/spec/ruby/core/process/status/right_shift_spec.rb @@ -22,7 +22,7 @@ ruby_exe("exit(0)") -> { $? >> -1 - }.should raise_error(ArgumentError, 'negative shift value: -1') + }.should.raise(ArgumentError, 'negative shift value: -1') end end diff --git a/spec/ruby/core/process/status/signaled_spec.rb b/spec/ruby/core/process/status/signaled_spec.rb index c0de7b8006e2f9..8cf409bb42bcfc 100644 --- a/spec/ruby/core/process/status/signaled_spec.rb +++ b/spec/ruby/core/process/status/signaled_spec.rb @@ -7,7 +7,7 @@ end it "returns false" do - $?.signaled?.should be_false + $?.signaled?.should == false end end @@ -18,13 +18,13 @@ platform_is_not :windows do it "returns true" do - $?.signaled?.should be_true + $?.signaled?.should == true end end platform_is :windows do it "always returns false" do - $?.signaled?.should be_false + $?.signaled?.should == false end end end diff --git a/spec/ruby/core/process/status/success_spec.rb b/spec/ruby/core/process/status/success_spec.rb index 3589cc611f0574..f61243c6670b38 100644 --- a/spec/ruby/core/process/status/success_spec.rb +++ b/spec/ruby/core/process/status/success_spec.rb @@ -7,7 +7,7 @@ end it "returns true" do - $?.success?.should be_true + $?.success?.should == true end end @@ -17,7 +17,7 @@ end it "returns false" do - $?.success?.should be_false + $?.success?.should == false end end @@ -28,13 +28,13 @@ platform_is_not :windows do it "returns nil" do - $?.success?.should be_nil + $?.success?.should == nil end end platform_is :windows do it "always returns true" do - $?.success?.should be_true + $?.success?.should == true end end end diff --git a/spec/ruby/core/process/status/termsig_spec.rb b/spec/ruby/core/process/status/termsig_spec.rb index 9a22dbea7180c6..1d57724d1201f2 100644 --- a/spec/ruby/core/process/status/termsig_spec.rb +++ b/spec/ruby/core/process/status/termsig_spec.rb @@ -7,7 +7,7 @@ end it "returns nil" do - $?.termsig.should be_nil + $?.termsig.should == nil end end @@ -36,7 +36,7 @@ platform_is :windows do it "always returns nil" do - $?.termsig.should be_nil + $?.termsig.should == nil end end end diff --git a/spec/ruby/core/process/status/to_i_spec.rb b/spec/ruby/core/process/status/to_i_spec.rb index 39f8e2d84c0c00..0bfb883d23060b 100644 --- a/spec/ruby/core/process/status/to_i_spec.rb +++ b/spec/ruby/core/process/status/to_i_spec.rb @@ -3,11 +3,11 @@ describe "Process::Status#to_i" do it "returns an integer when the child exits" do ruby_exe('exit 48', exit_status: 48) - $?.to_i.should be_an_instance_of(Integer) + $?.to_i.should.instance_of?(Integer) end it "returns an integer when the child is signaled" do ruby_exe('raise SignalException, "TERM"', exit_status: platform_is(:windows) ? 3 : :SIGTERM) - $?.to_i.should be_an_instance_of(Integer) + $?.to_i.should.instance_of?(Integer) end end diff --git a/spec/ruby/core/process/status/wait_spec.rb b/spec/ruby/core/process/status/wait_spec.rb index 57d56209a9ebf9..18ecc14f6fac86 100644 --- a/spec/ruby/core/process/status/wait_spec.rb +++ b/spec/ruby/core/process/status/wait_spec.rb @@ -21,14 +21,14 @@ it "returns a status with its child pid" do pid = Process.spawn(ruby_cmd('exit')) status = Process::Status.wait - status.should be_an_instance_of(Process::Status) + status.should.instance_of?(Process::Status) status.pid.should == pid end it "should not set $? to the Process::Status" do pid = Process.spawn(ruby_cmd('exit')) status = Process::Status.wait - $?.should_not equal(status) + $?.should_not.equal?(status) end it "should not change the value of $?" do @@ -36,13 +36,13 @@ Process.wait status = $? Process::Status.wait - status.should equal($?) + status.should.equal?($?) end it "waits for any child process if no pid is given" do pid = Process.spawn(ruby_cmd('exit')) Process::Status.wait.pid.should == pid - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) end it "waits for a specific child if a pid is given" do @@ -50,14 +50,14 @@ pid2 = Process.spawn(ruby_cmd('exit')) Process::Status.wait(pid2).pid.should == pid2 Process::Status.wait(pid1).pid.should == pid1 - -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) - -> { Process.kill(0, pid2) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should.raise(Errno::ESRCH) + -> { Process.kill(0, pid2) }.should.raise(Errno::ESRCH) end it "coerces the pid to an Integer" do pid1 = Process.spawn(ruby_cmd('exit')) Process::Status.wait(mock_int(pid1)).pid.should == pid1 - -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should.raise(Errno::ESRCH) end # This spec is probably system-dependent. @@ -80,7 +80,7 @@ sleep end - Process::Status.wait(pid, Process::WNOHANG).should be_nil + Process::Status.wait(pid, Process::WNOHANG).should == nil # wait for the child to setup its TERM handler write.close @@ -94,7 +94,7 @@ it "always accepts flags=0" do pid = Process.spawn(ruby_cmd('exit')) Process::Status.wait(-1, 0).pid.should == pid - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) end end end diff --git a/spec/ruby/core/process/times_spec.rb b/spec/ruby/core/process/times_spec.rb index d3bff2cda9fc59..a7ffbb79e57976 100644 --- a/spec/ruby/core/process/times_spec.rb +++ b/spec/ruby/core/process/times_spec.rb @@ -2,7 +2,7 @@ describe "Process.times" do it "returns a Process::Tms" do - Process.times.should be_kind_of(Process::Tms) + Process.times.should.is_a?(Process::Tms) end # TODO: Intel C Compiler does not work this example diff --git a/spec/ruby/core/process/uid_spec.rb b/spec/ruby/core/process/uid_spec.rb index a068b1a2c1aff9..1e218ef4fe53ab 100644 --- a/spec/ruby/core/process/uid_spec.rb +++ b/spec/ruby/core/process/uid_spec.rb @@ -20,16 +20,16 @@ describe "Process.uid=" do platform_is_not :windows do it "raises TypeError if not passed an Integer" do - -> { Process.uid = Object.new }.should raise_error(TypeError) + -> { Process.uid = Object.new }.should.raise(TypeError) end as_user do it "raises Errno::ERPERM if run by a non privileged user trying to set the superuser id" do - -> { (Process.uid = 0)}.should raise_error(Errno::EPERM) + -> { (Process.uid = 0)}.should.raise(Errno::EPERM) end it "raises Errno::ERPERM if run by a non privileged user trying to set the superuser id from username" do - -> { Process.uid = "root" }.should raise_error(Errno::EPERM) + -> { Process.uid = "root" }.should.raise(Errno::EPERM) end end diff --git a/spec/ruby/core/process/wait2_spec.rb b/spec/ruby/core/process/wait2_spec.rb index 8ba429dc96bbc7..5c57dd40fb79f2 100644 --- a/spec/ruby/core/process/wait2_spec.rb +++ b/spec/ruby/core/process/wait2_spec.rb @@ -12,7 +12,7 @@ leaked = Process.waitall $stderr.puts "leaked before wait2 specs: #{leaked}" unless leaked.empty? # Ruby-space should not see PIDs used by rjit - leaked.should be_empty + leaked.should.empty? rescue Errno::ECHILD # No child processes rescue NotImplementedError end @@ -30,15 +30,15 @@ end it "raises a StandardError if no child processes exist" do - -> { Process.wait2 }.should raise_error(Errno::ECHILD) - -> { Process.wait2 }.should raise_error(StandardError) + -> { Process.wait2 }.should.raise(Errno::ECHILD) + -> { Process.wait2 }.should.raise(StandardError) end it "returns nil if the child process is still running when given the WNOHANG flag" do IO.popen(ruby_cmd('STDIN.getbyte'), "w") do |io| pid, status = Process.wait2(io.pid, Process::WNOHANG) - pid.should be_nil - status.should be_nil + pid.should == nil + status.should == nil io.write('a') end end diff --git a/spec/ruby/core/process/wait_spec.rb b/spec/ruby/core/process/wait_spec.rb index 385acc9928542f..0b2e715f65d075 100644 --- a/spec/ruby/core/process/wait_spec.rb +++ b/spec/ruby/core/process/wait_spec.rb @@ -14,7 +14,7 @@ end it "raises an Errno::ECHILD if there are no child processes" do - -> { Process.wait }.should raise_error(Errno::ECHILD) + -> { Process.wait }.should.raise(Errno::ECHILD) end platform_is_not :windows do @@ -26,14 +26,14 @@ it "sets $? to a Process::Status" do pid = Process.spawn(ruby_cmd('exit')) Process.wait - $?.should be_kind_of(Process::Status) + $?.should.is_a?(Process::Status) $?.pid.should == pid end it "waits for any child process if no pid is given" do pid = Process.spawn(ruby_cmd('exit')) Process.wait.should == pid - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) end it "waits for a specific child if a pid is given" do @@ -41,14 +41,14 @@ pid2 = Process.spawn(ruby_cmd('exit')) Process.wait(pid2).should == pid2 Process.wait(pid1).should == pid1 - -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) - -> { Process.kill(0, pid2) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should.raise(Errno::ESRCH) + -> { Process.kill(0, pid2) }.should.raise(Errno::ESRCH) end it "coerces the pid to an Integer" do pid1 = Process.spawn(ruby_cmd('exit')) Process.wait(mock_int(pid1)).should == pid1 - -> { Process.kill(0, pid1) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid1) }.should.raise(Errno::ESRCH) end # This spec is probably system-dependent. @@ -71,7 +71,7 @@ sleep end - Process.wait(pid, Process::WNOHANG).should be_nil + Process.wait(pid, Process::WNOHANG).should == nil # wait for the child to setup its TERM handler write.close @@ -85,7 +85,7 @@ it "always accepts flags=0" do pid = Process.spawn(ruby_cmd('exit')) Process.wait(-1, 0).should == pid - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) end end end diff --git a/spec/ruby/core/process/waitall_spec.rb b/spec/ruby/core/process/waitall_spec.rb index 6cf4e32bc90898..a77873f553ce6b 100644 --- a/spec/ruby/core/process/waitall_spec.rb +++ b/spec/ruby/core/process/waitall_spec.rb @@ -13,7 +13,7 @@ end it "takes no arguments" do - -> { Process.waitall(0) }.should raise_error(ArgumentError) + -> { Process.waitall(0) }.should.raise(ArgumentError) end platform_is_not :windows do @@ -24,7 +24,7 @@ pids << Process.fork { Process.exit! 0 } Process.waitall pids.each { |pid| - -> { Process.kill(0, pid) }.should raise_error(Errno::ESRCH) + -> { Process.kill(0, pid) }.should.raise(Errno::ESRCH) } end @@ -34,14 +34,14 @@ pids << Process.fork { Process.exit! 1 } pids << Process.fork { Process.exit! 0 } a = Process.waitall - a.should be_kind_of(Array) + a.should.is_a?(Array) a.size.should == 3 pids.each { |pid| pid_status = a.assoc(pid) - pid_status.should be_kind_of(Array) + pid_status.should.is_a?(Array) pid_status.size.should == 2 pid_status.first.should == pid - pid_status.last.should be_kind_of(Process::Status) + pid_status.last.should.is_a?(Process::Status) } end end diff --git a/spec/ruby/core/queue/initialize_spec.rb b/spec/ruby/core/queue/initialize_spec.rb index 6b9e6b7fa9620c..080e4d0abd7d80 100644 --- a/spec/ruby/core/queue/initialize_spec.rb +++ b/spec/ruby/core/queue/initialize_spec.rb @@ -35,20 +35,20 @@ end it "raises a TypeError if the given argument can't be converted to an Array" do - -> { Queue.new(42) }.should raise_error(TypeError) - -> { Queue.new(:abc) }.should raise_error(TypeError) + -> { Queue.new(42) }.should.raise(TypeError) + -> { Queue.new(:abc) }.should.raise(TypeError) end it "raises a NoMethodError if the given argument raises a NoMethodError during type coercion to an Array" do enumerable = MockObject.new('mock-enumerable') enumerable.should_receive(:to_a).and_raise(NoMethodError) - -> { Queue.new(enumerable) }.should raise_error(NoMethodError) + -> { Queue.new(enumerable) }.should.raise(NoMethodError) end end it "raises TypeError if the provided Enumerable does not respond to #to_a" do enumerable = MockObject.new('mock-enumerable') - -> { Queue.new(enumerable) }.should raise_error(TypeError, "can't convert MockObject into Array") + -> { Queue.new(enumerable) }.should.raise(TypeError, "can't convert MockObject into Array") end it "raises TypeError if #to_a does not return Array" do diff --git a/spec/ruby/core/random/new_seed_spec.rb b/spec/ruby/core/random/new_seed_spec.rb index 7a93da99aa0d82..b2741aaa31e290 100644 --- a/spec/ruby/core/random/new_seed_spec.rb +++ b/spec/ruby/core/random/new_seed_spec.rb @@ -2,7 +2,7 @@ describe "Random.new_seed" do it "returns an Integer" do - Random.new_seed.should be_an_instance_of(Integer) + Random.new_seed.should.instance_of?(Integer) end it "returns an arbitrary seed value each time" do diff --git a/spec/ruby/core/random/new_spec.rb b/spec/ruby/core/random/new_spec.rb index 69210cef03bd43..e20d4871372b84 100644 --- a/spec/ruby/core/random/new_spec.rb +++ b/spec/ruby/core/random/new_spec.rb @@ -1,11 +1,11 @@ require_relative "../../spec_helper" describe "Random.new" do it "returns a new instance of Random" do - Random.new.should be_an_instance_of(Random) + Random.new.should.instance_of?(Random) end it "uses a random seed value if none is supplied" do - Random.new.seed.should be_an_instance_of(Integer) + Random.new.seed.should.instance_of?(Integer) end it "returns Random instances initialized with different seeds" do @@ -33,6 +33,6 @@ it "raises a RangeError if passed a Complex (with imaginary part) seed value as an argument" do -> do Random.new(Complex(20,2)) - end.should raise_error(RangeError) + end.should.raise(RangeError) end end diff --git a/spec/ruby/core/random/rand_spec.rb b/spec/ruby/core/random/rand_spec.rb index 9244177ab5a624..c882db638111c7 100644 --- a/spec/ruby/core/random/rand_spec.rb +++ b/spec/ruby/core/random/rand_spec.rb @@ -45,13 +45,13 @@ it "coerces arguments to Integers with #to_int" do obj = mock_numeric('int') obj.should_receive(:to_int).and_return(99) - Random.rand(obj).should be_kind_of(Integer) + Random.rand(obj).should.is_a?(Integer) end end describe "Random#rand with Fixnum" do it "returns an Integer" do - Random.new.rand(20).should be_an_instance_of(Integer) + Random.new.rand(20).should.instance_of?(Integer) end it "returns a Fixnum greater than or equal to 0" do @@ -82,20 +82,20 @@ it "raises an ArgumentError when the argument is 0" do -> do Random.new.rand(0) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises an ArgumentError when the argument is negative" do -> do Random.new.rand(-12) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end end describe "Random#rand with Bignum" do it "typically returns a Bignum" do rnd = Random.new(1) - 10.times.map{ rnd.rand(bignum_value*2) }.max.should be_an_instance_of(Integer) + 10.times.map{ rnd.rand(bignum_value*2) }.max.should.instance_of?(Integer) end it "returns a Bignum greater than or equal to 0" do @@ -121,13 +121,13 @@ it "raises an ArgumentError when the argument is negative" do -> do Random.new.rand(-bignum_value) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end end describe "Random#rand with Float" do it "returns a Float" do - Random.new.rand(20.43).should be_an_instance_of(Float) + Random.new.rand(20.43).should.instance_of?(Float) end it "returns a Float greater than or equal to 0.0" do @@ -153,25 +153,25 @@ it "raises an ArgumentError when the argument is negative" do -> do Random.new.rand(-1.234567) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end end describe "Random#rand with Range" do it "returns an element from the Range" do - Random.new.rand(20..43).should be_an_instance_of(Integer) + Random.new.rand(20..43).should.instance_of?(Integer) end it "supports custom object types" do - rand(RandomSpecs::CustomRangeInteger.new(1)..RandomSpecs::CustomRangeInteger.new(42)).should be_an_instance_of(RandomSpecs::CustomRangeInteger) - rand(RandomSpecs::CustomRangeFloat.new(1.0)..RandomSpecs::CustomRangeFloat.new(42.0)).should be_an_instance_of(RandomSpecs::CustomRangeFloat) - rand(Time.now..Time.now).should be_an_instance_of(Time) + rand(RandomSpecs::CustomRangeInteger.new(1)..RandomSpecs::CustomRangeInteger.new(42)).should.instance_of?(RandomSpecs::CustomRangeInteger) + rand(RandomSpecs::CustomRangeFloat.new(1.0)..RandomSpecs::CustomRangeFloat.new(42.0)).should.instance_of?(RandomSpecs::CustomRangeFloat) + rand(Time.now..Time.now).should.instance_of?(Time) end it "returns an object that is a member of the Range" do prng = Random.new r = 20..30 - 20.times { r.member?(prng.rand(r)).should be_true } + 20.times { r.member?(prng.rand(r)).should == true } end it "works with inclusive ranges" do @@ -201,8 +201,8 @@ end it "considers Integers as Floats if one end point is a float" do - Random.new(42).rand(0.0..1).should be_kind_of(Float) - Random.new(42).rand(0..1.0).should be_kind_of(Float) + Random.new(42).rand(0.0..1).should.is_a?(Float) + Random.new(42).rand(0..1.0).should.is_a?(Float) end it "returns a float within a given float range" do @@ -213,12 +213,12 @@ it "raises an ArgumentError when the startpoint lacks #+ and #- methods" do -> do Random.new.rand(Object.new..67) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises an ArgumentError when the endpoint lacks #+ and #- methods" do -> do Random.new.rand(68..Object.new) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/random/seed_spec.rb b/spec/ruby/core/random/seed_spec.rb index bf4524fdd9e8ea..6529b2c8733048 100644 --- a/spec/ruby/core/random/seed_spec.rb +++ b/spec/ruby/core/random/seed_spec.rb @@ -2,7 +2,7 @@ describe "Random#seed" do it "returns an Integer" do - Random.new.seed.should be_kind_of(Integer) + Random.new.seed.should.is_a?(Integer) end it "returns an arbitrary seed if the constructor was called without arguments" do diff --git a/spec/ruby/core/random/shared/bytes.rb b/spec/ruby/core/random/shared/bytes.rb index 9afad3b7f8fccb..86c64d56968a05 100644 --- a/spec/ruby/core/random/shared/bytes.rb +++ b/spec/ruby/core/random/shared/bytes.rb @@ -1,6 +1,6 @@ describe :random_bytes, shared: true do it "returns a String" do - @object.send(@method, 1).should be_an_instance_of(String) + @object.send(@method, 1).should.instance_of?(String) end it "returns a String of the length given as argument" do diff --git a/spec/ruby/core/random/shared/rand.rb b/spec/ruby/core/random/shared/rand.rb index d3b24b88514c2f..655c75c9f18f17 100644 --- a/spec/ruby/core/random/shared/rand.rb +++ b/spec/ruby/core/random/shared/rand.rb @@ -1,9 +1,9 @@ describe :random_number, shared: true do it "returns a Float if no max argument is passed" do - @object.send(@method).should be_kind_of(Float) + @object.send(@method).should.is_a?(Float) end it "returns an Integer if an Integer argument is passed" do - @object.send(@method, 20).should be_kind_of(Integer) + @object.send(@method, 20).should.is_a?(Integer) end end diff --git a/spec/ruby/core/random/urandom_spec.rb b/spec/ruby/core/random/urandom_spec.rb index 6f180e54ac88f7..94e9423a063be7 100644 --- a/spec/ruby/core/random/urandom_spec.rb +++ b/spec/ruby/core/random/urandom_spec.rb @@ -2,7 +2,7 @@ describe "Random.urandom" do it "returns a String" do - Random.urandom(1).should be_an_instance_of(String) + Random.urandom(1).should.instance_of?(String) end it "returns a String of the length given as argument" do @@ -12,7 +12,7 @@ it "raises an ArgumentError on a negative size" do -> { Random.urandom(-1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "returns a binary String" do diff --git a/spec/ruby/core/range/bsearch_spec.rb b/spec/ruby/core/range/bsearch_spec.rb index 5254ab756cb1ca..151a1798cf188c 100644 --- a/spec/ruby/core/range/bsearch_spec.rb +++ b/spec/ruby/core/range/bsearch_spec.rb @@ -3,46 +3,46 @@ describe "Range#bsearch" do it "returns an Enumerator when not passed a block" do - (0..1).bsearch.should be_an_instance_of(Enumerator) + (0..1).bsearch.should.instance_of?(Enumerator) end it_behaves_like :enumeratorized_with_unknown_size, :bsearch, (1..3) it "raises a TypeError if the block returns an Object" do - -> { (0..1).bsearch { Object.new } }.should raise_error(TypeError, "wrong argument type Object (must be numeric, true, false or nil)") + -> { (0..1).bsearch { Object.new } }.should.raise(TypeError, "wrong argument type Object (must be numeric, true, false or nil)") end it "raises a TypeError if the block returns a String and boundaries are Integer values" do - -> { (0..1).bsearch { "1" } }.should raise_error(TypeError, "wrong argument type String (must be numeric, true, false or nil)") + -> { (0..1).bsearch { "1" } }.should.raise(TypeError, "wrong argument type String (must be numeric, true, false or nil)") end it "raises a TypeError if the block returns a String and boundaries are Float values" do - -> { (0.0..1.0).bsearch { "1" } }.should raise_error(TypeError, "wrong argument type String (must be numeric, true, false or nil)") + -> { (0.0..1.0).bsearch { "1" } }.should.raise(TypeError, "wrong argument type String (must be numeric, true, false or nil)") end it "raises a TypeError if the Range has Object values" do value = mock("range bsearch") r = Range.new value, value - -> { r.bsearch { true } }.should raise_error(TypeError, "can't do binary search for MockObject") + -> { r.bsearch { true } }.should.raise(TypeError, "can't do binary search for MockObject") end it "raises a TypeError if the Range has String values" do - -> { ("a".."e").bsearch { true } }.should raise_error(TypeError, "can't do binary search for String") + -> { ("a".."e").bsearch { true } }.should.raise(TypeError, "can't do binary search for String") end it "raises TypeError when non-Numeric begin/end and block not passed" do - -> { ("a".."e").bsearch }.should raise_error(TypeError, "can't do binary search for String") + -> { ("a".."e").bsearch }.should.raise(TypeError, "can't do binary search for String") end context "with Integer values" do context "with a block returning true or false" do it "returns nil if the block returns false for every element" do - (0...3).bsearch { |x| x > 3 }.should be_nil + (0...3).bsearch { |x| x > 3 }.should == nil end it "returns nil if the block returns nil for every element" do - (0..3).bsearch { |x| nil }.should be_nil + (0..3).bsearch { |x| nil }.should == nil end it "returns minimum element if the block returns true for every element" do @@ -62,21 +62,21 @@ context "with a block returning negative, zero, positive numbers" do it "returns nil if the block returns less than zero for every element" do - (0..3).bsearch { |x| x <=> 5 }.should be_nil + (0..3).bsearch { |x| x <=> 5 }.should == nil end it "returns nil if the block returns greater than zero for every element" do - (0..3).bsearch { |x| x <=> -1 }.should be_nil + (0..3).bsearch { |x| x <=> -1 }.should == nil end it "returns nil if the block never returns zero" do - (0..3).bsearch { |x| x < 2 ? 1 : -1 }.should be_nil + (0..3).bsearch { |x| x < 2 ? 1 : -1 }.should == nil end it "accepts (+/-)Float::INFINITY from the block" do - (0..4).bsearch { |x| Float::INFINITY }.should be_nil - (0..4).bsearch { |x| -Float::INFINITY }.should be_nil + (0..4).bsearch { |x| Float::INFINITY }.should == nil + (0..4).bsearch { |x| -Float::INFINITY }.should == nil end it "returns an element at an index for which block returns 0.0" do @@ -86,7 +86,7 @@ it "returns an element at an index for which block returns 0" do result = (0..4).bsearch { |x| x < 1 ? 1 : x > 3 ? -1 : 0 } - [1, 2].should include(result) + [1, 2].should.include?(result) end end @@ -111,11 +111,11 @@ context "with Float values" do context "with a block returning true or false" do it "returns nil if the block returns false for every element" do - (0.1...2.3).bsearch { |x| x > 3 }.should be_nil + (0.1...2.3).bsearch { |x| x > 3 }.should == nil end it "returns nil if the block returns nil for every element" do - (-0.0..2.3).bsearch { |x| nil }.should be_nil + (-0.0..2.3).bsearch { |x| nil }.should == nil end it "returns minimum element if the block returns true for every element" do @@ -163,20 +163,20 @@ context "with a block returning negative, zero, positive numbers" do it "returns nil if the block returns less than zero for every element" do - (-2.0..3.2).bsearch { |x| x <=> 5 }.should be_nil + (-2.0..3.2).bsearch { |x| x <=> 5 }.should == nil end it "returns nil if the block returns greater than zero for every element" do - (0.3..3.0).bsearch { |x| x <=> -1 }.should be_nil + (0.3..3.0).bsearch { |x| x <=> -1 }.should == nil end it "returns nil if the block never returns zero" do - (0.2..2.3).bsearch { |x| x < 2 ? 1 : -1 }.should be_nil + (0.2..2.3).bsearch { |x| x < 2 ? 1 : -1 }.should == nil end it "accepts (+/-)Float::INFINITY from the block" do - (0.1..4.5).bsearch { |x| Float::INFINITY }.should be_nil - (-5.0..4.0).bsearch { |x| -Float::INFINITY }.should be_nil + (0.1..4.5).bsearch { |x| Float::INFINITY }.should == nil + (-5.0..4.0).bsearch { |x| -Float::INFINITY }.should == nil end it "returns an element at an index for which block returns 0.0" do @@ -244,15 +244,15 @@ context "with a block returning negative, zero, positive numbers" do it "returns nil if the block returns less than zero for every element" do - eval("(0..)").bsearch { |x| -1 }.should be_nil + eval("(0..)").bsearch { |x| -1 }.should == nil end it "returns nil if the block never returns zero" do - eval("(0..)").bsearch { |x| x > 5 ? -1 : 1 }.should be_nil + eval("(0..)").bsearch { |x| x > 5 ? -1 : 1 }.should == nil end it "accepts -Float::INFINITY from the block" do - eval("(0..)").bsearch { |x| -Float::INFINITY }.should be_nil + eval("(0..)").bsearch { |x| -Float::INFINITY }.should == nil end it "returns an element at an index for which block returns 0.0" do @@ -262,7 +262,7 @@ it "returns an element at an index for which block returns 0" do result = eval("(0..)").bsearch { |x| x < 1 ? 1 : x > 3 ? -1 : 0 } - [1, 2, 3].should include(result) + [1, 2, 3].should.include?(result) end end @@ -274,13 +274,13 @@ context "with endless ranges and Float values" do context "with a block returning true or false" do it "returns nil if the block returns false for every element" do - eval("(0.1..)").bsearch { |x| x < 0.0 }.should be_nil - eval("(0.1...)").bsearch { |x| x < 0.0 }.should be_nil + eval("(0.1..)").bsearch { |x| x < 0.0 }.should == nil + eval("(0.1...)").bsearch { |x| x < 0.0 }.should == nil end it "returns nil if the block returns nil for every element" do - eval("(-0.0..)").bsearch { |x| nil }.should be_nil - eval("(-0.0...)").bsearch { |x| nil }.should be_nil + eval("(-0.0..)").bsearch { |x| nil }.should == nil + eval("(-0.0...)").bsearch { |x| nil }.should == nil end it "returns minimum element if the block returns true for every element" do @@ -304,22 +304,22 @@ context "with a block returning negative, zero, positive numbers" do it "returns nil if the block returns less than zero for every element" do - eval("(-2.0..)").bsearch { |x| -1 }.should be_nil - eval("(-2.0...)").bsearch { |x| -1 }.should be_nil + eval("(-2.0..)").bsearch { |x| -1 }.should == nil + eval("(-2.0...)").bsearch { |x| -1 }.should == nil end it "returns nil if the block returns greater than zero for every element" do - eval("(0.3..)").bsearch { |x| 1 }.should be_nil - eval("(0.3...)").bsearch { |x| 1 }.should be_nil + eval("(0.3..)").bsearch { |x| 1 }.should == nil + eval("(0.3...)").bsearch { |x| 1 }.should == nil end it "returns nil if the block never returns zero" do - eval("(0.2..)").bsearch { |x| x < 2 ? 1 : -1 }.should be_nil + eval("(0.2..)").bsearch { |x| x < 2 ? 1 : -1 }.should == nil end it "accepts (+/-)Float::INFINITY from the block" do - eval("(0.1..)").bsearch { |x| Float::INFINITY }.should be_nil - eval("(-5.0..)").bsearch { |x| -Float::INFINITY }.should be_nil + eval("(0.1..)").bsearch { |x| Float::INFINITY }.should == nil + eval("(-5.0..)").bsearch { |x| -Float::INFINITY }.should == nil end it "returns an element at an index for which block returns 0.0" do @@ -362,15 +362,15 @@ context "with a block returning negative, zero, positive numbers" do it "returns nil if the block returns greater than zero for every element" do - (..0).bsearch { |x| 1 }.should be_nil + (..0).bsearch { |x| 1 }.should == nil end it "returns nil if the block never returns zero" do - (..0).bsearch { |x| x > 5 ? -1 : 1 }.should be_nil + (..0).bsearch { |x| x > 5 ? -1 : 1 }.should == nil end it "accepts Float::INFINITY from the block" do - (..0).bsearch { |x| Float::INFINITY }.should be_nil + (..0).bsearch { |x| Float::INFINITY }.should == nil end it "returns an element at an index for which block returns 0.0" do @@ -380,7 +380,7 @@ it "returns an element at an index for which block returns 0" do result = (...10).bsearch { |x| x < 1 ? 1 : x > 3 ? -1 : 0 } - [1, 2, 3].should include(result) + [1, 2, 3].should.include?(result) end end @@ -392,13 +392,13 @@ context "with beginless ranges and Float values" do context "with a block returning true or false" do it "returns nil if the block returns true for every element" do - (..-0.1).bsearch { |x| x > 0.0 }.should be_nil - (...-0.1).bsearch { |x| x > 0.0 }.should be_nil + (..-0.1).bsearch { |x| x > 0.0 }.should == nil + (...-0.1).bsearch { |x| x > 0.0 }.should == nil end it "returns nil if the block returns nil for every element" do - (..-0.1).bsearch { |x| nil }.should be_nil - (...-0.1).bsearch { |x| nil }.should be_nil + (..-0.1).bsearch { |x| nil }.should == nil + (...-0.1).bsearch { |x| nil }.should == nil end it "returns the smallest element for which block returns true" do @@ -417,22 +417,22 @@ context "with a block returning negative, zero, positive numbers" do it "returns nil if the block returns less than zero for every element" do - (..5.0).bsearch { |x| -1 }.should be_nil - (...5.0).bsearch { |x| -1 }.should be_nil + (..5.0).bsearch { |x| -1 }.should == nil + (...5.0).bsearch { |x| -1 }.should == nil end it "returns nil if the block returns greater than zero for every element" do - (..1.1).bsearch { |x| 1 }.should be_nil - (...1.1).bsearch { |x| 1 }.should be_nil + (..1.1).bsearch { |x| 1 }.should == nil + (...1.1).bsearch { |x| 1 }.should == nil end it "returns nil if the block never returns zero" do - (..6.3).bsearch { |x| x < 2 ? 1 : -1 }.should be_nil + (..6.3).bsearch { |x| x < 2 ? 1 : -1 }.should == nil end it "accepts (+/-)Float::INFINITY from the block" do - (..5.0).bsearch { |x| Float::INFINITY }.should be_nil - (..7.0).bsearch { |x| -Float::INFINITY }.should be_nil + (..5.0).bsearch { |x| Float::INFINITY }.should == nil + (..7.0).bsearch { |x| -Float::INFINITY }.should == nil end it "returns an element at an index for which block returns 0.0" do diff --git a/spec/ruby/core/range/cover_spec.rb b/spec/ruby/core/range/cover_spec.rb index c05bb50614e61c..eb8d5453bf8c5f 100644 --- a/spec/ruby/core/range/cover_spec.rb +++ b/spec/ruby/core/range/cover_spec.rb @@ -9,6 +9,6 @@ it_behaves_like :range_cover_subrange, :cover? it "covers U+9995 in the range U+0999..U+9999" do - ("\u{999}".."\u{9999}").cover?("\u{9995}").should be_true + ("\u{999}".."\u{9999}").cover?("\u{9995}").should == true end end diff --git a/spec/ruby/core/range/each_spec.rb b/spec/ruby/core/range/each_spec.rb index f10330d61d7769..b4389f864da4e9 100644 --- a/spec/ruby/core/range/each_spec.rb +++ b/spec/ruby/core/range/each_spec.rb @@ -59,26 +59,26 @@ end it "raises a TypeError beginless ranges" do - -> { (..2).each { |x| x } }.should raise_error(TypeError) + -> { (..2).each { |x| x } }.should.raise(TypeError) end it "raises a TypeError if the first element does not respond to #succ" do - -> { (0.5..2.4).each { |i| i } }.should raise_error(TypeError) + -> { (0.5..2.4).each { |i| i } }.should.raise(TypeError) b = mock('x') (a = mock('1')).should_receive(:<=>).with(b).and_return(1) - -> { (a..b).each { |i| i } }.should raise_error(TypeError) + -> { (a..b).each { |i| i } }.should.raise(TypeError) end it "returns self" do range = 1..10 - range.each{}.should equal(range) + range.each{}.should.equal?(range) end it "returns an enumerator when no block given" do enum = (1..3).each - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == [1, 2, 3] end diff --git a/spec/ruby/core/range/eql_spec.rb b/spec/ruby/core/range/eql_spec.rb index fa6c71840e9ca4..cdc19c9331e22c 100644 --- a/spec/ruby/core/range/eql_spec.rb +++ b/spec/ruby/core/range/eql_spec.rb @@ -5,6 +5,6 @@ it_behaves_like :range_eql, :eql? it "returns false if the endpoints are not eql?" do - (0..1).should_not eql(0..1.0) + (0..1).should_not.eql?(0..1.0) end end diff --git a/spec/ruby/core/range/first_spec.rb b/spec/ruby/core/range/first_spec.rb index 2af935f439a4fe..54bd73a4e8f0b9 100644 --- a/spec/ruby/core/range/first_spec.rb +++ b/spec/ruby/core/range/first_spec.rb @@ -21,7 +21,7 @@ end it "raises an ArgumentError when count is negative" do - -> { (0..2).first(-1) }.should raise_error(ArgumentError) + -> { (0..2).first(-1) }.should.raise(ArgumentError) end it "calls #to_int to convert the argument" do @@ -32,7 +32,7 @@ it "raises a TypeError if #to_int does not return an Integer" do obj = mock("to_int") obj.should_receive(:to_int).and_return("1") - -> { (2..3).first(obj) }.should raise_error(TypeError) + -> { (2..3).first(obj) }.should.raise(TypeError) end it "truncates the value when passed a Float" do @@ -40,14 +40,14 @@ end it "raises a TypeError when passed nil" do - -> { (2..3).first(nil) }.should raise_error(TypeError) + -> { (2..3).first(nil) }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { (2..3).first("1") }.should raise_error(TypeError) + -> { (2..3).first("1") }.should.raise(TypeError) end it "raises a RangeError when called on an beginless range" do - -> { (..1).first }.should raise_error(RangeError) + -> { (..1).first }.should.raise(RangeError) end end diff --git a/spec/ruby/core/range/hash_spec.rb b/spec/ruby/core/range/hash_spec.rb index 4f2681e86ed939..087f5d6de8a9af 100644 --- a/spec/ruby/core/range/hash_spec.rb +++ b/spec/ruby/core/range/hash_spec.rb @@ -15,10 +15,10 @@ end it "generates an Integer for the hash value" do - (0..0).hash.should be_an_instance_of(Integer) - (0..1).hash.should be_an_instance_of(Integer) - (0...10).hash.should be_an_instance_of(Integer) - (0..10).hash.should be_an_instance_of(Integer) + (0..0).hash.should.instance_of?(Integer) + (0..1).hash.should.instance_of?(Integer) + (0...10).hash.should.instance_of?(Integer) + (0..10).hash.should.instance_of?(Integer) end end diff --git a/spec/ruby/core/range/include_spec.rb b/spec/ruby/core/range/include_spec.rb index 449e18985b9505..66a049a90db510 100644 --- a/spec/ruby/core/range/include_spec.rb +++ b/spec/ruby/core/range/include_spec.rb @@ -9,6 +9,6 @@ it_behaves_like :range_include, :include? it "does not include U+9995 in the range U+0999..U+9999" do - ("\u{999}".."\u{9999}").include?("\u{9995}").should be_false + ("\u{999}".."\u{9999}").include?("\u{9995}").should == false end end diff --git a/spec/ruby/core/range/initialize_spec.rb b/spec/ruby/core/range/initialize_spec.rb index c653caf0c6f5c2..b1a0565ab25171 100644 --- a/spec/ruby/core/range/initialize_spec.rb +++ b/spec/ruby/core/range/initialize_spec.rb @@ -6,36 +6,36 @@ end it "is private" do - Range.should have_private_instance_method("initialize") + Range.private_instance_methods(false).should.include?(:initialize) end it "initializes correctly the Range object when given 2 arguments" do - -> { @range.send(:initialize, 0, 1) }.should_not raise_error + -> { @range.send(:initialize, 0, 1) }.should_not.raise end it "initializes correctly the Range object when given 3 arguments" do - -> { @range.send(:initialize, 0, 1, true) }.should_not raise_error + -> { @range.send(:initialize, 0, 1, true) }.should_not.raise end it "raises an ArgumentError if passed without or with only one argument" do - -> { @range.send(:initialize) }.should raise_error(ArgumentError) - -> { @range.send(:initialize, 1) }.should raise_error(ArgumentError) + -> { @range.send(:initialize) }.should.raise(ArgumentError) + -> { @range.send(:initialize, 1) }.should.raise(ArgumentError) end it "raises an ArgumentError if passed with four or more arguments" do - -> { @range.send(:initialize, 1, 3, 5, 7) }.should raise_error(ArgumentError) - -> { @range.send(:initialize, 1, 3, 5, 7, 9) }.should raise_error(ArgumentError) + -> { @range.send(:initialize, 1, 3, 5, 7) }.should.raise(ArgumentError) + -> { @range.send(:initialize, 1, 3, 5, 7, 9) }.should.raise(ArgumentError) end it "raises a FrozenError if called on an already initialized Range" do - -> { (0..1).send(:initialize, 1, 3) }.should raise_error(FrozenError) - -> { (0..1).send(:initialize, 1, 3, true) }.should raise_error(FrozenError) + -> { (0..1).send(:initialize, 1, 3) }.should.raise(FrozenError) + -> { (0..1).send(:initialize, 1, 3, true) }.should.raise(FrozenError) end it "raises an ArgumentError if arguments don't respond to <=>" do o1 = Object.new o2 = Object.new - -> { @range.send(:initialize, o1, o2) }.should raise_error(ArgumentError) + -> { @range.send(:initialize, o1, o2) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/range/last_spec.rb b/spec/ruby/core/range/last_spec.rb index 82b3e2ff5340cb..a7db7f85a7b47a 100644 --- a/spec/ruby/core/range/last_spec.rb +++ b/spec/ruby/core/range/last_spec.rb @@ -25,7 +25,7 @@ end it "raises an ArgumentError when count is negative" do - -> { (0..2).last(-1) }.should raise_error(ArgumentError) + -> { (0..2).last(-1) }.should.raise(ArgumentError) end it "calls #to_int to convert the argument" do @@ -36,7 +36,7 @@ it "raises a TypeError if #to_int does not return an Integer" do obj = mock("to_int") obj.should_receive(:to_int).and_return("1") - -> { (2..3).last(obj) }.should raise_error(TypeError) + -> { (2..3).last(obj) }.should.raise(TypeError) end it "truncates the value when passed a Float" do @@ -44,14 +44,14 @@ end it "raises a TypeError when passed nil" do - -> { (2..3).last(nil) }.should raise_error(TypeError) + -> { (2..3).last(nil) }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { (2..3).last("1") }.should raise_error(TypeError) + -> { (2..3).last("1") }.should.raise(TypeError) end it "raises a RangeError when called on an endless range" do - -> { eval("(1..)").last }.should raise_error(RangeError) + -> { eval("(1..)").last }.should.raise(RangeError) end end diff --git a/spec/ruby/core/range/max_spec.rb b/spec/ruby/core/range/max_spec.rb index 09371f52987862..57714967ce0afe 100644 --- a/spec/ruby/core/range/max_spec.rb +++ b/spec/ruby/core/range/max_spec.rb @@ -14,40 +14,40 @@ end it "raises TypeError when called on an exclusive range and a non Integer value" do - -> { (303.20...908.1111).max }.should raise_error(TypeError) + -> { (303.20...908.1111).max }.should.raise(TypeError) end it "returns nil when the endpoint is less than the start point" do - (100..10).max.should be_nil - ('z'..'l').max.should be_nil + (100..10).max.should == nil + ('z'..'l').max.should == nil end it "returns nil when the endpoint equals the start point and the range is exclusive" do - (5...5).max.should be_nil + (5...5).max.should == nil end it "returns the endpoint when the endpoint equals the start point and the range is inclusive" do - (5..5).max.should equal(5) + (5..5).max.should.equal?(5) end it "returns nil when the endpoint is less than the start point in a Float range" do - (3003.20..908.1111).max.should be_nil + (3003.20..908.1111).max.should == nil end it "returns end point when the range is Time..Time(included end point)" do time_start = Time.now time_end = Time.now + 1.0 - (time_start..time_end).max.should equal(time_end) + (time_start..time_end).max.should.equal?(time_end) end it "raises TypeError when called on a Time...Time(excluded end point)" do time_start = Time.now time_end = Time.now + 1.0 - -> { (time_start...time_end).max }.should raise_error(TypeError) + -> { (time_start...time_end).max }.should.raise(TypeError) end it "raises RangeError when called on an endless range" do - -> { eval("(1..)").max }.should raise_error(RangeError) + -> { eval("(1..)").max }.should.raise(RangeError) end it "returns the end point for beginless ranges" do @@ -59,7 +59,7 @@ it "raises for an exclusive beginless Integer range" do -> { (...1).max - }.should raise_error(TypeError, 'cannot exclude end value with non Integer begin value') + }.should.raise(TypeError, 'cannot exclude end value with non Integer begin value') end end @@ -72,7 +72,7 @@ it "raises for an exclusive beginless non Integer range" do -> { (...1.0).max - }.should raise_error(TypeError, 'cannot exclude non Integer end value') + }.should.raise(TypeError, 'cannot exclude non Integer end value') end end @@ -82,7 +82,7 @@ (1..10).max {|a,b| acc << [a,b]; a } acc.flatten! (1..10).each do |value| - acc.include?(value).should be_true + acc.include?(value).should == true end end @@ -104,12 +104,12 @@ end it "returns nil when the endpoint is less than the start point" do - (100..10).max {|x,y| x <=> y}.should be_nil - ('z'..'l').max {|x,y| x <=> y}.should be_nil - (5...5).max {|x,y| x <=> y}.should be_nil + (100..10).max {|x,y| x <=> y}.should == nil + ('z'..'l').max {|x,y| x <=> y}.should == nil + (5...5).max {|x,y| x <=> y}.should == nil end it "raises RangeError when called with custom comparison method on an beginless range" do - -> { (..1).max {|a, b| a} }.should raise_error(RangeError) + -> { (..1).max {|a, b| a} }.should.raise(RangeError) end end diff --git a/spec/ruby/core/range/min_spec.rb b/spec/ruby/core/range/min_spec.rb index 89310ee589ad2c..9c83d3decaec71 100644 --- a/spec/ruby/core/range/min_spec.rb +++ b/spec/ruby/core/range/min_spec.rb @@ -11,32 +11,32 @@ end it "returns nil when the start point is greater than the endpoint" do - (100..10).min.should be_nil - ('z'..'l').min.should be_nil + (100..10).min.should == nil + ('z'..'l').min.should == nil end it "returns nil when the endpoint equals the start point and the range is exclusive" do - (7...7).min.should be_nil + (7...7).min.should == nil end it "returns the start point when the endpoint equals the start point and the range is inclusive" do - (7..7).min.should equal(7) + (7..7).min.should.equal?(7) end it "returns nil when the start point is greater than the endpoint in a Float range" do - (3003.20..908.1111).min.should be_nil + (3003.20..908.1111).min.should == nil end it "returns start point when the range is Time..Time(included end point)" do time_start = Time.now time_end = Time.now + 1.0 - (time_start..time_end).min.should equal(time_start) + (time_start..time_end).min.should.equal?(time_start) end it "returns start point when the range is Time...Time(excluded end point)" do time_start = Time.now time_end = Time.now + 1.0 - (time_start...time_end).min.should equal(time_start) + (time_start...time_end).min.should.equal?(time_start) end it "returns the start point for endless ranges" do @@ -45,7 +45,7 @@ end it "raises RangeError when called on an beginless range" do - -> { (..1).min }.should raise_error(RangeError) + -> { (..1).min }.should.raise(RangeError) end end @@ -55,7 +55,7 @@ (1..10).min {|a,b| acc << [a,b]; a } acc.flatten! (1..10).each do |value| - acc.include?(value).should be_true + acc.include?(value).should == true end end @@ -77,12 +77,12 @@ end it "returns nil when the start point is greater than the endpoint" do - (100..10).min {|x,y| x <=> y}.should be_nil - ('z'..'l').min {|x,y| x <=> y}.should be_nil - (7...7).min {|x,y| x <=> y}.should be_nil + (100..10).min {|x,y| x <=> y}.should == nil + ('z'..'l').min {|x,y| x <=> y}.should == nil + (7...7).min {|x,y| x <=> y}.should == nil end it "raises RangeError when called with custom comparison method on an endless range" do - -> { eval("(1..)").min {|a, b| a} }.should raise_error(RangeError) + -> { eval("(1..)").min {|a, b| a} }.should.raise(RangeError) end end diff --git a/spec/ruby/core/range/minmax_spec.rb b/spec/ruby/core/range/minmax_spec.rb index 6651ae3726d906..16c7626ea349c1 100644 --- a/spec/ruby/core/range/minmax_spec.rb +++ b/spec/ruby/core/range/minmax_spec.rb @@ -17,19 +17,19 @@ range = (@x..) - -> { range.minmax }.should raise_error(RangeError, 'cannot get the maximum of endless range') + -> { range.minmax }.should.raise(RangeError, 'cannot get the maximum of endless range') end it 'raises RangeError or ArgumentError on a beginless range' do range = (..@x) - -> { range.minmax }.should raise_error(StandardError) { |e| + -> { range.minmax }.should.raise(StandardError) { |e| if RangeError === e # error from #min - -> { raise e }.should raise_error(RangeError, 'cannot get the minimum of beginless range') + -> { raise e }.should.raise(RangeError, 'cannot get the minimum of beginless range') else # error from #max - -> { raise e }.should raise_error(ArgumentError, 'comparison of NilClass with MockObject failed') + -> { raise e }.should.raise(ArgumentError, 'comparison of NilClass with MockObject failed') end } end @@ -76,13 +76,13 @@ @x.should_not_receive(:succ) range = (@x...) - -> { range.minmax }.should raise_error(RangeError, 'cannot get the maximum of endless range') + -> { range.minmax }.should.raise(RangeError, 'cannot get the maximum of endless range') end it 'should raise RangeError on a beginless range' do range = (...@x) - -> { range.minmax }.should raise_error(RangeError, + -> { range.minmax }.should.raise(RangeError, /cannot get the maximum of beginless range with custom comparison method|cannot get the minimum of beginless range/) end @@ -118,7 +118,7 @@ it 'raises TypeError if the end value is not an integer' do range = (0...Float::INFINITY) - -> { range.minmax }.should raise_error(TypeError, 'cannot exclude non Integer end value') + -> { range.minmax }.should.raise(TypeError, 'cannot exclude non Integer end value') end it 'should return the minimum and maximum values according to the provided block by iterating the range' do diff --git a/spec/ruby/core/range/new_spec.rb b/spec/ruby/core/range/new_spec.rb index 3cab8877995df4..9a35f28c7edc6b 100644 --- a/spec/ruby/core/range/new_spec.rb +++ b/spec/ruby/core/range/new_spec.rb @@ -25,12 +25,12 @@ end it "raises an ArgumentError when the given start and end can't be compared by using #<=>" do - -> { Range.new(1, mock('x')) }.should raise_error(ArgumentError) - -> { Range.new(mock('x'), mock('y')) }.should raise_error(ArgumentError) + -> { Range.new(1, mock('x')) }.should.raise(ArgumentError) + -> { Range.new(mock('x'), mock('y')) }.should.raise(ArgumentError) b = mock('x') (a = mock('nil')).should_receive(:<=>).with(b).and_return(nil) - -> { Range.new(a, b) }.should raise_error(ArgumentError) + -> { Range.new(a, b) }.should.raise(ArgumentError) end it "does not rescue exception raised in #<=> when compares the given start and end" do @@ -38,7 +38,7 @@ a = mock('b') a.should_receive(:<=>).with(b).and_raise(RangeSpecs::ComparisonError) - -> { Range.new(a, b) }.should raise_error(RangeSpecs::ComparisonError) + -> { Range.new(a, b) }.should.raise(RangeSpecs::ComparisonError) end describe "beginless/endless range" do diff --git a/spec/ruby/core/range/overlap_spec.rb b/spec/ruby/core/range/overlap_spec.rb index 3e7d2bdda8acf9..201cd2b1ff7e0f 100644 --- a/spec/ruby/core/range/overlap_spec.rb +++ b/spec/ruby/core/range/overlap_spec.rb @@ -21,7 +21,7 @@ it "raises TypeError when called with non-Range argument" do -> { (0..2).overlap?(1) - }.should raise_error(TypeError, "wrong argument type Integer (expected Range)") + }.should.raise(TypeError, "wrong argument type Integer (expected Range)") end it "returns true when beginningless and endless Ranges overlap" do diff --git a/spec/ruby/core/range/reverse_each_spec.rb b/spec/ruby/core/range/reverse_each_spec.rb index 16aaace6afaa60..49790e8b0a2574 100644 --- a/spec/ruby/core/range/reverse_each_spec.rb +++ b/spec/ruby/core/range/reverse_each_spec.rb @@ -13,25 +13,25 @@ it "returns self" do r = (1..3) - r.reverse_each { |x| }.should equal(r) + r.reverse_each { |x| }.should.equal?(r) end it "returns an Enumerator if no block given" do enum = (1..3).reverse_each - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == [3, 2, 1] end it "raises a TypeError for endless Ranges of Integers" do -> { (1..).reverse_each.take(3) - }.should raise_error(TypeError, "can't iterate from NilClass") + }.should.raise(TypeError, "can't iterate from NilClass") end it "raises a TypeError for endless Ranges of non-Integers" do -> { ("a"..).reverse_each.take(3) - }.should raise_error(TypeError, "can't iterate from NilClass") + }.should.raise(TypeError, "can't iterate from NilClass") end context "Integer boundaries" do @@ -69,15 +69,15 @@ end it "raises a TypeError when `begin` value does not respond to #succ" do - -> { (Time.now..Time.now).reverse_each { |x| x } }.should raise_error(TypeError, /can't iterate from Time/) - -> { (//..//).reverse_each { |x| x } }.should raise_error(TypeError, /can't iterate from Regexp/) - -> { ([]..[]).reverse_each { |x| x } }.should raise_error(TypeError, /can't iterate from Array/) + -> { (Time.now..Time.now).reverse_each { |x| x } }.should.raise(TypeError, /can't iterate from Time/) + -> { (//..//).reverse_each { |x| x } }.should.raise(TypeError, /can't iterate from Regexp/) + -> { ([]..[]).reverse_each { |x| x } }.should.raise(TypeError, /can't iterate from Array/) end it "does not support beginningless Ranges" do -> { (..'a').reverse_each { |x| x } - }.should raise_error(TypeError, /can't iterate from NilClass/) + }.should.raise(TypeError, /can't iterate from NilClass/) end end @@ -103,11 +103,11 @@ ruby_version_is "3.4" do it "raises TypeError when the range is not iterable" do - -> { (1.1..3).reverse_each.size }.should raise_error(TypeError, /can't iterate from Integer/) - -> { (1.1..3.3).reverse_each.size }.should raise_error(TypeError, /can't iterate from Float/) - -> { (1.1..nil).reverse_each.size }.should raise_error(TypeError, /can't iterate from NilClass/) - -> { (nil..3.3).reverse_each.size }.should raise_error(TypeError, /can't iterate from Float/) - -> { (nil..nil).reverse_each.size }.should raise_error(TypeError, /can't iterate from NilClass/) + -> { (1.1..3).reverse_each.size }.should.raise(TypeError, /can't iterate from Integer/) + -> { (1.1..3.3).reverse_each.size }.should.raise(TypeError, /can't iterate from Float/) + -> { (1.1..nil).reverse_each.size }.should.raise(TypeError, /can't iterate from NilClass/) + -> { (nil..3.3).reverse_each.size }.should.raise(TypeError, /can't iterate from Float/) + -> { (nil..nil).reverse_each.size }.should.raise(TypeError, /can't iterate from NilClass/) end end diff --git a/spec/ruby/core/range/shared/cover.rb b/spec/ruby/core/range/shared/cover.rb index eaefb45942f59d..189f3da4bf5185 100644 --- a/spec/ruby/core/range/shared/cover.rb +++ b/spec/ruby/core/range/shared/cover.rb @@ -6,26 +6,26 @@ it "uses the range element's <=> to make the comparison" do a = mock('a') a.should_receive(:<=>).twice.and_return(-1,-1) - (a..'z').send(@method, 'b').should be_true + (a..'z').send(@method, 'b').should == true end it "uses a continuous inclusion test" do - ('a'..'f').send(@method, 'aa').should be_true - ('a'..'f').send(@method, 'babe').should be_true - ('a'..'f').send(@method, 'baby').should be_true - ('a'..'f').send(@method, 'ga').should be_false - (-10..-2).send(@method, -2.5).should be_true + ('a'..'f').send(@method, 'aa').should == true + ('a'..'f').send(@method, 'babe').should == true + ('a'..'f').send(@method, 'baby').should == true + ('a'..'f').send(@method, 'ga').should == false + (-10..-2).send(@method, -2.5).should == true end describe "on string elements" do it "returns true if other is matched by element.succ" do - ('a'..'c').send(@method, 'b').should be_true - ('a'...'c').send(@method, 'b').should be_true + ('a'..'c').send(@method, 'b').should == true + ('a'...'c').send(@method, 'b').should == true end it "returns true if other is not matched by element.succ" do - ('a'..'c').send(@method, 'bc').should be_true - ('a'...'c').send(@method, 'bc').should be_true + ('a'..'c').send(@method, 'bc').should == true + ('a'...'c').send(@method, 'bc').should == true end end @@ -36,27 +36,27 @@ end it "returns false if other is less than first element" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(0)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(0)).should == false end it "returns true if other is equal as first element" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(1)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(1)).should == true end it "returns true if other is matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(10)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(10)).should == true end it "returns true if other is not matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(2)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(2)).should == true end it "returns true if other is equal as last element but not matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(99)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(99)).should == true end it "returns false if other is greater than last element but matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(100)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(100)).should == false end end @@ -66,27 +66,27 @@ end it "returns false if other is less than first element" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(0)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(0)).should == false end it "returns true if other is equal as first element" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(1)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(1)).should == true end it "returns true if other is matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(10)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(10)).should == true end it "returns true if other is not matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(2)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(2)).should == true end it "returns false if other is equal as last element but not matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(99)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(99)).should == false end it "returns false if other is greater than last element but matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(100)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(100)).should == false end end end @@ -95,99 +95,99 @@ describe :range_cover_subrange, shared: true do context "range argument" do it "accepts range argument" do - (0..10).send(@method, (3..7)).should be_true - (0..10).send(@method, (3..15)).should be_false - (0..10).send(@method, (-2..7)).should be_false + (0..10).send(@method, (3..7)).should == true + (0..10).send(@method, (3..15)).should == false + (0..10).send(@method, (-2..7)).should == false - (1.1..7.9).send(@method, (2.5..6.5)).should be_true - (1.1..7.9).send(@method, (2.5..8.5)).should be_false - (1.1..7.9).send(@method, (0.5..6.5)).should be_false + (1.1..7.9).send(@method, (2.5..6.5)).should == true + (1.1..7.9).send(@method, (2.5..8.5)).should == false + (1.1..7.9).send(@method, (0.5..6.5)).should == false - ('c'..'i').send(@method, ('d'..'f')).should be_true - ('c'..'i').send(@method, ('d'..'z')).should be_false - ('c'..'i').send(@method, ('a'..'f')).should be_false + ('c'..'i').send(@method, ('d'..'f')).should == true + ('c'..'i').send(@method, ('d'..'z')).should == false + ('c'..'i').send(@method, ('a'..'f')).should == false range_10_100 = RangeSpecs::TenfoldSucc.new(10)..RangeSpecs::TenfoldSucc.new(100) range_20_90 = RangeSpecs::TenfoldSucc.new(20)..RangeSpecs::TenfoldSucc.new(90) range_20_110 = RangeSpecs::TenfoldSucc.new(20)..RangeSpecs::TenfoldSucc.new(110) range_0_90 = RangeSpecs::TenfoldSucc.new(0)..RangeSpecs::TenfoldSucc.new(90) - range_10_100.send(@method, range_20_90).should be_true - range_10_100.send(@method, range_20_110).should be_false - range_10_100.send(@method, range_0_90).should be_false + range_10_100.send(@method, range_20_90).should == true + range_10_100.send(@method, range_20_110).should == false + range_10_100.send(@method, range_0_90).should == false end it "supports boundaries of different comparable types" do - (0..10).send(@method, (3.1..7.9)).should be_true - (0..10).send(@method, (3.1..15.9)).should be_false - (0..10).send(@method, (-2.1..7.9)).should be_false + (0..10).send(@method, (3.1..7.9)).should == true + (0..10).send(@method, (3.1..15.9)).should == false + (0..10).send(@method, (-2.1..7.9)).should == false end it "returns false if types are not comparable" do - (0..10).send(@method, ('a'..'z')).should be_false - (0..10).send(@method, (RangeSpecs::TenfoldSucc.new(0)..RangeSpecs::TenfoldSucc.new(100))).should be_false + (0..10).send(@method, ('a'..'z')).should == false + (0..10).send(@method, (RangeSpecs::TenfoldSucc.new(0)..RangeSpecs::TenfoldSucc.new(100))).should == false end it "honors exclusion of right boundary (:exclude_end option)" do # Integer - (0..10).send(@method, (0..10)).should be_true - (0...10).send(@method, (0...10)).should be_true + (0..10).send(@method, (0..10)).should == true + (0...10).send(@method, (0...10)).should == true - (0..10).send(@method, (0...10)).should be_true - (0...10).send(@method, (0..10)).should be_false + (0..10).send(@method, (0...10)).should == true + (0...10).send(@method, (0..10)).should == false - (0...11).send(@method, (0..10)).should be_true - (0..10).send(@method, (0...11)).should be_true + (0...11).send(@method, (0..10)).should == true + (0..10).send(@method, (0...11)).should == true # Float - (0..10.1).send(@method, (0..10.1)).should be_true - (0...10.1).send(@method, (0...10.1)).should be_true + (0..10.1).send(@method, (0..10.1)).should == true + (0...10.1).send(@method, (0...10.1)).should == true - (0..10.1).send(@method, (0...10.1)).should be_true - (0...10.1).send(@method, (0..10.1)).should be_false + (0..10.1).send(@method, (0...10.1)).should == true + (0...10.1).send(@method, (0..10.1)).should == false - (0...11.1).send(@method, (0..10.1)).should be_true - (0..10.1).send(@method, (0...11.1)).should be_false + (0...11.1).send(@method, (0..10.1)).should == true + (0..10.1).send(@method, (0...11.1)).should == false end end it "allows self to be a beginless range" do - (...10).send(@method, (3..7)).should be_true - (...10).send(@method, (3..15)).should be_false + (...10).send(@method, (3..7)).should == true + (...10).send(@method, (3..15)).should == false - (..7.9).send(@method, (2.5..6.5)).should be_true - (..7.9).send(@method, (2.5..8.5)).should be_false + (..7.9).send(@method, (2.5..6.5)).should == true + (..7.9).send(@method, (2.5..8.5)).should == false - (..'i').send(@method, ('d'..'f')).should be_true - (..'i').send(@method, ('d'..'z')).should be_false + (..'i').send(@method, ('d'..'f')).should == true + (..'i').send(@method, ('d'..'z')).should == false end it "allows self to be a endless range" do - eval("(0...)").send(@method, (3..7)).should be_true - eval("(5...)").send(@method, (3..15)).should be_false + eval("(0...)").send(@method, (3..7)).should == true + eval("(5...)").send(@method, (3..15)).should == false - eval("(1.1..)").send(@method, (2.5..6.5)).should be_true - eval("(3.3..)").send(@method, (2.5..8.5)).should be_false + eval("(1.1..)").send(@method, (2.5..6.5)).should == true + eval("(3.3..)").send(@method, (2.5..8.5)).should == false - eval("('a'..)").send(@method, ('d'..'f')).should be_true - eval("('p'..)").send(@method, ('d'..'z')).should be_false + eval("('a'..)").send(@method, ('d'..'f')).should == true + eval("('p'..)").send(@method, ('d'..'z')).should == false end it "accepts beginless range argument" do - (..10).send(@method, (...10)).should be_true - (0..10).send(@method, (...10)).should be_false + (..10).send(@method, (...10)).should == true + (0..10).send(@method, (...10)).should == false - (1.1..7.9).send(@method, (...10.5)).should be_false + (1.1..7.9).send(@method, (...10.5)).should == false - ('c'..'i').send(@method, (..'i')).should be_false + ('c'..'i').send(@method, (..'i')).should == false end it "accepts endless range argument" do - eval("(0..)").send(@method, eval("(0...)")).should be_true - (0..10).send(@method, eval("(0...)")).should be_false + eval("(0..)").send(@method, eval("(0...)")).should == true + (0..10).send(@method, eval("(0...)")).should == false - (1.1..7.9).send(@method, eval("(0.8...)")).should be_false + (1.1..7.9).send(@method, eval("(0.8...)")).should == false - ('c'..'i').send(@method, eval("('a'..)")).should be_false + ('c'..'i').send(@method, eval("('a'..)")).should == false end end diff --git a/spec/ruby/core/range/shared/cover_and_include.rb b/spec/ruby/core/range/shared/cover_and_include.rb index 13fc5e17906d03..97721a7307304f 100644 --- a/spec/ruby/core/range/shared/cover_and_include.rb +++ b/spec/ruby/core/range/shared/cover_and_include.rb @@ -46,41 +46,41 @@ m.should_receive(:coerce).and_return([1, 2]) m.should_receive(:<=>).and_return(1) - rng.send(@method, m).should be_false + rng.send(@method, m).should == false end it "raises an ArgumentError without exactly one argument" do - ->{ (1..2).send(@method) }.should raise_error(ArgumentError) - ->{ (1..2).send(@method, 1, 2) }.should raise_error(ArgumentError) + ->{ (1..2).send(@method) }.should.raise(ArgumentError) + ->{ (1..2).send(@method, 1, 2) }.should.raise(ArgumentError) end it "returns true if argument is equal to the first value of the range" do - (0..5).send(@method, 0).should be_true - ('f'..'s').send(@method, 'f').should be_true + (0..5).send(@method, 0).should == true + ('f'..'s').send(@method, 'f').should == true end it "returns true if argument is equal to the last value of the range" do - (0..5).send(@method, 5).should be_true - (0...5).send(@method, 4).should be_true - ('f'..'s').send(@method, 's').should be_true + (0..5).send(@method, 5).should == true + (0...5).send(@method, 4).should == true + ('f'..'s').send(@method, 's').should == true end it "returns true if argument is less than the last value of the range and greater than the first value" do - (20..30).send(@method, 28).should be_true - ('e'..'h').send(@method, 'g').should be_true + (20..30).send(@method, 28).should == true + ('e'..'h').send(@method, 'g').should == true end it "returns true if argument is sole element in the range" do - (30..30).send(@method, 30).should be_true + (30..30).send(@method, 30).should == true end it "returns false if range is empty" do - (30...30).send(@method, 30).should be_false - (30...30).send(@method, nil).should be_false + (30...30).send(@method, 30).should == false + (30...30).send(@method, nil).should == false end it "returns false if the range does not contain the argument" do - ('A'..'C').send(@method, 20.9).should be_false - ('A'...'C').send(@method, 'C').should be_false + ('A'..'C').send(@method, 20.9).should == false + ('A'...'C').send(@method, 'C').should == false end end diff --git a/spec/ruby/core/range/shared/include.rb b/spec/ruby/core/range/shared/include.rb index 15a0e5fb9fbb3c..5f0db480081ab4 100644 --- a/spec/ruby/core/range/shared/include.rb +++ b/spec/ruby/core/range/shared/include.rb @@ -5,13 +5,13 @@ describe :range_include, shared: true do describe "on string elements" do it "returns true if other is matched by element.succ" do - ('a'..'c').send(@method, 'b').should be_true - ('a'...'c').send(@method, 'b').should be_true + ('a'..'c').send(@method, 'b').should == true + ('a'...'c').send(@method, 'b').should == true end it "returns false if other is not matched by element.succ" do - ('a'..'c').send(@method, 'bc').should be_false - ('a'...'c').send(@method, 'bc').should be_false + ('a'..'c').send(@method, 'bc').should == false + ('a'...'c').send(@method, 'bc').should == false end end @@ -22,27 +22,27 @@ end it "returns false if other is less than first element" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(0)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(0)).should == false end it "returns true if other is equal as first element" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(1)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(1)).should == true end it "returns true if other is matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(10)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(10)).should == true end it "returns false if other is not matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(2)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(2)).should == false end it "returns false if other is equal as last element but not matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(99)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(99)).should == false end it "returns false if other is greater than last element but matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(100)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(100)).should == false end end @@ -52,27 +52,27 @@ end it "returns false if other is less than first element" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(0)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(0)).should == false end it "returns true if other is equal as first element" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(1)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(1)).should == true end it "returns true if other is matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(10)).should be_true + @range.send(@method, RangeSpecs::TenfoldSucc.new(10)).should == true end it "returns false if other is not matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(2)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(2)).should == false end it "returns false if other is equal as last element but not matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(99)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(99)).should == false end it "returns false if other is greater than last element but matched by element.succ" do - @range.send(@method, RangeSpecs::TenfoldSucc.new(100)).should be_false + @range.send(@method, RangeSpecs::TenfoldSucc.new(100)).should == false end end end diff --git a/spec/ruby/core/range/size_spec.rb b/spec/ruby/core/range/size_spec.rb index 1a3ddd197e9d82..3a8843b99d7e04 100644 --- a/spec/ruby/core/range/size_spec.rb +++ b/spec/ruby/core/range/size_spec.rb @@ -67,26 +67,26 @@ ruby_version_is "3.4" do it 'raises TypeError if a range is not iterable' do - -> { (1.0..16.0).size }.should raise_error(TypeError, /can't iterate from/) - -> { (1.0...16.0).size }.should raise_error(TypeError, /can't iterate from/) - -> { (1.0..15.9).size }.should raise_error(TypeError, /can't iterate from/) - -> { (1.1..16.0).size }.should raise_error(TypeError, /can't iterate from/) - -> { (1.1..15.9).size }.should raise_error(TypeError, /can't iterate from/) - -> { (16.0..0.0).size }.should raise_error(TypeError, /can't iterate from/) - -> { (Float::INFINITY..0).size }.should raise_error(TypeError, /can't iterate from/) - -> { (-Float::INFINITY..0).size }.should raise_error(TypeError, /can't iterate from/) - -> { (-Float::INFINITY..Float::INFINITY).size }.should raise_error(TypeError, /can't iterate from/) - -> { (..1).size }.should raise_error(TypeError, /can't iterate from/) - -> { (...0.5).size }.should raise_error(TypeError, /can't iterate from/) - -> { (..nil).size }.should raise_error(TypeError, /can't iterate from/) - -> { (...'o').size }.should raise_error(TypeError, /can't iterate from/) - -> { eval("(0.5...)").size }.should raise_error(TypeError, /can't iterate from/) - -> { eval("([]...)").size }.should raise_error(TypeError, /can't iterate from/) + -> { (1.0..16.0).size }.should.raise(TypeError, /can't iterate from/) + -> { (1.0...16.0).size }.should.raise(TypeError, /can't iterate from/) + -> { (1.0..15.9).size }.should.raise(TypeError, /can't iterate from/) + -> { (1.1..16.0).size }.should.raise(TypeError, /can't iterate from/) + -> { (1.1..15.9).size }.should.raise(TypeError, /can't iterate from/) + -> { (16.0..0.0).size }.should.raise(TypeError, /can't iterate from/) + -> { (Float::INFINITY..0).size }.should.raise(TypeError, /can't iterate from/) + -> { (-Float::INFINITY..0).size }.should.raise(TypeError, /can't iterate from/) + -> { (-Float::INFINITY..Float::INFINITY).size }.should.raise(TypeError, /can't iterate from/) + -> { (..1).size }.should.raise(TypeError, /can't iterate from/) + -> { (...0.5).size }.should.raise(TypeError, /can't iterate from/) + -> { (..nil).size }.should.raise(TypeError, /can't iterate from/) + -> { (...'o').size }.should.raise(TypeError, /can't iterate from/) + -> { eval("(0.5...)").size }.should.raise(TypeError, /can't iterate from/) + -> { eval("([]...)").size }.should.raise(TypeError, /can't iterate from/) end end it "returns nil if first and last are not Numeric" do - (:a..:z).size.should be_nil - ('a'..'z').size.should be_nil + (:a..:z).size.should == nil + ('a'..'z').size.should == nil end end diff --git a/spec/ruby/core/range/step_spec.rb b/spec/ruby/core/range/step_spec.rb index 4fe768e61c6331..faab95d88db15e 100644 --- a/spec/ruby/core/range/step_spec.rb +++ b/spec/ruby/core/range/step_spec.rb @@ -7,7 +7,7 @@ it "returns self" do r = 1..2 - r.step { }.should equal(r) + r.step { }.should.equal?(r) end ruby_version_is ""..."3.4" do @@ -16,27 +16,27 @@ obj.should_receive(:to_int).and_return(1) (1..2).step(obj) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([1, 2]) + ScratchPad.recorded.should.eql?([1, 2]) end it "raises a TypeError if step does not respond to #to_int" do obj = mock("Range#step non-integer") - -> { (1..2).step(obj) { } }.should raise_error(TypeError) + -> { (1..2).step(obj) { } }.should.raise(TypeError) end it "raises a TypeError if #to_int does not return an Integer" do obj = mock("Range#step non-integer") obj.should_receive(:to_int).and_return("1") - -> { (1..2).step(obj) { } }.should raise_error(TypeError) + -> { (1..2).step(obj) { } }.should.raise(TypeError) end it "raises a TypeError if the first element does not respond to #succ" do obj = mock("Range#step non-comparable") obj.should_receive(:<=>).with(obj).and_return(1) - -> { (obj..obj).step { |x| x } }.should raise_error(TypeError) + -> { (obj..obj).step { |x| x } }.should.raise(TypeError) end end @@ -46,22 +46,22 @@ obj.should_receive(:coerce).at_least(:once).and_return([1, 2]) (1..3).step(obj) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([1, 3]) + ScratchPad.recorded.should.eql?([1, 3]) end it "raises a TypeError if step does not respond to #coerce" do obj = mock("Range#step non-coercible") - -> { (1..2).step(obj) { } }.should raise_error(TypeError) + -> { (1..2).step(obj) { } }.should.raise(TypeError) end end it "raises an ArgumentError if step is 0" do - -> { (-1..1).step(0) { |x| x } }.should raise_error(ArgumentError) + -> { (-1..1).step(0) { |x| x } }.should.raise(ArgumentError) end it "raises an ArgumentError if step is 0.0" do - -> { (-1..1).step(0.0) { |x| x } }.should raise_error(ArgumentError) + -> { (-1..1).step(0.0) { |x| x } }.should.raise(ArgumentError) end ruby_version_is "3.4" do @@ -72,14 +72,14 @@ end it "raises an ArgumentError when iterating a beginless range" do - -> { (..10).step(1) { break } }.should raise_error(ArgumentError, + -> { (..10).step(1) { break } }.should.raise(ArgumentError, "#step iteration for beginless ranges is meaningless") end end ruby_version_is ""..."3.4" do it "raises an ArgumentError if step is negative" do - -> { (-1..1).step(-2) { |x| x } }.should raise_error(ArgumentError) + -> { (-1..1).step(-2) { |x| x } }.should.raise(ArgumentError) end end @@ -87,28 +87,28 @@ describe "and Integer values" do it "yields Integer values incremented by 1 and less than or equal to end when not passed a step" do (-2..2).step { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2, -1, 0, 1, 2]) + ScratchPad.recorded.should.eql?([-2, -1, 0, 1, 2]) end it "yields Integer values incremented by an Integer step" do (-5..5).step(2) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-5, -3, -1, 1, 3, 5]) + ScratchPad.recorded.should.eql?([-5, -3, -1, 1, 3, 5]) end it "yields Float values incremented by a Float step" do (-2..2).step(1.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -0.5, 1.0]) + ScratchPad.recorded.should.eql?([-2.0, -0.5, 1.0]) end ruby_version_is "3.4" do it "does not iterate if step is negative for forward range" do (-1..1).step(-1) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([]) + ScratchPad.recorded.should.eql?([]) end it "iterates backward if step is negative for backward range" do (1..-1).step(-1) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([1, 0, -1]) + ScratchPad.recorded.should.eql?([1, 0, -1]) end end end @@ -116,44 +116,44 @@ describe "and Float values" do it "yields Float values incremented by 1 and less than or equal to end when not passed a step" do (-2.0..2.0).step { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -1.0, 0.0, 1.0, 2.0]) + ScratchPad.recorded.should.eql?([-2.0, -1.0, 0.0, 1.0, 2.0]) end it "yields Float values incremented by an Integer step" do (-5.0..5.0).step(2) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-5.0, -3.0, -1.0, 1.0, 3.0, 5.0]) + ScratchPad.recorded.should.eql?([-5.0, -3.0, -1.0, 1.0, 3.0, 5.0]) end it "yields Float values incremented by a Float step" do (-1.0..1.0).step(0.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5, 1.0]) + ScratchPad.recorded.should.eql?([-1.0, -0.5, 0.0, 0.5, 1.0]) end it "returns Float values of 'step * n + begin <= end'" do (1.0..6.4).step(1.8) { |x| ScratchPad << x } (1.0..12.7).step(1.3) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([1.0, 2.8, 4.6, 6.4, 1.0, 2.3, 3.6, + ScratchPad.recorded.should.eql?([1.0, 2.8, 4.6, 6.4, 1.0, 2.3, 3.6, 4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7]) end it "handles infinite values at either end" do (-Float::INFINITY..0.0).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 } - ScratchPad.recorded.should eql([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY]) + ScratchPad.recorded.should.eql?([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY]) ScratchPad.record [] (0.0..Float::INFINITY).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 } - ScratchPad.recorded.should eql([0.0, 2.0, 4.0]) + ScratchPad.recorded.should.eql?([0.0, 2.0, 4.0]) end ruby_version_is "3.4" do it "does not iterate if step is negative for forward range" do (-1.0..1.0).step(-0.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([]) + ScratchPad.recorded.should.eql?([]) end it "iterates backward if step is negative for backward range" do (1.0..-1.0).step(-0.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([1.0, 0.5, 0.0, -0.5, -1.0]) + ScratchPad.recorded.should.eql?([1.0, 0.5, 0.0, -0.5, -1.0]) end end end @@ -161,34 +161,34 @@ describe "and Integer, Float values" do it "yields Float values incremented by 1 and less than or equal to end when not passed a step" do (-2..2.0).step { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -1.0, 0.0, 1.0, 2.0]) + ScratchPad.recorded.should.eql?([-2.0, -1.0, 0.0, 1.0, 2.0]) end it "yields Float values incremented by an Integer step" do (-5..5.0).step(2) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-5.0, -3.0, -1.0, 1.0, 3.0, 5.0]) + ScratchPad.recorded.should.eql?([-5.0, -3.0, -1.0, 1.0, 3.0, 5.0]) end it "yields Float values incremented by a Float step" do (-1..1.0).step(0.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5, 1.0]) + ScratchPad.recorded.should.eql?([-1.0, -0.5, 0.0, 0.5, 1.0]) end end describe "and Float, Integer values" do it "yields Float values incremented by 1 and less than or equal to end when not passed a step" do (-2.0..2).step { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -1.0, 0.0, 1.0, 2.0]) + ScratchPad.recorded.should.eql?([-2.0, -1.0, 0.0, 1.0, 2.0]) end it "yields Float values incremented by an Integer step" do (-5.0..5).step(2) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-5.0, -3.0, -1.0, 1.0, 3.0, 5.0]) + ScratchPad.recorded.should.eql?([-5.0, -3.0, -1.0, 1.0, 3.0, 5.0]) end it "yields Float values incremented by a Float step" do (-1.0..1).step(0.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5, 1.0]) + ScratchPad.recorded.should.eql?([-1.0, -0.5, 0.0, 0.5, 1.0]) end end @@ -204,7 +204,7 @@ end it "raises a TypeError when passed a Float step" do - -> { ("A".."G").step(2.0) { } }.should raise_error(TypeError) + -> { ("A".."G").step(2.0) { } }.should.raise(TypeError) end ruby_version_is ""..."3.4" do @@ -225,7 +225,7 @@ end it "raises a TypeError when passed an incompatible type step" do - -> { ("A".."G").step([]) { } }.should raise_error(TypeError) + -> { ("A".."G").step([]) { } }.should.raise(TypeError) end it "calls #+ on begin and each element returned by #+" do @@ -305,61 +305,61 @@ describe "and Integer values" do it "yields Integer values incremented by 1 and less than end when not passed a step" do (-2...2).step { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2, -1, 0, 1]) + ScratchPad.recorded.should.eql?([-2, -1, 0, 1]) end it "yields Integer values incremented by an Integer step" do (-5...5).step(2) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-5, -3, -1, 1, 3]) + ScratchPad.recorded.should.eql?([-5, -3, -1, 1, 3]) end it "yields Float values incremented by a Float step" do (-2...2).step(1.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -0.5, 1.0]) + ScratchPad.recorded.should.eql?([-2.0, -0.5, 1.0]) end end describe "and Float values" do it "yields Float values incremented by 1 and less than end when not passed a step" do (-2.0...2.0).step { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -1.0, 0.0, 1.0]) + ScratchPad.recorded.should.eql?([-2.0, -1.0, 0.0, 1.0]) end it "yields Float values incremented by an Integer step" do (-5.0...5.0).step(2) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-5.0, -3.0, -1.0, 1.0, 3.0]) + ScratchPad.recorded.should.eql?([-5.0, -3.0, -1.0, 1.0, 3.0]) end it "yields Float values incremented by a Float step" do (-1.0...1.0).step(0.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5]) + ScratchPad.recorded.should.eql?([-1.0, -0.5, 0.0, 0.5]) end it "returns Float values of 'step * n + begin < end'" do (1.0...6.4).step(1.8) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([1.0, 2.8, 4.6]) + ScratchPad.recorded.should.eql?([1.0, 2.8, 4.6]) end it "correctly handles values near the upper limit" do # https://bugs.ruby-lang.org/issues/16612 (1.0...55.6).step(18.2) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([1.0, 19.2, 37.4, 55.599999999999994]) + ScratchPad.recorded.should.eql?([1.0, 19.2, 37.4, 55.599999999999994]) (1.0...55.6).step(18.2).size.should == 4 end it "handles infinite values at either end" do (-Float::INFINITY...0.0).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 } - ScratchPad.recorded.should eql([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY]) + ScratchPad.recorded.should.eql?([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY]) ScratchPad.record [] (0.0...Float::INFINITY).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 } - ScratchPad.recorded.should eql([0.0, 2.0, 4.0]) + ScratchPad.recorded.should.eql?([0.0, 2.0, 4.0]) end ruby_version_is "3.4" do it "iterates backward with exclusive end if step is negative" do (1.0...-1.0).step(-0.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([1.0, 0.5, 0.0, -0.5]) + ScratchPad.recorded.should.eql?([1.0, 0.5, 0.0, -0.5]) end end end @@ -367,34 +367,34 @@ describe "and Integer, Float values" do it "yields Float values incremented by 1 and less than end when not passed a step" do (-2...2.0).step { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -1.0, 0.0, 1.0]) + ScratchPad.recorded.should.eql?([-2.0, -1.0, 0.0, 1.0]) end it "yields Float values incremented by an Integer step" do (-5...5.0).step(2) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-5.0, -3.0, -1.0, 1.0, 3.0]) + ScratchPad.recorded.should.eql?([-5.0, -3.0, -1.0, 1.0, 3.0]) end it "yields an Float and then Float values incremented by a Float step" do (-1...1.0).step(0.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5]) + ScratchPad.recorded.should.eql?([-1.0, -0.5, 0.0, 0.5]) end end describe "and Float, Integer values" do it "yields Float values incremented by 1 and less than end when not passed a step" do (-2.0...2).step { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -1.0, 0.0, 1.0]) + ScratchPad.recorded.should.eql?([-2.0, -1.0, 0.0, 1.0]) end it "yields Float values incremented by an Integer step" do (-5.0...5).step(2) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-5.0, -3.0, -1.0, 1.0, 3.0]) + ScratchPad.recorded.should.eql?([-5.0, -3.0, -1.0, 1.0, 3.0]) end it "yields Float values incremented by a Float step" do (-1.0...1).step(0.5) { |x| ScratchPad << x } - ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5]) + ScratchPad.recorded.should.eql?([-1.0, -0.5, 0.0, 0.5]) end end @@ -411,7 +411,7 @@ end it "raises a TypeError when passed a Float step" do - -> { ("A"..."G").step(2.0) { } }.should raise_error(TypeError) + -> { ("A"..."G").step(2.0) { } }.should.raise(TypeError) end end @@ -422,7 +422,7 @@ end it "raises a TypeError when passed an incompatible type step" do - -> { ("A".."G").step([]) { } }.should raise_error(TypeError) + -> { ("A".."G").step([]) { } }.should.raise(TypeError) end end end @@ -432,74 +432,74 @@ describe "and Integer values" do it "yield Integer values incremented by 1 when not passed a step" do (-2..).step { |x| break if x > 2; ScratchPad << x } - ScratchPad.recorded.should eql([-2, -1, 0, 1, 2]) + ScratchPad.recorded.should.eql?([-2, -1, 0, 1, 2]) ScratchPad.record [] (-2...).step { |x| break if x > 2; ScratchPad << x } - ScratchPad.recorded.should eql([-2, -1, 0, 1, 2]) + ScratchPad.recorded.should.eql?([-2, -1, 0, 1, 2]) end it "yields Integer values incremented by an Integer step" do (-5..).step(2) { |x| break if x > 3; ScratchPad << x } - ScratchPad.recorded.should eql([-5, -3, -1, 1, 3]) + ScratchPad.recorded.should.eql?([-5, -3, -1, 1, 3]) ScratchPad.record [] (-5...).step(2) { |x| break if x > 3; ScratchPad << x } - ScratchPad.recorded.should eql([-5, -3, -1, 1, 3]) + ScratchPad.recorded.should.eql?([-5, -3, -1, 1, 3]) end it "yields Float values incremented by a Float step" do (-2..).step(1.5) { |x| break if x > 1.0; ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -0.5, 1.0]) + ScratchPad.recorded.should.eql?([-2.0, -0.5, 1.0]) ScratchPad.record [] (-2..).step(1.5) { |x| break if x > 1.0; ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -0.5, 1.0]) + ScratchPad.recorded.should.eql?([-2.0, -0.5, 1.0]) end end describe "and Float values" do it "yields Float values incremented by 1 and less than end when not passed a step" do (-2.0..).step { |x| break if x > 1.5; ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -1.0, 0.0, 1.0]) + ScratchPad.recorded.should.eql?([-2.0, -1.0, 0.0, 1.0]) ScratchPad.record [] (-2.0...).step { |x| break if x > 1.5; ScratchPad << x } - ScratchPad.recorded.should eql([-2.0, -1.0, 0.0, 1.0]) + ScratchPad.recorded.should.eql?([-2.0, -1.0, 0.0, 1.0]) end it "yields Float values incremented by an Integer step" do (-5.0..).step(2) { |x| break if x > 3.5; ScratchPad << x } - ScratchPad.recorded.should eql([-5.0, -3.0, -1.0, 1.0, 3.0]) + ScratchPad.recorded.should.eql?([-5.0, -3.0, -1.0, 1.0, 3.0]) ScratchPad.record [] (-5.0...).step(2) { |x| break if x > 3.5; ScratchPad << x } - ScratchPad.recorded.should eql([-5.0, -3.0, -1.0, 1.0, 3.0]) + ScratchPad.recorded.should.eql?([-5.0, -3.0, -1.0, 1.0, 3.0]) end it "yields Float values incremented by a Float step" do (-1.0..).step(0.5) { |x| break if x > 0.6; ScratchPad << x } - ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5]) + ScratchPad.recorded.should.eql?([-1.0, -0.5, 0.0, 0.5]) ScratchPad.record [] (-1.0...).step(0.5) { |x| break if x > 0.6; ScratchPad << x } - ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5]) + ScratchPad.recorded.should.eql?([-1.0, -0.5, 0.0, 0.5]) end it "computes each value independently to avoid accumulating floating-point errors" do result = [] (0.0..).step(0.1) { |x| result << x; break if result.size == 20 } expected = 20.times.map { |i| i * 0.1 + 0.0 } - result.should eql(expected) + result.should.eql?(expected) end it "handles infinite values at the start" do (-Float::INFINITY..).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 } - ScratchPad.recorded.should eql([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY]) + ScratchPad.recorded.should.eql?([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY]) ScratchPad.record [] (-Float::INFINITY...).step(2) { |x| ScratchPad << x; break if ScratchPad.recorded.size == 3 } - ScratchPad.recorded.should eql([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY]) + ScratchPad.recorded.should.eql?([-Float::INFINITY, -Float::INFINITY, -Float::INFINITY]) end end @@ -523,8 +523,8 @@ end it "raises a TypeError when passed a Float step" do - -> { ('A'..).step(2.0) { } }.should raise_error(TypeError) - -> { ('A'...).step(2.0) { } }.should raise_error(TypeError) + -> { ('A'..).step(2.0) { } }.should.raise(TypeError) + -> { ('A'...).step(2.0) { } }.should.raise(TypeError) end ruby_version_is "3.4" do @@ -538,8 +538,8 @@ end it "raises a TypeError when passed an incompatible type step" do - -> { ('A'..).step([]) { } }.should raise_error(TypeError) - -> { ('A'...).step([]) { } }.should raise_error(TypeError) + -> { ('A'..).step([]) { } }.should.raise(TypeError) + -> { ('A'...).step([]) { } }.should.raise(TypeError) end end end @@ -547,7 +547,7 @@ describe "when no block is given" do it "raises an ArgumentError if step is 0" do - -> { (-1..1).step(0) }.should raise_error(ArgumentError) + -> { (-1..1).step(0) }.should.raise(ArgumentError) end describe "returned Enumerator" do @@ -555,20 +555,20 @@ ruby_version_is ""..."3.4" do it "raises a TypeError if step does not respond to #to_int" do obj = mock("Range#step non-integer") - -> { (1..2).step(obj) }.should raise_error(TypeError) + -> { (1..2).step(obj) }.should.raise(TypeError) end it "raises a TypeError if #to_int does not return an Integer" do obj = mock("Range#step non-integer") obj.should_receive(:to_int).and_return("1") - -> { (1..2).step(obj) }.should raise_error(TypeError) + -> { (1..2).step(obj) }.should.raise(TypeError) end end ruby_version_is "3.4" do it "does not raise if step is incompatible" do obj = mock("Range#step non-integer") - -> { (1..2).step(obj) }.should_not raise_error + -> { (1..2).step(obj) }.should_not.raise end end @@ -621,7 +621,7 @@ obj = mock("Range#step non-comparable") obj.should_receive(:<=>).with(obj).and_return(1) enum = (obj..obj).step - -> { enum.size }.should_not raise_error + -> { enum.size }.should_not.raise enum.size.should == nil end end @@ -636,7 +636,7 @@ obj = mock("Range#step non-comparable") obj.should_receive(:<=>).with(obj).and_return(1) enum = (obj..obj).step(obj) - -> { enum.size }.should_not raise_error + -> { enum.size }.should_not.raise enum.size.should == nil end end @@ -689,7 +689,7 @@ ruby_version_is "3.4" do it "raises an ArgumentError" do - -> { Range.new(nil, nil).step(1) }.should raise_error(ArgumentError, + -> { Range.new(nil, nil).step(1) }.should.raise(ArgumentError, "#step for non-numeric beginless ranges is meaningless") end end @@ -698,7 +698,7 @@ context "when range is beginless and finite" do ruby_version_is "3.4" do it "raises an ArgumentError if step is non-numeric" do - -> { (..10).step("a") }.should raise_error(ArgumentError, + -> { (..10).step("a") }.should.raise(ArgumentError, "#step for non-numeric beginless ranges is meaningless") end end diff --git a/spec/ruby/core/range/to_a_spec.rb b/spec/ruby/core/range/to_a_spec.rb index b1d3de32dba503..6221ae5f71c3a4 100644 --- a/spec/ruby/core/range/to_a_spec.rb +++ b/spec/ruby/core/range/to_a_spec.rb @@ -6,7 +6,7 @@ ('A'..'D').to_a.should == ['A','B','C','D'] ('A'...'D').to_a.should == ['A','B','C'] (0xfffd...0xffff).to_a.should == [0xfffd,0xfffe] - -> { (0.5..2.4).to_a }.should raise_error(TypeError) + -> { (0.5..2.4).to_a }.should.raise(TypeError) end it "returns empty array for descending-ordered" do @@ -30,10 +30,10 @@ end it "throws an exception for endless ranges" do - -> { eval("(1..)").to_a }.should raise_error(RangeError) + -> { eval("(1..)").to_a }.should.raise(RangeError) end it "throws an exception for beginless ranges" do - -> { (..1).to_a }.should raise_error(TypeError) + -> { (..1).to_a }.should.raise(TypeError) end end diff --git a/spec/ruby/core/range/to_set_spec.rb b/spec/ruby/core/range/to_set_spec.rb index 14e0ce1e31eac1..ac81d2cc4b9876 100644 --- a/spec/ruby/core/range/to_set_spec.rb +++ b/spec/ruby/core/range/to_set_spec.rb @@ -14,13 +14,13 @@ it "raises a TypeError for a beginningless range" do -> { (..0).to_set - }.should raise_error(TypeError, "can't iterate from NilClass") + }.should.raise(TypeError, "can't iterate from NilClass") end ruby_version_is "4.0" do it "raises a RangeError if the range is endless" do - -> { (1..).to_set }.should raise_error(RangeError, "cannot convert endless range to a set") - -> { (1...).to_set }.should raise_error(RangeError, "cannot convert endless range to a set") + -> { (1..).to_set }.should.raise(RangeError, "cannot convert endless range to a set") + -> { (1...).to_set }.should.raise(RangeError, "cannot convert endless range to a set") end end @@ -28,7 +28,7 @@ ruby_version_is ""..."4.0" do it "instantiates an object of provided as the first argument set class" do set = (1..3).to_set(EnumerableSpecs::SetSubclass) - set.should be_kind_of(EnumerableSpecs::SetSubclass) + set.should.is_a?(EnumerableSpecs::SetSubclass) set.to_a.sort.should == [1, 2, 3] end end @@ -37,7 +37,7 @@ it "instantiates an object of provided as the first argument set class and warns" do -> { set = (1..3).to_set(EnumerableSpecs::SetSubclass) - set.should be_kind_of(EnumerableSpecs::SetSubclass) + set.should.is_a?(EnumerableSpecs::SetSubclass) set.to_a.sort.should == [1, 2, 3] }.should complain(/warning: passing arguments to Enumerable#to_set is deprecated/) end @@ -47,7 +47,7 @@ it "does not accept any positional argument" do -> { (1..3).to_set(EnumerableSpecs::SetSubclass) - }.should raise_error(ArgumentError, "wrong number of arguments (given 1, expected 0)") + }.should.raise(ArgumentError, "wrong number of arguments (given 1, expected 0)") end end end diff --git a/spec/ruby/core/rational/ceil_spec.rb b/spec/ruby/core/rational/ceil_spec.rb index 0c0327448f35c6..0464eab101284b 100644 --- a/spec/ruby/core/rational/ceil_spec.rb +++ b/spec/ruby/core/rational/ceil_spec.rb @@ -12,37 +12,37 @@ describe "with no arguments (precision = 0)" do it "returns the Integer value rounded toward positive infinity" do - @rational.ceil.should eql 315 + @rational.ceil.should.eql? 315 - Rational(1, 2).ceil.should eql 1 - Rational(-1, 2).ceil.should eql 0 - Rational(1, 1).ceil.should eql 1 + Rational(1, 2).ceil.should.eql? 1 + Rational(-1, 2).ceil.should.eql? 0 + Rational(1, 1).ceil.should.eql? 1 end end describe "with a precision < 0" do it "moves the rounding point n decimal places left, returning an Integer" do - @rational.ceil(-3).should eql 1000 - @rational.ceil(-2).should eql 400 - @rational.ceil(-1).should eql 320 - - Rational(100, 2).ceil(-1).should eql 50 - Rational(100, 2).ceil(-2).should eql 100 - Rational(-100, 2).ceil(-1).should eql(-50) - Rational(-100, 2).ceil(-2).should eql(0) + @rational.ceil(-3).should.eql? 1000 + @rational.ceil(-2).should.eql? 400 + @rational.ceil(-1).should.eql? 320 + + Rational(100, 2).ceil(-1).should.eql? 50 + Rational(100, 2).ceil(-2).should.eql? 100 + Rational(-100, 2).ceil(-1).should.eql?(-50) + Rational(-100, 2).ceil(-2).should.eql?(0) end end describe "with precision > 0" do it "moves the rounding point n decimal places right, returning a Rational" do - @rational.ceil(1).should eql Rational(3143, 10) - @rational.ceil(2).should eql Rational(31429, 100) - @rational.ceil(3).should eql Rational(157143, 500) - - Rational(100, 2).ceil(1).should eql Rational(50, 1) - Rational(100, 2).ceil(2).should eql Rational(50, 1) - Rational(-100, 2).ceil(1).should eql Rational(-50, 1) - Rational(-100, 2).ceil(2).should eql Rational(-50, 1) + @rational.ceil(1).should.eql? Rational(3143, 10) + @rational.ceil(2).should.eql? Rational(31429, 100) + @rational.ceil(3).should.eql? Rational(157143, 500) + + Rational(100, 2).ceil(1).should.eql? Rational(50, 1) + Rational(100, 2).ceil(2).should.eql? Rational(50, 1) + Rational(-100, 2).ceil(1).should.eql? Rational(-50, 1) + Rational(-100, 2).ceil(2).should.eql? Rational(-50, 1) end end end diff --git a/spec/ruby/core/rational/comparison_spec.rb b/spec/ruby/core/rational/comparison_spec.rb index c9db60d5c78258..482e90498967ce 100644 --- a/spec/ruby/core/rational/comparison_spec.rb +++ b/spec/ruby/core/rational/comparison_spec.rb @@ -3,54 +3,54 @@ describe "Rational#<=> when passed a Rational object" do it "returns 1 when self is greater than the passed argument" do - (Rational(4, 4) <=> Rational(3, 4)).should equal(1) - (Rational(-3, 4) <=> Rational(-4, 4)).should equal(1) + (Rational(4, 4) <=> Rational(3, 4)).should.equal?(1) + (Rational(-3, 4) <=> Rational(-4, 4)).should.equal?(1) end it "returns 0 when self is equal to the passed argument" do - (Rational(4, 4) <=> Rational(4, 4)).should equal(0) - (Rational(-3, 4) <=> Rational(-3, 4)).should equal(0) + (Rational(4, 4) <=> Rational(4, 4)).should.equal?(0) + (Rational(-3, 4) <=> Rational(-3, 4)).should.equal?(0) end it "returns -1 when self is less than the passed argument" do - (Rational(3, 4) <=> Rational(4, 4)).should equal(-1) - (Rational(-4, 4) <=> Rational(-3, 4)).should equal(-1) + (Rational(3, 4) <=> Rational(4, 4)).should.equal?(-1) + (Rational(-4, 4) <=> Rational(-3, 4)).should.equal?(-1) end end describe "Rational#<=> when passed an Integer object" do it "returns 1 when self is greater than the passed argument" do - (Rational(4, 4) <=> 0).should equal(1) - (Rational(4, 4) <=> -10).should equal(1) - (Rational(-3, 4) <=> -1).should equal(1) + (Rational(4, 4) <=> 0).should.equal?(1) + (Rational(4, 4) <=> -10).should.equal?(1) + (Rational(-3, 4) <=> -1).should.equal?(1) end it "returns 0 when self is equal to the passed argument" do - (Rational(4, 4) <=> 1).should equal(0) - (Rational(-8, 4) <=> -2).should equal(0) + (Rational(4, 4) <=> 1).should.equal?(0) + (Rational(-8, 4) <=> -2).should.equal?(0) end it "returns -1 when self is less than the passed argument" do - (Rational(3, 4) <=> 1).should equal(-1) - (Rational(-4, 4) <=> 0).should equal(-1) + (Rational(3, 4) <=> 1).should.equal?(-1) + (Rational(-4, 4) <=> 0).should.equal?(-1) end end describe "Rational#<=> when passed a Float object" do it "returns 1 when self is greater than the passed argument" do - (Rational(4, 4) <=> 0.5).should equal(1) - (Rational(4, 4) <=> -1.5).should equal(1) - (Rational(-3, 4) <=> -0.8).should equal(1) + (Rational(4, 4) <=> 0.5).should.equal?(1) + (Rational(4, 4) <=> -1.5).should.equal?(1) + (Rational(-3, 4) <=> -0.8).should.equal?(1) end it "returns 0 when self is equal to the passed argument" do - (Rational(4, 4) <=> 1.0).should equal(0) - (Rational(-6, 4) <=> -1.5).should equal(0) + (Rational(4, 4) <=> 1.0).should.equal?(0) + (Rational(-6, 4) <=> -1.5).should.equal?(0) end it "returns -1 when self is less than the passed argument" do - (Rational(3, 4) <=> 1.2).should equal(-1) - (Rational(-4, 4) <=> 0.5).should equal(-1) + (Rational(3, 4) <=> 1.2).should.equal?(-1) + (Rational(-4, 4) <=> 0.5).should.equal?(-1) end end @@ -82,12 +82,12 @@ b = mock("numeric with failed #coerce") b.should_receive(:coerce).and_raise(RationalSpecs::CoerceError) - -> { Rational(3, 4) <=> b }.should raise_error(RationalSpecs::CoerceError) + -> { Rational(3, 4) <=> b }.should.raise(RationalSpecs::CoerceError) end end describe "Rational#<=> when passed a non-Numeric Object that doesn't respond to #coerce" do it "returns nil" do - (Rational <=> mock("Object")).should be_nil + (Rational <=> mock("Object")).should == nil end end diff --git a/spec/ruby/core/rational/denominator_spec.rb b/spec/ruby/core/rational/denominator_spec.rb index 468724489398b2..ba6e936d601dd9 100644 --- a/spec/ruby/core/rational/denominator_spec.rb +++ b/spec/ruby/core/rational/denominator_spec.rb @@ -2,8 +2,8 @@ describe "Rational#denominator" do it "returns the denominator" do - Rational(3, 4).denominator.should equal(4) - Rational(3, -4).denominator.should equal(4) + Rational(3, 4).denominator.should.equal?(4) + Rational(3, -4).denominator.should.equal?(4) Rational(1, bignum_value).denominator.should == bignum_value end diff --git a/spec/ruby/core/rational/div_spec.rb b/spec/ruby/core/rational/div_spec.rb index d3adb9b53676ef..a67966354346ab 100644 --- a/spec/ruby/core/rational/div_spec.rb +++ b/spec/ruby/core/rational/div_spec.rb @@ -2,16 +2,16 @@ describe "Rational#div" do it "returns an Integer" do - Rational(229, 21).div(82).should be_kind_of(Integer) + Rational(229, 21).div(82).should.is_a?(Integer) end it "raises an ArgumentError if passed more than one argument" do - -> { Rational(3, 4).div(2,3) }.should raise_error(ArgumentError) + -> { Rational(3, 4).div(2,3) }.should.raise(ArgumentError) end # See http://redmine.ruby-lang.org/issues/show/1648 it "raises a TypeError if passed a non-numeric argument" do - -> { Rational(3, 4).div([]) }.should raise_error(TypeError) + -> { Rational(3, 4).div([]) }.should.raise(TypeError) end end @@ -22,11 +22,11 @@ end it "raises a ZeroDivisionError when the argument has a numerator of 0" do - -> { Rational(3, 4).div(Rational(0, 3)) }.should raise_error(ZeroDivisionError) + -> { Rational(3, 4).div(Rational(0, 3)) }.should.raise(ZeroDivisionError) end it "raises a ZeroDivisionError when the argument has a numerator of 0.0" do - -> { Rational(3, 4).div(Rational(0.0, 3)) }.should raise_error(ZeroDivisionError) + -> { Rational(3, 4).div(Rational(0.0, 3)) }.should.raise(ZeroDivisionError) end end @@ -37,7 +37,7 @@ end it "raises a ZeroDivisionError when the argument is 0" do - -> { Rational(3, 4).div(0) }.should raise_error(ZeroDivisionError) + -> { Rational(3, 4).div(0) }.should.raise(ZeroDivisionError) end end @@ -49,6 +49,6 @@ end it "raises a ZeroDivisionError when the argument is 0.0" do - -> { Rational(3, 4).div(0.0) }.should raise_error(ZeroDivisionError) + -> { Rational(3, 4).div(0.0) }.should.raise(ZeroDivisionError) end end diff --git a/spec/ruby/core/rational/divide_spec.rb b/spec/ruby/core/rational/divide_spec.rb index 8f5ca1fdec7a93..c45d1fca2f5f61 100644 --- a/spec/ruby/core/rational/divide_spec.rb +++ b/spec/ruby/core/rational/divide_spec.rb @@ -29,46 +29,46 @@ describe "Rational#/ when passed an Integer" do it "returns self divided by other as a Rational" do - (Rational(3, 4) / 2).should eql(Rational(3, 8)) - (Rational(2, 4) / 2).should eql(Rational(1, 4)) - (Rational(6, 7) / -2).should eql(Rational(-3, 7)) + (Rational(3, 4) / 2).should.eql?(Rational(3, 8)) + (Rational(2, 4) / 2).should.eql?(Rational(1, 4)) + (Rational(6, 7) / -2).should.eql?(Rational(-3, 7)) end it "raises a ZeroDivisionError when passed 0" do - -> { Rational(3, 4) / 0 }.should raise_error(ZeroDivisionError) + -> { Rational(3, 4) / 0 }.should.raise(ZeroDivisionError) end end describe "Rational#/ when passed a Rational" do it "returns self divided by other as a Rational" do - (Rational(3, 4) / Rational(3, 4)).should eql(Rational(1, 1)) - (Rational(2, 4) / Rational(1, 4)).should eql(Rational(2, 1)) + (Rational(3, 4) / Rational(3, 4)).should.eql?(Rational(1, 1)) + (Rational(2, 4) / Rational(1, 4)).should.eql?(Rational(2, 1)) (Rational(2, 4) / 2).should == Rational(1, 4) (Rational(6, 7) / -2).should == Rational(-3, 7) end it "raises a ZeroDivisionError when passed a Rational with a numerator of 0" do - -> { Rational(3, 4) / Rational(0, 1) }.should raise_error(ZeroDivisionError) + -> { Rational(3, 4) / Rational(0, 1) }.should.raise(ZeroDivisionError) end end describe "Rational#/ when passed a Float" do it "returns self divided by other as a Float" do - (Rational(3, 4) / 0.75).should eql(1.0) - (Rational(3, 4) / 0.25).should eql(3.0) - (Rational(3, 4) / 0.3).should eql(2.5) + (Rational(3, 4) / 0.75).should.eql?(1.0) + (Rational(3, 4) / 0.25).should.eql?(3.0) + (Rational(3, 4) / 0.3).should.eql?(2.5) - (Rational(-3, 4) / 0.3).should eql(-2.5) - (Rational(3, -4) / 0.3).should eql(-2.5) - (Rational(3, 4) / -0.3).should eql(-2.5) + (Rational(-3, 4) / 0.3).should.eql?(-2.5) + (Rational(3, -4) / 0.3).should.eql?(-2.5) + (Rational(3, 4) / -0.3).should.eql?(-2.5) end it "returns infinity when passed 0" do - (Rational(3, 4) / 0.0).infinite?.should eql(1) - (Rational(-3, -4) / 0.0).infinite?.should eql(1) + (Rational(3, 4) / 0.0).infinite?.should.eql?(1) + (Rational(-3, -4) / 0.0).infinite?.should.eql?(1) - (Rational(-3, 4) / 0.0).infinite?.should eql(-1) - (Rational(3, -4) / 0.0).infinite?.should eql(-1) + (Rational(-3, 4) / 0.0).infinite?.should.eql?(-1) + (Rational(3, -4) / 0.0).infinite?.should.eql?(-1) end end diff --git a/spec/ruby/core/rational/divmod_spec.rb b/spec/ruby/core/rational/divmod_spec.rb index f0555294a3a52f..68f8ecfd2de517 100644 --- a/spec/ruby/core/rational/divmod_spec.rb +++ b/spec/ruby/core/rational/divmod_spec.rb @@ -2,41 +2,41 @@ describe "Rational#divmod when passed a Rational" do it "returns the quotient as Integer and the remainder as Rational" do - Rational(7, 4).divmod(Rational(1, 2)).should eql([3, Rational(1, 4)]) - Rational(7, 4).divmod(Rational(-1, 2)).should eql([-4, Rational(-1, 4)]) - Rational(0, 4).divmod(Rational(4, 3)).should eql([0, Rational(0, 1)]) + Rational(7, 4).divmod(Rational(1, 2)).should.eql?([3, Rational(1, 4)]) + Rational(7, 4).divmod(Rational(-1, 2)).should.eql?([-4, Rational(-1, 4)]) + Rational(0, 4).divmod(Rational(4, 3)).should.eql?([0, Rational(0, 1)]) - Rational(bignum_value, 4).divmod(Rational(4, 3)).should eql([3458764513820540928, Rational(0, 1)]) + Rational(bignum_value, 4).divmod(Rational(4, 3)).should.eql?([3458764513820540928, Rational(0, 1)]) end it "raises a ZeroDivisionError when passed a Rational with a numerator of 0" do - -> { Rational(7, 4).divmod(Rational(0, 3)) }.should raise_error(ZeroDivisionError) + -> { Rational(7, 4).divmod(Rational(0, 3)) }.should.raise(ZeroDivisionError) end end describe "Rational#divmod when passed an Integer" do it "returns the quotient as Integer and the remainder as Rational" do - Rational(7, 4).divmod(2).should eql([0, Rational(7, 4)]) - Rational(7, 4).divmod(-2).should eql([-1, Rational(-1, 4)]) + Rational(7, 4).divmod(2).should.eql?([0, Rational(7, 4)]) + Rational(7, 4).divmod(-2).should.eql?([-1, Rational(-1, 4)]) - Rational(bignum_value, 4).divmod(3).should eql([1537228672809129301, Rational(1, 1)]) + Rational(bignum_value, 4).divmod(3).should.eql?([1537228672809129301, Rational(1, 1)]) end it "raises a ZeroDivisionError when passed 0" do - -> { Rational(7, 4).divmod(0) }.should raise_error(ZeroDivisionError) + -> { Rational(7, 4).divmod(0) }.should.raise(ZeroDivisionError) end end describe "Rational#divmod when passed a Float" do it "returns the quotient as Integer and the remainder as Float" do - Rational(7, 4).divmod(0.5).should eql([3, 0.25]) + Rational(7, 4).divmod(0.5).should.eql?([3, 0.25]) end it "returns the quotient as Integer and the remainder as Float" do - Rational(7, 4).divmod(-0.5).should eql([-4, -0.25]) + Rational(7, 4).divmod(-0.5).should.eql?([-4, -0.25]) end it "raises a ZeroDivisionError when passed 0" do - -> { Rational(7, 4).divmod(0.0) }.should raise_error(ZeroDivisionError) + -> { Rational(7, 4).divmod(0.0) }.should.raise(ZeroDivisionError) end end diff --git a/spec/ruby/core/rational/equal_value_spec.rb b/spec/ruby/core/rational/equal_value_spec.rb index ba40d29c3b1350..1dd077ea41c1ee 100644 --- a/spec/ruby/core/rational/equal_value_spec.rb +++ b/spec/ruby/core/rational/equal_value_spec.rb @@ -5,35 +5,35 @@ obj = mock("Object") obj.should_receive(:==).and_return(:result) - (Rational(3, 4) == obj).should_not be_false + (Rational(3, 4) == obj).should_not == false end end describe "Rational#== when passed a Rational" do it "returns true if self has the same numerator and denominator as the passed argument" do - (Rational(3, 4) == Rational(3, 4)).should be_true - (Rational(-3, -4) == Rational(3, 4)).should be_true - (Rational(-4, 5) == Rational(4, -5)).should be_true + (Rational(3, 4) == Rational(3, 4)).should == true + (Rational(-3, -4) == Rational(3, 4)).should == true + (Rational(-4, 5) == Rational(4, -5)).should == true - (Rational(bignum_value, 3) == Rational(bignum_value, 3)).should be_true - (Rational(-bignum_value, 3) == Rational(bignum_value, -3)).should be_true + (Rational(bignum_value, 3) == Rational(bignum_value, 3)).should == true + (Rational(-bignum_value, 3) == Rational(bignum_value, -3)).should == true end end describe "Rational#== when passed a Float" do it "converts self to a Float and compares it with the passed argument" do - (Rational(3, 4) == 0.75).should be_true - (Rational(4, 2) == 2.0).should be_true - (Rational(-4, 2) == -2.0).should be_true - (Rational(4, -2) == -2.0).should be_true + (Rational(3, 4) == 0.75).should == true + (Rational(4, 2) == 2.0).should == true + (Rational(-4, 2) == -2.0).should == true + (Rational(4, -2) == -2.0).should == true end end describe "Rational#== when passed an Integer" do it "returns true if self has the passed argument as numerator and a denominator of 1" do # Rational(x, y) reduces x and y automatically - (Rational(4, 2) == 2).should be_true - (Rational(-4, 2) == -2).should be_true - (Rational(4, -2) == -2).should be_true + (Rational(4, 2) == 2).should == true + (Rational(-4, 2) == -2).should == true + (Rational(4, -2) == -2).should == true end end diff --git a/spec/ruby/core/rational/exponent_spec.rb b/spec/ruby/core/rational/exponent_spec.rb index 1f8a03740cc087..88b4a4379666ea 100644 --- a/spec/ruby/core/rational/exponent_spec.rb +++ b/spec/ruby/core/rational/exponent_spec.rb @@ -5,20 +5,20 @@ # Guard against the Mathn library guard -> { !defined?(Math.rsqrt) } do it "returns Rational(1) if the exponent is Rational(0)" do - (Rational(0) ** Rational(0)).should eql(Rational(1)) - (Rational(1) ** Rational(0)).should eql(Rational(1)) - (Rational(3, 4) ** Rational(0)).should eql(Rational(1)) - (Rational(-1) ** Rational(0)).should eql(Rational(1)) - (Rational(-3, 4) ** Rational(0)).should eql(Rational(1)) - (Rational(bignum_value) ** Rational(0)).should eql(Rational(1)) - (Rational(-bignum_value) ** Rational(0)).should eql(Rational(1)) + (Rational(0) ** Rational(0)).should.eql?(Rational(1)) + (Rational(1) ** Rational(0)).should.eql?(Rational(1)) + (Rational(3, 4) ** Rational(0)).should.eql?(Rational(1)) + (Rational(-1) ** Rational(0)).should.eql?(Rational(1)) + (Rational(-3, 4) ** Rational(0)).should.eql?(Rational(1)) + (Rational(bignum_value) ** Rational(0)).should.eql?(Rational(1)) + (Rational(-bignum_value) ** Rational(0)).should.eql?(Rational(1)) end it "returns self raised to the argument as a Rational if the exponent's denominator is 1" do - (Rational(3, 4) ** Rational(1, 1)).should eql(Rational(3, 4)) - (Rational(3, 4) ** Rational(2, 1)).should eql(Rational(9, 16)) - (Rational(3, 4) ** Rational(-1, 1)).should eql(Rational(4, 3)) - (Rational(3, 4) ** Rational(-2, 1)).should eql(Rational(16, 9)) + (Rational(3, 4) ** Rational(1, 1)).should.eql?(Rational(3, 4)) + (Rational(3, 4) ** Rational(2, 1)).should.eql?(Rational(9, 16)) + (Rational(3, 4) ** Rational(-1, 1)).should.eql?(Rational(4, 3)) + (Rational(3, 4) ** Rational(-2, 1)).should.eql?(Rational(16, 9)) end it "returns self raised to the argument as a Float if the exponent's denominator is not 1" do @@ -49,12 +49,12 @@ # Guard against the Mathn library guard -> { !defined?(Math.rsqrt) } do it "returns Rational(1, 1) when the passed argument is 0" do - (Rational(3, 4) ** 0).should eql(Rational(1, 1)) - (Rational(-3, 4) ** 0).should eql(Rational(1, 1)) - (Rational(3, -4) ** 0).should eql(Rational(1, 1)) + (Rational(3, 4) ** 0).should.eql?(Rational(1, 1)) + (Rational(-3, 4) ** 0).should.eql?(Rational(1, 1)) + (Rational(3, -4) ** 0).should.eql?(Rational(1, 1)) - (Rational(bignum_value, 4) ** 0).should eql(Rational(1, 1)) - (Rational(3, -bignum_value) ** 0).should eql(Rational(1, 1)) + (Rational(bignum_value, 4) ** 0).should.eql?(Rational(1, 1)) + (Rational(3, -bignum_value) ** 0).should.eql?(Rational(1, 1)) end end end @@ -62,26 +62,26 @@ describe "when passed Bignum" do # #5713 it "returns Rational(0) when self is Rational(0) and the exponent is positive" do - (Rational(0) ** bignum_value).should eql(Rational(0)) + (Rational(0) ** bignum_value).should.eql?(Rational(0)) end it "raises ZeroDivisionError when self is Rational(0) and the exponent is negative" do - -> { Rational(0) ** -bignum_value }.should raise_error(ZeroDivisionError) + -> { Rational(0) ** -bignum_value }.should.raise(ZeroDivisionError) end it "returns Rational(1) when self is Rational(1)" do - (Rational(1) ** bignum_value).should eql(Rational(1)) - (Rational(1) ** -bignum_value).should eql(Rational(1)) + (Rational(1) ** bignum_value).should.eql?(Rational(1)) + (Rational(1) ** -bignum_value).should.eql?(Rational(1)) end it "returns Rational(1) when self is Rational(-1) and the exponent is positive and even" do - (Rational(-1) ** bignum_value(0)).should eql(Rational(1)) - (Rational(-1) ** bignum_value(2)).should eql(Rational(1)) + (Rational(-1) ** bignum_value(0)).should.eql?(Rational(1)) + (Rational(-1) ** bignum_value(2)).should.eql?(Rational(1)) end it "returns Rational(-1) when self is Rational(-1) and the exponent is positive and odd" do - (Rational(-1) ** bignum_value(1)).should eql(Rational(-1)) - (Rational(-1) ** bignum_value(3)).should eql(Rational(-1)) + (Rational(-1) ** bignum_value(1)).should.eql?(Rational(-1)) + (Rational(-1) ** bignum_value(3)).should.eql?(Rational(-1)) end ruby_version_is ""..."3.4" do @@ -96,10 +96,10 @@ it "returns 0.0 when self is > 1 and the exponent is negative" do -> { - (Rational(2) ** -bignum_value).should eql(0.0) + (Rational(2) ** -bignum_value).should.eql?(0.0) }.should complain(/warning: in a\*\*b, b may be too big/) -> { - (Rational(fixnum_max) ** -bignum_value).should eql(0.0) + (Rational(fixnum_max) ** -bignum_value).should.eql?(0.0) }.should complain(/warning: in a\*\*b, b may be too big/) end end @@ -108,37 +108,37 @@ it "raises an ArgumentError when self is > 1" do -> { (Rational(2) ** bignum_value) - }.should raise_error(ArgumentError, "exponent is too large") + }.should.raise(ArgumentError, "exponent is too large") -> { (Rational(fixnum_max) ** bignum_value) - }.should raise_error(ArgumentError, "exponent is too large") + }.should.raise(ArgumentError, "exponent is too large") end it "raises an ArgumentError when self is > 1 and the exponent is negative" do -> { (Rational(2) ** -bignum_value) - }.should raise_error(ArgumentError, "exponent is too large") + }.should.raise(ArgumentError, "exponent is too large") -> { (Rational(fixnum_max) ** -bignum_value) - }.should raise_error(ArgumentError, "exponent is too large") + }.should.raise(ArgumentError, "exponent is too large") end it "raises an ArgumentError when self is < -1" do -> { (Rational(-2) ** bignum_value) - }.should raise_error(ArgumentError, "exponent is too large") + }.should.raise(ArgumentError, "exponent is too large") -> { (Rational(fixnum_min) ** bignum_value) - }.should raise_error(ArgumentError, "exponent is too large") + }.should.raise(ArgumentError, "exponent is too large") end it "raises an ArgumentError when self is < -1 and the exponent is negative" do -> { (Rational(-2) ** -bignum_value) - }.should raise_error(ArgumentError, "exponent is too large") + }.should.raise(ArgumentError, "exponent is too large") -> { (Rational(fixnum_min) ** -bignum_value) - }.should raise_error(ArgumentError, "exponent is too large") + }.should.raise(ArgumentError, "exponent is too large") end end @@ -159,10 +159,10 @@ it "returns 0.0 when self is < -1 and the exponent is negative" do -> { - (Rational(-2) ** -bignum_value).should eql(0.0) + (Rational(-2) ** -bignum_value).should.eql?(0.0) }.should complain(/warning: in a\*\*b, b may be too big/) -> { - (Rational(fixnum_min) ** -bignum_value).should eql(0.0) + (Rational(fixnum_min) ** -bignum_value).should.eql?(0.0) }.should complain(/warning: in a\*\*b, b may be too big/) end end @@ -171,7 +171,7 @@ describe "when passed Float" do it "returns self converted to Float and raised to the passed argument" do - (Rational(3, 1) ** 3.0).should eql(27.0) + (Rational(3, 1) ** 3.0).should.eql?(27.0) (Rational(3, 1) ** 1.5).should be_close(5.19615242270663, TOLERANCE) (Rational(3, 1) ** -1.5).should be_close(0.192450089729875, TOLERANCE) end @@ -213,19 +213,19 @@ it "raises ZeroDivisionError for Rational(0, 1) passed a negative Integer" do [-1, -4, -9999].each do |exponent| - -> { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0") + -> { Rational(0, 1) ** exponent }.should.raise(ZeroDivisionError, "divided by 0") end end it "raises ZeroDivisionError for Rational(0, 1) passed a negative Rational with denominator 1" do [Rational(-1, 1), Rational(-3, 1)].each do |exponent| - -> { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0") + -> { Rational(0, 1) ** exponent }.should.raise(ZeroDivisionError, "divided by 0") end end # #7513 it "raises ZeroDivisionError for Rational(0, 1) passed a negative Rational" do - -> { Rational(0, 1) ** Rational(-3, 2) }.should raise_error(ZeroDivisionError, "divided by 0") + -> { Rational(0, 1) ** Rational(-3, 2) }.should.raise(ZeroDivisionError, "divided by 0") end it "returns Infinity for Rational(0, 1) passed a negative Float" do diff --git a/spec/ruby/core/rational/floor_spec.rb b/spec/ruby/core/rational/floor_spec.rb index 5108e363f7a67c..6d4cee79a9f5ee 100644 --- a/spec/ruby/core/rational/floor_spec.rb +++ b/spec/ruby/core/rational/floor_spec.rb @@ -13,37 +13,37 @@ describe "with no arguments (precision = 0)" do it "returns the Integer value rounded toward negative infinity" do - @rational.floor.should eql 314 + @rational.floor.should.eql? 314 - Rational(1, 2).floor.should eql 0 - Rational(-1, 2).floor.should eql(-1) - Rational(1, 1).floor.should eql 1 + Rational(1, 2).floor.should.eql? 0 + Rational(-1, 2).floor.should.eql?(-1) + Rational(1, 1).floor.should.eql? 1 end end describe "with a precision < 0" do it "moves the rounding point n decimal places left, returning an Integer" do - @rational.floor(-3).should eql 0 - @rational.floor(-2).should eql 300 - @rational.floor(-1).should eql 310 - - Rational(100, 2).floor(-1).should eql 50 - Rational(100, 2).floor(-2).should eql 0 - Rational(-100, 2).floor(-1).should eql(-50) - Rational(-100, 2).floor(-2).should eql(-100) + @rational.floor(-3).should.eql? 0 + @rational.floor(-2).should.eql? 300 + @rational.floor(-1).should.eql? 310 + + Rational(100, 2).floor(-1).should.eql? 50 + Rational(100, 2).floor(-2).should.eql? 0 + Rational(-100, 2).floor(-1).should.eql?(-50) + Rational(-100, 2).floor(-2).should.eql?(-100) end end describe "with a precision > 0" do it "moves the rounding point n decimal places right, returning a Rational" do - @rational.floor(1).should eql Rational(1571, 5) - @rational.floor(2).should eql Rational(7857, 25) - @rational.floor(3).should eql Rational(62857, 200) - - Rational(100, 2).floor(1).should eql Rational(50, 1) - Rational(100, 2).floor(2).should eql Rational(50, 1) - Rational(-100, 2).floor(1).should eql Rational(-50, 1) - Rational(-100, 2).floor(2).should eql Rational(-50, 1) + @rational.floor(1).should.eql? Rational(1571, 5) + @rational.floor(2).should.eql? Rational(7857, 25) + @rational.floor(3).should.eql? Rational(62857, 200) + + Rational(100, 2).floor(1).should.eql? Rational(50, 1) + Rational(100, 2).floor(2).should.eql? Rational(50, 1) + Rational(-100, 2).floor(1).should.eql? Rational(-50, 1) + Rational(-100, 2).floor(2).should.eql? Rational(-50, 1) end end end diff --git a/spec/ruby/core/rational/integer_spec.rb b/spec/ruby/core/rational/integer_spec.rb index be7476a9ddf78d..cd7fa97fcf4e1f 100644 --- a/spec/ruby/core/rational/integer_spec.rb +++ b/spec/ruby/core/rational/integer_spec.rb @@ -3,11 +3,11 @@ # Guard against the Mathn library guard -> { !defined?(Math.rsqrt) } do it "returns false for a rational with a numerator and no denominator" do - Rational(20).integer?.should be_false + Rational(20).integer?.should == false end end it "returns false for a rational with a numerator and a denominator" do - Rational(20,3).integer?.should be_false + Rational(20,3).integer?.should == false end end diff --git a/spec/ruby/core/rational/marshal_dump_spec.rb b/spec/ruby/core/rational/marshal_dump_spec.rb index 17a6107cd5210b..06bf36f166f302 100644 --- a/spec/ruby/core/rational/marshal_dump_spec.rb +++ b/spec/ruby/core/rational/marshal_dump_spec.rb @@ -2,7 +2,7 @@ describe "Rational#marshal_dump" do it "is a private method" do - Rational.should have_private_instance_method(:marshal_dump, false) + Rational.private_instance_methods(false).should.include?(:marshal_dump) end it "dumps numerator and denominator" do diff --git a/spec/ruby/core/rational/minus_spec.rb b/spec/ruby/core/rational/minus_spec.rb index 8aee85f9dd6d3e..4e10e118b980f5 100644 --- a/spec/ruby/core/rational/minus_spec.rb +++ b/spec/ruby/core/rational/minus_spec.rb @@ -29,23 +29,23 @@ describe "Rational#- passed a Rational" do it "returns the result of subtracting other from self as a Rational" do - (Rational(3, 4) - Rational(0, 1)).should eql(Rational(3, 4)) - (Rational(3, 4) - Rational(1, 4)).should eql(Rational(1, 2)) + (Rational(3, 4) - Rational(0, 1)).should.eql?(Rational(3, 4)) + (Rational(3, 4) - Rational(1, 4)).should.eql?(Rational(1, 2)) - (Rational(3, 4) - Rational(2, 1)).should eql(Rational(-5, 4)) + (Rational(3, 4) - Rational(2, 1)).should.eql?(Rational(-5, 4)) end end describe "Rational#- passed a Float" do it "returns the result of subtracting other from self as a Float" do - (Rational(3, 4) - 0.2).should eql(0.55) - (Rational(3, 4) - 2.5).should eql(-1.75) + (Rational(3, 4) - 0.2).should.eql?(0.55) + (Rational(3, 4) - 2.5).should.eql?(-1.75) end end describe "Rational#- passed an Integer" do it "returns the result of subtracting other from self as a Rational" do - (Rational(3, 4) - 1).should eql(Rational(-1, 4)) - (Rational(3, 4) - 2).should eql(Rational(-5, 4)) + (Rational(3, 4) - 1).should.eql?(Rational(-1, 4)) + (Rational(3, 4) - 2).should.eql?(Rational(-5, 4)) end end diff --git a/spec/ruby/core/rational/modulo_spec.rb b/spec/ruby/core/rational/modulo_spec.rb index 23ed93e118e601..6241077f68951e 100644 --- a/spec/ruby/core/rational/modulo_spec.rb +++ b/spec/ruby/core/rational/modulo_spec.rb @@ -16,7 +16,7 @@ end it "returns a Float value when the argument is Float" do - (Rational(7, 4) % 1.0).should be_kind_of(Float) + (Rational(7, 4) % 1.0).should.is_a?(Float) (Rational(7, 4) % 1.0).should == 0.75 (Rational(7, 4) % 0.26).should be_close(0.19, 0.0001) end @@ -24,20 +24,20 @@ it "raises ZeroDivisionError on zero denominator" do -> { Rational(3, 5) % Rational(0, 1) - }.should raise_error(ZeroDivisionError) + }.should.raise(ZeroDivisionError) -> { Rational(0, 1) % Rational(0, 1) - }.should raise_error(ZeroDivisionError) + }.should.raise(ZeroDivisionError) -> { Rational(3, 5) % 0 - }.should raise_error(ZeroDivisionError) + }.should.raise(ZeroDivisionError) end it "raises a ZeroDivisionError when the argument is 0.0" do -> { Rational(3, 5) % 0.0 - }.should raise_error(ZeroDivisionError) + }.should.raise(ZeroDivisionError) end end diff --git a/spec/ruby/core/rational/multiply_spec.rb b/spec/ruby/core/rational/multiply_spec.rb index 87fb4de2b449f8..3e059cbc1cca05 100644 --- a/spec/ruby/core/rational/multiply_spec.rb +++ b/spec/ruby/core/rational/multiply_spec.rb @@ -29,37 +29,37 @@ describe "Rational#* passed a Rational" do it "returns self divided by other as a Rational" do - (Rational(3, 4) * Rational(3, 4)).should eql(Rational(9, 16)) - (Rational(2, 4) * Rational(1, 4)).should eql(Rational(1, 8)) + (Rational(3, 4) * Rational(3, 4)).should.eql?(Rational(9, 16)) + (Rational(2, 4) * Rational(1, 4)).should.eql?(Rational(1, 8)) - (Rational(3, 4) * Rational(0, 1)).should eql(Rational(0, 4)) + (Rational(3, 4) * Rational(0, 1)).should.eql?(Rational(0, 4)) end end describe "Rational#* passed a Float" do it "returns self divided by other as a Float" do - (Rational(3, 4) * 0.75).should eql(0.5625) - (Rational(3, 4) * 0.25).should eql(0.1875) + (Rational(3, 4) * 0.75).should.eql?(0.5625) + (Rational(3, 4) * 0.25).should.eql?(0.1875) (Rational(3, 4) * 0.3).should be_close(0.225, TOLERANCE) (Rational(-3, 4) * 0.3).should be_close(-0.225, TOLERANCE) (Rational(3, -4) * 0.3).should be_close(-0.225, TOLERANCE) (Rational(3, 4) * -0.3).should be_close(-0.225, TOLERANCE) - (Rational(3, 4) * 0.0).should eql(0.0) - (Rational(-3, -4) * 0.0).should eql(0.0) + (Rational(3, 4) * 0.0).should.eql?(0.0) + (Rational(-3, -4) * 0.0).should.eql?(0.0) - (Rational(-3, 4) * 0.0).should eql(0.0) - (Rational(3, -4) * 0.0).should eql(0.0) + (Rational(-3, 4) * 0.0).should.eql?(0.0) + (Rational(3, -4) * 0.0).should.eql?(0.0) end end describe "Rational#* passed an Integer" do it "returns self divided by other as a Rational" do - (Rational(3, 4) * 2).should eql(Rational(3, 2)) - (Rational(2, 4) * 2).should eql(Rational(1, 1)) - (Rational(6, 7) * -2).should eql(Rational(-12, 7)) + (Rational(3, 4) * 2).should.eql?(Rational(3, 2)) + (Rational(2, 4) * 2).should.eql?(Rational(1, 1)) + (Rational(6, 7) * -2).should.eql?(Rational(-12, 7)) - (Rational(3, 4) * 0).should eql(Rational(0, 4)) + (Rational(3, 4) * 0).should.eql?(Rational(0, 4)) end end diff --git a/spec/ruby/core/rational/numerator_spec.rb b/spec/ruby/core/rational/numerator_spec.rb index 2b9fe2ff5c154b..631bb4703cd047 100644 --- a/spec/ruby/core/rational/numerator_spec.rb +++ b/spec/ruby/core/rational/numerator_spec.rb @@ -2,8 +2,8 @@ describe "Rational#numerator" do it "returns the numerator" do - Rational(3, 4).numerator.should equal(3) - Rational(3, -4).numerator.should equal(-3) + Rational(3, 4).numerator.should.equal?(3) + Rational(3, -4).numerator.should.equal?(-3) Rational(bignum_value, 1).numerator.should == bignum_value end diff --git a/spec/ruby/core/rational/plus_spec.rb b/spec/ruby/core/rational/plus_spec.rb index 01df5f67192ec7..92f830a1056292 100644 --- a/spec/ruby/core/rational/plus_spec.rb +++ b/spec/ruby/core/rational/plus_spec.rb @@ -29,22 +29,22 @@ describe "Rational#+ with a Rational" do it "returns the result of subtracting other from self as a Rational" do - (Rational(3, 4) + Rational(0, 1)).should eql(Rational(3, 4)) - (Rational(3, 4) + Rational(1, 4)).should eql(Rational(1, 1)) + (Rational(3, 4) + Rational(0, 1)).should.eql?(Rational(3, 4)) + (Rational(3, 4) + Rational(1, 4)).should.eql?(Rational(1, 1)) - (Rational(3, 4) + Rational(2, 1)).should eql(Rational(11, 4)) + (Rational(3, 4) + Rational(2, 1)).should.eql?(Rational(11, 4)) end end describe "Rational#+ with a Float" do it "returns the result of subtracting other from self as a Float" do - (Rational(3, 4) + 0.2).should eql(0.95) - (Rational(3, 4) + 2.5).should eql(3.25) + (Rational(3, 4) + 0.2).should.eql?(0.95) + (Rational(3, 4) + 2.5).should.eql?(3.25) end end describe "Rational#+ with an Integer" do it "returns the result of subtracting other from self as a Rational" do - (Rational(3, 4) + 1).should eql(Rational(7, 4)) - (Rational(3, 4) + 2).should eql(Rational(11, 4)) + (Rational(3, 4) + 1).should.eql?(Rational(7, 4)) + (Rational(3, 4) + 2).should.eql?(Rational(11, 4)) end end diff --git a/spec/ruby/core/rational/rational_spec.rb b/spec/ruby/core/rational/rational_spec.rb index 482deab38d72a6..278c4116a42879 100644 --- a/spec/ruby/core/rational/rational_spec.rb +++ b/spec/ruby/core/rational/rational_spec.rb @@ -6,6 +6,6 @@ end it "does not respond to new" do - -> { Rational.new(1) }.should raise_error(NoMethodError) + -> { Rational.new(1) }.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/rational/rationalize_spec.rb b/spec/ruby/core/rational/rationalize_spec.rb index 3db027d446d3c4..9c86824ddd1769 100644 --- a/spec/ruby/core/rational/rationalize_spec.rb +++ b/spec/ruby/core/rational/rationalize_spec.rb @@ -30,7 +30,7 @@ end it "raises ArgumentError when passed more than one argument" do - -> { Rational(1,1).rationalize(0.1, 0.1) }.should raise_error(ArgumentError) - -> { Rational(1,1).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError) + -> { Rational(1,1).rationalize(0.1, 0.1) }.should.raise(ArgumentError) + -> { Rational(1,1).rationalize(0.1, 0.1, 2) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/rational/round_spec.rb b/spec/ruby/core/rational/round_spec.rb index ac3dcafe7bd755..dd6f66f408a9ff 100644 --- a/spec/ruby/core/rational/round_spec.rb +++ b/spec/ruby/core/rational/round_spec.rb @@ -7,9 +7,9 @@ describe "with no arguments (precision = 0)" do it "returns an integer" do - @rational.round.should be_kind_of(Integer) - Rational(0, 1).round(0).should be_kind_of(Integer) - Rational(124, 1).round(0).should be_kind_of(Integer) + @rational.round.should.is_a?(Integer) + Rational(0, 1).round(0).should.is_a?(Integer) + Rational(124, 1).round(0).should.is_a?(Integer) end it "returns the truncated value toward the nearest integer" do @@ -30,10 +30,10 @@ describe "with a precision < 0" do it "returns an integer" do - @rational.round(-2).should be_kind_of(Integer) - @rational.round(-1).should be_kind_of(Integer) - Rational(0, 1).round(-1).should be_kind_of(Integer) - Rational(2, 1).round(-1).should be_kind_of(Integer) + @rational.round(-2).should.is_a?(Integer) + @rational.round(-1).should.is_a?(Integer) + Rational(0, 1).round(-1).should.is_a?(Integer) + Rational(2, 1).round(-1).should.is_a?(Integer) end it "moves the truncation point n decimal places left" do @@ -45,12 +45,12 @@ describe "with a precision > 0" do it "returns a Rational" do - @rational.round(1).should be_kind_of(Rational) - @rational.round(2).should be_kind_of(Rational) + @rational.round(1).should.is_a?(Rational) + @rational.round(2).should.is_a?(Rational) # Guard against the Mathn library guard -> { !defined?(Math.rsqrt) } do - Rational(0, 1).round(1).should be_kind_of(Rational) - Rational(2, 1).round(1).should be_kind_of(Rational) + Rational(0, 1).round(1).should.is_a?(Rational) + Rational(2, 1).round(1).should.is_a?(Rational) end end @@ -100,7 +100,7 @@ end it "raise for a non-existent round mode" do - -> { Rational(10, 4).round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense") + -> { Rational(10, 4).round(half: :nonsense) }.should.raise(ArgumentError, "invalid rounding mode: nonsense") end end end diff --git a/spec/ruby/core/rational/shared/arithmetic_exception_in_coerce.rb b/spec/ruby/core/rational/shared/arithmetic_exception_in_coerce.rb index f4cf70d147d22b..e15169c912326f 100644 --- a/spec/ruby/core/rational/shared/arithmetic_exception_in_coerce.rb +++ b/spec/ruby/core/rational/shared/arithmetic_exception_in_coerce.rb @@ -6,6 +6,6 @@ b.should_receive(:coerce).and_raise(RationalSpecs::CoerceError) # e.g. Rational(3, 4) + b - -> { Rational(3, 4).send(@method, b) }.should raise_error(RationalSpecs::CoerceError) + -> { Rational(3, 4).send(@method, b) }.should.raise(RationalSpecs::CoerceError) end end diff --git a/spec/ruby/core/rational/to_f_spec.rb b/spec/ruby/core/rational/to_f_spec.rb index d0da49d3772b50..40e3f11c0cc76f 100644 --- a/spec/ruby/core/rational/to_f_spec.rb +++ b/spec/ruby/core/rational/to_f_spec.rb @@ -2,10 +2,10 @@ describe "Rational#to_f" do it "returns self converted to a Float" do - Rational(3, 4).to_f.should eql(0.75) - Rational(3, -4).to_f.should eql(-0.75) - Rational(-1, 4).to_f.should eql(-0.25) - Rational(-1, -4).to_f.should eql(0.25) + Rational(3, 4).to_f.should.eql?(0.75) + Rational(3, -4).to_f.should.eql?(-0.75) + Rational(-1, 4).to_f.should.eql?(-0.25) + Rational(-1, -4).to_f.should.eql?(0.25) end it "converts to a Float for large numerator and denominator" do diff --git a/spec/ruby/core/rational/to_i_spec.rb b/spec/ruby/core/rational/to_i_spec.rb index 520a380b2aeb61..e61b1b6c3bd9a9 100644 --- a/spec/ruby/core/rational/to_i_spec.rb +++ b/spec/ruby/core/rational/to_i_spec.rb @@ -2,11 +2,11 @@ describe "Rational#to_i" do it "converts self to an Integer by truncation" do - Rational(7, 4).to_i.should eql(1) - Rational(11, 4).to_i.should eql(2) + Rational(7, 4).to_i.should.eql?(1) + Rational(11, 4).to_i.should.eql?(2) end it "converts self to an Integer by truncation" do - Rational(-7, 4).to_i.should eql(-1) + Rational(-7, 4).to_i.should.eql?(-1) end end diff --git a/spec/ruby/core/rational/to_r_spec.rb b/spec/ruby/core/rational/to_r_spec.rb index 34f16d7890d772..eb6097f5954e83 100644 --- a/spec/ruby/core/rational/to_r_spec.rb +++ b/spec/ruby/core/rational/to_r_spec.rb @@ -3,15 +3,15 @@ describe "Rational#to_r" do it "returns self" do a = Rational(3, 4) - a.to_r.should equal(a) + a.to_r.should.equal?(a) a = Rational(bignum_value, 4) - a.to_r.should equal(a) + a.to_r.should.equal?(a) end it "raises TypeError trying to convert BasicObject" do obj = BasicObject.new - -> { Rational(obj) }.should raise_error(TypeError) + -> { Rational(obj) }.should.raise(TypeError) end it "works when a BasicObject has to_r" do @@ -21,6 +21,6 @@ it "fails when a BasicObject's to_r does not return a Rational" do obj = BasicObject.new; def obj.to_r; 1 end - -> { Rational(obj) }.should raise_error(TypeError) + -> { Rational(obj) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/rational/truncate_spec.rb b/spec/ruby/core/rational/truncate_spec.rb index 728fca34eaeac1..3614431a7f031b 100644 --- a/spec/ruby/core/rational/truncate_spec.rb +++ b/spec/ruby/core/rational/truncate_spec.rb @@ -7,7 +7,7 @@ describe "with no arguments (precision = 0)" do it "returns an integer" do - @rational.truncate.should be_kind_of(Integer) + @rational.truncate.should.is_a?(Integer) end it "returns the truncated value toward 0" do @@ -19,7 +19,7 @@ describe "with an explicit precision = 0" do it "returns an integer" do - @rational.truncate(0).should be_kind_of(Integer) + @rational.truncate(0).should.is_a?(Integer) end it "returns the truncated value toward 0" do @@ -31,8 +31,8 @@ describe "with a precision < 0" do it "returns an integer" do - @rational.truncate(-2).should be_kind_of(Integer) - @rational.truncate(-1).should be_kind_of(Integer) + @rational.truncate(-2).should.is_a?(Integer) + @rational.truncate(-1).should.is_a?(Integer) end it "moves the truncation point n decimal places left" do @@ -44,8 +44,8 @@ describe "with a precision > 0" do it "returns a Rational" do - @rational.truncate(1).should be_kind_of(Rational) - @rational.truncate(2).should be_kind_of(Rational) + @rational.truncate(1).should.is_a?(Rational) + @rational.truncate(2).should.is_a?(Rational) end it "moves the truncation point n decimal places right" do @@ -57,15 +57,15 @@ describe "with an invalid value for precision" do it "raises a TypeError" do - -> { @rational.truncate(nil) }.should raise_error(TypeError, "not an integer") - -> { @rational.truncate(1.0) }.should raise_error(TypeError, "not an integer") - -> { @rational.truncate('') }.should raise_error(TypeError, "not an integer") + -> { @rational.truncate(nil) }.should.raise(TypeError, "not an integer") + -> { @rational.truncate(1.0) }.should.raise(TypeError, "not an integer") + -> { @rational.truncate('') }.should.raise(TypeError, "not an integer") end it "does not call to_int on the argument" do object = Object.new object.should_not_receive(:to_int) - -> { @rational.truncate(object) }.should raise_error(TypeError, "not an integer") + -> { @rational.truncate(object) }.should.raise(TypeError, "not an integer") end end end diff --git a/spec/ruby/core/rational/zero_spec.rb b/spec/ruby/core/rational/zero_spec.rb index af7fb391acc03f..2e4f783d5cc6cd 100644 --- a/spec/ruby/core/rational/zero_spec.rb +++ b/spec/ruby/core/rational/zero_spec.rb @@ -1,14 +1,14 @@ require_relative "../../spec_helper" describe "Rational#zero?" do it "returns true if the numerator is 0" do - Rational(0,26).zero?.should be_true + Rational(0,26).zero?.should == true end it "returns true if the numerator is 0.0" do - Rational(0.0,26).zero?.should be_true + Rational(0.0,26).zero?.should == true end it "returns false if the numerator isn't 0" do - Rational(26).zero?.should be_false + Rational(26).zero?.should == false end end diff --git a/spec/ruby/core/refinement/append_features_spec.rb b/spec/ruby/core/refinement/append_features_spec.rb index f7e5f32bc1d305..cffc9ed308b896 100644 --- a/spec/ruby/core/refinement/append_features_spec.rb +++ b/spec/ruby/core/refinement/append_features_spec.rb @@ -2,7 +2,7 @@ describe "Refinement#append_features" do it "is not defined" do - Refinement.should_not have_private_instance_method(:append_features) + Refinement.private_instance_methods(true).should_not.include?(:append_features) end it "is not called by Module#include" do @@ -11,7 +11,7 @@ refine c do called = false define_method(:append_features){called = true} - proc{c.include(self)}.should raise_error(TypeError) + proc{c.include(self)}.should.raise(TypeError) called.should == false end end diff --git a/spec/ruby/core/refinement/extend_object_spec.rb b/spec/ruby/core/refinement/extend_object_spec.rb index 4da8b359cccc58..f6fe2a60ea0d87 100644 --- a/spec/ruby/core/refinement/extend_object_spec.rb +++ b/spec/ruby/core/refinement/extend_object_spec.rb @@ -2,7 +2,7 @@ describe "Refinement#extend_object" do it "is not defined" do - Refinement.should_not have_private_instance_method(:extend_object) + Refinement.private_instance_methods(true).should_not.include?(:extend_object) end it "is not called by Object#extend" do @@ -13,7 +13,7 @@ define_method(:extend_object) { called = true } -> { c.extend(self) - }.should raise_error(TypeError) + }.should.raise(TypeError) called.should == false end end diff --git a/spec/ruby/core/refinement/import_methods_spec.rb b/spec/ruby/core/refinement/import_methods_spec.rb index dc3e0ea31d38d6..bcb5e9b066ae67 100644 --- a/spec/ruby/core/refinement/import_methods_spec.rb +++ b/spec/ruby/core/refinement/import_methods_spec.rb @@ -23,7 +23,7 @@ def indent(level) refine String do -> { import_methods Integer - }.should raise_error(TypeError, "wrong argument type Class (expected Module)") + }.should.raise(TypeError, "wrong argument type Class (expected Module)") end end end @@ -82,7 +82,7 @@ def indent(level) refine String do -> { import_methods str_utils, Kernel - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -127,7 +127,7 @@ def indent(level) using self -> { "foo".indent(3) - }.should raise_error(NoMethodError, /undefined method [`']indent' for ("foo":String|an instance of String)/) + }.should.raise(NoMethodError, /undefined method [`']indent' for ("foo":String|an instance of String)/) end end @@ -142,7 +142,7 @@ def indent(level) refine String do -> { import_methods str_utils, Integer - }.should raise_error(TypeError) + }.should.raise(TypeError) end end @@ -150,7 +150,7 @@ def indent(level) using string_refined -> { "foo".indent(3) - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end end @@ -213,7 +213,7 @@ def self.indent(level) using self -> { String.indent(3) - }.should raise_error(NoMethodError, /undefined method [`']indent' for (String:Class|class String)/) + }.should.raise(NoMethodError, /undefined method [`']indent' for (String:Class|class String)/) end end @@ -268,7 +268,7 @@ def indent(level) refine String do -> { import_methods Kernel - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end end @@ -279,7 +279,7 @@ def indent(level) refine String do -> { import_methods Zlib - }.should raise_error(ArgumentError, /Can't import method which is not defined with Ruby code: Zlib#*/) + }.should.raise(ArgumentError, /Can't import method which is not defined with Ruby code: Zlib#*/) end end end diff --git a/spec/ruby/core/refinement/include_spec.rb b/spec/ruby/core/refinement/include_spec.rb index 57451bd9bc9fca..55ac89ffb573cf 100644 --- a/spec/ruby/core/refinement/include_spec.rb +++ b/spec/ruby/core/refinement/include_spec.rb @@ -6,7 +6,7 @@ refine String do -> { include Module.new - }.should raise_error(TypeError, "Refinement#include has been removed") + }.should.raise(TypeError, "Refinement#include has been removed") end end end diff --git a/spec/ruby/core/refinement/prepend_features_spec.rb b/spec/ruby/core/refinement/prepend_features_spec.rb index fbc431bbd233d8..9dc5838f1fbd35 100644 --- a/spec/ruby/core/refinement/prepend_features_spec.rb +++ b/spec/ruby/core/refinement/prepend_features_spec.rb @@ -2,7 +2,7 @@ describe "Refinement#prepend_features" do it "is not defined" do - Refinement.should_not have_private_instance_method(:prepend_features) + Refinement.private_instance_methods(true).should_not.include?(:prepend_features) end it "is not called by Module#prepend" do @@ -11,7 +11,7 @@ refine c do called = false define_method(:prepend_features){called = true} - proc{c.prepend(self)}.should raise_error(TypeError) + proc{c.prepend(self)}.should.raise(TypeError) called.should == false end end diff --git a/spec/ruby/core/refinement/prepend_spec.rb b/spec/ruby/core/refinement/prepend_spec.rb index 64cf7cd17f7ff8..fd70dd6f976fa7 100644 --- a/spec/ruby/core/refinement/prepend_spec.rb +++ b/spec/ruby/core/refinement/prepend_spec.rb @@ -6,7 +6,7 @@ refine String do -> { prepend Module.new - }.should raise_error(TypeError, "Refinement#prepend has been removed") + }.should.raise(TypeError, "Refinement#prepend has been removed") end end end diff --git a/spec/ruby/core/regexp/case_compare_spec.rb b/spec/ruby/core/regexp/case_compare_spec.rb index 5ae8b56c6a0414..29aada70bc22ac 100644 --- a/spec/ruby/core/regexp/case_compare_spec.rb +++ b/spec/ruby/core/regexp/case_compare_spec.rb @@ -2,25 +2,25 @@ describe "Regexp#===" do it "is true if there is a match" do - (/abc/ === "aabcc").should be_true + (/abc/ === "aabcc").should == true end it "is false if there is no match" do - (/abc/ === "xyz").should be_false + (/abc/ === "xyz").should == false end it "returns true if it matches a Symbol" do - (/a/ === :a).should be_true + (/a/ === :a).should == true end it "returns false if it does not match a Symbol" do - (/a/ === :b).should be_false + (/a/ === :b).should == false end # mirroring https://github.com/ruby/ruby/blob/master/test/ruby/test_regexp.rb it "returns false if the other value cannot be coerced to a string" do - (/abc/ === nil).should be_false - (/abc/ === /abc/).should be_false + (/abc/ === nil).should == false + (/abc/ === /abc/).should == false end it "uses #to_str on string-like objects" do @@ -30,6 +30,6 @@ def to_str end end.new - (/abc/ === stringlike).should be_true + (/abc/ === stringlike).should == true end end diff --git a/spec/ruby/core/regexp/encoding_spec.rb b/spec/ruby/core/regexp/encoding_spec.rb index dfc835b4e425a8..fb4fdba064e8a2 100644 --- a/spec/ruby/core/regexp/encoding_spec.rb +++ b/spec/ruby/core/regexp/encoding_spec.rb @@ -3,7 +3,7 @@ describe "Regexp#encoding" do it "returns an Encoding object" do - /glar/.encoding.should be_an_instance_of(Encoding) + /glar/.encoding.should.instance_of?(Encoding) end it "defaults to US-ASCII if the Regexp contains only US-ASCII character" do diff --git a/spec/ruby/core/regexp/fixed_encoding_spec.rb b/spec/ruby/core/regexp/fixed_encoding_spec.rb index 29d0a22c530727..5d8b1c28606be5 100644 --- a/spec/ruby/core/regexp/fixed_encoding_spec.rb +++ b/spec/ruby/core/regexp/fixed_encoding_spec.rb @@ -3,34 +3,34 @@ describe "Regexp#fixed_encoding?" do it "returns false by default" do - /needle/.fixed_encoding?.should be_false + /needle/.fixed_encoding?.should == false end it "returns false if the 'n' modifier was supplied to the Regexp" do - /needle/n.fixed_encoding?.should be_false + /needle/n.fixed_encoding?.should == false end it "returns true if the 'u' modifier was supplied to the Regexp" do - /needle/u.fixed_encoding?.should be_true + /needle/u.fixed_encoding?.should == true end it "returns true if the 's' modifier was supplied to the Regexp" do - /needle/s.fixed_encoding?.should be_true + /needle/s.fixed_encoding?.should == true end it "returns true if the 'e' modifier was supplied to the Regexp" do - /needle/e.fixed_encoding?.should be_true + /needle/e.fixed_encoding?.should == true end it "returns true if the Regexp contains a \\u escape" do - /needle \u{8768}/.fixed_encoding?.should be_true + /needle \u{8768}/.fixed_encoding?.should == true end it "returns true if the Regexp contains a UTF-8 literal" do - /文字化け/.fixed_encoding?.should be_true + /文字化け/.fixed_encoding?.should == true end it "returns true if the Regexp was created with the Regexp::FIXEDENCODING option" do - Regexp.new("", Regexp::FIXEDENCODING).fixed_encoding?.should be_true + Regexp.new("", Regexp::FIXEDENCODING).fixed_encoding?.should == true end end diff --git a/spec/ruby/core/regexp/initialize_spec.rb b/spec/ruby/core/regexp/initialize_spec.rb index aeab6d0f5ca1fe..1c0133acae4d3f 100644 --- a/spec/ruby/core/regexp/initialize_spec.rb +++ b/spec/ruby/core/regexp/initialize_spec.rb @@ -2,28 +2,28 @@ describe "Regexp#initialize" do it "is a private method" do - Regexp.should have_private_instance_method(:initialize) + Regexp.private_instance_methods(false).should.include?(:initialize) end it "raises a FrozenError on a Regexp literal" do - -> { //.send(:initialize, "") }.should raise_error(FrozenError) + -> { //.send(:initialize, "") }.should.raise(FrozenError) end ruby_version_is "4.1" do it "raises a FrozenError on an initialized non-literal Regexp" do regexp = Regexp.new("") - -> { regexp.send(:initialize, "") }.should raise_error(FrozenError) + -> { regexp.send(:initialize, "") }.should.raise(FrozenError) end end ruby_version_is ""..."4.1" do it "raises a TypeError on an initialized non-literal Regexp" do - -> { Regexp.new("").send(:initialize, "") }.should raise_error(TypeError) + -> { Regexp.new("").send(:initialize, "") }.should.raise(TypeError) end end it "raises a TypeError on an initialized non-literal Regexp subclass" do r = Class.new(Regexp).new("") - -> { r.send(:initialize, "") }.should raise_error(TypeError) + -> { r.send(:initialize, "") }.should.raise(TypeError) end end diff --git a/spec/ruby/core/regexp/last_match_spec.rb b/spec/ruby/core/regexp/last_match_spec.rb index 0bfed320511a63..6c256cc1cf4d4b 100644 --- a/spec/ruby/core/regexp/last_match_spec.rb +++ b/spec/ruby/core/regexp/last_match_spec.rb @@ -4,7 +4,7 @@ it "returns MatchData instance when not passed arguments" do /c(.)t/ =~ 'cat' - Regexp.last_match.should be_kind_of(MatchData) + Regexp.last_match.should.is_a?(MatchData) end it "returns the nth field in this MatchData when passed an Integer" do @@ -28,7 +28,7 @@ it "raises an IndexError when given a missing name" do /(?[A-Z]+.*)/ =~ "TEST123" - -> { Regexp.last_match(:missing) }.should raise_error(IndexError) + -> { Regexp.last_match(:missing) }.should.raise(IndexError) end end @@ -50,7 +50,7 @@ it "raises a TypeError when unable to coerce" do obj = Object.new /(?[A-Z]+.*)/ =~ "TEST123" - -> { Regexp.last_match(obj) }.should raise_error(TypeError) + -> { Regexp.last_match(obj) }.should.raise(TypeError) end end end diff --git a/spec/ruby/core/regexp/match_spec.rb b/spec/ruby/core/regexp/match_spec.rb index 80dbfb4c1049f2..276cecc8e4eef7 100644 --- a/spec/ruby/core/regexp/match_spec.rb +++ b/spec/ruby/core/regexp/match_spec.rb @@ -3,11 +3,11 @@ describe :regexp_match, shared: true do it "returns nil if there is no match" do - /xyz/.send(@method,"abxyc").should be_nil + /xyz/.send(@method,"abxyc").should == nil end it "returns nil if the object is nil" do - /\w+/.send(@method, nil).should be_nil + /\w+/.send(@method, nil).should == nil end end @@ -27,19 +27,19 @@ it_behaves_like :regexp_match, :match it "returns a MatchData object" do - /(.)(.)(.)/.match("abc").should be_kind_of(MatchData) + /(.)(.)(.)/.match("abc").should.is_a?(MatchData) end it "returns a MatchData object, when argument is a Symbol" do - /(.)(.)(.)/.match(:abc).should be_kind_of(MatchData) + /(.)(.)(.)/.match(:abc).should.is_a?(MatchData) end it "raises a TypeError on an uninitialized Regexp" do - -> { Regexp.allocate.match('foo') }.should raise_error(TypeError) + -> { Regexp.allocate.match('foo') }.should.raise(TypeError) end it "raises TypeError on an uninitialized Regexp" do - -> { Regexp.allocate.match('foo'.encode("UTF-16LE")) }.should raise_error(TypeError) + -> { Regexp.allocate.match('foo'.encode("UTF-16LE")) }.should.raise(TypeError) end describe "with [string, position]" do @@ -54,7 +54,7 @@ it "raises an ArgumentError for an invalid encoding" do x96 = ([150].pack('C')).force_encoding('utf-8') - -> { /(.).(.)/.match("Hello, #{x96} world!", 1) }.should raise_error(ArgumentError) + -> { /(.).(.)/.match("Hello, #{x96} world!", 1) }.should.raise(ArgumentError) end end @@ -69,14 +69,14 @@ it "raises an ArgumentError for an invalid encoding" do x96 = ([150].pack('C')).force_encoding('utf-8') - -> { /(.).(.)/.match("Hello, #{x96} world!", -1) }.should raise_error(ArgumentError) + -> { /(.).(.)/.match("Hello, #{x96} world!", -1) }.should.raise(ArgumentError) end end describe "when passed a block" do it "yields the MatchData" do /./.match("abc") {|m| ScratchPad.record m } - ScratchPad.recorded.should be_kind_of(MatchData) + ScratchPad.recorded.should.is_a?(MatchData) end it "returns the block result" do @@ -94,20 +94,20 @@ it "resets $~ if passed nil" do # set $~ /./.match("a") - $~.should be_kind_of(MatchData) + $~.should.is_a?(MatchData) /1/.match(nil) - $~.should be_nil + $~.should == nil end it "raises TypeError when the given argument cannot be coerced to String" do f = 1 - -> { /foo/.match(f)[0] }.should raise_error(TypeError) + -> { /foo/.match(f)[0] }.should.raise(TypeError) end it "raises TypeError when the given argument is an Exception" do f = Exception.new("foo") - -> { /foo/.match(f)[0] }.should raise_error(TypeError) + -> { /foo/.match(f)[0] }.should.raise(TypeError) end end @@ -119,22 +119,22 @@ context "when matches the given value" do it "returns true but does not set Regexp.last_match" do - /string/i.match?('string').should be_true - Regexp.last_match.should be_nil + /string/i.match?('string').should == true + Regexp.last_match.should == nil end end it "returns false when does not match the given value" do - /STRING/.match?('string').should be_false + /STRING/.match?('string').should == false end it "takes matching position as the 2nd argument" do - /str/i.match?('string', 0).should be_true - /str/i.match?('string', 1).should be_false + /str/i.match?('string', 0).should == true + /str/i.match?('string', 1).should == false end it "returns false when given nil" do - /./.match?(nil).should be_false + /./.match?(nil).should == false end end diff --git a/spec/ruby/core/regexp/named_captures_spec.rb b/spec/ruby/core/regexp/named_captures_spec.rb index 1a68d7877b8503..4d3fdd23ab2482 100644 --- a/spec/ruby/core/regexp/named_captures_spec.rb +++ b/spec/ruby/core/regexp/named_captures_spec.rb @@ -2,7 +2,7 @@ describe "Regexp#named_captures" do it "returns a Hash" do - /foo/.named_captures.should be_an_instance_of(Hash) + /foo/.named_captures.should.instance_of?(Hash) end it "returns an empty Hash when there are no capture groups" do @@ -17,7 +17,7 @@ it "sets the values of the Hash to Arrays" do rex = /this (?is) [aA] (?pate?rn)/ rex.named_captures.values.each do |value| - value.should be_an_instance_of(Array) + value.should.instance_of?(Array) end end diff --git a/spec/ruby/core/regexp/names_spec.rb b/spec/ruby/core/regexp/names_spec.rb index 099768fd263cba..9013f41e208488 100644 --- a/spec/ruby/core/regexp/names_spec.rb +++ b/spec/ruby/core/regexp/names_spec.rb @@ -2,7 +2,7 @@ describe "Regexp#names" do it "returns an Array" do - /foo/.names.should be_an_instance_of(Array) + /foo/.names.should.instance_of?(Array) end it "returns an empty Array if there are no named captures" do @@ -11,7 +11,7 @@ it "returns each named capture as a String" do /n(?ee)d(?le)/.names.each do |name| - name.should be_an_instance_of(String) + name.should.instance_of?(String) end end diff --git a/spec/ruby/core/regexp/options_spec.rb b/spec/ruby/core/regexp/options_spec.rb index 527b51a3b2dc1c..c3401cee6edd14 100644 --- a/spec/ruby/core/regexp/options_spec.rb +++ b/spec/ruby/core/regexp/options_spec.rb @@ -2,9 +2,9 @@ describe "Regexp#options" do it "returns an Integer bitvector of regexp options for the Regexp object" do - /cat/.options.should be_kind_of(Integer) + /cat/.options.should.is_a?(Integer) not_supported_on :opal do - /cat/ix.options.should be_kind_of(Integer) + /cat/ix.options.should.is_a?(Integer) end end @@ -29,7 +29,7 @@ end it "raises a TypeError on an uninitialized Regexp" do - -> { Regexp.allocate.options }.should raise_error(TypeError) + -> { Regexp.allocate.options }.should.raise(TypeError) end it "includes Regexp::FIXEDENCODING for a Regexp literal with the 'u' option" do diff --git a/spec/ruby/core/regexp/shared/new.rb b/spec/ruby/core/regexp/shared/new.rb index ba06ded756c605..affdaf855ce00a 100644 --- a/spec/ruby/core/regexp/shared/new.rb +++ b/spec/ruby/core/regexp/shared/new.rb @@ -23,10 +23,10 @@ def initialize(*args) class RegexpSpecsSubclassTwo < Regexp; end - RegexpSpecsSubclass.send(@method, "hi").should be_kind_of(RegexpSpecsSubclass) + RegexpSpecsSubclass.send(@method, "hi").should.is_a?(RegexpSpecsSubclass) RegexpSpecsSubclass.send(@method, "hi").args.first.should == "hi" - RegexpSpecsSubclassTwo.send(@method, "hi").should be_kind_of(RegexpSpecsSubclassTwo) + RegexpSpecsSubclassTwo.send(@method, "hi").should.is_a?(RegexpSpecsSubclassTwo) end end @@ -40,12 +40,12 @@ def obj.to_str() "a" end it "raises TypeError if there is no #to_str method for non-String/Regexp argument" do obj = Object.new - -> { Regexp.send(@method, obj) }.should raise_error(TypeError, "no implicit conversion of Object into String") + -> { Regexp.send(@method, obj) }.should.raise(TypeError, "no implicit conversion of Object into String") - -> { Regexp.send(@method, 1) }.should raise_error(TypeError, "no implicit conversion of Integer into String") - -> { Regexp.send(@method, 1.0) }.should raise_error(TypeError, "no implicit conversion of Float into String") - -> { Regexp.send(@method, :symbol) }.should raise_error(TypeError, "no implicit conversion of Symbol into String") - -> { Regexp.send(@method, []) }.should raise_error(TypeError, "no implicit conversion of Array into String") + -> { Regexp.send(@method, 1) }.should.raise(TypeError, "no implicit conversion of Integer into String") + -> { Regexp.send(@method, 1.0) }.should.raise(TypeError, "no implicit conversion of Float into String") + -> { Regexp.send(@method, :symbol) }.should.raise(TypeError, "no implicit conversion of Symbol into String") + -> { Regexp.send(@method, []) }.should.raise(TypeError, "no implicit conversion of Array into String") end it "raises TypeError if #to_str returns non-String value" do @@ -62,7 +62,7 @@ def obj.to_str() [] end end it "raises a RegexpError when passed an incorrect regexp" do - -> { Regexp.send(@method, "^[$", 0) }.should raise_error(RegexpError, Regexp.new(Regexp.escape("premature end of char-class: /^[$/"))) + -> { Regexp.send(@method, "^[$", 0) }.should.raise(RegexpError, Regexp.new(Regexp.escape("premature end of char-class: /^[$/"))) end it "does not set Regexp options if only given one argument" do @@ -184,21 +184,21 @@ def obj.to_int() ScratchPad.record(:called) end end it "raises an Argument error if the second argument contains unsupported chars" do - -> { Regexp.send(@method, 'Hi', 'e') }.should raise_error(ArgumentError, "unknown regexp option: e") - -> { Regexp.send(@method, 'Hi', 'n') }.should raise_error(ArgumentError, "unknown regexp option: n") - -> { Regexp.send(@method, 'Hi', 's') }.should raise_error(ArgumentError, "unknown regexp option: s") - -> { Regexp.send(@method, 'Hi', 'u') }.should raise_error(ArgumentError, "unknown regexp option: u") - -> { Regexp.send(@method, 'Hi', 'j') }.should raise_error(ArgumentError, "unknown regexp option: j") - -> { Regexp.send(@method, 'Hi', 'mjx') }.should raise_error(ArgumentError, /unknown regexp option: mjx\b/) + -> { Regexp.send(@method, 'Hi', 'e') }.should.raise(ArgumentError, "unknown regexp option: e") + -> { Regexp.send(@method, 'Hi', 'n') }.should.raise(ArgumentError, "unknown regexp option: n") + -> { Regexp.send(@method, 'Hi', 's') }.should.raise(ArgumentError, "unknown regexp option: s") + -> { Regexp.send(@method, 'Hi', 'u') }.should.raise(ArgumentError, "unknown regexp option: u") + -> { Regexp.send(@method, 'Hi', 'j') }.should.raise(ArgumentError, "unknown regexp option: j") + -> { Regexp.send(@method, 'Hi', 'mjx') }.should.raise(ArgumentError, /unknown regexp option: mjx\b/) end describe "with escaped characters" do it "raises a Regexp error if there is a trailing backslash" do - -> { Regexp.send(@method, "\\") }.should raise_error(RegexpError, Regexp.new(Regexp.escape("too short escape sequence: /\\/"))) + -> { Regexp.send(@method, "\\") }.should.raise(RegexpError, Regexp.new(Regexp.escape("too short escape sequence: /\\/"))) end it "does not raise a Regexp error if there is an escaped trailing backslash" do - -> { Regexp.send(@method, "\\\\") }.should_not raise_error(RegexpError) + -> { Regexp.send(@method, "\\\\") }.should_not.raise(RegexpError) end it "accepts a backspace followed by a non-special character" do @@ -206,23 +206,23 @@ def obj.to_int() ScratchPad.record(:called) end end it "raises a RegexpError if \\x is not followed by any hexadecimal digits" do - -> { Regexp.send(@method, "\\" + "xn") }.should raise_error(RegexpError, Regexp.new(Regexp.escape("invalid hex escape: /\\xn/"))) + -> { Regexp.send(@method, "\\" + "xn") }.should.raise(RegexpError, Regexp.new(Regexp.escape("invalid hex escape: /\\xn/"))) end it "raises a RegexpError if less than four digits are given for \\uHHHH" do - -> { Regexp.send(@method, "\\" + "u304") }.should raise_error(RegexpError, Regexp.new(Regexp.escape("invalid Unicode escape: /\\u304/"))) + -> { Regexp.send(@method, "\\" + "u304") }.should.raise(RegexpError, Regexp.new(Regexp.escape("invalid Unicode escape: /\\u304/"))) end it "raises a RegexpError if the \\u{} escape is empty" do - -> { Regexp.send(@method, "\\" + "u{}") }.should raise_error(RegexpError, Regexp.new(Regexp.escape("invalid Unicode list: /\\u{}/"))) + -> { Regexp.send(@method, "\\" + "u{}") }.should.raise(RegexpError, Regexp.new(Regexp.escape("invalid Unicode list: /\\u{}/"))) end it "raises a RegexpError if the \\u{} escape contains non hexadecimal digits" do - -> { Regexp.send(@method, "\\" + "u{abcX}") }.should raise_error(RegexpError, Regexp.new(Regexp.escape("invalid Unicode list: /\\u{abcX}/"))) + -> { Regexp.send(@method, "\\" + "u{abcX}") }.should.raise(RegexpError, Regexp.new(Regexp.escape("invalid Unicode list: /\\u{abcX}/"))) end it "raises a RegexpError if more than six hexadecimal digits are given" do - -> { Regexp.send(@method, "\\" + "u{0ffffff}") }.should raise_error(RegexpError, Regexp.new(Regexp.escape("invalid Unicode range: /\\u{0ffffff}/"))) + -> { Regexp.send(@method, "\\" + "u{0ffffff}") }.should.raise(RegexpError, Regexp.new(Regexp.escape("invalid Unicode range: /\\u{0ffffff}/"))) end it "returns a Regexp with US-ASCII encoding if only 7-bit ASCII characters are present regardless of the input String's encoding" do diff --git a/spec/ruby/core/regexp/shared/quote.rb b/spec/ruby/core/regexp/shared/quote.rb index 3f46a18b5bf8bb..083f12d78c1266 100644 --- a/spec/ruby/core/regexp/shared/quote.rb +++ b/spec/ruby/core/regexp/shared/quote.rb @@ -29,13 +29,13 @@ it "sets the encoding of the result to the encoding of the String if any non-US-ASCII characters are present in an input String with valid encoding" do str = "ありがとう".dup.force_encoding("utf-8") - str.valid_encoding?.should be_true + str.valid_encoding?.should == true Regexp.send(@method, str).encoding.should == Encoding::UTF_8 end it "sets the encoding of the result to BINARY if any non-US-ASCII characters are present in an input String with invalid encoding" do str = "\xff".dup.force_encoding "us-ascii" - str.valid_encoding?.should be_false + str.valid_encoding?.should == false Regexp.send(@method, "\xff").encoding.should == Encoding::BINARY end end diff --git a/spec/ruby/core/regexp/source_spec.rb b/spec/ruby/core/regexp/source_spec.rb index 5f253da9ea0590..4eebf280f076d9 100644 --- a/spec/ruby/core/regexp/source_spec.rb +++ b/spec/ruby/core/regexp/source_spec.rb @@ -34,14 +34,14 @@ not_supported_on :opal do it "has US-ASCII encoding when created from an ASCII-only \\u{} literal" do re = /[\u{20}-\u{7E}]/ - re.source.encoding.should equal(Encoding::US_ASCII) + re.source.encoding.should.equal?(Encoding::US_ASCII) end end not_supported_on :opal do it "has UTF-8 encoding when created from a non-ASCII-only \\u{} literal" do re = /[\u{20}-\u{7EE}]/ - re.source.encoding.should equal(Encoding::UTF_8) + re.source.encoding.should.equal?(Encoding::UTF_8) end end end diff --git a/spec/ruby/core/regexp/timeout_spec.rb b/spec/ruby/core/regexp/timeout_spec.rb index c64103c82cb129..a1ec475ef3f12e 100644 --- a/spec/ruby/core/regexp/timeout_spec.rb +++ b/spec/ruby/core/regexp/timeout_spec.rb @@ -17,7 +17,7 @@ -> { # A typical ReDoS case /^(a*)*$/ =~ "a" * 1000000 + "x" - }.should raise_error(Regexp::TimeoutError, "regexp match timeout") + }.should.raise(Regexp::TimeoutError, "regexp match timeout") end it "raises Regexp::TimeoutError after timeout keyword value elapsed" do @@ -28,6 +28,6 @@ -> { re =~ "a" * 1000000 + "x" - }.should raise_error(Regexp::TimeoutError, "regexp match timeout") + }.should.raise(Regexp::TimeoutError, "regexp match timeout") end end diff --git a/spec/ruby/core/regexp/try_convert_spec.rb b/spec/ruby/core/regexp/try_convert_spec.rb index 44a6fead83fb6f..da5e10adcef546 100644 --- a/spec/ruby/core/regexp/try_convert_spec.rb +++ b/spec/ruby/core/regexp/try_convert_spec.rb @@ -9,7 +9,7 @@ it "returns nil if given an argument that can't be converted to a Regexp" do ['', 'glark', [], Object.new, :pat].each do |arg| - Regexp.try_convert(arg).should be_nil + Regexp.try_convert(arg).should == nil end end diff --git a/spec/ruby/core/regexp/union_spec.rb b/spec/ruby/core/regexp/union_spec.rb index ea5a5053f7258b..c0a9d12fedfc5c 100644 --- a/spec/ruby/core/regexp/union_spec.rb +++ b/spec/ruby/core/regexp/union_spec.rb @@ -75,83 +75,83 @@ it "raises ArgumentError if the arguments include conflicting ASCII-incompatible Strings" do -> { Regexp.union("a".encode("UTF-16LE"), "b".encode("UTF-16BE")) - }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and UTF-16BE') + }.should.raise(ArgumentError, 'incompatible encodings: UTF-16LE and UTF-16BE') end it "raises ArgumentError if the arguments include conflicting ASCII-incompatible Regexps" do -> { Regexp.union(Regexp.new("a".encode("UTF-16LE")), Regexp.new("b".encode("UTF-16BE"))) - }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and UTF-16BE') + }.should.raise(ArgumentError, 'incompatible encodings: UTF-16LE and UTF-16BE') end it "raises ArgumentError if the arguments include conflicting fixed encoding Regexps" do -> { Regexp.union(Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING), Regexp.new("b".encode("US-ASCII"), Regexp::FIXEDENCODING)) - }.should raise_error(ArgumentError, 'incompatible encodings: UTF-8 and US-ASCII') + }.should.raise(ArgumentError, 'incompatible encodings: UTF-8 and US-ASCII') end it "raises ArgumentError if the arguments include a fixed encoding Regexp and a String containing non-ASCII-compatible characters in a different encoding" do -> { Regexp.union(Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING), "\u00A9".encode("ISO-8859-1")) - }.should raise_error(ArgumentError, 'incompatible encodings: UTF-8 and ISO-8859-1') + }.should.raise(ArgumentError, 'incompatible encodings: UTF-8 and ISO-8859-1') end it "raises ArgumentError if the arguments include a String containing non-ASCII-compatible characters and a fixed encoding Regexp in a different encoding" do -> { Regexp.union("\u00A9".encode("ISO-8859-1"), Regexp.new("a".encode("UTF-8"), Regexp::FIXEDENCODING)) - }.should raise_error(ArgumentError, 'incompatible encodings: ISO-8859-1 and UTF-8') + }.should.raise(ArgumentError, 'incompatible encodings: ISO-8859-1 and UTF-8') end it "raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only String" do -> { Regexp.union("a".encode("UTF-16LE"), "b".encode("UTF-8")) - }.should raise_error(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) + }.should.raise(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) end it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only String" do -> { Regexp.union(Regexp.new("a".encode("UTF-16LE")), "b".encode("UTF-8")) - }.should raise_error(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) + }.should.raise(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) end it "raises ArgumentError if the arguments include an ASCII-incompatible String and an ASCII-only Regexp" do -> { Regexp.union("a".encode("UTF-16LE"), Regexp.new("b".encode("UTF-8"))) - }.should raise_error(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) + }.should.raise(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) end it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and an ASCII-only Regexp" do -> { Regexp.union(Regexp.new("a".encode("UTF-16LE")), Regexp.new("b".encode("UTF-8"))) - }.should raise_error(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) + }.should.raise(ArgumentError, /ASCII incompatible encoding: UTF-16LE|incompatible encodings: UTF-16LE and US-ASCII/) end it "raises ArgumentError if the arguments include an ASCII-incompatible String and a String containing non-ASCII-compatible characters in a different encoding" do -> { Regexp.union("a".encode("UTF-16LE"), "\u00A9".encode("ISO-8859-1")) - }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') + }.should.raise(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') end it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a String containing non-ASCII-compatible characters in a different encoding" do -> { Regexp.union(Regexp.new("a".encode("UTF-16LE")), "\u00A9".encode("ISO-8859-1")) - }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') + }.should.raise(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') end it "raises ArgumentError if the arguments include an ASCII-incompatible String and a Regexp containing non-ASCII-compatible characters in a different encoding" do -> { Regexp.union("a".encode("UTF-16LE"), Regexp.new("\u00A9".encode("ISO-8859-1"))) - }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') + }.should.raise(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') end it "raises ArgumentError if the arguments include an ASCII-incompatible Regexp and a Regexp containing non-ASCII-compatible characters in a different encoding" do -> { Regexp.union(Regexp.new("a".encode("UTF-16LE")), Regexp.new("\u00A9".encode("ISO-8859-1"))) - }.should raise_error(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') + }.should.raise(ArgumentError, 'incompatible encodings: UTF-16LE and ISO-8859-1') end it "uses to_str to convert arguments (if not Regexp)" do @@ -177,6 +177,6 @@ end -> { Regexp.union(["skiing", "sledding"], [/dogs/, /cats/i]) - }.should raise_error(TypeError, 'no implicit conversion of Array into String') + }.should.raise(TypeError, 'no implicit conversion of Array into String') end end diff --git a/spec/ruby/core/set/add_spec.rb b/spec/ruby/core/set/add_spec.rb index 0fe1a0926ce8e7..1ce03b1eabb543 100644 --- a/spec/ruby/core/set/add_spec.rb +++ b/spec/ruby/core/set/add_spec.rb @@ -12,22 +12,22 @@ it "adds the passed Object to self" do @set.add?("cat") - @set.should include("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) + @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 + @set.add?("cat").should == nil end it "raises RuntimeError when called during iteration" do set = Set[:a, :b, :c, :d, :e, :f] set.each do |_m| - -> { set << 1 }.should raise_error(RuntimeError, /iteration/) + -> { set << 1 }.should.raise(RuntimeError, /iteration/) end set.should == Set[:a, :b, :c, :d, :e, :f] end diff --git a/spec/ruby/core/set/classify_spec.rb b/spec/ruby/core/set/classify_spec.rb index d86ea2722d8cfc..a225ab7cbb93ea 100644 --- a/spec/ruby/core/set/classify_spec.rb +++ b/spec/ruby/core/set/classify_spec.rb @@ -13,7 +13,7 @@ it "returns an Enumerator when passed no block" do enum = @set.classify - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) classified = enum.each { |x| x.length } classified.should == { 3 => Set["one", "two"], 4 => Set["four"], 5 => Set["three"] } diff --git a/spec/ruby/core/set/clear_spec.rb b/spec/ruby/core/set/clear_spec.rb index ebeac211d3f7e0..c61a0d78f2c599 100644 --- a/spec/ruby/core/set/clear_spec.rb +++ b/spec/ruby/core/set/clear_spec.rb @@ -7,10 +7,10 @@ it "removes all elements from self" do @set.clear - @set.should be_empty + @set.should.empty? end it "returns self" do - @set.clear.should equal(@set) + @set.clear.should.equal?(@set) end end diff --git a/spec/ruby/core/set/compare_by_identity_spec.rb b/spec/ruby/core/set/compare_by_identity_spec.rb index 238dc117a6ccfa..458e760da0fdfe 100644 --- a/spec/ruby/core/set/compare_by_identity_spec.rb +++ b/spec/ruby/core/set/compare_by_identity_spec.rb @@ -16,9 +16,9 @@ elt = [1] set = Set.new set << elt - set.member?(elt.dup).should be_true + set.member?(elt.dup).should == true set.compare_by_identity - set.member?(elt.dup).should be_false + set.member?(elt.dup).should == false end it "rehashes internally so that old members can be looked up" do @@ -28,19 +28,19 @@ def o.hash; 123; end set << o set.compare_by_identity - set.member?(o).should be_true + set.member?(o).should == true end it "returns self" do set = Set.new result = set.compare_by_identity - result.should equal(set) + result.should.equal?(set) end it "is idempotent and has no effect on an already compare_by_identity set" do set = Set.new.compare_by_identity set << :foo - set.compare_by_identity.should equal(set) + set.compare_by_identity.should.equal?(set) set.should.compare_by_identity? set.to_a.should == [:foo] end @@ -69,7 +69,7 @@ def o.hash; 123; end elt.should_not_receive(:hash) set = Set.new.compare_by_identity set << elt - set.member?(elt).should be_true + set.member?(elt).should == true end it "regards #dup'd objects as having different identities" do @@ -95,7 +95,7 @@ def o.hash; 123; end set = Set.new.freeze -> { set.compare_by_identity - }.should raise_error(FrozenError, /can't modify frozen Set: (#<)?Set(\[|: {)[\]}]>?/) + }.should.raise(FrozenError, /can't modify frozen Set: (#<)?Set(\[|: {)[\]}]>?/) end end @@ -104,7 +104,7 @@ def o.hash; 123; end set = Set.new.freeze -> { set.compare_by_identity - }.should raise_error(FrozenError, /frozen Hash/) + }.should.raise(FrozenError, /frozen Hash/) end end diff --git a/spec/ruby/core/set/comparison_spec.rb b/spec/ruby/core/set/comparison_spec.rb index 62059b70b3b470..eb18a198e5f0f9 100644 --- a/spec/ruby/core/set/comparison_spec.rb +++ b/spec/ruby/core/set/comparison_spec.rb @@ -17,10 +17,10 @@ end it "returns nil if the set has unique elements" do - (Set[1, 2, 3] <=> Set[:a, :b, :c]).should be_nil + (Set[1, 2, 3] <=> Set[:a, :b, :c]).should == nil end it "returns nil when the argument is not set-like" do - (Set[] <=> false).should be_nil + (Set[] <=> false).should == nil end end diff --git a/spec/ruby/core/set/constructor_spec.rb b/spec/ruby/core/set/constructor_spec.rb index 365081ad39b06a..11138f3a5b8f91 100644 --- a/spec/ruby/core/set/constructor_spec.rb +++ b/spec/ruby/core/set/constructor_spec.rb @@ -4,11 +4,11 @@ it "returns a new Set populated with the passed Objects" do set = Set[1, 2, 3] - set.instance_of?(Set).should be_true - set.size.should eql(3) + set.instance_of?(Set).should == true + set.size.should.eql?(3) - set.should include(1) - set.should include(2) - set.should include(3) + set.should.include?(1) + set.should.include?(2) + set.should.include?(3) end end diff --git a/spec/ruby/core/set/delete_if_spec.rb b/spec/ruby/core/set/delete_if_spec.rb index beda73a5e5f5b9..b231dff50dab3a 100644 --- a/spec/ruby/core/set/delete_if_spec.rb +++ b/spec/ruby/core/set/delete_if_spec.rb @@ -13,25 +13,25 @@ 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.size.should.eql?(1) - @set.should_not include("one") - @set.should_not include("two") - @set.should include("three") + @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) + @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.should.instance_of?(Enumerator) enum.each { |x| x.size == 3 } - @set.should_not include("one") - @set.should_not include("two") - @set.should include("three") + @set.should_not.include?("one") + @set.should_not.include?("two") + @set.should.include?("three") end end diff --git a/spec/ruby/core/set/delete_spec.rb b/spec/ruby/core/set/delete_spec.rb index a2543ecbee7b7c..cdc6dd7b369665 100644 --- a/spec/ruby/core/set/delete_spec.rb +++ b/spec/ruby/core/set/delete_spec.rb @@ -7,12 +7,12 @@ it "deletes the passed Object from self" do @set.delete("a") - @set.should_not include("a") + @set.should_not.include?("a") end it "returns self" do - @set.delete("a").should equal(@set) - @set.delete("x").should equal(@set) + @set.delete("a").should.equal?(@set) + @set.delete("x").should.equal?(@set) end end @@ -23,14 +23,14 @@ it "deletes the passed Object from self" do @set.delete?("a") - @set.should_not include("a") + @set.should_not.include?("a") end it "returns self when the passed Object is in self" do - @set.delete?("a").should equal(@set) + @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 + @set.delete?("x").should == nil end end diff --git a/spec/ruby/core/set/disjoint_spec.rb b/spec/ruby/core/set/disjoint_spec.rb index 89a3c4b1577ebe..d415c210454885 100644 --- a/spec/ruby/core/set/disjoint_spec.rb +++ b/spec/ruby/core/set/disjoint_spec.rb @@ -12,11 +12,11 @@ context "when comparing to a Set-like object" do it "returns false when a Set has at least one element in common with a Set-like object" do - Set[1, 2].disjoint?(SetSpecs::SetLike.new([2, 3])).should be_false + Set[1, 2].disjoint?(SetSpecs::SetLike.new([2, 3])).should == false end it "returns true when a Set has no element in common with a Set-like object" do - Set[1, 2].disjoint?(SetSpecs::SetLike.new([3, 4])).should be_true + Set[1, 2].disjoint?(SetSpecs::SetLike.new([3, 4])).should == true end end end diff --git a/spec/ruby/core/set/divide_spec.rb b/spec/ruby/core/set/divide_spec.rb index c6c6003e99d8b6..409a22df756e55 100644 --- a/spec/ruby/core/set/divide_spec.rb +++ b/spec/ruby/core/set/divide_spec.rb @@ -14,7 +14,7 @@ it "returns an enumerator when not passed a block" do ret = Set[1, 2, 3, 4].divide - ret.should be_kind_of(Enumerator) + ret.should.is_a?(Enumerator) ret.each(&:even?).should == Set[Set[1, 3], Set[2, 4]] end end @@ -43,7 +43,7 @@ it "returns an enumerator when not passed a block" do ret = Set[1, 2, 3, 4].divide - ret.should be_kind_of(Enumerator) + ret.should.is_a?(Enumerator) ret.each { |a, b| (a + b).even? }.should == Set[Set[1, 3], Set[2, 4]] end end @@ -51,8 +51,8 @@ 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 + y.should == nil + z.should == nil x.length end set.map { |x| x.to_a.sort }.sort.should == [["five", "four"], ["one", "two"], ["three"]] diff --git a/spec/ruby/core/set/each_spec.rb b/spec/ruby/core/set/each_spec.rb index 3d9cdc2d468e1e..bdafc995716f73 100644 --- a/spec/ruby/core/set/each_spec.rb +++ b/spec/ruby/core/set/each_spec.rb @@ -12,12 +12,12 @@ end it "returns self" do - @set.each { |x| x }.should equal(@set) + @set.each { |x| x }.should.equal?(@set) end it "returns an Enumerator when not passed a block" do enum = @set.each - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) ret = [] enum.each { |x| ret << x } diff --git a/spec/ruby/core/set/empty_spec.rb b/spec/ruby/core/set/empty_spec.rb index 4b55658e20fa9c..c71f2ce18da7a9 100644 --- a/spec/ruby/core/set/empty_spec.rb +++ b/spec/ruby/core/set/empty_spec.rb @@ -2,8 +2,8 @@ describe "Set#empty?" do it "returns true if self is empty" do - Set[].empty?.should be_true - Set[1].empty?.should be_false - Set[1,2,3].empty?.should be_false + Set[].empty?.should == true + Set[1].empty?.should == false + Set[1,2,3].empty?.should == false end end diff --git a/spec/ruby/core/set/eql_spec.rb b/spec/ruby/core/set/eql_spec.rb index 4ad5c3aa5a1459..6862ed4edad592 100644 --- a/spec/ruby/core/set/eql_spec.rb +++ b/spec/ruby/core/set/eql_spec.rb @@ -2,13 +2,13 @@ describe "Set#eql?" do it "returns true when the passed argument is a Set and contains the same elements" do - Set[].should eql(Set[]) - Set[1, 2, 3].should eql(Set[1, 2, 3]) - Set[1, 2, 3].should eql(Set[3, 2, 1]) - Set["a", :b, ?c].should eql(Set[?c, :b, "a"]) + Set[].should.eql?(Set[]) + Set[1, 2, 3].should.eql?(Set[1, 2, 3]) + Set[1, 2, 3].should.eql?(Set[3, 2, 1]) + Set["a", :b, ?c].should.eql?(Set[?c, :b, "a"]) - Set[1, 2, 3].should_not eql(Set[1.0, 2, 3]) - Set[1, 2, 3].should_not eql(Set[2, 3]) - Set[1, 2, 3].should_not eql(Set[]) + Set[1, 2, 3].should_not.eql?(Set[1.0, 2, 3]) + Set[1, 2, 3].should_not.eql?(Set[2, 3]) + Set[1, 2, 3].should_not.eql?(Set[]) end end diff --git a/spec/ruby/core/set/exclusion_spec.rb b/spec/ruby/core/set/exclusion_spec.rb index bbc29afa95e4c0..52ee34fe786a49 100644 --- a/spec/ruby/core/set/exclusion_spec.rb +++ b/spec/ruby/core/set/exclusion_spec.rb @@ -11,7 +11,7 @@ end it "raises an ArgumentError when passed a non-Enumerable" do - -> { @set ^ 3 }.should raise_error(ArgumentError) - -> { @set ^ Object.new }.should raise_error(ArgumentError) + -> { @set ^ 3 }.should.raise(ArgumentError) + -> { @set ^ Object.new }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/set/flatten_merge_spec.rb b/spec/ruby/core/set/flatten_merge_spec.rb index 13cedeead953de..3904d969aeee6d 100644 --- a/spec/ruby/core/set/flatten_merge_spec.rb +++ b/spec/ruby/core/set/flatten_merge_spec.rb @@ -3,7 +3,7 @@ describe "Set#flatten_merge" do ruby_version_is ""..."4.0" do it "is protected" do - Set.should have_protected_instance_method("flatten_merge") + Set.protected_instance_methods(false).should.include?(:flatten_merge) end it "flattens the passed Set and merges it into self" do @@ -18,7 +18,7 @@ set2 = Set[5, 6, 7] set2 << set2 - -> { set1.send(:flatten_merge, set2) }.should raise_error(ArgumentError) + -> { set1.send(:flatten_merge, set2) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/set/flatten_spec.rb b/spec/ruby/core/set/flatten_spec.rb index b26bc8481af58f..ca6323fac8b747 100644 --- a/spec/ruby/core/set/flatten_spec.rb +++ b/spec/ruby/core/set/flatten_spec.rb @@ -7,13 +7,13 @@ set = Set[1, 2, Set[3, 4, Set[5, 6, Set[7, 8]]], 9, 10] flattened_set = set.flatten - flattened_set.should_not equal(set) + flattened_set.should_not.equal?(set) flattened_set.should == Set[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] end it "raises an ArgumentError when self is recursive" do (set = Set[]) << set - -> { set.flatten }.should raise_error(ArgumentError) + -> { set.flatten }.should.raise(ArgumentError) end ruby_version_is ""..."4.0" do @@ -34,16 +34,16 @@ it "returns self when self was modified" do set = Set[1, 2, Set[3, 4]] - set.flatten!.should equal(set) + set.flatten!.should.equal?(set) end it "returns nil when self was not modified" do set = Set[1, 2, 3, 4] - set.flatten!.should be_nil + set.flatten!.should == nil end it "raises an ArgumentError when self is recursive" do (set = Set[]) << set - -> { set.flatten! }.should raise_error(ArgumentError) + -> { set.flatten! }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/set/initialize_spec.rb b/spec/ruby/core/set/initialize_spec.rb index ad9e1bd8c9d4d6..45538b38fb803a 100644 --- a/spec/ruby/core/set/initialize_spec.rb +++ b/spec/ruby/core/set/initialize_spec.rb @@ -2,71 +2,87 @@ describe "Set#initialize" do it "is private" do - Set.should have_private_instance_method(:initialize) + Set.private_instance_methods(false).should.include?(:initialize) end it "adds all elements of the passed Enumerable to self" do s = Set.new([1, 2, 3]) - s.size.should eql(3) - s.should include(1) - s.should include(2) - s.should include(3) + s.size.should.eql?(3) + s.should.include?(1) + s.should.include?(2) + s.should.include?(3) end it "uses #each_entry on the provided Enumerable" do enumerable = MockObject.new('mock-enumerable') enumerable.should_receive(:each_entry).and_yield(1).and_yield(2).and_yield(3) s = Set.new(enumerable) - s.size.should eql(3) - s.should include(1) - s.should include(2) - s.should include(3) + s.size.should.eql?(3) + s.should.include?(1) + s.should.include?(2) + s.should.include?(3) end it "uses #each on the provided Enumerable if it does not respond to #each_entry" do enumerable = MockObject.new('mock-enumerable') enumerable.should_receive(:each).and_yield(1).and_yield(2).and_yield(3) s = Set.new(enumerable) - s.size.should eql(3) - s.should include(1) - s.should include(2) - s.should include(3) + s.size.should.eql?(3) + s.should.include?(1) + s.should.include?(2) + s.should.include?(3) end it "raises if the provided Enumerable does not respond to #each_entry or #each" do enumerable = MockObject.new('mock-enumerable') - -> { Set.new(enumerable) }.should raise_error(ArgumentError, "value must be enumerable") + -> { Set.new(enumerable) }.should.raise(ArgumentError, "value must be enumerable") end it "should initialize with empty array and set" do s = Set.new([]) - s.size.should eql(0) + s.size.should.eql?(0) s = Set.new({}) - s.size.should eql(0) + s.size.should.eql?(0) end it "preprocesses all elements by a passed block before adding to self" do s = Set.new([1, 2, 3]) { |x| x * x } - s.size.should eql(3) - s.should include(1) - s.should include(4) - s.should include(9) + s.size.should.eql?(3) + s.should.include?(1) + s.should.include?(4) + s.should.include?(9) end it "should initialize with empty array and block" do s = Set.new([]) { |x| x * x } - s.size.should eql(0) + s.size.should.eql?(0) end it "should initialize with empty set and block" do s = Set.new(Set.new) { |x| x * x } - s.size.should eql(0) + s.size.should.eql?(0) + end + + it "should initialize with set" do + o = Set.new([1, 2]) + s = Set.new(o) + s.size.should.eql?(2) + s.should.include?(1) + s.should.include?(2) + end + + it "should initialize with set and block" do + o = Set.new([1, 2]) + s = Set.new(o) { |e| e + 2 } + s.size.should.eql?(2) + s.should.include?(3) + s.should.include?(4) end it "should initialize with just block" do s = Set.new { |x| x * x } - s.size.should eql(0) - s.should eql(Set.new) + s.size.should.eql?(0) + s.should.eql?(Set.new) end end diff --git a/spec/ruby/core/set/intersect_spec.rb b/spec/ruby/core/set/intersect_spec.rb index 0736dea5fd0580..d04a1af4416117 100644 --- a/spec/ruby/core/set/intersect_spec.rb +++ b/spec/ruby/core/set/intersect_spec.rb @@ -12,11 +12,11 @@ context "when comparing to a Set-like object" do it "returns true when a Set has at least one element in common with a Set-like object" do - Set[1, 2].intersect?(SetSpecs::SetLike.new([2, 3])).should be_true + Set[1, 2].intersect?(SetSpecs::SetLike.new([2, 3])).should == true end it "returns false when a Set has no element in common with a Set-like object" do - Set[1, 2].intersect?(SetSpecs::SetLike.new([3, 4])).should be_false + Set[1, 2].intersect?(SetSpecs::SetLike.new([3, 4])).should == false end end end diff --git a/spec/ruby/core/set/keep_if_spec.rb b/spec/ruby/core/set/keep_if_spec.rb index d6abdd6adc6003..7ca5d0cd43978e 100644 --- a/spec/ruby/core/set/keep_if_spec.rb +++ b/spec/ruby/core/set/keep_if_spec.rb @@ -13,25 +13,25 @@ it "keeps every element from self for which the passed block returns true" do @set.keep_if { |x| x.size != 3 } - @set.size.should eql(1) + @set.size.should.eql?(1) - @set.should_not include("one") - @set.should_not include("two") - @set.should include("three") + @set.should_not.include?("one") + @set.should_not.include?("two") + @set.should.include?("three") end it "returns self" do - @set.keep_if {}.should equal(@set) + @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.should.instance_of?(Enumerator) enum.each { |x| x.size != 3 } - @set.should_not include("one") - @set.should_not include("two") - @set.should include("three") + @set.should_not.include?("one") + @set.should_not.include?("two") + @set.should.include?("three") end end diff --git a/spec/ruby/core/set/merge_spec.rb b/spec/ruby/core/set/merge_spec.rb index bf945cdcc02238..a2c1a7e7069a01 100644 --- a/spec/ruby/core/set/merge_spec.rb +++ b/spec/ruby/core/set/merge_spec.rb @@ -8,18 +8,18 @@ it "returns self" do set = Set[1, 2] - set.merge([3, 4]).should equal(set) + set.merge([3, 4]).should.equal?(set) end it "raises an ArgumentError when passed a non-Enumerable" do - -> { Set[1, 2].merge(1) }.should raise_error(ArgumentError) - -> { Set[1, 2].merge(Object.new) }.should raise_error(ArgumentError) + -> { Set[1, 2].merge(1) }.should.raise(ArgumentError) + -> { Set[1, 2].merge(Object.new) }.should.raise(ArgumentError) end it "raises RuntimeError when called during iteration" do set = Set[:a, :b] set.each do |_m| - -> { set.merge([1, 2]) }.should raise_error(RuntimeError, /iteration/) + -> { set.merge([1, 2]) }.should.raise(RuntimeError, /iteration/) end end diff --git a/spec/ruby/core/set/proper_subset_spec.rb b/spec/ruby/core/set/proper_subset_spec.rb index 6f99447019b852..3fd27da131d442 100644 --- a/spec/ruby/core/set/proper_subset_spec.rb +++ b/spec/ruby/core/set/proper_subset_spec.rb @@ -8,28 +8,28 @@ end it "returns true if passed a Set that self is a proper subset of" do - Set[].proper_subset?(@set).should be_true - Set[].proper_subset?(Set[1, 2, 3]).should be_true - Set[].proper_subset?(Set["a", :b, ?c]).should be_true + Set[].proper_subset?(@set).should == true + Set[].proper_subset?(Set[1, 2, 3]).should == true + Set[].proper_subset?(Set["a", :b, ?c]).should == true - Set[1, 2, 3].proper_subset?(@set).should be_true - Set[1, 3].proper_subset?(@set).should be_true - Set[1, 2].proper_subset?(@set).should be_true - Set[1].proper_subset?(@set).should be_true + Set[1, 2, 3].proper_subset?(@set).should == true + Set[1, 3].proper_subset?(@set).should == true + Set[1, 2].proper_subset?(@set).should == true + Set[1].proper_subset?(@set).should == true - Set[5].proper_subset?(@set).should be_false - Set[1, 5].proper_subset?(@set).should be_false - Set[nil].proper_subset?(@set).should be_false - Set["test"].proper_subset?(@set).should be_false + Set[5].proper_subset?(@set).should == false + Set[1, 5].proper_subset?(@set).should == false + Set[nil].proper_subset?(@set).should == false + Set["test"].proper_subset?(@set).should == false - @set.proper_subset?(@set).should be_false - Set[].proper_subset?(Set[]).should be_false + @set.proper_subset?(@set).should == false + Set[].proper_subset?(Set[]).should == false end it "raises an ArgumentError when passed a non-Set" do - -> { Set[].proper_subset?([]) }.should raise_error(ArgumentError) - -> { Set[].proper_subset?(1) }.should raise_error(ArgumentError) - -> { Set[].proper_subset?("test") }.should raise_error(ArgumentError) - -> { Set[].proper_subset?(Object.new) }.should raise_error(ArgumentError) + -> { Set[].proper_subset?([]) }.should.raise(ArgumentError) + -> { Set[].proper_subset?(1) }.should.raise(ArgumentError) + -> { Set[].proper_subset?("test") }.should.raise(ArgumentError) + -> { Set[].proper_subset?(Object.new) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/set/proper_superset_spec.rb b/spec/ruby/core/set/proper_superset_spec.rb index dc1e87e2308e67..e95c67ef0e5dc6 100644 --- a/spec/ruby/core/set/proper_superset_spec.rb +++ b/spec/ruby/core/set/proper_superset_spec.rb @@ -7,35 +7,35 @@ end it "returns true if passed a Set that self is a proper superset of" do - @set.proper_superset?(Set[]).should be_true - Set[1, 2, 3].proper_superset?(Set[]).should be_true - Set["a", :b, ?c].proper_superset?(Set[]).should be_true + @set.proper_superset?(Set[]).should == true + Set[1, 2, 3].proper_superset?(Set[]).should == true + Set["a", :b, ?c].proper_superset?(Set[]).should == true - @set.proper_superset?(Set[1, 2, 3]).should be_true - @set.proper_superset?(Set[1, 3]).should be_true - @set.proper_superset?(Set[1, 2]).should be_true - @set.proper_superset?(Set[1]).should be_true + @set.proper_superset?(Set[1, 2, 3]).should == true + @set.proper_superset?(Set[1, 3]).should == true + @set.proper_superset?(Set[1, 2]).should == true + @set.proper_superset?(Set[1]).should == true - @set.proper_superset?(Set[5]).should be_false - @set.proper_superset?(Set[1, 5]).should be_false - @set.proper_superset?(Set[nil]).should be_false - @set.proper_superset?(Set["test"]).should be_false + @set.proper_superset?(Set[5]).should == false + @set.proper_superset?(Set[1, 5]).should == false + @set.proper_superset?(Set[nil]).should == false + @set.proper_superset?(Set["test"]).should == false - @set.proper_superset?(@set).should be_false - Set[].proper_superset?(Set[]).should be_false + @set.proper_superset?(@set).should == false + Set[].proper_superset?(Set[]).should == false end it "raises an ArgumentError when passed a non-Set" do - -> { Set[].proper_superset?([]) }.should raise_error(ArgumentError) - -> { Set[].proper_superset?(1) }.should raise_error(ArgumentError) - -> { Set[].proper_superset?("test") }.should raise_error(ArgumentError) - -> { Set[].proper_superset?(Object.new) }.should raise_error(ArgumentError) + -> { Set[].proper_superset?([]) }.should.raise(ArgumentError) + -> { Set[].proper_superset?(1) }.should.raise(ArgumentError) + -> { Set[].proper_superset?("test") }.should.raise(ArgumentError) + -> { Set[].proper_superset?(Object.new) }.should.raise(ArgumentError) end ruby_version_is ""..."4.0" do context "when comparing to a Set-like object" do it "returns true if passed a Set-like object that self is a proper superset of" do - Set[1, 2, 3, 4].proper_superset?(SetSpecs::SetLike.new([1, 2, 3])).should be_true + Set[1, 2, 3, 4].proper_superset?(SetSpecs::SetLike.new([1, 2, 3])).should == true end end end diff --git a/spec/ruby/core/set/reject_spec.rb b/spec/ruby/core/set/reject_spec.rb index 91d02934158288..b00a36812b946e 100644 --- a/spec/ruby/core/set/reject_spec.rb +++ b/spec/ruby/core/set/reject_spec.rb @@ -13,29 +13,29 @@ 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.size.should.eql?(1) - @set.should_not include("one") - @set.should_not include("two") - @set.should include("three") + @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) + @set.reject! { |x| true }.should.equal?(@set) end it "returns nil when self was not modified" do - @set.reject! { |x| false }.should be_nil + @set.reject! { |x| false }.should == nil end it "returns an Enumerator when passed no block" do enum = @set.reject! - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each { |x| x.size == 3 } - @set.should_not include("one") - @set.should_not include("two") - @set.should include("three") + @set.should_not.include?("one") + @set.should_not.include?("two") + @set.should.include?("three") end end diff --git a/spec/ruby/core/set/replace_spec.rb b/spec/ruby/core/set/replace_spec.rb index c66a2d0ec3686a..2a51a024dcb27a 100644 --- a/spec/ruby/core/set/replace_spec.rb +++ b/spec/ruby/core/set/replace_spec.rb @@ -13,7 +13,7 @@ it "raises RuntimeError when called during iteration" do set = Set[:a, :b, :c, :d, :e, :f] set.each do |_m| - -> { set.replace(Set[1, 2, 3]) }.should raise_error(RuntimeError, /iteration/) + -> { set.replace(Set[1, 2, 3]) }.should.raise(RuntimeError, /iteration/) end set.should == Set[:a, :b, :c, :d, :e, :f] end diff --git a/spec/ruby/core/set/shared/add.rb b/spec/ruby/core/set/shared/add.rb index 9e797f5df96c2f..8d6d83434f52e4 100644 --- a/spec/ruby/core/set/shared/add.rb +++ b/spec/ruby/core/set/shared/add.rb @@ -5,10 +5,10 @@ it "adds the passed Object to self" do @set.send(@method, "dog") - @set.should include("dog") + @set.should.include?("dog") end it "returns self" do - @set.send(@method, "dog").should equal(@set) + @set.send(@method, "dog").should.equal?(@set) end end diff --git a/spec/ruby/core/set/shared/collect.rb b/spec/ruby/core/set/shared/collect.rb index bc58c231be8d63..ad5c5afa590b04 100644 --- a/spec/ruby/core/set/shared/collect.rb +++ b/spec/ruby/core/set/shared/collect.rb @@ -10,7 +10,7 @@ end it "returns self" do - @set.send(@method) { |x| x }.should equal(@set) + @set.send(@method) { |x| x }.should.equal?(@set) end it "replaces self with the return values of the block" do diff --git a/spec/ruby/core/set/shared/difference.rb b/spec/ruby/core/set/shared/difference.rb index f88987ed2aa03b..8a17056a823862 100644 --- a/spec/ruby/core/set/shared/difference.rb +++ b/spec/ruby/core/set/shared/difference.rb @@ -9,7 +9,7 @@ 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) + -> { @set.send(@method, 1) }.should.raise(ArgumentError) + -> { @set.send(@method, Object.new) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/set/shared/include.rb b/spec/ruby/core/set/shared/include.rb index b4d95cde248ed8..82755ccf593313 100644 --- a/spec/ruby/core/set/shared/include.rb +++ b/spec/ruby/core/set/shared/include.rb @@ -1,8 +1,8 @@ describe :set_include, shared: true do it "returns true when self contains the passed Object" do set = Set[:a, :b, :c] - set.send(@method, :a).should be_true - set.send(@method, :e).should be_false + set.send(@method, :a).should == true + set.send(@method, :e).should == false end describe "member equality" do diff --git a/spec/ruby/core/set/shared/inspect.rb b/spec/ruby/core/set/shared/inspect.rb index a90af66c980dbf..31bd8accfd0ec7 100644 --- a/spec/ruby/core/set/shared/inspect.rb +++ b/spec/ruby/core/set/shared/inspect.rb @@ -1,10 +1,10 @@ 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) - Set[1, 2, 3].send(@method).should be_kind_of(String) - Set["1", "2", "3"].send(@method).should be_kind_of(String) - Set[:a, "b", Set[?c]].send(@method).should be_kind_of(String) + Set[].send(@method).should.is_a?(String) + Set[nil, false, true].send(@method).should.is_a?(String) + Set[1, 2, 3].send(@method).should.is_a?(String) + Set["1", "2", "3"].send(@method).should.is_a?(String) + Set[:a, "b", Set[?c]].send(@method).should.is_a?(String) end ruby_version_is "4.0" do @@ -20,7 +20,7 @@ end it "puts spaces between the elements" do - Set["1", "2"].send(@method).should include('", "') + Set["1", "2"].send(@method).should.include?('", "') end ruby_version_is "4.0" do @@ -28,8 +28,8 @@ set1 = Set[] set2 = Set[set1] set1 << set2 - set1.send(@method).should be_kind_of(String) - set1.send(@method).should include("Set[...]") + set1.send(@method).should.is_a?(String) + set1.send(@method).should.include?("Set[...]") end end @@ -38,8 +38,8 @@ set1 = Set[] set2 = Set[set1] set1 << set2 - set1.send(@method).should be_kind_of(String) - set1.send(@method).should include("#") + set1.send(@method).should.is_a?(String) + set1.send(@method).should.include?("#") end end end diff --git a/spec/ruby/core/set/shared/intersection.rb b/spec/ruby/core/set/shared/intersection.rb index 5ae4199c941894..978a4924ef86d2 100644 --- a/spec/ruby/core/set/shared/intersection.rb +++ b/spec/ruby/core/set/shared/intersection.rb @@ -9,7 +9,7 @@ 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) + -> { @set.send(@method, 1) }.should.raise(ArgumentError) + -> { @set.send(@method, Object.new) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/set/shared/select.rb b/spec/ruby/core/set/shared/select.rb index 467b236ed39e94..0d4a53fffd1c61 100644 --- a/spec/ruby/core/set/shared/select.rb +++ b/spec/ruby/core/set/shared/select.rb @@ -13,29 +13,29 @@ it "keeps every element from self for which the passed block returns true" do @set.send(@method) { |x| x.size != 3 } - @set.size.should eql(1) + @set.size.should.eql?(1) - @set.should_not include("one") - @set.should_not include("two") - @set.should include("three") + @set.should_not.include?("one") + @set.should_not.include?("two") + @set.should.include?("three") end it "returns self when self was modified" do - @set.send(@method) { false }.should equal(@set) + @set.send(@method) { false }.should.equal?(@set) end it "returns nil when self was not modified" do - @set.send(@method) { true }.should be_nil + @set.send(@method) { true }.should == nil end it "returns an Enumerator when passed no block" do enum = @set.send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each { |x| x.size != 3 } - @set.should_not include("one") - @set.should_not include("two") - @set.should include("three") + @set.should_not.include?("one") + @set.should_not.include?("two") + @set.should.include?("three") end end diff --git a/spec/ruby/core/set/shared/union.rb b/spec/ruby/core/set/shared/union.rb index 314f0e852db39c..dddf1716e5e3f3 100644 --- a/spec/ruby/core/set/shared/union.rb +++ b/spec/ruby/core/set/shared/union.rb @@ -9,7 +9,7 @@ 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) + -> { @set.send(@method, 1) }.should.raise(ArgumentError) + -> { @set.send(@method, Object.new) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/set/sortedset/sortedset_spec.rb b/spec/ruby/core/set/sortedset/sortedset_spec.rb index f3c1ec058d80ac..c8f65f08516587 100644 --- a/spec/ruby/core/set/sortedset/sortedset_spec.rb +++ b/spec/ruby/core/set/sortedset/sortedset_spec.rb @@ -5,7 +5,7 @@ it "raises error including message that it has been extracted from the set stdlib" do -> { SortedSet - }.should raise_error(RuntimeError) { |e| + }.should.raise(RuntimeError) { |e| e.message.should.include?("The `SortedSet` class has been extracted from the `set` library") } end diff --git a/spec/ruby/core/set/subset_spec.rb b/spec/ruby/core/set/subset_spec.rb index da80d174da4fa1..81869d4993b852 100644 --- a/spec/ruby/core/set/subset_spec.rb +++ b/spec/ruby/core/set/subset_spec.rb @@ -8,28 +8,28 @@ end it "returns true if passed a Set that is equal to self or self is a subset of" do - @set.subset?(@set).should be_true - Set[].subset?(Set[]).should be_true + @set.subset?(@set).should == true + Set[].subset?(Set[]).should == true - Set[].subset?(@set).should be_true - Set[].subset?(Set[1, 2, 3]).should be_true - Set[].subset?(Set["a", :b, ?c]).should be_true + Set[].subset?(@set).should == true + Set[].subset?(Set[1, 2, 3]).should == true + Set[].subset?(Set["a", :b, ?c]).should == true - Set[1, 2, 3].subset?(@set).should be_true - Set[1, 3].subset?(@set).should be_true - Set[1, 2].subset?(@set).should be_true - Set[1].subset?(@set).should be_true + Set[1, 2, 3].subset?(@set).should == true + Set[1, 3].subset?(@set).should == true + Set[1, 2].subset?(@set).should == true + Set[1].subset?(@set).should == true - Set[5].subset?(@set).should be_false - Set[1, 5].subset?(@set).should be_false - Set[nil].subset?(@set).should be_false - Set["test"].subset?(@set).should be_false + Set[5].subset?(@set).should == false + Set[1, 5].subset?(@set).should == false + Set[nil].subset?(@set).should == false + Set["test"].subset?(@set).should == false end it "raises an ArgumentError when passed a non-Set" do - -> { Set[].subset?([]) }.should raise_error(ArgumentError) - -> { Set[].subset?(1) }.should raise_error(ArgumentError) - -> { Set[].subset?("test") }.should raise_error(ArgumentError) - -> { Set[].subset?(Object.new) }.should raise_error(ArgumentError) + -> { Set[].subset?([]) }.should.raise(ArgumentError) + -> { Set[].subset?(1) }.should.raise(ArgumentError) + -> { Set[].subset?("test") }.should.raise(ArgumentError) + -> { Set[].subset?(Object.new) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/set/superset_spec.rb b/spec/ruby/core/set/superset_spec.rb index 9b3df2d047d4c0..7e7db2b1791e99 100644 --- a/spec/ruby/core/set/superset_spec.rb +++ b/spec/ruby/core/set/superset_spec.rb @@ -7,35 +7,35 @@ end it "returns true if passed a Set that equals self or self is a proper superset of" do - @set.superset?(@set).should be_true - Set[].superset?(Set[]).should be_true + @set.superset?(@set).should == true + Set[].superset?(Set[]).should == true - @set.superset?(Set[]).should be_true - Set[1, 2, 3].superset?(Set[]).should be_true - Set["a", :b, ?c].superset?(Set[]).should be_true + @set.superset?(Set[]).should == true + Set[1, 2, 3].superset?(Set[]).should == true + Set["a", :b, ?c].superset?(Set[]).should == true - @set.superset?(Set[1, 2, 3]).should be_true - @set.superset?(Set[1, 3]).should be_true - @set.superset?(Set[1, 2]).should be_true - @set.superset?(Set[1]).should be_true + @set.superset?(Set[1, 2, 3]).should == true + @set.superset?(Set[1, 3]).should == true + @set.superset?(Set[1, 2]).should == true + @set.superset?(Set[1]).should == true - @set.superset?(Set[5]).should be_false - @set.superset?(Set[1, 5]).should be_false - @set.superset?(Set[nil]).should be_false - @set.superset?(Set["test"]).should be_false + @set.superset?(Set[5]).should == false + @set.superset?(Set[1, 5]).should == false + @set.superset?(Set[nil]).should == false + @set.superset?(Set["test"]).should == false end it "raises an ArgumentError when passed a non-Set" do - -> { Set[].superset?([]) }.should raise_error(ArgumentError) - -> { Set[].superset?(1) }.should raise_error(ArgumentError) - -> { Set[].superset?("test") }.should raise_error(ArgumentError) - -> { Set[].superset?(Object.new) }.should raise_error(ArgumentError) + -> { Set[].superset?([]) }.should.raise(ArgumentError) + -> { Set[].superset?(1) }.should.raise(ArgumentError) + -> { Set[].superset?("test") }.should.raise(ArgumentError) + -> { Set[].superset?(Object.new) }.should.raise(ArgumentError) end ruby_version_is ""..."4.0" do context "when comparing to a Set-like object" do it "returns true if passed a Set-like object that self is a superset of" do - Set[1, 2, 3, 4].superset?(SetSpecs::SetLike.new([1, 2, 3])).should be_true + Set[1, 2, 3, 4].superset?(SetSpecs::SetLike.new([1, 2, 3])).should == true end end end diff --git a/spec/ruby/core/signal/signame_spec.rb b/spec/ruby/core/signal/signame_spec.rb index adfe895d97fbbd..82f040a6f90133 100644 --- a/spec/ruby/core/signal/signame_spec.rb +++ b/spec/ruby/core/signal/signame_spec.rb @@ -16,13 +16,13 @@ end it "raises a TypeError when the passed argument can't be coerced to Integer" do - -> { Signal.signame("hello") }.should raise_error(TypeError) + -> { Signal.signame("hello") }.should.raise(TypeError) end it "raises a TypeError when the passed argument responds to #to_int but does not return an Integer" do obj = mock('signal') obj.should_receive(:to_int).and_return('not an int') - -> { Signal.signame(obj) }.should raise_error(TypeError) + -> { Signal.signame(obj) }.should.raise(TypeError) end platform_is_not :windows do diff --git a/spec/ruby/core/signal/trap_spec.rb b/spec/ruby/core/signal/trap_spec.rb index 6d654a99be6d2c..5d3105fee8d297 100644 --- a/spec/ruby/core/signal/trap_spec.rb +++ b/spec/ruby/core/signal/trap_spec.rb @@ -14,7 +14,7 @@ end it "returns the previous handler" do - Signal.trap(:HUP, @saved_trap).should equal(@proc) + Signal.trap(:HUP, @saved_trap).should.equal?(@proc) end it "accepts a block" do @@ -97,7 +97,7 @@ -> { Process.kill :HUP, Process.pid loop { Thread.pass } - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end it "accepts a non-callable that becomes callable when used" do @@ -134,7 +134,7 @@ Process.kill :HUP, Process.pid Thread.pass until done - ScratchPad.recorded.should be_true + ScratchPad.recorded.should == true end it "registers an handler doing nothing with :IGNORE" do @@ -158,7 +158,7 @@ it "ignores the signal when passed nil" do Signal.trap :HUP, nil - Signal.trap(:HUP, @saved_trap).should be_nil + Signal.trap(:HUP, @saved_trap).should == nil end it "accepts :DEFAULT in place of a proc" do @@ -203,53 +203,53 @@ it "accepts long names as Strings" do Signal.trap "SIGHUP", @proc - Signal.trap("SIGHUP", @saved_trap).should equal(@proc) + Signal.trap("SIGHUP", @saved_trap).should.equal?(@proc) end it "accepts short names as Strings" do Signal.trap "HUP", @proc - Signal.trap("HUP", @saved_trap).should equal(@proc) + Signal.trap("HUP", @saved_trap).should.equal?(@proc) end it "accepts long names as Symbols" do Signal.trap :SIGHUP, @proc - Signal.trap(:SIGHUP, @saved_trap).should equal(@proc) + Signal.trap(:SIGHUP, @saved_trap).should.equal?(@proc) end it "accepts short names as Symbols" do Signal.trap :HUP, @proc - Signal.trap(:HUP, @saved_trap).should equal(@proc) + Signal.trap(:HUP, @saved_trap).should.equal?(@proc) end it "calls #to_str on an object to convert to a String" do obj = mock("signal") obj.should_receive(:to_str).exactly(2).times.and_return("HUP") Signal.trap obj, @proc - Signal.trap(obj, @saved_trap).should equal(@proc) + Signal.trap(obj, @saved_trap).should.equal?(@proc) end it "accepts Integer values" do hup = Signal.list["HUP"] Signal.trap hup, @proc - Signal.trap(hup, @saved_trap).should equal(@proc) + Signal.trap(hup, @saved_trap).should.equal?(@proc) end it "does not call #to_int on an object to convert to an Integer" do obj = mock("signal") obj.should_not_receive(:to_int) - -> { Signal.trap obj, @proc }.should raise_error(ArgumentError, /bad signal type/) + -> { Signal.trap obj, @proc }.should.raise(ArgumentError, /bad signal type/) end it "raises ArgumentError when passed unknown signal" do - -> { Signal.trap(300) { } }.should raise_error(ArgumentError, "invalid signal number (300)") - -> { Signal.trap("USR10") { } }.should raise_error(ArgumentError, /\Aunsupported signal [`']SIGUSR10'\z/) - -> { Signal.trap("SIGUSR10") { } }.should raise_error(ArgumentError, /\Aunsupported signal [`']SIGUSR10'\z/) + -> { Signal.trap(300) { } }.should.raise(ArgumentError, "invalid signal number (300)") + -> { Signal.trap("USR10") { } }.should.raise(ArgumentError, /\Aunsupported signal [`']SIGUSR10'\z/) + -> { Signal.trap("SIGUSR10") { } }.should.raise(ArgumentError, /\Aunsupported signal [`']SIGUSR10'\z/) end it "raises ArgumentError when passed signal is not Integer, String or Symbol" do - -> { Signal.trap(nil) { } }.should raise_error(ArgumentError, "bad signal type NilClass") - -> { Signal.trap(100.0) { } }.should raise_error(ArgumentError, "bad signal type Float") - -> { Signal.trap(Rational(100)) { } }.should raise_error(ArgumentError, "bad signal type Rational") + -> { Signal.trap(nil) { } }.should.raise(ArgumentError, "bad signal type NilClass") + -> { Signal.trap(100.0) { } }.should.raise(ArgumentError, "bad signal type Float") + -> { Signal.trap(Rational(100)) { } }.should.raise(ArgumentError, "bad signal type Rational") end # See man 2 signal @@ -257,8 +257,8 @@ it "raises ArgumentError or Errno::EINVAL for SIG#{signal}" do -> { Signal.trap(signal, -> {}) - }.should raise_error(StandardError) { |e| - [ArgumentError, Errno::EINVAL].should include(e.class) + }.should.raise(StandardError) { |e| + [ArgumentError, Errno::EINVAL].should.include?(e.class) e.message.should =~ /Invalid argument|Signal already used by VM or OS/ } end @@ -268,7 +268,7 @@ it "raises ArgumentError for SIG#{signal} which is reserved by Ruby" do -> { Signal.trap(signal, -> {}) - }.should raise_error(ArgumentError, "can't trap reserved signal: SIG#{signal}") + }.should.raise(ArgumentError, "can't trap reserved signal: SIG#{signal}") end end diff --git a/spec/ruby/core/string/allocate_spec.rb b/spec/ruby/core/string/allocate_spec.rb index 30d5f605947fc0..00dadaf076daa8 100644 --- a/spec/ruby/core/string/allocate_spec.rb +++ b/spec/ruby/core/string/allocate_spec.rb @@ -3,7 +3,7 @@ describe "String.allocate" do it "returns an instance of String" do str = String.allocate - str.should be_an_instance_of(String) + str.should.instance_of?(String) end it "returns a fully-formed String" do diff --git a/spec/ruby/core/string/append_as_bytes_spec.rb b/spec/ruby/core/string/append_as_bytes_spec.rb index def663d5ce2239..feead646150318 100644 --- a/spec/ruby/core/string/append_as_bytes_spec.rb +++ b/spec/ruby/core/string/append_as_bytes_spec.rb @@ -4,7 +4,7 @@ ruby_version_is "3.4" do it "doesn't allow to mutate frozen strings" do str = "hello".freeze - -> { str.append_as_bytes("\xE2\x82") }.should raise_error(FrozenError) + -> { str.append_as_bytes("\xE2\x82") }.should.raise(FrozenError) end it "allows creating broken strings in UTF8" do @@ -54,7 +54,7 @@ to_str.should_not_receive(:to_int) str = +"hello" - -> { str.append_as_bytes(to_str) }.should raise_error(TypeError, "wrong argument type MockObject (expected String or Integer)") + -> { str.append_as_bytes(to_str) }.should.raise(TypeError, "wrong argument type MockObject (expected String or Integer)") end end end diff --git a/spec/ruby/core/string/append_spec.rb b/spec/ruby/core/string/append_spec.rb index 8497ce826229da..e0f71b7c9789be 100644 --- a/spec/ruby/core/string/append_spec.rb +++ b/spec/ruby/core/string/append_spec.rb @@ -8,7 +8,7 @@ it_behaves_like :string_concat_type_coercion, :<< it "raises an ArgumentError when given the incorrect number of arguments" do - -> { "hello".send(:<<) }.should raise_error(ArgumentError) - -> { "hello".send(:<<, "one", "two") }.should raise_error(ArgumentError) + -> { "hello".send(:<<) }.should.raise(ArgumentError) + -> { "hello".send(:<<, "one", "two") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/ascii_only_spec.rb b/spec/ruby/core/string/ascii_only_spec.rb index 88a0559cfda1c2..9af663beb8c37a 100644 --- a/spec/ruby/core/string/ascii_only_spec.rb +++ b/spec/ruby/core/string/ascii_only_spec.rb @@ -12,13 +12,13 @@ end it "returns true if the encoding is US-ASCII" do - "hello".dup.force_encoding(Encoding::US_ASCII).ascii_only?.should be_true - "hello".encode(Encoding::US_ASCII).ascii_only?.should be_true + "hello".dup.force_encoding(Encoding::US_ASCII).ascii_only?.should == true + "hello".encode(Encoding::US_ASCII).ascii_only?.should == true end it "returns true for all single-character UTF-8 Strings" do 0.upto(127) do |n| - n.chr.ascii_only?.should be_true + n.chr.ascii_only?.should == true end end end @@ -27,7 +27,7 @@ it "returns false if the encoding is BINARY" do chr = 128.chr chr.encoding.should == Encoding::BINARY - chr.ascii_only?.should be_false + chr.ascii_only?.should == false end it "returns false if the String contains any non-ASCII characters" do @@ -46,37 +46,37 @@ end it "returns true for the empty String with an ASCII-compatible encoding" do - "".ascii_only?.should be_true - "".encode('UTF-8').ascii_only?.should be_true + "".ascii_only?.should == true + "".encode('UTF-8').ascii_only?.should == true end it "returns false for the empty String with a non-ASCII-compatible encoding" do - "".dup.force_encoding('UTF-16LE').ascii_only?.should be_false - "".encode('UTF-16BE').ascii_only?.should be_false + "".dup.force_encoding('UTF-16LE').ascii_only?.should == false + "".encode('UTF-16BE').ascii_only?.should == false end it "returns false for a non-empty String with non-ASCII-compatible encoding" do - "\x78\x00".dup.force_encoding("UTF-16LE").ascii_only?.should be_false + "\x78\x00".dup.force_encoding("UTF-16LE").ascii_only?.should == false end it "returns false when interpolating non ascii strings" do base = "EU currency is".dup.force_encoding(Encoding::US_ASCII) euro = "\u20AC" interp = "#{base} #{euro}" - euro.ascii_only?.should be_false - base.ascii_only?.should be_true - interp.ascii_only?.should be_false + euro.ascii_only?.should == false + base.ascii_only?.should == true + interp.ascii_only?.should == false end it "returns false after appending non ASCII characters to an empty String" do - ("".dup << "λ").ascii_only?.should be_false + ("".dup << "λ").ascii_only?.should == false end it "returns false when concatenating an ASCII and non-ASCII String" do - "".dup.concat("λ").ascii_only?.should be_false + "".dup.concat("λ").ascii_only?.should == false end it "returns false when replacing an ASCII String with a non-ASCII String" do - "".dup.replace("λ").ascii_only?.should be_false + "".dup.replace("λ").ascii_only?.should == false end end diff --git a/spec/ruby/core/string/b_spec.rb b/spec/ruby/core/string/b_spec.rb index 4b1fafff117806..d181447709e115 100644 --- a/spec/ruby/core/string/b_spec.rb +++ b/spec/ruby/core/string/b_spec.rb @@ -10,7 +10,7 @@ it "returns new string without modifying self" do str = "こんちには" - str.b.should_not equal(str) + str.b.should_not.equal?(str) str.should == "こんちには" end end diff --git a/spec/ruby/core/string/byteindex_spec.rb b/spec/ruby/core/string/byteindex_spec.rb index d420f3f6830c91..f4c6408790725a 100644 --- a/spec/ruby/core/string/byteindex_spec.rb +++ b/spec/ruby/core/string/byteindex_spec.rb @@ -149,7 +149,7 @@ char = "れ".encode Encoding::EUC_JP -> do "あれ".byteindex(char) - end.should raise_error(Encoding::CompatibilityError) + end.should.raise(Encoding::CompatibilityError) end it "handles a substring in a superset encoding" do @@ -255,7 +255,7 @@ end it "returns nil if the Regexp matches the empty string and the offset is out of range" do - "ruby".byteindex(//, 12).should be_nil + "ruby".byteindex(//, 12).should == nil end it "supports \\G which matches at the given start offset" do diff --git a/spec/ruby/core/string/byterindex_spec.rb b/spec/ruby/core/string/byterindex_spec.rb index 983222e35de630..569820463d2f6e 100644 --- a/spec/ruby/core/string/byterindex_spec.rb +++ b/spec/ruby/core/string/byterindex_spec.rb @@ -184,7 +184,7 @@ def obj.method_missing(*args) 5 end end it "raises a TypeError when given offset is nil" do - -> { "str".byterindex("st", nil) }.should raise_error(TypeError) + -> { "str".byterindex("st", nil) }.should.raise(TypeError) end it "handles a substring in a superset encoding" do @@ -338,7 +338,7 @@ def obj.method_missing(*args); 5; end end it "raises a TypeError when given offset is nil" do - -> { "str".byterindex(/../, nil) }.should raise_error(TypeError) + -> { "str".byterindex(/../, nil) }.should.raise(TypeError) end it "returns the reverse byte index of a multibyte character" do diff --git a/spec/ruby/core/string/bytes_spec.rb b/spec/ruby/core/string/bytes_spec.rb index 02151eebbcc678..e6019fb9872aa7 100644 --- a/spec/ruby/core/string/bytes_spec.rb +++ b/spec/ruby/core/string/bytes_spec.rb @@ -9,7 +9,7 @@ end it "returns an Array when no block is given" do - @utf8.bytes.should be_an_instance_of(Array) + @utf8.bytes.should.instance_of?(Array) end it "yields each byte to a block if one is given, returning self" do @@ -23,8 +23,8 @@ end it "returns bytes as Integers" do - @ascii.bytes.to_a.each {|b| b.should be_an_instance_of(Integer)} - @utf8_ascii.bytes { |b| b.should be_an_instance_of(Integer) } + @ascii.bytes.to_a.each {|b| b.should.instance_of?(Integer)} + @utf8_ascii.bytes { |b| b.should.instance_of?(Integer) } end it "agrees with #unpack('C*')" do diff --git a/spec/ruby/core/string/bytesplice_spec.rb b/spec/ruby/core/string/bytesplice_spec.rb index cfd9e3ea9a7f39..3e5e6fe1ee9912 100644 --- a/spec/ruby/core/string/bytesplice_spec.rb +++ b/spec/ruby/core/string/bytesplice_spec.rb @@ -4,15 +4,15 @@ describe "String#bytesplice" do it "raises IndexError when index is less than -bytesize" do - -> { "hello".bytesplice(-6, 0, "xxx") }.should raise_error(IndexError, "index -6 out of string") + -> { "hello".bytesplice(-6, 0, "xxx") }.should.raise(IndexError, "index -6 out of string") end it "raises IndexError when index is greater than bytesize" do - -> { "hello".bytesplice(6, 0, "xxx") }.should raise_error(IndexError, "index 6 out of string") + -> { "hello".bytesplice(6, 0, "xxx") }.should.raise(IndexError, "index 6 out of string") end it "raises IndexError for negative length" do - -> { "abc".bytesplice(0, -2, "") }.should raise_error(IndexError, "negative length -2") + -> { "abc".bytesplice(0, -2, "") }.should.raise(IndexError, "negative length -2") end it "replaces with integer indices" do @@ -24,7 +24,7 @@ end it "raises RangeError when range left boundary is less than -bytesize" do - -> { "hello".bytesplice(-6...-6, "xxx") }.should raise_error(RangeError, "-6...-6 out of range") + -> { "hello".bytesplice(-6...-6, "xxx") }.should.raise(RangeError, "-6...-6 out of range") end it "replaces with ranges" do @@ -39,7 +39,7 @@ end it "raises TypeError when integer index is provided without length argument" do - -> { "hello".bytesplice(0, "xxx") }.should raise_error(TypeError, "wrong argument type Integer (expected Range)") + -> { "hello".bytesplice(0, "xxx") }.should.raise(TypeError, "wrong argument type Integer (expected Range)") end it "replaces on an empty string" do @@ -54,19 +54,19 @@ it "raises when string is frozen" do s = "hello".freeze - -> { s.bytesplice(2, 1, "xxx") }.should raise_error(FrozenError, "can't modify frozen String: \"hello\"") + -> { s.bytesplice(2, 1, "xxx") }.should.raise(FrozenError, "can't modify frozen String: \"hello\"") end it "raises IndexError when str_index is less than -bytesize" do - -> { "hello".bytesplice(2, 1, "HELLO", -6, 0) }.should raise_error(IndexError, "index -6 out of string") + -> { "hello".bytesplice(2, 1, "HELLO", -6, 0) }.should.raise(IndexError, "index -6 out of string") end it "raises IndexError when str_index is greater than bytesize" do - -> { "hello".bytesplice(2, 1, "HELLO", 6, 0) }.should raise_error(IndexError, "index 6 out of string") + -> { "hello".bytesplice(2, 1, "HELLO", 6, 0) }.should.raise(IndexError, "index 6 out of string") end it "raises IndexError for negative str length" do - -> { "abc".bytesplice(0, 1, "", 0, -2) }.should raise_error(IndexError, "negative length -2") + -> { "abc".bytesplice(0, 1, "", 0, -2) }.should.raise(IndexError, "negative length -2") end it "replaces with integer str indices" do @@ -78,7 +78,7 @@ end it "raises RangeError when str range left boundary is less than -bytesize" do - -> { "hello".bytesplice(0..1, "HELLO", -6...-6) }.should raise_error(RangeError, "-6...-6 out of range") + -> { "hello".bytesplice(0..1, "HELLO", -6...-6) }.should.raise(RangeError, "-6...-6 out of range") end it "replaces with str ranges" do @@ -93,7 +93,7 @@ end it "raises ArgumentError when integer str index is provided without str length argument" do - -> { "hello".bytesplice(0, 1, "xxx", 0) }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 2, 3, or 5)") + -> { "hello".bytesplice(0, 1, "xxx", 0) }.should.raise(ArgumentError, "wrong number of arguments (given 4, expected 2, 3, or 5)") end it "replaces on an empty string with str index/length" do @@ -109,7 +109,7 @@ it "raises when string is frozen and str index/length" do s = "hello".freeze - -> { s.bytesplice(2, 1, "xxx", 0, 1) }.should raise_error(FrozenError, "can't modify frozen String: \"hello\"") + -> { s.bytesplice(2, 1, "xxx", 0, 1) }.should.raise(FrozenError, "can't modify frozen String: \"hello\"") end it "replaces on an empty string with str range" do @@ -125,22 +125,22 @@ it "raises when string is frozen and str range" do s = "hello".freeze - -> { s.bytesplice(2..2, "yzx", 0..1) }.should raise_error(FrozenError, "can't modify frozen String: \"hello\"") + -> { s.bytesplice(2..2, "yzx", 0..1) }.should.raise(FrozenError, "can't modify frozen String: \"hello\"") end end describe "String#bytesplice with multibyte characters" do it "raises IndexError when index is out of byte size boundary" do - -> { "こんにちは".bytesplice(-16, 0, "xxx") }.should raise_error(IndexError, "index -16 out of string") + -> { "こんにちは".bytesplice(-16, 0, "xxx") }.should.raise(IndexError, "index -16 out of string") end it "raises IndexError when index is not on a codepoint boundary" do - -> { "こんにちは".bytesplice(1, 0, "xxx") }.should raise_error(IndexError, "offset 1 does not land on character boundary") + -> { "こんにちは".bytesplice(1, 0, "xxx") }.should.raise(IndexError, "offset 1 does not land on character boundary") end it "raises IndexError when length is not matching the codepoint boundary" do - -> { "こんにちは".bytesplice(0, 1, "xxx") }.should raise_error(IndexError, "offset 1 does not land on character boundary") - -> { "こんにちは".bytesplice(0, 2, "xxx") }.should raise_error(IndexError, "offset 2 does not land on character boundary") + -> { "こんにちは".bytesplice(0, 1, "xxx") }.should.raise(IndexError, "offset 1 does not land on character boundary") + -> { "こんにちは".bytesplice(0, 2, "xxx") }.should.raise(IndexError, "offset 2 does not land on character boundary") end it "replaces with integer indices" do @@ -169,14 +169,14 @@ end it "raises when ranges not match codepoint boundaries" do - -> { "こんにちは".bytesplice(0..0, "x") }.should raise_error(IndexError, "offset 1 does not land on character boundary") - -> { "こんにちは".bytesplice(0..1, "x") }.should raise_error(IndexError, "offset 2 does not land on character boundary") + -> { "こんにちは".bytesplice(0..0, "x") }.should.raise(IndexError, "offset 1 does not land on character boundary") + -> { "こんにちは".bytesplice(0..1, "x") }.should.raise(IndexError, "offset 2 does not land on character boundary") # Begin is incorrect - -> { "こんにちは".bytesplice(-4..-1, "x") }.should raise_error(IndexError, "offset 11 does not land on character boundary") - -> { "こんにちは".bytesplice(-5..-1, "x") }.should raise_error(IndexError, "offset 10 does not land on character boundary") + -> { "こんにちは".bytesplice(-4..-1, "x") }.should.raise(IndexError, "offset 11 does not land on character boundary") + -> { "こんにちは".bytesplice(-5..-1, "x") }.should.raise(IndexError, "offset 10 does not land on character boundary") # End is incorrect - -> { "こんにちは".bytesplice(-3..-2, "x") }.should raise_error(IndexError, "offset 14 does not land on character boundary") - -> { "こんにちは".bytesplice(-3..-3, "x") }.should raise_error(IndexError, "offset 13 does not land on character boundary") + -> { "こんにちは".bytesplice(-3..-2, "x") }.should.raise(IndexError, "offset 14 does not land on character boundary") + -> { "こんにちは".bytesplice(-3..-3, "x") }.should.raise(IndexError, "offset 13 does not land on character boundary") end it "deals with a different encoded argument" do @@ -200,16 +200,16 @@ end it "raises IndexError when str_index is out of byte size boundary" do - -> { "こんにちは".bytesplice(3, 3, "こんにちは", -16, 0) }.should raise_error(IndexError, "index -16 out of string") + -> { "こんにちは".bytesplice(3, 3, "こんにちは", -16, 0) }.should.raise(IndexError, "index -16 out of string") end it "raises IndexError when str_index is not on a codepoint boundary" do - -> { "こんにちは".bytesplice(3, 3, "こんにちは", 1, 0) }.should raise_error(IndexError, "offset 1 does not land on character boundary") + -> { "こんにちは".bytesplice(3, 3, "こんにちは", 1, 0) }.should.raise(IndexError, "offset 1 does not land on character boundary") end it "raises IndexError when str_length is not matching the codepoint boundary" do - -> { "こんにちは".bytesplice(3, 3, "こんにちは", 0, 1) }.should raise_error(IndexError, "offset 1 does not land on character boundary") - -> { "こんにちは".bytesplice(3, 3, "こんにちは", 0, 2) }.should raise_error(IndexError, "offset 2 does not land on character boundary") + -> { "こんにちは".bytesplice(3, 3, "こんにちは", 0, 1) }.should.raise(IndexError, "offset 1 does not land on character boundary") + -> { "こんにちは".bytesplice(3, 3, "こんにちは", 0, 2) }.should.raise(IndexError, "offset 2 does not land on character boundary") end it "replaces with integer str indices" do @@ -238,14 +238,14 @@ end it "raises when ranges not match codepoint boundaries in str" do - -> { "こんにちは".bytesplice(3...3, "こ", 0..0) }.should raise_error(IndexError, "offset 1 does not land on character boundary") - -> { "こんにちは".bytesplice(3...3, "こ", 0..1) }.should raise_error(IndexError, "offset 2 does not land on character boundary") + -> { "こんにちは".bytesplice(3...3, "こ", 0..0) }.should.raise(IndexError, "offset 1 does not land on character boundary") + -> { "こんにちは".bytesplice(3...3, "こ", 0..1) }.should.raise(IndexError, "offset 2 does not land on character boundary") # Begin is incorrect - -> { "こんにちは".bytesplice(3...3, "こんにちは", -4..-1) }.should raise_error(IndexError, "offset 11 does not land on character boundary") - -> { "こんにちは".bytesplice(3...3, "こんにちは", -5..-1) }.should raise_error(IndexError, "offset 10 does not land on character boundary") + -> { "こんにちは".bytesplice(3...3, "こんにちは", -4..-1) }.should.raise(IndexError, "offset 11 does not land on character boundary") + -> { "こんにちは".bytesplice(3...3, "こんにちは", -5..-1) }.should.raise(IndexError, "offset 10 does not land on character boundary") # End is incorrect - -> { "こんにちは".bytesplice(3...3, "こんにちは", -3..-2) }.should raise_error(IndexError, "offset 14 does not land on character boundary") - -> { "こんにちは".bytesplice(3...3, "こんにちは", -3..-3) }.should raise_error(IndexError, "offset 13 does not land on character boundary") + -> { "こんにちは".bytesplice(3...3, "こんにちは", -3..-2) }.should.raise(IndexError, "offset 14 does not land on character boundary") + -> { "こんにちは".bytesplice(3...3, "こんにちは", -3..-3) }.should.raise(IndexError, "offset 13 does not land on character boundary") end it "deals with a different encoded argument with str index/length" do diff --git a/spec/ruby/core/string/capitalize_spec.rb b/spec/ruby/core/string/capitalize_spec.rb index 5e59b656c52d56..12b1675c2e06dc 100644 --- a/spec/ruby/core/string/capitalize_spec.rb +++ b/spec/ruby/core/string/capitalize_spec.rb @@ -28,7 +28,7 @@ capitalized.should == "Sset" capitalized.size.should == 4 capitalized.bytesize.should == 4 - capitalized.ascii_only?.should be_true + capitalized.ascii_only?.should == true end end @@ -52,7 +52,7 @@ end it "does not allow any other additional option" do - -> { "iSa".capitalize(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { "iSa".capitalize(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -66,21 +66,21 @@ end it "does not allow any other additional option" do - -> { "iß".capitalize(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { "iß".capitalize(:lithuanian, :ascii) }.should.raise(ArgumentError) end end it "does not allow the :fold option for upcasing" do - -> { "abc".capitalize(:fold) }.should raise_error(ArgumentError) + -> { "abc".capitalize(:fold) }.should.raise(ArgumentError) end it "does not allow invalid options" do - -> { "abc".capitalize(:invalid_option) }.should raise_error(ArgumentError) + -> { "abc".capitalize(:invalid_option) }.should.raise(ArgumentError) end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("hello").capitalize.should be_an_instance_of(String) - StringSpecs::MyString.new("Hello").capitalize.should be_an_instance_of(String) + StringSpecs::MyString.new("hello").capitalize.should.instance_of?(String) + StringSpecs::MyString.new("Hello").capitalize.should.instance_of?(String) end it "returns a String in the same encoding as self" do @@ -91,7 +91,7 @@ describe "String#capitalize!" do it "capitalizes self in place" do a = +"hello" - a.capitalize!.should equal(a) + a.capitalize!.should.equal?(a) a.should == "Hello" end @@ -127,7 +127,7 @@ capitalized.should == "Sset" capitalized.size.should == 4 capitalized.bytesize.should == 4 - capitalized.ascii_only?.should be_true + capitalized.ascii_only?.should == true end end @@ -159,7 +159,7 @@ end it "does not allow any other additional option" do - -> { a = "iSa"; a.capitalize!(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { a = "iSa"; a.capitalize!(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -177,16 +177,16 @@ end it "does not allow any other additional option" do - -> { a = "iß"; a.capitalize!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { a = "iß"; a.capitalize!(:lithuanian, :ascii) }.should.raise(ArgumentError) end end it "does not allow the :fold option for upcasing" do - -> { a = "abc"; a.capitalize!(:fold) }.should raise_error(ArgumentError) + -> { a = "abc"; a.capitalize!(:fold) }.should.raise(ArgumentError) end it "does not allow invalid options" do - -> { a = "abc"; a.capitalize!(:invalid_option) }.should raise_error(ArgumentError) + -> { a = "abc"; a.capitalize!(:invalid_option) }.should.raise(ArgumentError) end it "returns nil when no changes are made" do @@ -201,7 +201,7 @@ it "raises a FrozenError when self is frozen" do ["", "Hello", "hello"].each do |a| a.freeze - -> { a.capitalize! }.should raise_error(FrozenError) + -> { a.capitalize! }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/string/casecmp_spec.rb b/spec/ruby/core/string/casecmp_spec.rb index 81ebea557c740d..90577aaac06472 100644 --- a/spec/ruby/core/string/casecmp_spec.rb +++ b/spec/ruby/core/string/casecmp_spec.rb @@ -26,11 +26,11 @@ end it "returns nil if other can't be converted to a string" do - "abc".casecmp(mock('abc')).should be_nil + "abc".casecmp(mock('abc')).should == nil end it "returns nil if incompatible encodings" do - "あれ".casecmp("れ".encode(Encoding::EUC_JP)).should be_nil + "あれ".casecmp("れ".encode(Encoding::EUC_JP)).should == nil end describe "in UTF-8 mode" do @@ -143,7 +143,7 @@ end it "returns nil if incompatible encodings" do - "あれ".casecmp?("れ".encode(Encoding::EUC_JP)).should be_nil + "あれ".casecmp?("れ".encode(Encoding::EUC_JP)).should == nil end describe 'for UNICODE characters' do @@ -190,11 +190,11 @@ end it "case folds" do - "ß".casecmp?("ss").should be_true + "ß".casecmp?("ss").should == true end it "returns nil if other can't be converted to a string" do - "abc".casecmp?(mock('abc')).should be_nil + "abc".casecmp?(mock('abc')).should == nil end it "returns true for empty strings in different encodings" do diff --git a/spec/ruby/core/string/center_spec.rb b/spec/ruby/core/string/center_spec.rb index 1667b59327d104..ac5b8a2ff3c539 100644 --- a/spec/ruby/core/string/center_spec.rb +++ b/spec/ruby/core/string/center_spec.rb @@ -57,10 +57,10 @@ end it "raises a TypeError when length can't be converted to an integer" do - -> { "hello".center("x") }.should raise_error(TypeError) - -> { "hello".center("x", "y") }.should raise_error(TypeError) - -> { "hello".center([]) }.should raise_error(TypeError) - -> { "hello".center(mock('x')) }.should raise_error(TypeError) + -> { "hello".center("x") }.should.raise(TypeError) + -> { "hello".center("x", "y") }.should.raise(TypeError) + -> { "hello".center([]) }.should.raise(TypeError) + -> { "hello".center(mock('x')) }.should.raise(TypeError) end it "calls #to_str to convert padstr to a String" do @@ -71,23 +71,23 @@ end it "raises a TypeError when padstr can't be converted to a string" do - -> { "hello".center(20, 100) }.should raise_error(TypeError) - -> { "hello".center(20, []) }.should raise_error(TypeError) - -> { "hello".center(20, mock('x')) }.should raise_error(TypeError) + -> { "hello".center(20, 100) }.should.raise(TypeError) + -> { "hello".center(20, []) }.should.raise(TypeError) + -> { "hello".center(20, mock('x')) }.should.raise(TypeError) end it "raises an ArgumentError if padstr is empty" do - -> { "hello".center(10, "") }.should raise_error(ArgumentError) - -> { "hello".center(0, "") }.should raise_error(ArgumentError) + -> { "hello".center(10, "") }.should.raise(ArgumentError) + -> { "hello".center(0, "") }.should.raise(ArgumentError) end it "returns String instances when called on subclasses" do - StringSpecs::MyString.new("").center(10).should be_an_instance_of(String) - StringSpecs::MyString.new("foo").center(10).should be_an_instance_of(String) - StringSpecs::MyString.new("foo").center(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String) + StringSpecs::MyString.new("").center(10).should.instance_of?(String) + StringSpecs::MyString.new("foo").center(10).should.instance_of?(String) + StringSpecs::MyString.new("foo").center(10, StringSpecs::MyString.new("x")).should.instance_of?(String) - "".center(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String) - "foo".center(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String) + "".center(10, StringSpecs::MyString.new("x")).should.instance_of?(String) + "foo".center(10, StringSpecs::MyString.new("x")).should.instance_of?(String) end describe "with width" do @@ -95,7 +95,7 @@ str = "abc".dup.force_encoding Encoding::IBM437 result = str.center 6 result.should == " abc " - result.encoding.should equal(Encoding::IBM437) + result.encoding.should.equal?(Encoding::IBM437) end end @@ -104,14 +104,14 @@ str = "abc".dup.force_encoding Encoding::IBM437 result = str.center 6, "あ" result.should == "あabcああ" - result.encoding.should equal(Encoding::UTF_8) + result.encoding.should.equal?(Encoding::UTF_8) end it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP -> do "あれ".center 5, pat - end.should raise_error(Encoding::CompatibilityError) + end.should.raise(Encoding::CompatibilityError) end end end diff --git a/spec/ruby/core/string/chilled_string_spec.rb b/spec/ruby/core/string/chilled_string_spec.rb index 73d055cbdf2fd0..6a5e846db26c79 100644 --- a/spec/ruby/core/string/chilled_string_spec.rb +++ b/spec/ruby/core/string/chilled_string_spec.rb @@ -73,7 +73,7 @@ -> { -> { input << "mutated" - }.should raise_error(FrozenError) + }.should.raise(FrozenError) }.should_not complain(/literal string will be frozen in the future/) end end @@ -142,7 +142,7 @@ -> { -> { input << "mutated" - }.should raise_error(FrozenError) + }.should.raise(FrozenError) }.should_not complain(/string returned by :chilled\.to_s will be frozen in the future/) end end diff --git a/spec/ruby/core/string/chomp_spec.rb b/spec/ruby/core/string/chomp_spec.rb index d27c84c6f6a33f..3a8550892f5de8 100644 --- a/spec/ruby/core/string/chomp_spec.rb +++ b/spec/ruby/core/string/chomp_spec.rb @@ -22,7 +22,7 @@ it "returns a copy of the String when it is not modified" do str = "abc" - str.chomp.should_not equal(str) + str.chomp.should_not.equal?(str) end it "removes one trailing newline" do @@ -47,7 +47,7 @@ it "returns String instances when called on a subclass" do str = StringSpecs::MyString.new("hello\n").chomp - str.should be_an_instance_of(String) + str.should.instance_of?(String) end it "removes trailing characters that match $/ when it has been assigned a value" do @@ -67,7 +67,7 @@ it "returns a copy of the String" do str = "abc" - str.chomp(nil).should_not equal(str) + str.chomp(nil).should_not.equal?(str) end it "returns an empty String when self is empty" do @@ -133,7 +133,7 @@ it "raises a TypeError if #to_str does not return a String" do arg = mock("string chomp") arg.should_receive(:to_str).and_return(1) - -> { "abc".chomp(arg) }.should raise_error(TypeError) + -> { "abc".chomp(arg) }.should.raise(TypeError) end end @@ -171,11 +171,11 @@ it "modifies self" do str = "abc\n" - str.chomp!.should equal(str) + str.chomp!.should.equal?(str) end it "returns nil if self is not modified" do - "abc".chomp!.should be_nil + "abc".chomp!.should == nil end it "removes one trailing newline" do @@ -191,12 +191,12 @@ end it "returns nil when self is empty" do - "".chomp!.should be_nil + "".chomp!.should == nil end it "returns subclass instances when called on a subclass" do str = StringSpecs::MyString.new("hello\n").chomp! - str.should be_an_instance_of(StringSpecs::MyString) + str.should.instance_of?(StringSpecs::MyString) end it "removes trailing characters that match $/ when it has been assigned a value" do @@ -207,11 +207,11 @@ describe "when passed nil" do it "returns nil" do - "abc\r\n".chomp!(nil).should be_nil + "abc\r\n".chomp!(nil).should == nil end it "returns nil when self is empty" do - "".chomp!(nil).should be_nil + "".chomp!(nil).should == nil end end @@ -225,7 +225,7 @@ end it "does not remove a final carriage return" do - "abc\r".chomp!("").should be_nil + "abc\r".chomp!("").should == nil end it "removes more than one trailing newlines" do @@ -237,7 +237,7 @@ end it "returns nil when self is empty" do - "".chomp!("").should be_nil + "".chomp!("").should == nil end end @@ -255,7 +255,7 @@ end it "returns nil when self is empty" do - "".chomp!("\n").should be_nil + "".chomp!("\n").should == nil end end @@ -269,7 +269,7 @@ it "raises a TypeError if #to_str does not return a String" do arg = mock("string chomp") arg.should_receive(:to_str).and_return(1) - -> { "abc".chomp!(arg) }.should raise_error(TypeError) + -> { "abc".chomp!(arg) }.should.raise(TypeError) end end @@ -279,11 +279,11 @@ end it "returns nil if the argument does not match the trailing characters" do - "abc".chomp!("def").should be_nil + "abc".chomp!("def").should == nil end it "returns nil when self is empty" do - "".chomp!("abc").should be_nil + "".chomp!("abc").should == nil end end @@ -291,15 +291,15 @@ a = "string\n\r" a.freeze - -> { a.chomp! }.should raise_error(FrozenError) + -> { a.chomp! }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen instance when it would not be modified" do a = "string\n\r" a.freeze - -> { a.chomp!(nil) }.should raise_error(FrozenError) - -> { a.chomp!("x") }.should raise_error(FrozenError) + -> { a.chomp!(nil) }.should.raise(FrozenError) + -> { a.chomp!("x") }.should.raise(FrozenError) end end @@ -346,7 +346,7 @@ end it "returns nil when the String is not modified" do - "あれ".chomp!.should be_nil + "あれ".chomp!.should == nil end it "removes the final carriage return, newline from a multibyte String" do diff --git a/spec/ruby/core/string/chop_spec.rb b/spec/ruby/core/string/chop_spec.rb index 99c2c821909ec0..2113da543b1c40 100644 --- a/spec/ruby/core/string/chop_spec.rb +++ b/spec/ruby/core/string/chop_spec.rb @@ -47,11 +47,11 @@ it "returns a new string when applied to an empty string" do s = "" - s.chop.should_not equal(s) + s.chop.should_not.equal?(s) end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("hello\n").chop.should be_an_instance_of(String) + StringSpecs::MyString.new("hello\n").chop.should.instance_of?(String) end it "returns a String in the same encoding as self" do @@ -99,21 +99,21 @@ it "returns self if modifications were made" do str = "hello" - str.chop!.should equal(str) + str.chop!.should.equal?(str) end it "returns nil when called on an empty string" do - "".chop!.should be_nil + "".chop!.should == nil end it "raises a FrozenError on a frozen instance that is modified" do - -> { "string\n\r".freeze.chop! }.should raise_error(FrozenError) + -> { "string\n\r".freeze.chop! }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen instance that would not be modified" do a = "" a.freeze - -> { a.chop! }.should raise_error(FrozenError) + -> { a.chop! }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/chr_spec.rb b/spec/ruby/core/string/chr_spec.rb index 9ed29542e6a60b..26c7d51202ba50 100644 --- a/spec/ruby/core/string/chr_spec.rb +++ b/spec/ruby/core/string/chr_spec.rb @@ -3,11 +3,11 @@ describe "String#chr" do it "returns a copy of self" do s = 'e' - s.should_not equal s.chr + s.should_not.equal? s.chr end it "returns a String" do - 'glark'.chr.should be_an_instance_of(String) + 'glark'.chr.should.instance_of?(String) end it "returns an empty String if self is an empty String" do diff --git a/spec/ruby/core/string/clear_spec.rb b/spec/ruby/core/string/clear_spec.rb index 152986fd0fee9c..d4688d36892579 100644 --- a/spec/ruby/core/string/clear_spec.rb +++ b/spec/ruby/core/string/clear_spec.rb @@ -14,7 +14,7 @@ it "returns self after emptying it" do cleared = @s.clear cleared.should == "" - cleared.should equal @s + cleared.should.equal? @s end it "preserves its encoding" do @@ -32,7 +32,7 @@ it "raises a FrozenError if self is frozen" do @s.freeze - -> { @s.clear }.should raise_error(FrozenError) - -> { "".freeze.clear }.should raise_error(FrozenError) + -> { @s.clear }.should.raise(FrozenError) + -> { "".freeze.clear }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/clone_spec.rb b/spec/ruby/core/string/clone_spec.rb index a2ba2f98776615..2cb289d2c1f102 100644 --- a/spec/ruby/core/string/clone_spec.rb +++ b/spec/ruby/core/string/clone_spec.rb @@ -43,8 +43,8 @@ class << @obj end it "copies frozen state" do - @obj.freeze.clone.frozen?.should be_true - "".freeze.clone.frozen?.should be_true + @obj.freeze.clone.frozen?.should == true + "".freeze.clone.frozen?.should == true end it "does not modify the original string when changing cloned string" do diff --git a/spec/ruby/core/string/codepoints_spec.rb b/spec/ruby/core/string/codepoints_spec.rb index 12a5bf5892bed9..51bd57d127badd 100644 --- a/spec/ruby/core/string/codepoints_spec.rb +++ b/spec/ruby/core/string/codepoints_spec.rb @@ -12,7 +12,7 @@ it "raises an ArgumentError when no block is given if self has an invalid encoding" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.codepoints }.should raise_error(ArgumentError) + s.valid_encoding?.should == false + -> { s.codepoints }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/comparison_spec.rb b/spec/ruby/core/string/comparison_spec.rb index 9db0cff5ee2277..0737c131bbef14 100644 --- a/spec/ruby/core/string/comparison_spec.rb +++ b/spec/ruby/core/string/comparison_spec.rb @@ -85,7 +85,7 @@ # just using it as an indicator. describe "String#<=>" do it "returns nil if its argument provides neither #to_str nor #<=>" do - ("abc" <=> mock('x')).should be_nil + ("abc" <=> mock('x')).should == nil end it "uses the result of calling #to_str for comparison when #to_str is defined" do @@ -107,6 +107,6 @@ def obj.<=>(other); other <=> self; end obj.should_receive(:<=>).once - ("abc" <=> obj).should be_nil + ("abc" <=> obj).should == nil end end diff --git a/spec/ruby/core/string/concat_spec.rb b/spec/ruby/core/string/concat_spec.rb index cbd7df54e2bd0a..0194a357a0dc52 100644 --- a/spec/ruby/core/string/concat_spec.rb +++ b/spec/ruby/core/string/concat_spec.rb @@ -21,7 +21,7 @@ it "returns self when given no arguments" do str = +"hello" - str.concat.should equal(str) + str.concat.should.equal?(str) str.should == "hello" end end diff --git a/spec/ruby/core/string/count_spec.rb b/spec/ruby/core/string/count_spec.rb index e614e901ddbfb0..fd127c6ff21b5f 100644 --- a/spec/ruby/core/string/count_spec.rb +++ b/spec/ruby/core/string/count_spec.rb @@ -23,7 +23,7 @@ end it "raises an ArgumentError when given no arguments" do - -> { "hell yeah".count }.should raise_error(ArgumentError) + -> { "hell yeah".count }.should.raise(ArgumentError) end it "negates sets starting with ^" do @@ -76,8 +76,8 @@ it "raises if the given sequences are invalid" do s = "hel-[()]-lo012^" - -> { s.count("h-e") }.should raise_error(ArgumentError) - -> { s.count("^h-e") }.should raise_error(ArgumentError) + -> { s.count("h-e") }.should.raise(ArgumentError) + -> { s.count("^h-e") }.should.raise(ArgumentError) end it 'returns the number of occurrences of a multi-byte character' do @@ -98,8 +98,8 @@ end it "raises a TypeError when a set arg can't be converted to a string" do - -> { "hello world".count(100) }.should raise_error(TypeError) - -> { "hello world".count([]) }.should raise_error(TypeError) - -> { "hello world".count(mock('x')) }.should raise_error(TypeError) + -> { "hello world".count(100) }.should.raise(TypeError) + -> { "hello world".count([]) }.should.raise(TypeError) + -> { "hello world".count(mock('x')) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/string/crypt_spec.rb b/spec/ruby/core/string/crypt_spec.rb index 06f84c70a46130..924b4d48cfca38 100644 --- a/spec/ruby/core/string/crypt_spec.rb +++ b/spec/ruby/core/string/crypt_spec.rb @@ -15,7 +15,7 @@ end it "raises Errno::EINVAL when the salt is shorter than 29 characters" do - -> { "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHW") }.should raise_error(Errno::EINVAL) + -> { "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHW") }.should.raise(Errno::EINVAL) end it "calls #to_str to converts the salt arg to a String" do @@ -26,9 +26,9 @@ end it "doesn't return subclass instances" do - StringSpecs::MyString.new("mypassword").crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should be_an_instance_of(String) - "mypassword".crypt(StringSpecs::MyString.new("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu")).should be_an_instance_of(String) - StringSpecs::MyString.new("mypassword").crypt(StringSpecs::MyString.new("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu")).should be_an_instance_of(String) + StringSpecs::MyString.new("mypassword").crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should.instance_of?(String) + "mypassword".crypt(StringSpecs::MyString.new("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu")).should.instance_of?(String) + StringSpecs::MyString.new("mypassword").crypt(StringSpecs::MyString.new("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu")).should.instance_of?(String) end end @@ -60,7 +60,7 @@ end it "raises an ArgumentError when the string contains NUL character" do - -> { "poison\0null".crypt("aa") }.should raise_error(ArgumentError) + -> { "poison\0null".crypt("aa") }.should.raise(ArgumentError) end it "calls #to_str to converts the salt arg to a String" do @@ -71,22 +71,22 @@ end it "doesn't return subclass instances" do - StringSpecs::MyString.new("hello").crypt("aa").should be_an_instance_of(String) - "hello".crypt(StringSpecs::MyString.new("aa")).should be_an_instance_of(String) - StringSpecs::MyString.new("hello").crypt(StringSpecs::MyString.new("aa")).should be_an_instance_of(String) + StringSpecs::MyString.new("hello").crypt("aa").should.instance_of?(String) + "hello".crypt(StringSpecs::MyString.new("aa")).should.instance_of?(String) + StringSpecs::MyString.new("hello").crypt(StringSpecs::MyString.new("aa")).should.instance_of?(String) end it "raises an ArgumentError when the salt is shorter than two characters" do - -> { "hello".crypt("") }.should raise_error(ArgumentError) - -> { "hello".crypt("f") }.should raise_error(ArgumentError) - -> { "hello".crypt("\x00\x00") }.should raise_error(ArgumentError) - -> { "hello".crypt("\x00a") }.should raise_error(ArgumentError) - -> { "hello".crypt("a\x00") }.should raise_error(ArgumentError) + -> { "hello".crypt("") }.should.raise(ArgumentError) + -> { "hello".crypt("f") }.should.raise(ArgumentError) + -> { "hello".crypt("\x00\x00") }.should.raise(ArgumentError) + -> { "hello".crypt("\x00a") }.should.raise(ArgumentError) + -> { "hello".crypt("a\x00") }.should.raise(ArgumentError) end end it "raises a type error when the salt arg can't be converted to a string" do - -> { "".crypt(5) }.should raise_error(TypeError) - -> { "".crypt(mock('x')) }.should raise_error(TypeError) + -> { "".crypt(5) }.should.raise(TypeError) + -> { "".crypt(mock('x')) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/string/delete_prefix_spec.rb b/spec/ruby/core/string/delete_prefix_spec.rb index ee7f04490579cc..fc69adcbadf9a2 100644 --- a/spec/ruby/core/string/delete_prefix_spec.rb +++ b/spec/ruby/core/string/delete_prefix_spec.rb @@ -12,13 +12,13 @@ it "returns a copy of the string, when the prefix isn't found" do s = 'hello' r = s.delete_prefix('hello!') - r.should_not equal s + r.should_not.equal? s r.should == s r = s.delete_prefix('ell') - r.should_not equal s + r.should_not.equal? s r.should == s r = s.delete_prefix('') - r.should_not equal s + r.should_not.equal? s r.should == s end @@ -41,7 +41,7 @@ it "returns a String instance when called on a subclass instance" do s = StringSpecs::MyString.new('hello') - s.delete_prefix('hell').should be_an_instance_of(String) + s.delete_prefix('hell').should.instance_of?(String) end it "returns a String in the same encoding as self" do @@ -52,7 +52,7 @@ describe "String#delete_prefix!" do it "removes the found prefix" do s = 'hello' - s.delete_prefix!('hell').should equal(s) + s.delete_prefix!('hell').should.equal?(s) s.should == 'o' end @@ -76,8 +76,8 @@ end it "raises a FrozenError when self is frozen" do - -> { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(FrozenError) - -> { 'hello'.freeze.delete_prefix!('') }.should raise_error(FrozenError) - -> { ''.freeze.delete_prefix!('') }.should raise_error(FrozenError) + -> { 'hello'.freeze.delete_prefix!('hell') }.should.raise(FrozenError) + -> { 'hello'.freeze.delete_prefix!('') }.should.raise(FrozenError) + -> { ''.freeze.delete_prefix!('') }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/delete_spec.rb b/spec/ruby/core/string/delete_spec.rb index 6d359776e45f71..adb5150cff0d73 100644 --- a/spec/ruby/core/string/delete_spec.rb +++ b/spec/ruby/core/string/delete_spec.rb @@ -15,7 +15,7 @@ end it "raises an ArgumentError when given no arguments" do - -> { "hell yeah".delete }.should raise_error(ArgumentError) + -> { "hell yeah".delete }.should.raise(ArgumentError) end it "negates sets starting with ^" do @@ -63,10 +63,10 @@ not_supported_on :opal do xFF = [0xFF].pack('C') range = "\x00 - #{xFF}".force_encoding('utf-8') - -> { "hello".delete(range).should == "" }.should raise_error(ArgumentError) + -> { "hello".delete(range).should == "" }.should.raise(ArgumentError) end - -> { "hello".delete("h-e") }.should raise_error(ArgumentError) - -> { "hello".delete("^h-e") }.should raise_error(ArgumentError) + -> { "hello".delete("h-e") }.should.raise(ArgumentError) + -> { "hello".delete("^h-e") }.should.raise(ArgumentError) end it "tries to convert each set arg to a string using to_str" do @@ -80,13 +80,13 @@ end it "raises a TypeError when one set arg can't be converted to a string" do - -> { "hello world".delete(100) }.should raise_error(TypeError) - -> { "hello world".delete([]) }.should raise_error(TypeError) - -> { "hello world".delete(mock('x')) }.should raise_error(TypeError) + -> { "hello world".delete(100) }.should.raise(TypeError) + -> { "hello world".delete([]) }.should.raise(TypeError) + -> { "hello world".delete(mock('x')) }.should.raise(TypeError) end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("oh no!!!").delete("!").should be_an_instance_of(String) + StringSpecs::MyString.new("oh no!!!").delete("!").should.instance_of?(String) end it "returns a String in the same encoding as self" do @@ -97,7 +97,7 @@ describe "String#delete!" do it "modifies self in place and returns self" do a = "hello" - a.delete!("aeiou", "^e").should equal(a) + a.delete!("aeiou", "^e").should.equal?(a) a.should == "hell" end @@ -111,7 +111,7 @@ a = "hello" a.freeze - -> { a.delete!("") }.should raise_error(FrozenError) - -> { a.delete!("aeiou", "^e") }.should raise_error(FrozenError) + -> { a.delete!("") }.should.raise(FrozenError) + -> { a.delete!("aeiou", "^e") }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/delete_suffix_spec.rb b/spec/ruby/core/string/delete_suffix_spec.rb index 1842d75aa5e1d9..11d8fbbac16c80 100644 --- a/spec/ruby/core/string/delete_suffix_spec.rb +++ b/spec/ruby/core/string/delete_suffix_spec.rb @@ -12,13 +12,13 @@ it "returns a copy of the string, when the suffix isn't found" do s = 'hello' r = s.delete_suffix('!hello') - r.should_not equal s + r.should_not.equal? s r.should == s r = s.delete_suffix('ell') - r.should_not equal s + r.should_not.equal? s r.should == s r = s.delete_suffix('') - r.should_not equal s + r.should_not.equal? s r.should == s end @@ -41,7 +41,7 @@ it "returns a String instance when called on a subclass instance" do s = StringSpecs::MyString.new('hello') - s.delete_suffix('ello').should be_an_instance_of(String) + s.delete_suffix('ello').should.instance_of?(String) end it "returns a String in the same encoding as self" do @@ -52,7 +52,7 @@ describe "String#delete_suffix!" do it "removes the found prefix" do s = 'hello' - s.delete_suffix!('ello').should equal(s) + s.delete_suffix!('ello').should.equal?(s) s.should == 'h' end @@ -76,8 +76,8 @@ end it "raises a FrozenError when self is frozen" do - -> { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(FrozenError) - -> { 'hello'.freeze.delete_suffix!('') }.should raise_error(FrozenError) - -> { ''.freeze.delete_suffix!('') }.should raise_error(FrozenError) + -> { 'hello'.freeze.delete_suffix!('ello') }.should.raise(FrozenError) + -> { 'hello'.freeze.delete_suffix!('') }.should.raise(FrozenError) + -> { ''.freeze.delete_suffix!('') }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/downcase_spec.rb b/spec/ruby/core/string/downcase_spec.rb index 2d260f23f181e4..4f7f44e5d46703 100644 --- a/spec/ruby/core/string/downcase_spec.rb +++ b/spec/ruby/core/string/downcase_spec.rb @@ -24,7 +24,7 @@ downcased.should == "king" downcased.size.should == 4 downcased.bytesize.should == 4 - downcased.ascii_only?.should be_true + downcased.ascii_only?.should == true end end @@ -48,7 +48,7 @@ end it "does not allow any other additional option" do - -> { "İ".downcase(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { "İ".downcase(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -62,7 +62,7 @@ end it "does not allow any other additional option" do - -> { "İS".downcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { "İS".downcase(:lithuanian, :ascii) }.should.raise(ArgumentError) end end @@ -74,18 +74,18 @@ end it "does not allow invalid options" do - -> { "ABC".downcase(:invalid_option) }.should raise_error(ArgumentError) + -> { "ABC".downcase(:invalid_option) }.should.raise(ArgumentError) end it "returns a String instance for subclasses" do - StringSpecs::MyString.new("FOObar").downcase.should be_an_instance_of(String) + StringSpecs::MyString.new("FOObar").downcase.should.instance_of?(String) end end describe "String#downcase!" do it "modifies self in place" do a = "HeLlO" - a.downcase!.should equal(a) + a.downcase!.should.equal?(a) a.should == "hello" end @@ -109,7 +109,7 @@ downcased.should == "king" downcased.size.should == 4 downcased.bytesize.should == 4 - downcased.ascii_only?.should be_true + downcased.ascii_only?.should == true end end @@ -141,7 +141,7 @@ end it "does not allow any other additional option" do - -> { a = "İ"; a.downcase!(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { a = "İ"; a.downcase!(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -159,7 +159,7 @@ end it "does not allow any other additional option" do - -> { a = "İS"; a.downcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { a = "İS"; a.downcase!(:lithuanian, :ascii) }.should.raise(ArgumentError) end end @@ -175,7 +175,7 @@ end it "does not allow invalid options" do - -> { a = "ABC"; a.downcase!(:invalid_option) }.should raise_error(ArgumentError) + -> { a = "ABC"; a.downcase!(:invalid_option) }.should.raise(ArgumentError) end it "returns nil if no modifications were made" do @@ -185,11 +185,11 @@ end it "raises a FrozenError when self is frozen" do - -> { "HeLlo".freeze.downcase! }.should raise_error(FrozenError) - -> { "hello".freeze.downcase! }.should raise_error(FrozenError) + -> { "HeLlo".freeze.downcase! }.should.raise(FrozenError) + -> { "hello".freeze.downcase! }.should.raise(FrozenError) end it "sets the result String encoding to the source String encoding" do - "ABC".downcase.encoding.should equal(Encoding::UTF_8) + "ABC".downcase.encoding.should.equal?(Encoding::UTF_8) end end diff --git a/spec/ruby/core/string/dump_spec.rb b/spec/ruby/core/string/dump_spec.rb index cab8beff5ad72b..176be79db2d6d2 100644 --- a/spec/ruby/core/string/dump_spec.rb +++ b/spec/ruby/core/string/dump_spec.rb @@ -8,7 +8,7 @@ end it "returns a String instance" do - StringSpecs::MyString.new.dump.should be_an_instance_of(String) + StringSpecs::MyString.new.dump.should.instance_of?(String) end it "wraps string with \"" do diff --git a/spec/ruby/core/string/dup_spec.rb b/spec/ruby/core/string/dup_spec.rb index 073802d84b48ba..e367f7a3110b73 100644 --- a/spec/ruby/core/string/dup_spec.rb +++ b/spec/ruby/core/string/dup_spec.rb @@ -21,7 +21,7 @@ it "does not copy singleton methods" do def @obj.special() :the_one end dup = @obj.dup - -> { dup.special }.should raise_error(NameError) + -> { dup.special }.should.raise(NameError) end it "does not copy modules included in the singleton class" do @@ -30,7 +30,7 @@ class << @obj end dup = @obj.dup - -> { dup.repr }.should raise_error(NameError) + -> { dup.repr }.should.raise(NameError) end it "does not copy constants defined in the singleton class" do @@ -39,7 +39,7 @@ class << @obj end dup = @obj.dup - -> { class << dup; CLONE; end }.should raise_error(NameError) + -> { class << dup; CLONE; end }.should.raise(NameError) end it "does not modify the original string when changing dupped string" do diff --git a/spec/ruby/core/string/each_byte_spec.rb b/spec/ruby/core/string/each_byte_spec.rb index 7b3db265ac2f97..1884df416b5f93 100644 --- a/spec/ruby/core/string/each_byte_spec.rb +++ b/spec/ruby/core/string/each_byte_spec.rb @@ -35,13 +35,13 @@ it "returns self" do s = "hello" - (s.each_byte {}).should equal(s) + (s.each_byte {}).should.equal?(s) end describe "when no block is given" do it "returns an enumerator" do enum = "hello".each_byte - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == [104, 101, 108, 108, 111] end diff --git a/spec/ruby/core/string/element_set_spec.rb b/spec/ruby/core/string/element_set_spec.rb index e7599f832c0558..2abc5117aa8de4 100644 --- a/spec/ruby/core/string/element_set_spec.rb +++ b/spec/ruby/core/string/element_set_spec.rb @@ -18,13 +18,13 @@ it "raises an IndexError without changing self if idx is outside of self" do str = "hello" - -> { str[20] = "bam" }.should raise_error(IndexError) + -> { str[20] = "bam" }.should.raise(IndexError) str.should == "hello" - -> { str[-20] = "bam" }.should raise_error(IndexError) + -> { str[-20] = "bam" }.should.raise(IndexError) str.should == "hello" - -> { ""[-1] = "bam" }.should raise_error(IndexError) + -> { ""[-1] = "bam" }.should.raise(IndexError) end # Behaviour is verified by matz in @@ -37,7 +37,7 @@ it "raises IndexError if the string index doesn't match a position in the string" do str = "hello" - -> { str['y'] = "bam" }.should raise_error(IndexError) + -> { str['y'] = "bam" }.should.raise(IndexError) str.should == "hello" end @@ -45,7 +45,7 @@ a = "hello" a.freeze - -> { a[0] = "bam" }.should raise_error(FrozenError) + -> { a[0] = "bam" }.should.raise(FrozenError) end it "calls to_int on index" do @@ -69,17 +69,17 @@ end it "raises a TypeError if other_str can't be converted to a String" do - -> { "test"[1] = [] }.should raise_error(TypeError) - -> { "test"[1] = mock('x') }.should raise_error(TypeError) - -> { "test"[1] = nil }.should raise_error(TypeError) + -> { "test"[1] = [] }.should.raise(TypeError) + -> { "test"[1] = mock('x') }.should.raise(TypeError) + -> { "test"[1] = nil }.should.raise(TypeError) end it "raises a TypeError if passed an Integer replacement" do - -> { "abc"[1] = 65 }.should raise_error(TypeError) + -> { "abc"[1] = 65 }.should.raise(TypeError) end it "raises an IndexError if the index is greater than character size" do - -> { "あれ"[4] = "a" }.should raise_error(IndexError) + -> { "あれ"[4] = "a" }.should.raise(IndexError) end it "calls #to_int to convert the index" do @@ -95,14 +95,14 @@ index = mock("string element set") index.should_receive(:to_int).and_return('1') - -> { "abc"[index] = "d" }.should raise_error(TypeError) + -> { "abc"[index] = "d" }.should.raise(TypeError) end it "raises an IndexError if #to_int returns a value out of range" do index = mock("string element set") index.should_receive(:to_int).and_return(4) - -> { "ab"[index] = "c" }.should raise_error(IndexError) + -> { "ab"[index] = "c" }.should.raise(IndexError) end it "replaces a character with a multibyte character" do @@ -127,7 +127,7 @@ str = " ".force_encoding Encoding::US_ASCII rep = [160].pack('C').force_encoding Encoding::BINARY str[0] = rep - str.encoding.should equal(Encoding::BINARY) + str.encoding.should.equal?(Encoding::BINARY) end it "updates the string to a compatible encoding" do @@ -139,7 +139,7 @@ it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - -> { str[0] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str[0] = rep }.should.raise(Encoding::CompatibilityError) end end @@ -164,7 +164,7 @@ it "raises an IndexError if the search String is not found" do str = "abcde" - -> { str["g"] = "h" }.should raise_error(IndexError) + -> { str["g"] = "h" }.should.raise(IndexError) end it "replaces characters with a multibyte character" do @@ -189,13 +189,13 @@ str = " ".force_encoding Encoding::US_ASCII rep = [160].pack('C').force_encoding Encoding::BINARY str[" "] = rep - str.encoding.should equal(Encoding::BINARY) + str.encoding.should.equal?(Encoding::BINARY) end it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - -> { str["れ"] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str["れ"] = rep }.should.raise(Encoding::CompatibilityError) end end @@ -208,7 +208,7 @@ it "raises IndexError if the regexp index doesn't match a position in the string" do str = "hello" - -> { str[/y/] = "bam" }.should raise_error(IndexError) + -> { str[/y/] = "bam" }.should.raise(IndexError) str.should == "hello" end @@ -225,7 +225,7 @@ rep = mock("string element set regexp") rep.should_not_receive(:to_str) - -> { "abc"[/def/] = rep }.should raise_error(IndexError) + -> { "abc"[/def/] = rep }.should.raise(IndexError) end describe "with 3 arguments" do @@ -242,7 +242,7 @@ ref = mock("string element set regexp ref") ref.should_receive(:to_int).and_return(nil) - -> { "abc"[/a(b)/, ref] = "x" }.should raise_error(TypeError) + -> { "abc"[/a(b)/, ref] = "x" }.should.raise(TypeError) end it "uses the 2nd of 3 arguments as which capture should be replaced" do @@ -261,20 +261,20 @@ rep = mock("string element set regexp") rep.should_not_receive(:to_str) - -> { "abc"[/a(b)/, 2] = rep }.should raise_error(IndexError) + -> { "abc"[/a(b)/, 2] = rep }.should.raise(IndexError) end it "raises IndexError if the specified capture isn't available" do str = "aaa bbb ccc" - -> { str[/a (bbb) c/, 2] = "ddd" }.should raise_error(IndexError) - -> { str[/a (bbb) c/, -2] = "ddd" }.should raise_error(IndexError) + -> { str[/a (bbb) c/, 2] = "ddd" }.should.raise(IndexError) + -> { str[/a (bbb) c/, -2] = "ddd" }.should.raise(IndexError) end describe "when the optional capture does not match" do it "raises an IndexError before setting the replacement" do str1 = "a b c" str2 = str1.dup - -> { str2[/a (b) (Z)?/, 2] = "d" }.should raise_error(IndexError) + -> { str2[/a (b) (Z)?/, 2] = "d" }.should.raise(IndexError) str2.should == str1 end end @@ -302,13 +302,13 @@ str = " ".force_encoding Encoding::US_ASCII rep = [160].pack('C').force_encoding Encoding::BINARY str[/ /] = rep - str.encoding.should equal(Encoding::BINARY) + str.encoding.should.equal?(Encoding::BINARY) end it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - -> { str[/れ/] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str[/れ/] = rep }.should.raise(Encoding::CompatibilityError) end end @@ -358,11 +358,11 @@ end it "raises a RangeError if negative Range begin is out of range" do - -> { "abc"[-4..-2] = "x" }.should raise_error(RangeError, "-4..-2 out of range") + -> { "abc"[-4..-2] = "x" }.should.raise(RangeError, "-4..-2 out of range") end it "raises a RangeError if positive Range begin is greater than String size" do - -> { "abc"[4..2] = "x" }.should raise_error(RangeError, "4..2 out of range") + -> { "abc"[4..2] = "x" }.should.raise(RangeError, "4..2 out of range") end it "uses the Range end as an index rather than a count" do @@ -423,13 +423,13 @@ str = " ".force_encoding Encoding::US_ASCII rep = [160].pack('C').force_encoding Encoding::BINARY str[0..1] = rep - str.encoding.should equal(Encoding::BINARY) + str.encoding.should.equal?(Encoding::BINARY) end it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - -> { str[0..1] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str[0..1] = rep }.should.raise(Encoding::CompatibilityError) end end @@ -498,14 +498,14 @@ index = mock("string element set index") index.should_receive(:to_int).and_return("1") - -> { "abc"[index, 2] = "xyz" }.should raise_error(TypeError) + -> { "abc"[index, 2] = "xyz" }.should.raise(TypeError) end it "raises a TypeError if #to_int for count does not return an Integer" do count = mock("string element set count") count.should_receive(:to_int).and_return("1") - -> { "abc"[1, count] = "xyz" }.should raise_error(TypeError) + -> { "abc"[1, count] = "xyz" }.should.raise(TypeError) end it "calls #to_str to convert the replacement object" do @@ -521,23 +521,23 @@ r = mock("string element set replacement") r.should_receive(:to_str).and_return(nil) - -> { "abc"[1, 1] = r }.should raise_error(TypeError) + -> { "abc"[1, 1] = r }.should.raise(TypeError) end it "raises an IndexError if |idx| is greater than the length of the string" do - -> { "hello"[6, 0] = "bob" }.should raise_error(IndexError) - -> { "hello"[-6, 0] = "bob" }.should raise_error(IndexError) + -> { "hello"[6, 0] = "bob" }.should.raise(IndexError) + -> { "hello"[-6, 0] = "bob" }.should.raise(IndexError) end it "raises an IndexError if count < 0" do - -> { "hello"[0, -1] = "bob" }.should raise_error(IndexError) - -> { "hello"[1, -1] = "bob" }.should raise_error(IndexError) + -> { "hello"[0, -1] = "bob" }.should.raise(IndexError) + -> { "hello"[1, -1] = "bob" }.should.raise(IndexError) end it "raises a TypeError if other_str is a type other than String" do - -> { "hello"[0, 2] = nil }.should raise_error(TypeError) - -> { "hello"[0, 2] = [] }.should raise_error(TypeError) - -> { "hello"[0, 2] = 33 }.should raise_error(TypeError) + -> { "hello"[0, 2] = nil }.should.raise(TypeError) + -> { "hello"[0, 2] = [] }.should.raise(TypeError) + -> { "hello"[0, 2] = 33 }.should.raise(TypeError) end it "replaces characters with a multibyte character" do @@ -571,19 +571,19 @@ end it "raises an IndexError if the character index is out of range of a multibyte String" do - -> { "あれ"[3, 0] = "り" }.should raise_error(IndexError) + -> { "あれ"[3, 0] = "り" }.should.raise(IndexError) end it "encodes the String in an encoding compatible with the replacement" do str = " ".force_encoding Encoding::US_ASCII rep = [160].pack('C').force_encoding Encoding::BINARY str[0, 1] = rep - str.encoding.should equal(Encoding::BINARY) + str.encoding.should.equal?(Encoding::BINARY) end it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - -> { str[0, 1] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str[0, 1] = rep }.should.raise(Encoding::CompatibilityError) end end diff --git a/spec/ruby/core/string/encode_spec.rb b/spec/ruby/core/string/encode_spec.rb index cd449498a35209..ab096f4041a118 100644 --- a/spec/ruby/core/string/encode_spec.rb +++ b/spec/ruby/core/string/encode_spec.rb @@ -20,7 +20,7 @@ Encoding.default_internal = nil str = "あ" encoded = str.encode - encoded.should_not equal(str) + encoded.should_not.equal?(str) encoded.should == str end @@ -28,7 +28,7 @@ Encoding.default_internal = nil str = "abc" encoded = str.encode - encoded.should_not equal(str) + encoded.should_not.equal?(str) encoded.should == str end @@ -36,7 +36,7 @@ x82 = [0x82].pack('C') str = "#{x82}foo".dup.force_encoding("binary")[1..-1].encode("utf-8") str.should == "foo".dup.force_encoding("utf-8") - str.encoding.should equal(Encoding::UTF_8) + str.encoding.should.equal?(Encoding::UTF_8) end end @@ -44,7 +44,7 @@ it "returns a copy when passed the same encoding as the String" do str = "あ" encoded = str.encode(Encoding::UTF_8) - encoded.should_not equal(str) + encoded.should_not.equal?(str) encoded.should == str end @@ -58,7 +58,7 @@ it "returns a copy when Encoding.default_internal is nil" do Encoding.default_internal = nil str = "あ" - str.encode(invalid: :replace).should_not equal(str) + str.encode(invalid: :replace).should_not.equal?(str) end it "normalizes newlines with cr_newline option" do @@ -137,7 +137,7 @@ str = "あ".dup.force_encoding("binary") encoded = str.encode("utf-8", "utf-8") - encoded.should_not equal(str) + encoded.should_not.equal?(str) encoded.should == str.force_encoding("utf-8") encoded.encoding.should == Encoding::UTF_8 end @@ -152,7 +152,7 @@ it "returns a copy when the destination encoding is the same as the String encoding" do str = "あ" encoded = str.encode(Encoding::UTF_8, undef: :replace) - encoded.should_not equal(str) + encoded.should_not.equal?(str) encoded.should == str end end @@ -161,7 +161,7 @@ it "returns a copy when both encodings are the same" do str = "あ" encoded = str.encode("utf-8", "utf-8", invalid: :replace) - encoded.should_not equal(str) + encoded.should_not.equal?(str) encoded.should == str end @@ -169,7 +169,7 @@ str = "あ".dup.force_encoding("binary") encoded = str.encode("utf-8", "utf-8", invalid: :replace) - encoded.should_not equal(str) + encoded.should_not.equal?(str) encoded.should == str.force_encoding("utf-8") encoded.encoding.should == Encoding::UTF_8 end @@ -190,25 +190,25 @@ it_behaves_like :string_encode, :encode! it "raises a FrozenError when called on a frozen String" do - -> { "foo".freeze.encode!("euc-jp") }.should raise_error(FrozenError) + -> { "foo".freeze.encode!("euc-jp") }.should.raise(FrozenError) end # http://redmine.ruby-lang.org/issues/show/1836 it "raises a FrozenError when called on a frozen String when it's a no-op" do - -> { "foo".freeze.encode!("utf-8") }.should raise_error(FrozenError) + -> { "foo".freeze.encode!("utf-8") }.should.raise(FrozenError) end describe "when passed no options" do it "returns self when Encoding.default_internal is nil" do Encoding.default_internal = nil str = +"あ" - str.encode!.should equal(str) + str.encode!.should.equal?(str) end it "returns self for a ASCII-only String when Encoding.default_internal is nil" do Encoding.default_internal = nil str = +"abc" - str.encode!.should equal(str) + str.encode!.should.equal?(str) end end @@ -216,7 +216,7 @@ it "returns self for ASCII-only String when Encoding.default_internal is nil" do Encoding.default_internal = nil str = +"abc" - str.encode!(invalid: :replace).should equal(str) + str.encode!(invalid: :replace).should.equal?(str) end end @@ -224,8 +224,8 @@ it "returns self" do str = +"abc" result = str.encode!(Encoding::BINARY) - result.encoding.should equal(Encoding::BINARY) - result.should equal(str) + result.encoding.should.equal?(Encoding::BINARY) + result.should.equal?(str) end end @@ -233,8 +233,8 @@ it "returns self" do str = +"ああ" result = str.encode!("euc-jp", "utf-8") - result.encoding.should equal(Encoding::EUC_JP) - result.should equal(str) + result.encoding.should.equal?(Encoding::EUC_JP) + result.should.equal?(str) end end end diff --git a/spec/ruby/core/string/encoding_spec.rb b/spec/ruby/core/string/encoding_spec.rb index f6e8fd34702116..aa0e4765ed0910 100644 --- a/spec/ruby/core/string/encoding_spec.rb +++ b/spec/ruby/core/string/encoding_spec.rb @@ -4,7 +4,7 @@ describe "String#encoding" do it "returns an Encoding object" do - String.new.encoding.should be_an_instance_of(Encoding) + String.new.encoding.should.instance_of?(Encoding) end it "is equal to the source encoding by default" do @@ -70,13 +70,13 @@ it "returns US-ASCII if self is US-ASCII only" do s = "\u{40}" - s.ascii_only?.should be_true + s.ascii_only?.should == true s.encoding.should == Encoding::US_ASCII end it "returns UTF-8 if self isn't US-ASCII only" do s = "\u{4076}\u{619}" - s.ascii_only?.should be_false + s.ascii_only?.should == false s.encoding.should == Encoding::UTF_8 end @@ -122,7 +122,7 @@ it "returns US-ASCII if self is US-ASCII only" do s = "\x61" - s.ascii_only?.should be_true + s.ascii_only?.should == true s.encoding.should == Encoding::US_ASCII end @@ -131,7 +131,7 @@ str = " " str.encoding.should == Encoding::US_ASCII str += [0xDF].pack('C') - str.ascii_only?.should be_false + str.ascii_only?.should == false str.encoding.should == Encoding::BINARY end @@ -140,7 +140,7 @@ it "returns the source encoding when an escape creates a byte with the 8th bit set if the source encoding isn't US-ASCII" do fixture = StringSpecs::ISO88599Encoding.new fixture.source_encoding.should == Encoding::ISO8859_9 - fixture.x_escape.ascii_only?.should be_false + fixture.x_escape.ascii_only?.should == false fixture.x_escape.encoding.should == Encoding::ISO8859_9 end diff --git a/spec/ruby/core/string/eql_spec.rb b/spec/ruby/core/string/eql_spec.rb index 397974d9fb6854..46ebeda509925c 100644 --- a/spec/ruby/core/string/eql_spec.rb +++ b/spec/ruby/core/string/eql_spec.rb @@ -6,16 +6,16 @@ describe "when given a non-String" do it "returns false" do - 'hello'.should_not eql(5) + 'hello'.should_not.eql?(5) not_supported_on :opal do - 'hello'.should_not eql(:hello) + 'hello'.should_not.eql?(:hello) end - 'hello'.should_not eql(mock('x')) + 'hello'.should_not.eql?(mock('x')) end it "does not try to call #to_str on the given argument" do (obj = mock('x')).should_not_receive(:to_str) - 'hello'.should_not eql(obj) + 'hello'.should_not.eql?(obj) end end end diff --git a/spec/ruby/core/string/force_encoding_spec.rb b/spec/ruby/core/string/force_encoding_spec.rb index 2259dcf3cf8650..fc6914213f5bf0 100644 --- a/spec/ruby/core/string/force_encoding_spec.rb +++ b/spec/ruby/core/string/force_encoding_spec.rb @@ -41,23 +41,23 @@ obj = mock("force_encoding") obj.should_receive(:to_str).and_return(1) - -> { "abc".force_encoding(obj) }.should raise_error(TypeError) + -> { "abc".force_encoding(obj) }.should.raise(TypeError) end it "raises a TypeError if passed nil" do - -> { "abc".force_encoding(nil) }.should raise_error(TypeError) + -> { "abc".force_encoding(nil) }.should.raise(TypeError) end it "returns self" do str = "abc" - str.force_encoding('utf-8').should equal(str) + str.force_encoding('utf-8').should.equal?(str) end it "sets the encoding even if the String contents are invalid in that encoding" do str = "\u{9765}" str.force_encoding('euc-jp') str.encoding.should == Encoding::EUC_JP - str.valid_encoding?.should be_false + str.valid_encoding?.should == false end it "does not transcode self" do @@ -67,6 +67,6 @@ it "raises a FrozenError if self is frozen" do str = "abcd".freeze - -> { str.force_encoding(str.encoding) }.should raise_error(FrozenError) + -> { str.force_encoding(str.encoding) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/freeze_spec.rb b/spec/ruby/core/string/freeze_spec.rb index 2e8e70386dcaad..8485e8de214cc5 100644 --- a/spec/ruby/core/string/freeze_spec.rb +++ b/spec/ruby/core/string/freeze_spec.rb @@ -4,11 +4,11 @@ describe "String#freeze" do it "produces the same object whenever called on an instance of a literal in the source" do - "abc".freeze.should equal "abc".freeze + "abc".freeze.should.equal? "abc".freeze end it "doesn't produce the same object for different instances of literals in the source" do - "abc".should_not equal "abc" + "abc".should_not.equal? "abc" end it "being a special form doesn't change the value of defined?" do diff --git a/spec/ruby/core/string/getbyte_spec.rb b/spec/ruby/core/string/getbyte_spec.rb index 27b7d826eaccca..d4619dca6173ce 100644 --- a/spec/ruby/core/string/getbyte_spec.rb +++ b/spec/ruby/core/string/getbyte_spec.rb @@ -3,7 +3,7 @@ describe "String#getbyte" do it "returns an Integer if given a valid index" do - "a".getbyte(0).should be_kind_of(Integer) + "a".getbyte(0).should.is_a?(Integer) end it "starts indexing at 0" do @@ -51,19 +51,19 @@ end it "returns nil for out-of-bound indexes" do - "g".getbyte(1).should be_nil + "g".getbyte(1).should == nil end it "regards the empty String as containing no bytes" do - "".getbyte(0).should be_nil + "".getbyte(0).should == nil end it "raises an ArgumentError unless given one argument" do - -> { "glark".getbyte }.should raise_error(ArgumentError) - -> { "food".getbyte(0,0) }.should raise_error(ArgumentError) + -> { "glark".getbyte }.should.raise(ArgumentError) + -> { "food".getbyte(0,0) }.should.raise(ArgumentError) end it "raises a TypeError unless its argument can be coerced into an Integer" do - -> { "a".getbyte('a') }.should raise_error(TypeError) + -> { "a".getbyte('a') }.should.raise(TypeError) end end diff --git a/spec/ruby/core/string/gsub_spec.rb b/spec/ruby/core/string/gsub_spec.rb index 0d9f32eca2e11d..d0e1c30bd22fd0 100644 --- a/spec/ruby/core/string/gsub_spec.rb +++ b/spec/ruby/core/string/gsub_spec.rb @@ -175,9 +175,9 @@ def pattern.to_str() "." end end it "raises a TypeError when pattern can't be converted to a string" do - -> { "hello".gsub([], "x") }.should raise_error(TypeError) - -> { "hello".gsub(Object.new, "x") }.should raise_error(TypeError) - -> { "hello".gsub(nil, "x") }.should raise_error(TypeError) + -> { "hello".gsub([], "x") }.should.raise(TypeError) + -> { "hello".gsub(Object.new, "x") }.should.raise(TypeError) + -> { "hello".gsub(nil, "x") }.should.raise(TypeError) end it "tries to convert replacement to a string using to_str" do @@ -188,16 +188,16 @@ def replacement.to_str() "hello_replacement" end end it "raises a TypeError when replacement can't be converted to a string" do - -> { "hello".gsub(/[aeiou]/, []) }.should raise_error(TypeError) - -> { "hello".gsub(/[aeiou]/, Object.new) }.should raise_error(TypeError) - -> { "hello".gsub(/[aeiou]/, nil) }.should raise_error(TypeError) + -> { "hello".gsub(/[aeiou]/, []) }.should.raise(TypeError) + -> { "hello".gsub(/[aeiou]/, Object.new) }.should.raise(TypeError) + -> { "hello".gsub(/[aeiou]/, nil) }.should.raise(TypeError) end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("").gsub(//, "").should be_an_instance_of(String) - StringSpecs::MyString.new("").gsub(/foo/, "").should be_an_instance_of(String) - StringSpecs::MyString.new("foo").gsub(/foo/, "").should be_an_instance_of(String) - StringSpecs::MyString.new("foo").gsub("foo", "").should be_an_instance_of(String) + StringSpecs::MyString.new("").gsub(//, "").should.instance_of?(String) + StringSpecs::MyString.new("").gsub(/foo/, "").should.instance_of?(String) + StringSpecs::MyString.new("foo").gsub(/foo/, "").should.instance_of?(String) + StringSpecs::MyString.new("foo").gsub("foo", "").should.instance_of?(String) end it "sets $~ to MatchData of last match and nil when there's none" do @@ -450,8 +450,8 @@ def obj.to_s() "ok" end s = "hllëllo" s2 = "hellö" - -> { s.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) - -> { s2.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should.raise(Encoding::CompatibilityError) + -> { s2.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should.raise(Encoding::CompatibilityError) end it "replaces the incompatible part properly even if the encodings are not compatible" do @@ -463,7 +463,7 @@ def obj.to_s() "ok" end not_supported_on :opal do it "raises an ArgumentError if encoding is not valid" do x92 = [0x92].pack('C').force_encoding('utf-8') - -> { "a#{x92}b".gsub(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) + -> { "a#{x92}b".gsub(/[^\x00-\x7f]/u, '') }.should.raise(ArgumentError) end end end @@ -471,7 +471,7 @@ def obj.to_s() "ok" end describe "String#gsub with pattern and without replacement and block" do it "returns an enumerator" do enum = "abca".gsub(/a/) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == ["a", "a"] end @@ -495,13 +495,13 @@ def obj.to_s() "ok" end describe "String#gsub! with pattern and replacement" do it "modifies self in place and returns self" do a = "hello" - a.gsub!(/[aeiou]/, '*').should equal(a) + a.gsub!(/[aeiou]/, '*').should.equal?(a) a.should == "h*ll*" end it "modifies self in place with multi-byte characters and returns self" do a = "¿por qué?" - a.gsub!(/([a-z\d]*)/, "*").should equal(a) + a.gsub!(/([a-z\d]*)/, "*").should.equal?(a) a.should == "*¿** **é*?*" end @@ -517,9 +517,9 @@ def obj.to_s() "ok" end s = "hello" s.freeze - -> { s.gsub!(/ROAR/, "x") }.should raise_error(FrozenError) - -> { s.gsub!(/e/, "e") }.should raise_error(FrozenError) - -> { s.gsub!(/[aeiou]/, '*') }.should raise_error(FrozenError) + -> { s.gsub!(/ROAR/, "x") }.should.raise(FrozenError) + -> { s.gsub!(/e/, "e") }.should.raise(FrozenError) + -> { s.gsub!(/[aeiou]/, '*') }.should.raise(FrozenError) end it "handles a pattern in a superset encoding" do @@ -547,7 +547,7 @@ def obj.to_s() "ok" end describe "String#gsub! with pattern and block" do it "modifies self in place and returns self" do a = "hello" - a.gsub!(/[aeiou]/) { '*' }.should equal(a) + a.gsub!(/[aeiou]/) { '*' }.should.equal?(a) a.should == "h*ll*" end @@ -563,9 +563,9 @@ def obj.to_s() "ok" end s = "hello" s.freeze - -> { s.gsub!(/ROAR/) { "x" } }.should raise_error(FrozenError) - -> { s.gsub!(/e/) { "e" } }.should raise_error(FrozenError) - -> { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(FrozenError) + -> { s.gsub!(/ROAR/) { "x" } }.should.raise(FrozenError) + -> { s.gsub!(/e/) { "e" } }.should.raise(FrozenError) + -> { s.gsub!(/[aeiou]/) { '*' } }.should.raise(FrozenError) end it "uses the compatible encoding if they are compatible" do @@ -580,8 +580,8 @@ def obj.to_s() "ok" end s = "hllëllo" s2 = "hellö" - -> { s.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) - -> { s2.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should.raise(Encoding::CompatibilityError) + -> { s2.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should.raise(Encoding::CompatibilityError) end it "replaces the incompatible part properly even if the encodings are not compatible" do @@ -593,7 +593,7 @@ def obj.to_s() "ok" end not_supported_on :opal do it "raises an ArgumentError if encoding is not valid" do x92 = [0x92].pack('C').force_encoding('utf-8') - -> { "a#{x92}b".gsub!(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) + -> { "a#{x92}b".gsub!(/[^\x00-\x7f]/u, '') }.should.raise(ArgumentError) end end end @@ -601,7 +601,7 @@ def obj.to_s() "ok" end describe "String#gsub! with pattern and without replacement and block" do it "returns an enumerator" do enum = "abca".gsub!(/a/) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == ["a", "a"] end diff --git a/spec/ruby/core/string/include_spec.rb b/spec/ruby/core/string/include_spec.rb index 9781140a55ea1e..d94343033548ec 100644 --- a/spec/ruby/core/string/include_spec.rb +++ b/spec/ruby/core/string/include_spec.rb @@ -35,15 +35,15 @@ end it "raises a TypeError if other can't be converted to string" do - -> { "hello".include?([]) }.should raise_error(TypeError) - -> { "hello".include?('h'.ord) }.should raise_error(TypeError) - -> { "hello".include?(mock('x')) }.should raise_error(TypeError) + -> { "hello".include?([]) }.should.raise(TypeError) + -> { "hello".include?('h'.ord) }.should.raise(TypeError) + -> { "hello".include?(mock('x')) }.should.raise(TypeError) end it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP -> do "あれ".include?(pat) - end.should raise_error(Encoding::CompatibilityError) + end.should.raise(Encoding::CompatibilityError) end end diff --git a/spec/ruby/core/string/index_spec.rb b/spec/ruby/core/string/index_spec.rb index 01e6a6a4009720..3f82181b9842ee 100644 --- a/spec/ruby/core/string/index_spec.rb +++ b/spec/ruby/core/string/index_spec.rb @@ -4,15 +4,15 @@ describe "String#index" do it "raises a TypeError if passed nil" do - -> { "abc".index nil }.should raise_error(TypeError) + -> { "abc".index nil }.should.raise(TypeError) end it "raises a TypeError if passed a boolean" do - -> { "abc".index true }.should raise_error(TypeError) + -> { "abc".index true }.should.raise(TypeError) end it "raises a TypeError if passed a Symbol" do - -> { "abc".index :a }.should raise_error(TypeError) + -> { "abc".index :a }.should.raise(TypeError) end it "calls #to_str to convert the first argument" do @@ -28,7 +28,7 @@ end it "raises a TypeError if passed an Integer" do - -> { "abc".index 97 }.should raise_error(TypeError) + -> { "abc".index 97 }.should.raise(TypeError) end end @@ -157,7 +157,7 @@ char = "れ".encode Encoding::EUC_JP -> do "あれ".index char - end.should raise_error(Encoding::CompatibilityError) + end.should.raise(Encoding::CompatibilityError) end it "handles a substring in a superset encoding" do @@ -172,7 +172,7 @@ str = 'abc'.dup.force_encoding("ISO-2022-JP") pattern = 'b'.dup.force_encoding("EUC-JP") - -> { str.index(pattern) }.should raise_error(Encoding::CompatibilityError, "incompatible character encodings: ISO-2022-JP and EUC-JP") + -> { str.index(pattern) }.should.raise(Encoding::CompatibilityError, "incompatible character encodings: ISO-2022-JP and EUC-JP") end end @@ -287,7 +287,7 @@ end it "returns nil if the Regexp matches the empty string and the offset is out of range" do - "ruby".index(//,12).should be_nil + "ruby".index(//,12).should == nil end it "supports \\G which matches at the given start offset" do @@ -332,6 +332,6 @@ re = Regexp.new "れ".encode(Encoding::EUC_JP) -> do "あれ".index re - end.should raise_error(Encoding::CompatibilityError, "incompatible encoding regexp match (EUC-JP regexp with UTF-8 string)") + end.should.raise(Encoding::CompatibilityError, "incompatible encoding regexp match (EUC-JP regexp with UTF-8 string)") end end diff --git a/spec/ruby/core/string/initialize_spec.rb b/spec/ruby/core/string/initialize_spec.rb index 08734cc916f6fd..b0c1e2e573a308 100644 --- a/spec/ruby/core/string/initialize_spec.rb +++ b/spec/ruby/core/string/initialize_spec.rb @@ -4,7 +4,7 @@ describe "String#initialize" do it "is a private method" do - String.should have_private_instance_method(:initialize) + String.private_instance_methods(false).should.include?(:initialize) end describe "with no arguments" do @@ -16,7 +16,7 @@ it "does not raise an exception when frozen" do a = "hello".freeze - a.send(:initialize).should equal(a) + a.send(:initialize).should.equal?(a) end end diff --git a/spec/ruby/core/string/insert_spec.rb b/spec/ruby/core/string/insert_spec.rb index 483f3c9367b16e..c89793a8ca9dbb 100644 --- a/spec/ruby/core/string/insert_spec.rb +++ b/spec/ruby/core/string/insert_spec.rb @@ -23,8 +23,8 @@ end it "raises an IndexError if the index is beyond string" do - -> { "abcd".insert(5, 'X') }.should raise_error(IndexError) - -> { "abcd".insert(-6, 'X') }.should raise_error(IndexError) + -> { "abcd".insert(5, 'X') }.should.raise(IndexError) + -> { "abcd".insert(-6, 'X') }.should.raise(IndexError) end it "converts index to an integer using to_int" do @@ -42,15 +42,15 @@ end it "raises a TypeError if other can't be converted to string" do - -> { "abcd".insert(-6, Object.new)}.should raise_error(TypeError) - -> { "abcd".insert(-6, []) }.should raise_error(TypeError) - -> { "abcd".insert(-6, mock('x')) }.should raise_error(TypeError) + -> { "abcd".insert(-6, Object.new)}.should.raise(TypeError) + -> { "abcd".insert(-6, []) }.should.raise(TypeError) + -> { "abcd".insert(-6, mock('x')) }.should.raise(TypeError) end it "raises a FrozenError if self is frozen" do str = "abcd".freeze - -> { str.insert(4, '') }.should raise_error(FrozenError) - -> { str.insert(4, 'X') }.should raise_error(FrozenError) + -> { str.insert(4, '') }.should.raise(FrozenError) + -> { str.insert(4, 'X') }.should.raise(FrozenError) end it "inserts a character into a multibyte encoded string" do @@ -67,7 +67,7 @@ pat = "ア".encode Encoding::EUC_JP -> do "あれ".insert 0, pat - end.should raise_error(Encoding::CompatibilityError) + end.should.raise(Encoding::CompatibilityError) end it "should not call subclassed string methods" do diff --git a/spec/ruby/core/string/inspect_spec.rb b/spec/ruby/core/string/inspect_spec.rb index 15db06c7f5f7e0..8b91ce2f8423b8 100644 --- a/spec/ruby/core/string/inspect_spec.rb +++ b/spec/ruby/core/string/inspect_spec.rb @@ -4,7 +4,7 @@ describe "String#inspect" do it "does not return a subclass instance" do - StringSpecs::MyString.new.inspect.should be_an_instance_of(String) + StringSpecs::MyString.new.inspect.should.instance_of?(String) end it "returns a string with special characters replaced with \\ notation" do diff --git a/spec/ruby/core/string/ljust_spec.rb b/spec/ruby/core/string/ljust_spec.rb index 47324c59d2f4de..0b2aab2638d67e 100644 --- a/spec/ruby/core/string/ljust_spec.rb +++ b/spec/ruby/core/string/ljust_spec.rb @@ -41,10 +41,10 @@ end it "raises a TypeError when length can't be converted to an integer" do - -> { "hello".ljust("x") }.should raise_error(TypeError) - -> { "hello".ljust("x", "y") }.should raise_error(TypeError) - -> { "hello".ljust([]) }.should raise_error(TypeError) - -> { "hello".ljust(mock('x')) }.should raise_error(TypeError) + -> { "hello".ljust("x") }.should.raise(TypeError) + -> { "hello".ljust("x", "y") }.should.raise(TypeError) + -> { "hello".ljust([]) }.should.raise(TypeError) + -> { "hello".ljust(mock('x')) }.should.raise(TypeError) end it "tries to convert padstr to a string using to_str" do @@ -55,22 +55,22 @@ end it "raises a TypeError when padstr can't be converted" do - -> { "hello".ljust(20, []) }.should raise_error(TypeError) - -> { "hello".ljust(20, Object.new)}.should raise_error(TypeError) - -> { "hello".ljust(20, mock('x')) }.should raise_error(TypeError) + -> { "hello".ljust(20, []) }.should.raise(TypeError) + -> { "hello".ljust(20, Object.new)}.should.raise(TypeError) + -> { "hello".ljust(20, mock('x')) }.should.raise(TypeError) end it "raises an ArgumentError when padstr is empty" do - -> { "hello".ljust(10, '') }.should raise_error(ArgumentError) + -> { "hello".ljust(10, '') }.should.raise(ArgumentError) end it "returns String instances when called on subclasses" do - StringSpecs::MyString.new("").ljust(10).should be_an_instance_of(String) - StringSpecs::MyString.new("foo").ljust(10).should be_an_instance_of(String) - StringSpecs::MyString.new("foo").ljust(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String) + StringSpecs::MyString.new("").ljust(10).should.instance_of?(String) + StringSpecs::MyString.new("foo").ljust(10).should.instance_of?(String) + StringSpecs::MyString.new("foo").ljust(10, StringSpecs::MyString.new("x")).should.instance_of?(String) - "".ljust(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String) - "foo".ljust(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String) + "".ljust(10, StringSpecs::MyString.new("x")).should.instance_of?(String) + "foo".ljust(10, StringSpecs::MyString.new("x")).should.instance_of?(String) end describe "with width" do @@ -78,7 +78,7 @@ str = "abc".dup.force_encoding Encoding::IBM437 result = str.ljust 5 result.should == "abc " - result.encoding.should equal(Encoding::IBM437) + result.encoding.should.equal?(Encoding::IBM437) end end @@ -87,14 +87,14 @@ str = "abc".dup.force_encoding Encoding::IBM437 result = str.ljust 5, "あ" result.should == "abcああ" - result.encoding.should equal(Encoding::UTF_8) + result.encoding.should.equal?(Encoding::UTF_8) end it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP -> do "あれ".ljust 5, pat - end.should raise_error(Encoding::CompatibilityError) + end.should.raise(Encoding::CompatibilityError) end end end diff --git a/spec/ruby/core/string/lstrip_spec.rb b/spec/ruby/core/string/lstrip_spec.rb index c83650207e23a8..5896f8d7da6bc1 100644 --- a/spec/ruby/core/string/lstrip_spec.rb +++ b/spec/ruby/core/string/lstrip_spec.rb @@ -30,7 +30,7 @@ describe "String#lstrip!" do it "modifies self in place and returns self" do a = " hello " - a.lstrip!.should equal(a) + a.lstrip!.should.equal?(a) a.should == "hello " end @@ -53,22 +53,22 @@ end it "raises a FrozenError on a frozen instance that is modified" do - -> { " hello ".freeze.lstrip! }.should raise_error(FrozenError) + -> { " hello ".freeze.lstrip! }.should.raise(FrozenError) end # see [ruby-core:23657] it "raises a FrozenError on a frozen instance that would not be modified" do - -> { "hello".freeze.lstrip! }.should raise_error(FrozenError) - -> { "".freeze.lstrip! }.should raise_error(FrozenError) + -> { "hello".freeze.lstrip! }.should.raise(FrozenError) + -> { "".freeze.lstrip! }.should.raise(FrozenError) end it "raises an ArgumentError if the first non-space codepoint is invalid" do s = "\xDFabc".force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.lstrip! }.should raise_error(ArgumentError) + s.valid_encoding?.should == false + -> { s.lstrip! }.should.raise(ArgumentError) s = " \xDFabc".force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.lstrip! }.should raise_error(ArgumentError) + s.valid_encoding?.should == false + -> { s.lstrip! }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/match_spec.rb b/spec/ruby/core/string/match_spec.rb index 3a906716c53b5a..3ea8d90aa8fc39 100644 --- a/spec/ruby/core/string/match_spec.rb +++ b/spec/ruby/core/string/match_spec.rb @@ -19,8 +19,8 @@ end it "raises a TypeError if a obj is a string" do - -> { "some string" =~ "another string" }.should raise_error(TypeError) - -> { "a" =~ StringSpecs::MyString.new("b") }.should raise_error(TypeError) + -> { "some string" =~ "another string" }.should.raise(TypeError) + -> { "a" =~ StringSpecs::MyString.new("b") }.should.raise(TypeError) end it "invokes obj.=~ with self if obj is neither a string nor regexp" do @@ -81,7 +81,7 @@ describe "when passed a block" do it "yields the MatchData" do "abc".match(/./) {|m| ScratchPad.record m } - ScratchPad.recorded.should be_kind_of(MatchData) + ScratchPad.recorded.should.is_a?(MatchData) end it "returns the block result" do @@ -107,9 +107,9 @@ def obj.method_missing(*args) "." end end it "raises a TypeError if pattern is not a regexp or a string" do - -> { 'hello'.match(10) }.should raise_error(TypeError) + -> { 'hello'.match(10) }.should.raise(TypeError) not_supported_on :opal do - -> { 'hello'.match(:ell) }.should raise_error(TypeError) + -> { 'hello'.match(:ell) }.should.raise(TypeError) end end @@ -159,17 +159,17 @@ def match(*args) context "when matches the given regex" do it "returns true but does not set Regexp.last_match" do - 'string'.match?(/string/i).should be_true - Regexp.last_match.should be_nil + 'string'.match?(/string/i).should == true + Regexp.last_match.should == nil end end it "returns false when does not match the given regex" do - 'string'.match?(/STRING/).should be_false + 'string'.match?(/STRING/).should == false end it "takes matching position as the 2nd argument" do - 'string'.match?(/str/i, 0).should be_true - 'string'.match?(/str/i, 1).should be_false + 'string'.match?(/str/i, 0).should == true + 'string'.match?(/str/i, 1).should == false end end diff --git a/spec/ruby/core/string/modulo_spec.rb b/spec/ruby/core/string/modulo_spec.rb index 46e0aa0f3616c8..f93ec4bcf8fbe3 100644 --- a/spec/ruby/core/string/modulo_spec.rb +++ b/spec/ruby/core/string/modulo_spec.rb @@ -46,13 +46,13 @@ end it "raises if a compatible encoding can't be found" do - -> { "hello %s".encode("utf-8") % "world".encode("UTF-16LE") }.should raise_error(Encoding::CompatibilityError) + -> { "hello %s".encode("utf-8") % "world".encode("UTF-16LE") }.should.raise(Encoding::CompatibilityError) end end it "raises an error if single % appears at the end" do - -> { ("%" % []) }.should raise_error(ArgumentError) - -> { ("foo%" % [])}.should raise_error(ArgumentError) + -> { ("%" % []) }.should.raise(ArgumentError) + -> { ("foo%" % [])}.should.raise(ArgumentError) end ruby_version_is ""..."3.4" do @@ -69,18 +69,18 @@ end it "raises an error if single % appears anywhere else" do - -> { (" % " % []) }.should raise_error(ArgumentError) - -> { ("foo%quux" % []) }.should raise_error(ArgumentError) + -> { (" % " % []) }.should.raise(ArgumentError) + -> { ("foo%quux" % []) }.should.raise(ArgumentError) end it "raises an error if NULL or \\n appear anywhere else in the format string" do begin old_debug, $DEBUG = $DEBUG, false - -> { "%.\n3f" % 1.2 }.should raise_error(ArgumentError) - -> { "%.3\nf" % 1.2 }.should raise_error(ArgumentError) - -> { "%.\03f" % 1.2 }.should raise_error(ArgumentError) - -> { "%.3\0f" % 1.2 }.should raise_error(ArgumentError) + -> { "%.\n3f" % 1.2 }.should.raise(ArgumentError) + -> { "%.3\nf" % 1.2 }.should.raise(ArgumentError) + -> { "%.\03f" % 1.2 }.should.raise(ArgumentError) + -> { "%.3\0f" % 1.2 }.should.raise(ArgumentError) ensure $DEBUG = old_debug end @@ -89,14 +89,14 @@ ruby_version_is "3.4" do it "raises an ArgumentError if % is not followed by a conversion specifier" do - -> { "%" % [] }.should raise_error(ArgumentError) - -> { "%\n" % [] }.should raise_error(ArgumentError) - -> { "%\0" % [] }.should raise_error(ArgumentError) - -> { " % " % [] }.should raise_error(ArgumentError) - -> { "%.\n3f" % 1.2 }.should raise_error(ArgumentError) - -> { "%.3\nf" % 1.2 }.should raise_error(ArgumentError) - -> { "%.\03f" % 1.2 }.should raise_error(ArgumentError) - -> { "%.3\0f" % 1.2 }.should raise_error(ArgumentError) + -> { "%" % [] }.should.raise(ArgumentError) + -> { "%\n" % [] }.should.raise(ArgumentError) + -> { "%\0" % [] }.should.raise(ArgumentError) + -> { " % " % [] }.should.raise(ArgumentError) + -> { "%.\n3f" % 1.2 }.should.raise(ArgumentError) + -> { "%.3\nf" % 1.2 }.should.raise(ArgumentError) + -> { "%.\03f" % 1.2 }.should.raise(ArgumentError) + -> { "%.3\0f" % 1.2 }.should.raise(ArgumentError) end end @@ -119,8 +119,8 @@ s = $stderr $stderr = IOStub.new - -> { "" % [1, 2, 3] }.should raise_error(ArgumentError) - -> { "%s" % [1, 2, 3] }.should raise_error(ArgumentError) + -> { "" % [1, 2, 3] }.should.raise(ArgumentError) + -> { "%s" % [1, 2, 3] }.should.raise(ArgumentError) ensure $DEBUG = old_debug $stderr = s @@ -148,26 +148,26 @@ ruby_version_is "3.4" do it "raises an ArgumentError if absolute argument specifier is followed by a conversion specifier" do - -> { "hello %1$" % "foo" }.should raise_error(ArgumentError) + -> { "hello %1$" % "foo" }.should.raise(ArgumentError) end end it "raises an ArgumentError when given invalid argument specifiers" do - -> { "%1" % [] }.should raise_error(ArgumentError) - -> { "%+" % [] }.should raise_error(ArgumentError) - -> { "%-" % [] }.should raise_error(ArgumentError) - -> { "%#" % [] }.should raise_error(ArgumentError) - -> { "%0" % [] }.should raise_error(ArgumentError) - -> { "%*" % [] }.should raise_error(ArgumentError) - -> { "%." % [] }.should raise_error(ArgumentError) - -> { "%_" % [] }.should raise_error(ArgumentError) - -> { "%0$s" % "x" }.should raise_error(ArgumentError) - -> { "%*0$s" % [5, "x"] }.should raise_error(ArgumentError) - -> { "%*1$.*0$1$s" % [1, 2, 3] }.should raise_error(ArgumentError) + -> { "%1" % [] }.should.raise(ArgumentError) + -> { "%+" % [] }.should.raise(ArgumentError) + -> { "%-" % [] }.should.raise(ArgumentError) + -> { "%#" % [] }.should.raise(ArgumentError) + -> { "%0" % [] }.should.raise(ArgumentError) + -> { "%*" % [] }.should.raise(ArgumentError) + -> { "%." % [] }.should.raise(ArgumentError) + -> { "%_" % [] }.should.raise(ArgumentError) + -> { "%0$s" % "x" }.should.raise(ArgumentError) + -> { "%*0$s" % [5, "x"] }.should.raise(ArgumentError) + -> { "%*1$.*0$1$s" % [1, 2, 3] }.should.raise(ArgumentError) end it "raises an ArgumentError when multiple positional argument tokens are given for one format specifier" do - -> { "%1$1$s" % "foo" }.should raise_error(ArgumentError) + -> { "%1$1$s" % "foo" }.should.raise(ArgumentError) end it "respects positional arguments and precision tokens given for one format specifier" do @@ -183,36 +183,36 @@ end it "raises an ArgumentError when multiple width star tokens are given for one format specifier" do - -> { "%**s" % [5, 5, 5] }.should raise_error(ArgumentError) + -> { "%**s" % [5, 5, 5] }.should.raise(ArgumentError) end it "raises an ArgumentError when a width star token is seen after a width token" do - -> { "%5*s" % [5, 5] }.should raise_error(ArgumentError) + -> { "%5*s" % [5, 5] }.should.raise(ArgumentError) end it "raises an ArgumentError when multiple precision tokens are given" do - -> { "%.5.5s" % 5 }.should raise_error(ArgumentError) - -> { "%.5.*s" % [5, 5] }.should raise_error(ArgumentError) - -> { "%.*.5s" % [5, 5] }.should raise_error(ArgumentError) + -> { "%.5.5s" % 5 }.should.raise(ArgumentError) + -> { "%.5.*s" % [5, 5] }.should.raise(ArgumentError) + -> { "%.*.5s" % [5, 5] }.should.raise(ArgumentError) end it "raises an ArgumentError when there are less arguments than format specifiers" do ("foo" % []).should == "foo" - -> { "%s" % [] }.should raise_error(ArgumentError) - -> { "%s %s" % [1] }.should raise_error(ArgumentError) + -> { "%s" % [] }.should.raise(ArgumentError) + -> { "%s %s" % [1] }.should.raise(ArgumentError) end it "raises an ArgumentError when absolute and relative argument numbers are mixed" do - -> { "%s %1$s" % "foo" }.should raise_error(ArgumentError) - -> { "%1$s %s" % "foo" }.should raise_error(ArgumentError) + -> { "%s %1$s" % "foo" }.should.raise(ArgumentError) + -> { "%1$s %s" % "foo" }.should.raise(ArgumentError) - -> { "%s %2$s" % ["foo", "bar"] }.should raise_error(ArgumentError) - -> { "%2$s %s" % ["foo", "bar"] }.should raise_error(ArgumentError) + -> { "%s %2$s" % ["foo", "bar"] }.should.raise(ArgumentError) + -> { "%2$s %s" % ["foo", "bar"] }.should.raise(ArgumentError) - -> { "%*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) - -> { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) - -> { "%*2$.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) - -> { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) + -> { "%*2$s" % [5, 5, 5] }.should.raise(ArgumentError) + -> { "%*.*2$s" % [5, 5, 5] }.should.raise(ArgumentError) + -> { "%*2$.*2$s" % [5, 5, 5] }.should.raise(ArgumentError) + -> { "%*.*2$s" % [5, 5, 5] }.should.raise(ArgumentError) end it "allows reuse of the one argument multiple via absolute argument numbers" do @@ -221,13 +221,13 @@ end it "always interprets an array argument as a list of argument parameters" do - -> { "%p" % [] }.should raise_error(ArgumentError) + -> { "%p" % [] }.should.raise(ArgumentError) ("%p" % [1]).should == "1" ("%p %p" % [1, 2]).should == "1 2" end it "always interprets an array subclass argument as a list of argument parameters" do - -> { "%p" % StringSpecs::MyArray[] }.should raise_error(ArgumentError) + -> { "%p" % StringSpecs::MyArray[] }.should.raise(ArgumentError) ("%p" % StringSpecs::MyArray[1]).should == "1" ("%p %p" % StringSpecs::MyArray[1, 2]).should == "1 2" end @@ -298,7 +298,7 @@ x = mock("string modulo to_ary") x.should_receive(:to_ary).and_return("x") - -> { "%s" % x }.should raise_error(TypeError) + -> { "%s" % x }.should.raise(TypeError) end it "tries to convert the argument to Array by calling #to_ary" do @@ -321,7 +321,7 @@ def universal.to_f() 0.0 end "%f", "%g", "%G", "%i", "%o", "%p", "%s", "%u", "%x", "%X" ].each do |format| - (StringSpecs::MyString.new(format) % universal).should be_an_instance_of(String) + (StringSpecs::MyString.new(format) % universal).should.instance_of?(String) end end @@ -384,7 +384,7 @@ def universal.to_f() 0.0 end ("%*c" % [10, 3]).should == " \003" ("%c" % 42).should == "*" - -> { "%c" % Object }.should raise_error(TypeError) + -> { "%c" % Object }.should.raise(TypeError) end it "supports single character strings as argument for %c" do @@ -610,7 +610,7 @@ def obj.to_s() "obj" end # See http://groups.google.com/group/ruby-core-google/t/c285c18cd94c216d it "raises an ArgumentError for huge precisions for %s" do block = -> { "%.25555555555555555555555555555555555555s" % "hello world" } - block.should raise_error(ArgumentError) + block.should.raise(ArgumentError) end # Note: %u has been changed to an alias for %d in 1.9. @@ -705,16 +705,16 @@ def obj.to_s() "obj" end -> { # see [ruby-core:14139] for more details (format % "0777").should == (format % Kernel.Integer("0777")) - }.should_not raise_error(ArgumentError) + }.should_not.raise(ArgumentError) - -> { format % "0__7_7_7" }.should raise_error(ArgumentError) + -> { format % "0__7_7_7" }.should.raise(ArgumentError) - -> { format % "" }.should raise_error(ArgumentError) - -> { format % "x" }.should raise_error(ArgumentError) - -> { format % "5x" }.should raise_error(ArgumentError) - -> { format % "08" }.should raise_error(ArgumentError) - -> { format % "0b2" }.should raise_error(ArgumentError) - -> { format % "123__456" }.should raise_error(ArgumentError) + -> { format % "" }.should.raise(ArgumentError) + -> { format % "x" }.should.raise(ArgumentError) + -> { format % "5x" }.should.raise(ArgumentError) + -> { format % "08" }.should.raise(ArgumentError) + -> { format % "0b2" }.should.raise(ArgumentError) + -> { format % "123__456" }.should.raise(ArgumentError) obj = mock('5') obj.should_receive(:to_i).and_return(5) @@ -752,14 +752,14 @@ def obj.to_s() "obj" end (format % "0777").should == (format % 777) - -> { format % "" }.should raise_error(ArgumentError) - -> { format % "x" }.should raise_error(ArgumentError) - -> { format % "." }.should raise_error(ArgumentError) - -> { format % "5x" }.should raise_error(ArgumentError) - -> { format % "0b1" }.should raise_error(ArgumentError) - -> { format % "10e10.5" }.should raise_error(ArgumentError) - -> { format % "10__10" }.should raise_error(ArgumentError) - -> { format % "10.10__10" }.should raise_error(ArgumentError) + -> { format % "" }.should.raise(ArgumentError) + -> { format % "x" }.should.raise(ArgumentError) + -> { format % "." }.should.raise(ArgumentError) + -> { format % "5x" }.should.raise(ArgumentError) + -> { format % "0b1" }.should.raise(ArgumentError) + -> { format % "10e10.5" }.should.raise(ArgumentError) + -> { format % "10__10" }.should.raise(ArgumentError) + -> { format % "10.10__10" }.should.raise(ArgumentError) obj = mock('5.0') obj.should_receive(:to_f).and_return(5.0) @@ -777,7 +777,7 @@ def obj.to_s() "obj" end end it "should raise ArgumentError if no hash given" do - -> {"%{foo}" % []}.should raise_error(ArgumentError) + -> {"%{foo}" % []}.should.raise(ArgumentError) end end @@ -787,11 +787,11 @@ def obj.to_s() "obj" end end it "raises KeyError if key is missing from passed-in hash" do - -> {"%d" % {}}.should raise_error(KeyError) + -> {"%d" % {}}.should.raise(KeyError) end it "should raise ArgumentError if no hash given" do - -> {"%" % []}.should raise_error(ArgumentError) + -> {"%" % []}.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/string/new_spec.rb b/spec/ruby/core/string/new_spec.rb index ca678f53238636..aadf1e0e467aa2 100644 --- a/spec/ruby/core/string/new_spec.rb +++ b/spec/ruby/core/string/new_spec.rb @@ -4,7 +4,7 @@ describe "String.new" do it "returns an instance of String" do str = String.new - str.should be_an_instance_of(String) + str.should.instance_of?(String) end it "accepts an encoding argument" do @@ -28,7 +28,7 @@ it "returns a new string given a string argument" do str1 = "test" str = String.new(str1) - str.should be_an_instance_of(String) + str.should.instance_of?(String) str.should == str1 str << "more" str.should == "testmore" @@ -36,7 +36,7 @@ it "returns an instance of a subclass" do a = StringSpecs::MyString.new("blah") - a.should be_an_instance_of(StringSpecs::MyString) + a.should.instance_of?(StringSpecs::MyString) a.should == "blah" end @@ -51,8 +51,8 @@ end it "raises TypeError on inconvertible object" do - -> { String.new 5 }.should raise_error(TypeError) - -> { String.new nil }.should raise_error(TypeError) + -> { String.new 5 }.should.raise(TypeError) + -> { String.new nil }.should.raise(TypeError) end it "returns a binary String" do diff --git a/spec/ruby/core/string/ord_spec.rb b/spec/ruby/core/string/ord_spec.rb index 35af3b5458eb28..5a17fc1d873e06 100644 --- a/spec/ruby/core/string/ord_spec.rb +++ b/spec/ruby/core/string/ord_spec.rb @@ -2,7 +2,7 @@ describe "String#ord" do it "returns an Integer" do - 'a'.ord.should be_an_instance_of(Integer) + 'a'.ord.should.instance_of?(Integer) end it "returns the codepoint of the first character in the String" do @@ -23,11 +23,11 @@ end it "raises an ArgumentError if called on an empty String" do - -> { ''.ord }.should raise_error(ArgumentError) + -> { ''.ord }.should.raise(ArgumentError) end it "raises ArgumentError if the character is broken" do s = "©".dup.force_encoding("US-ASCII") - -> { s.ord }.should raise_error(ArgumentError, "invalid byte sequence in US-ASCII") + -> { s.ord }.should.raise(ArgumentError, "invalid byte sequence in US-ASCII") end end diff --git a/spec/ruby/core/string/partition_spec.rb b/spec/ruby/core/string/partition_spec.rb index d5370dcc7352d3..29fe910b39bb21 100644 --- a/spec/ruby/core/string/partition_spec.rb +++ b/spec/ruby/core/string/partition_spec.rb @@ -31,8 +31,8 @@ end it "raises an error if not convertible to string" do - ->{ "hello".partition(5) }.should raise_error(TypeError) - ->{ "hello".partition(nil) }.should raise_error(TypeError) + ->{ "hello".partition(5) }.should.raise(TypeError) + ->{ "hello".partition(nil) }.should.raise(TypeError) end it "takes precedence over a given block" do diff --git a/spec/ruby/core/string/plus_spec.rb b/spec/ruby/core/string/plus_spec.rb index 9da17451c69c78..0464141c378fb4 100644 --- a/spec/ruby/core/string/plus_spec.rb +++ b/spec/ruby/core/string/plus_spec.rb @@ -21,17 +21,17 @@ end it "raises a TypeError when given any object that fails #to_str" do - -> { "" + Object.new }.should raise_error(TypeError) - -> { "" + 65 }.should raise_error(TypeError) + -> { "" + Object.new }.should.raise(TypeError) + -> { "" + 65 }.should.raise(TypeError) end it "doesn't return subclass instances" do - (StringSpecs::MyString.new("hello") + "").should be_an_instance_of(String) - (StringSpecs::MyString.new("hello") + "foo").should be_an_instance_of(String) - (StringSpecs::MyString.new("hello") + StringSpecs::MyString.new("foo")).should be_an_instance_of(String) - (StringSpecs::MyString.new("hello") + StringSpecs::MyString.new("")).should be_an_instance_of(String) - (StringSpecs::MyString.new("") + StringSpecs::MyString.new("")).should be_an_instance_of(String) - ("hello" + StringSpecs::MyString.new("foo")).should be_an_instance_of(String) - ("hello" + StringSpecs::MyString.new("")).should be_an_instance_of(String) + (StringSpecs::MyString.new("hello") + "").should.instance_of?(String) + (StringSpecs::MyString.new("hello") + "foo").should.instance_of?(String) + (StringSpecs::MyString.new("hello") + StringSpecs::MyString.new("foo")).should.instance_of?(String) + (StringSpecs::MyString.new("hello") + StringSpecs::MyString.new("")).should.instance_of?(String) + (StringSpecs::MyString.new("") + StringSpecs::MyString.new("")).should.instance_of?(String) + ("hello" + StringSpecs::MyString.new("foo")).should.instance_of?(String) + ("hello" + StringSpecs::MyString.new("")).should.instance_of?(String) end end diff --git a/spec/ruby/core/string/prepend_spec.rb b/spec/ruby/core/string/prepend_spec.rb index 5248ea8056b53f..a8da4e62cbbd20 100644 --- a/spec/ruby/core/string/prepend_spec.rb +++ b/spec/ruby/core/string/prepend_spec.rb @@ -5,7 +5,7 @@ describe "String#prepend" do it "prepends the given argument to self and returns self" do str = "world" - str.prepend("hello ").should equal(str) + str.prepend("hello ").should.equal?(str) str.should == "hello world" end @@ -17,16 +17,16 @@ end it "raises a TypeError if the given argument can't be converted to a String" do - -> { "hello ".prepend [] }.should raise_error(TypeError) - -> { 'hello '.prepend mock('x') }.should raise_error(TypeError) + -> { "hello ".prepend [] }.should.raise(TypeError) + -> { 'hello '.prepend mock('x') }.should.raise(TypeError) end it "raises a FrozenError when self is frozen" do a = "hello" a.freeze - -> { a.prepend "" }.should raise_error(FrozenError) - -> { a.prepend "test" }.should raise_error(FrozenError) + -> { a.prepend "" }.should.raise(FrozenError) + -> { a.prepend "test" }.should.raise(FrozenError) end it "works when given a subclass instance" do @@ -49,7 +49,7 @@ it "returns self when given no arguments" do str = "hello" - str.prepend.should equal(str) + str.prepend.should.equal?(str) str.should == "hello" end end diff --git a/spec/ruby/core/string/reverse_spec.rb b/spec/ruby/core/string/reverse_spec.rb index aa6abe6036e466..e37c1125db7b84 100644 --- a/spec/ruby/core/string/reverse_spec.rb +++ b/spec/ruby/core/string/reverse_spec.rb @@ -12,9 +12,9 @@ end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("stressed").reverse.should be_an_instance_of(String) - StringSpecs::MyString.new("m").reverse.should be_an_instance_of(String) - StringSpecs::MyString.new("").reverse.should be_an_instance_of(String) + StringSpecs::MyString.new("stressed").reverse.should.instance_of?(String) + StringSpecs::MyString.new("m").reverse.should.instance_of?(String) + StringSpecs::MyString.new("").reverse.should.instance_of?(String) end it "reverses a string with multi byte characters" do @@ -24,7 +24,7 @@ it "works with a broken string" do str = "微軟\xDF\xDE正黑體".force_encoding(Encoding::UTF_8) - str.valid_encoding?.should be_false + str.valid_encoding?.should == false str.reverse.should == "體黑正\xDE\xDF軟微" end @@ -37,20 +37,20 @@ describe "String#reverse!" do it "reverses self in place and always returns self" do a = "stressed" - a.reverse!.should equal(a) + a.reverse!.should.equal?(a) a.should == "desserts" "".reverse!.should == "" end it "raises a FrozenError on a frozen instance that is modified" do - -> { "anna".freeze.reverse! }.should raise_error(FrozenError) - -> { "hello".freeze.reverse! }.should raise_error(FrozenError) + -> { "anna".freeze.reverse! }.should.raise(FrozenError) + -> { "hello".freeze.reverse! }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen instance that would not be modified" do - -> { "".freeze.reverse! }.should raise_error(FrozenError) + -> { "".freeze.reverse! }.should.raise(FrozenError) end it "reverses a string with multi byte characters" do @@ -62,7 +62,7 @@ it "works with a broken string" do str = "微軟\xDF\xDE正黑體".force_encoding(Encoding::UTF_8) - str.valid_encoding?.should be_false + str.valid_encoding?.should == false str.reverse! str.should == "體黑正\xDE\xDF軟微" diff --git a/spec/ruby/core/string/rindex_spec.rb b/spec/ruby/core/string/rindex_spec.rb index 0863a9c3bed98b..acecec224f4024 100644 --- a/spec/ruby/core/string/rindex_spec.rb +++ b/spec/ruby/core/string/rindex_spec.rb @@ -5,19 +5,19 @@ describe "String#rindex with object" do it "raises a TypeError if obj isn't a String or Regexp" do not_supported_on :opal do - -> { "hello".rindex(:sym) }.should raise_error(TypeError) + -> { "hello".rindex(:sym) }.should.raise(TypeError) end - -> { "hello".rindex(mock('x')) }.should raise_error(TypeError) + -> { "hello".rindex(mock('x')) }.should.raise(TypeError) end it "raises a TypeError if obj is an Integer" do - -> { "hello".rindex(42) }.should raise_error(TypeError) + -> { "hello".rindex(42) }.should.raise(TypeError) end it "doesn't try to convert obj to an integer via to_int" do obj = mock('x') obj.should_not_receive(:to_int) - -> { "hello".rindex(obj) }.should raise_error(TypeError) + -> { "hello".rindex(obj) }.should.raise(TypeError) end it "tries to convert obj to a string via to_str" do @@ -193,7 +193,7 @@ def obj.method_missing(*args) 5 end end it "raises a TypeError when given offset is nil" do - -> { "str".rindex("st", nil) }.should raise_error(TypeError) + -> { "str".rindex("st", nil) }.should.raise(TypeError) end it "handles a substring in a superset encoding" do @@ -208,7 +208,7 @@ def obj.method_missing(*args) 5 end str = 'abc'.dup.force_encoding("ISO-2022-JP") pattern = 'b'.dup.force_encoding("EUC-JP") - -> { str.rindex(pattern) }.should raise_error(Encoding::CompatibilityError, "incompatible character encodings: ISO-2022-JP and EUC-JP") + -> { str.rindex(pattern) }.should.raise(Encoding::CompatibilityError, "incompatible character encodings: ISO-2022-JP and EUC-JP") end end @@ -362,7 +362,7 @@ def obj.method_missing(*args); 5; end end it "raises a TypeError when given offset is nil" do - -> { "str".rindex(/../, nil) }.should raise_error(TypeError) + -> { "str".rindex(/../, nil) }.should.raise(TypeError) end it "returns the reverse character index of a multibyte character" do @@ -379,6 +379,6 @@ def obj.method_missing(*args); 5; end re = Regexp.new "れ".encode(Encoding::EUC_JP) -> do "あれ".rindex re - end.should raise_error(Encoding::CompatibilityError, "incompatible encoding regexp match (EUC-JP regexp with UTF-8 string)") + end.should.raise(Encoding::CompatibilityError, "incompatible encoding regexp match (EUC-JP regexp with UTF-8 string)") end end diff --git a/spec/ruby/core/string/rjust_spec.rb b/spec/ruby/core/string/rjust_spec.rb index 4ad3e54aea2cf5..9f9c369745ec15 100644 --- a/spec/ruby/core/string/rjust_spec.rb +++ b/spec/ruby/core/string/rjust_spec.rb @@ -41,10 +41,10 @@ end it "raises a TypeError when length can't be converted to an integer" do - -> { "hello".rjust("x") }.should raise_error(TypeError) - -> { "hello".rjust("x", "y") }.should raise_error(TypeError) - -> { "hello".rjust([]) }.should raise_error(TypeError) - -> { "hello".rjust(mock('x')) }.should raise_error(TypeError) + -> { "hello".rjust("x") }.should.raise(TypeError) + -> { "hello".rjust("x", "y") }.should.raise(TypeError) + -> { "hello".rjust([]) }.should.raise(TypeError) + -> { "hello".rjust(mock('x')) }.should.raise(TypeError) end it "tries to convert padstr to a string using to_str" do @@ -55,22 +55,22 @@ end it "raises a TypeError when padstr can't be converted" do - -> { "hello".rjust(20, []) }.should raise_error(TypeError) - -> { "hello".rjust(20, Object.new)}.should raise_error(TypeError) - -> { "hello".rjust(20, mock('x')) }.should raise_error(TypeError) + -> { "hello".rjust(20, []) }.should.raise(TypeError) + -> { "hello".rjust(20, Object.new)}.should.raise(TypeError) + -> { "hello".rjust(20, mock('x')) }.should.raise(TypeError) end it "raises an ArgumentError when padstr is empty" do - -> { "hello".rjust(10, '') }.should raise_error(ArgumentError) + -> { "hello".rjust(10, '') }.should.raise(ArgumentError) end it "returns String instances when called on subclasses" do - StringSpecs::MyString.new("").rjust(10).should be_an_instance_of(String) - StringSpecs::MyString.new("foo").rjust(10).should be_an_instance_of(String) - StringSpecs::MyString.new("foo").rjust(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String) + StringSpecs::MyString.new("").rjust(10).should.instance_of?(String) + StringSpecs::MyString.new("foo").rjust(10).should.instance_of?(String) + StringSpecs::MyString.new("foo").rjust(10, StringSpecs::MyString.new("x")).should.instance_of?(String) - "".rjust(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String) - "foo".rjust(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String) + "".rjust(10, StringSpecs::MyString.new("x")).should.instance_of?(String) + "foo".rjust(10, StringSpecs::MyString.new("x")).should.instance_of?(String) end describe "with width" do @@ -78,7 +78,7 @@ str = "abc".dup.force_encoding Encoding::IBM437 result = str.rjust 5 result.should == " abc" - result.encoding.should equal(Encoding::IBM437) + result.encoding.should.equal?(Encoding::IBM437) end end @@ -87,14 +87,14 @@ str = "abc".dup.force_encoding Encoding::IBM437 result = str.rjust 5, "あ" result.should == "ああabc" - result.encoding.should equal(Encoding::UTF_8) + result.encoding.should.equal?(Encoding::UTF_8) end it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP -> do "あれ".rjust 5, pat - end.should raise_error(Encoding::CompatibilityError) + end.should.raise(Encoding::CompatibilityError) end end end diff --git a/spec/ruby/core/string/rpartition_spec.rb b/spec/ruby/core/string/rpartition_spec.rb index cef0384c7396c2..a7dd7430b73061 100644 --- a/spec/ruby/core/string/rpartition_spec.rb +++ b/spec/ruby/core/string/rpartition_spec.rb @@ -43,8 +43,8 @@ end it "raises an error if not convertible to string" do - ->{ "hello".rpartition(5) }.should raise_error(TypeError) - ->{ "hello".rpartition(nil) }.should raise_error(TypeError) + ->{ "hello".rpartition(5) }.should.raise(TypeError) + ->{ "hello".rpartition(nil) }.should.raise(TypeError) end it "handles a pattern in a superset encoding" do diff --git a/spec/ruby/core/string/rstrip_spec.rb b/spec/ruby/core/string/rstrip_spec.rb index 55773f52380640..1638ea375d9584 100644 --- a/spec/ruby/core/string/rstrip_spec.rb +++ b/spec/ruby/core/string/rstrip_spec.rb @@ -30,7 +30,7 @@ describe "String#rstrip!" do it "modifies self in place and returns self" do a = " hello " - a.rstrip!.should equal(a) + a.rstrip!.should.equal?(a) a.should == " hello" end @@ -59,22 +59,22 @@ end it "raises a FrozenError on a frozen instance that is modified" do - -> { " hello ".freeze.rstrip! }.should raise_error(FrozenError) + -> { " hello ".freeze.rstrip! }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen instance that would not be modified" do - -> { "hello".freeze.rstrip! }.should raise_error(FrozenError) - -> { "".freeze.rstrip! }.should raise_error(FrozenError) + -> { "hello".freeze.rstrip! }.should.raise(FrozenError) + -> { "".freeze.rstrip! }.should.raise(FrozenError) end it "raises an Encoding::CompatibilityError if the last non-space codepoint is invalid" do s = "abc\xDF".force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.rstrip! }.should raise_error(Encoding::CompatibilityError) + s.valid_encoding?.should == false + -> { s.rstrip! }.should.raise(Encoding::CompatibilityError) s = "abc\xDF ".force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.rstrip! }.should raise_error(Encoding::CompatibilityError) + s.valid_encoding?.should == false + -> { s.rstrip! }.should.raise(Encoding::CompatibilityError) end end diff --git a/spec/ruby/core/string/scan_spec.rb b/spec/ruby/core/string/scan_spec.rb index bbe843b591dbce..47fa7214c2442f 100644 --- a/spec/ruby/core/string/scan_spec.rb +++ b/spec/ruby/core/string/scan_spec.rb @@ -58,11 +58,11 @@ end it "raises a TypeError if pattern isn't a Regexp and can't be converted to a String" do - -> { "cruel world".scan(5) }.should raise_error(TypeError) + -> { "cruel world".scan(5) }.should.raise(TypeError) not_supported_on :opal do - -> { "cruel world".scan(:test) }.should raise_error(TypeError) + -> { "cruel world".scan(:test) }.should.raise(TypeError) end - -> { "cruel world".scan(mock('x')) }.should raise_error(TypeError) + -> { "cruel world".scan(mock('x')) }.should.raise(TypeError) end # jruby/jruby#5513 @@ -80,8 +80,8 @@ describe "String#scan with pattern and block" do it "returns self" do s = "foo" - s.scan(/./) {}.should equal(s) - s.scan(/roar/) {}.should equal(s) + s.scan(/./) {}.should.equal?(s) + s.scan(/roar/) {}.should.equal?(s) end it "passes each match to the block as one argument: an array" do diff --git a/spec/ruby/core/string/scrub_spec.rb b/spec/ruby/core/string/scrub_spec.rb index b9ef0f1a16e8c0..9dc55dbef7f638 100644 --- a/spec/ruby/core/string/scrub_spec.rb +++ b/spec/ruby/core/string/scrub_spec.rb @@ -38,9 +38,9 @@ end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("foo").scrub.should be_an_instance_of(String) + StringSpecs::MyString.new("foo").scrub.should.instance_of?(String) input = [0x81].pack('C').force_encoding('utf-8') - StringSpecs::MyString.new(input).scrub.should be_an_instance_of(String) + StringSpecs::MyString.new(input).scrub.should.instance_of?(String) end end @@ -75,7 +75,7 @@ xE4 = [0xE4].pack('C').force_encoding('utf-8') block = -> { "foo#{x81}".scrub(xE4) } - block.should raise_error(ArgumentError) + block.should.raise(ArgumentError) end it "returns a String in the same encoding as self" do @@ -87,13 +87,13 @@ x81 = [0x81].pack('C').force_encoding('utf-8') block = -> { "foo#{x81}".scrub(1) } - block.should raise_error(TypeError) + block.should.raise(TypeError) end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("foo").scrub("*").should be_an_instance_of(String) + StringSpecs::MyString.new("foo").scrub("*").should.instance_of?(String) input = [0x81].pack('C').force_encoding('utf-8') - StringSpecs::MyString.new(input).scrub("*").should be_an_instance_of(String) + StringSpecs::MyString.new(input).scrub("*").should.instance_of?(String) end end @@ -121,9 +121,9 @@ end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("foo").scrub { |b| "*" }.should be_an_instance_of(String) + StringSpecs::MyString.new("foo").scrub { |b| "*" }.should.instance_of?(String) input = [0x81].pack('C').force_encoding('utf-8') - StringSpecs::MyString.new(input).scrub { |b| "<#{b.unpack("H*")[0]}>" }.should be_an_instance_of(String) + StringSpecs::MyString.new(input).scrub { |b| "<#{b.unpack("H*")[0]}>" }.should.instance_of?(String) end end @@ -146,7 +146,7 @@ input = "a" input.freeze input.scrub! - input.frozen?.should be_true + input.frozen?.should == true end it "preserves the instance variables of already valid strings" do diff --git a/spec/ruby/core/string/setbyte_spec.rb b/spec/ruby/core/string/setbyte_spec.rb index 85403ca62c6cc7..d9fcc279c02a85 100644 --- a/spec/ruby/core/string/setbyte_spec.rb +++ b/spec/ruby/core/string/setbyte_spec.rb @@ -4,7 +4,7 @@ describe "String#setbyte" do it "returns an Integer" do - "a".setbyte(0,1).should be_kind_of(Integer) + "a".setbyte(0,1).should.is_a?(Integer) end it "modifies the receiver" do @@ -34,9 +34,9 @@ it "can invalidate a String's encoding" do str = "glark" - str.valid_encoding?.should be_true + str.valid_encoding?.should == true str.setbyte(2,253) - str.valid_encoding?.should be_false + str.valid_encoding?.should == false str = "ABC" str.setbyte(0, 0x20) # ' ' @@ -58,11 +58,11 @@ end it "raises an IndexError if the index is greater than the String bytesize" do - -> { "?".setbyte(1, 97) }.should raise_error(IndexError) + -> { "?".setbyte(1, 97) }.should.raise(IndexError) end it "raises an IndexError if the negative index is greater magnitude than the String bytesize" do - -> { "???".setbyte(-5, 97) }.should raise_error(IndexError) + -> { "???".setbyte(-5, 97) }.should.raise(IndexError) end it "sets a byte at an index greater than String size" do @@ -84,12 +84,12 @@ it "raises a FrozenError if self is frozen" do str = "cold".freeze - str.frozen?.should be_true - -> { str.setbyte(3,96) }.should raise_error(FrozenError) + str.frozen?.should == true + -> { str.setbyte(3,96) }.should.raise(FrozenError) end it "raises a TypeError unless the second argument is an Integer" do - -> { "a".setbyte(0,'a') }.should raise_error(TypeError) + -> { "a".setbyte(0,'a') }.should.raise(TypeError) end it "calls #to_int to convert the index" do diff --git a/spec/ruby/core/string/shared/byte_index_common.rb b/spec/ruby/core/string/shared/byte_index_common.rb index 3de1453f4f9462..bae6cff49f9353 100644 --- a/spec/ruby/core/string/shared/byte_index_common.rb +++ b/spec/ruby/core/string/shared/byte_index_common.rb @@ -4,43 +4,43 @@ describe :byte_index_common, shared: true do describe "raises on type errors" do it "raises a TypeError if passed nil" do - -> { "abc".send(@method, nil) }.should raise_error(TypeError, "no implicit conversion of nil into String") + -> { "abc".send(@method, nil) }.should.raise(TypeError, "no implicit conversion of nil into String") end it "raises a TypeError if passed a boolean" do - -> { "abc".send(@method, true) }.should raise_error(TypeError, "no implicit conversion of true into String") + -> { "abc".send(@method, true) }.should.raise(TypeError, "no implicit conversion of true into String") end it "raises a TypeError if passed a Symbol" do not_supported_on :opal do - -> { "abc".send(@method, :a) }.should raise_error(TypeError, "no implicit conversion of Symbol into String") + -> { "abc".send(@method, :a) }.should.raise(TypeError, "no implicit conversion of Symbol into String") end end it "raises a TypeError if passed a Symbol" do obj = mock('x') obj.should_not_receive(:to_int) - -> { "hello".send(@method, obj) }.should raise_error(TypeError, "no implicit conversion of MockObject into String") + -> { "hello".send(@method, obj) }.should.raise(TypeError, "no implicit conversion of MockObject into String") end it "raises a TypeError if passed an Integer" do - -> { "abc".send(@method, 97) }.should raise_error(TypeError, "no implicit conversion of Integer into String") + -> { "abc".send(@method, 97) }.should.raise(TypeError, "no implicit conversion of Integer into String") end end describe "with multibyte codepoints" do it "raises an IndexError when byte offset lands in the middle of a multibyte character" do - -> { "わ".send(@method, "", 1) }.should raise_error(IndexError, "offset 1 does not land on character boundary") - -> { "わ".send(@method, "", 2) }.should raise_error(IndexError, "offset 2 does not land on character boundary") - -> { "わ".send(@method, "", -1) }.should raise_error(IndexError, "offset 2 does not land on character boundary") - -> { "わ".send(@method, "", -2) }.should raise_error(IndexError, "offset 1 does not land on character boundary") + -> { "わ".send(@method, "", 1) }.should.raise(IndexError, "offset 1 does not land on character boundary") + -> { "わ".send(@method, "", 2) }.should.raise(IndexError, "offset 2 does not land on character boundary") + -> { "わ".send(@method, "", -1) }.should.raise(IndexError, "offset 2 does not land on character boundary") + -> { "わ".send(@method, "", -2) }.should.raise(IndexError, "offset 1 does not land on character boundary") end it "raises an Encoding::CompatibilityError if the encodings are incompatible" do re = Regexp.new "れ".encode(Encoding::EUC_JP) -> do "あれ".send(@method, re) - end.should raise_error(Encoding::CompatibilityError, "incompatible encoding regexp match (EUC-JP regexp with UTF-8 string)") + end.should.raise(Encoding::CompatibilityError, "incompatible encoding regexp match (EUC-JP regexp with UTF-8 string)") end end diff --git a/spec/ruby/core/string/shared/chars.rb b/spec/ruby/core/string/shared/chars.rb index 74a32fb513f024..826d4035899b57 100644 --- a/spec/ruby/core/string/shared/chars.rb +++ b/spec/ruby/core/string/shared/chars.rb @@ -11,7 +11,7 @@ it "returns self" do s = StringSpecs::MyString.new "hello" - s.send(@method){}.should equal(s) + s.send(@method){}.should.equal?(s) end it "is unicode aware" do @@ -33,7 +33,7 @@ it "works if the String's contents is invalid for its encoding" do xA4 = [0xA4].pack('C') xA4.force_encoding('UTF-8') - xA4.valid_encoding?.should be_false + xA4.valid_encoding?.should == false xA4.send(@method).to_a.should == [xA4.force_encoding("UTF-8")] end diff --git a/spec/ruby/core/string/shared/codepoints.rb b/spec/ruby/core/string/shared/codepoints.rb index ecdf7d719db553..b6abf6a3ffe4b4 100644 --- a/spec/ruby/core/string/shared/codepoints.rb +++ b/spec/ruby/core/string/shared/codepoints.rb @@ -3,13 +3,13 @@ it "returns self" do s = "foo" result = s.send(@method) {} - result.should equal s + result.should.equal? s end it "raises an ArgumentError when self has an invalid encoding and a method is called on the returned Enumerator" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.send(@method).to_a }.should raise_error(ArgumentError) + s.valid_encoding?.should == false + -> { s.send(@method).to_a }.should.raise(ArgumentError) end it "yields each codepoint to the block if one is given" do @@ -22,13 +22,13 @@ it "raises an ArgumentError if self's encoding is invalid and a block is given" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.send(@method) { } }.should raise_error(ArgumentError) + s.valid_encoding?.should == false + -> { s.send(@method) { } }.should.raise(ArgumentError) end it "yields codepoints as Integers" do "glark\u{20}".send(@method).to_a.each do |codepoint| - codepoint.should be_an_instance_of(Integer) + codepoint.should.instance_of?(Integer) end end @@ -56,7 +56,7 @@ it "is synonymous with #bytes for Strings which are single-byte optimizable" do s = "(){}".encode('ascii') - s.ascii_only?.should be_true + s.ascii_only?.should == true s.send(@method).to_a.should == s.bytes.to_a end diff --git a/spec/ruby/core/string/shared/concat.rb b/spec/ruby/core/string/shared/concat.rb index dded9a69e73e35..60cd0e12d4917b 100644 --- a/spec/ruby/core/string/shared/concat.rb +++ b/spec/ruby/core/string/shared/concat.rb @@ -2,7 +2,7 @@ describe :string_concat, shared: true do it "concatenates the given argument to self and returns self" do str = 'hello ' - str.send(@method, 'world').should equal(str) + str.send(@method, 'world').should.equal?(str) str.should == "hello world" end @@ -10,22 +10,22 @@ a = "hello" a.freeze - -> { a.send(@method, "") }.should raise_error(FrozenError) - -> { a.send(@method, "test") }.should raise_error(FrozenError) + -> { a.send(@method, "") }.should.raise(FrozenError) + -> { a.send(@method, "test") }.should.raise(FrozenError) end it "returns a String when given a subclass instance" do a = "hello" a.send(@method, StringSpecs::MyString.new(" world")) a.should == "hello world" - a.should be_an_instance_of(String) + a.should.instance_of?(String) end it "returns an instance of same class when called on a subclass" do str = StringSpecs::MyString.new("hello") str.send(@method, " world") str.should == "hello world" - str.should be_an_instance_of(StringSpecs::MyString) + str.should.instance_of?(StringSpecs::MyString) end describe "with Integer" do @@ -50,28 +50,28 @@ end it "raises RangeError if the argument is an invalid codepoint for self's encoding" do - -> { "".encode(Encoding::US_ASCII).send(@method, 256) }.should raise_error(RangeError) - -> { "".encode(Encoding::EUC_JP).send(@method, 0x81) }.should raise_error(RangeError) + -> { "".encode(Encoding::US_ASCII).send(@method, 256) }.should.raise(RangeError) + -> { "".encode(Encoding::EUC_JP).send(@method, 0x81) }.should.raise(RangeError) end it "raises RangeError if the argument is negative" do - -> { "".send(@method, -200) }.should raise_error(RangeError) - -> { "".send(@method, -bignum_value) }.should raise_error(RangeError) + -> { "".send(@method, -200) }.should.raise(RangeError) + -> { "".send(@method, -bignum_value) }.should.raise(RangeError) end it "doesn't call to_int on its argument" do x = mock('x') x.should_not_receive(:to_int) - -> { "".send(@method, x) }.should raise_error(TypeError) + -> { "".send(@method, x) }.should.raise(TypeError) end it "raises a FrozenError when self is frozen" do a = "hello" a.freeze - -> { a.send(@method, 0) }.should raise_error(FrozenError) - -> { a.send(@method, 33) }.should raise_error(FrozenError) + -> { a.send(@method, 0) }.should.raise(FrozenError) + -> { a.send(@method, 33) }.should.raise(FrozenError) end end end @@ -91,7 +91,7 @@ end it "raises Encoding::CompatibilityError if neither are empty" do - -> { "x".encode("UTF-16LE").send(@method, "y".encode("UTF-8")) }.should raise_error(Encoding::CompatibilityError) + -> { "x".encode("UTF-16LE").send(@method, "y".encode("UTF-8")) }.should.raise(Encoding::CompatibilityError) end end @@ -109,7 +109,7 @@ end it "raises Encoding::CompatibilityError if neither are empty" do - -> { "x".encode("UTF-8").send(@method, "y".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError) + -> { "x".encode("UTF-8").send(@method, "y".encode("UTF-16LE")) }.should.raise(Encoding::CompatibilityError) end end @@ -127,7 +127,7 @@ end it "raises Encoding::CompatibilityError if neither are ASCII-only" do - -> { "\u00E9".encode("UTF-8").send(@method, "\u00E9".encode("ISO-8859-1")) }.should raise_error(Encoding::CompatibilityError) + -> { "\u00E9".encode("UTF-8").send(@method, "\u00E9".encode("ISO-8859-1")) }.should.raise(Encoding::CompatibilityError) end end @@ -147,13 +147,13 @@ end it "raises a TypeError if the given argument can't be converted to a String" do - -> { 'hello '.send(@method, []) }.should raise_error(TypeError) - -> { 'hello '.send(@method, mock('x')) }.should raise_error(TypeError) + -> { 'hello '.send(@method, []) }.should.raise(TypeError) + -> { 'hello '.send(@method, mock('x')) }.should.raise(TypeError) end it "raises a NoMethodError if the given argument raises a NoMethodError during type coercion to a String" do obj = mock('world!') obj.should_receive(:to_str).and_raise(NoMethodError) - -> { 'hello '.send(@method, obj) }.should raise_error(NoMethodError) + -> { 'hello '.send(@method, obj) }.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/string/shared/dedup.rb b/spec/ruby/core/string/shared/dedup.rb index 1ffd6aa0fd0ef1..59506c290144e2 100644 --- a/spec/ruby/core/string/shared/dedup.rb +++ b/spec/ruby/core/string/shared/dedup.rb @@ -4,7 +4,7 @@ input = 'foo'.freeze output = input.send(@method) - output.should equal(input) + output.should.equal?(input) output.should.frozen? end @@ -13,7 +13,7 @@ output = input.send(@method) output.should.frozen? - output.should_not equal(input) + output.should_not.equal?(input) output.should == 'foo' end @@ -21,22 +21,22 @@ origin = "this is a string" dynamic = %w(this is a string).join(' ') - origin.should_not equal(dynamic) - origin.send(@method).should equal(dynamic.send(@method)) + origin.should_not.equal?(dynamic) + origin.send(@method).should.equal?(dynamic.send(@method)) end it "returns the same object when it's called on the same String literal" do - "unfrozen string".send(@method).should equal("unfrozen string".send(@method)) - "unfrozen string".send(@method).should_not equal("another unfrozen string".send(@method)) + "unfrozen string".send(@method).should.equal?("unfrozen string".send(@method)) + "unfrozen string".send(@method).should_not.equal?("another unfrozen string".send(@method)) end it "deduplicates frozen strings" do dynamic = %w(this string is frozen).join(' ').freeze - dynamic.should_not equal("this string is frozen".freeze) + dynamic.should_not.equal?("this string is frozen".freeze) - dynamic.send(@method).should equal("this string is frozen".freeze) - dynamic.send(@method).should equal("this string is frozen".send(@method).freeze) + dynamic.send(@method).should.equal?("this string is frozen".freeze) + dynamic.send(@method).should.equal?("this string is frozen".send(@method).freeze) end it "does not deduplicate a frozen string when it has instance variables" do @@ -44,8 +44,8 @@ dynamic.instance_variable_set(:@a, 1) dynamic.freeze - dynamic.send(@method).should_not equal("this string is frozen".freeze) - dynamic.send(@method).should_not equal("this string is frozen".send(@method).freeze) - dynamic.send(@method).should equal(dynamic) + dynamic.send(@method).should_not.equal?("this string is frozen".freeze) + dynamic.send(@method).should_not.equal?("this string is frozen".send(@method).freeze) + dynamic.send(@method).should.equal?(dynamic) end end diff --git a/spec/ruby/core/string/shared/each_char_without_block.rb b/spec/ruby/core/string/shared/each_char_without_block.rb index 397100ce0eb389..3c32bae42b9cb9 100644 --- a/spec/ruby/core/string/shared/each_char_without_block.rb +++ b/spec/ruby/core/string/shared/each_char_without_block.rb @@ -6,7 +6,7 @@ describe "when no block is given" do it "returns an enumerator" do enum = "hello".send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == ['h', 'e', 'l', 'l', 'o'] end diff --git a/spec/ruby/core/string/shared/each_codepoint_without_block.rb b/spec/ruby/core/string/shared/each_codepoint_without_block.rb index c88e5c54c75993..60d603954c3e34 100644 --- a/spec/ruby/core/string/shared/each_codepoint_without_block.rb +++ b/spec/ruby/core/string/shared/each_codepoint_without_block.rb @@ -2,13 +2,13 @@ describe :string_each_codepoint_without_block, shared: true do describe "when no block is given" do it "returns an Enumerator" do - "".send(@method).should be_an_instance_of(Enumerator) + "".send(@method).should.instance_of?(Enumerator) end it "returns an Enumerator even when self has an invalid encoding" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - s.send(@method).should be_an_instance_of(Enumerator) + s.valid_encoding?.should == false + s.send(@method).should.instance_of?(Enumerator) end describe "returned Enumerator" do @@ -24,7 +24,7 @@ it "should return the size of the string even when the string has an invalid encoding" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false + s.valid_encoding?.should == false s.send(@method).size.should == 1 end end diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb index c2f3abfa80e0a6..d79c2b74c4aeee 100644 --- a/spec/ruby/core/string/shared/each_line.rb +++ b/spec/ruby/core/string/shared/each_line.rb @@ -93,7 +93,7 @@ it "returns self" do s = "hello\nworld" - (s.send(@method) {}).should equal(s) + (s.send(@method) {}).should.equal?(s) end it "tries to convert the separator to a string using to_str" do @@ -119,8 +119,8 @@ end it "raises a TypeError when the separator can't be converted to a string" do - -> { "hello world".send(@method, false) {} }.should raise_error(TypeError) - -> { "hello world".send(@method, mock('x')) {} }.should raise_error(TypeError) + -> { "hello world".send(@method, false) {} }.should.raise(TypeError) + -> { "hello world".send(@method, mock('x')) {} }.should.raise(TypeError) end it "accepts a string separator" do @@ -128,7 +128,7 @@ end it "raises a TypeError when the separator is a symbol" do - -> { "hello world".send(@method, :o).to_a }.should raise_error(TypeError) + -> { "hello world".send(@method, :o).to_a }.should.raise(TypeError) end context "when `chomp` keyword argument is passed" do @@ -171,6 +171,6 @@ it "raises Encoding::ConverterNotFoundError for dummy UTF-7" do str = "a\nb".dup.force_encoding(Encoding::UTF_7) - -> { str.lines }.should raise_error(Encoding::ConverterNotFoundError) + -> { str.lines }.should.raise(Encoding::ConverterNotFoundError) end end diff --git a/spec/ruby/core/string/shared/each_line_without_block.rb b/spec/ruby/core/string/shared/each_line_without_block.rb index 8e08b0390c9521..af0ab69c005a5f 100644 --- a/spec/ruby/core/string/shared/each_line_without_block.rb +++ b/spec/ruby/core/string/shared/each_line_without_block.rb @@ -2,7 +2,7 @@ describe "when no block is given" do it "returns an enumerator" do enum = "hello world".send(@method, ' ') - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == ["hello ", "world"] end diff --git a/spec/ruby/core/string/shared/encode.rb b/spec/ruby/core/string/shared/encode.rb index 51a117c90ed564..7f644c26d9ae07 100644 --- a/spec/ruby/core/string/shared/encode.rb +++ b/spec/ruby/core/string/shared/encode.rb @@ -11,7 +11,7 @@ it "transcodes a 7-bit String despite no generic converting being available" do -> do Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) Encoding.default_internal = Encoding::Emacs_Mule str = "\x79".force_encoding Encoding::BINARY @@ -22,7 +22,7 @@ it "raises an Encoding::ConverterNotFoundError when no conversion is possible" do Encoding.default_internal = Encoding::Emacs_Mule str = [0x80].pack('C').force_encoding Encoding::BINARY - -> { str.send(@method) }.should raise_error(Encoding::ConverterNotFoundError) + -> { str.send(@method) }.should.raise(Encoding::ConverterNotFoundError) end end @@ -54,7 +54,7 @@ it "transcodes a 7-bit String despite no generic converting being available" do -> do Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) str = "\x79".force_encoding Encoding::BINARY str.send(@method, Encoding::Emacs_Mule).should == "y".force_encoding(Encoding::BINARY) @@ -64,13 +64,13 @@ str = [0x80].pack('C').force_encoding Encoding::BINARY -> do str.send(@method, Encoding::Emacs_Mule) - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) end it "raises an Encoding::ConverterNotFoundError for an invalid encoding" do -> do "abc".send(@method, "xyz") - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) end it "raises an Encoding::UndefinedConversionError when a character cannot be represented in the destination encoding" do @@ -78,7 +78,7 @@ str = "test\u0100".force_encoding('utf-8') -> { str.send(@method, Encoding::Windows_1252) - }.should raise_error(Encoding::UndefinedConversionError) + }.should.raise(Encoding::UndefinedConversionError) end end @@ -107,7 +107,7 @@ str = [0x80].pack('C').force_encoding Encoding::BINARY -> do str.send(@method, invalid: :replace, undef: :replace) - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) end it "replaces invalid characters when replacing Emacs-Mule encoded strings" do @@ -155,7 +155,7 @@ str = "test\u0100".force_encoding('utf-8') -> { str.send(@method, Encoding::Windows_1252, invalid: :replace, replace: "") - }.should raise_error(Encoding::UndefinedConversionError) + }.should.raise(Encoding::UndefinedConversionError) end it "calls #to_hash to convert the options object" do @@ -229,19 +229,19 @@ obj.should_not_receive(:to_s) -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: { "\ufffd" => obj }) - }.should raise_error(TypeError, "no implicit conversion of Object into String") + }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises an error if the key is not present in the hash" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: { "foo" => "bar" }) - }.should raise_error(Encoding::UndefinedConversionError, "U+FFFD from UTF-8 to US-ASCII") + }.should.raise(Encoding::UndefinedConversionError, "U+FFFD from UTF-8 to US-ASCII") end it "raises an error if the value is itself invalid" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: { "\ufffd" => "\uffee" }) - }.should raise_error(ArgumentError, "too big fallback string") + }.should.raise(ArgumentError, "too big fallback string") end it "uses the hash's default value if set" do @@ -294,7 +294,7 @@ def [](c) = c.bytes.inspect it "raises an error" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: @non_hash_like) - }.should raise_error(Encoding::UndefinedConversionError, "U+FFFD from UTF-8 to US-ASCII") + }.should.raise(Encoding::UndefinedConversionError, "U+FFFD from UTF-8 to US-ASCII") end end @@ -316,13 +316,13 @@ def [](c) = c.bytes.inspect obj.should_not_receive(:to_s) -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: proc { |c| obj }) - }.should raise_error(TypeError, "no implicit conversion of Object into String") + }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises an error if the returned value is itself invalid" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: -> c { "\uffee" }) - }.should raise_error(ArgumentError, "too big fallback string") + }.should.raise(ArgumentError, "too big fallback string") end end @@ -344,13 +344,13 @@ def [](c) = c.bytes.inspect obj.should_not_receive(:to_s) -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: -> c { obj }) - }.should raise_error(TypeError, "no implicit conversion of Object into String") + }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises an error if the returned value is itself invalid" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: -> c { "\uffee" }) - }.should raise_error(ArgumentError, "too big fallback string") + }.should.raise(ArgumentError, "too big fallback string") end end @@ -383,13 +383,13 @@ def replace_to_s(c) it "does not call to_s on the returned value" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: method(:replace_to_s)) - }.should raise_error(TypeError, "no implicit conversion of Object into String") + }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises an error if the returned value is itself invalid" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: method(:replace_bad)) - }.should raise_error(ArgumentError, "too big fallback string") + }.should.raise(ArgumentError, "too big fallback string") end end end @@ -443,6 +443,6 @@ def replace_to_s(c) end it "raises ArgumentError if the value of the :xml option is not :text or :attr" do - -> { ''.send(@method, "UTF-8", xml: :other) }.should raise_error(ArgumentError) + -> { ''.send(@method, "UTF-8", xml: :other) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/shared/eql.rb b/spec/ruby/core/string/shared/eql.rb index d5af337d53c117..0e356c69e8597c 100644 --- a/spec/ruby/core/string/shared/eql.rb +++ b/spec/ruby/core/string/shared/eql.rb @@ -4,32 +4,32 @@ describe :string_eql_value, shared: true do it "returns true if self <=> string returns 0" do - 'hello'.send(@method, 'hello').should be_true + 'hello'.send(@method, 'hello').should == true end it "returns false if self <=> string does not return 0" do - "more".send(@method, "MORE").should be_false - "less".send(@method, "greater").should be_false + "more".send(@method, "MORE").should == false + "less".send(@method, "greater").should == false end it "ignores encoding difference of compatible string" do - "hello".dup.force_encoding("utf-8").send(@method, "hello".dup.force_encoding("iso-8859-1")).should be_true + "hello".dup.force_encoding("utf-8").send(@method, "hello".dup.force_encoding("iso-8859-1")).should == true end it "considers encoding difference of incompatible string" do - "\xff".dup.force_encoding("utf-8").send(@method, "\xff".dup.force_encoding("iso-8859-1")).should be_false + "\xff".dup.force_encoding("utf-8").send(@method, "\xff".dup.force_encoding("iso-8859-1")).should == false end it "considers encoding compatibility" do - "abcd".dup.force_encoding("utf-8").send(@method, "abcd".dup.force_encoding("utf-32le")).should be_false + "abcd".dup.force_encoding("utf-8").send(@method, "abcd".dup.force_encoding("utf-32le")).should == false end it "ignores subclass differences" do a = "hello" b = StringSpecs::MyString.new("hello") - a.send(@method, b).should be_true - b.send(@method, a).should be_true + a.send(@method, b).should == true + b.send(@method, a).should == true end it "returns true when comparing 2 empty strings but one is not ASCII-compatible" do diff --git a/spec/ruby/core/string/shared/equal_value.rb b/spec/ruby/core/string/shared/equal_value.rb index fccafb5821bde8..dfc5c7cd29e66f 100644 --- a/spec/ruby/core/string/shared/equal_value.rb +++ b/spec/ruby/core/string/shared/equal_value.rb @@ -3,11 +3,11 @@ describe :string_equal_value, shared: true do it "returns false if obj does not respond to to_str" do - 'hello'.send(@method, 5).should be_false + 'hello'.send(@method, 5).should == false not_supported_on :opal do - 'hello'.send(@method, :hello).should be_false + 'hello'.send(@method, :hello).should == false end - 'hello'.send(@method, mock('x')).should be_false + 'hello'.send(@method, mock('x')).should == false end it "returns obj == self if obj responds to to_str" do @@ -20,10 +20,10 @@ # Don't use @method for :== in `obj.should_receive(:==)` obj.should_receive(:==).and_return(true) - 'hello'.send(@method, obj).should be_true + 'hello'.send(@method, obj).should == true end it "is not fooled by NUL characters" do - "abc\0def".send(@method, "abc\0xyz").should be_false + "abc\0def".send(@method, "abc\0xyz").should == false end end diff --git a/spec/ruby/core/string/shared/grapheme_clusters.rb b/spec/ruby/core/string/shared/grapheme_clusters.rb index 985b558f08a03e..dd8c7ed5fefd77 100644 --- a/spec/ruby/core/string/shared/grapheme_clusters.rb +++ b/spec/ruby/core/string/shared/grapheme_clusters.rb @@ -20,6 +20,6 @@ it "returns self" do s = StringSpecs::MyString.new "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}" - s.send(@method) {}.should equal(s) + s.send(@method) {}.should.equal?(s) end end diff --git a/spec/ruby/core/string/shared/partition.rb b/spec/ruby/core/string/shared/partition.rb index 4cac149ce5765c..3f7e606eb31d3c 100644 --- a/spec/ruby/core/string/shared/partition.rb +++ b/spec/ruby/core/string/shared/partition.rb @@ -4,15 +4,15 @@ describe :string_partition, shared: true do it "returns String instances when called on a subclass" do StringSpecs::MyString.new("hello").send(@method, "l").each do |item| - item.should be_an_instance_of(String) + item.should.instance_of?(String) end StringSpecs::MyString.new("hello").send(@method, "x").each do |item| - item.should be_an_instance_of(String) + item.should.instance_of?(String) end StringSpecs::MyString.new("hello").send(@method, /l./).each do |item| - item.should be_an_instance_of(String) + item.should.instance_of?(String) end end diff --git a/spec/ruby/core/string/shared/replace.rb b/spec/ruby/core/string/shared/replace.rb index 24dac0eb270873..73b26351f1d609 100644 --- a/spec/ruby/core/string/shared/replace.rb +++ b/spec/ruby/core/string/shared/replace.rb @@ -2,7 +2,7 @@ describe :string_replace, shared: true do it "returns self" do a = "a" - a.send(@method, "b").should equal(a) + a.send(@method, "b").should.equal?(a) end it "replaces the content of self with other" do @@ -20,7 +20,7 @@ it "carries over the encoding invalidity" do a = "\u{8765}".force_encoding('ascii') - "".send(@method, a).valid_encoding?.should be_false + "".send(@method, a).valid_encoding?.should == false end it "tries to convert other to string using to_str" do @@ -30,19 +30,19 @@ end it "raises a TypeError if other can't be converted to string" do - -> { "hello".send(@method, 123) }.should raise_error(TypeError) - -> { "hello".send(@method, []) }.should raise_error(TypeError) - -> { "hello".send(@method, mock('x')) }.should raise_error(TypeError) + -> { "hello".send(@method, 123) }.should.raise(TypeError) + -> { "hello".send(@method, []) }.should.raise(TypeError) + -> { "hello".send(@method, mock('x')) }.should.raise(TypeError) end it "raises a FrozenError on a frozen instance that is modified" do a = "hello".freeze - -> { a.send(@method, "world") }.should raise_error(FrozenError) + -> { a.send(@method, "world") }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen instance when self-replacing" do a = "hello".freeze - -> { a.send(@method, a) }.should raise_error(FrozenError) + -> { a.send(@method, a) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/shared/slice.rb b/spec/ruby/core/string/shared/slice.rb index 7b9b9f6a14cc5f..d296ab66803c4b 100644 --- a/spec/ruby/core/string/shared/slice.rb +++ b/spec/ruby/core/string/shared/slice.rb @@ -21,17 +21,17 @@ end it "raises a TypeError if the given index is nil" do - -> { "hello".send(@method, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, nil) }.should.raise(TypeError) end it "raises a TypeError if the given index can't be converted to an Integer" do - -> { "hello".send(@method, mock('x')) }.should raise_error(TypeError) - -> { "hello".send(@method, {}) }.should raise_error(TypeError) - -> { "hello".send(@method, []) }.should raise_error(TypeError) + -> { "hello".send(@method, mock('x')) }.should.raise(TypeError) + -> { "hello".send(@method, {}) }.should.raise(TypeError) + -> { "hello".send(@method, []) }.should.raise(TypeError) end it "raises a RangeError if the index is too big" do - -> { "hello".send(@method, bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, bignum_value) }.should.raise(RangeError) end end @@ -145,35 +145,35 @@ end it "raises a TypeError when idx or length can't be converted to an integer" do - -> { "hello".send(@method, mock('x'), 0) }.should raise_error(TypeError) - -> { "hello".send(@method, 0, mock('x')) }.should raise_error(TypeError) + -> { "hello".send(@method, mock('x'), 0) }.should.raise(TypeError) + -> { "hello".send(@method, 0, mock('x')) }.should.raise(TypeError) # I'm deliberately including this here. # It means that str.send(@method, other, idx) isn't supported. - -> { "hello".send(@method, "", 0) }.should raise_error(TypeError) + -> { "hello".send(@method, "", 0) }.should.raise(TypeError) end it "raises a TypeError when the given index or the given length is nil" do - -> { "hello".send(@method, 1, nil) }.should raise_error(TypeError) - -> { "hello".send(@method, nil, 1) }.should raise_error(TypeError) - -> { "hello".send(@method, nil, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, 1, nil) }.should.raise(TypeError) + -> { "hello".send(@method, nil, 1) }.should.raise(TypeError) + -> { "hello".send(@method, nil, nil) }.should.raise(TypeError) end it "raises a RangeError if the index or length is too big" do - -> { "hello".send(@method, bignum_value, 1) }.should raise_error(RangeError) - -> { "hello".send(@method, 0, bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, bignum_value, 1) }.should.raise(RangeError) + -> { "hello".send(@method, 0, bignum_value) }.should.raise(RangeError) end it "raises a RangeError if the index or length is too small" do - -> { "hello".send(@method, -bignum_value, 1) }.should raise_error(RangeError) - -> { "hello".send(@method, 0, -bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, -bignum_value, 1) }.should.raise(RangeError) + -> { "hello".send(@method, 0, -bignum_value) }.should.raise(RangeError) end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, 0,0).should be_an_instance_of(String) - s.send(@method, 0,4).should be_an_instance_of(String) - s.send(@method, 1,4).should be_an_instance_of(String) + s.send(@method, 0,0).should.instance_of?(String) + s.send(@method, 0,4).should.instance_of?(String) + s.send(@method, 1,4).should.instance_of?(String) end it "handles repeated application" do @@ -250,9 +250,9 @@ it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, 0...0).should be_an_instance_of(String) - s.send(@method, 0..4).should be_an_instance_of(String) - s.send(@method, 1..4).should be_an_instance_of(String) + s.send(@method, 0...0).should.instance_of?(String) + s.send(@method, 0..4).should.instance_of?(String) + s.send(@method, 1..4).should.instance_of?(String) end it "calls to_int on range arguments" do @@ -293,12 +293,12 @@ end it "raises a type error if a range is passed with a length" do - ->{ "hello".send(@method, 1..2, 1) }.should raise_error(TypeError) + ->{ "hello".send(@method, 1..2, 1) }.should.raise(TypeError) end it "raises a RangeError if one of the bound is too big" do - -> { "hello".send(@method, bignum_value..(bignum_value + 1)) }.should raise_error(RangeError) - -> { "hello".send(@method, 0..bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, bignum_value..(bignum_value + 1)) }.should.raise(RangeError) + -> { "hello".send(@method, 0..bignum_value) }.should.raise(RangeError) end it "works with endless ranges" do @@ -333,8 +333,8 @@ it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, //).should be_an_instance_of(String) - s.send(@method, /../).should be_an_instance_of(String) + s.send(@method, //).should.instance_of?(String) + s.send(@method, /../).should.instance_of?(String) end it "sets $~ to MatchData when there is a match and nil when there's none" do @@ -394,19 +394,19 @@ end it "raises a TypeError when the given index can't be converted to Integer" do - -> { "hello".send(@method, /(.)(.)(.)/, mock('x')) }.should raise_error(TypeError) - -> { "hello".send(@method, /(.)(.)(.)/, {}) }.should raise_error(TypeError) - -> { "hello".send(@method, /(.)(.)(.)/, []) }.should raise_error(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, mock('x')) }.should.raise(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, {}) }.should.raise(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, []) }.should.raise(TypeError) end it "raises a TypeError when the given index is nil" do - -> { "hello".send(@method, /(.)(.)(.)/, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, nil) }.should.raise(TypeError) end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, /(.)(.)/, 0).should be_an_instance_of(String) - s.send(@method, /(.)(.)/, 1).should be_an_instance_of(String) + s.send(@method, /(.)(.)/, 0).should.instance_of?(String) + s.send(@method, /(.)(.)/, 1).should.instance_of?(String) end it "sets $~ to MatchData when there is a match and nil when there's none" do @@ -442,14 +442,14 @@ o = mock('x') o.should_not_receive(:to_str) - -> { "hello".send(@method, o) }.should raise_error(TypeError) + -> { "hello".send(@method, o) }.should.raise(TypeError) end it "returns a String instance when given a subclass instance" do s = StringSpecs::MyString.new("el") r = "hello".send(@method, s) r.should == "el" - r.should be_an_instance_of(String) + r.should.instance_of?(String) end end @@ -476,28 +476,28 @@ end it "returns nil if there is no match" do - "hello there".send(@method, /(?what?)/, 'whut').should be_nil + "hello there".send(@method, /(?what?)/, 'whut').should == nil end it "raises an IndexError if there is no capture for the given name" do -> do "hello there".send(@method, /[aeiou](.)\1/, 'non') - end.should raise_error(IndexError) + end.should.raise(IndexError) end it "raises a TypeError when the given name is not a String" do - -> { "hello".send(@method, /(?.)/, mock('x')) }.should raise_error(TypeError) - -> { "hello".send(@method, /(?.)/, {}) }.should raise_error(TypeError) - -> { "hello".send(@method, /(?.)/, []) }.should raise_error(TypeError) + -> { "hello".send(@method, /(?.)/, mock('x')) }.should.raise(TypeError) + -> { "hello".send(@method, /(?.)/, {}) }.should.raise(TypeError) + -> { "hello".send(@method, /(?.)/, []) }.should.raise(TypeError) end it "raises an IndexError when given the empty String as a group name" do - -> { "hello".send(@method, /(?)/, '') }.should raise_error(IndexError) + -> { "hello".send(@method, /(?)/, '') }.should.raise(IndexError) end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, /(?.)/, 'q').should be_an_instance_of(String) + s.send(@method, /(?.)/, 'q').should.instance_of?(String) end it "sets $~ to MatchData when there is a match and nil when there's none" do @@ -505,13 +505,13 @@ $~[0].should == 'he' 'hello'.send(@method, /(?not)/, 'non') - $~.should be_nil + $~.should == nil end end end describe :string_slice_symbol, shared: true do it "raises TypeError" do - -> { 'hello'.send(@method, :hello) }.should raise_error(TypeError) + -> { 'hello'.send(@method, :hello) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/string/shared/strip.rb b/spec/ruby/core/string/shared/strip.rb index 3af77b50fe6fa9..39c7232ff9977f 100644 --- a/spec/ruby/core/string/shared/strip.rb +++ b/spec/ruby/core/string/shared/strip.rb @@ -7,8 +7,8 @@ end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new(" hello ").send(@method).should be_an_instance_of(String) - StringSpecs::MyString.new(" ").send(@method).should be_an_instance_of(String) - StringSpecs::MyString.new("").send(@method).should be_an_instance_of(String) + StringSpecs::MyString.new(" hello ").send(@method).should.instance_of?(String) + StringSpecs::MyString.new(" ").send(@method).should.instance_of?(String) + StringSpecs::MyString.new("").send(@method).should.instance_of?(String) end end diff --git a/spec/ruby/core/string/shared/succ.rb b/spec/ruby/core/string/shared/succ.rb index 7c68345f109de1..8f1d327741f7f4 100644 --- a/spec/ruby/core/string/shared/succ.rb +++ b/spec/ruby/core/string/shared/succ.rb @@ -60,9 +60,9 @@ end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("").send(@method).should be_an_instance_of(String) - StringSpecs::MyString.new("a").send(@method).should be_an_instance_of(String) - StringSpecs::MyString.new("z").send(@method).should be_an_instance_of(String) + StringSpecs::MyString.new("").send(@method).should.instance_of?(String) + StringSpecs::MyString.new("a").send(@method).should.instance_of?(String) + StringSpecs::MyString.new("z").send(@method).should.instance_of?(String) end it "returns a String in the same encoding as self" do @@ -75,13 +75,13 @@ ["", "abcd", "THX1138"].each do |s| s = +s r = s.dup.send(@method) - s.send(@method).should equal(s) + s.send(@method).should.equal?(s) s.should == r end end it "raises a FrozenError if self is frozen" do - -> { "".freeze.send(@method) }.should raise_error(FrozenError) - -> { "abcd".freeze.send(@method) }.should raise_error(FrozenError) + -> { "".freeze.send(@method) }.should.raise(FrozenError) + -> { "abcd".freeze.send(@method) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/shared/to_s.rb b/spec/ruby/core/string/shared/to_s.rb index 4b87a6cbe15270..96c59470d6060e 100644 --- a/spec/ruby/core/string/shared/to_s.rb +++ b/spec/ruby/core/string/shared/to_s.rb @@ -1,13 +1,13 @@ describe :string_to_s, shared: true do it "returns self when self.class == String" do a = "a string" - a.should equal(a.send(@method)) + a.should.equal?(a.send(@method)) end it "returns a new instance of String when called on a subclass" do a = StringSpecs::MyString.new("a string") s = a.send(@method) s.should == "a string" - s.should be_an_instance_of(String) + s.should.instance_of?(String) end end diff --git a/spec/ruby/core/string/shared/to_sym.rb b/spec/ruby/core/string/shared/to_sym.rb index 833eae100e4e6a..2a8a2e3182166d 100644 --- a/spec/ruby/core/string/shared/to_sym.rb +++ b/spec/ruby/core/string/shared/to_sym.rb @@ -1,42 +1,42 @@ describe :string_to_sym, shared: true do it "returns the symbol corresponding to self" do - "Koala".send(@method).should equal :Koala - 'cat'.send(@method).should equal :cat - '@cat'.send(@method).should equal :@cat - 'cat and dog'.send(@method).should equal :"cat and dog" - "abc=".send(@method).should equal :abc= + "Koala".send(@method).should.equal? :Koala + 'cat'.send(@method).should.equal? :cat + '@cat'.send(@method).should.equal? :@cat + 'cat and dog'.send(@method).should.equal? :"cat and dog" + "abc=".send(@method).should.equal? :abc= end it "does not special case +(binary) and -(binary)" do - "+(binary)".send(@method).should equal :"+(binary)" - "-(binary)".send(@method).should equal :"-(binary)" + "+(binary)".send(@method).should.equal? :"+(binary)" + "-(binary)".send(@method).should.equal? :"-(binary)" end it "does not special case certain operators" do - "!@".send(@method).should equal :"!@" - "~@".send(@method).should equal :"~@" - "!(unary)".send(@method).should equal :"!(unary)" - "~(unary)".send(@method).should equal :"~(unary)" - "+(unary)".send(@method).should equal :"+(unary)" - "-(unary)".send(@method).should equal :"-(unary)" + "!@".send(@method).should.equal? :"!@" + "~@".send(@method).should.equal? :"~@" + "!(unary)".send(@method).should.equal? :"!(unary)" + "~(unary)".send(@method).should.equal? :"~(unary)" + "+(unary)".send(@method).should.equal? :"+(unary)" + "-(unary)".send(@method).should.equal? :"-(unary)" end it "returns a US-ASCII Symbol for a UTF-8 String containing only US-ASCII characters" do sym = "foobar".send(@method) sym.encoding.should == Encoding::US_ASCII - sym.should equal :"foobar" + sym.should.equal? :"foobar" end it "returns a US-ASCII Symbol for a binary String containing only US-ASCII characters" do sym = "foobar".b.send(@method) sym.encoding.should == Encoding::US_ASCII - sym.should equal :"foobar" + sym.should.equal? :"foobar" end it "returns a UTF-8 Symbol for a UTF-8 String containing non US-ASCII characters" do sym = "il était une fois".send(@method) sym.encoding.should == Encoding::UTF_8 - sym.should equal :"il était une #{'fois'}" + sym.should.equal? :"il était une #{'fois'}" end it "returns a UTF-16LE Symbol for a UTF-16LE String containing non US-ASCII characters" do @@ -67,6 +67,6 @@ invalid_utf8.should_not.valid_encoding? -> { invalid_utf8.send(@method) - }.should raise_error(EncodingError, 'invalid symbol in encoding UTF-8 :"\xC3"') + }.should.raise(EncodingError, 'invalid symbol in encoding UTF-8 :"\xC3"') end end diff --git a/spec/ruby/core/string/slice_spec.rb b/spec/ruby/core/string/slice_spec.rb index 5aba2d3be069e1..14e2251b3f7bff 100644 --- a/spec/ruby/core/string/slice_spec.rb +++ b/spec/ruby/core/string/slice_spec.rb @@ -54,9 +54,9 @@ end it "raises a FrozenError if self is frozen" do - -> { "hello".freeze.slice!(1) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(10) }.should raise_error(FrozenError) - -> { "".freeze.slice!(0) }.should raise_error(FrozenError) + -> { "hello".freeze.slice!(1) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(10) }.should.raise(FrozenError) + -> { "".freeze.slice!(0) }.should.raise(FrozenError) end it "calls to_int on index" do @@ -110,13 +110,13 @@ end it "raises a FrozenError if self is frozen" do - -> { "hello".freeze.slice!(1, 2) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(10, 3) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(-10, 3)}.should raise_error(FrozenError) - -> { "hello".freeze.slice!(4, -3) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(10, 3) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(-10, 3)}.should raise_error(FrozenError) - -> { "hello".freeze.slice!(4, -3) }.should raise_error(FrozenError) + -> { "hello".freeze.slice!(1, 2) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(10, 3) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(-10, 3)}.should.raise(FrozenError) + -> { "hello".freeze.slice!(4, -3) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(10, 3) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(-10, 3)}.should.raise(FrozenError) + -> { "hello".freeze.slice!(4, -3) }.should.raise(FrozenError) end it "calls to_int on idx and length" do @@ -134,8 +134,8 @@ def obj.method_missing(name, *) name == :to_int ? 2 : super; end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.slice!(0, 0).should be_an_instance_of(String) - s.slice!(0, 4).should be_an_instance_of(String) + s.slice!(0, 0).should.instance_of?(String) + s.slice!(0, 4).should.instance_of?(String) end it "returns the substring given by the character offsets" do @@ -177,8 +177,8 @@ def obj.method_missing(name, *) name == :to_int ? 2 : super; end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.slice!(0...0).should be_an_instance_of(String) - s.slice!(0..4).should be_an_instance_of(String) + s.slice!(0...0).should.instance_of?(String) + s.slice!(0..4).should.instance_of?(String) end it "calls to_int on range arguments" do @@ -228,12 +228,12 @@ def to.method_missing(name) name == :to_int ? -2 : super; end it "raises a FrozenError on a frozen instance that is modified" do - -> { "hello".freeze.slice!(1..3) }.should raise_error(FrozenError) + -> { "hello".freeze.slice!(1..3) }.should.raise(FrozenError) end # see redmine #1551 it "raises a FrozenError on a frozen instance that would not be modified" do - -> { "hello".freeze.slice!(10..20)}.should raise_error(FrozenError) + -> { "hello".freeze.slice!(10..20)}.should.raise(FrozenError) end end @@ -256,8 +256,8 @@ def to.method_missing(name) name == :to_int ? -2 : super; end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.slice!(//).should be_an_instance_of(String) - s.slice!(/../).should be_an_instance_of(String) + s.slice!(//).should.instance_of?(String) + s.slice!(/../).should.instance_of?(String) end it "returns the matching portion of self with a multi byte character" do @@ -274,11 +274,11 @@ def to.method_missing(name) name == :to_int ? -2 : super; end end it "raises a FrozenError on a frozen instance that is modified" do - -> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(FrozenError) + -> { "this is a string".freeze.slice!(/s.*t/) }.should.raise(FrozenError) end it "raises a FrozenError on a frozen instance that would not be modified" do - -> { "this is a string".freeze.slice!(/zzz/) }.should raise_error(FrozenError) + -> { "this is a string".freeze.slice!(/zzz/) }.should.raise(FrozenError) end end @@ -316,8 +316,8 @@ def to.method_missing(name) name == :to_int ? -2 : super; end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.slice!(/(.)(.)/, 0).should be_an_instance_of(String) - s.slice!(/(.)(.)/, 1).should be_an_instance_of(String) + s.slice!(/(.)(.)/, 0).should.instance_of?(String) + s.slice!(/(.)(.)/, 1).should.instance_of?(String) end it "returns the encoding aware capture for the given index" do @@ -342,9 +342,9 @@ def to.method_missing(name) name == :to_int ? -2 : super; end end it "raises a FrozenError if self is frozen" do - -> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(FrozenError) - -> { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(FrozenError) - -> { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(FrozenError) + -> { "this is a string".freeze.slice!(/s.*t/) }.should.raise(FrozenError) + -> { "this is a string".freeze.slice!(/zzz/, 0)}.should.raise(FrozenError) + -> { "this is a string".freeze.slice!(/(.)/, 2)}.should.raise(FrozenError) end end @@ -372,19 +372,19 @@ def to.method_missing(name) name == :to_int ? -2 : super; end o = mock('x') o.should_not_receive(:to_str) - -> { "hello".slice!(o) }.should raise_error(TypeError) + -> { "hello".slice!(o) }.should.raise(TypeError) end it "returns a subclass instance when given a subclass instance" do s = StringSpecs::MyString.new("el") r = "hello".slice!(s) r.should == "el" - r.should be_an_instance_of(String) + r.should.instance_of?(String) end it "raises a FrozenError if self is frozen" do - -> { "hello hello".freeze.slice!('llo') }.should raise_error(FrozenError) - -> { "this is a string".freeze.slice!('zzz')}.should raise_error(FrozenError) - -> { "this is a string".freeze.slice!('zzz')}.should raise_error(FrozenError) + -> { "hello hello".freeze.slice!('llo') }.should.raise(FrozenError) + -> { "this is a string".freeze.slice!('zzz')}.should.raise(FrozenError) + -> { "this is a string".freeze.slice!('zzz')}.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/split_spec.rb b/spec/ruby/core/string/split_spec.rb index cada1a6789353d..6e8c1c6219bd9a 100644 --- a/spec/ruby/core/string/split_spec.rb +++ b/spec/ruby/core/string/split_spec.rb @@ -6,15 +6,15 @@ it "throws an ArgumentError if the string is not a valid" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - -> { s.split }.should raise_error(ArgumentError) - -> { s.split(':') }.should raise_error(ArgumentError) + -> { s.split }.should.raise(ArgumentError) + -> { s.split(':') }.should.raise(ArgumentError) end it "throws an ArgumentError if the pattern is not a valid string" do str = 'проверка' broken_str = "\xDF".dup.force_encoding(Encoding::UTF_8) - -> { str.split(broken_str) }.should raise_error(ArgumentError) + -> { str.split(broken_str) }.should.raise(ArgumentError) end it "splits on multibyte characters" do @@ -94,7 +94,7 @@ end it "raises a RangeError when the limit is larger than int" do - -> { "a,b".split(" ", 2147483649) }.should raise_error(RangeError) + -> { "a,b".split(" ", 2147483649) }.should.raise(RangeError) end it "defaults to $; when string isn't given or nil" do @@ -197,11 +197,11 @@ ["", ".", " "].each do |pat| [-1, 0, 1, 2].each do |limit| StringSpecs::MyString.new(str).split(pat, limit).each do |x| - x.should be_an_instance_of(String) + x.should.instance_of?(String) end str.split(StringSpecs::MyString.new(pat), limit).each do |x| - x.should be_an_instance_of(String) + x.should.instance_of?(String) end end end @@ -231,7 +231,7 @@ it "throws an ArgumentError if the string is not a valid" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - -> { s.split(/./) }.should raise_error(ArgumentError) + -> { s.split(/./) }.should.raise(ArgumentError) end it "divides self on regexp matches" do @@ -367,8 +367,8 @@ end it "returns a type error if limit can't be converted to an integer" do - -> {"1.2.3.4".split(".", "three")}.should raise_error(TypeError) - -> {"1.2.3.4".split(".", nil) }.should raise_error(TypeError) + -> {"1.2.3.4".split(".", "three")}.should.raise(TypeError) + -> {"1.2.3.4".split(".", nil) }.should.raise(TypeError) end it "doesn't set $~" do @@ -391,7 +391,7 @@ [//, /:/, /\s+/].each do |pat| [-1, 0, 1, 2].each do |limit| StringSpecs::MyString.new(str).split(pat, limit).each do |x| - x.should be_an_instance_of(String) + x.should.instance_of?(String) end end end @@ -413,7 +413,7 @@ broken_str.force_encoding('binary') broken_str.chop! broken_str.force_encoding('utf-8') - ->{ broken_str.split(/\r\n|\r|\n/) }.should raise_error(ArgumentError) + ->{ broken_str.split(/\r\n|\r|\n/) }.should.raise(ArgumentError) end # See https://bugs.ruby-lang.org/issues/12689 and https://github.com/jruby/jruby/issues/4868 @@ -522,19 +522,19 @@ StringSpecs::MyString.new("a|b").split("|") { |str| a << str } first, last = a - first.should be_an_instance_of(String) + first.should.instance_of?(String) first.should == "a" - last.should be_an_instance_of(String) + last.should.instance_of?(String) last.should == "b" end end it "raises a TypeError when not called with nil, String, or Regexp" do - -> { "hello".split(42) }.should raise_error(TypeError) - -> { "hello".split(:ll) }.should raise_error(TypeError) - -> { "hello".split(false) }.should raise_error(TypeError) - -> { "hello".split(Object.new) }.should raise_error(TypeError) + -> { "hello".split(42) }.should.raise(TypeError) + -> { "hello".split(:ll) }.should.raise(TypeError) + -> { "hello".split(false) }.should.raise(TypeError) + -> { "hello".split(Object.new) }.should.raise(TypeError) end it "returns Strings in the same encoding as self" do diff --git a/spec/ruby/core/string/squeeze_spec.rb b/spec/ruby/core/string/squeeze_spec.rb index 981d480684c3cc..52b6e1eed44e5a 100644 --- a/spec/ruby/core/string/squeeze_spec.rb +++ b/spec/ruby/core/string/squeeze_spec.rb @@ -51,8 +51,8 @@ it "raises an ArgumentError when the parameter is out of sequence" do s = "--subbookkeeper--" - -> { s.squeeze("e-b") }.should raise_error(ArgumentError) - -> { s.squeeze("^e-b") }.should raise_error(ArgumentError) + -> { s.squeeze("e-b") }.should.raise(ArgumentError) + -> { s.squeeze("^e-b") }.should.raise(ArgumentError) end it "tries to convert each set arg to a string using to_str" do @@ -71,20 +71,20 @@ end it "raises a TypeError when one set arg can't be converted to a string" do - -> { "hello world".squeeze([]) }.should raise_error(TypeError) - -> { "hello world".squeeze(Object.new)}.should raise_error(TypeError) - -> { "hello world".squeeze(mock('x')) }.should raise_error(TypeError) + -> { "hello world".squeeze([]) }.should.raise(TypeError) + -> { "hello world".squeeze(Object.new)}.should.raise(TypeError) + -> { "hello world".squeeze(mock('x')) }.should.raise(TypeError) end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("oh no!!!").squeeze("!").should be_an_instance_of(String) + StringSpecs::MyString.new("oh no!!!").squeeze("!").should.instance_of?(String) end end describe "String#squeeze!" do it "modifies self in place and returns self" do a = "yellow moon" - a.squeeze!.should equal(a) + a.squeeze!.should.equal?(a) a.should == "yelow mon" end @@ -97,15 +97,15 @@ it "raises an ArgumentError when the parameter is out of sequence" do s = "--subbookkeeper--" - -> { s.squeeze!("e-b") }.should raise_error(ArgumentError) - -> { s.squeeze!("^e-b") }.should raise_error(ArgumentError) + -> { s.squeeze!("e-b") }.should.raise(ArgumentError) + -> { s.squeeze!("^e-b") }.should.raise(ArgumentError) end it "raises a FrozenError when self is frozen" do a = "yellow moon" a.freeze - -> { a.squeeze!("") }.should raise_error(FrozenError) - -> { a.squeeze! }.should raise_error(FrozenError) + -> { a.squeeze!("") }.should.raise(FrozenError) + -> { a.squeeze! }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/strip_spec.rb b/spec/ruby/core/string/strip_spec.rb index edb6ea3b444edc..81994a7f2e2fa5 100644 --- a/spec/ruby/core/string/strip_spec.rb +++ b/spec/ruby/core/string/strip_spec.rb @@ -20,7 +20,7 @@ describe "String#strip!" do it "modifies self in place and returns self" do a = " hello " - a.strip!.should equal(a) + a.strip!.should.equal?(a) a.should == "hello" a = "\tgoodbye\r\v\n" @@ -47,12 +47,12 @@ end it "raises a FrozenError on a frozen instance that is modified" do - -> { " hello ".freeze.strip! }.should raise_error(FrozenError) + -> { " hello ".freeze.strip! }.should.raise(FrozenError) end # see #1552 it "raises a FrozenError on a frozen instance that would not be modified" do - -> {"hello".freeze.strip! }.should raise_error(FrozenError) - -> {"".freeze.strip! }.should raise_error(FrozenError) + -> {"hello".freeze.strip! }.should.raise(FrozenError) + -> {"".freeze.strip! }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/sub_spec.rb b/spec/ruby/core/string/sub_spec.rb index 6ff28ec851eb63..f0082fba59394a 100644 --- a/spec/ruby/core/string/sub_spec.rb +++ b/spec/ruby/core/string/sub_spec.rb @@ -7,7 +7,7 @@ a = "hello" b = a.sub(/w.*$/, "*") - b.should_not equal(a) + b.should_not.equal?(a) b.should == "hello" end @@ -147,16 +147,16 @@ not_supported_on :opal do it "raises a TypeError when pattern is a Symbol" do - -> { "hello".sub(:woot, "x") }.should raise_error(TypeError) + -> { "hello".sub(:woot, "x") }.should.raise(TypeError) end end it "raises a TypeError when pattern is an Array" do - -> { "hello".sub([], "x") }.should raise_error(TypeError) + -> { "hello".sub([], "x") }.should.raise(TypeError) end it "raises a TypeError when pattern can't be converted to a string" do - -> { "hello".sub(Object.new, nil) }.should raise_error(TypeError) + -> { "hello".sub(Object.new, nil) }.should.raise(TypeError) end it "tries to convert replacement to a string using to_str" do @@ -167,15 +167,15 @@ end it "raises a TypeError when replacement can't be converted to a string" do - -> { "hello".sub(/[aeiou]/, []) }.should raise_error(TypeError) - -> { "hello".sub(/[aeiou]/, 99) }.should raise_error(TypeError) + -> { "hello".sub(/[aeiou]/, []) }.should.raise(TypeError) + -> { "hello".sub(/[aeiou]/, 99) }.should.raise(TypeError) end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("").sub(//, "").should be_an_instance_of(String) - StringSpecs::MyString.new("").sub(/foo/, "").should be_an_instance_of(String) - StringSpecs::MyString.new("foo").sub(/foo/, "").should be_an_instance_of(String) - StringSpecs::MyString.new("foo").sub("foo", "").should be_an_instance_of(String) + StringSpecs::MyString.new("").sub(//, "").should.instance_of?(String) + StringSpecs::MyString.new("").sub(/foo/, "").should.instance_of?(String) + StringSpecs::MyString.new("foo").sub(/foo/, "").should.instance_of?(String) + StringSpecs::MyString.new("foo").sub("foo", "").should.instance_of?(String) end it "sets $~ to MatchData of match and nil when there's none" do @@ -281,7 +281,7 @@ describe "String#sub! with pattern, replacement" do it "modifies self in place and returns self" do a = "hello" - a.sub!(/[aeiou]/, '*').should equal(a) + a.sub!(/[aeiou]/, '*').should.equal?(a) a.should == "h*llo" end @@ -296,9 +296,9 @@ s = "hello" s.freeze - -> { s.sub!(/ROAR/, "x") }.should raise_error(FrozenError) - -> { s.sub!(/e/, "e") }.should raise_error(FrozenError) - -> { s.sub!(/[aeiou]/, '*') }.should raise_error(FrozenError) + -> { s.sub!(/ROAR/, "x") }.should.raise(FrozenError) + -> { s.sub!(/e/, "e") }.should.raise(FrozenError) + -> { s.sub!(/[aeiou]/, '*') }.should.raise(FrozenError) end it "handles a pattern in a superset encoding" do @@ -326,7 +326,7 @@ describe "String#sub! with pattern and block" do it "modifies self in place and returns self" do a = "hello" - a.sub!(/[aeiou]/) { '*' }.should equal(a) + a.sub!(/[aeiou]/) { '*' }.should.equal?(a) a.should == "h*llo" end @@ -357,16 +357,16 @@ it "raises a RuntimeError if the string is modified while substituting" do str = "hello" - -> { str.sub!(//) { str << 'x' } }.should raise_error(RuntimeError) + -> { str.sub!(//) { str << 'x' } }.should.raise(RuntimeError) end it "raises a FrozenError when self is frozen" do s = "hello" s.freeze - -> { s.sub!(/ROAR/) { "x" } }.should raise_error(FrozenError) - -> { s.sub!(/e/) { "e" } }.should raise_error(FrozenError) - -> { s.sub!(/[aeiou]/) { '*' } }.should raise_error(FrozenError) + -> { s.sub!(/ROAR/) { "x" } }.should.raise(FrozenError) + -> { s.sub!(/e/) { "e" } }.should.raise(FrozenError) + -> { s.sub!(/[aeiou]/) { '*' } }.should.raise(FrozenError) end end @@ -501,12 +501,12 @@ describe "String#sub with pattern and without replacement and block" do it "raises a ArgumentError" do - -> { "abca".sub(/a/) }.should raise_error(ArgumentError) + -> { "abca".sub(/a/) }.should.raise(ArgumentError) end end describe "String#sub! with pattern and without replacement and block" do it "raises a ArgumentError" do - -> { "abca".sub!(/a/) }.should raise_error(ArgumentError) + -> { "abca".sub!(/a/) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/swapcase_spec.rb b/spec/ruby/core/string/swapcase_spec.rb index 011a2135016e65..f0e6e0182cb1a7 100644 --- a/spec/ruby/core/string/swapcase_spec.rb +++ b/spec/ruby/core/string/swapcase_spec.rb @@ -25,7 +25,7 @@ swapcased.should == "aSSET" swapcased.size.should == 5 swapcased.bytesize.should == 5 - swapcased.ascii_only?.should be_true + swapcased.ascii_only?.should == true end end @@ -49,7 +49,7 @@ end it "does not allow any other additional option" do - -> { "aiS".swapcase(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { "aiS".swapcase(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -63,28 +63,28 @@ end it "does not allow any other additional option" do - -> { "aiS".swapcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { "aiS".swapcase(:lithuanian, :ascii) }.should.raise(ArgumentError) end end it "does not allow the :fold option for upcasing" do - -> { "abc".swapcase(:fold) }.should raise_error(ArgumentError) + -> { "abc".swapcase(:fold) }.should.raise(ArgumentError) end it "does not allow invalid options" do - -> { "abc".swapcase(:invalid_option) }.should raise_error(ArgumentError) + -> { "abc".swapcase(:invalid_option) }.should.raise(ArgumentError) end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("").swapcase.should be_an_instance_of(String) - StringSpecs::MyString.new("hello").swapcase.should be_an_instance_of(String) + StringSpecs::MyString.new("").swapcase.should.instance_of?(String) + StringSpecs::MyString.new("hello").swapcase.should.instance_of?(String) end end describe "String#swapcase!" do it "modifies self in place" do a = "cYbEr_PuNk11" - a.swapcase!.should equal(a) + a.swapcase!.should.equal?(a) a.should == "CyBeR_pUnK11" end @@ -114,7 +114,7 @@ swapcased.should == "aSSET" swapcased.size.should == 5 swapcased.bytesize.should == 5 - swapcased.ascii_only?.should be_true + swapcased.ascii_only?.should == true end end @@ -146,7 +146,7 @@ end it "does not allow any other additional option" do - -> { a = "aiS"; a.swapcase!(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { a = "aiS"; a.swapcase!(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -164,16 +164,16 @@ end it "does not allow any other additional option" do - -> { a = "aiS"; a.swapcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { a = "aiS"; a.swapcase!(:lithuanian, :ascii) }.should.raise(ArgumentError) end end it "does not allow the :fold option for upcasing" do - -> { a = "abc"; a.swapcase!(:fold) }.should raise_error(ArgumentError) + -> { a = "abc"; a.swapcase!(:fold) }.should.raise(ArgumentError) end it "does not allow invalid options" do - -> { a = "abc"; a.swapcase!(:invalid_option) }.should raise_error(ArgumentError) + -> { a = "abc"; a.swapcase!(:invalid_option) }.should.raise(ArgumentError) end it "returns nil if no modifications were made" do @@ -187,7 +187,7 @@ it "raises a FrozenError when self is frozen" do ["", "hello"].each do |a| a.freeze - -> { a.swapcase! }.should raise_error(FrozenError) + -> { a.swapcase! }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/string/to_c_spec.rb b/spec/ruby/core/string/to_c_spec.rb index 1813890e722067..9cd0ed44014a41 100644 --- a/spec/ruby/core/string/to_c_spec.rb +++ b/spec/ruby/core/string/to_c_spec.rb @@ -38,7 +38,7 @@ it "raises Encoding::CompatibilityError if String is in not ASCII-compatible encoding" do -> { '79+4i'.encode("UTF-16").to_c - }.should raise_error(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16") + }.should.raise(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16") end it "treats a sequence of underscores as an end of Complex string" do diff --git a/spec/ruby/core/string/to_f_spec.rb b/spec/ruby/core/string/to_f_spec.rb index 520a797af97764..bb09e4f2f31975 100644 --- a/spec/ruby/core/string/to_f_spec.rb +++ b/spec/ruby/core/string/to_f_spec.rb @@ -123,7 +123,7 @@ it "raises Encoding::CompatibilityError if String is in not ASCII-compatible encoding" do -> { '1.2'.encode("UTF-16").to_f - }.should raise_error(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16") + }.should.raise(Encoding::CompatibilityError, "ASCII incompatible encoding: UTF-16") end it "allows String representation without a fractional part" do diff --git a/spec/ruby/core/string/to_i_spec.rb b/spec/ruby/core/string/to_i_spec.rb index 39f69acda3107b..629750bd732de5 100644 --- a/spec/ruby/core/string/to_i_spec.rb +++ b/spec/ruby/core/string/to_i_spec.rb @@ -138,31 +138,31 @@ end it "raises an ArgumentError for illegal bases (1, < 0 or > 36)" do - -> { "".to_i(1) }.should raise_error(ArgumentError) - -> { "".to_i(-1) }.should raise_error(ArgumentError) - -> { "".to_i(37) }.should raise_error(ArgumentError) + -> { "".to_i(1) }.should.raise(ArgumentError) + -> { "".to_i(-1) }.should.raise(ArgumentError) + -> { "".to_i(37) }.should.raise(ArgumentError) end it "returns an Integer for long strings with trailing spaces" do "0 ".to_i.should == 0 - "0 ".to_i.should be_an_instance_of(Integer) + "0 ".to_i.should.instance_of?(Integer) "10 ".to_i.should == 10 - "10 ".to_i.should be_an_instance_of(Integer) + "10 ".to_i.should.instance_of?(Integer) "-10 ".to_i.should == -10 - "-10 ".to_i.should be_an_instance_of(Integer) + "-10 ".to_i.should.instance_of?(Integer) end it "returns an Integer for long strings with leading spaces" do " 0".to_i.should == 0 - " 0".to_i.should be_an_instance_of(Integer) + " 0".to_i.should.instance_of?(Integer) " 10".to_i.should == 10 - " 10".to_i.should be_an_instance_of(Integer) + " 10".to_i.should.instance_of?(Integer) " -10".to_i.should == -10 - " -10".to_i.should be_an_instance_of(Integer) + " -10".to_i.should.instance_of?(Integer) end it "returns the correct Integer for long strings" do diff --git a/spec/ruby/core/string/to_r_spec.rb b/spec/ruby/core/string/to_r_spec.rb index 4ffbb10d9878e5..fb7c9d108ee0bb 100644 --- a/spec/ruby/core/string/to_r_spec.rb +++ b/spec/ruby/core/string/to_r_spec.rb @@ -2,7 +2,7 @@ describe "String#to_r" do it "returns a Rational object" do - String.new.to_r.should be_an_instance_of(Rational) + String.new.to_r.should.instance_of?(Rational) end it "returns (0/1) for the empty String" do diff --git a/spec/ruby/core/string/tr_s_spec.rb b/spec/ruby/core/string/tr_s_spec.rb index 693ff8ace21bb5..22a193ec4be794 100644 --- a/spec/ruby/core/string/tr_s_spec.rb +++ b/spec/ruby/core/string/tr_s_spec.rb @@ -54,7 +54,7 @@ end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("hello").tr_s("e", "a").should be_an_instance_of(String) + StringSpecs::MyString.new("hello").tr_s("e", "a").should.instance_of?(String) end # http://redmine.ruby-lang.org/issues/show/1839 @@ -124,8 +124,8 @@ it "raises a FrozenError if self is frozen" do s = "hello".freeze - -> { s.tr_s!("el", "ar") }.should raise_error(FrozenError) - -> { s.tr_s!("l", "r") }.should raise_error(FrozenError) - -> { s.tr_s!("", "") }.should raise_error(FrozenError) + -> { s.tr_s!("el", "ar") }.should.raise(FrozenError) + -> { s.tr_s!("l", "r") }.should.raise(FrozenError) + -> { s.tr_s!("", "") }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/tr_spec.rb b/spec/ruby/core/string/tr_spec.rb index 8478ccc9d2879c..cb57c3851eec5e 100644 --- a/spec/ruby/core/string/tr_spec.rb +++ b/spec/ruby/core/string/tr_spec.rb @@ -30,11 +30,11 @@ end it "raises an ArgumentError a descending range in the replacement as containing just the start character" do - -> { "hello".tr("a-y", "z-b") }.should raise_error(ArgumentError) + -> { "hello".tr("a-y", "z-b") }.should.raise(ArgumentError) end it "raises an ArgumentError a descending range in the source as empty" do - -> { "hello".tr("l-a", "z") }.should raise_error(ArgumentError) + -> { "hello".tr("l-a", "z") }.should.raise(ArgumentError) end it "translates chars not in from_string when it starts with a ^" do @@ -66,7 +66,7 @@ end it "returns Stringinstances when called on a subclass" do - StringSpecs::MyString.new("hello").tr("e", "a").should be_an_instance_of(String) + StringSpecs::MyString.new("hello").tr("e", "a").should.instance_of?(String) end # http://redmine.ruby-lang.org/issues/show/1839 @@ -119,8 +119,8 @@ it "raises a FrozenError if self is frozen" do s = "abcdefghijklmnopqR".freeze - -> { s.tr!("cdefg", "12") }.should raise_error(FrozenError) - -> { s.tr!("R", "S") }.should raise_error(FrozenError) - -> { s.tr!("", "") }.should raise_error(FrozenError) + -> { s.tr!("cdefg", "12") }.should.raise(FrozenError) + -> { s.tr!("R", "S") }.should.raise(FrozenError) + -> { s.tr!("", "") }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/try_convert_spec.rb b/spec/ruby/core/string/try_convert_spec.rb index 7019f1fc2ac6c9..0c0219cd2e2a50 100644 --- a/spec/ruby/core/string/try_convert_spec.rb +++ b/spec/ruby/core/string/try_convert_spec.rb @@ -4,36 +4,36 @@ describe "String.try_convert" do it "returns the argument if it's a String" do x = String.new - String.try_convert(x).should equal(x) + String.try_convert(x).should.equal?(x) end it "returns the argument if it's a kind of String" do x = StringSpecs::MyString.new - String.try_convert(x).should equal(x) + String.try_convert(x).should.equal?(x) end it "returns nil when the argument does not respond to #to_str" do - String.try_convert(Object.new).should be_nil + String.try_convert(Object.new).should == nil end it "sends #to_str to the argument and returns the result if it's nil" do obj = mock("to_str") obj.should_receive(:to_str).and_return(nil) - String.try_convert(obj).should be_nil + String.try_convert(obj).should == nil end it "sends #to_str to the argument and returns the result if it's a String" do x = String.new obj = mock("to_str") obj.should_receive(:to_str).and_return(x) - String.try_convert(obj).should equal(x) + String.try_convert(obj).should.equal?(x) end it "sends #to_str to the argument and returns the result if it's a kind of String" do x = StringSpecs::MyString.new obj = mock("to_str") obj.should_receive(:to_str).and_return(x) - String.try_convert(obj).should equal(x) + String.try_convert(obj).should.equal?(x) end it "sends #to_str to the argument and raises TypeError if it's not a kind of String" do @@ -45,6 +45,6 @@ it "does not rescue exceptions raised by #to_str" do obj = mock("to_str") obj.should_receive(:to_str).and_raise(RuntimeError) - -> { String.try_convert obj }.should raise_error(RuntimeError) + -> { String.try_convert obj }.should.raise(RuntimeError) end end diff --git a/spec/ruby/core/string/undump_spec.rb b/spec/ruby/core/string/undump_spec.rb index 6ff220161c1d6e..8516e24b3b073d 100644 --- a/spec/ruby/core/string/undump_spec.rb +++ b/spec/ruby/core/string/undump_spec.rb @@ -8,7 +8,7 @@ end it "always returns String instance" do - StringSpecs::MyString.new('"foo"').undump.should be_an_instance_of(String) + StringSpecs::MyString.new('"foo"').undump.should.instance_of?(String) end it "strips outer \"" do @@ -396,46 +396,46 @@ describe "Limitations" do it "cannot undump non ASCII-compatible string" do - -> { '"foo"'.encode('utf-16le').undump }.should raise_error(Encoding::CompatibilityError) + -> { '"foo"'.encode('utf-16le').undump }.should.raise(Encoding::CompatibilityError) end end describe "invalid dump" do it "raises RuntimeError exception if wrapping \" are missing" do - -> { 'foo'.undump }.should raise_error(RuntimeError, /invalid dumped string/) - -> { '"foo'.undump }.should raise_error(RuntimeError, /unterminated dumped string/) - -> { 'foo"'.undump }.should raise_error(RuntimeError, /invalid dumped string/) - -> { "'foo'".undump }.should raise_error(RuntimeError, /invalid dumped string/) + -> { 'foo'.undump }.should.raise(RuntimeError, /invalid dumped string/) + -> { '"foo'.undump }.should.raise(RuntimeError, /unterminated dumped string/) + -> { 'foo"'.undump }.should.raise(RuntimeError, /invalid dumped string/) + -> { "'foo'".undump }.should.raise(RuntimeError, /invalid dumped string/) end it "raises RuntimeError if there is incorrect \\x sequence" do - -> { '"\x"'.undump }.should raise_error(RuntimeError, /invalid hex escape/) - -> { '"\\x3y"'.undump }.should raise_error(RuntimeError, /invalid hex escape/) + -> { '"\x"'.undump }.should.raise(RuntimeError, /invalid hex escape/) + -> { '"\\x3y"'.undump }.should.raise(RuntimeError, /invalid hex escape/) end it "raises RuntimeError in there is incorrect \\u sequence" do - -> { '"\\u"'.undump }.should raise_error(RuntimeError, /invalid Unicode escape/) - -> { '"\\u{"'.undump }.should raise_error(RuntimeError, /invalid Unicode escape/) - -> { '"\\u{3042"'.undump }.should raise_error(RuntimeError, /invalid Unicode escape/) - -> { '"\\u"'.undump }.should raise_error(RuntimeError, /invalid Unicode escape/) + -> { '"\\u"'.undump }.should.raise(RuntimeError, /invalid Unicode escape/) + -> { '"\\u{"'.undump }.should.raise(RuntimeError, /invalid Unicode escape/) + -> { '"\\u{3042"'.undump }.should.raise(RuntimeError, /invalid Unicode escape/) + -> { '"\\u"'.undump }.should.raise(RuntimeError, /invalid Unicode escape/) end it "raises RuntimeError if there is malformed dump of non ASCII-compatible string" do - -> { '"".force_encoding("BINARY"'.undump }.should raise_error(RuntimeError, /invalid dumped string/) - -> { '"".force_encoding("Unknown")'.undump }.should raise_error(RuntimeError, /dumped string has unknown encoding name/) - -> { '"".force_encoding()'.undump }.should raise_error(RuntimeError, /invalid dumped string/) + -> { '"".force_encoding("BINARY"'.undump }.should.raise(RuntimeError, /invalid dumped string/) + -> { '"".force_encoding("Unknown")'.undump }.should.raise(RuntimeError, /dumped string has unknown encoding name/) + -> { '"".force_encoding()'.undump }.should.raise(RuntimeError, /invalid dumped string/) end it "raises RuntimeError if string contains \0 character" do - -> { "\"foo\0\"".undump }.should raise_error(RuntimeError, /string contains null byte/) + -> { "\"foo\0\"".undump }.should.raise(RuntimeError, /string contains null byte/) end it "raises RuntimeError if string contains non ASCII character" do - -> { "\"\u3042\"".undump }.should raise_error(RuntimeError, /non-ASCII character detected/) + -> { "\"\u3042\"".undump }.should.raise(RuntimeError, /non-ASCII character detected/) end it "raises RuntimeError if there are some excessive \"" do - -> { '" "" "'.undump }.should raise_error(RuntimeError, /invalid dumped string/) + -> { '" "" "'.undump }.should.raise(RuntimeError, /invalid dumped string/) end end end diff --git a/spec/ruby/core/string/unicode_normalize_spec.rb b/spec/ruby/core/string/unicode_normalize_spec.rb index 2e7d22394a28a2..92b3a46b43afb0 100644 --- a/spec/ruby/core/string/unicode_normalize_spec.rb +++ b/spec/ruby/core/string/unicode_normalize_spec.rb @@ -51,13 +51,13 @@ it "raises an Encoding::CompatibilityError if string is not in an unicode encoding" do -> do [0xE0].pack('C').force_encoding("ISO-8859-1").unicode_normalize(:nfd) - end.should raise_error(Encoding::CompatibilityError) + end.should.raise(Encoding::CompatibilityError) end it "raises an ArgumentError if the specified form is invalid" do -> { @angstrom.unicode_normalize(:invalid_form) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -104,13 +104,13 @@ it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do -> { [0xE0].pack('C').force_encoding("ISO-8859-1").unicode_normalize! - }.should raise_error(Encoding::CompatibilityError) + }.should.raise(Encoding::CompatibilityError) end it "raises an ArgumentError if the specified form is invalid" do ohm = "\u2126" -> { ohm.unicode_normalize!(:invalid_form) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/unicode_normalized_spec.rb b/spec/ruby/core/string/unicode_normalized_spec.rb index 91cf2086b25972..3ca27d35ddf3e0 100644 --- a/spec/ruby/core/string/unicode_normalized_spec.rb +++ b/spec/ruby/core/string/unicode_normalized_spec.rb @@ -38,38 +38,38 @@ end it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do - -> { @nfc_normalized_str.force_encoding("ISO-8859-1").unicode_normalized? }.should raise_error(Encoding::CompatibilityError) + -> { @nfc_normalized_str.force_encoding("ISO-8859-1").unicode_normalized? }.should.raise(Encoding::CompatibilityError) end it "raises an ArgumentError if the specified form is invalid" do - -> { @nfc_normalized_str.unicode_normalized?(:invalid_form) }.should raise_error(ArgumentError) + -> { @nfc_normalized_str.unicode_normalized?(:invalid_form) }.should.raise(ArgumentError) end it "returns true if str is in Unicode normalization form (nfc)" do str = "a\u0300" - str.unicode_normalized?(:nfc).should be_false + str.unicode_normalized?(:nfc).should == false str.unicode_normalize!(:nfc) - str.unicode_normalized?(:nfc).should be_true + str.unicode_normalized?(:nfc).should == true end it "returns true if str is in Unicode normalization form (nfd)" do str = "a\u00E0" - str.unicode_normalized?(:nfd).should be_false + str.unicode_normalized?(:nfd).should == false str.unicode_normalize!(:nfd) - str.unicode_normalized?(:nfd).should be_true + str.unicode_normalized?(:nfd).should == true end it "returns true if str is in Unicode normalization form (nfkc)" do str = "a\u0300" - str.unicode_normalized?(:nfkc).should be_false + str.unicode_normalized?(:nfkc).should == false str.unicode_normalize!(:nfkc) - str.unicode_normalized?(:nfkc).should be_true + str.unicode_normalized?(:nfkc).should == true end it "returns true if str is in Unicode normalization form (nfkd)" do str = "a\u00E0" - str.unicode_normalized?(:nfkd).should be_false + str.unicode_normalized?(:nfkd).should == false str.unicode_normalize!(:nfkd) - str.unicode_normalized?(:nfkd).should be_true + str.unicode_normalized?(:nfkd).should == true end end diff --git a/spec/ruby/core/string/unpack/at_spec.rb b/spec/ruby/core/string/unpack/at_spec.rb index d4133c23ee5576..f4999f5922b1d0 100644 --- a/spec/ruby/core/string/unpack/at_spec.rb +++ b/spec/ruby/core/string/unpack/at_spec.rb @@ -24,6 +24,6 @@ end it "raises an ArgumentError if the count exceeds the size of the String" do - -> { "\x01\x02\x03\x04".unpack("C2@5C") }.should raise_error(ArgumentError) + -> { "\x01\x02\x03\x04".unpack("C2@5C") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/unpack/b_spec.rb b/spec/ruby/core/string/unpack/b_spec.rb index 70ea1cb6ad98e3..fac6ef5151ef9e 100644 --- a/spec/ruby/core/string/unpack/b_spec.rb +++ b/spec/ruby/core/string/unpack/b_spec.rb @@ -89,7 +89,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "\x80\x00".unpack("B\x00B") - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -187,7 +187,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "\x01\x00".unpack("b\x00b") - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do diff --git a/spec/ruby/core/string/unpack/c_spec.rb b/spec/ruby/core/string/unpack/c_spec.rb index e42b027c7b8d6c..d881015b5e0e5a 100644 --- a/spec/ruby/core/string/unpack/c_spec.rb +++ b/spec/ruby/core/string/unpack/c_spec.rb @@ -38,7 +38,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "abc".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do diff --git a/spec/ruby/core/string/unpack/h_spec.rb b/spec/ruby/core/string/unpack/h_spec.rb index 130b36401a7d05..0cf8d943a7f458 100644 --- a/spec/ruby/core/string/unpack/h_spec.rb +++ b/spec/ruby/core/string/unpack/h_spec.rb @@ -59,7 +59,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "\x01\x10".unpack("H\x00H") - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -126,7 +126,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "\x01\x10".unpack("h\x00h") - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do diff --git a/spec/ruby/core/string/unpack/m_spec.rb b/spec/ruby/core/string/unpack/m_spec.rb index 357987a053def1..c1c1eea629c7c8 100644 --- a/spec/ruby/core/string/unpack/m_spec.rb +++ b/spec/ruby/core/string/unpack/m_spec.rb @@ -186,7 +186,7 @@ end it "raises an ArgumentError for an invalid base64 character" do - -> { "dGV%zdA==".unpack("m0") }.should raise_error(ArgumentError) + -> { "dGV%zdA==".unpack("m0") }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/string/unpack/p_spec.rb b/spec/ruby/core/string/unpack/p_spec.rb index cd48c0523d643c..4103730269b6f5 100644 --- a/spec/ruby/core/string/unpack/p_spec.rb +++ b/spec/ruby/core/string/unpack/p_spec.rb @@ -15,7 +15,7 @@ packed = ["hello"].pack("P") packed.unpack("P5").should == ["hello"] packed.dup.unpack("P5").should == ["hello"] - -> { packed.to_sym.to_s.unpack("P5") }.should raise_error(ArgumentError, /no associated pointer/) + -> { packed.to_sym.to_s.unpack("P5") }.should.raise(ArgumentError, /no associated pointer/) end it "reads as many characters as specified" do @@ -39,6 +39,6 @@ packed = ["hello"].pack("p") packed.unpack("p").should == ["hello"] packed.dup.unpack("p").should == ["hello"] - -> { packed.to_sym.to_s.unpack("p") }.should raise_error(ArgumentError, /no associated pointer/) + -> { packed.to_sym.to_s.unpack("p") }.should.raise(ArgumentError, /no associated pointer/) end end diff --git a/spec/ruby/core/string/unpack/percent_spec.rb b/spec/ruby/core/string/unpack/percent_spec.rb index 0e27663195b118..7142bbf2418ede 100644 --- a/spec/ruby/core/string/unpack/percent_spec.rb +++ b/spec/ruby/core/string/unpack/percent_spec.rb @@ -2,6 +2,6 @@ describe "String#unpack with format '%'" do it "raises an Argument Error" do - -> { "abc".unpack("%") }.should raise_error(ArgumentError) + -> { "abc".unpack("%") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/unpack/shared/basic.rb b/spec/ruby/core/string/unpack/shared/basic.rb index 132c4ef08acf21..2ee2d6899a7657 100644 --- a/spec/ruby/core/string/unpack/shared/basic.rb +++ b/spec/ruby/core/string/unpack/shared/basic.rb @@ -1,27 +1,27 @@ describe :string_unpack_basic, shared: true do it "ignores whitespace in the format string" do - "abc".unpack("a \t\n\v\f\r"+unpack_format).should be_an_instance_of(Array) + "abc".unpack("a \t\n\v\f\r"+unpack_format).should.instance_of?(Array) end it "calls #to_str to coerce the directives string" do d = mock("unpack directive") d.should_receive(:to_str).and_return("a"+unpack_format) - "abc".unpack(d).should be_an_instance_of(Array) + "abc".unpack(d).should.instance_of?(Array) end it "raises ArgumentError when a directive is unknown" do - -> { "abcdefgh".unpack("a K" + unpack_format) }.should raise_error(ArgumentError, "unknown unpack directive 'K' in 'a K#{unpack_format}'") - -> { "abcdefgh".unpack("a 0" + unpack_format) }.should raise_error(ArgumentError, "unknown unpack directive '0' in 'a 0#{unpack_format}'") - -> { "abcdefgh".unpack("a :" + unpack_format) }.should raise_error(ArgumentError, "unknown unpack directive ':' in 'a :#{unpack_format}'") + -> { "abcdefgh".unpack("a K" + unpack_format) }.should.raise(ArgumentError, "unknown unpack directive 'K' in 'a K#{unpack_format}'") + -> { "abcdefgh".unpack("a 0" + unpack_format) }.should.raise(ArgumentError, "unknown unpack directive '0' in 'a 0#{unpack_format}'") + -> { "abcdefgh".unpack("a :" + unpack_format) }.should.raise(ArgumentError, "unknown unpack directive ':' in 'a :#{unpack_format}'") end end describe :string_unpack_no_platform, shared: true do it "raises an ArgumentError when the format modifier is '_'" do - -> { "abcdefgh".unpack(unpack_format("_")) }.should raise_error(ArgumentError) + -> { "abcdefgh".unpack(unpack_format("_")) }.should.raise(ArgumentError) end it "raises an ArgumentError when the format modifier is '!'" do - -> { "abcdefgh".unpack(unpack_format("!")) }.should raise_error(ArgumentError) + -> { "abcdefgh".unpack(unpack_format("!")) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/unpack/shared/float.rb b/spec/ruby/core/string/unpack/shared/float.rb index 0133be2ecb498e..5525c3fe73de85 100644 --- a/spec/ruby/core/string/unpack/shared/float.rb +++ b/spec/ruby/core/string/unpack/shared/float.rb @@ -53,13 +53,13 @@ it "decodes NaN" do # mumble mumble NaN mumble https://bugs.ruby-lang.org/issues/5884 - [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should be_true + [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should == true end it "raise ArgumentError for NULL bytes between directives" do -> { "\x9a\x999@33\xb3?".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -121,13 +121,13 @@ it "decodes NaN" do # mumble mumble NaN mumble https://bugs.ruby-lang.org/issues/5884 - [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should be_true + [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should == true end it "raise ArgumentError for NULL bytes between directives" do -> { "@9\x99\x9a?\xb333".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -192,13 +192,13 @@ it "decodes NaN" do # mumble mumble NaN mumble https://bugs.ruby-lang.org/issues/5884 - [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should be_true + [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should == true end it "raise ArgumentError for NULL bytes between directives" do -> { "333333\x07@ffffff\xf6?".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -262,13 +262,13 @@ it "decodes NaN" do # mumble mumble NaN mumble https://bugs.ruby-lang.org/issues/5884 - [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should be_true + [nan_value].pack(unpack_format).unpack(unpack_format).first.nan?.should == true end it "raise ArgumentError for NULL bytes between directives" do -> { "@\x07333333?\xf6ffffff".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do diff --git a/spec/ruby/core/string/unpack/shared/integer.rb b/spec/ruby/core/string/unpack/shared/integer.rb index eb994562251732..c66156536b3289 100644 --- a/spec/ruby/core/string/unpack/shared/integer.rb +++ b/spec/ruby/core/string/unpack/shared/integer.rb @@ -35,7 +35,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "abcd".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -90,7 +90,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "badc".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -146,7 +146,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "abcdefgh".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -202,7 +202,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "dcbahgfe".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -254,7 +254,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "badc".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do @@ -317,7 +317,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "hgfedcbadcfehgba".unpack(unpack_format("\000", 2)) - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do diff --git a/spec/ruby/core/string/unpack/shared/unicode.rb b/spec/ruby/core/string/unpack/shared/unicode.rb index b056aaed0be627..9b4e0c09de42cf 100644 --- a/spec/ruby/core/string/unpack/shared/unicode.rb +++ b/spec/ruby/core/string/unpack/shared/unicode.rb @@ -53,7 +53,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "\x01\x02".unpack("U\x00U") - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do diff --git a/spec/ruby/core/string/unpack/u_spec.rb b/spec/ruby/core/string/unpack/u_spec.rb index 68c8f6f11c1775..720c1b85832687 100644 --- a/spec/ruby/core/string/unpack/u_spec.rb +++ b/spec/ruby/core/string/unpack/u_spec.rb @@ -12,11 +12,11 @@ it_behaves_like :string_unpack_taint, 'U' it "raises ArgumentError on a malformed byte sequence" do - -> { "\xE3".unpack('U') }.should raise_error(ArgumentError) + -> { "\xE3".unpack('U') }.should.raise(ArgumentError) end it "raises ArgumentError on a malformed byte sequence and doesn't continue when used with the * modifier" do - -> { "\xE3".unpack('U*') }.should raise_error(ArgumentError) + -> { "\xE3".unpack('U*') }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/unpack/w_spec.rb b/spec/ruby/core/string/unpack/w_spec.rb index d2ad657b09c8b8..cc9aecac9c9ae1 100644 --- a/spec/ruby/core/string/unpack/w_spec.rb +++ b/spec/ruby/core/string/unpack/w_spec.rb @@ -18,7 +18,7 @@ it "raise ArgumentError for NULL bytes between directives" do -> { "\x01\x02\x03".unpack("w\x00w") - }.should raise_error(ArgumentError, /unknown unpack directive/) + }.should.raise(ArgumentError, /unknown unpack directive/) end it "ignores spaces between directives" do diff --git a/spec/ruby/core/string/unpack/x_spec.rb b/spec/ruby/core/string/unpack/x_spec.rb index 2926ebbe0f3a95..fb2e79fc1f765a 100644 --- a/spec/ruby/core/string/unpack/x_spec.rb +++ b/spec/ruby/core/string/unpack/x_spec.rb @@ -24,11 +24,11 @@ end it "raises an ArgumentError when passed the '*' modifier if the remaining bytes exceed the bytes from the index to the start of the String" do - -> { "abcd".unpack("CX*C") }.should raise_error(ArgumentError) + -> { "abcd".unpack("CX*C") }.should.raise(ArgumentError) end it "raises an ArgumentError if the count exceeds the bytes from current index to the start of the String" do - -> { "\x01\x02\x03\x04".unpack("C3X4C") }.should raise_error(ArgumentError) + -> { "\x01\x02\x03\x04".unpack("C3X4C") }.should.raise(ArgumentError) end end @@ -57,6 +57,6 @@ end it "raises an ArgumentError if the count exceeds the size of the String" do - -> { "\x01\x02\x03\x04".unpack("C2x3C") }.should raise_error(ArgumentError) + -> { "\x01\x02\x03\x04".unpack("C2x3C") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/unpack1_spec.rb b/spec/ruby/core/string/unpack1_spec.rb index cfb47fe6953365..3b0fa90900abcf 100644 --- a/spec/ruby/core/string/unpack1_spec.rb +++ b/spec/ruby/core/string/unpack1_spec.rb @@ -21,7 +21,7 @@ end it "raises an ArgumentError when the offset is negative" do - -> { "a".unpack1("C", offset: -1) }.should raise_error(ArgumentError, "offset can't be negative") + -> { "a".unpack1("C", offset: -1) }.should.raise(ArgumentError, "offset can't be negative") end it "returns nil if the offset is at the end of the string" do @@ -29,7 +29,7 @@ end it "raises an ArgumentError when the offset is larger than the string bytesize" do - -> { "a".unpack1("C", offset: 2) }.should raise_error(ArgumentError, "offset outside of string") + -> { "a".unpack1("C", offset: 2) }.should.raise(ArgumentError, "offset outside of string") end context "with format 'm0'" do @@ -41,7 +41,7 @@ end it "raises an ArgumentError for an invalid base64 character" do - -> { "dGV%zdA==".unpack1("m0") }.should raise_error(ArgumentError) + -> { "dGV%zdA==".unpack1("m0") }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/core/string/unpack_spec.rb b/spec/ruby/core/string/unpack_spec.rb index a0abf8fa994788..28dbbc14c411c6 100644 --- a/spec/ruby/core/string/unpack_spec.rb +++ b/spec/ruby/core/string/unpack_spec.rb @@ -2,11 +2,11 @@ describe "String#unpack" do it "raises a TypeError when passed nil" do - -> { "abc".unpack(nil) }.should raise_error(TypeError) + -> { "abc".unpack(nil) }.should.raise(TypeError) end it "raises a TypeError when passed an Integer" do - -> { "abc".unpack(1) }.should raise_error(TypeError) + -> { "abc".unpack(1) }.should.raise(TypeError) end it "starts unpacking from the given offset" do @@ -19,7 +19,7 @@ end it "raises an ArgumentError when the offset is negative" do - -> { "a".unpack("C", offset: -1) }.should raise_error(ArgumentError, "offset can't be negative") + -> { "a".unpack("C", offset: -1) }.should.raise(ArgumentError, "offset can't be negative") end it "returns nil if the offset is at the end of the string" do @@ -27,6 +27,6 @@ end it "raises an ArgumentError when the offset is larger than the string" do - -> { "a".unpack("C", offset: 2) }.should raise_error(ArgumentError, "offset outside of string") + -> { "a".unpack("C", offset: 2) }.should.raise(ArgumentError, "offset outside of string") end end diff --git a/spec/ruby/core/string/upcase_spec.rb b/spec/ruby/core/string/upcase_spec.rb index 652de5c2ef0c26..a6e186926725c1 100644 --- a/spec/ruby/core/string/upcase_spec.rb +++ b/spec/ruby/core/string/upcase_spec.rb @@ -24,7 +24,7 @@ upcased.should == "ASSET" upcased.size.should == 5 upcased.bytesize.should == 5 - upcased.ascii_only?.should be_true + upcased.ascii_only?.should == true end end @@ -48,7 +48,7 @@ end it "does not allow any other additional option" do - -> { "i".upcase(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { "i".upcase(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -62,27 +62,27 @@ end it "does not allow any other additional option" do - -> { "iß".upcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { "iß".upcase(:lithuanian, :ascii) }.should.raise(ArgumentError) end end it "does not allow the :fold option for upcasing" do - -> { "abc".upcase(:fold) }.should raise_error(ArgumentError) + -> { "abc".upcase(:fold) }.should.raise(ArgumentError) end it "does not allow invalid options" do - -> { "abc".upcase(:invalid_option) }.should raise_error(ArgumentError) + -> { "abc".upcase(:invalid_option) }.should.raise(ArgumentError) end it "returns a String instance for subclasses" do - StringSpecs::MyString.new("fooBAR").upcase.should be_an_instance_of(String) + StringSpecs::MyString.new("fooBAR").upcase.should.instance_of?(String) end end describe "String#upcase!" do it "modifies self in place" do a = "HeLlO" - a.upcase!.should equal(a) + a.upcase!.should.equal?(a) a.should == "HELLO" end @@ -112,7 +112,7 @@ upcased.should == "ASSET" upcased.size.should == 5 upcased.bytesize.should == 5 - upcased.ascii_only?.should be_true + upcased.ascii_only?.should == true end end @@ -144,7 +144,7 @@ end it "does not allow any other additional option" do - -> { a = "i"; a.upcase!(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { a = "i"; a.upcase!(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -162,16 +162,16 @@ end it "does not allow any other additional option" do - -> { a = "iß"; a.upcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { a = "iß"; a.upcase!(:lithuanian, :ascii) }.should.raise(ArgumentError) end end it "does not allow the :fold option for upcasing" do - -> { a = "abc"; a.upcase!(:fold) }.should raise_error(ArgumentError) + -> { a = "abc"; a.upcase!(:fold) }.should.raise(ArgumentError) end it "does not allow invalid options" do - -> { a = "abc"; a.upcase!(:invalid_option) }.should raise_error(ArgumentError) + -> { a = "abc"; a.upcase!(:invalid_option) }.should.raise(ArgumentError) end it "returns nil if no modifications were made" do @@ -181,7 +181,7 @@ end it "raises a FrozenError when self is frozen" do - -> { "HeLlo".freeze.upcase! }.should raise_error(FrozenError) - -> { "HELLO".freeze.upcase! }.should raise_error(FrozenError) + -> { "HeLlo".freeze.upcase! }.should.raise(FrozenError) + -> { "HELLO".freeze.upcase! }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/upto_spec.rb b/spec/ruby/core/string/upto_spec.rb index 8bc847d5ac1358..2eea06fd013858 100644 --- a/spec/ruby/core/string/upto_spec.rb +++ b/spec/ruby/core/string/upto_spec.rb @@ -53,13 +53,13 @@ def other.to_str() "abd" end end it "raises a TypeError if other can't be converted to a string" do - -> { "abc".upto(123) { } }.should raise_error(TypeError) - -> { "abc".upto(mock('x')){ } }.should raise_error(TypeError) + -> { "abc".upto(123) { } }.should.raise(TypeError) + -> { "abc".upto(mock('x')){ } }.should.raise(TypeError) end it "does not work with symbols" do - -> { "a".upto(:c).to_a }.should raise_error(TypeError) + -> { "a".upto(:c).to_a }.should.raise(TypeError) end it "returns non-alphabetic characters in the ASCII range for single letters" do @@ -83,7 +83,7 @@ def other.to_str() "abd" end it "raises Encoding::CompatibilityError when incompatible characters are given" do char1 = 'a'.dup.force_encoding("EUC-JP") char2 = 'b'.dup.force_encoding("ISO-2022-JP") - -> { char1.upto(char2) {} }.should raise_error(Encoding::CompatibilityError, "incompatible character encodings: EUC-JP and ISO-2022-JP") + -> { char1.upto(char2) {} }.should.raise(Encoding::CompatibilityError, "incompatible character encodings: EUC-JP and ISO-2022-JP") end describe "on sequence of numbers" do @@ -95,7 +95,7 @@ def other.to_str() "abd" end describe "when no block is given" do it "returns an enumerator" do enum = "aaa".upto("baa", true) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.count.should == 26**2 end diff --git a/spec/ruby/core/string/valid_encoding_spec.rb b/spec/ruby/core/string/valid_encoding_spec.rb index 375035cd9496a9..f29220fc999066 100644 --- a/spec/ruby/core/string/valid_encoding_spec.rb +++ b/spec/ruby/core/string/valid_encoding_spec.rb @@ -2,132 +2,132 @@ describe "String#valid_encoding?" do it "returns true if the String's encoding is valid" do - "a".valid_encoding?.should be_true - "\u{8365}\u{221}".valid_encoding?.should be_true + "a".valid_encoding?.should == true + "\u{8365}\u{221}".valid_encoding?.should == true end it "returns true if self is valid in the current encoding and other encodings" do str = +"\x77" - str.force_encoding('utf-8').valid_encoding?.should be_true - str.force_encoding('binary').valid_encoding?.should be_true + str.force_encoding('utf-8').valid_encoding?.should == true + str.force_encoding('binary').valid_encoding?.should == true end it "returns true for all encodings self is valid in" do str = +"\xE6\x9D\x94" - str.force_encoding('BINARY').valid_encoding?.should be_true - str.force_encoding('UTF-8').valid_encoding?.should be_true - str.force_encoding('US-ASCII').valid_encoding?.should be_false - str.force_encoding('Big5').valid_encoding?.should be_false - str.force_encoding('CP949').valid_encoding?.should be_false - str.force_encoding('Emacs-Mule').valid_encoding?.should be_false - str.force_encoding('EUC-JP').valid_encoding?.should be_false - str.force_encoding('EUC-KR').valid_encoding?.should be_false - str.force_encoding('EUC-TW').valid_encoding?.should be_false - str.force_encoding('GB18030').valid_encoding?.should be_false - str.force_encoding('GBK').valid_encoding?.should be_false - str.force_encoding('ISO-8859-1').valid_encoding?.should be_true - str.force_encoding('ISO-8859-2').valid_encoding?.should be_true - str.force_encoding('ISO-8859-3').valid_encoding?.should be_true - str.force_encoding('ISO-8859-4').valid_encoding?.should be_true - str.force_encoding('ISO-8859-5').valid_encoding?.should be_true - str.force_encoding('ISO-8859-6').valid_encoding?.should be_true - str.force_encoding('ISO-8859-7').valid_encoding?.should be_true - str.force_encoding('ISO-8859-8').valid_encoding?.should be_true - str.force_encoding('ISO-8859-9').valid_encoding?.should be_true - str.force_encoding('ISO-8859-10').valid_encoding?.should be_true - str.force_encoding('ISO-8859-11').valid_encoding?.should be_true - str.force_encoding('ISO-8859-13').valid_encoding?.should be_true - str.force_encoding('ISO-8859-14').valid_encoding?.should be_true - str.force_encoding('ISO-8859-15').valid_encoding?.should be_true - str.force_encoding('ISO-8859-16').valid_encoding?.should be_true - str.force_encoding('KOI8-R').valid_encoding?.should be_true - str.force_encoding('KOI8-U').valid_encoding?.should be_true - str.force_encoding('Shift_JIS').valid_encoding?.should be_false - "\xD8\x00".dup.force_encoding('UTF-16BE').valid_encoding?.should be_false - "\x00\xD8".dup.force_encoding('UTF-16LE').valid_encoding?.should be_false - "\x04\x03\x02\x01".dup.force_encoding('UTF-32BE').valid_encoding?.should be_false - "\x01\x02\x03\x04".dup.force_encoding('UTF-32LE').valid_encoding?.should be_false - str.force_encoding('Windows-1251').valid_encoding?.should be_true - str.force_encoding('IBM437').valid_encoding?.should be_true - str.force_encoding('IBM737').valid_encoding?.should be_true - str.force_encoding('IBM775').valid_encoding?.should be_true - str.force_encoding('CP850').valid_encoding?.should be_true - str.force_encoding('IBM852').valid_encoding?.should be_true - str.force_encoding('CP852').valid_encoding?.should be_true - str.force_encoding('IBM855').valid_encoding?.should be_true - str.force_encoding('CP855').valid_encoding?.should be_true - str.force_encoding('IBM857').valid_encoding?.should be_true - str.force_encoding('IBM860').valid_encoding?.should be_true - str.force_encoding('IBM861').valid_encoding?.should be_true - str.force_encoding('IBM862').valid_encoding?.should be_true - str.force_encoding('IBM863').valid_encoding?.should be_true - str.force_encoding('IBM864').valid_encoding?.should be_true - str.force_encoding('IBM865').valid_encoding?.should be_true - str.force_encoding('IBM866').valid_encoding?.should be_true - str.force_encoding('IBM869').valid_encoding?.should be_true - str.force_encoding('Windows-1258').valid_encoding?.should be_true - str.force_encoding('GB1988').valid_encoding?.should be_true - str.force_encoding('macCentEuro').valid_encoding?.should be_true - str.force_encoding('macCroatian').valid_encoding?.should be_true - str.force_encoding('macCyrillic').valid_encoding?.should be_true - str.force_encoding('macGreek').valid_encoding?.should be_true - str.force_encoding('macIceland').valid_encoding?.should be_true - str.force_encoding('macRoman').valid_encoding?.should be_true - str.force_encoding('macRomania').valid_encoding?.should be_true - str.force_encoding('macThai').valid_encoding?.should be_true - str.force_encoding('macTurkish').valid_encoding?.should be_true - str.force_encoding('macUkraine').valid_encoding?.should be_true - str.force_encoding('stateless-ISO-2022-JP').valid_encoding?.should be_false - str.force_encoding('eucJP-ms').valid_encoding?.should be_false - str.force_encoding('CP51932').valid_encoding?.should be_false - str.force_encoding('GB2312').valid_encoding?.should be_false - str.force_encoding('GB12345').valid_encoding?.should be_false - str.force_encoding('ISO-2022-JP').valid_encoding?.should be_true - str.force_encoding('ISO-2022-JP-2').valid_encoding?.should be_true - str.force_encoding('CP50221').valid_encoding?.should be_true - str.force_encoding('Windows-1252').valid_encoding?.should be_true - str.force_encoding('Windows-1250').valid_encoding?.should be_true - str.force_encoding('Windows-1256').valid_encoding?.should be_true - str.force_encoding('Windows-1253').valid_encoding?.should be_true - str.force_encoding('Windows-1255').valid_encoding?.should be_true - str.force_encoding('Windows-1254').valid_encoding?.should be_true - str.force_encoding('TIS-620').valid_encoding?.should be_true - str.force_encoding('Windows-874').valid_encoding?.should be_true - str.force_encoding('Windows-1257').valid_encoding?.should be_true - str.force_encoding('Windows-31J').valid_encoding?.should be_false - str.force_encoding('MacJapanese').valid_encoding?.should be_false - str.force_encoding('UTF-7').valid_encoding?.should be_true - str.force_encoding('UTF8-MAC').valid_encoding?.should be_true + str.force_encoding('BINARY').valid_encoding?.should == true + str.force_encoding('UTF-8').valid_encoding?.should == true + str.force_encoding('US-ASCII').valid_encoding?.should == false + str.force_encoding('Big5').valid_encoding?.should == false + str.force_encoding('CP949').valid_encoding?.should == false + str.force_encoding('Emacs-Mule').valid_encoding?.should == false + str.force_encoding('EUC-JP').valid_encoding?.should == false + str.force_encoding('EUC-KR').valid_encoding?.should == false + str.force_encoding('EUC-TW').valid_encoding?.should == false + str.force_encoding('GB18030').valid_encoding?.should == false + str.force_encoding('GBK').valid_encoding?.should == false + str.force_encoding('ISO-8859-1').valid_encoding?.should == true + str.force_encoding('ISO-8859-2').valid_encoding?.should == true + str.force_encoding('ISO-8859-3').valid_encoding?.should == true + str.force_encoding('ISO-8859-4').valid_encoding?.should == true + str.force_encoding('ISO-8859-5').valid_encoding?.should == true + str.force_encoding('ISO-8859-6').valid_encoding?.should == true + str.force_encoding('ISO-8859-7').valid_encoding?.should == true + str.force_encoding('ISO-8859-8').valid_encoding?.should == true + str.force_encoding('ISO-8859-9').valid_encoding?.should == true + str.force_encoding('ISO-8859-10').valid_encoding?.should == true + str.force_encoding('ISO-8859-11').valid_encoding?.should == true + str.force_encoding('ISO-8859-13').valid_encoding?.should == true + str.force_encoding('ISO-8859-14').valid_encoding?.should == true + str.force_encoding('ISO-8859-15').valid_encoding?.should == true + str.force_encoding('ISO-8859-16').valid_encoding?.should == true + str.force_encoding('KOI8-R').valid_encoding?.should == true + str.force_encoding('KOI8-U').valid_encoding?.should == true + str.force_encoding('Shift_JIS').valid_encoding?.should == false + "\xD8\x00".dup.force_encoding('UTF-16BE').valid_encoding?.should == false + "\x00\xD8".dup.force_encoding('UTF-16LE').valid_encoding?.should == false + "\x04\x03\x02\x01".dup.force_encoding('UTF-32BE').valid_encoding?.should == false + "\x01\x02\x03\x04".dup.force_encoding('UTF-32LE').valid_encoding?.should == false + str.force_encoding('Windows-1251').valid_encoding?.should == true + str.force_encoding('IBM437').valid_encoding?.should == true + str.force_encoding('IBM737').valid_encoding?.should == true + str.force_encoding('IBM775').valid_encoding?.should == true + str.force_encoding('CP850').valid_encoding?.should == true + str.force_encoding('IBM852').valid_encoding?.should == true + str.force_encoding('CP852').valid_encoding?.should == true + str.force_encoding('IBM855').valid_encoding?.should == true + str.force_encoding('CP855').valid_encoding?.should == true + str.force_encoding('IBM857').valid_encoding?.should == true + str.force_encoding('IBM860').valid_encoding?.should == true + str.force_encoding('IBM861').valid_encoding?.should == true + str.force_encoding('IBM862').valid_encoding?.should == true + str.force_encoding('IBM863').valid_encoding?.should == true + str.force_encoding('IBM864').valid_encoding?.should == true + str.force_encoding('IBM865').valid_encoding?.should == true + str.force_encoding('IBM866').valid_encoding?.should == true + str.force_encoding('IBM869').valid_encoding?.should == true + str.force_encoding('Windows-1258').valid_encoding?.should == true + str.force_encoding('GB1988').valid_encoding?.should == true + str.force_encoding('macCentEuro').valid_encoding?.should == true + str.force_encoding('macCroatian').valid_encoding?.should == true + str.force_encoding('macCyrillic').valid_encoding?.should == true + str.force_encoding('macGreek').valid_encoding?.should == true + str.force_encoding('macIceland').valid_encoding?.should == true + str.force_encoding('macRoman').valid_encoding?.should == true + str.force_encoding('macRomania').valid_encoding?.should == true + str.force_encoding('macThai').valid_encoding?.should == true + str.force_encoding('macTurkish').valid_encoding?.should == true + str.force_encoding('macUkraine').valid_encoding?.should == true + str.force_encoding('stateless-ISO-2022-JP').valid_encoding?.should == false + str.force_encoding('eucJP-ms').valid_encoding?.should == false + str.force_encoding('CP51932').valid_encoding?.should == false + str.force_encoding('GB2312').valid_encoding?.should == false + str.force_encoding('GB12345').valid_encoding?.should == false + str.force_encoding('ISO-2022-JP').valid_encoding?.should == true + str.force_encoding('ISO-2022-JP-2').valid_encoding?.should == true + str.force_encoding('CP50221').valid_encoding?.should == true + str.force_encoding('Windows-1252').valid_encoding?.should == true + str.force_encoding('Windows-1250').valid_encoding?.should == true + str.force_encoding('Windows-1256').valid_encoding?.should == true + str.force_encoding('Windows-1253').valid_encoding?.should == true + str.force_encoding('Windows-1255').valid_encoding?.should == true + str.force_encoding('Windows-1254').valid_encoding?.should == true + str.force_encoding('TIS-620').valid_encoding?.should == true + str.force_encoding('Windows-874').valid_encoding?.should == true + str.force_encoding('Windows-1257').valid_encoding?.should == true + str.force_encoding('Windows-31J').valid_encoding?.should == false + str.force_encoding('MacJapanese').valid_encoding?.should == false + str.force_encoding('UTF-7').valid_encoding?.should == true + str.force_encoding('UTF8-MAC').valid_encoding?.should == true end it "returns true for IBM720 encoding self is valid in" do str = +"\xE6\x9D\x94" - str.force_encoding('IBM720').valid_encoding?.should be_true - str.force_encoding('CP720').valid_encoding?.should be_true + str.force_encoding('IBM720').valid_encoding?.should == true + str.force_encoding('CP720').valid_encoding?.should == true end it "returns false if self is valid in one encoding, but invalid in the one it's tagged with" do str = +"\u{8765}" - str.valid_encoding?.should be_true + str.valid_encoding?.should == true str.force_encoding('ascii') - str.valid_encoding?.should be_false + str.valid_encoding?.should == false end it "returns false if self contains a character invalid in the associated encoding" do - "abc#{[0x80].pack('C')}".dup.force_encoding('ascii').valid_encoding?.should be_false + "abc#{[0x80].pack('C')}".dup.force_encoding('ascii').valid_encoding?.should == false end it "returns false if a valid String had an invalid character appended to it" do str = +"a" - str.valid_encoding?.should be_true + str.valid_encoding?.should == true str << [0xDD].pack('C').force_encoding('utf-8') - str.valid_encoding?.should be_false + str.valid_encoding?.should == false end it "returns true if an invalid string is appended another invalid one but both make a valid string" do str = [0xD0].pack('C').force_encoding('utf-8') - str.valid_encoding?.should be_false + str.valid_encoding?.should == false str << [0xBF].pack('C').force_encoding('utf-8') - str.valid_encoding?.should be_true + str.valid_encoding?.should == true end end diff --git a/spec/ruby/core/struct/deconstruct_keys_spec.rb b/spec/ruby/core/struct/deconstruct_keys_spec.rb index 0360a4b1947aa3..590e1ab40b158f 100644 --- a/spec/ruby/core/struct/deconstruct_keys_spec.rb +++ b/spec/ruby/core/struct/deconstruct_keys_spec.rb @@ -14,7 +14,7 @@ -> { obj.deconstruct_keys - }.should raise_error(ArgumentError, /wrong number of arguments \(given 0, expected 1\)/) + }.should.raise(ArgumentError, /wrong number of arguments \(given 0, expected 1\)/) end it "returns only specified keys" do @@ -115,16 +115,16 @@ -> { s.deconstruct_keys([0, []]) - }.should raise_error(TypeError, "no implicit conversion of Array into Integer") + }.should.raise(TypeError, "no implicit conversion of Array into Integer") end it "raise TypeError if passed anything except nil or array" do struct = Struct.new(:x, :y) s = struct.new(1, 2) - -> { s.deconstruct_keys('x') }.should raise_error(TypeError, /expected Array or nil/) - -> { s.deconstruct_keys(1) }.should raise_error(TypeError, /expected Array or nil/) - -> { s.deconstruct_keys(:x) }.should raise_error(TypeError, /expected Array or nil/) - -> { s.deconstruct_keys({}) }.should raise_error(TypeError, /expected Array or nil/) + -> { s.deconstruct_keys('x') }.should.raise(TypeError, /expected Array or nil/) + -> { s.deconstruct_keys(1) }.should.raise(TypeError, /expected Array or nil/) + -> { s.deconstruct_keys(:x) }.should.raise(TypeError, /expected Array or nil/) + -> { s.deconstruct_keys({}) }.should.raise(TypeError, /expected Array or nil/) end end diff --git a/spec/ruby/core/struct/dig_spec.rb b/spec/ruby/core/struct/dig_spec.rb index 93a52dbbe15471..52e4d1dd9ae063 100644 --- a/spec/ruby/core/struct/dig_spec.rb +++ b/spec/ruby/core/struct/dig_spec.rb @@ -32,11 +32,11 @@ instance = @klass.new(1) -> { instance.dig(:a, 3) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises an ArgumentError if no arguments provided" do - -> { @instance.dig }.should raise_error(ArgumentError) + -> { @instance.dig }.should.raise(ArgumentError) end it "calls #dig on any intermediate step with the rest of the sequence as arguments" do diff --git a/spec/ruby/core/struct/each_pair_spec.rb b/spec/ruby/core/struct/each_pair_spec.rb index 1230ca9026350c..db146c81e9cc1a 100644 --- a/spec/ruby/core/struct/each_pair_spec.rb +++ b/spec/ruby/core/struct/each_pair_spec.rb @@ -21,11 +21,11 @@ end it "returns self if passed a block" do - @car.each_pair {}.should equal(@car) + @car.each_pair {}.should.equal?(@car) end it "returns an Enumerator if not passed a block" do - @car.each_pair.should be_an_instance_of(Enumerator) + @car.each_pair.should.instance_of?(Enumerator) end it_behaves_like :struct_accessor, :each_pair diff --git a/spec/ruby/core/struct/each_spec.rb b/spec/ruby/core/struct/each_spec.rb index 41c0fbd4d0d882..4fbdfee02a9e0f 100644 --- a/spec/ruby/core/struct/each_spec.rb +++ b/spec/ruby/core/struct/each_spec.rb @@ -19,7 +19,7 @@ it "returns an Enumerator if not passed a block" do car = StructClasses::Car.new('Ford', 'Ranger') - car.each.should be_an_instance_of(Enumerator) + car.each.should.instance_of?(Enumerator) end it_behaves_like :struct_accessor, :each diff --git a/spec/ruby/core/struct/element_reference_spec.rb b/spec/ruby/core/struct/element_reference_spec.rb index 0f6d547f665d3e..b94f3aae8cb19d 100644 --- a/spec/ruby/core/struct/element_reference_spec.rb +++ b/spec/ruby/core/struct/element_reference_spec.rb @@ -3,7 +3,7 @@ describe "Struct[]" do it "is a synonym for new" do - StructClasses::Ruby['2.0', 'i686'].should be_kind_of(StructClasses::Ruby) + StructClasses::Ruby['2.0', 'i686'].should.is_a?(StructClasses::Ruby) end end @@ -26,20 +26,20 @@ it "fails when it does not know about the requested attribute" do car = StructClasses::Car.new('Ford', 'Ranger') - -> { car[3] }.should raise_error(IndexError) - -> { car[-4] }.should raise_error(IndexError) - -> { car[:body] }.should raise_error(NameError) - -> { car['wheels'] }.should raise_error(NameError) + -> { car[3] }.should.raise(IndexError) + -> { car[-4] }.should.raise(IndexError) + -> { car[:body] }.should.raise(NameError) + -> { car['wheels'] }.should.raise(NameError) end it "fails if passed too many arguments" do car = StructClasses::Car.new('Ford', 'Ranger') - -> { car[:make, :model] }.should raise_error(ArgumentError) + -> { car[:make, :model] }.should.raise(ArgumentError) end it "fails if not passed a string, symbol, or integer" do car = StructClasses::Car.new('Ford', 'Ranger') - -> { car[Object.new] }.should raise_error(TypeError) + -> { car[Object.new] }.should.raise(TypeError) end it "returns attribute names that contain hyphens" do diff --git a/spec/ruby/core/struct/element_set_spec.rb b/spec/ruby/core/struct/element_set_spec.rb index 0a0e34a5eee1c2..e5438ca09a0e36 100644 --- a/spec/ruby/core/struct/element_set_spec.rb +++ b/spec/ruby/core/struct/element_set_spec.rb @@ -21,16 +21,16 @@ it "fails when trying to assign attributes which don't exist" do car = StructClasses::Car.new('Ford', 'Ranger') - -> { car[:something] = true }.should raise_error(NameError) - -> { car[3] = true }.should raise_error(IndexError) - -> { car[-4] = true }.should raise_error(IndexError) - -> { car[Object.new] = true }.should raise_error(TypeError) + -> { car[:something] = true }.should.raise(NameError) + -> { car[3] = true }.should.raise(IndexError) + -> { car[-4] = true }.should.raise(IndexError) + -> { car[Object.new] = true }.should.raise(TypeError) end it "raises a FrozenError on a frozen struct" do car = StructClasses::Car.new('Ford', 'Ranger') car.freeze - -> { car[:model] = 'Escape' }.should raise_error(FrozenError) + -> { car[:model] = 'Escape' }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/struct/eql_spec.rb b/spec/ruby/core/struct/eql_spec.rb index c864b2b943cbdc..327c9272782367 100644 --- a/spec/ruby/core/struct/eql_spec.rb +++ b/spec/ruby/core/struct/eql_spec.rb @@ -8,6 +8,6 @@ it "returns false if any corresponding elements are not #eql?" do car = StructClasses::Car.new("Honda", "Accord", 1998) similar_car = StructClasses::Car.new("Honda", "Accord", 1998.0) - car.should_not eql(similar_car) + car.should_not.eql?(similar_car) end end diff --git a/spec/ruby/core/struct/hash_spec.rb b/spec/ruby/core/struct/hash_spec.rb index 53361eb7a95b13..750387b326ef3a 100644 --- a/spec/ruby/core/struct/hash_spec.rb +++ b/spec/ruby/core/struct/hash_spec.rb @@ -8,14 +8,14 @@ [StructClasses::Ruby.new("1.8.6", "PPC"), StructClasses::Car.new("Hugo", "Foo", "1972")].each do |stc| stc.hash.should == stc.dup.hash - stc.hash.should be_kind_of(Integer) + stc.hash.should.is_a?(Integer) end end it "returns the same value if structs are #eql?" do car = StructClasses::Car.new("Honda", "Accord", "1998") similar_car = StructClasses::Car.new("Honda", "Accord", "1998") - car.should eql(similar_car) + car.should.eql?(similar_car) car.hash.should == similar_car.hash end diff --git a/spec/ruby/core/struct/initialize_spec.rb b/spec/ruby/core/struct/initialize_spec.rb index 6a541d7c9edb3b..c824f52e13c9c5 100644 --- a/spec/ruby/core/struct/initialize_spec.rb +++ b/spec/ruby/core/struct/initialize_spec.rb @@ -4,7 +4,7 @@ describe "Struct#initialize" do it "is private" do - StructClasses::Car.should have_private_instance_method(:initialize) + StructClasses::Car.private_instance_methods(true).should.include?(:initialize) end it 'allows valid Ruby method names for members' do diff --git a/spec/ruby/core/struct/instance_variable_get_spec.rb b/spec/ruby/core/struct/instance_variable_get_spec.rb index e4a3ea87dc41e7..e3555cd246ea74 100644 --- a/spec/ruby/core/struct/instance_variable_get_spec.rb +++ b/spec/ruby/core/struct/instance_variable_get_spec.rb @@ -4,7 +4,7 @@ describe "Struct#instance_variable_get" do it "returns nil for attributes" do car = StructClasses::Car.new("Hugo", "Foo", "1972") - car.instance_variable_get(:@make).should be_nil + car.instance_variable_get(:@make).should == nil end it "returns a user value for variables with the same name as attributes" do diff --git a/spec/ruby/core/struct/keyword_init_spec.rb b/spec/ruby/core/struct/keyword_init_spec.rb index 536b82041ae321..42fcd3cc2906f1 100644 --- a/spec/ruby/core/struct/keyword_init_spec.rb +++ b/spec/ruby/core/struct/keyword_init_spec.rb @@ -5,36 +5,36 @@ describe "StructClass#keyword_init?" do it "returns true for a struct that accepts keyword arguments to initialize" do struct = Struct.new(:arg, keyword_init: true) - struct.keyword_init?.should be_true + struct.keyword_init?.should == true end it "returns false for a struct that does not accept keyword arguments to initialize" do struct = Struct.new(:arg, keyword_init: false) - struct.keyword_init?.should be_false + struct.keyword_init?.should == false end it "returns nil for a struct that did not explicitly specify keyword_init" do struct = Struct.new(:arg) - struct.keyword_init?.should be_nil + struct.keyword_init?.should == nil end it "returns nil for a struct that does specify keyword_init to be nil" do struct = Struct.new(:arg, keyword_init: nil) - struct.keyword_init?.should be_nil + struct.keyword_init?.should == nil end it "returns true for any truthy value, not just for true" do struct = Struct.new(:arg, keyword_init: 1) - struct.keyword_init?.should be_true + struct.keyword_init?.should == true struct = Struct.new(:arg, keyword_init: "") - struct.keyword_init?.should be_true + struct.keyword_init?.should == true struct = Struct.new(:arg, keyword_init: []) - struct.keyword_init?.should be_true + struct.keyword_init?.should == true struct = Struct.new(:arg, keyword_init: {}) - struct.keyword_init?.should be_true + struct.keyword_init?.should == true end context "class inheriting Struct" do diff --git a/spec/ruby/core/struct/new_spec.rb b/spec/ruby/core/struct/new_spec.rb index 741d6889af08a1..b3ece2efed5669 100644 --- a/spec/ruby/core/struct/new_spec.rb +++ b/spec/ruby/core/struct/new_spec.rb @@ -38,19 +38,19 @@ def obj.to_str() "Foo" end it "creates a new anonymous class with nil first argument" do struct = Struct.new(nil, :foo) struct.new("bar").foo.should == "bar" - struct.should be_kind_of(Class) - struct.name.should be_nil + struct.should.is_a?(Class) + struct.name.should == nil end it "creates a new anonymous class with symbol arguments" do struct = Struct.new(:make, :model) - struct.should be_kind_of(Class) + struct.should.is_a?(Class) struct.name.should == nil end it "does not create a constant with symbol as first argument" do Struct.new(:Animal2, :name, :legs, :eyeballs) - Struct.const_defined?("Animal2").should be_false + Struct.const_defined?("Animal2").should == false end it "allows non-ASCII member name" do @@ -60,42 +60,42 @@ def obj.to_str() "Foo" end end it "fails with invalid constant name as first argument" do - -> { Struct.new('animal', :name, :legs, :eyeballs) }.should raise_error(NameError) + -> { Struct.new('animal', :name, :legs, :eyeballs) }.should.raise(NameError) end it "raises a TypeError if object doesn't respond to to_sym" do - -> { Struct.new(:animal, mock('giraffe')) }.should raise_error(TypeError) - -> { Struct.new(:animal, 1.0) }.should raise_error(TypeError) - -> { Struct.new(:animal, Time.now) }.should raise_error(TypeError) - -> { Struct.new(:animal, Class) }.should raise_error(TypeError) - -> { Struct.new(:animal, nil) }.should raise_error(TypeError) - -> { Struct.new(:animal, true) }.should raise_error(TypeError) - -> { Struct.new(:animal, ['chris', 'evan']) }.should raise_error(TypeError) + -> { Struct.new(:animal, mock('giraffe')) }.should.raise(TypeError) + -> { Struct.new(:animal, 1.0) }.should.raise(TypeError) + -> { Struct.new(:animal, Time.now) }.should.raise(TypeError) + -> { Struct.new(:animal, Class) }.should.raise(TypeError) + -> { Struct.new(:animal, nil) }.should.raise(TypeError) + -> { Struct.new(:animal, true) }.should.raise(TypeError) + -> { Struct.new(:animal, ['chris', 'evan']) }.should.raise(TypeError) end it "raises a TypeError if passed a Hash with an unknown key" do - -> { Struct.new(:animal, { name: 'chris' }) }.should raise_error(TypeError) + -> { Struct.new(:animal, { name: 'chris' }) }.should.raise(TypeError) end it "works when not provided any arguments" do c = Struct.new - c.should be_kind_of(Class) + c.should.is_a?(Class) c.superclass.should == Struct end it "raises ArgumentError when there is a duplicate member" do - -> { Struct.new(:foo, :foo) }.should raise_error(ArgumentError, "duplicate member: foo") + -> { Struct.new(:foo, :foo) }.should.raise(ArgumentError, "duplicate member: foo") end it "raises a TypeError if object is not a Symbol" do obj = mock(':ruby') def obj.to_sym() :ruby end - -> { Struct.new(:animal, obj) }.should raise_error(TypeError) + -> { Struct.new(:animal, obj) }.should.raise(TypeError) end it "processes passed block with instance_eval" do klass = Struct.new(:something) { @something_else = 'something else entirely!' } - klass.instance_variables.should include(:@something_else) + klass.instance_variables.should.include?(:@something_else) end context "with a block" do @@ -116,7 +116,7 @@ def platform klass = Struct.new(:attr) do |block_parameter| given = block_parameter end - klass.should equal(given) + klass.should.equal?(given) end end @@ -133,17 +133,17 @@ def platform end it "creates reader methods" do - StructClasses::Ruby.new.should have_method(:version) - StructClasses::Ruby.new.should have_method(:platform) + StructClasses::Ruby.new.should.respond_to?(:version) + StructClasses::Ruby.new.should.respond_to?(:platform) end it "creates writer methods" do - StructClasses::Ruby.new.should have_method(:version=) - StructClasses::Ruby.new.should have_method(:platform=) + StructClasses::Ruby.new.should.respond_to?(:version=) + StructClasses::Ruby.new.should.respond_to?(:platform=) end it "fails with too many arguments" do - -> { StructClasses::Ruby.new('2.0', 'i686', true) }.should raise_error(ArgumentError) + -> { StructClasses::Ruby.new('2.0', 'i686', true) }.should.raise(ArgumentError) end it "accepts keyword arguments to initialize" do @@ -182,7 +182,7 @@ def platform it "raises ArgumentError when all struct attribute values are specified" do type = Struct.new(:a, :b) - -> { type.new("a", "b", c: "c") }.should raise_error(ArgumentError, "struct size differs") + -> { type.new("a", "b", c: "c") }.should.raise(ArgumentError, "struct size differs") end end end @@ -199,7 +199,7 @@ def platform end it "raises when there is a duplicate member" do - -> { Struct.new(:foo, :foo, keyword_init: true) }.should raise_error(ArgumentError, "duplicate member: foo") + -> { Struct.new(:foo, :foo, keyword_init: true) }.should.raise(ArgumentError, "duplicate member: foo") end describe "new class instantiation" do @@ -212,31 +212,31 @@ def platform it "allows missing arguments" do obj = @struct_with_kwa.new(name: "elefant") obj.name.should == "elefant" - obj.legs.should be_nil + obj.legs.should == nil end it "allows no arguments" do obj = @struct_with_kwa.new - obj.name.should be_nil - obj.legs.should be_nil + obj.name.should == nil + obj.legs.should == nil end it "raises ArgumentError when passed not declared keyword argument" do -> { @struct_with_kwa.new(name: "elefant", legs: 4, foo: "bar") - }.should raise_error(ArgumentError, /unknown keywords: foo/) + }.should.raise(ArgumentError, /unknown keywords: foo/) end it "raises ArgumentError when passed a list of arguments" do -> { @struct_with_kwa.new("elefant", 4) - }.should raise_error(ArgumentError, /wrong number of arguments/) + }.should.raise(ArgumentError, /wrong number of arguments/) end it "raises ArgumentError when passed a single non-hash argument" do -> { @struct_with_kwa.new("elefant") - }.should raise_error(ArgumentError, /wrong number of arguments/) + }.should.raise(ArgumentError, /wrong number of arguments/) end end end diff --git a/spec/ruby/core/struct/shared/select.rb b/spec/ruby/core/struct/shared/select.rb index 35abee461b3602..dfa1a809fe774c 100644 --- a/spec/ruby/core/struct/shared/select.rb +++ b/spec/ruby/core/struct/shared/select.rb @@ -4,7 +4,7 @@ describe :struct_select, shared: true do it "raises an ArgumentError if given any non-block arguments" do struct = StructClasses::Car.new - -> { struct.send(@method, 1) { } }.should raise_error(ArgumentError) + -> { struct.send(@method, 1) { } }.should.raise(ArgumentError) end it "returns a new array of elements for which block is true" do @@ -14,13 +14,13 @@ it "returns an instance of Array" do struct = StructClasses::Car.new("Ford", "Escort", "1995") - struct.send(@method) { true }.should be_an_instance_of(Array) + struct.send(@method) { true }.should.instance_of?(Array) end describe "without block" do it "returns an instance of Enumerator" do struct = Struct.new(:foo).new - struct.send(@method).should be_an_instance_of(Enumerator) + struct.send(@method).should.instance_of?(Enumerator) end end end diff --git a/spec/ruby/core/struct/struct_spec.rb b/spec/ruby/core/struct/struct_spec.rb index 1b6a4488ce9b7a..9fab9c0629d852 100644 --- a/spec/ruby/core/struct/struct_spec.rb +++ b/spec/ruby/core/struct/struct_spec.rb @@ -21,7 +21,7 @@ it "reader method should not interfere with undefined methods" do car = StructClasses::Car.new('Ford', 'Ranger') - -> { car.something_weird }.should raise_error(NoMethodError) + -> { car.something_weird }.should.raise(NoMethodError) end it "writer method be a synonym for []=" do @@ -38,7 +38,7 @@ car = StructClasses::Car.new('Ford', 'Ranger') car.freeze - -> { car.model = 'Escape' }.should raise_error(FrozenError) + -> { car.model = 'Escape' }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/struct/to_h_spec.rb b/spec/ruby/core/struct/to_h_spec.rb index 861ce3f49df401..e0846ef268f4ba 100644 --- a/spec/ruby/core/struct/to_h_spec.rb +++ b/spec/ruby/core/struct/to_h_spec.rb @@ -36,17 +36,17 @@ it "raises ArgumentError if block returns longer or shorter array" do -> do StructClasses::Car.new.to_h { |k, v| [k.to_s, "#{v}".downcase, 1] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) -> do StructClasses::Car.new.to_h { |k, v| [k] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(ArgumentError, /element has wrong array length/) end it "raises TypeError if block returns something other than Array" do -> do StructClasses::Car.new.to_h { |k, v| "not-array" } - end.should raise_error(TypeError, /wrong element type String/) + end.should.raise(TypeError, /wrong element type String/) end it "coerces returned pair to Array with #to_ary" do @@ -62,7 +62,7 @@ -> do StructClasses::Car.new.to_h { |k| x } - end.should raise_error(TypeError, /wrong element type MockObject/) + end.should.raise(TypeError, /wrong element type MockObject/) end end end diff --git a/spec/ruby/core/struct/values_at_spec.rb b/spec/ruby/core/struct/values_at_spec.rb index 5e5a496600f7d9..6aac5d96b3252e 100644 --- a/spec/ruby/core/struct/values_at_spec.rb +++ b/spec/ruby/core/struct/values_at_spec.rb @@ -14,8 +14,8 @@ end it "raises IndexError if any of integers is out of range" do - -> { @movie.values_at(3) }.should raise_error(IndexError, "offset 3 too large for struct(size:3)") - -> { @movie.values_at(-4) }.should raise_error(IndexError, "offset -4 too small for struct(size:3)") + -> { @movie.values_at(3) }.should.raise(IndexError, "offset 3 too large for struct(size:3)") + -> { @movie.values_at(-4) }.should.raise(IndexError, "offset -4 too small for struct(size:3)") end end @@ -29,7 +29,7 @@ end it "raises RangeError if any element of the range is negative and out of range" do - -> { @movie.values_at(-4..3) }.should raise_error(RangeError, "-4..3 out of range") + -> { @movie.values_at(-4..3) }.should.raise(RangeError, "-4..3 out of range") end it "supports endless Range" do @@ -54,6 +54,6 @@ end it "fails when passed unsupported types" do - -> { @movie.values_at('make') }.should raise_error(TypeError, "no implicit conversion of String into Integer") + -> { @movie.values_at('make') }.should.raise(TypeError, "no implicit conversion of String into Integer") end end diff --git a/spec/ruby/core/symbol/all_symbols_spec.rb b/spec/ruby/core/symbol/all_symbols_spec.rb index 1e2180909328f5..689f6211def124 100644 --- a/spec/ruby/core/symbol/all_symbols_spec.rb +++ b/spec/ruby/core/symbol/all_symbols_spec.rb @@ -3,17 +3,17 @@ describe "Symbol.all_symbols" do it "returns an array of Symbols" do all_symbols = Symbol.all_symbols - all_symbols.should be_an_instance_of(Array) - all_symbols.each { |s| s.should be_an_instance_of(Symbol) } + all_symbols.should.instance_of?(Array) + all_symbols.each { |s| s.should.instance_of?(Symbol) } end it "includes symbols that are strongly referenced" do symbol = "symbol_specs_#{rand(5_000_000)}".to_sym - Symbol.all_symbols.should include(symbol) + Symbol.all_symbols.should.include?(symbol) end it "includes symbols that are referenced in source code but not yet executed" do - Symbol.all_symbols.any? { |s| s.to_s == 'symbol_specs_referenced_in_source_code' }.should be_true + Symbol.all_symbols.any? { |s| s.to_s == 'symbol_specs_referenced_in_source_code' }.should == true :symbol_specs_referenced_in_source_code end end diff --git a/spec/ruby/core/symbol/capitalize_spec.rb b/spec/ruby/core/symbol/capitalize_spec.rb index a84bcf280a1c29..a93d951e6a6f86 100644 --- a/spec/ruby/core/symbol/capitalize_spec.rb +++ b/spec/ruby/core/symbol/capitalize_spec.rb @@ -3,7 +3,7 @@ describe "Symbol#capitalize" do it "returns a Symbol" do - :glark.capitalize.should be_an_instance_of(Symbol) + :glark.capitalize.should.instance_of?(Symbol) end it "converts the first character to uppercase if it is ASCII" do diff --git a/spec/ruby/core/symbol/casecmp_spec.rb b/spec/ruby/core/symbol/casecmp_spec.rb index 662a29a2847a63..dcb77a8350ff51 100644 --- a/spec/ruby/core/symbol/casecmp_spec.rb +++ b/spec/ruby/core/symbol/casecmp_spec.rb @@ -64,16 +64,16 @@ describe "Symbol#casecmp" do it "returns nil if other is a String" do - :abc.casecmp("abc").should be_nil + :abc.casecmp("abc").should == nil end it "returns nil if other is an Integer" do - :abc.casecmp(1).should be_nil + :abc.casecmp(1).should == nil end it "returns nil if other is an object" do obj = mock("string <=>") - :abc.casecmp(obj).should be_nil + :abc.casecmp(obj).should == nil end end diff --git a/spec/ruby/core/symbol/comparison_spec.rb b/spec/ruby/core/symbol/comparison_spec.rb index 613177be0564c9..6d56176e975f6d 100644 --- a/spec/ruby/core/symbol/comparison_spec.rb +++ b/spec/ruby/core/symbol/comparison_spec.rb @@ -37,15 +37,15 @@ describe "Symbol#<=>" do it "returns nil if other is a String" do - (:abc <=> "abc").should be_nil + (:abc <=> "abc").should == nil end it "returns nil if other is an Integer" do - (:abc <=> 1).should be_nil + (:abc <=> 1).should == nil end it "returns nil if other is an object" do obj = mock("string <=>") - (:abc <=> obj).should be_nil + (:abc <=> obj).should == nil end end diff --git a/spec/ruby/core/symbol/downcase_spec.rb b/spec/ruby/core/symbol/downcase_spec.rb index 7e94c669cc59d7..76418aa9da5ab1 100644 --- a/spec/ruby/core/symbol/downcase_spec.rb +++ b/spec/ruby/core/symbol/downcase_spec.rb @@ -3,7 +3,7 @@ describe "Symbol#downcase" do it "returns a Symbol" do - :glark.downcase.should be_an_instance_of(Symbol) + :glark.downcase.should.instance_of?(Symbol) end it "converts uppercase ASCII characters to their lowercase equivalents" do diff --git a/spec/ruby/core/symbol/dup_spec.rb b/spec/ruby/core/symbol/dup_spec.rb index 8b35917c27edaa..eef3078030893a 100644 --- a/spec/ruby/core/symbol/dup_spec.rb +++ b/spec/ruby/core/symbol/dup_spec.rb @@ -2,6 +2,6 @@ describe "Symbol#dup" do it "returns self" do - :a_symbol.dup.should equal(:a_symbol) + :a_symbol.dup.should.equal?(:a_symbol) end end diff --git a/spec/ruby/core/symbol/empty_spec.rb b/spec/ruby/core/symbol/empty_spec.rb index 19c23cfe5f5c1d..1d90a59a5b2950 100644 --- a/spec/ruby/core/symbol/empty_spec.rb +++ b/spec/ruby/core/symbol/empty_spec.rb @@ -2,10 +2,10 @@ describe "Symbol#empty?" do it "returns true if self is empty" do - :"".empty?.should be_true + :"".empty?.should == true end it "returns false if self is non-empty" do - :"a".empty?.should be_false + :"a".empty?.should == false end end diff --git a/spec/ruby/core/symbol/intern_spec.rb b/spec/ruby/core/symbol/intern_spec.rb index ea04b87e8a6ee3..9d0914c7fbe802 100644 --- a/spec/ruby/core/symbol/intern_spec.rb +++ b/spec/ruby/core/symbol/intern_spec.rb @@ -6,6 +6,6 @@ end it "returns a Symbol" do - :foo.intern.should be_kind_of(Symbol) + :foo.intern.should.is_a?(Symbol) end end diff --git a/spec/ruby/core/symbol/match_spec.rb b/spec/ruby/core/symbol/match_spec.rb index 41e058f9777b31..7b165218c649de 100644 --- a/spec/ruby/core/symbol/match_spec.rb +++ b/spec/ruby/core/symbol/match_spec.rb @@ -6,7 +6,7 @@ end it "returns nil if there is no match" do - :a.send(@method, /b/).should be_nil + :a.send(@method, /b/).should == nil end it "sets the last match pseudo-variables" do @@ -22,12 +22,12 @@ describe "Symbol#match" do it "returns the MatchData" do result = :abc.match(/b/) - result.should be_kind_of(MatchData) + result.should.is_a?(MatchData) result[0].should == 'b' end it "returns nil if there is no match" do - :a.match(/b/).should be_nil + :a.match(/b/).should == nil end it "sets the last match pseudo-variables" do @@ -38,7 +38,7 @@ describe "when passed a block" do it "yields the MatchData" do :abc.match(/./) {|m| ScratchPad.record m } - ScratchPad.recorded.should be_kind_of(MatchData) + ScratchPad.recorded.should.is_a?(MatchData) end it "returns the block result" do @@ -61,17 +61,17 @@ context "when matches the given regex" do it "returns true but does not set Regexp.last_match" do - :string.match?(/string/i).should be_true - Regexp.last_match.should be_nil + :string.match?(/string/i).should == true + Regexp.last_match.should == nil end end it "returns false when does not match the given regex" do - :string.match?(/STRING/).should be_false + :string.match?(/STRING/).should == false end it "takes matching position as the 2nd argument" do - :string.match?(/str/i, 0).should be_true - :string.match?(/str/i, 1).should be_false + :string.match?(/str/i, 0).should == true + :string.match?(/str/i, 1).should == false end end diff --git a/spec/ruby/core/symbol/shared/slice.rb b/spec/ruby/core/symbol/shared/slice.rb index d3d4aad617c741..4e3a35240cc4d0 100644 --- a/spec/ruby/core/symbol/shared/slice.rb +++ b/spec/ruby/core/symbol/shared/slice.rb @@ -7,11 +7,11 @@ end it "returns nil if the index starts from the end and is greater than the length" do - :symbol.send(@method, -10).should be_nil + :symbol.send(@method, -10).should == nil end it "returns nil if the index is greater than the length" do - :symbol.send(@method, 42).should be_nil + :symbol.send(@method, 42).should == nil end end @@ -31,14 +31,14 @@ end it "returns nil if the index is greater than the length" do - :symbol.send(@method, 10,1).should be_nil + :symbol.send(@method, 10,1).should == nil end end describe "and a positive index and negative length" do it "returns nil" do - :symbol.send(@method, 0,-1).should be_nil - :symbol.send(@method, 1,-1).should be_nil + :symbol.send(@method, 0,-1).should == nil + :symbol.send(@method, 1,-1).should == nil end end @@ -56,13 +56,13 @@ end it "returns nil if the index is past the start" do - :symbol.send(@method, -10,1).should be_nil + :symbol.send(@method, -10,1).should == nil end end describe "and a negative index and negative length" do it "returns nil" do - :symbol.send(@method, -1,-1).should be_nil + :symbol.send(@method, -1,-1).should == nil end end @@ -74,21 +74,21 @@ describe "and a nil length" do it "raises a TypeError" do - -> { :symbol.send(@method, 1,nil) }.should raise_error(TypeError) + -> { :symbol.send(@method, 1,nil) }.should.raise(TypeError) end end describe "and a length that cannot be converted into an Integer" do it "raises a TypeError when given an Array" do - -> { :symbol.send(@method, 1,Array.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, 1,Array.new) }.should.raise(TypeError) end it "raises a TypeError when given an Hash" do - -> { :symbol.send(@method, 1,Hash.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, 1,Hash.new) }.should.raise(TypeError) end it "raises a TypeError when given an Object" do - -> { :symbol.send(@method, 1,Object.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, 1,Object.new) }.should.raise(TypeError) end end end @@ -101,21 +101,21 @@ describe "with a nil index" do it "raises a TypeError" do - -> { :symbol.send(@method, nil) }.should raise_error(TypeError) + -> { :symbol.send(@method, nil) }.should.raise(TypeError) end end describe "with an index that cannot be converted into an Integer" do it "raises a TypeError when given an Array" do - -> { :symbol.send(@method, Array.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, Array.new) }.should.raise(TypeError) end it "raises a TypeError when given an Hash" do - -> { :symbol.send(@method, Hash.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, Hash.new) }.should.raise(TypeError) end it "raises a TypeError when given an Object" do - -> { :symbol.send(@method, Object.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, Object.new) }.should.raise(TypeError) end end @@ -136,7 +136,7 @@ describe "that is out of bounds" do it "returns nil if the first range value begins past the end" do - :symbol.send(@method, 10..12).should be_nil + :symbol.send(@method, 10..12).should == nil end it "returns a blank string if the first range value is within bounds and the last range value is not" do @@ -145,11 +145,11 @@ end it "returns nil if the first range value starts from the end and is within bounds and the last value starts from the end and is greater than the length" do - :symbol.send(@method, -10..-12).should be_nil + :symbol.send(@method, -10..-12).should == nil end it "returns nil if the first range value starts from the end and is out of bounds and the last value starts from the end and is less than the length" do - :symbol.send(@method, -10..-2).should be_nil + :symbol.send(@method, -10..-2).should == nil end end @@ -178,7 +178,7 @@ end it "returns nil if the expression does not match" do - :symbol.send(@method, /0-9/).should be_nil + :symbol.send(@method, /0-9/).should == nil end it "sets $~ to the MatchData if there is a match" do @@ -188,7 +188,7 @@ it "does not set $~ if there if there is not a match" do :symbol.send(@method, /[0-9]+/) - $~.should be_nil + $~.should == nil end end @@ -203,8 +203,8 @@ end it "returns nil if there is no capture for the index" do - :symbol.send(@method, /(sy)(mb)(ol)/, 4).should be_nil - :symbol.send(@method, /(sy)(mb)(ol)/, -4).should be_nil + :symbol.send(@method, /(sy)(mb)(ol)/, 4).should == nil + :symbol.send(@method, /(sy)(mb)(ol)/, -4).should == nil end it "converts the index to an Integer" do @@ -213,20 +213,20 @@ describe "and an index that cannot be converted to an Integer" do it "raises a TypeError when given an Hash" do - -> { :symbol.send(@method, /(sy)(mb)(ol)/, Hash.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, /(sy)(mb)(ol)/, Hash.new) }.should.raise(TypeError) end it "raises a TypeError when given an Array" do - -> { :symbol.send(@method, /(sy)(mb)(ol)/, Array.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, /(sy)(mb)(ol)/, Array.new) }.should.raise(TypeError) end it "raises a TypeError when given an Object" do - -> { :symbol.send(@method, /(sy)(mb)(ol)/, Object.new) }.should raise_error(TypeError) + -> { :symbol.send(@method, /(sy)(mb)(ol)/, Object.new) }.should.raise(TypeError) end end it "raises a TypeError if the index is nil" do - -> { :symbol.send(@method, /(sy)(mb)(ol)/, nil) }.should raise_error(TypeError) + -> { :symbol.send(@method, /(sy)(mb)(ol)/, nil) }.should.raise(TypeError) end it "sets $~ to the MatchData if there is a match" do @@ -239,7 +239,7 @@ it "does not set $~ to the MatchData if there is not a match" do :symbol.send(@method, /0-9/, 0) - $~.should be_nil + $~.should == nil end end end @@ -248,7 +248,7 @@ it "does not set $~" do $~ = nil :symbol.send(@method, "sym") - $~.should be_nil + $~.should == nil end it "returns a string if there is match" do @@ -256,7 +256,7 @@ end it "returns nil if there is not a match" do - :symbol.send(@method, "foo").should be_nil + :symbol.send(@method, "foo").should == nil end end end diff --git a/spec/ruby/core/symbol/swapcase_spec.rb b/spec/ruby/core/symbol/swapcase_spec.rb index 24709cac30fb4d..95fc29e32b7f39 100644 --- a/spec/ruby/core/symbol/swapcase_spec.rb +++ b/spec/ruby/core/symbol/swapcase_spec.rb @@ -3,7 +3,7 @@ describe "Symbol#swapcase" do it "returns a Symbol" do - :glark.swapcase.should be_an_instance_of(Symbol) + :glark.swapcase.should.instance_of?(Symbol) end it "converts lowercase ASCII characters to their uppercase equivalents" do diff --git a/spec/ruby/core/symbol/symbol_spec.rb b/spec/ruby/core/symbol/symbol_spec.rb index cefe70bc99f063..3534686a08bd48 100644 --- a/spec/ruby/core/symbol/symbol_spec.rb +++ b/spec/ruby/core/symbol/symbol_spec.rb @@ -8,12 +8,12 @@ it ".allocate raises a TypeError" do -> do Symbol.allocate - end.should raise_error(TypeError) + end.should.raise(TypeError) end it ".new is undefined" do -> do Symbol.new - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/symbol/to_proc_spec.rb b/spec/ruby/core/symbol/to_proc_spec.rb index def5d6d3444b95..93ed1e9e9b91d5 100644 --- a/spec/ruby/core/symbol/to_proc_spec.rb +++ b/spec/ruby/core/symbol/to_proc_spec.rb @@ -3,7 +3,7 @@ describe "Symbol#to_proc" do it "returns a new Proc" do proc = :to_s.to_proc - proc.should be_kind_of(Proc) + proc.should.is_a?(Proc) end it "sends self to arguments passed when calling #call on the Proc" do @@ -38,8 +38,8 @@ @a = [] singleton_class.class_eval(&body) tap(&:pub) - proc{tap(&:pro)}.should raise_error(NoMethodError, /protected method [`']pro' called/) - proc{tap(&:pri)}.should raise_error(NoMethodError, /private method [`']pri' called/) + proc{tap(&:pro)}.should.raise(NoMethodError, /protected method [`']pro' called/) + proc{tap(&:pri)}.should.raise(NoMethodError, /private method [`']pri' called/) @a.should == [:pub] @a = [] @@ -47,15 +47,15 @@ o = c.new o.instance_variable_set(:@a, []) o.tap(&:pub) - proc{tap(&:pro)}.should raise_error(NoMethodError, /protected method [`']pro' called/) - proc{o.tap(&:pri)}.should raise_error(NoMethodError, /private method [`']pri' called/) + proc{tap(&:pro)}.should.raise(NoMethodError, /protected method [`']pro' called/) + proc{o.tap(&:pri)}.should.raise(NoMethodError, /private method [`']pri' called/) o.a.should == [:pub] end it "raises an ArgumentError when calling #call on the Proc without receiver" do -> { :object_id.to_proc.call - }.should raise_error(ArgumentError, /no receiver given|wrong number of arguments \(given 0, expected 1\+\)/) + }.should.raise(ArgumentError, /no receiver given|wrong number of arguments \(given 0, expected 1\+\)/) end it "passes along the block passed to Proc#call" do diff --git a/spec/ruby/core/symbol/upcase_spec.rb b/spec/ruby/core/symbol/upcase_spec.rb index f704bdcbf346c7..3895d95efb403f 100644 --- a/spec/ruby/core/symbol/upcase_spec.rb +++ b/spec/ruby/core/symbol/upcase_spec.rb @@ -3,7 +3,7 @@ describe "Symbol#upcase" do it "returns a Symbol" do - :glark.upcase.should be_an_instance_of(Symbol) + :glark.upcase.should.instance_of?(Symbol) end it "converts lowercase ASCII characters to their uppercase equivalents" do diff --git a/spec/ruby/core/thread/abort_on_exception_spec.rb b/spec/ruby/core/thread/abort_on_exception_spec.rb index 49be84ea9f147e..aeca50e5c17541 100644 --- a/spec/ruby/core/thread/abort_on_exception_spec.rb +++ b/spec/ruby/core/thread/abort_on_exception_spec.rb @@ -13,12 +13,12 @@ end it "is false by default" do - @thread.abort_on_exception.should be_false + @thread.abort_on_exception.should == false end it "returns true when #abort_on_exception= is passed true" do @thread.abort_on_exception = true - @thread.abort_on_exception.should be_true + @thread.abort_on_exception.should == true end end @@ -39,7 +39,7 @@ ThreadSpecs.state = :run # Wait for the main thread to be interrupted sleep - end.should raise_error(RuntimeError, "Thread#abort_on_exception= specs") + end.should.raise(RuntimeError, "Thread#abort_on_exception= specs") ScratchPad << :after rescue Exception => e @@ -81,7 +81,7 @@ it "returns true when .abort_on_exception= is passed true" do Thread.abort_on_exception = true - Thread.abort_on_exception.should be_true + Thread.abort_on_exception.should == true end end diff --git a/spec/ruby/core/thread/allocate_spec.rb b/spec/ruby/core/thread/allocate_spec.rb index cfd556812f34aa..0b4e4f1b1faf18 100644 --- a/spec/ruby/core/thread/allocate_spec.rb +++ b/spec/ruby/core/thread/allocate_spec.rb @@ -4,6 +4,6 @@ it "raises a TypeError" do -> { Thread.allocate - }.should raise_error(TypeError) + }.should.raise(TypeError) end end diff --git a/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb b/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb index 68a69049d93a21..6d9482f2ae1f38 100644 --- a/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb +++ b/spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb @@ -42,7 +42,7 @@ locations = ScratchPad.recorded locations[0].absolute_path.should == path # Make sure it's from the class body, not from the file top-level - locations[0].label.should include 'MethodAddedAbsolutePath' + locations[0].label.should.include? 'MethodAddedAbsolutePath' end end diff --git a/spec/ruby/core/thread/backtrace/location/inspect_spec.rb b/spec/ruby/core/thread/backtrace/location/inspect_spec.rb index 20e477a5a629cd..4df88a2f3318c5 100644 --- a/spec/ruby/core/thread/backtrace/location/inspect_spec.rb +++ b/spec/ruby/core/thread/backtrace/location/inspect_spec.rb @@ -8,6 +8,6 @@ end it 'converts the call frame to a String' do - @frame.inspect.should include("#{__FILE__}:#{@line}:in ") + @frame.inspect.should.include?("#{__FILE__}:#{@line}:in ") end end diff --git a/spec/ruby/core/thread/backtrace/location/label_spec.rb b/spec/ruby/core/thread/backtrace/location/label_spec.rb index 7d358b45ea8fe3..5f6a7b73dfed1f 100644 --- a/spec/ruby/core/thread/backtrace/location/label_spec.rb +++ b/spec/ruby/core/thread/backtrace/location/label_spec.rb @@ -3,7 +3,7 @@ describe 'Thread::Backtrace::Location#label' do it 'returns the base label of the call frame' do - ThreadBacktraceLocationSpecs.locations[0].label.should include('') + ThreadBacktraceLocationSpecs.locations[0].label.should.include?('') end it 'returns the method name for a method location' do diff --git a/spec/ruby/core/thread/backtrace/location/to_s_spec.rb b/spec/ruby/core/thread/backtrace/location/to_s_spec.rb index 5911cdced0c30c..983ce4c3f8c8ca 100644 --- a/spec/ruby/core/thread/backtrace/location/to_s_spec.rb +++ b/spec/ruby/core/thread/backtrace/location/to_s_spec.rb @@ -8,6 +8,6 @@ end it 'converts the call frame to a String' do - @frame.to_s.should include("#{__FILE__}:#{@line}:in ") + @frame.to_s.should.include?("#{__FILE__}:#{@line}:in ") end end diff --git a/spec/ruby/core/thread/backtrace_locations_spec.rb b/spec/ruby/core/thread/backtrace_locations_spec.rb index 09fe622e0daf2b..28a488f3116458 100644 --- a/spec/ruby/core/thread/backtrace_locations_spec.rb +++ b/spec/ruby/core/thread/backtrace_locations_spec.rb @@ -3,20 +3,20 @@ describe "Thread#backtrace_locations" do it "returns an Array" do locations = Thread.current.backtrace_locations - locations.should be_an_instance_of(Array) - locations.should_not be_empty + locations.should.instance_of?(Array) + locations.should_not.empty? end it "sets each element to a Thread::Backtrace::Location" do locations = Thread.current.backtrace_locations - locations.each { |loc| loc.should be_an_instance_of(Thread::Backtrace::Location) } + locations.each { |loc| loc.should.instance_of?(Thread::Backtrace::Location) } end it "can be called on any Thread" do locations = Thread.new { Thread.current.backtrace_locations }.value - locations.should be_an_instance_of(Array) - locations.should_not be_empty - locations.each { |loc| loc.should be_an_instance_of(Thread::Backtrace::Location) } + locations.should.instance_of?(Array) + locations.should_not.empty? + locations.each { |loc| loc.should.instance_of?(Thread::Backtrace::Location) } end it "can be called with a number of locations to omit" do diff --git a/spec/ruby/core/thread/backtrace_spec.rb b/spec/ruby/core/thread/backtrace_spec.rb index 15bb29a349af10..770c300f06a9a6 100644 --- a/spec/ruby/core/thread/backtrace_spec.rb +++ b/spec/ruby/core/thread/backtrace_spec.rb @@ -12,7 +12,7 @@ Thread.pass while t.status && t.status != 'sleep' backtrace = t.backtrace - backtrace.should be_kind_of(Array) + backtrace.should.is_a?(Array) backtrace.first.should =~ /[`'](?:Kernel#)?sleep'/ t.raise 'finish the thread' @@ -30,7 +30,7 @@ backtrace = t.backtrace t.kill t.join - backtrace.should be_kind_of(Array) + backtrace.should.is_a?(Array) end it "can be called with a number of locations to omit" do diff --git a/spec/ruby/core/thread/current_spec.rb b/spec/ruby/core/thread/current_spec.rb index f5ed1d95cd332f..f893f078ba3036 100644 --- a/spec/ruby/core/thread/current_spec.rb +++ b/spec/ruby/core/thread/current_spec.rb @@ -4,13 +4,13 @@ describe "Thread.current" do it "returns a thread" do current = Thread.current - current.should be_kind_of(Thread) + current.should.is_a?(Thread) end it "returns the current thread" do t = Thread.new { Thread.current } - t.value.should equal(t) - Thread.current.should_not equal(t.value) + t.value.should.equal?(t) + Thread.current.should_not.equal?(t.value) end it "returns the correct thread in a Fiber" do @@ -22,10 +22,10 @@ cur = Thread.current Fiber.new { Thread.current - }.resume.should equal cur + }.resume.should.equal? cur cur } - t.value.should equal t + t.value.should.equal? t end end end diff --git a/spec/ruby/core/thread/each_caller_location_spec.rb b/spec/ruby/core/thread/each_caller_location_spec.rb index aa7423675b5a62..15fda1a37badb1 100644 --- a/spec/ruby/core/thread/each_caller_location_spec.rb +++ b/spec/ruby/core/thread/each_caller_location_spec.rb @@ -6,7 +6,7 @@ Thread.each_caller_location { |l| ScratchPad << l; } ScratchPad.recorded.map(&:to_s).should == caller_locations.map(&:to_s) - ScratchPad.recorded[0].should be_kind_of(Thread::Backtrace::Location) + ScratchPad.recorded[0].should.is_a?(Thread::Backtrace::Location) end it "returns subset of 'Thread.to_enum(:each_caller_location)' locations" do @@ -26,7 +26,7 @@ end ar.map(&:to_s).should == caller_locations(1, 2).map(&:to_s) - ecl.should be_kind_of(Thread::Backtrace::Location) + ecl.should.is_a?(Thread::Backtrace::Location) end it "returns nil" do @@ -36,12 +36,12 @@ it "raises LocalJumpError when called without a block" do -> { Thread.each_caller_location - }.should raise_error(LocalJumpError, "no block given") + }.should.raise(LocalJumpError, "no block given") end it "doesn't accept keyword arguments" do -> { Thread.each_caller_location(12, foo: 10) {} - }.should raise_error(ArgumentError); + }.should.raise(ArgumentError); end end diff --git a/spec/ruby/core/thread/element_reference_spec.rb b/spec/ruby/core/thread/element_reference_spec.rb index fde9d1f4401ff2..72892f6c509e97 100644 --- a/spec/ruby/core/thread/element_reference_spec.rb +++ b/spec/ruby/core/thread/element_reference_spec.rb @@ -49,7 +49,7 @@ end it "raises exceptions on the wrong type of keys" do - -> { Thread.current[nil] }.should raise_error(TypeError) - -> { Thread.current[5] }.should raise_error(TypeError) + -> { Thread.current[nil] }.should.raise(TypeError) + -> { Thread.current[5] }.should.raise(TypeError) end end diff --git a/spec/ruby/core/thread/element_set_spec.rb b/spec/ruby/core/thread/element_set_spec.rb index f2051773041fba..97d6c23980411f 100644 --- a/spec/ruby/core/thread/element_set_spec.rb +++ b/spec/ruby/core/thread/element_set_spec.rb @@ -12,7 +12,7 @@ th.freeze -> { th[:foo] = "bar" - }.should raise_error(FrozenError, "can't modify frozen thread locals") + }.should.raise(FrozenError, "can't modify frozen thread locals") end.join end @@ -40,8 +40,8 @@ end it "raises exceptions on the wrong type of keys" do - -> { Thread.current[nil] = true }.should raise_error(TypeError) - -> { Thread.current[5] = true }.should raise_error(TypeError) + -> { Thread.current[nil] = true }.should.raise(TypeError) + -> { Thread.current[5] = true }.should.raise(TypeError) end it "is not shared across fibers" do @@ -51,7 +51,7 @@ Thread.current[:value].should == 1 end fib.resume - Thread.current[:value].should be_nil + Thread.current[:value].should == nil Thread.current[:value] = 2 fib.resume Thread.current[:value] = 2 diff --git a/spec/ruby/core/thread/exit_spec.rb b/spec/ruby/core/thread/exit_spec.rb index c3f710920e28ba..b2e923c680c10a 100644 --- a/spec/ruby/core/thread/exit_spec.rb +++ b/spec/ruby/core/thread/exit_spec.rb @@ -10,6 +10,6 @@ it "causes the current thread to exit" do thread = Thread.new { Thread.exit; sleep } thread.join - thread.status.should be_false + thread.status.should == false end end diff --git a/spec/ruby/core/thread/fetch_spec.rb b/spec/ruby/core/thread/fetch_spec.rb index 85ffb718748c9a..fe27dec4a2871f 100644 --- a/spec/ruby/core/thread/fetch_spec.rb +++ b/spec/ruby/core/thread/fetch_spec.rb @@ -19,7 +19,7 @@ it 'raises a KeyError when the Thread does not have a fiber-local variable of the same name' do th = Thread.new {} th.join - -> { th.fetch(:cat) }.should raise_error(KeyError) + -> { th.fetch(:cat) }.should.raise(KeyError) end it 'returns the value of the fiber-local variable if value has been assigned' do @@ -60,7 +60,7 @@ end it 'raises an ArgumentError when not passed one or two arguments' do - -> { Thread.current.fetch() }.should raise_error(ArgumentError) - -> { Thread.current.fetch(1, 2, 3) }.should raise_error(ArgumentError) + -> { Thread.current.fetch() }.should.raise(ArgumentError) + -> { Thread.current.fetch(1, 2, 3) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/thread/fixtures/classes.rb b/spec/ruby/core/thread/fixtures/classes.rb index 7c485660a8f522..14d5d2f7bfb1cd 100644 --- a/spec/ruby/core/thread/fixtures/classes.rb +++ b/spec/ruby/core/thread/fixtures/classes.rb @@ -207,7 +207,7 @@ def self.dying_thread_with_outer_ensure(kill_method_name=:kill) def self.join_dying_thread_with_outer_ensure(kill_method_name=:kill) t = dying_thread_with_outer_ensure(kill_method_name) { yield } - -> { t.join }.should raise_error(RuntimeError, "In dying thread") + -> { t.join }.should.raise(RuntimeError, "In dying thread") return t end diff --git a/spec/ruby/core/thread/handle_interrupt_spec.rb b/spec/ruby/core/thread/handle_interrupt_spec.rb index ea7e81cb989ce2..aa03d4c66d2570 100644 --- a/spec/ruby/core/thread/handle_interrupt_spec.rb +++ b/spec/ruby/core/thread/handle_interrupt_spec.rb @@ -75,7 +75,7 @@ def make_handle_interrupt_thread(interrupt_config, blocking = true) Thread.handle_interrupt(RuntimeError => :immediate) { flunk "not reached" } - }.should raise_error(RuntimeError, "interrupt immediate") + }.should.raise(RuntimeError, "interrupt immediate") Thread.pending_interrupt?.should == false end end @@ -95,7 +95,7 @@ def make_handle_interrupt_thread(interrupt_config, blocking = true) Thread.handle_interrupt(RuntimeError => :immediate) { flunk "not reached" } - }.should raise_error(RuntimeError, "interrupt with fibers") + }.should.raise(RuntimeError, "interrupt with fibers") Thread.pending_interrupt?.should == false end @@ -115,7 +115,7 @@ def make_handle_interrupt_thread(interrupt_config, blocking = true) executed = true raise "regular exception" end - }.should raise_error(RuntimeError, "interrupt exception") + }.should.raise(RuntimeError, "interrupt exception") executed.should == true end diff --git a/spec/ruby/core/thread/initialize_spec.rb b/spec/ruby/core/thread/initialize_spec.rb index 4fca900cd81c9f..b9a94560ee4cbd 100644 --- a/spec/ruby/core/thread/initialize_spec.rb +++ b/spec/ruby/core/thread/initialize_spec.rb @@ -19,7 +19,7 @@ @t.instance_eval do initialize {} end - }.should raise_error(ThreadError) + }.should.raise(ThreadError) end end diff --git a/spec/ruby/core/thread/join_spec.rb b/spec/ruby/core/thread/join_spec.rb index 213fe2e505190c..f4332167f10f12 100644 --- a/spec/ruby/core/thread/join_spec.rb +++ b/spec/ruby/core/thread/join_spec.rb @@ -4,28 +4,28 @@ describe "Thread#join" do it "returns the thread when it is finished" do t = Thread.new {} - t.join.should equal(t) + t.join.should.equal?(t) end it "returns the thread when it is finished when given a timeout" do t = Thread.new {} t.join - t.join(0).should equal(t) + t.join(0).should.equal?(t) end it "coerces timeout to a Float if it is not nil" do t = Thread.new {} t.join - t.join(0).should equal(t) - t.join(0.0).should equal(t) - t.join(nil).should equal(t) + t.join(0).should.equal?(t) + t.join(0.0).should.equal?(t) + t.join(nil).should.equal?(t) end it "raises TypeError if the argument is not a valid timeout" do t = Thread.new { } t.join - -> { t.join(:foo) }.should raise_error TypeError - -> { t.join("bar") }.should raise_error TypeError + -> { t.join(:foo) }.should.raise TypeError + -> { t.join("bar") }.should.raise TypeError end it "returns nil if it is not finished when given a timeout" do @@ -55,16 +55,16 @@ Thread.current.report_on_exception = false raise NotImplementedError.new("Just kidding") } - -> { t.join }.should raise_error(NotImplementedError) + -> { t.join }.should.raise(NotImplementedError) end it "returns the dead thread" do t = Thread.new { Thread.current.kill } - t.join.should equal(t) + t.join.should.equal?(t) end it "raises any uncaught exception encountered in ensure block" do t = ThreadSpecs.dying_thread_ensures { raise NotImplementedError.new("Just kidding") } - -> { t.join }.should raise_error(NotImplementedError) + -> { t.join }.should.raise(NotImplementedError) end end diff --git a/spec/ruby/core/thread/key_spec.rb b/spec/ruby/core/thread/key_spec.rb index 339fa98f533a3c..a14aeb8d314a2f 100644 --- a/spec/ruby/core/thread/key_spec.rb +++ b/spec/ruby/core/thread/key_spec.rb @@ -24,30 +24,30 @@ end it "raises exceptions on the wrong type of keys" do - -> { Thread.current.key? nil }.should raise_error(TypeError) - -> { Thread.current.key? 5 }.should raise_error(TypeError) + -> { Thread.current.key? nil }.should.raise(TypeError) + -> { Thread.current.key? 5 }.should.raise(TypeError) end it "is not shared across fibers" do fib = Fiber.new do Thread.current[:val1] = 1 Fiber.yield - Thread.current.key?(:val1).should be_true - Thread.current.key?(:val2).should be_false + Thread.current.key?(:val1).should == true + Thread.current.key?(:val2).should == false end - Thread.current.key?(:val1).should_not be_true + Thread.current.key?(:val1).should_not == true fib.resume Thread.current[:val2] = 2 fib.resume - Thread.current.key?(:val1).should be_false - Thread.current.key?(:val2).should be_true + Thread.current.key?(:val1).should == false + Thread.current.key?(:val2).should == true end it "stores a local in another thread when in a fiber" do fib = Fiber.new do t = Thread.new do sleep - Thread.current.key?(:value).should be_true + Thread.current.key?(:value).should == true end Thread.pass while t.status and t.status != "sleep" diff --git a/spec/ruby/core/thread/keys_spec.rb b/spec/ruby/core/thread/keys_spec.rb index 15efda51d6cf94..3a2edd245669ea 100644 --- a/spec/ruby/core/thread/keys_spec.rb +++ b/spec/ruby/core/thread/keys_spec.rb @@ -16,22 +16,22 @@ fib = Fiber.new do Thread.current[:val1] = 1 Fiber.yield - Thread.current.keys.should include(:val1) - Thread.current.keys.should_not include(:val2) + Thread.current.keys.should.include?(:val1) + Thread.current.keys.should_not.include?(:val2) end - Thread.current.keys.should_not include(:val1) + Thread.current.keys.should_not.include?(:val1) fib.resume Thread.current[:val2] = 2 fib.resume - Thread.current.keys.should include(:val2) - Thread.current.keys.should_not include(:val1) + Thread.current.keys.should.include?(:val2) + Thread.current.keys.should_not.include?(:val1) end it "stores a local in another thread when in a fiber" do fib = Fiber.new do t = Thread.new do sleep - Thread.current.keys.should include(:value) + Thread.current.keys.should.include?(:value) end Thread.pass while t.status and t.status != "sleep" diff --git a/spec/ruby/core/thread/kill_spec.rb b/spec/ruby/core/thread/kill_spec.rb index 4b62c686c7de98..f9f1f467444400 100644 --- a/spec/ruby/core/thread/kill_spec.rb +++ b/spec/ruby/core/thread/kill_spec.rb @@ -15,7 +15,7 @@ Thread.pass while thread.status and thread.status != "sleep" Thread.kill(thread).should == thread thread.join - thread.status.should be_false + thread.status.should == false end end end diff --git a/spec/ruby/core/thread/list_spec.rb b/spec/ruby/core/thread/list_spec.rb index 3c6f70c13e230a..5036841d581c1d 100644 --- a/spec/ruby/core/thread/list_spec.rb +++ b/spec/ruby/core/thread/list_spec.rb @@ -3,15 +3,15 @@ describe "Thread.list" do it "includes the current and main thread" do - Thread.list.should include(Thread.current) - Thread.list.should include(Thread.main) + Thread.list.should.include?(Thread.current) + Thread.list.should.include?(Thread.main) end it "includes threads of non-default thread groups" do t = Thread.new { sleep } begin ThreadGroup.new.add(t) - Thread.list.should include(t) + Thread.list.should.include?(t) ensure t.kill t.join @@ -21,7 +21,7 @@ it "does not include deceased threads" do t = Thread.new { 1; } t.join - Thread.list.should_not include(t) + Thread.list.should_not.include?(t) end it "includes waiting threads" do @@ -29,7 +29,7 @@ t = Thread.new { q.pop } begin Thread.pass while t.status and t.status != 'sleep' - Thread.list.should include(t) + Thread.list.should.include?(t) ensure q << nil t.join @@ -45,7 +45,7 @@ begin Thread.list.each { |th| - th.should be_kind_of(Thread) + th.should.is_a?(Thread) } end while spawner.alive? diff --git a/spec/ruby/core/thread/name_spec.rb b/spec/ruby/core/thread/name_spec.rb index 9b3d2f4b09ca0e..47d807be4d2058 100644 --- a/spec/ruby/core/thread/name_spec.rb +++ b/spec/ruby/core/thread/name_spec.rb @@ -36,7 +36,7 @@ it "raises an ArgumentError if the name includes a null byte" do -> { @thread.name = "new thread\0name" - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "can be reset to nil" do diff --git a/spec/ruby/core/thread/native_thread_id_spec.rb b/spec/ruby/core/thread/native_thread_id_spec.rb index 65d1b5b318dbac..cc72e0b85374fd 100644 --- a/spec/ruby/core/thread/native_thread_id_spec.rb +++ b/spec/ruby/core/thread/native_thread_id_spec.rb @@ -3,7 +3,7 @@ platform_is :linux, :darwin, :windows, :freebsd do describe "Thread#native_thread_id" do it "returns an integer when the thread is alive" do - Thread.current.native_thread_id.should be_kind_of(Integer) + Thread.current.native_thread_id.should.is_a?(Integer) end it "returns nil when the thread is not running" do @@ -19,7 +19,7 @@ t_thread_id = t.native_thread_id # native_thread_id can be nil on a M:N scheduler - t_thread_id.should be_kind_of(Integer) if t_thread_id != nil + t_thread_id.should.is_a?(Integer) if t_thread_id != nil main_thread_id.should_not == t_thread_id diff --git a/spec/ruby/core/thread/new_spec.rb b/spec/ruby/core/thread/new_spec.rb index 47a836201c0a0d..acb6cd4e3054d1 100644 --- a/spec/ruby/core/thread/new_spec.rb +++ b/spec/ruby/core/thread/new_spec.rb @@ -18,7 +18,7 @@ end it "raises an exception when not given a block" do - -> { Thread.new }.should raise_error(ThreadError) + -> { Thread.new }.should.raise(ThreadError) end it "creates a subclass of thread calls super with a block in initialize" do @@ -36,7 +36,7 @@ def initialize -> { c.new - }.should raise_error(ThreadError) + }.should.raise(ThreadError) end it "calls and respects #initialize for the block to use" do diff --git a/spec/ruby/core/thread/pending_interrupt_spec.rb b/spec/ruby/core/thread/pending_interrupt_spec.rb index cd565d92a488a3..5fbe7422a9abb0 100644 --- a/spec/ruby/core/thread/pending_interrupt_spec.rb +++ b/spec/ruby/core/thread/pending_interrupt_spec.rb @@ -19,7 +19,7 @@ Thread.pending_interrupt?.should == true executed = true end - }.should raise_error(RuntimeError, "interrupt") + }.should.raise(RuntimeError, "interrupt") executed.should == true Thread.pending_interrupt?.should == false end diff --git a/spec/ruby/core/thread/priority_spec.rb b/spec/ruby/core/thread/priority_spec.rb index e13ad478b544b8..970f7f99710f98 100644 --- a/spec/ruby/core/thread/priority_spec.rb +++ b/spec/ruby/core/thread/priority_spec.rb @@ -15,19 +15,19 @@ end it "inherits the priority of the current thread while running" do - @thread.alive?.should be_true + @thread.alive?.should == true @thread.priority.should == @current_priority end it "maintain the priority of the current thread after death" do ThreadSpecs.state = :exit @thread.join - @thread.alive?.should be_false + @thread.alive?.should == false @thread.priority.should == @current_priority end it "returns an integer" do - @thread.priority.should be_kind_of(Integer) + @thread.priority.should.is_a?(Integer) end end @@ -59,7 +59,7 @@ describe "when set with a non-integer" do it "raises a type error" do - ->{ @thread.priority = Object.new }.should raise_error(TypeError) + ->{ @thread.priority = Object.new }.should.raise(TypeError) end end diff --git a/spec/ruby/core/thread/raise_spec.rb b/spec/ruby/core/thread/raise_spec.rb index 996b07b1b81de6..3b02a2e005481b 100644 --- a/spec/ruby/core/thread/raise_spec.rb +++ b/spec/ruby/core/thread/raise_spec.rb @@ -4,7 +4,7 @@ describe "Thread#raise" do it "is a public method" do - Thread.public_instance_methods.should include(:raise) + Thread.public_instance_methods.should.include?(:raise) end it_behaves_like :kernel_raise, :raise, ThreadSpecs::NewThreadToRaise @@ -36,27 +36,27 @@ it "raises a RuntimeError if no exception class is given" do @thr.raise Thread.pass while @thr.status - ScratchPad.recorded.should be_kind_of(RuntimeError) + ScratchPad.recorded.should.is_a?(RuntimeError) end it "raises the given exception" do @thr.raise Exception Thread.pass while @thr.status - ScratchPad.recorded.should be_kind_of(Exception) + ScratchPad.recorded.should.is_a?(Exception) end it "raises the given exception with the given message" do @thr.raise Exception, "get to work" Thread.pass while @thr.status - ScratchPad.recorded.should be_kind_of(Exception) + ScratchPad.recorded.should.is_a?(Exception) ScratchPad.recorded.message.should == "get to work" end it "raises the given exception and the backtrace is the one of the interrupted thread" do @thr.raise Exception Thread.pass while @thr.status - ScratchPad.recorded.should be_kind_of(Exception) - ScratchPad.recorded.backtrace[0].should include("sleep") + ScratchPad.recorded.should.is_a?(Exception) + ScratchPad.recorded.backtrace[0].should.include?("sleep") end it "is captured and raised by Thread#value" do @@ -68,7 +68,7 @@ ThreadSpecs.spin_until_sleeping(t) t.raise - -> { t.value }.should raise_error(RuntimeError) + -> { t.value }.should.raise(RuntimeError) end it "raises a RuntimeError when called with no arguments inside rescue" do @@ -86,7 +86,7 @@ ThreadSpecs.spin_until_sleeping(t) t.raise end - -> { t.value }.should raise_error(RuntimeError) + -> { t.value }.should.raise(RuntimeError) end it "re-raises a previously rescued exception without overwriting the backtrace" do @@ -108,8 +108,8 @@ raise_again_line = __LINE__; t.raise raised raised_again = t.value - raised_again.backtrace.first.should include("#{__FILE__}:#{initial_raise_line}:") - raised_again.backtrace.first.should_not include("#{__FILE__}:#{raise_again_line}:") + raised_again.backtrace.first.should.include?("#{__FILE__}:#{initial_raise_line}:") + raised_again.backtrace.first.should_not.include?("#{__FILE__}:#{raise_again_line}:") end end @@ -155,19 +155,19 @@ def exception(*args) it "raises a RuntimeError if no exception class is given" do @thr.raise Thread.pass while @thr.status - ScratchPad.recorded.should be_kind_of(RuntimeError) + ScratchPad.recorded.should.is_a?(RuntimeError) end it "raises the given exception" do @thr.raise Exception Thread.pass while @thr.status - ScratchPad.recorded.should be_kind_of(Exception) + ScratchPad.recorded.should.is_a?(Exception) end it "raises the given exception with the given message" do @thr.raise Exception, "get to work" Thread.pass while @thr.status - ScratchPad.recorded.should be_kind_of(Exception) + ScratchPad.recorded.should.is_a?(Exception) ScratchPad.recorded.message.should == "get to work" end @@ -181,7 +181,7 @@ def exception(*args) q.pop # wait for `report_on_exception = false`. t.raise - -> { t.value }.should raise_error(RuntimeError) + -> { t.value }.should.raise(RuntimeError) end it "raises the given argument even when there is an active exception" do @@ -200,7 +200,7 @@ def exception(*args) rescue Thread.pass until raised t.raise RangeError - -> { t.value }.should raise_error(RangeError) + -> { t.value }.should.raise(RangeError) end end @@ -221,7 +221,7 @@ def exception(*args) Thread.pass until raised t.raise end - -> { t.value }.should raise_error(RuntimeError) + -> { t.value }.should.raise(RuntimeError) end end @@ -237,6 +237,6 @@ def exception(*args) Thread.current.raise end end - -> { t.value }.should raise_error(RuntimeError, '') + -> { t.value }.should.raise(RuntimeError, '') end end diff --git a/spec/ruby/core/thread/report_on_exception_spec.rb b/spec/ruby/core/thread/report_on_exception_spec.rb index d9daa041cd9c7a..9cf52608085a13 100644 --- a/spec/ruby/core/thread/report_on_exception_spec.rb +++ b/spec/ruby/core/thread/report_on_exception_spec.rb @@ -58,7 +58,7 @@ -> { t.join - }.should raise_error(RuntimeError, "Thread#report_on_exception specs") + }.should.raise(RuntimeError, "Thread#report_on_exception specs") end it "prints a backtrace on $stderr in the regular backtrace order" do @@ -86,7 +86,7 @@ def foo -> { t.join - }.should raise_error(RuntimeError, "Thread#report_on_exception specs backtrace order") + }.should.raise(RuntimeError, "Thread#report_on_exception specs backtrace order") end it "prints the backtrace even if the thread was killed just after Thread#raise" do @@ -107,7 +107,7 @@ def foo -> { t.join - }.should raise_error(RuntimeError, "Thread#report_on_exception before kill spec") + }.should.raise(RuntimeError, "Thread#report_on_exception before kill spec") end end @@ -124,7 +124,7 @@ def foo -> { t.join - }.should raise_error(RuntimeError, "Thread#report_on_exception specs") + }.should.raise(RuntimeError, "Thread#report_on_exception specs") end end @@ -144,12 +144,12 @@ def foo -> { mutex.sleep(5) - }.should raise_error(RuntimeError, "Thread#report_on_exception specs") + }.should.raise(RuntimeError, "Thread#report_on_exception specs") }.should output("", /Thread.+terminated with exception.+Thread#report_on_exception specs/m) -> { t.join - }.should raise_error(RuntimeError, "Thread#report_on_exception specs") + }.should.raise(RuntimeError, "Thread#report_on_exception specs") end end end diff --git a/spec/ruby/core/thread/shared/exit.rb b/spec/ruby/core/thread/shared/exit.rb index 13e883268422fb..a294c3a4d63ff4 100644 --- a/spec/ruby/core/thread/shared/exit.rb +++ b/spec/ruby/core/thread/shared/exit.rb @@ -56,8 +56,8 @@ Thread.pass while @inner.status and @inner.status != "sleep" @outer.send(@method) @outer.join - ScratchPad.recorded.should include(:inner_ensure_clause) - ScratchPad.recorded.should include(:outer_ensure_clause) + ScratchPad.recorded.should.include?(:inner_ensure_clause) + ScratchPad.recorded.should.include?(:outer_ensure_clause) end it "does not set $!" do @@ -155,7 +155,7 @@ it "propagates inner exception to Thread.join if there is an outer ensure clause" do thread = ThreadSpecs.dying_thread_with_outer_ensure(@method) { } - -> { thread.join }.should raise_error(RuntimeError, "In dying thread") + -> { thread.join }.should.raise(RuntimeError, "In dying thread") end it "runs all outer ensure clauses even if inner ensure clause raises exception" do diff --git a/spec/ruby/core/thread/shared/start.rb b/spec/ruby/core/thread/shared/start.rb index 2ba926bf0054b6..c5d62ab0984a57 100644 --- a/spec/ruby/core/thread/shared/start.rb +++ b/spec/ruby/core/thread/shared/start.rb @@ -6,22 +6,22 @@ it "raises an ArgumentError if not passed a block" do -> { Thread.send(@method) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "spawns a new Thread running the block" do run = false t = Thread.send(@method) { run = true } - t.should be_kind_of(Thread) + t.should.is_a?(Thread) t.join - run.should be_true + run.should == true end it "respects Thread subclasses" do c = Class.new(Thread) t = c.send(@method) { } - t.should be_kind_of(c) + t.should.is_a?(c) t.join end diff --git a/spec/ruby/core/thread/shared/to_s.rb b/spec/ruby/core/thread/shared/to_s.rb index 43640deb33ad79..27e53ba4b83fa8 100644 --- a/spec/ruby/core/thread/shared/to_s.rb +++ b/spec/ruby/core/thread/shared/to_s.rb @@ -12,42 +12,42 @@ end it "can check it's own status" do - ThreadSpecs.status_of_current_thread.send(@method).should include('run') + ThreadSpecs.status_of_current_thread.send(@method).should.include?('run') end it "describes a running thread" do - ThreadSpecs.status_of_running_thread.send(@method).should include('run') + ThreadSpecs.status_of_running_thread.send(@method).should.include?('run') end it "describes a sleeping thread" do - ThreadSpecs.status_of_sleeping_thread.send(@method).should include('sleep') + ThreadSpecs.status_of_sleeping_thread.send(@method).should.include?('sleep') end it "describes a blocked thread" do - ThreadSpecs.status_of_blocked_thread.send(@method).should include('sleep') + ThreadSpecs.status_of_blocked_thread.send(@method).should.include?('sleep') end it "describes a completed thread" do - ThreadSpecs.status_of_completed_thread.send(@method).should include('dead') + ThreadSpecs.status_of_completed_thread.send(@method).should.include?('dead') end it "describes a killed thread" do - ThreadSpecs.status_of_killed_thread.send(@method).should include('dead') + ThreadSpecs.status_of_killed_thread.send(@method).should.include?('dead') end it "describes a thread with an uncaught exception" do - ThreadSpecs.status_of_thread_with_uncaught_exception.send(@method).should include('dead') + ThreadSpecs.status_of_thread_with_uncaught_exception.send(@method).should.include?('dead') end it "describes a dying sleeping thread" do - ThreadSpecs.status_of_dying_sleeping_thread.send(@method).should include('sleep') + ThreadSpecs.status_of_dying_sleeping_thread.send(@method).should.include?('sleep') end it "reports aborting on a killed thread" do - ThreadSpecs.status_of_dying_running_thread.send(@method).should include('aborting') + ThreadSpecs.status_of_dying_running_thread.send(@method).should.include?('aborting') end it "reports aborting on a killed thread after sleep" do - ThreadSpecs.status_of_dying_thread_after_sleep.send(@method).should include('aborting') + ThreadSpecs.status_of_dying_thread_after_sleep.send(@method).should.include?('aborting') end end diff --git a/spec/ruby/core/thread/shared/wakeup.rb b/spec/ruby/core/thread/shared/wakeup.rb index 6f010fea254687..c89235ba600618 100644 --- a/spec/ruby/core/thread/shared/wakeup.rb +++ b/spec/ruby/core/thread/shared/wakeup.rb @@ -57,6 +57,6 @@ it "raises a ThreadError when trying to wake up a dead thread" do t = Thread.new { 1 } t.join - -> { t.send @method }.should raise_error(ThreadError) + -> { t.send @method }.should.raise(ThreadError) end end diff --git a/spec/ruby/core/thread/thread_variable_get_spec.rb b/spec/ruby/core/thread/thread_variable_get_spec.rb index 1ea34cf2b31917..3d92cd54797814 100644 --- a/spec/ruby/core/thread/thread_variable_get_spec.rb +++ b/spec/ruby/core/thread/thread_variable_get_spec.rb @@ -10,7 +10,7 @@ end it "returns nil if the variable is not set" do - @t.thread_variable_get(:a).should be_nil + @t.thread_variable_get(:a).should == nil end it "returns the value previously set by #thread_variable_set" do @@ -20,7 +20,7 @@ it "returns a value private to self" do @t.thread_variable_set(:thread_variable_get_spec, 82) - Thread.current.thread_variable_get(:thread_variable_get_spec).should be_nil + Thread.current.thread_variable_get(:thread_variable_get_spec).should == nil end it "accepts String and Symbol keys interchangeably" do @@ -38,23 +38,23 @@ it "does not raise FrozenError if the thread is frozen" do @t.freeze - @t.thread_variable_get(:a).should be_nil + @t.thread_variable_get(:a).should == nil end it "raises a TypeError if the key is neither Symbol nor String when thread variables are already set" do @t.thread_variable_set(:a, 49) - -> { @t.thread_variable_get(123) }.should raise_error(TypeError, /123 is not a symbol/) + -> { @t.thread_variable_get(123) }.should.raise(TypeError, /123 is not a symbol/) end ruby_version_is '3.4' do it "raises a TypeError if the key is neither Symbol nor String when no thread variables are set" do - -> { @t.thread_variable_get(123) }.should raise_error(TypeError, /123 is not a symbol/) + -> { @t.thread_variable_get(123) }.should.raise(TypeError, /123 is not a symbol/) end it "raises a TypeError if the key is neither Symbol nor String without calling #to_sym" do key = mock('key') key.should_not_receive(:to_sym) - -> { @t.thread_variable_get(key) }.should raise_error(TypeError, /#{Regexp.escape(key.inspect)} is not a symbol/) + -> { @t.thread_variable_get(key) }.should.raise(TypeError, /#{Regexp.escape(key.inspect)} is not a symbol/) end end end diff --git a/spec/ruby/core/thread/thread_variable_set_spec.rb b/spec/ruby/core/thread/thread_variable_set_spec.rb index eadee76afba00d..f8d25364ae9156 100644 --- a/spec/ruby/core/thread/thread_variable_set_spec.rb +++ b/spec/ruby/core/thread/thread_variable_set_spec.rb @@ -21,7 +21,7 @@ it "sets a value private to self" do @t.thread_variable_set(:thread_variable_get_spec, 82) @t.thread_variable_get(:thread_variable_get_spec).should == 82 - Thread.current.thread_variable_get(:thread_variable_get_spec).should be_nil + Thread.current.thread_variable_get(:thread_variable_get_spec).should == nil end it "accepts String and Symbol keys interchangeably" do @@ -42,21 +42,21 @@ it "removes a key if the value is nil" do @t.thread_variable_set(:a, 52) @t.thread_variable_set(:a, nil) - @t.thread_variable?(:a).should be_false + @t.thread_variable?(:a).should == false end it "raises a FrozenError if the thread is frozen" do @t.freeze - -> { @t.thread_variable_set(:a, 1) }.should raise_error(FrozenError, "can't modify frozen thread locals") + -> { @t.thread_variable_set(:a, 1) }.should.raise(FrozenError, "can't modify frozen thread locals") end it "raises a TypeError if the key is neither Symbol nor String, nor responds to #to_str" do - -> { @t.thread_variable_set(123, 1) }.should raise_error(TypeError, /123 is not a symbol/) + -> { @t.thread_variable_set(123, 1) }.should.raise(TypeError, /123 is not a symbol/) end it "does not try to convert the key with #to_sym" do key = mock('key') key.should_not_receive(:to_sym) - -> { @t.thread_variable_set(key, 42) }.should raise_error(TypeError, /#{Regexp.quote(key.inspect)} is not a symbol/) + -> { @t.thread_variable_set(key, 42) }.should.raise(TypeError, /#{Regexp.quote(key.inspect)} is not a symbol/) end end diff --git a/spec/ruby/core/thread/thread_variable_spec.rb b/spec/ruby/core/thread/thread_variable_spec.rb index 1b021e94044d52..ebafd4f3ebbf29 100644 --- a/spec/ruby/core/thread/thread_variable_spec.rb +++ b/spec/ruby/core/thread/thread_variable_spec.rb @@ -11,50 +11,50 @@ it "returns false if the thread variables do not contain 'key'" do @t.thread_variable_set(:a, 2) - @t.thread_variable?(:b).should be_false + @t.thread_variable?(:b).should == false end it "returns true if the thread variables contain 'key'" do @t.thread_variable_set(:a, 2) - @t.thread_variable?(:a).should be_true + @t.thread_variable?(:a).should == true end it "accepts String and Symbol keys interchangeably" do - @t.thread_variable?('a').should be_false - @t.thread_variable?(:a).should be_false + @t.thread_variable?('a').should == false + @t.thread_variable?(:a).should == false @t.thread_variable_set(:a, 49) - @t.thread_variable?('a').should be_true - @t.thread_variable?(:a).should be_true + @t.thread_variable?('a').should == true + @t.thread_variable?(:a).should == true end it "converts a key that is neither String nor Symbol with #to_str" do key = mock('key') key.should_receive(:to_str).and_return('a') @t.thread_variable_set(:a, 49) - @t.thread_variable?(key).should be_true + @t.thread_variable?(key).should == true end it "does not raise FrozenError if the thread is frozen" do @t.freeze - @t.thread_variable?(:a).should be_false + @t.thread_variable?(:a).should == false end it "raises a TypeError if the key is neither Symbol nor String when thread variables are already set" do @t.thread_variable_set(:a, 49) - -> { @t.thread_variable?(123) }.should raise_error(TypeError, /123 is not a symbol/) + -> { @t.thread_variable?(123) }.should.raise(TypeError, /123 is not a symbol/) end ruby_version_is '3.4' do it "raises a TypeError if the key is neither Symbol nor String when no thread variables are set" do - -> { @t.thread_variable?(123) }.should raise_error(TypeError, /123 is not a symbol/) + -> { @t.thread_variable?(123) }.should.raise(TypeError, /123 is not a symbol/) end it "raises a TypeError if the key is neither Symbol nor String without calling #to_sym" do key = mock('key') key.should_not_receive(:to_sym) - -> { @t.thread_variable?(key) }.should raise_error(TypeError, /#{Regexp.escape(key.inspect)} is not a symbol/) + -> { @t.thread_variable?(key) }.should.raise(TypeError, /#{Regexp.escape(key.inspect)} is not a symbol/) end end end diff --git a/spec/ruby/core/thread/thread_variables_spec.rb b/spec/ruby/core/thread/thread_variables_spec.rb index 51ceef3376ecbd..f15c681a8fcbfa 100644 --- a/spec/ruby/core/thread/thread_variables_spec.rb +++ b/spec/ruby/core/thread/thread_variables_spec.rb @@ -19,7 +19,8 @@ it "returns the keys private to self" do @t.thread_variable_set(:a, 82) @t.thread_variable_set(:b, 82) - Thread.current.thread_variables.should_not include(:a, :b) + Thread.current.thread_variables.should_not.include?(:a) + Thread.current.thread_variables.should_not.include?(:b) end it "only contains user thread variables and is empty initially" do diff --git a/spec/ruby/core/thread/value_spec.rb b/spec/ruby/core/thread/value_spec.rb index 30e43abd1a8d89..50c823171d1d2a 100644 --- a/spec/ruby/core/thread/value_spec.rb +++ b/spec/ruby/core/thread/value_spec.rb @@ -11,7 +11,7 @@ Thread.current.report_on_exception = false raise "Hello" } - -> { t.value }.should raise_error(RuntimeError, "Hello") + -> { t.value }.should.raise(RuntimeError, "Hello") end it "is nil for a killed thread" do diff --git a/spec/ruby/core/threadgroup/default_spec.rb b/spec/ruby/core/threadgroup/default_spec.rb index d7d4726cc2b420..4f57508abfa219 100644 --- a/spec/ruby/core/threadgroup/default_spec.rb +++ b/spec/ruby/core/threadgroup/default_spec.rb @@ -2,7 +2,7 @@ describe "ThreadGroup::Default" do it "is a ThreadGroup instance" do - ThreadGroup::Default.should be_kind_of(ThreadGroup) + ThreadGroup::Default.should.is_a?(ThreadGroup) end it "is the ThreadGroup of the main thread" do diff --git a/spec/ruby/core/threadgroup/enclose_spec.rb b/spec/ruby/core/threadgroup/enclose_spec.rb index dd9a7a362da54c..6f703d4ce29c87 100644 --- a/spec/ruby/core/threadgroup/enclose_spec.rb +++ b/spec/ruby/core/threadgroup/enclose_spec.rb @@ -19,6 +19,6 @@ thread_group.enclose -> do default_group.add(@thread) - end.should raise_error(ThreadError) + end.should.raise(ThreadError) end end diff --git a/spec/ruby/core/threadgroup/enclosed_spec.rb b/spec/ruby/core/threadgroup/enclosed_spec.rb index a734256a649755..cf8a5bb4c63e5f 100644 --- a/spec/ruby/core/threadgroup/enclosed_spec.rb +++ b/spec/ruby/core/threadgroup/enclosed_spec.rb @@ -3,12 +3,12 @@ describe "ThreadGroup#enclosed?" do it "returns false when a ThreadGroup has not been enclosed (default state)" do thread_group = ThreadGroup.new - thread_group.enclosed?.should be_false + thread_group.enclosed?.should == false end it "returns true when a ThreadGroup is enclosed" do thread_group = ThreadGroup.new thread_group.enclose - thread_group.enclosed?.should be_true + thread_group.enclosed?.should == true end end diff --git a/spec/ruby/core/threadgroup/list_spec.rb b/spec/ruby/core/threadgroup/list_spec.rb index b2ac64324abf0d..ef601d75eabb49 100644 --- a/spec/ruby/core/threadgroup/list_spec.rb +++ b/spec/ruby/core/threadgroup/list_spec.rb @@ -7,13 +7,13 @@ q.pop.should == :go tg = ThreadGroup.new tg.add(th1) - tg.list.should include(th1) + tg.list.should.include?(th1) th2 = Thread.new { q << :go; sleep } q.pop.should == :go tg.add(th2) - (tg.list & [th1, th2]).should include(th1, th2) + (tg.list & [th1, th2]).to_set.should == Set[th1, th2] Thread.pass while th1.status and th1.status != 'sleep' Thread.pass while th2.status and th2.status != 'sleep' diff --git a/spec/ruby/core/time/_dump_spec.rb b/spec/ruby/core/time/_dump_spec.rb index 852f9a07abfddd..21f08063270b1f 100644 --- a/spec/ruby/core/time/_dump_spec.rb +++ b/spec/ruby/core/time/_dump_spec.rb @@ -10,7 +10,7 @@ end it "is a private method" do - Time.should have_private_instance_method(:_dump, false) + Time.private_instance_methods(false).should.include?(:_dump) end # http://redmine.ruby-lang.org/issues/show/627 @@ -25,7 +25,7 @@ end it "dumps a Time object to a bytestring" do - @s.should be_an_instance_of(String) + @s.should.instance_of?(String) @s.should == [3222863947, 2235564032].pack("VV") end diff --git a/spec/ruby/core/time/_load_spec.rb b/spec/ruby/core/time/_load_spec.rb index 30899de262573d..a74e3dc1292379 100644 --- a/spec/ruby/core/time/_load_spec.rb +++ b/spec/ruby/core/time/_load_spec.rb @@ -3,7 +3,7 @@ describe "Time._load" do it "is a private method" do - Time.should have_private_method(:_load, false) + Time.private_methods(false).should.include?(:_load) end # http://redmine.ruby-lang.org/issues/show/627 diff --git a/spec/ruby/core/time/at_spec.rb b/spec/ruby/core/time/at_spec.rb index 97906b8c8c2a7e..10d4d36a68f603 100644 --- a/spec/ruby/core/time/at_spec.rb +++ b/spec/ruby/core/time/at_spec.rb @@ -20,7 +20,7 @@ it "returns a subclass instance on a Time subclass" do c = Class.new(Time) t = c.at(0) - t.should be_an_instance_of(c) + t.should.instance_of?(c) end it "roundtrips a Rational produced by #to_r" do @@ -56,7 +56,7 @@ it "creates a dup time object with the value given by time" do t1 = Time.new t2 = Time.at(t1) - t1.should_not equal t2 + t1.should_not.equal? t2 end it "returns a UTC time if the argument is UTC" do @@ -72,17 +72,17 @@ it "returns a subclass instance" do c = Class.new(Time) t = c.at(Time.now) - t.should be_an_instance_of(c) + t.should.instance_of?(c) end end describe "passed non-Time, non-Numeric" do it "raises a TypeError with a String argument" do - -> { Time.at("0") }.should raise_error(TypeError) + -> { Time.at("0") }.should.raise(TypeError) end it "raises a TypeError with a nil argument" do - -> { Time.at(nil) }.should raise_error(TypeError) + -> { Time.at(nil) }.should.raise(TypeError) end describe "with an argument that responds to #to_int" do @@ -103,7 +103,7 @@ it "needs for the argument to respond to #to_int too" do o = mock('rational-but-no-to_int') def o.to_r; Rational(5, 2) end - -> { Time.at(o) }.should raise_error(TypeError, "can't convert MockObject into an exact number") + -> { Time.at(o) }.should.raise(TypeError, "can't convert MockObject into an exact number") end end end @@ -140,20 +140,20 @@ def o.to_r; Rational(5, 2) end describe "passed [Integer, nil]" do it "raises a TypeError" do - -> { Time.at(0, nil) }.should raise_error(TypeError) + -> { Time.at(0, nil) }.should.raise(TypeError) end end describe "passed [Integer, String]" do it "raises a TypeError" do - -> { Time.at(0, "0") }.should raise_error(TypeError) + -> { Time.at(0, "0") }.should.raise(TypeError) end end describe "passed [Time, Integer]" do # #8173 it "raises a TypeError" do - -> { Time.at(Time.now, 500000) }.should raise_error(TypeError) + -> { Time.at(Time.now, 500000) }.should.raise(TypeError) end end @@ -190,15 +190,15 @@ def o.to_r; Rational(5, 2) end context "not supported format" do it "raises ArgumentError" do - -> { Time.at(0, 123456, 2) }.should raise_error(ArgumentError) - -> { Time.at(0, 123456, nil) }.should raise_error(ArgumentError) - -> { Time.at(0, 123456, :invalid) }.should raise_error(ArgumentError) + -> { Time.at(0, 123456, 2) }.should.raise(ArgumentError) + -> { Time.at(0, 123456, nil) }.should.raise(ArgumentError) + -> { Time.at(0, 123456, :invalid) }.should.raise(ArgumentError) end it "does not try to convert format to Symbol with #to_sym" do format = +"usec" format.should_not_receive(:to_sym) - -> { Time.at(0, 123456, format) }.should raise_error(ArgumentError) + -> { Time.at(0, 123456, format) }.should.raise(ArgumentError) end end @@ -283,33 +283,33 @@ def o.to_r; Rational(5, 2) end end it "raises ArgumentError if format is invalid" do - -> { Time.at(@epoch_time, in: "+09:99") }.should raise_error(ArgumentError) - -> { Time.at(@epoch_time, in: "ABC") }.should raise_error(ArgumentError) + -> { Time.at(@epoch_time, in: "+09:99") }.should.raise(ArgumentError) + -> { Time.at(@epoch_time, in: "ABC") }.should.raise(ArgumentError) end it "raises ArgumentError if hours greater than 23" do # TODO - -> { Time.at(@epoch_time, in: "+24:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.at(@epoch_time, in: "+2400") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.at(@epoch_time, in: "+24:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.at(@epoch_time, in: "+2400") }.should.raise(ArgumentError, "utc_offset out of range") - -> { Time.at(@epoch_time, in: "+99:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.at(@epoch_time, in: "+9900") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.at(@epoch_time, in: "+99:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.at(@epoch_time, in: "+9900") }.should.raise(ArgumentError, "utc_offset out of range") end it "raises ArgumentError if minutes greater than 59" do # TODO - -> { Time.at(@epoch_time, in: "+00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') - -> { Time.at(@epoch_time, in: "+0060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') + -> { Time.at(@epoch_time, in: "+00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') + -> { Time.at(@epoch_time, in: "+0060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') - -> { Time.at(@epoch_time, in: "+00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') - -> { Time.at(@epoch_time, in: "+0099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') + -> { Time.at(@epoch_time, in: "+00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') + -> { Time.at(@epoch_time, in: "+0099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') end ruby_bug '#20797', ''...'3.4' do it "raises ArgumentError if seconds greater than 59" do - -> { Time.at(@epoch_time, in: "+00:00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') - -> { Time.at(@epoch_time, in: "+000060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') + -> { Time.at(@epoch_time, in: "+00:00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') + -> { Time.at(@epoch_time, in: "+000060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') - -> { Time.at(@epoch_time, in: "+00:00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') - -> { Time.at(@epoch_time, in: "+000099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') + -> { Time.at(@epoch_time, in: "+00:00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') + -> { Time.at(@epoch_time, in: "+000099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') end end end diff --git a/spec/ruby/core/time/ceil_spec.rb b/spec/ruby/core/time/ceil_spec.rb index 9d624a1ed09346..18e26f999457e9 100644 --- a/spec/ruby/core/time/ceil_spec.rb +++ b/spec/ruby/core/time/ceil_spec.rb @@ -28,8 +28,8 @@ it "returns an instance of Time, even if #ceil is called on a subclass" do subclass = Class.new(Time) instance = subclass.at(0) - instance.class.should equal subclass - instance.ceil.should be_an_instance_of(Time) + instance.class.should.equal? subclass + instance.ceil.should.instance_of?(Time) end it "copies own timezone to the returning value" do diff --git a/spec/ruby/core/time/comparison_spec.rb b/spec/ruby/core/time/comparison_spec.rb index 866fbea72ef106..0790088f9eb1cf 100644 --- a/spec/ruby/core/time/comparison_spec.rb +++ b/spec/ruby/core/time/comparison_spec.rb @@ -124,7 +124,7 @@ def r.<=>(other); other <=> self; end r.should_receive(:<=>).once - (t <=> r).should be_nil + (t <=> r).should == nil end end end diff --git a/spec/ruby/core/time/deconstruct_keys_spec.rb b/spec/ruby/core/time/deconstruct_keys_spec.rb index b5cfdaa93f881e..9918728c1d9410 100644 --- a/spec/ruby/core/time/deconstruct_keys_spec.rb +++ b/spec/ruby/core/time/deconstruct_keys_spec.rb @@ -16,16 +16,16 @@ it "requires one argument" do -> { Time.new(2022, 10, 5, 13, 30).deconstruct_keys - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "it raises error when argument is neither nil nor array" do d = Time.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)") + -> { d.deconstruct_keys(1) }.should.raise(TypeError, "wrong argument type Integer (expected Array or nil)") + -> { d.deconstruct_keys("asd") }.should.raise(TypeError, "wrong argument type String (expected Array or nil)") + -> { d.deconstruct_keys(:x) }.should.raise(TypeError, "wrong argument type Symbol (expected Array or nil)") + -> { d.deconstruct_keys({}) }.should.raise(TypeError, "wrong argument type Hash (expected Array or nil)") end it "returns {} when passed []" do diff --git a/spec/ruby/core/time/dup_spec.rb b/spec/ruby/core/time/dup_spec.rb index 5d6621beaa84f7..33aa1304ef9b16 100644 --- a/spec/ruby/core/time/dup_spec.rb +++ b/spec/ruby/core/time/dup_spec.rb @@ -22,25 +22,25 @@ c = Class.new(Time) t = c.now - t.should be_an_instance_of(c) - t.dup.should be_an_instance_of(c) + t.should.instance_of?(c) + t.dup.should.instance_of?(c) end it "returns a clone of Time instance" do c = Time.dup t = c.now - t.should be_an_instance_of(c) - t.should_not be_an_instance_of(Time) + t.should.instance_of?(c) + t.should_not.instance_of?(Time) - t.dup.should be_an_instance_of(c) - t.dup.should_not be_an_instance_of(Time) + t.dup.should.instance_of?(c) + t.dup.should_not.instance_of?(Time) end it "does not copy frozen status from the original" do t = Time.now t.freeze t2 = t.dup - t2.frozen?.should be_false + t2.frozen?.should == false end end diff --git a/spec/ruby/core/time/eql_spec.rb b/spec/ruby/core/time/eql_spec.rb index 2ffb4eec962608..b7505969ddfb1f 100644 --- a/spec/ruby/core/time/eql_spec.rb +++ b/spec/ruby/core/time/eql_spec.rb @@ -2,28 +2,28 @@ describe "Time#eql?" do it "returns true if self and other have the same whole number of seconds" do - Time.at(100).should eql(Time.at(100)) + Time.at(100).should.eql?(Time.at(100)) end it "returns false if self and other have differing whole numbers of seconds" do - Time.at(100).should_not eql(Time.at(99)) + Time.at(100).should_not.eql?(Time.at(99)) end it "returns true if self and other have the same number of microseconds" do - Time.at(100, 100).should eql(Time.at(100, 100)) + Time.at(100, 100).should.eql?(Time.at(100, 100)) end it "returns false if self and other have differing numbers of microseconds" do - Time.at(100, 100).should_not eql(Time.at(100, 99)) + Time.at(100, 100).should_not.eql?(Time.at(100, 99)) end it "returns false if self and other have differing fractional microseconds" do - Time.at(100, Rational(100,1000)).should_not eql(Time.at(100, Rational(99,1000))) + Time.at(100, Rational(100,1000)).should_not.eql?(Time.at(100, Rational(99,1000))) end it "returns false when given a non-time value" do - Time.at(100, 100).should_not eql("100") - Time.at(100, 100).should_not eql(100) - Time.at(100, 100).should_not eql(100.1) + Time.at(100, 100).should_not.eql?("100") + Time.at(100, 100).should_not.eql?(100) + Time.at(100, 100).should_not.eql?(100.1) end end diff --git a/spec/ruby/core/time/floor_spec.rb b/spec/ruby/core/time/floor_spec.rb index b0003469c956c5..41e5142b19a895 100644 --- a/spec/ruby/core/time/floor_spec.rb +++ b/spec/ruby/core/time/floor_spec.rb @@ -20,8 +20,8 @@ it "returns an instance of Time, even if #floor is called on a subclass" do subclass = Class.new(Time) instance = subclass.at(0) - instance.class.should equal subclass - instance.floor.should be_an_instance_of(Time) + instance.class.should.equal? subclass + instance.floor.should.instance_of?(Time) end it "copies own timezone to the returning value" do diff --git a/spec/ruby/core/time/getlocal_spec.rb b/spec/ruby/core/time/getlocal_spec.rb index 398596f400494e..7e5334c3033c9d 100644 --- a/spec/ruby/core/time/getlocal_spec.rb +++ b/spec/ruby/core/time/getlocal_spec.rb @@ -14,7 +14,7 @@ t = Time.gm(2007, 1, 9, 12, 0, 0).getlocal(3630) t.should == Time.new(2007, 1, 9, 13, 0, 30, 3630) t.utc_offset.should == 3630 - t.zone.should be_nil + t.zone.should == nil end platform_is_not :windows do @@ -41,7 +41,7 @@ it "returns a Time with a UTC offset of the specified number of Rational seconds" do t = Time.gm(2007, 1, 9, 12, 0, 0).getlocal(Rational(7201, 2)) t.should == Time.new(2007, 1, 9, 13, 0, Rational(1, 2), Rational(7201, 2)) - t.utc_offset.should eql(Rational(7201, 2)) + t.utc_offset.should.eql?(Rational(7201, 2)) end describe "with an argument that responds to #to_r" do @@ -50,7 +50,7 @@ o.should_receive(:to_r).and_return(Rational(7201, 2)) t = Time.gm(2007, 1, 9, 12, 0, 0).getlocal(o) t.should == Time.new(2007, 1, 9, 13, 0, Rational(1, 2), Rational(7201, 2)) - t.utc_offset.should eql(Rational(7201, 2)) + t.utc_offset.should.eql?(Rational(7201, 2)) end end @@ -90,49 +90,49 @@ it "raises ArgumentError if the String argument is not of the form (+|-)HH:MM" do t = Time.now - -> { t.getlocal("3600") }.should raise_error(ArgumentError) + -> { t.getlocal("3600") }.should.raise(ArgumentError) end it "raises ArgumentError if the String argument is not in an ASCII-compatible encoding" do t = Time.now - -> { t.getlocal("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError) + -> { t.getlocal("-01:00".encode("UTF-16LE")) }.should.raise(ArgumentError) end it "raises ArgumentError if the argument represents a value less than or equal to -86400 seconds" do t = Time.new t.getlocal(-86400 + 1).utc_offset.should == (-86400 + 1) - -> { t.getlocal(-86400) }.should raise_error(ArgumentError) + -> { t.getlocal(-86400) }.should.raise(ArgumentError) end it "raises ArgumentError if the argument represents a value greater than or equal to 86400 seconds" do t = Time.new t.getlocal(86400 - 1).utc_offset.should == (86400 - 1) - -> { t.getlocal(86400) }.should raise_error(ArgumentError) + -> { t.getlocal(86400) }.should.raise(ArgumentError) end it "raises ArgumentError if String argument and hours greater than 23" do - -> { Time.now.getlocal("+24:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.now.getlocal("+2400") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.now.getlocal("+24:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.now.getlocal("+2400") }.should.raise(ArgumentError, "utc_offset out of range") - -> { Time.now.getlocal("+99:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.now.getlocal("+9900") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.now.getlocal("+99:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.now.getlocal("+9900") }.should.raise(ArgumentError, "utc_offset out of range") end it "raises ArgumentError if String argument and minutes greater than 59" do - -> { Time.now.getlocal("+00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') - -> { Time.now.getlocal("+0060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') + -> { Time.now.getlocal("+00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') + -> { Time.now.getlocal("+0060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') - -> { Time.now.getlocal("+00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') - -> { Time.now.getlocal("+0099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') + -> { Time.now.getlocal("+00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') + -> { Time.now.getlocal("+0099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') end ruby_bug '#20797', ''...'3.4' do it "raises ArgumentError if String argument and seconds greater than 59" do - -> { Time.now.getlocal("+00:00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') - -> { Time.now.getlocal("+000060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') + -> { Time.now.getlocal("+00:00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') + -> { Time.now.getlocal("+000060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') - -> { Time.now.getlocal("+00:00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') - -> { Time.now.getlocal("+000099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') + -> { Time.now.getlocal("+00:00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') + -> { Time.now.getlocal("+000099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') end end @@ -155,8 +155,8 @@ def zone.local_to_utc(time) end -> { - Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should be_kind_of(Time) - }.should_not raise_error + Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should.is_a?(Time) + }.should_not.raise end it "raises TypeError if timezone does not implement #utc_to_local method" do @@ -167,7 +167,7 @@ def zone.local_to_utc(time) -> { Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone) - }.should raise_error(TypeError, /can't convert \w+ into an exact number/) + }.should.raise(TypeError, /can't convert \w+ into an exact number/) end it "does not raise exception if timezone does not implement #local_to_utc method" do @@ -177,18 +177,18 @@ def zone.utc_to_local(time) end -> { - Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should be_kind_of(Time) - }.should_not raise_error + Time.utc(2000, 1, 1, 12, 0, 0).getlocal(zone).should.is_a?(Time) + }.should_not.raise end context "subject's class implements .find_timezone method" do it "calls .find_timezone to build a time object if passed zone name as a timezone argument" do time = TimeSpecs::TimeWithFindTimezone.utc(2000, 1, 1, 12, 0, 0).getlocal("Asia/Colombo") - time.zone.should be_kind_of TimeSpecs::TimezoneWithName + time.zone.should.is_a? TimeSpecs::TimezoneWithName time.zone.name.should == "Asia/Colombo" time = TimeSpecs::TimeWithFindTimezone.utc(2000, 1, 1, 12, 0, 0).getlocal("some invalid zone name") - time.zone.should be_kind_of TimeSpecs::TimezoneWithName + time.zone.should.is_a? TimeSpecs::TimezoneWithName time.zone.name.should == "some invalid zone name" end @@ -198,7 +198,7 @@ def zone.utc_to_local(time) -> { time.getlocal(zone) - }.should raise_error(TypeError, /can't convert \w+ into an exact number/) + }.should.raise(TypeError, /can't convert \w+ into an exact number/) end end end diff --git a/spec/ruby/core/time/hash_spec.rb b/spec/ruby/core/time/hash_spec.rb index 4f4d11a2cd8aba..1cfc56eab06158 100644 --- a/spec/ruby/core/time/hash_spec.rb +++ b/spec/ruby/core/time/hash_spec.rb @@ -2,7 +2,7 @@ describe "Time#hash" do it "returns an Integer" do - Time.at(100).hash.should be_an_instance_of(Integer) + Time.at(100).hash.should.instance_of?(Integer) end it "is stable" do diff --git a/spec/ruby/core/time/localtime_spec.rb b/spec/ruby/core/time/localtime_spec.rb index 71c0dfebde7bad..1c0b11b7a62ef7 100644 --- a/spec/ruby/core/time/localtime_spec.rb +++ b/spec/ruby/core/time/localtime_spec.rb @@ -12,7 +12,7 @@ it "returns self" do t = Time.gm(2007, 1, 9, 12, 0, 0) - t.localtime.should equal(t) + t.localtime.should.equal?(t) end it "converts time to the UTC offset specified as an Integer number of seconds" do @@ -26,13 +26,13 @@ it "does not raise an error if already in the right time zone" do time = Time.now time.freeze - time.localtime.should equal(time) + time.localtime.should.equal?(time) end it "raises a FrozenError if the time has a different time zone" do time = Time.gm(2007, 1, 9, 12, 0, 0) time.freeze - -> { time.localtime }.should raise_error(FrozenError) + -> { time.localtime }.should.raise(FrozenError) end end @@ -51,7 +51,7 @@ t = Time.gm(2007, 1, 9, 12, 0, 0) t.localtime(Rational(7201, 2)) t.should == Time.new(2007, 1, 9, 13, 0, Rational(1, 2), Rational(7201, 2)) - t.utc_offset.should eql(Rational(7201, 2)) + t.utc_offset.should.eql?(Rational(7201, 2)) end describe "with an argument that responds to #to_r" do @@ -61,7 +61,7 @@ t = Time.gm(2007, 1, 9, 12, 0, 0) t.localtime(o) t.should == Time.new(2007, 1, 9, 13, 0, Rational(1, 2), Rational(7201, 2)) - t.utc_offset.should eql(Rational(7201, 2)) + t.utc_offset.should.eql?(Rational(7201, 2)) end end @@ -106,28 +106,28 @@ end it "raises ArgumentError if String argument and hours greater than 23" do - -> { Time.now.localtime("+24:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.now.localtime("+2400") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.now.localtime("+24:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.now.localtime("+2400") }.should.raise(ArgumentError, "utc_offset out of range") - -> { Time.now.localtime("+99:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.now.localtime("+9900") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.now.localtime("+99:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.now.localtime("+9900") }.should.raise(ArgumentError, "utc_offset out of range") end it "raises ArgumentError if String argument and minutes greater than 59" do - -> { Time.now.localtime("+00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') - -> { Time.now.localtime("+0060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') + -> { Time.now.localtime("+00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') + -> { Time.now.localtime("+0060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') - -> { Time.now.localtime("+00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') - -> { Time.now.localtime("+0099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') + -> { Time.now.localtime("+00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') + -> { Time.now.localtime("+0099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') end ruby_bug '#20797', ''...'3.4' do it "raises ArgumentError if String argument and seconds greater than 59" do - -> { Time.now.localtime("+00:00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') - -> { Time.now.localtime("+000060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') + -> { Time.now.localtime("+00:00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') + -> { Time.now.localtime("+000060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') - -> { Time.now.localtime("+00:00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') - -> { Time.now.localtime("+000099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') + -> { Time.now.localtime("+00:00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') + -> { Time.now.localtime("+000099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') end end @@ -181,23 +181,23 @@ it "raises ArgumentError if the String argument is not of the form (+|-)HH:MM" do t = Time.now - -> { t.localtime("3600") }.should raise_error(ArgumentError) + -> { t.localtime("3600") }.should.raise(ArgumentError) end it "raises ArgumentError if the String argument is not in an ASCII-compatible encoding" do t = Time.now - -> { t.localtime("-01:00".encode("UTF-16LE")) }.should raise_error(ArgumentError) + -> { t.localtime("-01:00".encode("UTF-16LE")) }.should.raise(ArgumentError) end it "raises ArgumentError if the argument represents a value less than or equal to -86400 seconds" do t = Time.new t.localtime(-86400 + 1).utc_offset.should == (-86400 + 1) - -> { t.localtime(-86400) }.should raise_error(ArgumentError) + -> { t.localtime(-86400) }.should.raise(ArgumentError) end it "raises ArgumentError if the argument represents a value greater than or equal to 86400 seconds" do t = Time.new t.localtime(86400 - 1).utc_offset.should == (86400 - 1) - -> { t.localtime(86400) }.should raise_error(ArgumentError) + -> { t.localtime(86400) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/time/minus_spec.rb b/spec/ruby/core/time/minus_spec.rb index 9182d9965297f0..ee3d8acda8f516 100644 --- a/spec/ruby/core/time/minus_spec.rb +++ b/spec/ruby/core/time/minus_spec.rb @@ -20,18 +20,18 @@ end it "raises a TypeError if given argument is a coercible String" do - -> { Time.now - "1" }.should raise_error(TypeError) - -> { Time.now - "0.1" }.should raise_error(TypeError) - -> { Time.now - "1/3" }.should raise_error(TypeError) + -> { Time.now - "1" }.should.raise(TypeError) + -> { Time.now - "0.1" }.should.raise(TypeError) + -> { Time.now - "1/3" }.should.raise(TypeError) end it "raises TypeError on argument that can't be coerced" do - -> { Time.now - Object.new }.should raise_error(TypeError) - -> { Time.now - "stuff" }.should raise_error(TypeError) + -> { Time.now - Object.new }.should.raise(TypeError) + -> { Time.now - "stuff" }.should.raise(TypeError) end it "raises TypeError on nil argument" do - -> { Time.now - nil }.should raise_error(TypeError) + -> { Time.now - nil }.should.raise(TypeError) end it "tracks microseconds" do @@ -110,7 +110,7 @@ it "does not return a subclass instance" do c = Class.new(Time) x = c.now - 1 - x.should be_an_instance_of(Time) + x.should.instance_of?(Time) end it "returns a time with nanoseconds precision between two time objects" do diff --git a/spec/ruby/core/time/new_spec.rb b/spec/ruby/core/time/new_spec.rb index e4e54e16a39fe7..91ce4b2e3a75f1 100644 --- a/spec/ruby/core/time/new_spec.rb +++ b/spec/ruby/core/time/new_spec.rb @@ -31,14 +31,14 @@ end it "returns a Time with a UTC offset of the specified number of Rational seconds" do - Time.new(2000, 1, 1, 0, 0, 0, Rational(5, 2)).utc_offset.should eql(Rational(5, 2)) + Time.new(2000, 1, 1, 0, 0, 0, Rational(5, 2)).utc_offset.should.eql?(Rational(5, 2)) end describe "with an argument that responds to #to_r" do it "coerces using #to_r" do o = mock_numeric('rational') o.should_receive(:to_r).and_return(Rational(5, 2)) - Time.new(2000, 1, 1, 0, 0, 0, o).utc_offset.should eql(Rational(5, 2)) + Time.new(2000, 1, 1, 0, 0, 0, o).utc_offset.should.eql?(Rational(5, 2)) end end @@ -129,7 +129,7 @@ it "raises ArgumentError if the string argument is J" do message = '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: J' - -> { Time.new(2000, 1, 1, 0, 0, 0, "J") }.should raise_error(ArgumentError, message) + -> { Time.new(2000, 1, 1, 0, 0, 0, "J") }.should.raise(ArgumentError, message) end it "returns a local Time if the argument is nil" do @@ -144,18 +144,18 @@ it "disallows a value for minutes greater than 59" do -> { Time.new(2000, 1, 1, 0, 0, 0, "+01:60") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { Time.new(2000, 1, 1, 0, 0, 0, "+01:99") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises ArgumentError if the String argument is not of the form (+|-)HH:MM" do - -> { Time.new(2000, 1, 1, 0, 0, 0, "3600") }.should raise_error(ArgumentError) + -> { Time.new(2000, 1, 1, 0, 0, 0, "3600") }.should.raise(ArgumentError) end it "raises ArgumentError if the hour value is greater than 23" do - -> { Time.new(2000, 1, 1, 0, 0, 0, "+24:00") }.should raise_error(ArgumentError) + -> { Time.new(2000, 1, 1, 0, 0, 0, "+24:00") }.should.raise(ArgumentError) end it "raises ArgumentError if the String argument is not in an ASCII-compatible encoding" do @@ -164,21 +164,21 @@ # - '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset' -> { Time.new(2000, 1, 1, 0, 0, 0, "-04:10".encode("UTF-16LE")) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises ArgumentError if the argument represents a value less than or equal to -86400 seconds" do Time.new(2000, 1, 1, 0, 0, 0, -86400 + 1).utc_offset.should == (-86400 + 1) - -> { Time.new(2000, 1, 1, 0, 0, 0, -86400) }.should raise_error(ArgumentError) + -> { Time.new(2000, 1, 1, 0, 0, 0, -86400) }.should.raise(ArgumentError) end it "raises ArgumentError if the argument represents a value greater than or equal to 86400 seconds" do Time.new(2000, 1, 1, 0, 0, 0, 86400 - 1).utc_offset.should == (86400 - 1) - -> { Time.new(2000, 1, 1, 0, 0, 0, 86400) }.should raise_error(ArgumentError) + -> { Time.new(2000, 1, 1, 0, 0, 0, 86400) }.should.raise(ArgumentError) end it "raises ArgumentError if the utc_offset argument is greater than or equal to 10e9" do - -> { Time.new(2000, 1, 1, 0, 0, 0, 1000000000) }.should raise_error(ArgumentError) + -> { Time.new(2000, 1, 1, 0, 0, 0, 1000000000) }.should.raise(ArgumentError) end end @@ -203,7 +203,7 @@ def zone.local_to_utc(time) time end - Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time) + Time.new(2000, 1, 1, 12, 0, 0, zone).should.is_a?(Time) end it "raises TypeError if timezone does not implement #local_to_utc method" do @@ -214,7 +214,7 @@ def zone.utc_to_local(time) -> { Time.new(2000, 1, 1, 12, 0, 0, zone) - }.should raise_error(TypeError, /can't convert Object into an exact number/) + }.should.raise(TypeError, /can't convert Object into an exact number/) end it "does not raise exception if timezone does not implement #utc_to_local method" do @@ -223,7 +223,7 @@ def zone.local_to_utc(time) time end - Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time) + Time.new(2000, 1, 1, 12, 0, 0, zone).should.is_a?(Time) end # The result also should be a Time or Time-like object (not necessary to be the same class) @@ -236,7 +236,7 @@ def zone.local_to_utc(t) time - 60 * 60 # - 1 hour end - Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time) + Time.new(2000, 1, 1, 12, 0, 0, zone).should.is_a?(Time) Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60 end @@ -248,7 +248,7 @@ def zone.local_to_utc(t) Class.new(Time).utc(time.year, time.mon, time.day, time.hour, t.min, t.sec) end - Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time) + Time.new(2000, 1, 1, 12, 0, 0, zone).should.is_a?(Time) Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60 end @@ -260,7 +260,7 @@ def zone.local_to_utc(time) obj end - Time.new(2000, 1, 1, 12, 0, 0, zone).should be_kind_of(Time) + Time.new(2000, 1, 1, 12, 0, 0, zone).should.is_a?(Time) Time.new(2000, 1, 1, 12, 0, 0, zone).utc_offset.should == 60*60 end @@ -294,7 +294,7 @@ def zone.local_to_utc(t) -> { Time.new(2000, 1, 1, 12, 0, 0, zone) - }.should raise_error(ArgumentError, "utc_offset out of range") + }.should.raise(ArgumentError, "utc_offset out of range") end end @@ -348,7 +348,7 @@ def zone.local_to_utc(t) -> { Marshal.dump(time) - }.should raise_error(NoMethodError, /undefined method [`']name' for/) + }.should.raise(NoMethodError, /undefined method [`']name' for/) end end @@ -369,18 +369,18 @@ def zone.local_to_utc(t) time = TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, zone) time_loaded = Marshal.load(Marshal.dump(time)) - time_loaded.zone.should be_kind_of TimeSpecs::TimezoneWithName + time_loaded.zone.should.is_a? TimeSpecs::TimezoneWithName time_loaded.zone.name.should == "Asia/Colombo" time_loaded.utc_offset.should == 5*3600+30*60 end it "calls .find_timezone to build a time object if passed zone name as a timezone argument" do time = TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, "Asia/Colombo") - time.zone.should be_kind_of TimeSpecs::TimezoneWithName + time.zone.should.is_a? TimeSpecs::TimezoneWithName time.zone.name.should == "Asia/Colombo" time = TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, "some invalid zone name") - time.zone.should be_kind_of TimeSpecs::TimezoneWithName + time.zone.should.is_a? TimeSpecs::TimezoneWithName time.zone.name.should == "some invalid zone name" end @@ -388,7 +388,7 @@ def zone.local_to_utc(t) [Object.new, [], {}, :"some zone"].each do |zone| -> { TimeSpecs::TimeWithFindTimezone.new(2000, 1, 1, 12, 0, 0, zone) - }.should raise_error(TypeError, /can't convert \w+ into an exact number/) + }.should.raise(TypeError, /can't convert \w+ into an exact number/) end end end @@ -456,14 +456,14 @@ def zone.local_to_utc(t) end it "raises ArgumentError if format is invalid" do - -> { Time.new(2000, 1, 1, 12, 0, 0, in: "+09:99") }.should raise_error(ArgumentError) - -> { Time.new(2000, 1, 1, 12, 0, 0, in: "ABC") }.should raise_error(ArgumentError) + -> { Time.new(2000, 1, 1, 12, 0, 0, in: "+09:99") }.should.raise(ArgumentError) + -> { Time.new(2000, 1, 1, 12, 0, 0, in: "ABC") }.should.raise(ArgumentError) end it "raises ArgumentError if two offset arguments are given" do -> { Time.new(2000, 1, 1, 12, 0, 0, "+05:00", in: "+05:00") - }.should raise_error(ArgumentError, "timezone argument given as positional and keyword arguments") + }.should.raise(ArgumentError, "timezone argument given as positional and keyword arguments") end end @@ -557,183 +557,183 @@ def obj.to_int; 3; end it "raise TypeError is can't convert precision keyword argument into Integer" do -> { Time.new("2021-12-25 00:00:00.123456789876 +09:00", precision: "") - }.should raise_error(TypeError, "no implicit conversion of String into Integer") + }.should.raise(TypeError, "no implicit conversion of String into Integer") end it "raises ArgumentError if part of time string is missing" do -> { Time.new("2020-12-25 00:56 +09:00") - }.should raise_error(ArgumentError, /missing sec part: 00:56 |can't parse:/) + }.should.raise(ArgumentError, /missing sec part: 00:56 |can't parse:/) -> { Time.new("2020-12-25 00 +09:00") - }.should raise_error(ArgumentError, /missing min part: 00 |can't parse:/) + }.should.raise(ArgumentError, /missing min part: 00 |can't parse:/) end it "raises ArgumentError if the time part is missing" do -> { Time.new("2020-12-25") - }.should raise_error(ArgumentError, /no time information|can't parse:/) + }.should.raise(ArgumentError, /no time information|can't parse:/) end it "raises ArgumentError if day is missing" do -> { Time.new("2020-12") - }.should raise_error(ArgumentError, /no time information|can't parse:/) + }.should.raise(ArgumentError, /no time information|can't parse:/) end it "raises ArgumentError if subsecond is missing after dot" do -> { Time.new("2020-12-25 00:56:17. +0900") - }.should raise_error(ArgumentError, /subsecond expected after dot: 00:56:17. |can't parse:/) + }.should.raise(ArgumentError, /subsecond expected after dot: 00:56:17. |can't parse:/) end it "raises ArgumentError if String argument is not in the supported format" do -> { Time.new("021-12-25 00:00:00.123456 +09:00") - }.should raise_error(ArgumentError, /year must be 4 or more digits: 021|can't parse:/) + }.should.raise(ArgumentError, /year must be 4 or more digits: 021|can't parse:/) -> { Time.new("2020-012-25 00:56:17 +0900") - }.should raise_error(ArgumentError, /\Atwo digits mon is expected after [`']-': -012-25 00:\z|can't parse:/) + }.should.raise(ArgumentError, /\Atwo digits mon is expected after [`']-': -012-25 00:\z|can't parse:/) -> { Time.new("2020-2-25 00:56:17 +0900") - }.should raise_error(ArgumentError, /\Atwo digits mon is expected after [`']-': -2-25 00:56\z|can't parse:/) + }.should.raise(ArgumentError, /\Atwo digits mon is expected after [`']-': -2-25 00:56\z|can't parse:/) -> { Time.new("2020-12-215 00:56:17 +0900") - }.should raise_error(ArgumentError, /\Atwo digits mday is expected after [`']-': -215 00:56:\z|can't parse:/) + }.should.raise(ArgumentError, /\Atwo digits mday is expected after [`']-': -215 00:56:\z|can't parse:/) -> { Time.new("2020-12-25 000:56:17 +0900") - }.should raise_error(ArgumentError, /two digits hour is expected: 000:56:17 |can't parse:/) + }.should.raise(ArgumentError, /two digits hour is expected: 000:56:17 |can't parse:/) -> { Time.new("2020-12-25 0:56:17 +0900") - }.should raise_error(ArgumentError, /two digits hour is expected: 0:56:17 \+0|can't parse:/) + }.should.raise(ArgumentError, /two digits hour is expected: 0:56:17 \+0|can't parse:/) -> { Time.new("2020-12-25 00:516:17 +0900") - }.should raise_error(ArgumentError, /\Atwo digits min is expected after [`']:': :516:17 \+09\z|can't parse:/) + }.should.raise(ArgumentError, /\Atwo digits min is expected after [`']:': :516:17 \+09\z|can't parse:/) -> { Time.new("2020-12-25 00:6:17 +0900") - }.should raise_error(ArgumentError, /\Atwo digits min is expected after [`']:': :6:17 \+0900\z|can't parse:/) + }.should.raise(ArgumentError, /\Atwo digits min is expected after [`']:': :6:17 \+0900\z|can't parse:/) -> { Time.new("2020-12-25 00:56:137 +0900") - }.should raise_error(ArgumentError, /\Atwo digits sec is expected after [`']:': :137 \+0900\z|can't parse:/) + }.should.raise(ArgumentError, /\Atwo digits sec is expected after [`']:': :137 \+0900\z|can't parse:/) -> { Time.new("2020-12-25 00:56:7 +0900") - }.should raise_error(ArgumentError, /\Atwo digits sec is expected after [`']:': :7 \+0900\z|can't parse:/) + }.should.raise(ArgumentError, /\Atwo digits sec is expected after [`']:': :7 \+0900\z|can't parse:/) -> { Time.new("2020-12-25 00:56. +0900") - }.should raise_error(ArgumentError, /fraction min is not supported: 00:56\.|can't parse:/) + }.should.raise(ArgumentError, /fraction min is not supported: 00:56\.|can't parse:/) -> { Time.new("2020-12-25 00. +0900") - }.should raise_error(ArgumentError, /fraction hour is not supported: 00\.|can't parse:/) + }.should.raise(ArgumentError, /fraction hour is not supported: 00\.|can't parse:/) end it "raises ArgumentError if date/time parts values are not valid" do -> { Time.new("2020-13-25 00:56:17 +09:00") - }.should raise_error(ArgumentError, /(mon|argument) out of range/) + }.should.raise(ArgumentError, /(mon|argument) out of range/) -> { Time.new("2020-12-32 00:56:17 +09:00") - }.should raise_error(ArgumentError, /(mday|argument) out of range/) + }.should.raise(ArgumentError, /(mday|argument) out of range/) -> { Time.new("2020-12-25 25:56:17 +09:00") - }.should raise_error(ArgumentError, /(hour|argument) out of range/) + }.should.raise(ArgumentError, /(hour|argument) out of range/) -> { Time.new("2020-12-25 00:61:17 +09:00") - }.should raise_error(ArgumentError, /(min|argument) out of range/) + }.should.raise(ArgumentError, /(min|argument) out of range/) -> { Time.new("2020-12-25 00:56:61 +09:00") - }.should raise_error(ArgumentError, /(sec|argument) out of range/) + }.should.raise(ArgumentError, /(sec|argument) out of range/) -> { Time.new("2020-12-25 00:56:17 +23:59:60") - }.should raise_error(ArgumentError, /utc_offset|argument out of range/) + }.should.raise(ArgumentError, /utc_offset|argument out of range/) -> { Time.new("2020-12-25 00:56:17 +24:00") - }.should raise_error(ArgumentError, /(utc_offset|argument) out of range/) + }.should.raise(ArgumentError, /(utc_offset|argument) out of range/) -> { Time.new("2020-12-25 00:56:17 +23:61") - }.should raise_error(ArgumentError, /utc_offset/) + }.should.raise(ArgumentError, /utc_offset/) ruby_bug '#20797', ''...'3.4' do -> { Time.new("2020-12-25 00:56:17 +00:23:61") - }.should raise_error(ArgumentError, /utc_offset/) + }.should.raise(ArgumentError, /utc_offset/) end end it "raises ArgumentError if utc offset parts are not valid" do - -> { Time.new("2020-12-25 00:56:17 +24:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.new("2020-12-25 00:56:17 +2400") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.new("2020-12-25 00:56:17 +24:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.new("2020-12-25 00:56:17 +2400") }.should.raise(ArgumentError, "utc_offset out of range") - -> { Time.new("2020-12-25 00:56:17 +99:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.new("2020-12-25 00:56:17 +9900") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.new("2020-12-25 00:56:17 +99:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.new("2020-12-25 00:56:17 +9900") }.should.raise(ArgumentError, "utc_offset out of range") - -> { Time.new("2020-12-25 00:56:17 +00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') - -> { Time.new("2020-12-25 00:56:17 +0060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') + -> { Time.new("2020-12-25 00:56:17 +00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') + -> { Time.new("2020-12-25 00:56:17 +0060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') - -> { Time.new("2020-12-25 00:56:17 +00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') - -> { Time.new("2020-12-25 00:56:17 +0099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') + -> { Time.new("2020-12-25 00:56:17 +00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') + -> { Time.new("2020-12-25 00:56:17 +0099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') ruby_bug '#20797', ''...'3.4' do - -> { Time.new("2020-12-25 00:56:17 +00:00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') - -> { Time.new("2020-12-25 00:56:17 +000060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') + -> { Time.new("2020-12-25 00:56:17 +00:00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') + -> { Time.new("2020-12-25 00:56:17 +000060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') - -> { Time.new("2020-12-25 00:56:17 +00:00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') - -> { Time.new("2020-12-25 00:56:17 +000099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') + -> { Time.new("2020-12-25 00:56:17 +00:00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') + -> { Time.new("2020-12-25 00:56:17 +000099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') end end it "raises ArgumentError if string has not ascii-compatible encoding" do -> { Time.new("2021-11-31 00:00:60 +09:00".encode("utf-32le")) - }.should raise_error(ArgumentError, "time string should have ASCII compatible encoding") + }.should.raise(ArgumentError, "time string should have ASCII compatible encoding") end it "raises ArgumentError if string doesn't start with year" do -> { Time.new("a\nb") - }.should raise_error(ArgumentError, "can't parse: \"a\\nb\"") + }.should.raise(ArgumentError, "can't parse: \"a\\nb\"") end it "raises ArgumentError if string has extra characters after offset" do -> { Time.new("2021-11-31 00:00:59 +09:00 abc") - }.should raise_error(ArgumentError, /can't parse.+ abc/) + }.should.raise(ArgumentError, /can't parse.+ abc/) end it "raises ArgumentError when there are leading space characters" do - -> { Time.new(" 2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("\t2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("\n2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("\v2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("\f2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("\r2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new(" 2020-12-02 00:00:00") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("\t2020-12-02 00:00:00") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("\n2020-12-02 00:00:00") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("\v2020-12-02 00:00:00") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("\f2020-12-02 00:00:00") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("\r2020-12-02 00:00:00") }.should.raise(ArgumentError, /can't parse/) end it "raises ArgumentError when there are trailing whitespaces" do - -> { Time.new("2020-12-02 00:00:00 ") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("2020-12-02 00:00:00\t") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("2020-12-02 00:00:00\n") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("2020-12-02 00:00:00\v") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("2020-12-02 00:00:00\f") }.should raise_error(ArgumentError, /can't parse/) - -> { Time.new("2020-12-02 00:00:00\r") }.should raise_error(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00 ") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\t") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\n") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\v") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\f") }.should.raise(ArgumentError, /can't parse/) + -> { Time.new("2020-12-02 00:00:00\r") }.should.raise(ArgumentError, /can't parse/) end end end diff --git a/spec/ruby/core/time/now_spec.rb b/spec/ruby/core/time/now_spec.rb index e3fe6edad667ed..533cf683804e0d 100644 --- a/spec/ruby/core/time/now_spec.rb +++ b/spec/ruby/core/time/now_spec.rb @@ -53,33 +53,33 @@ end it "raises ArgumentError if format is invalid" do - -> { Time.now(in: "+09:99") }.should raise_error(ArgumentError) - -> { Time.now(in: "ABC") }.should raise_error(ArgumentError) + -> { Time.now(in: "+09:99") }.should.raise(ArgumentError) + -> { Time.now(in: "ABC") }.should.raise(ArgumentError) end it "raises ArgumentError if String argument and hours greater than 23" do - -> { Time.now(in: "+24:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.now(in: "+2400") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.now(in: "+24:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.now(in: "+2400") }.should.raise(ArgumentError, "utc_offset out of range") - -> { Time.now(in: "+99:00") }.should raise_error(ArgumentError, "utc_offset out of range") - -> { Time.now(in: "+9900") }.should raise_error(ArgumentError, "utc_offset out of range") + -> { Time.now(in: "+99:00") }.should.raise(ArgumentError, "utc_offset out of range") + -> { Time.now(in: "+9900") }.should.raise(ArgumentError, "utc_offset out of range") end it "raises ArgumentError if String argument and minutes greater than 59" do - -> { Time.now(in: "+00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') - -> { Time.now(in: "+0060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') + -> { Time.now(in: "+00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:60') + -> { Time.now(in: "+0060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0060') - -> { Time.now(in: "+00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') - -> { Time.now(in: "+0099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') + -> { Time.now(in: "+00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:99') + -> { Time.now(in: "+0099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +0099') end ruby_bug '#20797', ''...'3.4' do it "raises ArgumentError if String argument and seconds greater than 59" do - -> { Time.now(in: "+00:00:60") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') - -> { Time.now(in: "+000060") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') + -> { Time.now(in: "+00:00:60") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:60') + -> { Time.now(in: "+000060") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000060') - -> { Time.now(in: "+00:00:99") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') - -> { Time.now(in: "+000099") }.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') + -> { Time.now(in: "+00:00:99") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +00:00:99') + -> { Time.now(in: "+000099") }.should.raise(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +000099') end end end @@ -93,7 +93,7 @@ def zone.local_to_utc(time) -> { Time.now(in: zone) - }.should raise_error(TypeError, /can't convert Object into an exact number/) + }.should.raise(TypeError, /can't convert Object into an exact number/) end it "does not raise exception if timezone does not implement #local_to_utc method" do @@ -102,7 +102,7 @@ def zone.utc_to_local(time) time end - Time.now(in: zone).should be_kind_of(Time) + Time.now(in: zone).should.is_a?(Time) end # The result also should be a Time or Time-like object (not necessary to be the same class) @@ -115,7 +115,7 @@ def zone.utc_to_local(t) time + 60 * 60 # + 1 hour end - Time.now(in: zone).should be_kind_of(Time) + Time.now(in: zone).should.is_a?(Time) Time.now(in: zone).utc_offset.should == 3600 end @@ -128,7 +128,7 @@ def zone.utc_to_local(t) Class.new(Time).new(time.year, time.mon, time.day, time.hour, time.min, time.sec, time.utc_offset) end - Time.now(in: zone).should be_kind_of(Time) + Time.now(in: zone).should.is_a?(Time) Time.now(in: zone).utc_offset.should == 3600 end @@ -138,7 +138,7 @@ def zone.utc_to_local(time) time.to_i + 60*60 end - Time.now(in: zone).should be_kind_of(Time) + Time.now(in: zone).should.is_a?(Time) Time.now(in: zone).utc_offset.should == 60*60 end @@ -174,7 +174,7 @@ def zone.utc_to_local(t) -> { Time.now(in: zone) - }.should raise_error(ArgumentError, "utc_offset out of range") + }.should.raise(ArgumentError, "utc_offset out of range") end end end diff --git a/spec/ruby/core/time/plus_spec.rb b/spec/ruby/core/time/plus_spec.rb index 642393b615cd06..6bd01bcdf3446c 100644 --- a/spec/ruby/core/time/plus_spec.rb +++ b/spec/ruby/core/time/plus_spec.rb @@ -17,9 +17,9 @@ end it "raises a TypeError if given argument is a coercible String" do - -> { Time.now + "1" }.should raise_error(TypeError) - -> { Time.now + "0.1" }.should raise_error(TypeError) - -> { Time.now + "1/3" }.should raise_error(TypeError) + -> { Time.now + "1" }.should.raise(TypeError) + -> { Time.now + "0.1" }.should.raise(TypeError) + -> { Time.now + "1/3" }.should.raise(TypeError) end it "increments the time by the specified amount as rational numbers" do @@ -32,8 +32,8 @@ end it "raises TypeError on argument that can't be coerced into Rational" do - -> { Time.now + Object.new }.should raise_error(TypeError) - -> { Time.now + "stuff" }.should raise_error(TypeError) + -> { Time.now + Object.new }.should.raise(TypeError) + -> { Time.now + "stuff" }.should.raise(TypeError) end it "returns a UTC time if self is UTC" do @@ -68,15 +68,15 @@ it "does not return a subclass instance" do c = Class.new(Time) x = c.now + 1 - x.should be_an_instance_of(Time) + x.should.instance_of?(Time) end it "raises TypeError on Time argument" do - -> { Time.now + Time.now }.should raise_error(TypeError) + -> { Time.now + Time.now }.should.raise(TypeError) end it "raises TypeError on nil argument" do - -> { Time.now + nil }.should raise_error(TypeError) + -> { Time.now + nil }.should.raise(TypeError) end #see [ruby-dev:38446] diff --git a/spec/ruby/core/time/round_spec.rb b/spec/ruby/core/time/round_spec.rb index 0cbed04adeb421..a739cabfdf825f 100644 --- a/spec/ruby/core/time/round_spec.rb +++ b/spec/ruby/core/time/round_spec.rb @@ -20,8 +20,8 @@ it "returns an instance of Time, even if #round is called on a subclass" do subclass = Class.new(Time) instance = subclass.at(0) - instance.class.should equal subclass - instance.round.should be_an_instance_of(Time) + instance.class.should.equal? subclass + instance.round.should.instance_of?(Time) end it "copies own timezone to the returning value" do diff --git a/spec/ruby/core/time/shared/gmtime.rb b/spec/ruby/core/time/shared/gmtime.rb index 7b4f65f0b796cf..aa76b436ccca45 100644 --- a/spec/ruby/core/time/shared/gmtime.rb +++ b/spec/ruby/core/time/shared/gmtime.rb @@ -18,7 +18,7 @@ it "returns self" do with_timezone("CST", -6) do t = Time.local(2007, 1, 9, 12, 0, 0) - t.send(@method).should equal(t) + t.send(@method).should.equal?(t) end end @@ -26,14 +26,14 @@ it "does not raise an error if already in UTC" do time = Time.gm(2007, 1, 9, 12, 0, 0) time.freeze - time.send(@method).should equal(time) + time.send(@method).should.equal?(time) end it "raises a FrozenError if the time is not UTC" do with_timezone("CST", -6) do time = Time.now time.freeze - -> { time.send(@method) }.should raise_error(FrozenError) + -> { time.send(@method) }.should.raise(FrozenError) end end end diff --git a/spec/ruby/core/time/shared/inspect.rb b/spec/ruby/core/time/shared/inspect.rb index 4133671924729f..82f7f3c686ff63 100644 --- a/spec/ruby/core/time/shared/inspect.rb +++ b/spec/ruby/core/time/shared/inspect.rb @@ -16,6 +16,6 @@ end it "returns a US-ASCII encoded string" do - Time.now.send(@method).encoding.should equal(Encoding::US_ASCII) + Time.now.send(@method).encoding.should.equal?(Encoding::US_ASCII) end end diff --git a/spec/ruby/core/time/shared/now.rb b/spec/ruby/core/time/shared/now.rb index f4018d72f4488f..839cfdcd2abc31 100644 --- a/spec/ruby/core/time/shared/now.rb +++ b/spec/ruby/core/time/shared/now.rb @@ -2,8 +2,8 @@ describe :time_now, shared: true do it "creates a subclass instance if called on a subclass" do - TimeSpecs::SubTime.send(@method).should be_an_instance_of(TimeSpecs::SubTime) - TimeSpecs::MethodHolder.send(@method).should be_an_instance_of(Time) + TimeSpecs::SubTime.send(@method).should.instance_of?(TimeSpecs::SubTime) + TimeSpecs::MethodHolder.send(@method).should.instance_of?(Time) end it "sets the current time" do diff --git a/spec/ruby/core/time/shared/time_params.rb b/spec/ruby/core/time/shared/time_params.rb index 9832fd17fe1846..f0de986b8ec6ed 100644 --- a/spec/ruby/core/time/shared/time_params.rb +++ b/spec/ruby/core/time/shared/time_params.rb @@ -30,7 +30,7 @@ end it "raises a TypeError if the year is nil" do - -> { Time.send(@method, nil) }.should raise_error(TypeError) + -> { Time.send(@method, nil) }.should.raise(TypeError) end it "accepts nil month, day, hour, minute, and second" do @@ -148,52 +148,52 @@ # For some reason MRI uses a different message for month in 13-15 and month>=16 -> { Time.send(@method, 2008, 16, 31, 23, 59, 59) - }.should raise_error(ArgumentError, /(mon|argument) out of range/) + }.should.raise(ArgumentError, /(mon|argument) out of range/) end it "raises an ArgumentError for out of range day" do -> { Time.send(@method, 2008, 12, 32, 23, 59, 59) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an ArgumentError for out of range hour" do -> { Time.send(@method, 2008, 12, 31, 25, 59, 59) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an ArgumentError for out of range minute" do -> { Time.send(@method, 2008, 12, 31, 23, 61, 59) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an ArgumentError for out of range second" do # For some reason MRI uses different messages for seconds 61-63 and seconds >= 64 -> { Time.send(@method, 2008, 12, 31, 23, 59, 61) - }.should raise_error(ArgumentError, /(sec|argument) out of range/) + }.should.raise(ArgumentError, /(sec|argument) out of range/) -> { Time.send(@method, 2008, 12, 31, 23, 59, -1) - }.should raise_error(ArgumentError, "argument out of range") + }.should.raise(ArgumentError, "argument out of range") end it "raises ArgumentError when given 8 arguments" do - -> { Time.send(@method, *[0]*8) }.should raise_error(ArgumentError) + -> { Time.send(@method, *[0]*8) }.should.raise(ArgumentError) end it "raises ArgumentError when given 9 arguments" do - -> { Time.send(@method, *[0]*9) }.should raise_error(ArgumentError) + -> { Time.send(@method, *[0]*9) }.should.raise(ArgumentError) end it "raises ArgumentError when given 11 arguments" do - -> { Time.send(@method, *[0]*11) }.should raise_error(ArgumentError) + -> { Time.send(@method, *[0]*11) }.should.raise(ArgumentError) end it "returns subclass instances" do c = Class.new(Time) - c.send(@method, 2008, "12").should be_an_instance_of(c) + c.send(@method, 2008, "12").should.instance_of?(c) end end @@ -213,23 +213,23 @@ it "raises an ArgumentError for out of range values" do -> { Time.send(@method, 61, 59, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) - }.should raise_error(ArgumentError) # sec + }.should.raise(ArgumentError) # sec -> { Time.send(@method, 59, 61, 23, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) - }.should raise_error(ArgumentError) # min + }.should.raise(ArgumentError) # min -> { Time.send(@method, 59, 59, 25, 31, 12, 2008, :ignored, :ignored, :ignored, :ignored) - }.should raise_error(ArgumentError) # hour + }.should.raise(ArgumentError) # hour -> { Time.send(@method, 59, 59, 23, 32, 12, 2008, :ignored, :ignored, :ignored, :ignored) - }.should raise_error(ArgumentError) # day + }.should.raise(ArgumentError) # day -> { Time.send(@method, 59, 59, 23, 31, 13, 2008, :ignored, :ignored, :ignored, :ignored) - }.should raise_error(ArgumentError) # month + }.should.raise(ArgumentError) # month end end @@ -240,7 +240,7 @@ end it "raises an ArgumentError for out of range microsecond" do - -> { Time.send(@method, 2000, 1, 1, 20, 15, 1, 1000000) }.should raise_error(ArgumentError) + -> { Time.send(@method, 2000, 1, 1, 20, 15, 1, 1000000) }.should.raise(ArgumentError) end it "handles fractional microseconds as a Float" do diff --git a/spec/ruby/core/time/strftime_spec.rb b/spec/ruby/core/time/strftime_spec.rb index fd233f3577bf45..1528a668a1c55b 100644 --- a/spec/ruby/core/time/strftime_spec.rb +++ b/spec/ruby/core/time/strftime_spec.rb @@ -25,7 +25,7 @@ # Differences with date it "requires an argument" do - -> { @time.strftime }.should raise_error(ArgumentError) + -> { @time.strftime }.should.raise(ArgumentError) end # %Z is zone name or empty for Time diff --git a/spec/ruby/core/time/subsec_spec.rb b/spec/ruby/core/time/subsec_spec.rb index 0f2c4eb856a1d9..3ed1bf5dd18274 100644 --- a/spec/ruby/core/time/subsec_spec.rb +++ b/spec/ruby/core/time/subsec_spec.rb @@ -2,26 +2,26 @@ describe "Time#subsec" do it "returns 0 as an Integer for a Time with a whole number of seconds" do - Time.at(100).subsec.should eql(0) + Time.at(100).subsec.should.eql?(0) end it "returns the fractional seconds as a Rational for a Time constructed with a Rational number of seconds" do - Time.at(Rational(3, 2)).subsec.should eql(Rational(1, 2)) + Time.at(Rational(3, 2)).subsec.should.eql?(Rational(1, 2)) end it "returns the fractional seconds as a Rational for a Time constructed with a Float number of seconds" do - Time.at(10.75).subsec.should eql(Rational(3, 4)) + Time.at(10.75).subsec.should.eql?(Rational(3, 4)) end it "returns the fractional seconds as a Rational for a Time constructed with an Integer number of microseconds" do - Time.at(0, 999999).subsec.should eql(Rational(999999, 1000000)) + Time.at(0, 999999).subsec.should.eql?(Rational(999999, 1000000)) end it "returns the fractional seconds as a Rational for a Time constructed with an Rational number of microseconds" do - Time.at(0, Rational(9, 10)).subsec.should eql(Rational(9, 10000000)) + Time.at(0, Rational(9, 10)).subsec.should.eql?(Rational(9, 10000000)) end it "returns the fractional seconds as a Rational for a Time constructed with an Float number of microseconds" do - Time.at(0, 0.75).subsec.should eql(Rational(3, 4000000)) + Time.at(0, 0.75).subsec.should.eql?(Rational(3, 4000000)) end end diff --git a/spec/ruby/core/time/to_r_spec.rb b/spec/ruby/core/time/to_r_spec.rb index 6af2d9b7ea2a74..e30f5d8f94e884 100644 --- a/spec/ruby/core/time/to_r_spec.rb +++ b/spec/ruby/core/time/to_r_spec.rb @@ -2,10 +2,10 @@ describe "Time#to_r" do it "returns the a Rational representing seconds and subseconds since the epoch" do - Time.at(Rational(11, 10)).to_r.should eql(Rational(11, 10)) + Time.at(Rational(11, 10)).to_r.should.eql?(Rational(11, 10)) end it "returns a Rational even for a whole number of seconds" do - Time.at(2).to_r.should eql(Rational(2)) + Time.at(2).to_r.should.eql?(Rational(2)) end end diff --git a/spec/ruby/core/time/zone_spec.rb b/spec/ruby/core/time/zone_spec.rb index 9a15bd569b4544..2cb3c5e7bb7dcc 100644 --- a/spec/ruby/core/time/zone_spec.rb +++ b/spec/ruby/core/time/zone_spec.rb @@ -6,7 +6,7 @@ with_timezone("America/New_York") do Time.new(2001, 1, 1, 0, 0, 0).zone.should == "EST" Time.new(2001, 7, 1, 0, 0, 0).zone.should == "EDT" - %w[EST EDT].should include Time.now.zone + %w[EST EDT].should.include? Time.now.zone end end end @@ -29,7 +29,7 @@ t = Time.new(2005, 2, 27, 22, 50, 0, -3600) with_timezone("America/New_York") do - t.getlocal("+05:00").zone.should be_nil + t.getlocal("+05:00").zone.should == nil end end diff --git a/spec/ruby/core/tracepoint/allow_reentry_spec.rb b/spec/ruby/core/tracepoint/allow_reentry_spec.rb index 75e9e859a913d4..475cca29a98962 100644 --- a/spec/ruby/core/tracepoint/allow_reentry_spec.rb +++ b/spec/ruby/core/tracepoint/allow_reentry_spec.rb @@ -25,6 +25,6 @@ it 'raises RuntimeError when not called inside a TracePoint' do -> { TracePoint.allow_reentry{} - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end end diff --git a/spec/ruby/core/tracepoint/binding_spec.rb b/spec/ruby/core/tracepoint/binding_spec.rb index 6a7ef5f85a6cd2..6de6e47d7d9025 100644 --- a/spec/ruby/core/tracepoint/binding_spec.rb +++ b/spec/ruby/core/tracepoint/binding_spec.rb @@ -15,7 +15,7 @@ def test test } bindings.size.should == 1 - bindings[0].should be_kind_of(Binding) + bindings[0].should.is_a?(Binding) bindings[0].local_variables.should == [:secret] end end diff --git a/spec/ruby/core/tracepoint/defined_class_spec.rb b/spec/ruby/core/tracepoint/defined_class_spec.rb index 4593db6d1f4b0c..53c86a821066f7 100644 --- a/spec/ruby/core/tracepoint/defined_class_spec.rb +++ b/spec/ruby/core/tracepoint/defined_class_spec.rb @@ -9,19 +9,19 @@ last_class_name = tp.defined_class end.enable do TracePointSpec::B.new.foo - last_class_name.should equal(TracePointSpec::B) + last_class_name.should.equal?(TracePointSpec::B) TracePointSpec::B.new.bar - last_class_name.should equal(TracePointSpec::A) + last_class_name.should.equal?(TracePointSpec::A) c = TracePointSpec::C.new - last_class_name.should equal(TracePointSpec::C) + last_class_name.should.equal?(TracePointSpec::C) c.foo - last_class_name.should equal(TracePointSpec::B) + last_class_name.should.equal?(TracePointSpec::B) c.bar - last_class_name.should equal(TracePointSpec::A) + last_class_name.should.equal?(TracePointSpec::A) end end end diff --git a/spec/ruby/core/tracepoint/enable_spec.rb b/spec/ruby/core/tracepoint/enable_spec.rb index 93a6b281e3583b..bf61c35154a476 100644 --- a/spec/ruby/core/tracepoint/enable_spec.rb +++ b/spec/ruby/core/tracepoint/enable_spec.rb @@ -54,7 +54,7 @@ TracePoint.new(:line) do |tp| next unless TracePointSpec.target_thread? event_name = tp.event - end.enable { event_name.should equal(:line) } + end.enable { event_name.should.equal?(:line) } end it 'enables the trace object only for the current thread' do @@ -85,7 +85,7 @@ event_name = tp.event end trace.enable do |*args| - event_name.should equal(:line) + event_name.should.equal?(:line) args.should == [] end trace.should_not.enabled? @@ -301,7 +301,7 @@ def foo; end end ScratchPad.recorded.should == [lineno] - lineno.should be_kind_of(Integer) + lineno.should.is_a?(Integer) end end @@ -317,7 +317,7 @@ def foo; end trace.enable(target: block) do block.call # triggers :b_call and :b_return events end - }.should raise_error(ArgumentError, /can not enable any hooks/) + }.should.raise(ArgumentError, /can not enable any hooks/) end it "raises ArgumentError if passed not Method/UnboundMethod/Proc" do @@ -326,7 +326,7 @@ def foo; end -> { trace.enable(target: Object.new) do end - }.should raise_error(ArgumentError, /specified target is not supported/) + }.should.raise(ArgumentError, /specified target is not supported/) end context "nested enabling and disabling" do @@ -338,7 +338,7 @@ def foo; end trace.enable(target: -> {}) do end end - }.should raise_error(ArgumentError, /can't nest-enable a targett?ing TracePoint/) + }.should.raise(ArgumentError, /can't nest-enable a targett?ing TracePoint/) end it "raises ArgumentError if trace point already enabled without target is re-enabled with target" do @@ -349,7 +349,7 @@ def foo; end trace.enable(target: -> {}) do end end - }.should raise_error(ArgumentError, /can't nest-enable a targett?ing TracePoint/) + }.should.raise(ArgumentError, /can't nest-enable a targett?ing TracePoint/) end it "raises ArgumentError if trace point already enabled with target is re-enabled without target" do @@ -360,7 +360,7 @@ def foo; end trace.enable do end end - }.should raise_error(ArgumentError, /can't nest-enable a targett?ing TracePoint/) + }.should.raise(ArgumentError, /can't nest-enable a targett?ing TracePoint/) end it "raises ArgumentError if trace point already enabled with target is disabled with block" do @@ -371,7 +371,7 @@ def foo; end trace.disable do end end - }.should raise_error(ArgumentError, /can't disable a targett?ing TracePoint in a block/) + }.should.raise(ArgumentError, /can't disable a targett?ing TracePoint in a block/) end it "traces events when trace point with target is enabled in another trace point enabled without target" do @@ -474,7 +474,7 @@ def foo; end -> { trace.enable(target_line: 67) do end - }.should raise_error(ArgumentError, /only target_line is specified/) + }.should.raise(ArgumentError, /only target_line is specified/) end it "raises ArgumentError if :line event isn't registered" do @@ -491,7 +491,7 @@ def foo; end -> { trace.enable(target_line: target_line, target: target) do end - }.should raise_error(ArgumentError, /target_line is specified, but line event is not specified/) + }.should.raise(ArgumentError, /target_line is specified, but line event is not specified/) end it "raises ArgumentError if :target_line value is out of target code lines range" do @@ -500,7 +500,7 @@ def foo; end -> { trace.enable(target_line: 1, target: -> { }) do end - }.should raise_error(ArgumentError, /can not enable any hooks/) + }.should.raise(ArgumentError, /can not enable any hooks/) end it "raises TypeError if :target_line value couldn't be coerced to Integer" do @@ -509,7 +509,7 @@ def foo; end -> { trace.enable(target_line: Object.new, target: -> { }) do end - }.should raise_error(TypeError, /no implicit conversion of \w+? into Integer/) + }.should.raise(TypeError, /no implicit conversion of \w+? into Integer/) end it "raises ArgumentError if :target_line value is negative" do @@ -518,7 +518,7 @@ def foo; end -> { trace.enable(target_line: -2, target: -> { }) do end - }.should raise_error(ArgumentError, /can not enable any hooks/) + }.should.raise(ArgumentError, /can not enable any hooks/) end it "accepts value that could be coerced to Integer" do diff --git a/spec/ruby/core/tracepoint/event_spec.rb b/spec/ruby/core/tracepoint/event_spec.rb index 9dea24d12583d6..58017dc98deca6 100644 --- a/spec/ruby/core/tracepoint/event_spec.rb +++ b/spec/ruby/core/tracepoint/event_spec.rb @@ -9,13 +9,13 @@ event_name = tp.event end.enable do TracePointSpec.test - event_name.should equal(:call) + event_name.should.equal?(:call) TracePointSpec::B.new.foo - event_name.should equal(:call) + event_name.should.equal?(:call) class TracePointSpec::B; end - event_name.should equal(:end) + event_name.should.equal?(:end) end end diff --git a/spec/ruby/core/tracepoint/lineno_spec.rb b/spec/ruby/core/tracepoint/lineno_spec.rb index 77b3ac8b5491f8..7c46d5222bcd5e 100644 --- a/spec/ruby/core/tracepoint/lineno_spec.rb +++ b/spec/ruby/core/tracepoint/lineno_spec.rb @@ -15,6 +15,6 @@ it 'raises RuntimeError if accessed from outside' do tp = TracePoint.new(:line) {} - -> { tp.lineno }.should raise_error(RuntimeError, 'access from outside') + -> { tp.lineno }.should.raise(RuntimeError, 'access from outside') end end diff --git a/spec/ruby/core/tracepoint/method_id_spec.rb b/spec/ruby/core/tracepoint/method_id_spec.rb index 43e23248b7ee2c..67740f2d7d3fec 100644 --- a/spec/ruby/core/tracepoint/method_id_spec.rb +++ b/spec/ruby/core/tracepoint/method_id_spec.rb @@ -9,7 +9,7 @@ method_name = tp.method_id }.enable do TracePointSpec.test - method_name.should equal(:test) + method_name.should.equal?(:test) end end end diff --git a/spec/ruby/core/tracepoint/new_spec.rb b/spec/ruby/core/tracepoint/new_spec.rb index e53c2b04a24ea3..763b35292b9de5 100644 --- a/spec/ruby/core/tracepoint/new_spec.rb +++ b/spec/ruby/core/tracepoint/new_spec.rb @@ -3,7 +3,7 @@ describe 'TracePoint.new' do it 'returns a new TracePoint object, not enabled by default' do - TracePoint.new(:line) {}.enabled?.should be_false + TracePoint.new(:line) {}.enabled?.should == false end it 'includes :line event when event is not specified' do @@ -12,15 +12,15 @@ next unless TracePointSpec.target_thread? event_name = tp.event }.enable do - event_name.should equal(:line) + event_name.should.equal?(:line) event_name = nil TracePointSpec.test - event_name.should equal(:line) + event_name.should.equal?(:line) event_name = nil TracePointSpec::B.new.foo - event_name.should equal(:line) + event_name.should.equal?(:line) end end @@ -44,29 +44,29 @@ event_name = tp.event end.enable do TracePointSpec.test - event_name.should equal(:call) + event_name.should.equal?(:call) TracePointSpec::B.new.foo - event_name.should equal(:call) + event_name.should.equal?(:call) class TracePointSpec::B; end - event_name.should equal(:end) + event_name.should.equal?(:end) end end it 'raises a TypeError when the given object is not a string/symbol' do o = mock('123') - -> { TracePoint.new(o) {} }.should raise_error(TypeError) + -> { TracePoint.new(o) {} }.should.raise(TypeError) o.should_receive(:to_sym).and_return(123) - -> { TracePoint.new(o) {} }.should raise_error(TypeError) + -> { TracePoint.new(o) {} }.should.raise(TypeError) end it 'expects to be called with a block' do - -> { TracePoint.new(:line) }.should raise_error(ArgumentError, "must be called with a block") + -> { TracePoint.new(:line) }.should.raise(ArgumentError, "must be called with a block") end it "raises a Argument error when the given argument doesn't match an event name" do - -> { TracePoint.new(:test) }.should raise_error(ArgumentError, "unknown event: test") + -> { TracePoint.new(:test) }.should.raise(ArgumentError, "unknown event: test") end end diff --git a/spec/ruby/core/tracepoint/raised_exception_spec.rb b/spec/ruby/core/tracepoint/raised_exception_spec.rb index e74afa9abc96c1..b1199902f27d03 100644 --- a/spec/ruby/core/tracepoint/raised_exception_spec.rb +++ b/spec/ruby/core/tracepoint/raised_exception_spec.rb @@ -14,7 +14,7 @@ rescue => e error_result = e end - raised_exception.should equal(error_result) + raised_exception.should.equal?(error_result) end end @@ -30,7 +30,7 @@ rescue => e error_result = e end - raised_exception.should equal(error_result) + raised_exception.should.equal?(error_result) end end end diff --git a/spec/ruby/core/tracepoint/self_spec.rb b/spec/ruby/core/tracepoint/self_spec.rb index 2098860e59221d..bf9a2b6a451b60 100644 --- a/spec/ruby/core/tracepoint/self_spec.rb +++ b/spec/ruby/core/tracepoint/self_spec.rb @@ -8,7 +8,7 @@ next unless TracePointSpec.target_thread? trace = tp.self }.enable do - trace.equal?(self).should be_true + trace.equal?(self).should == true end end @@ -21,6 +21,6 @@ class TracePointSpec::C end end - trace.should equal TracePointSpec::C + trace.should.equal? TracePointSpec::C end end diff --git a/spec/ruby/core/true/dup_spec.rb b/spec/ruby/core/true/dup_spec.rb index 351457ed229344..2628f6d374718c 100644 --- a/spec/ruby/core/true/dup_spec.rb +++ b/spec/ruby/core/true/dup_spec.rb @@ -2,6 +2,6 @@ describe "TrueClass#dup" do it "returns self" do - true.dup.should equal(true) + true.dup.should.equal?(true) end end diff --git a/spec/ruby/core/true/singleton_method_spec.rb b/spec/ruby/core/true/singleton_method_spec.rb index 575c504b728da3..58689fb6e5a24a 100644 --- a/spec/ruby/core/true/singleton_method_spec.rb +++ b/spec/ruby/core/true/singleton_method_spec.rb @@ -2,10 +2,10 @@ describe "TrueClass#singleton_method" do it "raises regardless of whether TrueClass defines the method" do - -> { true.singleton_method(:foo) }.should raise_error(NameError) + -> { true.singleton_method(:foo) }.should.raise(NameError) begin def (true).foo; end - -> { true.singleton_method(:foo) }.should raise_error(NameError) + -> { true.singleton_method(:foo) }.should.raise(NameError) ensure TrueClass.send(:remove_method, :foo) end diff --git a/spec/ruby/core/true/to_s_spec.rb b/spec/ruby/core/true/to_s_spec.rb index fa1b53a580c4d7..2c6f3889e940e2 100644 --- a/spec/ruby/core/true/to_s_spec.rb +++ b/spec/ruby/core/true/to_s_spec.rb @@ -10,6 +10,6 @@ end it "always returns the same string" do - true.to_s.should equal(true.to_s) + true.to_s.should.equal?(true.to_s) end end diff --git a/spec/ruby/core/true/trueclass_spec.rb b/spec/ruby/core/true/trueclass_spec.rb index 02af649d0909a4..1c1a0ddbe27b00 100644 --- a/spec/ruby/core/true/trueclass_spec.rb +++ b/spec/ruby/core/true/trueclass_spec.rb @@ -4,12 +4,12 @@ it ".allocate raises a TypeError" do -> do TrueClass.allocate - end.should raise_error(TypeError) + end.should.raise(TypeError) end it ".new is undefined" do -> do TrueClass.new - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end end diff --git a/spec/ruby/core/unboundmethod/bind_call_spec.rb b/spec/ruby/core/unboundmethod/bind_call_spec.rb index 80b2095d8605d5..ee1dad9c9eff12 100644 --- a/spec/ruby/core/unboundmethod/bind_call_spec.rb +++ b/spec/ruby/core/unboundmethod/bind_call_spec.rb @@ -12,7 +12,7 @@ end it "raises TypeError if object is not kind_of? the Module the method defined in" do - -> { @normal_um.bind_call(UnboundMethodSpecs::B.new) }.should raise_error(TypeError) + -> { @normal_um.bind_call(UnboundMethodSpecs::B.new) }.should.raise(TypeError) end it "binds and calls the method if object is kind_of the Module the method defined in" do @@ -47,7 +47,7 @@ def singleton_method end end um = p.method(:singleton_method).unbind - ->{ um.bind_call(other) }.should raise_error(TypeError) + ->{ um.bind_call(other) }.should.raise(TypeError) end it "allows calling super for module methods bound to hierarchies that do not already have that module" do diff --git a/spec/ruby/core/unboundmethod/bind_spec.rb b/spec/ruby/core/unboundmethod/bind_spec.rb index 7658b664e53dae..087994ff572cbb 100644 --- a/spec/ruby/core/unboundmethod/bind_spec.rb +++ b/spec/ruby/core/unboundmethod/bind_spec.rb @@ -12,15 +12,15 @@ end it "raises TypeError if object is not kind_of? the Module the method defined in" do - -> { @normal_um.bind(UnboundMethodSpecs::B.new) }.should raise_error(TypeError) + -> { @normal_um.bind(UnboundMethodSpecs::B.new) }.should.raise(TypeError) end it "returns Method for any object that is kind_of? the Module method was extracted from" do - @normal_um.bind(UnboundMethodSpecs::Methods.new).should be_kind_of(Method) + @normal_um.bind(UnboundMethodSpecs::Methods.new).should.is_a?(Method) end it "returns Method on any object when UnboundMethod is unbound from a module" do - UnboundMethodSpecs::Mod.instance_method(:from_mod).bind(Object.new).should be_kind_of(Method) + UnboundMethodSpecs::Mod.instance_method(:from_mod).bind(Object.new).should.is_a?(Method) end it "the returned Method is equal to the one directly returned by obj.method" do @@ -29,9 +29,9 @@ end it "returns Method for any object kind_of? the Module the method is defined in" do - @parent_um.bind(UnboundMethodSpecs::Child1.new).should be_kind_of(Method) - @child1_um.bind(UnboundMethodSpecs::Parent.new).should be_kind_of(Method) - @child2_um.bind(UnboundMethodSpecs::Child1.new).should be_kind_of(Method) + @parent_um.bind(UnboundMethodSpecs::Child1.new).should.is_a?(Method) + @child1_um.bind(UnboundMethodSpecs::Parent.new).should.is_a?(Method) + @child2_um.bind(UnboundMethodSpecs::Child1.new).should.is_a?(Method) end it "allows binding a Kernel method retrieved from Object on BasicObject" do @@ -45,7 +45,7 @@ it "binds a Parent's class method to any Child's class methods" do m = UnboundMethodSpecs::Parent.method(:class_method).unbind.bind(UnboundMethodSpecs::Child1) - m.should be_an_instance_of(Method) + m.should.instance_of?(Method) m.call.should == "I am UnboundMethodSpecs::Child1" end @@ -58,7 +58,7 @@ def singleton_method end end um = p.method(:singleton_method).unbind - ->{ um.bind(other) }.should raise_error(TypeError) + ->{ um.bind(other) }.should.raise(TypeError) end it "allows calling super for module methods bound to hierarchies that do not already have that module" do diff --git a/spec/ruby/core/unboundmethod/equal_value_spec.rb b/spec/ruby/core/unboundmethod/equal_value_spec.rb index 2dcf08e155300f..24d5233299fc6a 100644 --- a/spec/ruby/core/unboundmethod/equal_value_spec.rb +++ b/spec/ruby/core/unboundmethod/equal_value_spec.rb @@ -3,8 +3,8 @@ context "Creating UnboundMethods" do specify "there is no difference between Method#unbind and Module#instance_method" do - UnboundMethodSpecs::Methods.instance_method(:foo).should be_kind_of(UnboundMethod) - UnboundMethodSpecs::Methods.new.method(:foo).unbind.should be_kind_of(UnboundMethod) + UnboundMethodSpecs::Methods.instance_method(:foo).should.is_a?(UnboundMethod) + UnboundMethodSpecs::Methods.new.method(:foo).unbind.should.is_a?(UnboundMethod) end end diff --git a/spec/ruby/core/unboundmethod/fixtures/classes.rb b/spec/ruby/core/unboundmethod/fixtures/classes.rb index bb3f7e08494279..58120c2f88afad 100644 --- a/spec/ruby/core/unboundmethod/fixtures/classes.rb +++ b/spec/ruby/core/unboundmethod/fixtures/classes.rb @@ -36,6 +36,7 @@ def with_block(&block); end alias bar foo alias baz bar + alias qux baz alias alias_1 foo alias alias_2 foo diff --git a/spec/ruby/core/unboundmethod/original_name_spec.rb b/spec/ruby/core/unboundmethod/original_name_spec.rb index 7280dcb2b49d38..fa9a6fcc637f50 100644 --- a/spec/ruby/core/unboundmethod/original_name_spec.rb +++ b/spec/ruby/core/unboundmethod/original_name_spec.rb @@ -19,4 +19,25 @@ obj.method(:baz).unbind.original_name.should == :foo UnboundMethodSpecs::Methods.instance_method(:baz).original_name.should == :foo end + + it "returns the original name even when aliased thrice" do + obj = UnboundMethodSpecs::Methods.new + obj.method(:qux).unbind.original_name.should == :foo + UnboundMethodSpecs::Methods.instance_method(:qux).original_name.should == :foo + end + + it "returns the source UnboundMethod's name (not the name given to define_method)" do + klass = Class.new { define_method(:my_inspect, ::Kernel.instance_method(:inspect)) } + klass.instance_method(:my_inspect).original_name.should == :inspect + end + + it "preserves the source method's name through define_method and alias" do + source = Class.new { def my_method; end } + klass = Class.new(source) do + define_method(:renamed, source.instance_method(:my_method)) + alias aliased renamed + end + klass.instance_method(:renamed).original_name.should == :my_method + klass.instance_method(:aliased).original_name.should == :my_method + end end diff --git a/spec/ruby/core/unboundmethod/shared/dup.rb b/spec/ruby/core/unboundmethod/shared/dup.rb index 194e2cc1a1841a..fd30f75c5bc180 100644 --- a/spec/ruby/core/unboundmethod/shared/dup.rb +++ b/spec/ruby/core/unboundmethod/shared/dup.rb @@ -4,7 +4,7 @@ b = a.send(@method) a.should == b - a.should_not equal(b) + a.should_not.equal?(b) end ruby_version_is "3.4" do diff --git a/spec/ruby/core/unboundmethod/shared/to_s.rb b/spec/ruby/core/unboundmethod/shared/to_s.rb index 6b2c9c3e793915..848c1eba2e30ce 100644 --- a/spec/ruby/core/unboundmethod/shared/to_s.rb +++ b/spec/ruby/core/unboundmethod/shared/to_s.rb @@ -8,8 +8,8 @@ end it "returns a String" do - @from_module.send(@method).should be_kind_of(String) - @from_method.send(@method).should be_kind_of(String) + @from_module.send(@method).should.is_a?(String) + @from_method.send(@method).should.is_a?(String) end it "the String reflects that this is an UnboundMethod object" do diff --git a/spec/ruby/core/unboundmethod/source_location_spec.rb b/spec/ruby/core/unboundmethod/source_location_spec.rb index 5c2f14362c40b4..927600bfcbef2d 100644 --- a/spec/ruby/core/unboundmethod/source_location_spec.rb +++ b/spec/ruby/core/unboundmethod/source_location_spec.rb @@ -8,13 +8,13 @@ it "sets the first value to the path of the file in which the method was defined" do file = @method.source_location.first - file.should be_an_instance_of(String) + file.should.instance_of?(String) file.should == File.realpath('fixtures/classes.rb', __dir__) end it "sets the last value to an Integer representing the line on which the method was defined" do line = @method.source_location.last - line.should be_an_instance_of(Integer) + line.should.instance_of?(Integer) line.should == 5 end diff --git a/spec/ruby/core/warning/element_reference_spec.rb b/spec/ruby/core/warning/element_reference_spec.rb index 6179c578646255..5f977759ecc622 100644 --- a/spec/ruby/core/warning/element_reference_spec.rb +++ b/spec/ruby/core/warning/element_reference_spec.rb @@ -16,12 +16,12 @@ end it "raises for unknown category" do - -> { Warning[:noop] }.should raise_error(ArgumentError, /unknown category: noop/) + -> { Warning[:noop] }.should.raise(ArgumentError, /unknown category: noop/) end it "raises for non-Symbol category" do - -> { Warning[42] }.should raise_error(TypeError) - -> { Warning[false] }.should raise_error(TypeError) - -> { Warning["noop"] }.should raise_error(TypeError) + -> { Warning[42] }.should.raise(TypeError) + -> { Warning[false] }.should.raise(TypeError) + -> { Warning["noop"] }.should.raise(TypeError) end end diff --git a/spec/ruby/core/warning/element_set_spec.rb b/spec/ruby/core/warning/element_set_spec.rb index 1dbc66ce26cae9..3c8ceb721e8ffd 100644 --- a/spec/ruby/core/warning/element_set_spec.rb +++ b/spec/ruby/core/warning/element_set_spec.rb @@ -28,12 +28,12 @@ end it "raises for unknown category" do - -> { Warning[:noop] = false }.should raise_error(ArgumentError, /unknown category: noop/) + -> { Warning[:noop] = false }.should.raise(ArgumentError, /unknown category: noop/) end it "raises for non-Symbol category" do - -> { Warning[42] = false }.should raise_error(TypeError) - -> { Warning[false] = false }.should raise_error(TypeError) - -> { Warning["noop"] = false }.should raise_error(TypeError) + -> { Warning[42] = false }.should.raise(TypeError) + -> { Warning[false] = false }.should.raise(TypeError) + -> { Warning["noop"] = false }.should.raise(TypeError) end end diff --git a/spec/ruby/core/warning/warn_spec.rb b/spec/ruby/core/warning/warn_spec.rb index 2e4a822e026d72..62f36e34547941 100644 --- a/spec/ruby/core/warning/warn_spec.rb +++ b/spec/ruby/core/warning/warn_spec.rb @@ -16,7 +16,7 @@ end it "extends itself" do - Warning.singleton_class.ancestors.should include(Warning) + Warning.singleton_class.ancestors.should.include?(Warning) end it "has Warning as the method owner" do diff --git a/spec/ruby/language/BEGIN_spec.rb b/spec/ruby/language/BEGIN_spec.rb index 5aef5a1d7cc5d2..25db32b96ac938 100644 --- a/spec/ruby/language/BEGIN_spec.rb +++ b/spec/ruby/language/BEGIN_spec.rb @@ -15,7 +15,7 @@ end it "must appear in a top-level context" do - -> { eval "1.times { BEGIN { 1 } }" }.should raise_error(SyntaxError) + -> { eval "1.times { BEGIN { 1 } }" }.should.raise(SyntaxError) end it "uses top-level for self" do diff --git a/spec/ruby/language/alias_spec.rb b/spec/ruby/language/alias_spec.rb index 61fddb0184962b..4b3d36d3085239 100644 --- a/spec/ruby/language/alias_spec.rb +++ b/spec/ruby/language/alias_spec.rb @@ -140,7 +140,7 @@ def self.klass_method; 7; end end @obj.__value.should == 5 - -> { AliasObject.new.__value }.should raise_error(NoMethodError) + -> { AliasObject.new.__value }.should.raise(NoMethodError) end it "operates on the class/module metaclass when used in instance_eval" do @@ -149,7 +149,7 @@ def self.klass_method; 7; end end AliasObject.__klass_method.should == 7 - -> { Object.__klass_method }.should raise_error(NoMethodError) + -> { Object.__klass_method }.should.raise(NoMethodError) end it "operates on the class/module metaclass when used in instance_exec" do @@ -158,7 +158,7 @@ def self.klass_method; 7; end end AliasObject.__klass_method2.should == 7 - -> { Object.__klass_method2 }.should raise_error(NoMethodError) + -> { Object.__klass_method2 }.should.raise(NoMethodError) end it "operates on methods defined via attr, attr_reader, and attr_accessor" do @@ -241,13 +241,13 @@ def test_with_check(*args) 1.instance_eval do alias :foo :to_s end - end.should raise_error(TypeError) + end.should.raise(TypeError) -> do :blah.instance_eval do alias :foo :to_s end - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "on top level defines the alias on Object" do @@ -256,7 +256,7 @@ def test_with_check(*args) end it "raises a NameError when passed a missing name" do - -> { @meta.class_eval { alias undef_method not_exist } }.should raise_error(NameError) { |e| + -> { @meta.class_eval { alias undef_method not_exist } }.should.raise(NameError) { |e| # a NameError and not a NoMethodError e.class.should == NameError } @@ -272,7 +272,7 @@ def parent_method end child.instance_method(:parent_method_alias).owner.should == child - child.instance_methods(false).should include(:parent_method_alias) + child.instance_methods(false).should.include?(:parent_method_alias) end end diff --git a/spec/ruby/language/and_spec.rb b/spec/ruby/language/and_spec.rb index 55a2a3103a1967..c5c255989b74a8 100644 --- a/spec/ruby/language/and_spec.rb +++ b/spec/ruby/language/and_spec.rb @@ -5,7 +5,7 @@ it "short-circuits evaluation at the first condition to be false" do x = nil true && false && x = 1 - x.should be_nil + x.should == nil end it "evaluates to the first condition not to be true" do @@ -33,9 +33,9 @@ end it "treats empty expressions as nil" do - (() && true).should be_nil - (true && ()).should be_nil - (() && ()).should be_nil + (() && true).should == nil + (true && ()).should == nil + (() && ()).should == nil end end @@ -44,7 +44,7 @@ it "short-circuits evaluation at the first condition to be false" do x = nil true and false and x = 1 - x.should be_nil + x.should == nil end it "evaluates to the first condition not to be true" do @@ -72,9 +72,9 @@ end it "treats empty expressions as nil" do - (() and true).should be_nil - (true and ()).should be_nil - (() and ()).should be_nil + (() and true).should == nil + (true and ()).should == nil + (() and ()).should == nil end end diff --git a/spec/ruby/language/array_spec.rb b/spec/ruby/language/array_spec.rb index 2583cffbf70e57..3601eb0e00ba21 100644 --- a/spec/ruby/language/array_spec.rb +++ b/spec/ruby/language/array_spec.rb @@ -4,7 +4,7 @@ describe "Array literals" do it "[] should return a new array populated with the given elements" do array = [1, 'a', nil] - array.should be_kind_of(Array) + array.should.is_a?(Array) array[0].should == 1 array[1].should == 'a' array[2].should == nil @@ -12,7 +12,7 @@ it "[] treats empty expressions as nil elements" do array = [0, (), 2, (), 4] - array.should be_kind_of(Array) + array.should.is_a?(Array) array[0].should == 0 array[1].should == nil array[2].should == 2 @@ -89,7 +89,7 @@ it "returns a new array containing the same values when applied to an array inside an empty array" do splatted_array = [3, 4, 5] [*splatted_array].should == splatted_array - [*splatted_array].should_not equal(splatted_array) + [*splatted_array].should_not.equal?(splatted_array) end it "unpacks the start and count arguments in an array slice assignment" do @@ -135,7 +135,7 @@ it "when applied to a non-Array value uses it unchanged if it does not respond_to?(:to_a)" do obj = Object.new - obj.should_not respond_to(:to_a) + obj.should_not.respond_to?(:to_a) [1, *obj].should == [1, obj] end diff --git a/spec/ruby/language/assignments_spec.rb b/spec/ruby/language/assignments_spec.rb index 58a244b7c27d87..d621c9f0c62c1e 100644 --- a/spec/ruby/language/assignments_spec.rb +++ b/spec/ruby/language/assignments_spec.rb @@ -36,7 +36,7 @@ def object.[]=(_, _) end -> { (:not_a_module)::A = (ScratchPad << :rhs; :value) - }.should raise_error(TypeError) + }.should.raise(TypeError) ScratchPad.recorded.should == [:rhs] end @@ -68,7 +68,7 @@ def []=(k, v, &block) @h[k] = v; end -> { eval "obj[:a, &block] = 2" - }.should raise_error(SyntaxError, /unexpected block arg given in index assignment|block arg given in index assignment/) + }.should.raise(SyntaxError, /unexpected block arg given in index assignment|block arg given in index assignment/) end end end @@ -95,7 +95,7 @@ def []=(*args, **kw) ruby_version_is "3.4" do it "raises SyntaxError when given keyword arguments in index assignments" do a = @klass.new - -> { eval "a[1, 2, 3, b: 4] = 5" }.should raise_error(SyntaxError, + -> { eval "a[1, 2, 3, b: 4] = 5" }.should.raise(SyntaxError, /keywords are not allowed in index assignment expressions|keyword arg given in index assignment/) # prism|parse.y end end @@ -199,7 +199,7 @@ def []=(k, v, &block) @h[k] = v; end -> { eval "obj[:a, &block] += 2" - }.should raise_error(SyntaxError, /unexpected block arg given in index assignment|block arg given in index assignment/) + }.should.raise(SyntaxError, /unexpected block arg given in index assignment|block arg given in index assignment/) end end end @@ -230,7 +230,7 @@ def []=(*args, **kw) ruby_version_is "3.4" do it "raises SyntaxError when given keyword arguments in index assignments" do a = @klass.new - -> { eval "a[1, 2, 3, b: 4] += 5" }.should raise_error(SyntaxError, + -> { eval "a[1, 2, 3, b: 4] += 5" }.should.raise(SyntaxError, /keywords are not allowed in index assignment expressions|keyword arg given in index assignment/) # prism|parse.y end end diff --git a/spec/ruby/language/block_spec.rb b/spec/ruby/language/block_spec.rb index ad6f7190b43f5e..5bdb993aea6249 100644 --- a/spec/ruby/language/block_spec.rb +++ b/spec/ruby/language/block_spec.rb @@ -13,7 +13,7 @@ def m(a) yield a end it "receives the identical Array object" do ary = [1, 2] - m(ary) { |a| a }.should equal(ary) + m(ary) { |a| a }.should.equal?(ary) end it "assigns the Array to a single rest argument" do @@ -73,7 +73,7 @@ def m(a) yield a end it "raises error when required keyword arguments are present" do -> { m([1, 2]) { |a, b:, c:| [a, b, c] } - }.should raise_error(ArgumentError, "missing keywords: :b, :c") + }.should.raise(ArgumentError, "missing keywords: :b, :c") end it "assigns elements to mixed argument types" do @@ -234,14 +234,14 @@ def obj.respond_to_missing?(name, include_private) obj = mock("destructure block arguments") obj.should_receive(:to_ary).and_return(1) - -> { m(obj) { |a, b| } }.should raise_error(TypeError) + -> { m(obj) { |a, b| } }.should.raise(TypeError) end it "raises error transparently if #to_ary raises error on its own" do obj = Object.new def obj.to_ary; raise "Exception raised in #to_ary" end - -> { m(obj) { |a, b| } }.should raise_error(RuntimeError, "Exception raised in #to_ary") + -> { m(obj) { |a, b| } }.should.raise(RuntimeError, "Exception raised in #to_ary") end end end @@ -311,7 +311,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end describe "taking |a| arguments" do it "assigns nil to the argument when no values are yielded" do - @y.z { |a| a }.should be_nil + @y.z { |a| a }.should == nil end it "assigns the value yielded to the argument" do @@ -322,7 +322,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end obj = mock("block yield to_ary") obj.should_not_receive(:to_ary) - @y.s(obj) { |a| a }.should equal(obj) + @y.s(obj) { |a| a }.should.equal?(obj) end it "assigns the first value yielded to the argument" do @@ -398,14 +398,14 @@ def obj.to_ary; raise "Exception raised in #to_ary" end obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - -> { @y.s(obj) { |a, b| } }.should raise_error(TypeError) + -> { @y.s(obj) { |a, b| } }.should.raise(TypeError) end it "raises the original exception if #to_ary raises an exception" do obj = mock("block yield to_ary raising an exception") obj.should_receive(:to_ary).and_raise(ZeroDivisionError) - -> { @y.s(obj) { |a, b| } }.should raise_error(ZeroDivisionError) + -> { @y.s(obj) { |a, b| } }.should.raise(ZeroDivisionError) end end @@ -461,7 +461,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - -> { @y.s(obj) { |a, *b| } }.should raise_error(TypeError) + -> { @y.s(obj) { |a, *b| } }.should.raise(TypeError) end end @@ -539,7 +539,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end describe "taking |a, | arguments" do it "assigns nil to the argument when no values are yielded" do - @y.z { |a, | a }.should be_nil + @y.z { |a, | a }.should == nil end it "assigns the argument a single value yielded" do @@ -555,7 +555,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end end it "assigns nil to the argument when passed an empty Array" do - @y.s([]) { |a, | a }.should be_nil + @y.s([]) { |a, | a }.should == nil end it "assigns the argument the first element of the Array when passed a single Array" do @@ -586,7 +586,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - -> { @y.s(obj) { |a, | } }.should raise_error(TypeError) + -> { @y.s(obj) { |a, | } }.should.raise(TypeError) end end @@ -628,7 +628,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - -> { @y.s(obj) { |(a, b)| } }.should raise_error(TypeError) + -> { @y.s(obj) { |(a, b)| } }.should.raise(TypeError) end end @@ -669,7 +669,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - -> { @y.s(obj) { |(a, b), c| } }.should raise_error(TypeError) + -> { @y.s(obj) { |(a, b), c| } }.should.raise(TypeError) end end @@ -728,15 +728,15 @@ def obj.to_ary; raise "Exception raised in #to_ary" end describe "taking identically-named arguments" do it "raises a SyntaxError for standard arguments" do - -> { eval "lambda { |x,x| }" }.should raise_error(SyntaxError) - -> { eval "->(x,x) {}" }.should raise_error(SyntaxError) - -> { eval "Proc.new { |x,x| }" }.should raise_error(SyntaxError) + -> { eval "lambda { |x,x| }" }.should.raise(SyntaxError) + -> { eval "->(x,x) {}" }.should.raise(SyntaxError) + -> { eval "Proc.new { |x,x| }" }.should.raise(SyntaxError) end it "accepts unnamed arguments" do - lambda { |_,_| }.should be_an_instance_of(Proc) # rubocop:disable Style/Lambda - -> _,_ {}.should be_an_instance_of(Proc) - Proc.new { |_,_| }.should be_an_instance_of(Proc) + lambda { |_,_| }.should.instance_of?(Proc) # rubocop:disable Style/Lambda + -> _,_ {}.should.instance_of?(Proc) + Proc.new { |_,_| }.should.instance_of?(Proc) end end @@ -787,29 +787,29 @@ def obj.to_ary; raise "Exception raised in #to_ary" end end it "can not have the same name as one of the standard parameters" do - -> { eval "[1].each {|foo; foo| }" }.should raise_error(SyntaxError) - -> { eval "[1].each {|foo, bar; glark, bar| }" }.should raise_error(SyntaxError) + -> { eval "[1].each {|foo; foo| }" }.should.raise(SyntaxError) + -> { eval "[1].each {|foo, bar; glark, bar| }" }.should.raise(SyntaxError) end it "can not be prefixed with an asterisk" do - -> { eval "[1].each {|foo; *bar| }" }.should raise_error(SyntaxError) + -> { eval "[1].each {|foo; *bar| }" }.should.raise(SyntaxError) -> do eval "[1].each {|foo, bar; glark, *fnord| }" - end.should raise_error(SyntaxError) + end.should.raise(SyntaxError) end it "can not be prefixed with an ampersand" do - -> { eval "[1].each {|foo; &bar| }" }.should raise_error(SyntaxError) + -> { eval "[1].each {|foo; &bar| }" }.should.raise(SyntaxError) -> do eval "[1].each {|foo, bar; glark, &fnord| }" - end.should raise_error(SyntaxError) + end.should.raise(SyntaxError) end it "can not be assigned default values" do - -> { eval "[1].each {|foo; bar=1| }" }.should raise_error(SyntaxError) + -> { eval "[1].each {|foo; bar=1| }" }.should.raise(SyntaxError) -> do eval "[1].each {|foo, bar; glark, fnord=:fnord| }" - end.should raise_error(SyntaxError) + end.should.raise(SyntaxError) end it "need not be preceded by standard parameters" do @@ -818,8 +818,8 @@ def obj.to_ary; raise "Exception raised in #to_ary" end end it "only allow a single semi-colon in the parameter list" do - -> { eval "[1].each {|foo; bar; glark| }" }.should raise_error(SyntaxError) - -> { eval "[1].each {|; bar; glark| }" }.should raise_error(SyntaxError) + -> { eval "[1].each {|foo; bar; glark| }" }.should.raise(SyntaxError) + -> { eval "[1].each {|; bar; glark| }" }.should.raise(SyntaxError) end it "override shadowed variables from the outer scope" do @@ -844,21 +844,21 @@ def obj.to_ary; raise "Exception raised in #to_ary" end end it "are not automatically instantiated in the outer scope" do - defined?(glark).should be_nil + defined?(glark).should == nil [1].each {|;glark| 1} - defined?(glark).should be_nil + defined?(glark).should == nil end it "are automatically instantiated in the block" do [1].each do |;glark| - glark.should be_nil + glark.should == nil end end it "are visible in deeper scopes before initialization" do [1].each {|;glark| [1].each { - defined?(glark).should_not be_nil + defined?(glark).should_not == nil glark = 1 } glark.should == 1 @@ -886,7 +886,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end -> *a, b do [a, b] end.call - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "are assigned to nil when not enough arguments are given to a proc" do @@ -962,7 +962,7 @@ def obj.to_ary; raise "Exception raised in #to_ary" end a = 1 -> { eval "proc { |a=a| a }" - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end end @@ -1006,7 +1006,7 @@ def c(&); yield :non_null end end it "requires the anonymous block parameter to be declared if directly passing a block" do - -> { eval "def a; b(&); end; def b; end" }.should raise_error(SyntaxError) + -> { eval "def a; b(&); end; def b; end" }.should.raise(SyntaxError) end it "works when it's the only declared parameter" do @@ -1118,7 +1118,7 @@ def o.it EOF no_block.call(:a).should == :a - -> { no_block.call(:a) {} }.should raise_error(ArgumentError, 'no block accepted') + -> { no_block.call(:a) {} }.should.raise(ArgumentError, 'no block accepted') end end end @@ -1136,3 +1136,13 @@ def o.it proc { it = 5; it }.call(0).should == 5 end end + +describe "Block-parameter destructuring" do + it "does not warn about unused inner names in verbose mode" do + -> { + eval <<~RUBY, binding, __FILE__, __LINE__ + 1 + proc { |key, (val1, val2)| [key, val2] } + RUBY + }.should_not complain(verbose: true) + end +end diff --git a/spec/ruby/language/break_spec.rb b/spec/ruby/language/break_spec.rb index 7e5b6fb32859c2..5c9b8060c358c7 100644 --- a/spec/ruby/language/break_spec.rb +++ b/spec/ruby/language/break_spec.rb @@ -52,29 +52,29 @@ describe "when the invocation of the scope creating the block is still active" do it "raises a LocalJumpError when invoking the block from the scope creating the block" do - -> { @program.break_in_method }.should raise_error(LocalJumpError) + -> { @program.break_in_method }.should.raise(LocalJumpError) ScratchPad.recorded.should == [:a, :xa, :d, :b] end it "raises a LocalJumpError when invoking the block from a method" do - -> { @program.break_in_nested_method }.should raise_error(LocalJumpError) + -> { @program.break_in_nested_method }.should.raise(LocalJumpError) ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b] end it "raises a LocalJumpError when yielding to the block" do - -> { @program.break_in_yielding_method }.should raise_error(LocalJumpError) + -> { @program.break_in_yielding_method }.should.raise(LocalJumpError) ScratchPad.recorded.should == [:a, :xa, :cc, :aa, :b] end end describe "from a scope that has returned" do it "raises a LocalJumpError when calling the block from a method" do - -> { @program.break_in_method_captured }.should raise_error(LocalJumpError) + -> { @program.break_in_method_captured }.should.raise(LocalJumpError) ScratchPad.recorded.should == [:a, :za, :xa, :zd, :zb] end it "raises a LocalJumpError when yielding to the block" do - -> { @program.break_in_yield_captured }.should raise_error(LocalJumpError) + -> { @program.break_in_yield_captured }.should.raise(LocalJumpError) ScratchPad.recorded.should == [:a, :za, :xa, :zd, :aa, :zb] end end @@ -88,7 +88,7 @@ e end end - thread_with_break.value.should be_an_instance_of(LocalJumpError) + thread_with_break.value.should.instance_of?(LocalJumpError) end end end @@ -256,7 +256,7 @@ def mid(&b) it "is invalid and raises a SyntaxError" do -> { eval("def m; break; end") - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end end @@ -268,7 +268,7 @@ module BreakSpecs:ModuleWithBreak end RUBY - -> { eval(code) }.should raise_error(SyntaxError) + -> { eval(code) }.should.raise(SyntaxError) end end @@ -388,7 +388,7 @@ def three -> do cls2.new.foo.should == 1 - end.should_not raise_error + end.should_not.raise end it "raises LocalJumpError when converted into a proc during a super call" do @@ -397,6 +397,6 @@ def three -> do cls2.new.foo - end.should raise_error(LocalJumpError) + end.should.raise(LocalJumpError) end end diff --git a/spec/ruby/language/case_spec.rb b/spec/ruby/language/case_spec.rb index 464d06e46a4b25..8355062e446327 100644 --- a/spec/ruby/language/case_spec.rb +++ b/spec/ruby/language/case_spec.rb @@ -94,12 +94,12 @@ def bar; @calls << :bar; end it "tests with matching regexps and sets $~ and captures" do case "foo42" when /oo(\d+)/ - $~.should be_kind_of(MatchData) + $~.should.is_a?(MatchData) $1.should == "42" else flunk end - $~.should be_kind_of(MatchData) + $~.should.is_a?(MatchData) $1.should == "42" end @@ -107,12 +107,12 @@ def bar; @calls << :bar; end digits = '\d+' case "foo44" when /oo(#{digits})/ - $~.should be_kind_of(MatchData) + $~.should.is_a?(MatchData) $1.should == "44" else flunk end - $~.should be_kind_of(MatchData) + $~.should.is_a?(MatchData) $1.should == "44" end @@ -120,12 +120,12 @@ def bar; @calls << :bar; end digits_regexp = /\d+/ case "foo43" when /oo(#{digits_regexp})/ - $~.should be_kind_of(MatchData) + $~.should.is_a?(MatchData) $1.should == "43" else flunk end - $~.should be_kind_of(MatchData) + $~.should.is_a?(MatchData) $1.should == "43" end @@ -268,7 +268,7 @@ def bar; @calls << :bar; end true end CODE - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "raises a SyntaxError when 'else' is used before a 'when' was given" do @@ -280,7 +280,7 @@ def bar; @calls << :bar; end when 4; false end CODE - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "supports nested case statements" do diff --git a/spec/ruby/language/class_spec.rb b/spec/ruby/language/class_spec.rb index 6fb785fd568d6a..7ea485751447b6 100644 --- a/spec/ruby/language/class_spec.rb +++ b/spec/ruby/language/class_spec.rb @@ -10,23 +10,23 @@ module ClassSpecs describe "The class keyword" do it "creates a new class with semicolon" do class ClassSpecsKeywordWithSemicolon; end - ClassSpecsKeywordWithSemicolon.should be_an_instance_of(Class) + ClassSpecsKeywordWithSemicolon.should.instance_of?(Class) end it "does not raise a SyntaxError when opening a class without a semicolon" do eval "class ClassSpecsKeywordWithoutSemicolon end" - ClassSpecsKeywordWithoutSemicolon.should be_an_instance_of(Class) + ClassSpecsKeywordWithoutSemicolon.should.instance_of?(Class) end it "can redefine a class when called from a block" do ClassSpecs::DEFINE_CLASS.call - A.should be_an_instance_of(Class) + A.should.instance_of?(Class) Object.send(:remove_const, :A) - defined?(A).should be_nil + defined?(A).should == nil ClassSpecs::DEFINE_CLASS.call - A.should be_an_instance_of(Class) + A.should.instance_of?(Class) ensure Object.send(:remove_const, :A) if defined?(::A) end @@ -34,8 +34,8 @@ class ClassSpecsKeywordWithSemicolon; end describe "A class definition" do it "creates a new class" do - ClassSpecs::A.should be_kind_of(Class) - ClassSpecs::A.new.should be_kind_of(ClassSpecs::A) + ClassSpecs::A.should.is_a?(Class) + ClassSpecs::A.new.should.is_a?(ClassSpecs::A) end it "has no class variables" do @@ -46,14 +46,14 @@ class ClassSpecsKeywordWithSemicolon; end -> { class ClassSpecsNumber end - }.should raise_error(TypeError, /\AClassSpecsNumber is not a class/) + }.should.raise(TypeError, /\AClassSpecsNumber is not a class/) end it "raises TypeError if constant given as class name exists and is a Module but not a Class" do -> { class ClassSpecs end - }.should raise_error(TypeError, /\AClassSpecs is not a class/) + }.should.raise(TypeError, /\AClassSpecs is not a class/) end # test case known to be detecting bugs (JRuby, MRI) @@ -61,19 +61,19 @@ class ClassSpecs -> { class nil::Foo end - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises TypeError if any constant qualifying the class is not a Module" do -> { class ClassSpecs::Number::MyClass end - }.should raise_error(TypeError) + }.should.raise(TypeError) -> { class ClassSpecsNumber::MyClass end - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "inherits from Object by default" do @@ -87,7 +87,7 @@ class SuperclassResetToSubclass < L -> { class SuperclassResetToSubclass < M end - }.should raise_error(TypeError, /superclass mismatch/) + }.should.raise(TypeError, /superclass mismatch/) end end @@ -100,7 +100,7 @@ class SuperclassReopenedBasicObject < A -> { class SuperclassReopenedBasicObject < BasicObject end - }.should raise_error(TypeError, /superclass mismatch/) + }.should.raise(TypeError, /superclass mismatch/) SuperclassReopenedBasicObject.superclass.should == A end end @@ -115,7 +115,7 @@ class SuperclassReopenedObject < A -> { class SuperclassReopenedObject < Object end - }.should raise_error(TypeError, /superclass mismatch/) + }.should.raise(TypeError, /superclass mismatch/) SuperclassReopenedObject.superclass.should == A end end @@ -140,7 +140,7 @@ class NoSuperclassSet -> { class NoSuperclassSet < String end - }.should raise_error(TypeError, /superclass mismatch/) + }.should.raise(TypeError, /superclass mismatch/) end end @@ -149,7 +149,7 @@ class NoSuperclassSet < String -> { class ShouldNotWork < self; end - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "first evaluates the superclass before checking if the class already exists" do @@ -168,7 +168,7 @@ class SuperclassEvaluatedFirst < remove_const(:SuperclassEvaluatedFirst) it "raises a TypeError if inheriting from a metaclass" do obj = mock("metaclass super") meta = obj.singleton_class - -> { class ClassSpecs::MetaclassSuper < meta; end }.should raise_error(TypeError) + -> { class ClassSpecs::MetaclassSuper < meta; end }.should.raise(TypeError) end it "allows the declaration of class variables in the body" do @@ -177,7 +177,7 @@ class SuperclassEvaluatedFirst < remove_const(:SuperclassEvaluatedFirst) end it "stores instance variables defined in the class body in the class object" do - ClassSpecs.string_instance_variables(ClassSpecs::B).should include("@ivar") + ClassSpecs.string_instance_variables(ClassSpecs::B).should.include?("@ivar") ClassSpecs::B.instance_variable_get(:@ivar).should == :ivar end @@ -189,9 +189,9 @@ class SuperclassEvaluatedFirst < remove_const(:SuperclassEvaluatedFirst) end it "allows the definition of class-level instance variables in a class method" do - ClassSpecs.string_instance_variables(ClassSpecs::C).should_not include("@civ") + ClassSpecs.string_instance_variables(ClassSpecs::C).should_not.include?("@civ") ClassSpecs::C.make_class_instance_variable - ClassSpecs.string_instance_variables(ClassSpecs::C).should include("@civ") + ClassSpecs.string_instance_variables(ClassSpecs::C).should.include?("@civ") ClassSpecs::C.remove_instance_variable :@civ end @@ -286,7 +286,8 @@ def self.get_class_name describe "An outer class definition" do it "contains the inner classes" do - ClassSpecs::Container.constants.should include(:A, :B) + ClassSpecs::Container.constants.should.include?(:A) + ClassSpecs::Container.constants.should.include?(:B) end end @@ -304,23 +305,23 @@ def xyz end end CODE - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a TypeError when trying to extend non-Class" do error_msg = /superclass must be a.* Class/ - -> { class TestClass < ""; end }.should raise_error(TypeError, error_msg) - -> { class TestClass < 1; end }.should raise_error(TypeError, error_msg) - -> { class TestClass < :symbol; end }.should raise_error(TypeError, error_msg) - -> { class TestClass < mock('o'); end }.should raise_error(TypeError, error_msg) - -> { class TestClass < Module.new; end }.should raise_error(TypeError, error_msg) - -> { class TestClass < BasicObject.new; end }.should raise_error(TypeError, error_msg) + -> { class TestClass < ""; end }.should.raise(TypeError, error_msg) + -> { class TestClass < 1; end }.should.raise(TypeError, error_msg) + -> { class TestClass < :symbol; end }.should.raise(TypeError, error_msg) + -> { class TestClass < mock('o'); end }.should.raise(TypeError, error_msg) + -> { class TestClass < Module.new; end }.should.raise(TypeError, error_msg) + -> { class TestClass < BasicObject.new; end }.should.raise(TypeError, error_msg) end it "does not allow accessing the block of the original scope" do -> { ClassSpecs.sclass_with_block { 123 } - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "can use return to cause the enclosing method to return" do @@ -340,11 +341,11 @@ def xyz end it "raises a TypeError when superclasses mismatch" do - -> { class ClassSpecs::A < Array; end }.should raise_error(TypeError) + -> { class ClassSpecs::A < Array; end }.should.raise(TypeError) end it "adds new methods to subclasses" do - -> { ClassSpecs::M.m }.should raise_error(NoMethodError) + -> { ClassSpecs::M.m }.should.raise(NoMethodError) class ClassSpecs::L def self.m 1 diff --git a/spec/ruby/language/class_variable_spec.rb b/spec/ruby/language/class_variable_spec.rb index a26a3fb8deb811..84a7684c6da137 100644 --- a/spec/ruby/language/class_variable_spec.rb +++ b/spec/ruby/language/class_variable_spec.rb @@ -30,19 +30,19 @@ end it "is not defined in these classes" do - ClassVariablesSpec::ClassC.cvar_defined?.should be_false + ClassVariablesSpec::ClassC.cvar_defined?.should == false end it "is only updated in the module a method defined in the module is used" do ClassVariablesSpec::ClassC.cvar_m = "new value" ClassVariablesSpec::ClassC.cvar_m.should == "new value" - ClassVariablesSpec::ClassC.cvar_defined?.should be_false + ClassVariablesSpec::ClassC.cvar_defined?.should == false end it "is updated in the class when a Method defined in the class is used" do ClassVariablesSpec::ClassC.cvar_c = "new value" - ClassVariablesSpec::ClassC.cvar_defined?.should be_true + ClassVariablesSpec::ClassC.cvar_defined?.should == true end it "can be accessed inside the class using the module methods" do @@ -55,11 +55,11 @@ end it "is defined in the extended module" do - ClassVariablesSpec::ModuleN.class_variable_defined?(:@@cvar_n).should be_true + ClassVariablesSpec::ModuleN.class_variable_defined?(:@@cvar_n).should == true end it "is not defined in the extending module" do - ClassVariablesSpec::ModuleO.class_variable_defined?(:@@cvar_n).should be_false + ClassVariablesSpec::ModuleO.class_variable_defined?(:@@cvar_n).should == false end end @@ -70,14 +70,14 @@ c = Class.new(b) b.class_variable_set(:@@cv, :value) - -> { a.class_variable_get(:@@cv) }.should raise_error(NameError) + -> { a.class_variable_get(:@@cv) }.should.raise(NameError) b.class_variable_get(:@@cv).should == :value c.class_variable_get(:@@cv).should == :value # updates the same variable c.class_variable_set(:@@cv, :next) - -> { a.class_variable_get(:@@cv) }.should raise_error(NameError) + -> { a.class_variable_get(:@@cv) }.should.raise(NameError) b.class_variable_get(:@@cv).should == :next c.class_variable_get(:@@cv).should == :next end @@ -87,16 +87,16 @@ it "raises a RuntimeError when accessed from the toplevel scope (not in some module or class)" do -> { eval "@@cvar_toplevel1" - }.should raise_error(RuntimeError, 'class variable access from toplevel') + }.should.raise(RuntimeError, 'class variable access from toplevel') -> { eval "@@cvar_toplevel2 = 2" - }.should raise_error(RuntimeError, 'class variable access from toplevel') + }.should.raise(RuntimeError, 'class variable access from toplevel') end it "does not raise an error when checking if defined from the toplevel scope" do -> { eval "defined?(@@cvar_toplevel1)" - }.should_not raise_error + }.should_not.raise end it "raises a RuntimeError when a class variable is overtaken in an ancestor class" do @@ -107,7 +107,7 @@ -> { subclass.class_variable_get(:@@cvar_overtaken) - }.should raise_error(RuntimeError, /class variable @@cvar_overtaken of .+ is overtaken by .+/) + }.should.raise(RuntimeError, /class variable @@cvar_overtaken of .+ is overtaken by .+/) parent.class_variable_get(:@@cvar_overtaken).should == :parent end diff --git a/spec/ruby/language/constants_spec.rb b/spec/ruby/language/constants_spec.rb index 063c52c4226d57..0880230a36d689 100644 --- a/spec/ruby/language/constants_spec.rb +++ b/spec/ruby/language/constants_spec.rb @@ -51,8 +51,8 @@ module ConstantSpecs::SpecAdded1 it "does not search the singleton class of the class or module" do -> do ConstantSpecs::ContainerA::ChildA::CS_CONST14 - end.should raise_error(NameError) - -> { ConstantSpecs::CS_CONST14 }.should raise_error(NameError) + end.should.raise(NameError) + -> { ConstantSpecs::CS_CONST14 }.should.raise(NameError) end end @@ -135,7 +135,7 @@ class << ConstantSpecs::ContainerB::ChildB -> do ConstantSpecs::ContainerB::ChildB::CS_CONST108 - end.should raise_error(NameError) + end.should.raise(NameError) module ConstantSpecs class << self @@ -143,7 +143,7 @@ class << self end end - -> { ConstantSpecs::CS_CONST108 }.should raise_error(NameError) + -> { ConstantSpecs::CS_CONST108 }.should.raise(NameError) ensure ConstantSpecs::ContainerB::ChildB.singleton_class.send(:remove_const, :CS_CONST108) ConstantSpecs.singleton_class.send(:remove_const, :CS_CONST108) @@ -175,7 +175,7 @@ class << self end it "raises a NameError if no constant is defined in the search path" do - -> { ConstantSpecs::ParentA::CS_CONSTX }.should raise_error(NameError) + -> { ConstantSpecs::ParentA::CS_CONSTX }.should.raise(NameError) end it "uses the module or class #name to craft the error message" do @@ -189,7 +189,7 @@ def self.inspect end end - -> { mod::DOES_NOT_EXIST }.should raise_error(NameError, /uninitialized constant ModuleName::DOES_NOT_EXIST/) + -> { mod::DOES_NOT_EXIST }.should.raise(NameError, /uninitialized constant ModuleName::DOES_NOT_EXIST/) end it "uses the module or class #inspect to craft the error message if they are anonymous" do @@ -203,7 +203,7 @@ def self.inspect end end - -> { mod::DOES_NOT_EXIST }.should raise_error(NameError, /uninitialized constant ::DOES_NOT_EXIST/) + -> { mod::DOES_NOT_EXIST }.should.raise(NameError, /uninitialized constant ::DOES_NOT_EXIST/) end it "sends #const_missing to the original class or module scope" do @@ -215,10 +215,10 @@ def self.inspect end it "raises a TypeError if a non-class or non-module qualifier is given" do - -> { CS_CONST1::CS_CONST }.should raise_error(TypeError) - -> { 1::CS_CONST }.should raise_error(TypeError) - -> { "mod"::CS_CONST }.should raise_error(TypeError) - -> { false::CS_CONST }.should raise_error(TypeError) + -> { CS_CONST1::CS_CONST }.should.raise(TypeError) + -> { 1::CS_CONST }.should.raise(TypeError) + -> { "mod"::CS_CONST }.should.raise(TypeError) + -> { false::CS_CONST }.should.raise(TypeError) end end @@ -264,7 +264,7 @@ def self.inspect end it "does not search the lexical scope of the caller" do - -> { ConstantSpecs::ClassA.const16 }.should raise_error(NameError) + -> { ConstantSpecs::ClassA.const16 }.should.raise(NameError) end it "searches the lexical scope of a block" do @@ -279,7 +279,7 @@ def self.inspect it "does not search the lexical scope of qualifying modules" do -> do ConstantSpecs::ContainerA::ChildA.const23 - end.should raise_error(NameError) + end.should.raise(NameError) end end @@ -377,7 +377,7 @@ class << self it "does not search the lexical scope of the caller" do ConstantSpecs::ClassB::CS_CONST209 = :const209 - -> { ConstantSpecs::ClassB.const209 }.should raise_error(NameError) + -> { ConstantSpecs::ClassB.const209 }.should.raise(NameError) ensure ConstantSpecs::ClassB.send(:remove_const, :CS_CONST209) end @@ -426,14 +426,14 @@ class << self -> do ConstantSpecs::ContainerB::ChildB.const214 - end.should raise_error(NameError) + end.should.raise(NameError) ensure ConstantSpecs::ContainerB.send(:remove_const, :CS_CONST214) end end it "raises a NameError if no constant is defined in the search path" do - -> { ConstantSpecs::ParentA.constx }.should raise_error(NameError) + -> { ConstantSpecs::ParentA.constx }.should.raise(NameError) end it "sends #const_missing to the original class or module scope" do @@ -456,7 +456,7 @@ class << self it "uses its own namespace for nested modules" do a = ConstantSpecs::CS_SINGLETON3[0].x b = ConstantSpecs::CS_SINGLETON3[1].x - a.should_not equal(b) + a.should_not.equal?(b) end it "allows nested modules to have proper resolution" do @@ -469,12 +469,12 @@ class << self describe "top-level constant lookup" do context "on a class" do it "does not search Object after searching other scopes" do - -> { String::Hash }.should raise_error(NameError) + -> { String::Hash }.should.raise(NameError) end end it "searches Object unsuccessfully when searches on a module" do - -> { Enumerable::Hash }.should raise_error(NameError) + -> { Enumerable::Hash }.should.raise(NameError) end end @@ -488,7 +488,7 @@ class << self mod.const_set :Foo, false }.should complain(/already initialized constant/) - -> {mod::Foo}.should raise_error(NameError) + -> {mod::Foo}.should.raise(NameError) end it "sends #const_missing to the original class or module" do @@ -506,19 +506,19 @@ def mod.const_missing(name) it "cannot be accessed from outside the module" do -> do ConstantVisibility::PrivConstModule::PRIVATE_CONSTANT_MODULE - end.should raise_error(NameError) + end.should.raise(NameError) end it "cannot be reopened as a module from scope where constant would be private" do -> do module ConstantVisibility::ModuleContainer::PrivateModule; end - end.should raise_error(NameError) + end.should.raise(NameError) end it "cannot be reopened as a class from scope where constant would be private" do -> do class ConstantVisibility::ModuleContainer::PrivateClass; end - end.should raise_error(NameError) + end.should.raise(NameError) end it "can be reopened as a module where constant is not private" do @@ -554,7 +554,7 @@ module ::ConstantVisibility::ModuleContainer end it "can be accessed from the module itself" do - ConstantVisibility::PrivConstModule.private_constant_from_self.should be_true + ConstantVisibility::PrivConstModule.private_constant_from_self.should == true end it "is defined? from the module itself" do @@ -562,7 +562,7 @@ module ::ConstantVisibility::ModuleContainer end it "can be accessed from lexical scope" do - ConstantVisibility::PrivConstModule::Nested.private_constant_from_scope.should be_true + ConstantVisibility::PrivConstModule::Nested.private_constant_from_scope.should == true end it "is defined? from lexical scope" do @@ -570,20 +570,20 @@ module ::ConstantVisibility::ModuleContainer end it "can be accessed from classes that include the module" do - ConstantVisibility::ClassIncludingPrivConstModule.new.private_constant_from_include.should be_true + ConstantVisibility::ClassIncludingPrivConstModule.new.private_constant_from_include.should == true end it "can be accessed from modules that include the module" do - ConstantVisibility::ModuleIncludingPrivConstModule.private_constant_from_include.should be_true + ConstantVisibility::ModuleIncludingPrivConstModule.private_constant_from_include.should == true end it "raises a NameError when accessed directly from modules that include the module" do -> do ConstantVisibility::ModuleIncludingPrivConstModule.private_constant_self_from_include - end.should raise_error(NameError) + end.should.raise(NameError) -> do ConstantVisibility::ModuleIncludingPrivConstModule.private_constant_named_from_include - end.should raise_error(NameError) + end.should.raise(NameError) end it "is defined? from classes that include the module" do @@ -595,19 +595,19 @@ module ::ConstantVisibility::ModuleContainer it "cannot be accessed from outside the class" do -> do ConstantVisibility::PrivConstClass::PRIVATE_CONSTANT_CLASS - end.should raise_error(NameError) + end.should.raise(NameError) end it "cannot be reopened as a module" do -> do module ConstantVisibility::ClassContainer::PrivateModule; end - end.should raise_error(NameError) + end.should.raise(NameError) end it "cannot be reopened as a class" do -> do class ConstantVisibility::ClassContainer::PrivateClass; end - end.should raise_error(NameError) + end.should.raise(NameError) end it "can be reopened as a module where constant is not private" do @@ -643,7 +643,7 @@ class ::ConstantVisibility::ClassContainer end it "can be accessed from the class itself" do - ConstantVisibility::PrivConstClass.private_constant_from_self.should be_true + ConstantVisibility::PrivConstClass.private_constant_from_self.should == true end it "is defined? from the class itself" do @@ -651,7 +651,7 @@ class ::ConstantVisibility::ClassContainer end it "can be accessed from lexical scope" do - ConstantVisibility::PrivConstClass::Nested.private_constant_from_scope.should be_true + ConstantVisibility::PrivConstClass::Nested.private_constant_from_scope.should == true end it "is defined? from lexical scope" do @@ -659,7 +659,7 @@ class ::ConstantVisibility::ClassContainer end it "can be accessed from subclasses" do - ConstantVisibility::PrivConstClassChild.new.private_constant_from_subclass.should be_true + ConstantVisibility::PrivConstClassChild.new.private_constant_from_subclass.should == true end it "is defined? from subclasses" do @@ -671,7 +671,7 @@ class ::ConstantVisibility::ClassContainer it "cannot be accessed using ::Const form" do -> do ::PRIVATE_CONSTANT_IN_OBJECT - end.should raise_error(NameError) + end.should.raise(NameError) end it "is not defined? using ::Const form" do @@ -691,14 +691,14 @@ class ::ConstantVisibility::ClassContainer it "has :receiver and :name attributes" do -> do ConstantVisibility::PrivConstClass::PRIVATE_CONSTANT_CLASS - end.should raise_error(NameError) {|e| + end.should.raise(NameError) {|e| e.receiver.should == ConstantVisibility::PrivConstClass e.name.should == :PRIVATE_CONSTANT_CLASS } -> do ConstantVisibility::PrivConstModule::PRIVATE_CONSTANT_MODULE - end.should raise_error(NameError) {|e| + end.should.raise(NameError) {|e| e.receiver.should == ConstantVisibility::PrivConstModule e.name.should == :PRIVATE_CONSTANT_MODULE } @@ -707,14 +707,14 @@ class ::ConstantVisibility::ClassContainer it "has the defined class as the :name attribute" do -> do ConstantVisibility::PrivConstClassChild::PRIVATE_CONSTANT_CLASS - end.should raise_error(NameError) {|e| + end.should.raise(NameError) {|e| e.receiver.should == ConstantVisibility::PrivConstClass e.name.should == :PRIVATE_CONSTANT_CLASS } -> do ConstantVisibility::ClassIncludingPrivConstModule::PRIVATE_CONSTANT_MODULE - end.should raise_error(NameError) {|e| + end.should.raise(NameError) {|e| e.receiver.should == ConstantVisibility::PrivConstModule e.name.should == :PRIVATE_CONSTANT_MODULE } @@ -783,7 +783,7 @@ class ::ConstantVisibility::ClassContainer it 'does not allow not ASCII characters that cannot be upcased or lowercased at the beginning' do -> do Module.new.const_set("થBB", 1) - end.should raise_error(NameError, /wrong constant name/) + end.should.raise(NameError, /wrong constant name/) end it 'allows not ASCII upcased characters at the beginning' do @@ -803,7 +803,7 @@ def test B = 1 end CODE - end.should raise_error(SyntaxError, /dynamic constant assignment/) + end.should.raise(SyntaxError, /dynamic constant assignment/) end end end diff --git a/spec/ruby/language/def_spec.rb b/spec/ruby/language/def_spec.rb index 0cf1790791a0fb..82c89a0d081977 100644 --- a/spec/ruby/language/def_spec.rb +++ b/spec/ruby/language/def_spec.rb @@ -14,11 +14,11 @@ def barfoo; 200; end describe "Defining a method at the top-level" do it "defines it on Object with private visibility by default" do - Object.should have_private_instance_method(:some_toplevel_method, false) + Object.private_instance_methods(false).should.include?(:some_toplevel_method) end it "defines it on Object with public visibility after calling public" do - Object.should have_public_instance_method(:public_toplevel_method, false) + Object.public_instance_methods(false).should.include?(:public_toplevel_method) end end @@ -28,7 +28,7 @@ class DefInitializeSpec def initialize end end - DefInitializeSpec.should have_private_instance_method(:initialize, false) + DefInitializeSpec.private_instance_methods(false).should.include?(:initialize) end end @@ -38,7 +38,7 @@ class DefInitializeCopySpec def initialize_copy end end - DefInitializeCopySpec.should have_private_instance_method(:initialize_copy, false) + DefInitializeCopySpec.private_instance_methods(false).should.include?(:initialize_copy) end end @@ -48,7 +48,7 @@ class DefInitializeDupSpec def initialize_dup end end - DefInitializeDupSpec.should have_private_instance_method(:initialize_dup, false) + DefInitializeDupSpec.private_instance_methods(false).should.include?(:initialize_dup) end end @@ -58,7 +58,7 @@ class DefInitializeCloneSpec def initialize_clone end end - DefInitializeCloneSpec.should have_private_instance_method(:initialize_clone, false) + DefInitializeCloneSpec.private_instance_methods(false).should.include?(:initialize_clone) end end @@ -68,7 +68,7 @@ class DefRespondToMissingPSpec def respond_to_missing? end end - DefRespondToMissingPSpec.should have_private_instance_method(:respond_to_missing?, false) + DefRespondToMissingPSpec.private_instance_methods(false).should.include?(:respond_to_missing?) end end @@ -82,12 +82,12 @@ def respond_to_missing? describe "An instance method" do it "raises an error with too few arguments" do def foo(a, b); end - -> { foo 1 }.should raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 2)') + -> { foo 1 }.should.raise(ArgumentError, 'wrong number of arguments (given 1, expected 2)') end it "raises an error with too many arguments" do def foo(a); end - -> { foo 1, 2 }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 1)') + -> { foo 1, 2 }.should.raise(ArgumentError, 'wrong number of arguments (given 2, expected 1)') end it "raises FrozenError with the correct class name" do @@ -96,7 +96,7 @@ def foo(a); end self.freeze def foo; end end - }.should raise_error(FrozenError) { |e| + }.should.raise(FrozenError) { |e| msg_class = ruby_version_is("4.0") ? "Module" : "module" e.message.should == "can't modify frozen #{msg_class}: #{e.receiver}" } @@ -106,7 +106,7 @@ def foo; end self.freeze def foo; end end - }.should raise_error(FrozenError){ |e| + }.should.raise(FrozenError){ |e| msg_class = ruby_version_is("4.0") ? "Class" : "class" e.message.should == "can't modify frozen #{msg_class}: #{e.receiver}" } @@ -135,12 +135,12 @@ def foo(a, b, c, d, e, *f); [a, b, c, d, e, f]; end end it "allows only a single * argument" do - -> { eval 'def foo(a, *b, *c); end' }.should raise_error(SyntaxError) + -> { eval 'def foo(a, *b, *c); end' }.should.raise(SyntaxError) end it "requires the presence of any arguments that precede the *" do def foo(a, b, *c); end - -> { foo 1 }.should raise_error(ArgumentError, 'wrong number of arguments (given 1, expected 2+)') + -> { foo 1 }.should.raise(ArgumentError, 'wrong number of arguments (given 1, expected 2+)') end end @@ -173,7 +173,7 @@ def foo(a = 1, *b) def foo(a, b = 2) [a,b] end - -> { foo }.should raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1..2)') + -> { foo }.should.raise(ArgumentError, 'wrong number of arguments (given 0, expected 1..2)') foo(1).should == [1, 2] end @@ -181,7 +181,7 @@ def foo(a, b = 2) def foo(a, b = 2, *c) [a,b,c] end - -> { foo }.should raise_error(ArgumentError, 'wrong number of arguments (given 0, expected 1+)') + -> { foo }.should.raise(ArgumentError, 'wrong number of arguments (given 0, expected 1+)') foo(1).should == [1,2,[]] end @@ -205,7 +205,7 @@ def foo(a, b = 2, *args) eval "def foo(bar = bar) bar end" - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end end @@ -279,27 +279,27 @@ def obj.==(other) it "raises FrozenError if frozen" do obj = Object.new obj.freeze - -> { def obj.foo; end }.should raise_error(FrozenError) + -> { def obj.foo; end }.should.raise(FrozenError) end it "raises FrozenError with the correct class name" do obj = Object.new obj.freeze msg_class = ruby_version_is("4.0") ? "Object" : "object" - -> { def obj.foo; end }.should raise_error(FrozenError, "can't modify frozen #{msg_class}: #{obj}") + -> { def obj.foo; end }.should.raise(FrozenError, "can't modify frozen #{msg_class}: #{obj}") obj = Object.new c = obj.singleton_class c.singleton_class.freeze - -> { def c.foo; end }.should raise_error(FrozenError, "can't modify frozen Class: #{c}") + -> { def c.foo; end }.should.raise(FrozenError, "can't modify frozen Class: #{c}") c = Class.new c.freeze - -> { def c.foo; end }.should raise_error(FrozenError, "can't modify frozen Class: #{c}") + -> { def c.foo; end }.should.raise(FrozenError, "can't modify frozen Class: #{c}") m = Module.new m.freeze - -> { def m.foo; end }.should raise_error(FrozenError, "can't modify frozen Module: #{m}") + -> { def m.foo; end }.should.raise(FrozenError, "can't modify frozen Module: #{m}") end end @@ -434,7 +434,7 @@ def a_class_method;self;end end DefSpecSingleton.a_class_method.should == DefSpecSingleton - -> { Object.a_class_method }.should raise_error(NoMethodError) + -> { Object.a_class_method }.should.raise(NoMethodError) end it "can create a singleton method" do @@ -444,7 +444,7 @@ def a_singleton_method;self;end end obj.a_singleton_method.should == obj - -> { Object.new.a_singleton_method }.should raise_error(NoMethodError) + -> { Object.new.a_singleton_method }.should.raise(NoMethodError) end it "raises FrozenError if frozen" do @@ -452,7 +452,7 @@ def a_singleton_method;self;end obj.freeze class << obj - -> { def foo; end }.should raise_error(FrozenError) + -> { def foo; end }.should.raise(FrozenError) end end end @@ -473,7 +473,7 @@ def an_instance_method;self;end other = DefSpecNested.new other.an_instance_method.should == other - DefSpecNested.should have_instance_method(:an_instance_method) + DefSpecNested.should.method_defined?(:an_instance_method, false) end it "creates a class method when evaluated in a class method" do @@ -488,11 +488,11 @@ def a_class_method;self;end end end - -> { DefSpecNested.a_class_method }.should raise_error(NoMethodError) + -> { DefSpecNested.a_class_method }.should.raise(NoMethodError) DefSpecNested.create_class_method.should == DefSpecNested DefSpecNested.a_class_method.should == DefSpecNested - -> { Object.a_class_method }.should raise_error(NoMethodError) - -> { DefSpecNested.new.a_class_method }.should raise_error(NoMethodError) + -> { Object.a_class_method }.should.raise(NoMethodError) + -> { DefSpecNested.new.a_class_method }.should.raise(NoMethodError) end it "creates a singleton method when evaluated in the metaclass of an instance" do @@ -510,7 +510,7 @@ def a_singleton_method;self;end obj.a_singleton_method.should == obj other = DefSpecNested.new - -> { other.a_singleton_method }.should raise_error(NoMethodError) + -> { other.a_singleton_method }.should.raise(NoMethodError) end it "creates a method in the surrounding context when evaluated in a def expr.method" do @@ -522,8 +522,8 @@ def inherited_method;self;end end DefSpecNested::TARGET.defs_method - DefSpecNested.should have_instance_method :inherited_method - DefSpecNested::TARGET.should_not have_method :inherited_method + DefSpecNested.should.method_defined?(:inherited_method, false) + DefSpecNested::TARGET.should_not.respond_to? :inherited_method obj = DefSpecNested.new obj.inherited_method.should == obj @@ -545,11 +545,11 @@ def body_method; end obj = DefSpecNested::OBJ obj.create_method_in_instance_eval - obj.should have_method :arg_method - obj.should have_method :body_method + obj.should.respond_to? :arg_method + obj.should.respond_to? :body_method - DefSpecNested.should_not have_instance_method :arg_method - DefSpecNested.should_not have_instance_method :body_method + DefSpecNested.should_not.method_defined? :arg_method + DefSpecNested.should_not.method_defined? :body_method ensure DefSpecNested.send(:remove_const, :OBJ) end @@ -569,7 +569,7 @@ def new_def cls.new.new_def.should == 1 - -> { Object.new.new_def }.should raise_error(NoMethodError) + -> { Object.new.new_def }.should.raise(NoMethodError) end end @@ -585,18 +585,18 @@ def new_def end obj = cls.new - -> { obj.do_def }.should raise_error(NoMethodError, /private/) + -> { obj.do_def }.should.raise(NoMethodError, /private/) obj.send :do_def obj.new_def.should == 1 cls.new.new_def.should == 1 - -> { Object.new.new_def }.should raise_error(NoMethodError) + -> { Object.new.new_def }.should.raise(NoMethodError) end it "at the toplevel" do obj = Object.new - -> { obj.toplevel_define_other_method }.should raise_error(NoMethodError, /private/) + -> { obj.toplevel_define_other_method }.should.raise(NoMethodError, /private/) toplevel_define_other_method nested_method_in_toplevel_method.should == 42 @@ -613,7 +613,7 @@ def an_instance_eval_method;self;end obj.an_instance_eval_method.should == obj other = Object.new - -> { other.an_instance_eval_method }.should raise_error(NoMethodError) + -> { other.an_instance_eval_method }.should.raise(NoMethodError) end it "creates a singleton method when evaluated inside a metaclass" do @@ -626,7 +626,7 @@ def a_metaclass_eval_method;self;end obj.a_metaclass_eval_method.should == obj other = Object.new - -> { other.a_metaclass_eval_method }.should raise_error(NoMethodError) + -> { other.a_metaclass_eval_method }.should.raise(NoMethodError) end it "creates a class method when the receiver is a class" do @@ -635,7 +635,7 @@ def an_instance_eval_class_method;self;end end DefSpecNested.an_instance_eval_class_method.should == DefSpecNested - -> { Object.an_instance_eval_class_method }.should raise_error(NoMethodError) + -> { Object.an_instance_eval_class_method }.should.raise(NoMethodError) end it "creates a class method when the receiver is an anonymous class" do @@ -647,7 +647,7 @@ def klass_method end m.klass_method.should == :test - -> { Object.klass_method }.should raise_error(NoMethodError) + -> { Object.klass_method }.should.raise(NoMethodError) end it "creates a class method when instance_eval is within class" do @@ -660,7 +660,7 @@ def klass_method end m.klass_method.should == :test - -> { Object.klass_method }.should raise_error(NoMethodError) + -> { Object.klass_method }.should.raise(NoMethodError) end end @@ -673,7 +673,7 @@ def an_instance_exec_class_method; @stuff; end end DefSpecNested.an_instance_exec_class_method.should == 1 - -> { Object.an_instance_exec_class_method }.should raise_error(NoMethodError) + -> { Object.an_instance_exec_class_method }.should.raise(NoMethodError) end it "creates a class method when the receiver is an anonymous class" do @@ -687,7 +687,7 @@ def klass_method end m.klass_method.should == 1 - -> { Object.klass_method }.should raise_error(NoMethodError) + -> { Object.klass_method }.should.raise(NoMethodError) end it "creates a class method when instance_exec is within class" do @@ -702,7 +702,7 @@ def klass_method end m.klass_method.should == 2 - -> { Object.klass_method }.should raise_error(NoMethodError) + -> { Object.klass_method }.should.raise(NoMethodError) end end @@ -722,7 +722,7 @@ def eval_instance_method other = DefSpecNested.new other.an_eval_instance_method.should == other - -> { Object.new.an_eval_instance_method }.should raise_error(NoMethodError) + -> { Object.new.an_eval_instance_method }.should.raise(NoMethodError) end it "creates a class method" do @@ -738,8 +738,8 @@ def eval_class_method DefSpecNestedB.eval_class_method.should == DefSpecNestedB DefSpecNestedB.an_eval_class_method.should == DefSpecNestedB - -> { Object.an_eval_class_method }.should raise_error(NoMethodError) - -> { DefSpecNestedB.new.an_eval_class_method}.should raise_error(NoMethodError) + -> { Object.an_eval_class_method }.should.raise(NoMethodError) + -> { DefSpecNestedB.new.an_eval_class_method}.should.raise(NoMethodError) end it "creates a singleton method" do @@ -757,7 +757,7 @@ class << self obj.an_eval_singleton_method.should == obj other = DefSpecNested.new - -> { other.an_eval_singleton_method }.should raise_error(NoMethodError) + -> { other.an_eval_singleton_method }.should.raise(NoMethodError) end end @@ -768,8 +768,8 @@ def foo(a=b=c={}) it "assigns them all the same object by default" do foo.should == [{},{},{}] a, b, c = foo - a.should eql(b) - a.should eql(c) + a.should.eql?(b) + a.should.eql?(c) end it "allows the first argument to be given, and sets the rest to null" do @@ -779,11 +779,11 @@ def foo(a=b=c={}) it "assigns the parameters different objects across different default calls" do a, _b, _c = foo d, _e, _f = foo - a.should_not equal(d) + a.should_not.equal?(d) end it "only allows overriding the default value of the first such parameter in each set" do - -> { foo(1,2) }.should raise_error(ArgumentError, 'wrong number of arguments (given 2, expected 0..1)') + -> { foo(1,2) }.should.raise(ArgumentError, 'wrong number of arguments (given 2, expected 0..1)') end def bar(a=b=c=1,d=2) @@ -794,7 +794,7 @@ def bar(a=b=c=1,d=2) bar.should == [1,1,1,2] bar(3).should == [3,nil,nil,2] bar(3,4).should == [3,nil,nil,4] - -> { bar(3,4,5) }.should raise_error(ArgumentError, 'wrong number of arguments (given 3, expected 0..2)') + -> { bar(3,4,5) }.should.raise(ArgumentError, 'wrong number of arguments (given 3, expected 0..2)') end end @@ -809,7 +809,7 @@ def some_method; end }.call end - DefSpecsLambdaVisibility.should have_private_instance_method("some_method") + DefSpecsLambdaVisibility.private_instance_methods(false).should.include?(:some_method) end end end diff --git a/spec/ruby/language/defined_spec.rb b/spec/ruby/language/defined_spec.rb index 80ad1818b11652..3fd611d09e6f96 100644 --- a/spec/ruby/language/defined_spec.rb +++ b/spec/ruby/language/defined_spec.rb @@ -70,7 +70,7 @@ end it "returns nil if the method is not defined" do - defined?(defined_specs_undefined_method).should be_nil + defined?(defined_specs_undefined_method).should == nil end it "returns 'method' if the method is defined and private" do @@ -90,23 +90,23 @@ end it "returns nil if the method is private" do - defined?(Object.print).should be_nil + defined?(Object.print).should == nil end it "returns nil if the method is protected" do - defined?(DefinedSpecs::Basic.new.protected_method).should be_nil + defined?(DefinedSpecs::Basic.new.protected_method).should == nil end it "returns nil if the method is not defined" do - defined?(Kernel.defined_specs_undefined_method).should be_nil + defined?(Kernel.defined_specs_undefined_method).should == nil end it "returns nil if the class is not defined" do - defined?(DefinedSpecsUndefined.puts).should be_nil + defined?(DefinedSpecsUndefined.puts).should == nil end it "returns nil if the subclass is not defined" do - defined?(DefinedSpecs::Undefined.puts).should be_nil + defined?(DefinedSpecs::Undefined.puts).should == nil end end @@ -123,11 +123,11 @@ it "returns nil if the method is not defined" do obj = DefinedSpecs::Basic.new - defined?(obj.an_undefined_method).should be_nil + defined?(obj.an_undefined_method).should == nil end it "returns nil if the variable does not exist" do - defined?(nonexistent_local_variable.some_method).should be_nil + defined?(nonexistent_local_variable.some_method).should == nil end it "calls #respond_to_missing?" do @@ -145,11 +145,11 @@ it "returns nil if the method is not defined" do @defined_specs_obj = DefinedSpecs::Basic.new - defined?(@defined_specs_obj.an_undefined_method).should be_nil + defined?(@defined_specs_obj.an_undefined_method).should == nil end it "returns nil if the variable does not exist" do - defined?(@nonexistent_instance_variable.some_method).should be_nil + defined?(@nonexistent_instance_variable.some_method).should == nil end end @@ -161,22 +161,22 @@ it "returns nil if the method is not defined" do $defined_specs_obj = DefinedSpecs::Basic.new - defined?($defined_specs_obj.an_undefined_method).should be_nil + defined?($defined_specs_obj.an_undefined_method).should == nil end it "returns nil if the variable does not exist" do - defined?($nonexistent_global_variable.some_method).should be_nil + defined?($nonexistent_global_variable.some_method).should == nil end end describe "having a method call as a receiver" do it "returns nil if evaluating the receiver raises an exception" do - defined?(DefinedSpecs.exception_method / 2).should be_nil + defined?(DefinedSpecs.exception_method / 2).should == nil ScratchPad.recorded.should == :defined_specs_exception end it "returns nil if the method is not defined on the object the receiver returns" do - defined?(DefinedSpecs.side_effects / 2).should be_nil + defined?(DefinedSpecs.side_effects / 2).should == nil ScratchPad.recorded.should == :defined_specs_side_effects end @@ -403,15 +403,15 @@ end it "returns nil for an expression with == and an undefined method" do - defined?(defined_specs_undefined_method == 2).should be_nil + defined?(defined_specs_undefined_method == 2).should == nil end it "returns nil for an expression with != and an undefined method" do - defined?(defined_specs_undefined_method != 2).should be_nil + defined?(defined_specs_undefined_method != 2).should == nil end it "returns nil for an expression with !~ and an undefined method" do - defined?(defined_specs_undefined_method !~ 2).should be_nil + defined?(defined_specs_undefined_method !~ 2).should == nil end it "returns 'method' for an expression with '=='" do @@ -431,25 +431,25 @@ describe "with logical connectives" do it "returns nil for an expression with '!' and an undefined method" do - defined?(!defined_specs_undefined_method).should be_nil + defined?(!defined_specs_undefined_method).should == nil end it "returns nil for an expression with '!' and an unset class variable" do @result = eval("class singleton_class::A; defined?(!@@doesnt_exist) end", binding, __FILE__, __LINE__) - @result.should be_nil + @result.should == nil end it "returns nil for an expression with 'not' and an undefined method" do - defined?(not defined_specs_undefined_method).should be_nil + defined?(not defined_specs_undefined_method).should == nil end it "returns nil for an expression with 'not' and an unset class variable" do @result = eval("class singleton_class::A; defined?(not @@doesnt_exist) end", binding, __FILE__, __LINE__) - @result.should be_nil + @result.should == nil end it "does not propagate an exception raised by a method in a 'not' expression" do - defined?(not DefinedSpecs.exception_method).should be_nil + defined?(not DefinedSpecs.exception_method).should == nil ScratchPad.recorded.should == :defined_specs_exception end @@ -488,11 +488,11 @@ end it "returns nil for an expression with '!' and an unset global variable" do - defined?(!$defined_specs_undefined_global_variable).should be_nil + defined?(!$defined_specs_undefined_global_variable).should == nil end it "returns nil for an expression with '!' and an unset instance variable" do - defined?(!@defined_specs_undefined_instance_variable).should be_nil + defined?(!@defined_specs_undefined_instance_variable).should == nil end it "returns 'method' for a 'not' expression with a method" do @@ -505,11 +505,11 @@ end it "returns nil for an expression with 'not' and an unset global variable" do - defined?(not $defined_specs_undefined_global_variable).should be_nil + defined?(not $defined_specs_undefined_global_variable).should == nil end it "returns nil for an expression with 'not' and an unset instance variable" do - defined?(not @defined_specs_undefined_instance_variable).should be_nil + defined?(not @defined_specs_undefined_instance_variable).should == nil end it "returns 'expression' for an expression with '&&/and' and an undefined method" do @@ -524,12 +524,12 @@ it "does not call a method in an '&&' expression and returns 'expression'" do defined?(DefinedSpecs.side_effects && true).should == "expression" - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "does not call a method in an 'and' expression and returns 'expression'" do defined?(DefinedSpecs.side_effects and true).should == "expression" - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "returns 'expression' for an expression with '||/or' and an undefined method" do @@ -544,12 +544,12 @@ it "does not call a method in an '||' expression and returns 'expression'" do defined?(DefinedSpecs.side_effects || true).should == "expression" - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "does not call a method in an 'or' expression and returns 'expression'" do defined?(DefinedSpecs.side_effects or true).should == "expression" - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end end @@ -572,7 +572,7 @@ it "does not call the method in the String" do defined?("garble #{DefinedSpecs.dynamic_string}").should == "expression" - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end end @@ -591,7 +591,7 @@ it "does not call the method in the Regexp" do defined?(/garble #{DefinedSpecs.dynamic_string}/).should == "expression" - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end end @@ -640,11 +640,11 @@ end it "returns nil for an instance variable that has not been read" do - DefinedSpecs::Basic.new.instance_variable_undefined.should be_nil + DefinedSpecs::Basic.new.instance_variable_undefined.should == nil end it "returns nil for an instance variable that has been read but not assigned to" do - DefinedSpecs::Basic.new.instance_variable_read.should be_nil + DefinedSpecs::Basic.new.instance_variable_read.should == nil end it "returns 'instance-variable' for an instance variable that has been assigned" do @@ -658,11 +658,11 @@ end it "returns nil for a global variable that has not been read" do - DefinedSpecs::Basic.new.global_variable_undefined.should be_nil + DefinedSpecs::Basic.new.global_variable_undefined.should == nil end it "returns nil for a global variable that has been read but not assigned to" do - DefinedSpecs::Basic.new.global_variable_read.should be_nil + DefinedSpecs::Basic.new.global_variable_read.should == nil end it "returns 'global-variable' for a global variable that has been assigned nil" do @@ -694,27 +694,27 @@ end it "returns nil for $&" do - defined?($&).should be_nil + defined?($&).should == nil end it "returns nil for $`" do - defined?($`).should be_nil + defined?($`).should == nil end it "returns nil for $'" do - defined?($').should be_nil + defined?($').should == nil end it "returns nil for $+" do - defined?($+).should be_nil + defined?($+).should == nil end it "returns nil for any last match global" do - defined?($1).should be_nil - defined?($4).should be_nil - defined?($7).should be_nil - defined?($10).should be_nil - defined?($200).should be_nil + defined?($1).should == nil + defined?($4).should == nil + defined?($7).should == nil + defined?($10).should == nil + defined?($200).should == nil end end @@ -749,10 +749,10 @@ end it "returns nil for non-captures" do - defined?($4).should be_nil - defined?($7).should be_nil - defined?($10).should be_nil - defined?($200).should be_nil + defined?($4).should == nil + defined?($7).should == nil + defined?($10).should == nil + defined?($200).should == nil end end @@ -766,27 +766,27 @@ end it "returns nil for $&" do - defined?($&).should be_nil + defined?($&).should == nil end it "returns nil for $`" do - defined?($`).should be_nil + defined?($`).should == nil end it "returns nil for $'" do - defined?($').should be_nil + defined?($').should == nil end it "returns nil for $+" do - defined?($+).should be_nil + defined?($+).should == nil end it "returns nil for any last match global" do - defined?($1).should be_nil - defined?($4).should be_nil - defined?($7).should be_nil - defined?($10).should be_nil - defined?($200).should be_nil + defined?($1).should == nil + defined?($4).should == nil + defined?($7).should == nil + defined?($10).should == nil + defined?($200).should == nil end end @@ -821,10 +821,10 @@ end it "returns nil for non-captures" do - defined?($4).should be_nil - defined?($7).should be_nil - defined?($10).should be_nil - defined?($200).should be_nil + defined?($4).should == nil + defined?($7).should == nil + defined?($10).should == nil + defined?($200).should == nil end end it "returns 'global-variable' for a global variable that has been assigned" do @@ -832,7 +832,7 @@ end it "returns nil for a class variable that has not been read" do - DefinedSpecs::Basic.new.class_variable_undefined.should be_nil + DefinedSpecs::Basic.new.class_variable_undefined.should == nil end # There is no spec for a class variable that is read before being assigned @@ -859,12 +859,12 @@ end it "returns nil when the constant is not defined" do - defined?(DefinedSpecsUndefined).should be_nil + defined?(DefinedSpecsUndefined).should == nil end it "does not call Object.const_missing if the constant is not defined" do Object.should_not_receive(:const_missing) - defined?(DefinedSpecsUndefined).should be_nil + defined?(DefinedSpecsUndefined).should == nil end it "returns 'constant' for an included module" do @@ -882,12 +882,12 @@ end it "returns nil if the constant is not defined" do - defined?(::DefinedSpecsUndefined).should be_nil + defined?(::DefinedSpecsUndefined).should == nil end it "does not call Object.const_missing if the constant is not defined" do Object.should_not_receive(:const_missing) - defined?(::DefinedSpecsUndefined).should be_nil + defined?(::DefinedSpecsUndefined).should == nil end end @@ -897,37 +897,37 @@ end it "returns nil when the scoped constant is not defined" do - defined?(DefinedSpecs::Undefined).should be_nil + defined?(DefinedSpecs::Undefined).should == nil end it "returns nil when the constant is not defined and the outer module implements .const_missing" do - defined?(DefinedSpecs::ModuleWithConstMissing::Undefined).should be_nil + defined?(DefinedSpecs::ModuleWithConstMissing::Undefined).should == nil end it "does not call .const_missing if the constant is not defined" do DefinedSpecs.should_not_receive(:const_missing) - defined?(DefinedSpecs::UnknownChild).should be_nil + defined?(DefinedSpecs::UnknownChild).should == nil end it "returns nil when an undefined constant is scoped to a defined constant" do - defined?(DefinedSpecs::Child::Undefined).should be_nil + defined?(DefinedSpecs::Child::Undefined).should == nil end it "returns nil when a constant is scoped to an undefined constant" do Object.should_not_receive(:const_missing) - defined?(Undefined::Object).should be_nil + defined?(Undefined::Object).should == nil end it "returns nil when the undefined constant is scoped to an undefined constant" do - defined?(DefinedSpecs::Undefined::Undefined).should be_nil + defined?(DefinedSpecs::Undefined::Undefined).should == nil end it "returns nil when a constant is defined on top-level but not on the module" do - defined?(DefinedSpecs::String).should be_nil + defined?(DefinedSpecs::String).should == nil end it "returns nil when a constant is defined on top-level but not on the class" do - defined?(DefinedSpecs::Basic::String).should be_nil + defined?(DefinedSpecs::Basic::String).should == nil end it "returns 'constant' if the scoped-scoped constant is defined" do @@ -941,15 +941,15 @@ end it "returns nil when the scoped constant is not defined" do - defined?(::DefinedSpecs::Undefined).should be_nil + defined?(::DefinedSpecs::Undefined).should == nil end it "returns nil when an undefined constant is scoped to a defined constant" do - defined?(::DefinedSpecs::Child::Undefined).should be_nil + defined?(::DefinedSpecs::Child::Undefined).should == nil end it "returns nil when the undefined constant is scoped to an undefined constant" do - defined?(::DefinedSpecs::Undefined::Undefined).should be_nil + defined?(::DefinedSpecs::Undefined::Undefined).should == nil end it "returns 'constant' if the scoped-scoped constant is defined" do @@ -959,7 +959,7 @@ describe "The defined? keyword for a self-send method call scoped constant" do it "returns nil if the constant is not defined in the scope of the method's value" do - defined?(defined_specs_method::Undefined).should be_nil + defined?(defined_specs_method::Undefined).should == nil end it "returns 'constant' if the constant is defined in the scope of the method's value" do @@ -967,11 +967,11 @@ end it "returns nil if the last constant is not defined in the scope chain" do - defined?(defined_specs_method::Basic::Undefined).should be_nil + defined?(defined_specs_method::Basic::Undefined).should == nil end it "returns nil if the middle constant is not defined in the scope chain" do - defined?(defined_specs_method::Undefined::Undefined).should be_nil + defined?(defined_specs_method::Undefined::Undefined).should == nil end it "returns 'constant' if all the constants in the scope chain are defined" do @@ -981,7 +981,7 @@ describe "The defined? keyword for a receiver method call scoped constant" do it "returns nil if the constant is not defined in the scope of the method's value" do - defined?(defined_specs_receiver.defined_method::Undefined).should be_nil + defined?(defined_specs_receiver.defined_method::Undefined).should == nil end it "returns 'constant' if the constant is defined in the scope of the method's value" do @@ -989,11 +989,11 @@ end it "returns nil if the last constant is not defined in the scope chain" do - defined?(defined_specs_receiver.defined_method::Basic::Undefined).should be_nil + defined?(defined_specs_receiver.defined_method::Basic::Undefined).should == nil end it "returns nil if the middle constant is not defined in the scope chain" do - defined?(defined_specs_receiver.defined_method::Undefined::Undefined).should be_nil + defined?(defined_specs_receiver.defined_method::Undefined::Undefined).should == nil end it "returns 'constant' if all the constants in the scope chain are defined" do @@ -1003,7 +1003,7 @@ describe "The defined? keyword for a module method call scoped constant" do it "returns nil if the constant is not defined in the scope of the method's value" do - defined?(DefinedSpecs.defined_method::Undefined).should be_nil + defined?(DefinedSpecs.defined_method::Undefined).should == nil end it "returns 'constant' if the constant scoped by the method's value is defined" do @@ -1011,11 +1011,11 @@ end it "returns nil if the last constant in the scope chain is not defined" do - defined?(DefinedSpecs.defined_method::Basic::Undefined).should be_nil + defined?(DefinedSpecs.defined_method::Basic::Undefined).should == nil end it "returns nil if the middle constant in the scope chain is not defined" do - defined?(DefinedSpecs.defined_method::Undefined::Undefined).should be_nil + defined?(DefinedSpecs.defined_method::Undefined::Undefined).should == nil end it "returns 'constant' if all the constants in the scope chain are defined" do @@ -1023,11 +1023,11 @@ end it "returns nil if the outer scope constant in the receiver is not defined" do - defined?(Undefined::DefinedSpecs.defined_method::Basic).should be_nil + defined?(Undefined::DefinedSpecs.defined_method::Basic).should == nil end it "returns nil if the scoped constant in the receiver is not defined" do - defined?(DefinedSpecs::Undefined.defined_method::Basic).should be_nil + defined?(DefinedSpecs::Undefined.defined_method::Basic).should == nil end it "returns 'constant' if all the constants in the receiver are defined" do @@ -1048,7 +1048,7 @@ it "returns nil if the instance scoped constant is not defined" do @defined_specs_obj = DefinedSpecs::Basic - defined?(@defined_specs_obj::Undefined).should be_nil + defined?(@defined_specs_obj::Undefined).should == nil end it "returns 'constant' if the constant is defined in the scope of the instance variable" do @@ -1058,7 +1058,7 @@ it "returns nil if the global scoped constant is not defined" do $defined_specs_obj = DefinedSpecs::Basic - defined?($defined_specs_obj::Undefined).should be_nil + defined?($defined_specs_obj::Undefined).should == nil end it "returns 'constant' if the constant is defined in the scope of the global variable" do @@ -1070,7 +1070,7 @@ eval(<<-END, binding, __FILE__, __LINE__) class singleton_class::A @@defined_specs_obj = DefinedSpecs::Basic - defined?(@@defined_specs_obj::Undefined).should be_nil + defined?(@@defined_specs_obj::Undefined).should == nil end END end @@ -1086,7 +1086,7 @@ class singleton_class::A it "returns nil if the local scoped constant is not defined" do defined_specs_obj = DefinedSpecs::Basic - defined?(defined_specs_obj::Undefined).should be_nil + defined?(defined_specs_obj::Undefined).should == nil end it "returns 'constant' if the constant is defined in the scope of the local variable" do @@ -1107,11 +1107,11 @@ class singleton_class::A describe "The defined? keyword for yield" do it "returns nil if no block is passed to a method not taking a block parameter" do - DefinedSpecs::Basic.new.no_yield_block.should be_nil + DefinedSpecs::Basic.new.no_yield_block.should == nil end it "returns nil if no block is passed to a method taking a block parameter" do - DefinedSpecs::Basic.new.no_yield_block_parameter.should be_nil + DefinedSpecs::Basic.new.no_yield_block_parameter.should == nil end it "returns 'yield' if a block is passed to a method not taking a block parameter" do @@ -1139,24 +1139,24 @@ def call_defined describe "The defined? keyword for super" do it "returns nil when a superclass undef's the method" do - DefinedSpecs::ClassWithoutMethod.new.test.should be_nil + DefinedSpecs::ClassWithoutMethod.new.test.should == nil end describe "for a method taking no arguments" do it "returns nil when no superclass method exists" do - DefinedSpecs::Super.new.no_super_method_no_args.should be_nil + DefinedSpecs::Super.new.no_super_method_no_args.should == nil end it "returns nil from a block when no superclass method exists" do - DefinedSpecs::Super.new.no_super_method_block_no_args.should be_nil + DefinedSpecs::Super.new.no_super_method_block_no_args.should == nil end it "returns nil from a #define_method when no superclass method exists" do - DefinedSpecs::Super.new.no_super_define_method_no_args.should be_nil + DefinedSpecs::Super.new.no_super_define_method_no_args.should == nil end it "returns nil from a block in a #define_method when no superclass method exists" do - DefinedSpecs::Super.new.no_super_define_method_block_no_args.should be_nil + DefinedSpecs::Super.new.no_super_define_method_block_no_args.should == nil end it "returns 'super' when a superclass method exists" do @@ -1184,19 +1184,19 @@ def call_defined describe "for a method taking arguments" do it "returns nil when no superclass method exists" do - DefinedSpecs::Super.new.no_super_method_args.should be_nil + DefinedSpecs::Super.new.no_super_method_args.should == nil end it "returns nil from a block when no superclass method exists" do - DefinedSpecs::Super.new.no_super_method_block_args.should be_nil + DefinedSpecs::Super.new.no_super_method_block_args.should == nil end it "returns nil from a #define_method when no superclass method exists" do - DefinedSpecs::Super.new.no_super_define_method_args.should be_nil + DefinedSpecs::Super.new.no_super_define_method_args.should == nil end it "returns nil from a block in a #define_method when no superclass method exists" do - DefinedSpecs::Super.new.no_super_define_method_block_args.should be_nil + DefinedSpecs::Super.new.no_super_define_method_block_args.should == nil end it "returns 'super' when a superclass method exists" do @@ -1231,7 +1231,7 @@ def call_defined end it "returns nil if not assigned" do - defined?(@unassigned_ivar).should be_nil + defined?(@unassigned_ivar).should == nil end end diff --git a/spec/ruby/language/delegation_spec.rb b/spec/ruby/language/delegation_spec.rb index cd44956f5d1c65..3d917993f545e9 100644 --- a/spec/ruby/language/delegation_spec.rb +++ b/spec/ruby/language/delegation_spec.rb @@ -113,7 +113,7 @@ def delegate(*) it "does not allow delegating rest" do -> { eval "def m(*); proc { |*| n(*) } end" - }.should raise_error(SyntaxError, /anonymous rest parameter is also used within block/) + }.should.raise(SyntaxError, /anonymous rest parameter is also used within block/) end end end @@ -134,7 +134,7 @@ def delegate(**) it "does not allow delegating kwargs" do -> { eval "def m(**); proc { |**| n(**) } end" - }.should raise_error(SyntaxError, /anonymous keyword rest parameter is also used within block/) + }.should.raise(SyntaxError, /anonymous keyword rest parameter is also used within block/) end end end @@ -156,7 +156,7 @@ def delegate(&) it "does not allow delegating a block" do -> { eval "def m(&); proc { |&| n(&) } end" - }.should raise_error(SyntaxError, /anonymous block parameter is also used within block/) + }.should.raise(SyntaxError, /anonymous block parameter is also used within block/) end end end diff --git a/spec/ruby/language/encoding_spec.rb b/spec/ruby/language/encoding_spec.rb index e761a53cb69371..116f53a77de0ee 100644 --- a/spec/ruby/language/encoding_spec.rb +++ b/spec/ruby/language/encoding_spec.rb @@ -5,7 +5,7 @@ describe "The __ENCODING__ pseudo-variable" do it "is an instance of Encoding" do - __ENCODING__.should be_kind_of(Encoding) + __ENCODING__.should.is_a?(Encoding) end it "is US-ASCII by default" do @@ -31,6 +31,6 @@ end it "raises a SyntaxError if assigned to" do - -> { eval("__ENCODING__ = 1") }.should raise_error(SyntaxError) + -> { eval("__ENCODING__ = 1") }.should.raise(SyntaxError) end end diff --git a/spec/ruby/language/ensure_spec.rb b/spec/ruby/language/ensure_spec.rb index 1b44457f6a051f..04ff0305abd026 100644 --- a/spec/ruby/language/ensure_spec.rb +++ b/spec/ruby/language/ensure_spec.rb @@ -14,7 +14,7 @@ ensure ScratchPad << :ensure end - }.should raise_error(EnsureSpec::Error) + }.should.raise(EnsureSpec::Error) ScratchPad.recorded.should == [:begin, :ensure] end @@ -74,7 +74,7 @@ ensure raise "from ensure" end - }.should raise_error(RuntimeError, "from ensure") { |e| + }.should.raise(RuntimeError, "from ensure") { |e| e.cause.message.should == "from block" } end @@ -108,7 +108,7 @@ end it "is executed when an exception is raised in the method" do - -> { @obj.raise_in_method_with_ensure }.should raise_error(EnsureSpec::Error) + -> { @obj.raise_in_method_with_ensure }.should.raise(EnsureSpec::Error) @obj.executed.should == [:method, :ensure] end @@ -149,13 +149,13 @@ it "overrides exception raised in rescue if raises exception itself" do -> { @obj.raise_in_rescue_and_raise_in_ensure - }.should raise_error(RuntimeError, "raised in ensure") + }.should.raise(RuntimeError, "raised in ensure") end it "suppresses exception raised in method if raises exception itself" do -> { @obj.raise_in_method_and_raise_in_ensure - }.should raise_error(RuntimeError, "raised in ensure") + }.should.raise(RuntimeError, "raised in ensure") end end @@ -174,7 +174,7 @@ class EnsureInClassExample ScratchPad << :ensure end ruby - }.should raise_error(EnsureSpec::Error) + }.should.raise(EnsureSpec::Error) ScratchPad.recorded.should == [:class, :ensure] end @@ -247,7 +247,7 @@ class EnsureInClassExample ensure } ruby - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end end @@ -266,7 +266,7 @@ class EnsureInClassExample ScratchPad << :ensure end ruby - }.should raise_error(EnsureSpec::Error) + }.should.raise(EnsureSpec::Error) ScratchPad.recorded.should == [:begin, :ensure] end diff --git a/spec/ruby/language/file_spec.rb b/spec/ruby/language/file_spec.rb index 36fd329bf6a7ca..dd89ce238521ac 100644 --- a/spec/ruby/language/file_spec.rb +++ b/spec/ruby/language/file_spec.rb @@ -4,7 +4,7 @@ describe "The __FILE__ pseudo-variable" do it "raises a SyntaxError if assigned to" do - -> { eval("__FILE__ = 1") }.should raise_error(SyntaxError) + -> { eval("__FILE__ = 1") }.should.raise(SyntaxError) end it "equals (eval at __FILE__:__LINE__) inside an eval" do diff --git a/spec/ruby/language/for_spec.rb b/spec/ruby/language/for_spec.rb index dfaafa296fe469..b0f3aef40566de 100644 --- a/spec/ruby/language/for_spec.rb +++ b/spec/ruby/language/for_spec.rb @@ -155,7 +155,7 @@ class OFor n += 1 end RUBY - ofor.should be_nil + ofor.should == nil n.should == 3 end diff --git a/spec/ruby/language/hash_spec.rb b/spec/ruby/language/hash_spec.rb index c7e1bf2d88bffd..7a4a2e37c98d46 100644 --- a/spec/ruby/language/hash_spec.rb +++ b/spec/ruby/language/hash_spec.rb @@ -81,7 +81,7 @@ end it "with '==>' in the middle raises SyntaxError" do - -> { eval("{:a ==> 1}") }.should raise_error(SyntaxError) + -> { eval("{:a ==> 1}") }.should.raise(SyntaxError) end it "recognizes '!' at the end of the key" do @@ -93,7 +93,7 @@ end it "raises a SyntaxError if there is no space between `!` and `=>`" do - -> { eval("{:a!=> 1}") }.should raise_error(SyntaxError) + -> { eval("{:a!=> 1}") }.should.raise(SyntaxError) end it "recognizes '?' at the end of the key" do @@ -105,7 +105,7 @@ end it "raises a SyntaxError if there is no space between `?` and `=>`" do - -> { eval("{:a?=> 1}") }.should raise_error(SyntaxError) + -> { eval("{:a?=> 1}") }.should.raise(SyntaxError) end it "constructs a new hash with the given elements" do @@ -152,9 +152,9 @@ def h.to_hash; {:b => 2, :c => 3}; end ruby_version_is ""..."3.4" do it "does not expand nil using ** into {} and raises TypeError" do h = nil - -> { {a: 1, **h} }.should raise_error(TypeError, "no implicit conversion of nil into Hash") + -> { {a: 1, **h} }.should.raise(TypeError, "no implicit conversion of nil into Hash") - -> { {a: 1, **nil} }.should raise_error(TypeError, "no implicit conversion of nil into Hash") + -> { {a: 1, **nil} }.should.raise(TypeError, "no implicit conversion of nil into Hash") end end @@ -223,13 +223,13 @@ def h.to_hash; {:b => 2, :c => 3}; end obj = mock("hash splat") obj.should_receive(:to_hash).and_return(obj) - -> { {**obj} }.should raise_error(TypeError) + -> { {**obj} }.should.raise(TypeError) end it "raises a TypeError if the object does not respond to #to_hash" do obj = 42 - -> { {**obj} }.should raise_error(TypeError) - -> { {a: 1, **obj} }.should raise_error(TypeError) + -> { {**obj} }.should.raise(TypeError) + -> { {a: 1, **obj} }.should.raise(TypeError) end it "does not change encoding of literal string keys during creation" do @@ -249,7 +249,7 @@ def h.to_hash; {:b => 2, :c => 3}; end ScratchPad.record [] -> { eval 'ScratchPad << 1; {:"\xC3" => 1}' - }.should raise_error(SyntaxError, /invalid symbol/) + }.should.raise(SyntaxError, /invalid symbol/) ScratchPad.recorded.should == [] end @@ -257,7 +257,7 @@ def h.to_hash; {:b => 2, :c => 3}; end ScratchPad.record [] -> { eval 'ScratchPad << 1; {"\xC3": 1}' - }.should raise_error(SyntaxError, /invalid symbol/) + }.should.raise(SyntaxError, /invalid symbol/) ScratchPad.recorded.should == [] end end @@ -323,11 +323,11 @@ def foo(val) end it "raises a SyntaxError when the hash key ends with `!`" do - -> { eval("{a!:}") }.should raise_error(SyntaxError, /identifier a! is not valid to get/) + -> { eval("{a!:}") }.should.raise(SyntaxError, /identifier a! is not valid to get/) end it "raises a SyntaxError when the hash key ends with `?`" do - -> { eval("{a?:}") }.should raise_error(SyntaxError, /identifier a\? is not valid to get/) + -> { eval("{a?:}") }.should.raise(SyntaxError, /identifier a\? is not valid to get/) end end end diff --git a/spec/ruby/language/heredoc_spec.rb b/spec/ruby/language/heredoc_spec.rb index 47ee9c2c519086..535f18cba88e21 100644 --- a/spec/ruby/language/heredoc_spec.rb +++ b/spec/ruby/language/heredoc_spec.rb @@ -62,7 +62,7 @@ it 'raises SyntaxError if quoted HEREDOC identifier is ending not on same line' do -> { eval %{<<"HERE\n"\nraises syntax error\nHERE} - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "allows HEREDOC with <<~'identifier', allowing to indent identifier and content" do @@ -114,6 +114,6 @@ b #{c} HERE - }.should raise_error(NameError) { |e| e.backtrace[0].should.start_with?("#{__FILE__}:#{__LINE__ - 2}") } + }.should.raise(NameError) { |e| e.backtrace[0].should.start_with?("#{__FILE__}:#{__LINE__ - 2}") } end end diff --git a/spec/ruby/language/if_spec.rb b/spec/ruby/language/if_spec.rb index 2d1a89f081f60a..53fcb853d5b8e3 100644 --- a/spec/ruby/language/if_spec.rb +++ b/spec/ruby/language/if_spec.rb @@ -330,7 +330,7 @@ def m a end RUBY - }.should raise_error(SyntaxError, /void value expression/) + }.should.raise(SyntaxError, /void value expression/) end it "does not raise SyntaxError if one branch returns a value" do diff --git a/spec/ruby/language/it_parameter_spec.rb b/spec/ruby/language/it_parameter_spec.rb index 58ec3a6faf0f1a..6ba67cbb4f26a3 100644 --- a/spec/ruby/language/it_parameter_spec.rb +++ b/spec/ruby/language/it_parameter_spec.rb @@ -43,27 +43,27 @@ def o.it end it "raises SyntaxError when block parameters are specified explicitly" do - -> { eval("-> () { it }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) - -> { eval("-> (x) { it }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) + -> { eval("-> () { it }") }.should.raise(SyntaxError, /ordinary parameter is defined/) + -> { eval("-> (x) { it }") }.should.raise(SyntaxError, /ordinary parameter is defined/) - -> { eval("proc { || it }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) - -> { eval("proc { |x| it }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) + -> { eval("proc { || it }") }.should.raise(SyntaxError, /ordinary parameter is defined/) + -> { eval("proc { |x| it }") }.should.raise(SyntaxError, /ordinary parameter is defined/) - -> { eval("lambda { || it }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) - -> { eval("lambda { |x| it }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) + -> { eval("lambda { || it }") }.should.raise(SyntaxError, /ordinary parameter is defined/) + -> { eval("lambda { |x| it }") }.should.raise(SyntaxError, /ordinary parameter is defined/) - -> { eval("['a'].map { || it }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) - -> { eval("['a'].map { |x| it }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) + -> { eval("['a'].map { || it }") }.should.raise(SyntaxError, /ordinary parameter is defined/) + -> { eval("['a'].map { |x| it }") }.should.raise(SyntaxError, /ordinary parameter is defined/) end it "cannot be mixed with numbered parameters" do -> { eval("proc { it + _1 }") - }.should raise_error(SyntaxError, /numbered parameters are not allowed when 'it' is already used|'it' is already used in/) + }.should.raise(SyntaxError, /numbered parameters are not allowed when 'it' is already used|'it' is already used in/) -> { eval("proc { _1 + it }") - }.should raise_error(SyntaxError, /numbered parameter is already used in|'it' is not allowed when a numbered parameter is already used/) + }.should.raise(SyntaxError, /numbered parameter is already used in|'it' is not allowed when a numbered parameter is already used/) end it "affects block arity" do @@ -90,7 +90,7 @@ def o.it obj = Object.new def obj.foo; it; end - -> { obj.foo("a") }.should raise_error(ArgumentError, /wrong number of arguments/) + -> { obj.foo("a") }.should.raise(ArgumentError, /wrong number of arguments/) end context "given multiple arguments" do @@ -99,8 +99,8 @@ def obj.foo; it; end end it "raises ArgumentError for a proc" do - -> { -> { it }.call("a", "b") }.should raise_error(ArgumentError, "wrong number of arguments (given 2, expected 1)") - -> { lambda { it }.call("a", "b") }.should raise_error(ArgumentError, "wrong number of arguments (given 2, expected 1)") + -> { -> { it }.call("a", "b") }.should.raise(ArgumentError, "wrong number of arguments (given 2, expected 1)") + -> { lambda { it }.call("a", "b") }.should.raise(ArgumentError, "wrong number of arguments (given 2, expected 1)") end end end diff --git a/spec/ruby/language/keyword_arguments_spec.rb b/spec/ruby/language/keyword_arguments_spec.rb index d769839bdaa2a5..38edc24414d784 100644 --- a/spec/ruby/language/keyword_arguments_spec.rb +++ b/spec/ruby/language/keyword_arguments_spec.rb @@ -55,9 +55,9 @@ def m(*a, kw:) end m(kw: 1).should == [] - -> { m(kw: 1, kw2: 2) }.should raise_error(ArgumentError, 'unknown keyword: :kw2') - -> { m(kw: 1, true => false) }.should raise_error(ArgumentError, 'unknown keyword: true') - -> { m(kw: 1, a: 1, b: 2, c: 3) }.should raise_error(ArgumentError, 'unknown keywords: :a, :b, :c') + -> { m(kw: 1, kw2: 2) }.should.raise(ArgumentError, 'unknown keyword: :kw2') + -> { m(kw: 1, true => false) }.should.raise(ArgumentError, 'unknown keyword: true') + -> { m(kw: 1, a: 1, b: 2, c: 3) }.should.raise(ArgumentError, 'unknown keywords: :a, :b, :c') end it "raises ArgumentError exception when required keyword argument is not passed" do @@ -65,8 +65,8 @@ def m(a:, b:, c:) [a, b, c] end - -> { m(a: 1, b: 2) }.should raise_error(ArgumentError, /missing keyword: :c/) - -> { m() }.should raise_error(ArgumentError, /missing keywords: :a, :b, :c/) + -> { m(a: 1, b: 2) }.should.raise(ArgumentError, /missing keyword: :c/) + -> { m() }.should.raise(ArgumentError, /missing keywords: :a, :b, :c/) end it "raises ArgumentError for missing keyword arguments even if there are extra ones" do @@ -74,7 +74,7 @@ def m(a:) a end - -> { m(b: 1) }.should raise_error(ArgumentError, /missing keyword: :a/) + -> { m(b: 1) }.should.raise(ArgumentError, /missing keyword: :a/) end it "handle * and ** at the same call site" do @@ -95,7 +95,7 @@ def bar(a) end h2 = bar(h) - h2.should equal(h) + h2.should.equal?(h) Hash.ruby2_keywords_hash?(h).should == true end end diff --git a/spec/ruby/language/lambda_spec.rb b/spec/ruby/language/lambda_spec.rb index 8a73b51d2cff2b..2a2953bd97a8e9 100644 --- a/spec/ruby/language/lambda_spec.rb +++ b/spec/ruby/language/lambda_spec.rb @@ -11,23 +11,23 @@ def create_lambda end end - klass.new.create_lambda.should be_an_instance_of(Proc) + klass.new.create_lambda.should.instance_of?(Proc) end it "does not execute the block" do - -> { fail }.should be_an_instance_of(Proc) + -> { fail }.should.instance_of?(Proc) end it "returns a lambda" do - -> { }.lambda?.should be_true + -> { }.lambda?.should == true end it "may include a rescue clause" do - eval('-> do raise ArgumentError; rescue ArgumentError; 7; end').should be_an_instance_of(Proc) + eval('-> do raise ArgumentError; rescue ArgumentError; 7; end').should.instance_of?(Proc) end it "may include a ensure clause" do - eval('-> do 1; ensure; 2; end').should be_an_instance_of(Proc) + eval('-> do 1; ensure; 2; end').should.instance_of?(Proc) end it "has its own scope for local variables" do @@ -48,10 +48,10 @@ def create_lambda @d = -> do end ruby - @a.().should be_nil - @b.().should be_nil - @c.().should be_nil - @d.().should be_nil + @a.().should == nil + @b.().should == nil + @c.().should == nil + @d.().should == nil end end @@ -91,9 +91,9 @@ def create_lambda @a = -> (*) { } ruby - @a.().should be_nil - @a.(1).should be_nil - @a.(1, 2, 3).should be_nil + @a.().should == nil + @a.(1).should == nil + @a.(1, 2, 3).should == nil end evaluate <<-ruby do @@ -109,7 +109,7 @@ def create_lambda @a = -> (a:) { a } ruby - -> { @a.() }.should raise_error(ArgumentError) + -> { @a.() }.should.raise(ArgumentError) @a.(a: 1).should == 1 end @@ -125,9 +125,9 @@ def create_lambda @a = -> (**) { } ruby - @a.().should be_nil - @a.(a: 1, b: 2).should be_nil - -> { @a.(1) }.should raise_error(ArgumentError) + @a.().should == nil + @a.(a: 1, b: 2).should == nil + -> { @a.(1) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -142,8 +142,8 @@ def create_lambda @a = -> (&b) { b } ruby - @a.().should be_nil - @a.() { }.should be_an_instance_of(Proc) + @a.().should == nil + @a.() { }.should.instance_of?(Proc) end evaluate <<-ruby do @@ -151,8 +151,8 @@ def create_lambda ruby @a.(1, 2).should == [1, 2] - -> { @a.() }.should raise_error(ArgumentError) - -> { @a.(1) }.should raise_error(ArgumentError) + -> { @a.() }.should.raise(ArgumentError) + -> { @a.(1) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -193,9 +193,9 @@ def create_lambda @a = -> (*, &b) { b } ruby - @a.().should be_nil - @a.(1, 2, 3, 4).should be_nil - @a.(&(l = ->{})).should equal(l) + @a.().should == nil + @a.(1, 2, 3, 4).should == nil + @a.(&(l = ->{})).should.equal?(l) end evaluate <<-ruby do @@ -268,7 +268,7 @@ def create_lambda a = 1 -> { eval "-> (a=a) { a }" - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end end @@ -292,9 +292,9 @@ def a; 1; end ruby @a.call().should == :ok - -> { @a.call(a: 1) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { @a.call(**{a: 1}) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { @a.call("a" => 1) }.should raise_error(ArgumentError, 'no keywords accepted') + -> { @a.call(a: 1) }.should.raise(ArgumentError, 'no keywords accepted') + -> { @a.call(**{a: 1}) }.should.raise(ArgumentError, 'no keywords accepted') + -> { @a.call("a" => 1) }.should.raise(ArgumentError, 'no keywords accepted') end evaluate <<-ruby do @@ -302,7 +302,7 @@ def a; 1; end ruby @a.call({a: 1}).should == {a: 1} - -> { @a.call(a: 1) }.should raise_error(ArgumentError, 'no keywords accepted') + -> { @a.call(a: 1) }.should.raise(ArgumentError, 'no keywords accepted') end end @@ -317,25 +317,25 @@ def obj.define lambda { } end - obj.define.should equal(obj) + obj.define.should.equal?(obj) end it "does not execute the block" do - lambda { fail }.should be_an_instance_of(Proc) + lambda { fail }.should.instance_of?(Proc) end it "returns a lambda" do - lambda { }.lambda?.should be_true + lambda { }.lambda?.should == true end it "requires a block" do suppress_warning do - lambda { lambda }.should raise_error(ArgumentError) + lambda { lambda }.should.raise(ArgumentError) end end it "may include a rescue clause" do - eval('lambda do raise ArgumentError; rescue ArgumentError; 7; end').should be_an_instance_of(Proc) + eval('lambda do raise ArgumentError; rescue ArgumentError; 7; end').should.instance_of?(Proc) end context "with an implicit block" do @@ -348,7 +348,7 @@ def meth; lambda; end suppress_warning do -> { meth { 1 } - }.should raise_error(ArgumentError, /tried to create Proc object without a block/) + }.should.raise(ArgumentError, /tried to create Proc object without a block/) end end end @@ -359,8 +359,8 @@ def meth; lambda; end @b = lambda { || } ruby - @a.().should be_nil - @b.().should be_nil + @a.().should == nil + @b.().should == nil end end @@ -377,8 +377,8 @@ def m(*a) yield(*a) end @a = lambda { |a| a } ruby - lambda { m(&@a) }.should raise_error(ArgumentError) - lambda { m(1, 2, &@a) }.should raise_error(ArgumentError) + lambda { m(&@a) }.should.raise(ArgumentError) + lambda { m(1, 2, &@a) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -388,8 +388,8 @@ def m(*a) yield(*a) end @a.(1).should == 1 @a.([1, 2]).should == [1, 2] - lambda { @a.() }.should raise_error(ArgumentError) - lambda { @a.(1, 2) }.should raise_error(ArgumentError) + lambda { @a.() }.should.raise(ArgumentError) + lambda { @a.(1, 2) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -402,7 +402,7 @@ def m2() yield end m(1, &@a).should == 1 m([1, 2], &@a).should == [1, 2] - lambda { m2(&@a) }.should raise_error(ArgumentError) + lambda { m2(&@a) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -433,9 +433,9 @@ def m2() yield end @a = lambda { |*| } ruby - @a.().should be_nil - @a.(1).should be_nil - @a.(1, 2, 3).should be_nil + @a.().should == nil + @a.(1).should == nil + @a.(1, 2, 3).should == nil end evaluate <<-ruby do @@ -451,7 +451,7 @@ def m2() yield end @a = lambda { |a:| a } ruby - lambda { @a.() }.should raise_error(ArgumentError) + lambda { @a.() }.should.raise(ArgumentError) @a.(a: 1).should == 1 end @@ -467,9 +467,9 @@ def m2() yield end @a = lambda { |**| } ruby - @a.().should be_nil - @a.(a: 1, b: 2).should be_nil - lambda { @a.(1) }.should raise_error(ArgumentError) + @a.().should == nil + @a.(a: 1, b: 2).should == nil + lambda { @a.(1) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -484,8 +484,8 @@ def m2() yield end @a = lambda { |&b| b } ruby - @a.().should be_nil - @a.() { }.should be_an_instance_of(Proc) + @a.().should == nil + @a.() { }.should.instance_of?(Proc) end evaluate <<-ruby do @@ -533,9 +533,9 @@ def m2() yield end @a = lambda { |*, &b| b } ruby - @a.().should be_nil - @a.(1, 2, 3, 4).should be_nil - @a.(&(l = ->{})).should equal(l) + @a.().should == nil + @a.(1, 2, 3, 4).should == nil + @a.(&(l = ->{})).should.equal?(l) end evaluate <<-ruby do @@ -607,9 +607,9 @@ def m2() yield end ruby @a.call().should == :ok - -> { @a.call(a: 1) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { @a.call(**{a: 1}) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { @a.call("a" => 1) }.should raise_error(ArgumentError, 'no keywords accepted') + -> { @a.call(a: 1) }.should.raise(ArgumentError, 'no keywords accepted') + -> { @a.call(**{a: 1}) }.should.raise(ArgumentError, 'no keywords accepted') + -> { @a.call("a" => 1) }.should.raise(ArgumentError, 'no keywords accepted') end evaluate <<-ruby do @@ -617,7 +617,7 @@ def m2() yield end ruby @a.call({a: 1}).should == {a: 1} - -> { @a.call(a: 1) }.should raise_error(ArgumentError, 'no keywords accepted') + -> { @a.call(a: 1) }.should.raise(ArgumentError, 'no keywords accepted') end end end diff --git a/spec/ruby/language/line_spec.rb b/spec/ruby/language/line_spec.rb index fcadaa71d70578..2864798079c1ea 100644 --- a/spec/ruby/language/line_spec.rb +++ b/spec/ruby/language/line_spec.rb @@ -4,7 +4,7 @@ describe "The __LINE__ pseudo-variable" do it "raises a SyntaxError if assigned to" do - -> { eval("__LINE__ = 1") }.should raise_error(SyntaxError) + -> { eval("__LINE__ = 1") }.should.raise(SyntaxError) end before :each do diff --git a/spec/ruby/language/loop_spec.rb b/spec/ruby/language/loop_spec.rb index fd17b5391038b3..9b12765a5fe099 100644 --- a/spec/ruby/language/loop_spec.rb +++ b/spec/ruby/language/loop_spec.rb @@ -15,7 +15,7 @@ inner_loop = 123 break end - -> { inner_loop }.should raise_error(NameError) + -> { inner_loop }.should.raise(NameError) end it "returns the value passed to break if interrupted by break" do diff --git a/spec/ruby/language/metaclass_spec.rb b/spec/ruby/language/metaclass_spec.rb index fc8306797759f4..3bee823a751fe7 100644 --- a/spec/ruby/language/metaclass_spec.rb +++ b/spec/ruby/language/metaclass_spec.rb @@ -16,17 +16,17 @@ class << nil; self; end.should == NilClass end it "raises a TypeError for numbers" do - -> { class << 1; self; end }.should raise_error(TypeError) + -> { class << 1; self; end }.should.raise(TypeError) end it "raises a TypeError for symbols" do - -> { class << :symbol; self; end }.should raise_error(TypeError) + -> { class << :symbol; self; end }.should.raise(TypeError) end it "is a singleton Class instance" do cls = class << mock('x'); self; end cls.is_a?(Class).should == true - cls.should_not equal(Object) + cls.should_not.equal?(Object) end end @@ -57,20 +57,20 @@ class << @object end it "is not defined on the object's class" do - @object.class.const_defined?(:CONST).should be_false + @object.class.const_defined?(:CONST).should == false end it "is not defined in the metaclass opener's scope" do class << @object CONST end - -> { CONST }.should raise_error(NameError) + -> { CONST }.should.raise(NameError) end it "cannot be accessed via object::CONST" do -> do @object::CONST - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a NameError for anonymous_module::CONST" do @@ -81,16 +81,16 @@ class << @object -> do @object::CONST - end.should raise_error(NameError) + end.should.raise(NameError) end it "appears in the metaclass constant list" do constants = class << @object; constants; end - constants.should include(:CONST) + constants.should.include?(:CONST) end it "does not appear in the object's class constant list" do - @object.class.constants.should_not include(:CONST) + @object.class.constants.should_not.include?(:CONST) end it "is not preserved when the object is duped" do @@ -98,14 +98,14 @@ class << @object -> do class << @object; CONST; end - end.should raise_error(NameError) + end.should.raise(NameError) end it "is preserved when the object is cloned" do @object = @object.clone class << @object - CONST.should_not be_nil + CONST.should_not == nil end end end diff --git a/spec/ruby/language/method_spec.rb b/spec/ruby/language/method_spec.rb index 00a087b33730bf..324bd6cea5cb4a 100644 --- a/spec/ruby/language/method_spec.rb +++ b/spec/ruby/language/method_spec.rb @@ -19,7 +19,7 @@ def m(a) a end x = mock("splat argument") x.should_not_receive(:to_ary) - m(*x).should equal(x) + m(*x).should.equal?(x) end it "calls #to_a" do @@ -40,7 +40,7 @@ def m(a) a end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { m(*x) }.should raise_error(TypeError) + -> { m(*x) }.should.raise(TypeError) end end @@ -74,7 +74,7 @@ def m(a, b, *c, d, e) [a, b, c, d, e] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { m(*x, 2, 3) }.should raise_error(TypeError) + -> { m(*x, 2, 3) }.should.raise(TypeError) end end @@ -108,13 +108,13 @@ def m(a, b, *c, d, e) [a, b, c, d, e] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { m(1, *x, 2, 3) }.should raise_error(TypeError) + -> { m(1, *x, 2, 3) }.should.raise(TypeError) end it "copies the splatted array" do args = [3, 4] m(1, 2, *args, 4, 5).should == [1, 2, [3, 4], 4, 5] - m(1, 2, *args, 4, 5)[2].should_not equal(args) + m(1, 2, *args, 4, 5)[2].should_not.equal?(args) end it "allows an array being splatted to be modified by another argument" do @@ -153,7 +153,7 @@ def m(a, *b, c) [a, b, c] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { m(1, 2, *x) }.should raise_error(TypeError) + -> { m(1, 2, *x) }.should.raise(TypeError) end end @@ -217,7 +217,7 @@ def @o.[]=(a, b) ScratchPad.record [a, b] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { @o[*x] = 1 }.should raise_error(TypeError) + -> { @o[*x] = 1 }.should.raise(TypeError) end end @@ -255,7 +255,7 @@ def @o.[]=(a, b, *c, d, e) ScratchPad.record [a, b, c, d, e] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { @o[*x, 2, 3] = 4 }.should raise_error(TypeError) + -> { @o[*x, 2, 3] = 4 }.should.raise(TypeError) end end @@ -293,7 +293,7 @@ def @o.[]=(a, b, *c, d, e) ScratchPad.record [a, b, c, d, e] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { @o[1, 2, *x, 3] = 4 }.should raise_error(TypeError) + -> { @o[1, 2, *x, 3] = 4 }.should.raise(TypeError) end end @@ -331,7 +331,7 @@ def @o.[]=(a, b, *c, d, e) ScratchPad.record [a, b, c, d, e] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { @o[1, 2, 3, *x] = 4 }.should raise_error(TypeError) + -> { @o[1, 2, 3, *x] = 4 }.should.raise(TypeError) end end end @@ -368,7 +368,7 @@ def @o.m=(a, b) [a, b] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { @o.send :m=, *x, 1 }.should raise_error(TypeError) + -> { @o.send :m=, *x, 1 }.should.raise(TypeError) end end @@ -403,7 +403,7 @@ def @o.m=(a, b, *c, d, e) [a, b, c, d, e] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { @o.send :m=, *x, 2, 3, 4 }.should raise_error(TypeError) + -> { @o.send :m=, *x, 2, 3, 4 }.should.raise(TypeError) end end @@ -438,7 +438,7 @@ def @o.m=(a, b, *c, d, e) [a, b, c, d, e] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { @o.send :m=, 1, 2, *x, 3, 4 }.should raise_error(TypeError) + -> { @o.send :m=, 1, 2, *x, 3, 4 }.should.raise(TypeError) end end @@ -473,7 +473,7 @@ def @o.m=(a, b, *c, d, e) [a, b, c, d, e] end x = mock("splat argument") x.should_receive(:to_a).and_return(1) - -> { @o.send :m=, 1, 2, 3, *x, 4 }.should raise_error(TypeError) + -> { @o.send :m=, 1, 2, 3, *x, 4 }.should.raise(TypeError) end end end @@ -487,7 +487,7 @@ def m end ruby - m.should be_nil + m.should == nil end evaluate <<-ruby do @@ -495,7 +495,7 @@ def m() end ruby - m.should be_nil + m.should == nil end end @@ -504,7 +504,7 @@ def m() def m(a) a end ruby - m((args = 1, 2, 3)).should equal(args) + m((args = 1, 2, 3)).should.equal?(args) end evaluate <<-ruby do @@ -535,18 +535,18 @@ def m(a=1) a end def m() end ruby - m().should be_nil - m(*[]).should be_nil - m(**{}).should be_nil + m().should == nil + m(*[]).should == nil + m(**{}).should == nil end evaluate <<-ruby do def m(*) end ruby - m().should be_nil - m(1).should be_nil - m(1, 2, 3).should be_nil + m().should == nil + m(1).should == nil + m(1, 2, 3).should == nil end evaluate <<-ruby do @@ -564,10 +564,10 @@ def m(*a) a end def m(a:) a end ruby - -> { m() }.should raise_error(ArgumentError) + -> { m() }.should.raise(ArgumentError) m(a: 1).should == 1 suppress_keyword_warning do - -> { m("a" => 1, a: 1) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1) }.should.raise(ArgumentError) end end @@ -575,7 +575,7 @@ def m(a:) a end def m(a:, **kw) [a, kw] end ruby - -> { m(b: 1) }.should raise_error(ArgumentError) + -> { m(b: 1) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -590,9 +590,9 @@ def m(a: 1) a end def m(**) end ruby - m().should be_nil - m(a: 1, b: 2).should be_nil - -> { m(1) }.should raise_error(ArgumentError) + m().should == nil + m(a: 1, b: 2).should == nil + -> { m(1) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -606,7 +606,7 @@ def m(**k) k end suppress_warning { eval "m(**{a: 1, b: 2}, **{a: 4, c: 7})" }.should == { a: 4, b: 2, c: 7 } - -> { m(2) }.should raise_error(ArgumentError) + -> { m(2) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -620,7 +620,7 @@ def m(**k); k end; def m(&b) b end ruby - m { }.should be_an_instance_of(Proc) + m { }.should.instance_of?(Proc) end evaluate <<-ruby do @@ -650,9 +650,9 @@ def m((a), (b)) [a, b] end def m((*), (*)) end ruby - m(2, 3).should be_nil - m([2, 3, 4], [5, 6]).should be_nil - -> { m a: 1 }.should raise_error(ArgumentError) + m(2, 3).should == nil + m([2, 3, 4], [5, 6]).should == nil + -> { m a: 1 }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -745,7 +745,7 @@ def m(a, b:) [a, b] end m(1, b: 2).should == [1, 2] suppress_keyword_warning do - -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, b: 2) }.should.raise(ArgumentError) end end @@ -755,7 +755,7 @@ def m(a, b: 1) [a, b] end m(2).should == [2, 1] m(1, b: 2).should == [1, 2] - -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, b: 2) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -764,7 +764,7 @@ def m(a, **) a end m(1).should == 1 m(1, a: 2, b: 3).should == 1 - -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, b: 2) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -773,7 +773,7 @@ def m(a, **k) [a, k] end m(1).should == [1, {}] m(1, a: 2, b: 3).should == [1, {a: 2, b: 3}] - -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, b: 2) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -848,8 +848,8 @@ def m(a=1, (b), (c)) [a, b, c] end def m(a=1, (*b), (*c)) [a, b, c] end ruby - -> { m() }.should raise_error(ArgumentError) - -> { m(2) }.should raise_error(ArgumentError) + -> { m() }.should.raise(ArgumentError) + -> { m(2) }.should.raise(ArgumentError) m(2, 3).should == [1, [2], [3]] m(2, [3, 4], [5, 6]).should == [2, [3, 4], [5, 6]] end @@ -890,7 +890,7 @@ def m(a=1, b:) [a, b] end m(b: 2).should == [1, 2] m(2, b: 1).should == [2, 1] - -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, b: 2) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -900,7 +900,7 @@ def m(a=1, b: 2) [a, b] end m().should == [1, 2] m(2).should == [2, 2] m(b: 3).should == [1, 3] - -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, b: 2) }.should.raise(ArgumentError) end evaluate <<-ruby do @@ -953,9 +953,9 @@ def m(*a, b) [a, b] end def m(*, &b) b end ruby - m().should be_nil - m(1, 2, 3, 4).should be_nil - m(&(l = ->{})).should equal(l) + m().should == nil + m(1, 2, 3, 4).should == nil + m(&(l = ->{})).should.equal?(l) end evaluate <<-ruby do @@ -973,7 +973,7 @@ def m(a:, b:) [a, b] end m(a: 1, b: 2).should == [1, 2] suppress_keyword_warning do - -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should.raise(ArgumentError) end end @@ -984,7 +984,7 @@ def m(a:, b: 1) [a, b] end m(a: 1).should == [1, 1] m(a: 1, b: 2).should == [1, 2] suppress_keyword_warning do - -> { m("a" => 1, a: 1, b: 2) }.should raise_error(ArgumentError) + -> { m("a" => 1, a: 1, b: 2) }.should.raise(ArgumentError) end end @@ -1105,9 +1105,9 @@ def m(**nil); :ok; end; ruby m().should == :ok - -> { m(a: 1) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { m(**{a: 1}) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { m("a" => 1) }.should raise_error(ArgumentError, 'no keywords accepted') + -> { m(a: 1) }.should.raise(ArgumentError, 'no keywords accepted') + -> { m(**{a: 1}) }.should.raise(ArgumentError, 'no keywords accepted') + -> { m("a" => 1) }.should.raise(ArgumentError, 'no keywords accepted') end evaluate <<-ruby do @@ -1117,9 +1117,9 @@ def m(a, **nil); a end; m({a: 1}).should == {a: 1} m({"a" => 1}).should == {"a" => 1} - -> { m(a: 1) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { m(**{a: 1}) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { m("a" => 1) }.should raise_error(ArgumentError, 'no keywords accepted') + -> { m(a: 1) }.should.raise(ArgumentError, 'no keywords accepted') + -> { m(**{a: 1}) }.should.raise(ArgumentError, 'no keywords accepted') + -> { m("a" => 1) }.should.raise(ArgumentError, 'no keywords accepted') end evaluate <<-ruby do @@ -1145,8 +1145,8 @@ def m(a, &nil); a end; m(1).should == 1 - -> { m(1) {} }.should raise_error(ArgumentError, 'no block accepted') - -> { m(1, &proc {}) }.should raise_error(ArgumentError, 'no block accepted') + -> { m(1) {} }.should.raise(ArgumentError, 'no block accepted') + -> { m(1, &proc {}) }.should.raise(ArgumentError, 'no block accepted') end end end @@ -1169,7 +1169,7 @@ def m(a); a; end -> do m(**h).should == {} - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end end @@ -1181,7 +1181,7 @@ def m(a: nil); a; end options = {a: 1}.freeze -> do m(options) - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end end @@ -1203,8 +1203,8 @@ def m(a = nil, b = {}, v: false) def m(**kw) kw; end h = nil - -> { m(a: 1, **h) }.should raise_error(TypeError, "no implicit conversion of nil into Hash") - -> { m(a: 1, **nil) }.should raise_error(TypeError, "no implicit conversion of nil into Hash") + -> { m(a: 1, **h) }.should.raise(TypeError, "no implicit conversion of nil into Hash") + -> { m(a: 1, **nil) }.should.raise(TypeError, "no implicit conversion of nil into Hash") end end @@ -1277,11 +1277,11 @@ def n(value, &block) it "raises a syntax error" do -> { eval("m (1, 2)") - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) -> { eval("m (1, 2, 3)") - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end end @@ -1431,7 +1431,7 @@ def foo(a, b, c, **hsh) -> { foo(1, 2, 3, { key: 42 }) - }.should raise_error(ArgumentError, 'wrong number of arguments (given 4, expected 3)') + }.should.raise(ArgumentError, 'wrong number of arguments (given 4, expected 3)') end end @@ -1444,7 +1444,7 @@ def foo(a, b, c, key: 1) -> { foo(1, 2, 3, { key: 42 }) - }.should raise_error(ArgumentError, 'wrong number of arguments (given 4, expected 3)') + }.should.raise(ArgumentError, 'wrong number of arguments (given 4, expected 3)') end end diff --git a/spec/ruby/language/module_spec.rb b/spec/ruby/language/module_spec.rb index fba4aa8c6e68b7..2f22e383d54c30 100644 --- a/spec/ruby/language/module_spec.rb +++ b/spec/ruby/language/module_spec.rb @@ -4,28 +4,28 @@ describe "The module keyword" do it "creates a new module without semicolon" do module ModuleSpecsKeywordWithoutSemicolon end - ModuleSpecsKeywordWithoutSemicolon.should be_an_instance_of(Module) + ModuleSpecsKeywordWithoutSemicolon.should.instance_of?(Module) end it "creates a new module with a non-qualified constant name" do module ModuleSpecsToplevel; end - ModuleSpecsToplevel.should be_an_instance_of(Module) + ModuleSpecsToplevel.should.instance_of?(Module) end it "creates a new module with a qualified constant name" do module ModuleSpecs::Nested; end - ModuleSpecs::Nested.should be_an_instance_of(Module) + ModuleSpecs::Nested.should.instance_of?(Module) end it "creates a new module with a variable qualified constant name" do m = Module.new module m::N; end - m::N.should be_an_instance_of(Module) + m::N.should.instance_of?(Module) end it "reopens an existing module" do module ModuleSpecs; Reopened = true; end - ModuleSpecs::Reopened.should be_true + ModuleSpecs::Reopened.should == true ensure ModuleSpecs.send(:remove_const, :Reopened) end @@ -64,34 +64,34 @@ module IncludedModule; end it "raises a TypeError if the constant is a Class" do -> do module ModuleSpecs::Modules::Klass; end - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if the constant is a String" do - -> { module ModuleSpecs::Modules::A; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::A; end }.should.raise(TypeError) end it "raises a TypeError if the constant is an Integer" do - -> { module ModuleSpecs::Modules::B; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::B; end }.should.raise(TypeError) end it "raises a TypeError if the constant is nil" do - -> { module ModuleSpecs::Modules::C; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::C; end }.should.raise(TypeError) end it "raises a TypeError if the constant is true" do - -> { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::D; end }.should.raise(TypeError) end it "raises a TypeError if the constant is false" do - -> { module ModuleSpecs::Modules::D; end }.should raise_error(TypeError) + -> { module ModuleSpecs::Modules::D; end }.should.raise(TypeError) end end describe "Assigning an anonymous module to a constant" do it "sets the name of the module" do mod = Module.new - mod.name.should be_nil + mod.name.should == nil ::ModuleSpecs_CS1 = mod mod.name.should == "ModuleSpecs_CS1" diff --git a/spec/ruby/language/next_spec.rb b/spec/ruby/language/next_spec.rb index 6fbfc4a54d8ae3..eac151eeb30bfb 100644 --- a/spec/ruby/language/next_spec.rb +++ b/spec/ruby/language/next_spec.rb @@ -21,7 +21,7 @@ end it "causes block to return nil if invoked with an empty expression" do - -> { next (); 456 }.call.should be_nil + -> { next (); 456 }.call.should == nil end it "returns the argument passed" do @@ -111,7 +111,7 @@ def self.enclosing_method it "is invalid and raises a SyntaxError" do -> { eval("def m; next; end") - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end end end diff --git a/spec/ruby/language/not_spec.rb b/spec/ruby/language/not_spec.rb index 052af9b2568bed..23411a8e1ddb47 100644 --- a/spec/ruby/language/not_spec.rb +++ b/spec/ruby/language/not_spec.rb @@ -2,50 +2,50 @@ describe "The not keyword" do it "negates a `true' value" do - (not true).should be_false - (not 'true').should be_false + (not true).should == false + (not 'true').should == false end it "negates a `false' value" do - (not false).should be_true - (not nil).should be_true + (not false).should == true + (not nil).should == true end it "accepts an argument" do - not(true).should be_false + not(true).should == false end it "returns false if the argument is true" do - (not(true)).should be_false + (not(true)).should == false end it "returns true if the argument is false" do - (not(false)).should be_true + (not(false)).should == true end it "returns true if the argument is nil" do - (not(nil)).should be_true + (not(nil)).should == true end end describe "The `!' keyword" do it "negates a `true' value" do - (!true).should be_false - (!'true').should be_false + (!true).should == false + (!'true').should == false end it "negates a `false' value" do - (!false).should be_true - (!nil).should be_true + (!false).should == true + (!nil).should == true end it "doubled turns a truthful object into `true'" do - (!!true).should be_true - (!!'true').should be_true + (!!true).should == true + (!!'true').should == true end it "doubled turns a not truthful object into `false'" do - (!!false).should be_false - (!!nil).should be_false + (!!false).should == false + (!!nil).should == false end end diff --git a/spec/ruby/language/numbered_parameters_spec.rb b/spec/ruby/language/numbered_parameters_spec.rb index de532c326d4cd1..23e89a14be9065 100644 --- a/spec/ruby/language/numbered_parameters_spec.rb +++ b/spec/ruby/language/numbered_parameters_spec.rb @@ -22,13 +22,13 @@ it "does not support more than 9 parameters" do -> { proc { [_10] }.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - }.should raise_error(NameError, /undefined local variable or method [`']_10'/) + }.should.raise(NameError, /undefined local variable or method [`']_10'/) end it "can not be used in both outer and nested blocks at the same time" do -> { eval("-> { _1; -> { _2 } }") - }.should raise_error(SyntaxError, /numbered parameter is already used in/m) + }.should.raise(SyntaxError, /numbered parameter is already used in/m) end it "cannot be overwritten with local variable" do @@ -37,32 +37,32 @@ _1 = 0 proc { _1 }.call("a").should == 0 CODE - }.should raise_error(SyntaxError, /_1 is reserved for numbered parameter/) + }.should.raise(SyntaxError, /_1 is reserved for numbered parameter/) end it "errors when numbered parameter is overwritten with local variable" do -> { eval("_1 = 0") - }.should raise_error(SyntaxError, /_1 is reserved for numbered parameter/) + }.should.raise(SyntaxError, /_1 is reserved for numbered parameter/) end it "raises SyntaxError when block parameters are specified explicitly" do - -> { eval("-> () { _1 }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) - -> { eval("-> (x) { _1 }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) + -> { eval("-> () { _1 }") }.should.raise(SyntaxError, /ordinary parameter is defined/) + -> { eval("-> (x) { _1 }") }.should.raise(SyntaxError, /ordinary parameter is defined/) - -> { eval("proc { || _1 }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) - -> { eval("proc { |x| _1 }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) + -> { eval("proc { || _1 }") }.should.raise(SyntaxError, /ordinary parameter is defined/) + -> { eval("proc { |x| _1 }") }.should.raise(SyntaxError, /ordinary parameter is defined/) - -> { eval("lambda { || _1 }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) - -> { eval("lambda { |x| _1 }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) + -> { eval("lambda { || _1 }") }.should.raise(SyntaxError, /ordinary parameter is defined/) + -> { eval("lambda { |x| _1 }") }.should.raise(SyntaxError, /ordinary parameter is defined/) - -> { eval("['a'].map { || _1 }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) - -> { eval("['a'].map { |x| _1 }") }.should raise_error(SyntaxError, /ordinary parameter is defined/) + -> { eval("['a'].map { || _1 }") }.should.raise(SyntaxError, /ordinary parameter is defined/) + -> { eval("['a'].map { |x| _1 }") }.should.raise(SyntaxError, /ordinary parameter is defined/) end describe "assigning to a numbered parameter" do it "raises SyntaxError" do - -> { eval("proc { _1 = 0 }") }.should raise_error(SyntaxError, /_1 is reserved for numbered parameter/) + -> { eval("proc { _1 = 0 }") }.should.raise(SyntaxError, /_1 is reserved for numbered parameter/) end end @@ -108,6 +108,6 @@ obj = Object.new def obj.foo; _1 end - -> { obj.foo("a") }.should raise_error(ArgumentError, /wrong number of arguments/) + -> { obj.foo("a") }.should.raise(ArgumentError, /wrong number of arguments/) end end diff --git a/spec/ruby/language/numbers_spec.rb b/spec/ruby/language/numbers_spec.rb index a8e023efb6ac0e..ed0e49c048df71 100644 --- a/spec/ruby/language/numbers_spec.rb +++ b/spec/ruby/language/numbers_spec.rb @@ -11,7 +11,7 @@ end it "cannot have a leading underscore" do - -> { eval("_4_2") }.should raise_error(NameError) + -> { eval("_4_2") }.should.raise(NameError) end it "can have a decimal point" do @@ -20,8 +20,8 @@ it "must have a digit before the decimal point" do 0.75.should == 0.75 - -> { eval(".75") }.should raise_error(SyntaxError) - -> { eval("-.75") }.should raise_error(SyntaxError) + -> { eval(".75") }.should.raise(SyntaxError) + -> { eval("-.75") }.should.raise(SyntaxError) end it "can have an exponent" do diff --git a/spec/ruby/language/optional_assignments_spec.rb b/spec/ruby/language/optional_assignments_spec.rb index 5fe3e3671b4c32..ebb5d3635170a4 100644 --- a/spec/ruby/language/optional_assignments_spec.rb +++ b/spec/ruby/language/optional_assignments_spec.rb @@ -603,7 +603,7 @@ def []=(k1, k2, k3, v) end it 'with &&= assignments will fail with non-existent constants' do - -> { Object::A &&= 10 }.should raise_error(NameError) + -> { Object::A &&= 10 }.should.raise(NameError) end it 'with operator assignments' do @@ -615,7 +615,7 @@ def []=(k1, k2, k3, v) end it 'with operator assignments will fail with non-existent constants' do - -> { Object::A += 10 }.should raise_error(NameError) + -> { Object::A += 10 }.should.raise(NameError) end end end @@ -623,7 +623,7 @@ def []=(k1, k2, k3, v) describe 'Optional constant assignment' do describe 'with ||=' do it "assigns a scoped constant if previously undefined" do - ConstantSpecs.should_not have_constant(:OpAssignUndefined) + ConstantSpecs.should_not.const_defined?(:OpAssignUndefined) module ConstantSpecs OpAssignUndefined ||= 42 end @@ -679,7 +679,7 @@ module ConstantSpecs -> { (x += 1; raise Exception; ConstantSpecs::ClassA)::OR_ASSIGNED_CONSTANT3 ||= (y += 1; :assigned) - }.should raise_error(Exception) + }.should.raise(Exception) x.should == 1 y.should == 0 @@ -693,7 +693,7 @@ module ConstantSpecs -> { (x += 1; raise Exception; ConstantSpecs::ClassA)::NIL_OR_ASSIGNED_CONSTANT3 ||= (y += 1; :assigned) - }.should raise_error(Exception) + }.should.raise(Exception) x.should == 1 y.should == 0 diff --git a/spec/ruby/language/or_spec.rb b/spec/ruby/language/or_spec.rb index fb75e788f16d39..8ae577a142b2d3 100644 --- a/spec/ruby/language/or_spec.rb +++ b/spec/ruby/language/or_spec.rb @@ -26,24 +26,24 @@ end it "treats empty expressions as nil" do - (() || true).should be_true - (() || false).should be_false - (true || ()).should be_true - (false || ()).should be_nil - (() || ()).should be_nil + (() || true).should == true + (() || false).should == false + (true || ()).should == true + (false || ()).should == nil + (() || ()).should == nil end it "has a higher precedence than 'break' in 'break true || false'" do # see also 'break true or false' below - -> { break false || true }.call.should be_true + -> { break false || true }.call.should == true end it "has a higher precedence than 'next' in 'next true || false'" do - -> { next false || true }.call.should be_true + -> { next false || true }.call.should == true end it "has a higher precedence than 'return' in 'return true || false'" do - -> { return false || true }.call.should be_true + -> { return false || true }.call.should == true end end @@ -68,23 +68,23 @@ end it "treats empty expressions as nil" do - (() or true).should be_true - (() or false).should be_false - (true or ()).should be_true - (false or ()).should be_nil - (() or ()).should be_nil + (() or true).should == true + (() or false).should == false + (true or ()).should == true + (false or ()).should == nil + (() or ()).should == nil end it "has a lower precedence than 'break' in 'break true or false'" do # see also 'break true || false' above - -> { eval "break true or false" }.should raise_error(SyntaxError, /void value expression/) + -> { eval "break true or false" }.should.raise(SyntaxError, /void value expression/) end it "has a lower precedence than 'next' in 'next true or false'" do - -> { eval "next true or false" }.should raise_error(SyntaxError, /void value expression/) + -> { eval "next true or false" }.should.raise(SyntaxError, /void value expression/) end it "has a lower precedence than 'return' in 'return true or false'" do - -> { eval "return true or false" }.should raise_error(SyntaxError, /void value expression/) + -> { eval "return true or false" }.should.raise(SyntaxError, /void value expression/) end end diff --git a/spec/ruby/language/pattern_matching_spec.rb b/spec/ruby/language/pattern_matching_spec.rb index c1a6f0e4d63686..a24500c9fd0b16 100644 --- a/spec/ruby/language/pattern_matching_spec.rb +++ b/spec/ruby/language/pattern_matching_spec.rb @@ -185,7 +185,7 @@ in [] end RUBY - }.should raise_error(SyntaxError, /syntax error, unexpected `in'|\(eval\):3: syntax error, unexpected keyword_in|unexpected 'in'/) + }.should.raise(SyntaxError, /syntax error, unexpected `in'|\(eval\):3: syntax error, unexpected keyword_in|unexpected 'in'/) -> { eval <<~RUBY @@ -194,7 +194,7 @@ when 1 == 1 end RUBY - }.should raise_error(SyntaxError, /syntax error, unexpected `when'|\(eval\):3: syntax error, unexpected keyword_when|unexpected 'when'/) + }.should.raise(SyntaxError, /syntax error, unexpected `when'|\(eval\):3: syntax error, unexpected keyword_when|unexpected 'when'/) end it "checks patterns until the first matching" do @@ -222,14 +222,14 @@ case [0, 1] in [0] end - }.should raise_error(NoMatchingPatternError, /\[0, 1\]/) + }.should.raise(NoMatchingPatternError, /\[0, 1\]/) error_pattern = ruby_version_is("3.4") ? /\{a: 0, b: 1\}/ : /\{:a=>0, :b=>1\}/ -> { case {a: 0, b: 1} in a: 1, b: 1 end - }.should raise_error(NoMatchingPatternError, error_pattern) + }.should.raise(NoMatchingPatternError, error_pattern) end it "raises NoMatchingPatternError if no pattern matches and evaluates the expression only once" do @@ -238,7 +238,7 @@ case (evals += 1; [0, 1]) in [0] end - }.should raise_error(NoMatchingPatternError, /\[0, 1\]/) + }.should.raise(NoMatchingPatternError, /\[0, 1\]/) evals.should == 1 end @@ -250,7 +250,7 @@ true end RUBY - }.should raise_error(SyntaxError, /unexpected|expected a delimiter after the patterns of an `in` clause/) + }.should.raise(SyntaxError, /unexpected|expected a delimiter after the patterns of an `in` clause/) end it "evaluates the case expression once for multiple patterns, caching the result" do @@ -336,7 +336,7 @@ case [0, 1] in [0, 1] if false end - }.should raise_error(NoMatchingPatternError, /\[0, 1\]/) + }.should.raise(NoMatchingPatternError, /\[0, 1\]/) end end @@ -438,7 +438,7 @@ in [a, a] end RUBY - }.should raise_error(SyntaxError, /duplicated variable name/) + }.should.raise(SyntaxError, /duplicated variable name/) end it "supports existing variables in a pattern specified with ^ operator" do @@ -474,7 +474,7 @@ false end RUBY - }.should raise_error(SyntaxError, /n: no such local variable/) + }.should.raise(SyntaxError, /n: no such local variable/) end end @@ -493,7 +493,7 @@ in [0, 0] | [0, a] end RUBY - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "support underscore prefixed variables in alternation" do @@ -674,7 +674,7 @@ def obj.deconstruct in Object[] else end - }.should raise_error(TypeError, /deconstruct must return Array/) + }.should.raise(TypeError, /deconstruct must return Array/) end it "accepts a subclass of Array from #deconstruct" do @@ -870,7 +870,7 @@ def obj.deconstruct in {"a" => 1} end RUBY - }.should raise_error(SyntaxError, /unexpected|expected a label as the key in the hash pattern/) + }.should.raise(SyntaxError, /unexpected|expected a label as the key in the hash pattern/) end it "does not support string interpolation in keys" do @@ -880,7 +880,7 @@ def obj.deconstruct in {"#{x}": 1} end RUBY - }.should raise_error(SyntaxError, /symbol literal with interpolation is not allowed|expected a label as the key in the hash pattern/) + }.should.raise(SyntaxError, /symbol literal with interpolation is not allowed|expected a label as the key in the hash pattern/) end it "raise SyntaxError when keys duplicate in pattern" do @@ -890,7 +890,7 @@ def obj.deconstruct in {a: 1, b: 2, a: 3} end RUBY - }.should raise_error(SyntaxError, /duplicated key name/) + }.should.raise(SyntaxError, /duplicated key name/) end it "matches an object with #deconstruct_keys method which returns a Hash with equal keys and each value in Hash matches value in pattern" do @@ -969,7 +969,7 @@ def obj.deconstruct_keys(*) case obj in Object[a: 1] end - }.should raise_error(TypeError, /deconstruct_keys must return Hash/) + }.should.raise(TypeError, /deconstruct_keys must return Hash/) end it "does not match object if #deconstruct_keys method returns Hash with non-symbol keys" do diff --git a/spec/ruby/language/precedence_spec.rb b/spec/ruby/language/precedence_spec.rb index 5e606c16d86af3..edb990525eef14 100644 --- a/spec/ruby/language/precedence_spec.rb +++ b/spec/ruby/language/precedence_spec.rb @@ -251,12 +251,12 @@ def >=(a); 0; end; end it "<=> == === != =~ !~ are non-associative" do - -> { eval("1 <=> 2 <=> 3") }.should raise_error(SyntaxError) - -> { eval("1 == 2 == 3") }.should raise_error(SyntaxError) - -> { eval("1 === 2 === 3") }.should raise_error(SyntaxError) - -> { eval("1 != 2 != 3") }.should raise_error(SyntaxError) - -> { eval("1 =~ 2 =~ 3") }.should raise_error(SyntaxError) - -> { eval("1 !~ 2 !~ 3") }.should raise_error(SyntaxError) + -> { eval("1 <=> 2 <=> 3") }.should.raise(SyntaxError) + -> { eval("1 == 2 == 3") }.should.raise(SyntaxError) + -> { eval("1 === 2 === 3") }.should.raise(SyntaxError) + -> { eval("1 != 2 != 3") }.should.raise(SyntaxError) + -> { eval("1 =~ 2 =~ 3") }.should.raise(SyntaxError) + -> { eval("1 !~ 2 !~ 3") }.should.raise(SyntaxError) end it "<=> == === != =~ !~ have higher precedence than &&" do @@ -290,8 +290,8 @@ class FalseClass; undef_method :=~; end end it ".. ... are non-associative" do - -> { eval("1..2..3") }.should raise_error(SyntaxError) - -> { eval("1...2...3") }.should raise_error(SyntaxError) + -> { eval("1..2..3") }.should.raise(SyntaxError) + -> { eval("1...2...3") }.should.raise(SyntaxError) end it ".. ... have higher precedence than ? :" do diff --git a/spec/ruby/language/predefined_spec.rb b/spec/ruby/language/predefined_spec.rb index 948ad2647528ac..d57b924bcf6fff 100644 --- a/spec/ruby/language/predefined_spec.rb +++ b/spec/ruby/language/predefined_spec.rb @@ -40,12 +40,12 @@ describe "Predefined global $~" do it "is set to contain the MatchData object of the last match if successful" do md = /foo/.match 'foo' - $~.should be_kind_of(MatchData) - $~.should equal md + $~.should.is_a?(MatchData) + $~.should.equal? md /bar/ =~ 'bar' - $~.should be_kind_of(MatchData) - $~.should_not equal md + $~.should.is_a?(MatchData) + $~.should_not.equal? md end it "is set to nil if the last match was unsuccessful" do @@ -87,10 +87,10 @@ def obj.foo2(&proc); proc.call; end $~ = nil $~.should == nil $~ = /foo/.match("foo") - $~.should be_an_instance_of(MatchData) + $~.should.instance_of?(MatchData) - -> { $~ = Object.new }.should raise_error(TypeError, 'wrong argument type Object (expected MatchData)') - -> { $~ = 1 }.should raise_error(TypeError, 'wrong argument type Integer (expected MatchData)') + -> { $~ = Object.new }.should.raise(TypeError, 'wrong argument type Object (expected MatchData)') + -> { $~ = 1 }.should.raise(TypeError, 'wrong argument type Integer (expected MatchData)') end it "changes the value of derived capture globals when assigned" do @@ -135,20 +135,20 @@ def obj.foo2(&proc); proc.call; end it "sets the encoding to the encoding of the source String" do "abc".dup.force_encoding(Encoding::EUC_JP) =~ /b/ - $&.encoding.should equal(Encoding::EUC_JP) + $&.encoding.should.equal?(Encoding::EUC_JP) end it "is read-only" do -> { eval %q{$& = ""} - }.should raise_error(SyntaxError, /Can't set variable \$&/) + }.should.raise(SyntaxError, /Can't set variable \$&/) end it "is read-only when aliased" do alias $predefined_spec_ampersand $& -> { $predefined_spec_ampersand = "" - }.should raise_error(NameError, '$predefined_spec_ampersand is a read-only variable') + }.should.raise(NameError, '$predefined_spec_ampersand is a read-only variable') end end @@ -161,25 +161,25 @@ def obj.foo2(&proc); proc.call; end it "sets the encoding to the encoding of the source String" do "abc".dup.force_encoding(Encoding::EUC_JP) =~ /b/ - $`.encoding.should equal(Encoding::EUC_JP) + $`.encoding.should.equal?(Encoding::EUC_JP) end it "sets an empty result to the encoding of the source String" do "abc".dup.force_encoding(Encoding::ISO_8859_1) =~ /a/ - $`.encoding.should equal(Encoding::ISO_8859_1) + $`.encoding.should.equal?(Encoding::ISO_8859_1) end it "is read-only" do -> { eval %q{$` = ""} - }.should raise_error(SyntaxError, /Can't set variable \$`/) + }.should.raise(SyntaxError, /Can't set variable \$`/) end it "is read-only when aliased" do alias $predefined_spec_backquote $` -> { $predefined_spec_backquote = "" - }.should raise_error(NameError, '$predefined_spec_backquote is a read-only variable') + }.should.raise(NameError, '$predefined_spec_backquote is a read-only variable') end end @@ -192,25 +192,25 @@ def obj.foo2(&proc); proc.call; end it "sets the encoding to the encoding of the source String" do "abc".dup.force_encoding(Encoding::EUC_JP) =~ /b/ - $'.encoding.should equal(Encoding::EUC_JP) + $'.encoding.should.equal?(Encoding::EUC_JP) end it "sets an empty result to the encoding of the source String" do "abc".dup.force_encoding(Encoding::ISO_8859_1) =~ /c/ - $'.encoding.should equal(Encoding::ISO_8859_1) + $'.encoding.should.equal?(Encoding::ISO_8859_1) end it "is read-only" do -> { eval %q{$' = ""} - }.should raise_error(SyntaxError, /Can't set variable \$'/) + }.should.raise(SyntaxError, /Can't set variable \$'/) end it "is read-only when aliased" do alias $predefined_spec_single_quote $' -> { $predefined_spec_single_quote = "" - }.should raise_error(NameError, '$predefined_spec_single_quote is a read-only variable') + }.should.raise(NameError, '$predefined_spec_single_quote is a read-only variable') end end @@ -228,20 +228,20 @@ def obj.foo2(&proc); proc.call; end it "sets the encoding to the encoding of the source String" do "abc".dup.force_encoding(Encoding::EUC_JP) =~ /(b)/ - $+.encoding.should equal(Encoding::EUC_JP) + $+.encoding.should.equal?(Encoding::EUC_JP) end it "is read-only" do -> { eval %q{$+ = ""} - }.should raise_error(SyntaxError, /Can't set variable \$\+/) + }.should.raise(SyntaxError, /Can't set variable \$\+/) end it "is read-only when aliased" do alias $predefined_spec_plus $+ -> { $predefined_spec_plus = "" - }.should raise_error(NameError, '$predefined_spec_plus is a read-only variable') + }.should.raise(NameError, '$predefined_spec_plus is a read-only variable') end end @@ -268,7 +268,7 @@ def test(arg) it "sets the encoding to the encoding of the source String" do "abc".dup.force_encoding(Encoding::EUC_JP) =~ /(b)/ - $1.encoding.should equal(Encoding::EUC_JP) + $1.encoding.should.equal?(Encoding::EUC_JP) end end @@ -282,16 +282,16 @@ def test(arg) end it "raises TypeError error if assigned to nil" do - -> { $stdout = nil }.should raise_error(TypeError, '$stdout must have write method, NilClass given') + -> { $stdout = nil }.should.raise(TypeError, '$stdout must have write method, NilClass given') end it "raises TypeError error if assigned to object that doesn't respond to #write" do obj = mock('object') - -> { $stdout = obj }.should raise_error(TypeError) + -> { $stdout = obj }.should.raise(TypeError) obj.stub!(:write) $stdout = obj - $stdout.should equal(obj) + $stdout.should.equal?(obj) end end @@ -309,7 +309,7 @@ def test(arg) it "is read-only" do -> { $! = [] - }.should raise_error(NameError, '$! is a read-only variable') + }.should.raise(NameError, '$! is a read-only variable') end # See http://jira.codehaus.org/browse/JRUBY-5550 @@ -586,7 +586,7 @@ def foo begin raise rescue - $@.should be_an_instance_of(Array) + $@.should.instance_of?(Array) $@.should == $!.backtrace end end @@ -608,7 +608,7 @@ def foo begin raise rescue - $@.should be_an_instance_of(Array) + $@.should.instance_of?(Array) $@.should == $!.backtrace end end @@ -636,7 +636,7 @@ def foo it "cannot be assigned when there is no a rescued exception" do -> { $@ = [] - }.should raise_error(ArgumentError, '$! not set') + }.should.raise(ArgumentError, '$! not set') end end @@ -691,7 +691,7 @@ def foo it "can be assigned a String" do str = +"abc" $/ = str - $/.should equal(str) + $/.should.equal?(str) end end @@ -702,7 +702,7 @@ def foo str.instance_variable_set(:@ivar, 1) $/ = str $/.should.frozen? - $/.should be_an_instance_of(String) + $/.should.instance_of?(String) $/.should_not.instance_variable_defined?(:@ivar) $/.should == str end @@ -717,13 +717,13 @@ def foo it "assigns the given String if it's frozen and has no instance variables" do str = "abc".freeze $/ = str - $/.should equal(str) + $/.should.equal?(str) end end it "can be assigned nil" do $/ = nil - $/.should be_nil + $/.should == nil end it "returns the value assigned" do @@ -732,22 +732,22 @@ def foo it "changes $-0" do $/ = "xyz" - $-0.should equal($/) + $-0.should.equal?($/) end it "does not call #to_str to convert the object to a String" do obj = mock("$/ value") obj.should_not_receive(:to_str) - -> { $/ = obj }.should raise_error(TypeError, 'value of $/ must be String') + -> { $/ = obj }.should.raise(TypeError, 'value of $/ must be String') end it "raises a TypeError if assigned an Integer" do - -> { $/ = 1 }.should raise_error(TypeError, 'value of $/ must be String') + -> { $/ = 1 }.should.raise(TypeError, 'value of $/ must be String') end it "raises a TypeError if assigned a boolean" do - -> { $/ = true }.should raise_error(TypeError, 'value of $/ must be String') + -> { $/ = true }.should.raise(TypeError, 'value of $/ must be String') end it "warns if assigned non-nil" do @@ -772,7 +772,7 @@ def foo it "can be assigned a String" do str = +"abc" $-0 = str - $-0.should equal(str) + $-0.should.equal?(str) end end @@ -783,7 +783,7 @@ def foo str.instance_variable_set(:@ivar, 1) $-0 = str $-0.should.frozen? - $-0.should be_an_instance_of(String) + $-0.should.instance_of?(String) $-0.should_not.instance_variable_defined?(:@ivar) $-0.should == str end @@ -798,13 +798,13 @@ def foo it "assigns the given String if it's frozen and has no instance variables" do str = "abc".freeze $-0 = str - $-0.should equal(str) + $-0.should.equal?(str) end end it "can be assigned nil" do $-0 = nil - $-0.should be_nil + $-0.should == nil end it "returns the value assigned" do @@ -813,22 +813,22 @@ def foo it "changes $/" do $-0 = "xyz" - $/.should equal($-0) + $/.should.equal?($-0) end it "does not call #to_str to convert the object to a String" do obj = mock("$-0 value") obj.should_not_receive(:to_str) - -> { $-0 = obj }.should raise_error(TypeError, 'value of $-0 must be String') + -> { $-0 = obj }.should.raise(TypeError, 'value of $-0 must be String') end it "raises a TypeError if assigned an Integer" do - -> { $-0 = 1 }.should raise_error(TypeError, 'value of $-0 must be String') + -> { $-0 = 1 }.should.raise(TypeError, 'value of $-0 must be String') end it "raises a TypeError if assigned a boolean" do - -> { $-0 = true }.should raise_error(TypeError, 'value of $-0 must be String') + -> { $-0 = true }.should.raise(TypeError, 'value of $-0 must be String') end it "warns if assigned non-nil" do @@ -850,12 +850,12 @@ def foo it "can be assigned a String" do str = "abc" $\ = str - $\.should equal(str) + $\.should.equal?(str) end it "can be assigned nil" do $\ = nil - $\.should be_nil + $\.should == nil end it "returns the value assigned" do @@ -866,12 +866,12 @@ def foo obj = mock("$\\ value") obj.should_not_receive(:to_str) - -> { $\ = obj }.should raise_error(TypeError, 'value of $\ must be String') + -> { $\ = obj }.should.raise(TypeError, 'value of $\ must be String') end it "raises a TypeError if assigned not String" do - -> { $\ = 1 }.should raise_error(TypeError, 'value of $\ must be String') - -> { $\ = true }.should raise_error(TypeError, 'value of $\ must be String') + -> { $\ = 1 }.should.raise(TypeError, 'value of $\ must be String') + -> { $\ = true }.should.raise(TypeError, 'value of $\ must be String') end it "warns if assigned non-nil" do @@ -885,11 +885,11 @@ def foo end it "defaults to nil" do - $,.should be_nil + $,.should == nil end it "raises TypeError if assigned a non-String" do - -> { $, = Object.new }.should raise_error(TypeError, 'value of $, must be String') + -> { $, = Object.new }.should.raise(TypeError, 'value of $, must be String') end it "warns if assigned non-nil" do @@ -920,7 +920,7 @@ def foo obj = mock("bad-value") obj.should_receive(:to_int).and_return('abc') - -> { $. = obj }.should raise_error(TypeError) + -> { $. = obj }.should.raise(TypeError) end end @@ -985,7 +985,7 @@ def obj.foo2; yield; end end Thread.pass until running - $_.should be_nil + $_.should == nil thr.join end @@ -1056,7 +1056,7 @@ def obj.foo2; yield; end end it "does not include the current directory" do - $:.should_not include(".") + $:.should_not.include?(".") end it "is the same object as $LOAD_PATH and $-I" do @@ -1066,7 +1066,7 @@ def obj.foo2; yield; end it "can be changed via <<" do $: << "foo" - $:.should include("foo") + $:.should.include?("foo") ensure $:.delete("foo") end @@ -1074,15 +1074,15 @@ def obj.foo2; yield; end it "is read-only" do -> { $: = [] - }.should raise_error(NameError, '$: is a read-only variable') + }.should.raise(NameError, '$: is a read-only variable') -> { $LOAD_PATH = [] - }.should raise_error(NameError, '$LOAD_PATH is a read-only variable') + }.should.raise(NameError, '$LOAD_PATH is a read-only variable') -> { $-I = [] - }.should raise_error(NameError, '$-I is a read-only variable') + }.should.raise(NameError, '$-I is a read-only variable') end it "default $LOAD_PATH entries until sitelibdir included have @gem_prelude_index set" do @@ -1097,24 +1097,24 @@ def obj.foo2; yield; end idx = $:.index(RbConfig::CONFIG['sitelibdir']) end - $:[idx..-1].all? { |p| p.instance_variable_defined?(:@gem_prelude_index) }.should be_true - $:[0...idx].all? { |p| !p.instance_variable_defined?(:@gem_prelude_index) }.should be_true + $:[idx..-1].all? { |p| p.instance_variable_defined?(:@gem_prelude_index) }.should == true + $:[0...idx].all? { |p| !p.instance_variable_defined?(:@gem_prelude_index) }.should == true end end describe "Global variable $\"" do it "is an alias for $LOADED_FEATURES" do - $".should equal $LOADED_FEATURES + $".should.equal? $LOADED_FEATURES end it "is read-only" do -> { $" = [] - }.should raise_error(NameError, '$" is a read-only variable') + }.should.raise(NameError, '$" is a read-only variable') -> { $LOADED_FEATURES = [] - }.should raise_error(NameError, '$LOADED_FEATURES is a read-only variable') + }.should.raise(NameError, '$LOADED_FEATURES is a read-only variable') end end @@ -1122,7 +1122,7 @@ def obj.foo2; yield; end it "is read-only" do -> { $< = nil - }.should raise_error(NameError, '$< is a read-only variable') + }.should.raise(NameError, '$< is a read-only variable') end end @@ -1130,7 +1130,7 @@ def obj.foo2; yield; end it "is read-only" do -> { $FILENAME = "-" - }.should raise_error(NameError, '$FILENAME is a read-only variable') + }.should.raise(NameError, '$FILENAME is a read-only variable') end end @@ -1138,30 +1138,30 @@ def obj.foo2; yield; end it "is read-only" do -> { $? = nil - }.should raise_error(NameError, '$? is a read-only variable') + }.should.raise(NameError, '$? is a read-only variable') end it "is thread-local" do system(ruby_cmd('exit 0')) - Thread.new { $?.should be_nil }.join + Thread.new { $?.should == nil }.join end end describe "Global variable $-a" do it "is read-only" do - -> { $-a = true }.should raise_error(NameError, '$-a is a read-only variable') + -> { $-a = true }.should.raise(NameError, '$-a is a read-only variable') end end describe "Global variable $-l" do it "is read-only" do - -> { $-l = true }.should raise_error(NameError, '$-l is a read-only variable') + -> { $-l = true }.should.raise(NameError, '$-l is a read-only variable') end end describe "Global variable $-p" do it "is read-only" do - -> { $-p = true }.should raise_error(NameError, '$-p is a read-only variable') + -> { $-p = true }.should.raise(NameError, '$-p is a read-only variable') end end @@ -1176,9 +1176,9 @@ def obj.foo2; yield; end it "is an alias of $DEBUG" do $DEBUG = true - $-d.should be_true + $-d.should == true $-d = false - $DEBUG.should be_false + $DEBUG.should == false end end @@ -1192,24 +1192,24 @@ def obj.foo2; yield; end end it "is false by default" do - $VERBOSE.should be_false + $VERBOSE.should == false end it "converts truthy values to true" do [true, 1, 0, [], ""].each do |true_value| $VERBOSE = true_value - $VERBOSE.should be_true + $VERBOSE.should == true end end it "allows false" do $VERBOSE = false - $VERBOSE.should be_false + $VERBOSE.should == false end it "allows nil without coercing to false" do $VERBOSE = nil - $VERBOSE.should be_nil + $VERBOSE.should == nil end end @@ -1224,9 +1224,9 @@ def obj.foo2; yield; end it "is an alias of $VERBOSE" do $VERBOSE = true - eval(@method).should be_true + eval(@method).should == true eval("#{@method} = false") - $VERBOSE.should be_false + $VERBOSE.should == false end end @@ -1263,7 +1263,7 @@ def obj.foo2; yield; end it "actually sets the program name" do title = "rubyspec-dollar0-test" $0 = title - `ps -ocommand= -p#{$$}`.should include(title) + `ps -ocommand= -p#{$$}`.should.include?(title) end end @@ -1272,7 +1272,7 @@ def obj.foo2; yield; end end it "raises a TypeError when not given an object that can be coerced to a String" do - -> { $0 = nil }.should raise_error(TypeError) + -> { $0 = nil }.should.raise(TypeError) end end @@ -1308,37 +1308,37 @@ def obj.foo2; yield; end describe "The predefined standard object nil" do it "is an instance of NilClass" do - nil.should be_kind_of(NilClass) + nil.should.is_a?(NilClass) end it "raises a SyntaxError if assigned to" do - -> { eval("nil = true") }.should raise_error(SyntaxError, /Can't assign to nil/) + -> { eval("nil = true") }.should.raise(SyntaxError, /Can't assign to nil/) end end describe "The predefined standard object true" do it "is an instance of TrueClass" do - true.should be_kind_of(TrueClass) + true.should.is_a?(TrueClass) end it "raises a SyntaxError if assigned to" do - -> { eval("true = false") }.should raise_error(SyntaxError, /Can't assign to true/) + -> { eval("true = false") }.should.raise(SyntaxError, /Can't assign to true/) end end describe "The predefined standard object false" do it "is an instance of FalseClass" do - false.should be_kind_of(FalseClass) + false.should.is_a?(FalseClass) end it "raises a SyntaxError if assigned to" do - -> { eval("false = nil") }.should raise_error(SyntaxError, /Can't assign to false/) + -> { eval("false = nil") }.should.raise(SyntaxError, /Can't assign to false/) end end describe "The self pseudo-variable" do it "raises a SyntaxError if assigned to" do - -> { eval("self = 1") }.should raise_error(SyntaxError, /Can't change the value of self/) + -> { eval("self = 1") }.should.raise(SyntaxError, /Can't change the value of self/) end end @@ -1433,21 +1433,21 @@ def obj.foo2; yield; end describe "STDIN" do platform_is_not :windows do it "has the same external encoding as Encoding.default_external" do - STDIN.external_encoding.should equal(Encoding.default_external) + STDIN.external_encoding.should.equal?(Encoding.default_external) end it "has the same external encoding as Encoding.default_external when that encoding is changed" do Encoding.default_external = Encoding::ISO_8859_16 - STDIN.external_encoding.should equal(Encoding::ISO_8859_16) + STDIN.external_encoding.should.equal?(Encoding::ISO_8859_16) end it "has nil for the internal encoding" do - STDIN.internal_encoding.should be_nil + STDIN.internal_encoding.should == nil end it "has nil for the internal encoding despite Encoding.default_internal being changed" do Encoding.default_internal = Encoding::IBM437 - STDIN.internal_encoding.should be_nil + STDIN.internal_encoding.should == nil end end @@ -1467,12 +1467,12 @@ def obj.foo2; yield; end describe "STDOUT" do it "has nil for the external encoding" do - STDOUT.external_encoding.should be_nil + STDOUT.external_encoding.should == nil end it "has nil for the external encoding despite Encoding.default_external being changed" do Encoding.default_external = Encoding::ISO_8859_1 - STDOUT.external_encoding.should be_nil + STDOUT.external_encoding.should == nil end it "has the encodings set by #set_encoding" do @@ -1482,23 +1482,23 @@ def obj.foo2; yield; end end it "has nil for the internal encoding" do - STDOUT.internal_encoding.should be_nil + STDOUT.internal_encoding.should == nil end it "has nil for the internal encoding despite Encoding.default_internal being changed" do Encoding.default_internal = Encoding::IBM437 - STDOUT.internal_encoding.should be_nil + STDOUT.internal_encoding.should == nil end end describe "STDERR" do it "has nil for the external encoding" do - STDERR.external_encoding.should be_nil + STDERR.external_encoding.should == nil end it "has nil for the external encoding despite Encoding.default_external being changed" do Encoding.default_external = Encoding::ISO_8859_1 - STDERR.external_encoding.should be_nil + STDERR.external_encoding.should == nil end it "has the encodings set by #set_encoding" do @@ -1508,12 +1508,12 @@ def obj.foo2; yield; end end it "has nil for the internal encoding" do - STDERR.internal_encoding.should be_nil + STDERR.internal_encoding.should == nil end it "has nil for the internal encoding despite Encoding.default_internal being changed" do Encoding.default_internal = Encoding::IBM437 - STDERR.internal_encoding.should be_nil + STDERR.internal_encoding.should == nil end end @@ -1544,7 +1544,7 @@ def obj.foo2; yield; end end it "return nil if feature cannot be found" do - $LOAD_PATH.resolve_feature_path('noop').should be_nil + $LOAD_PATH.resolve_feature_path('noop').should == nil end end diff --git a/spec/ruby/language/private_spec.rb b/spec/ruby/language/private_spec.rb index b04aa25c9e57fe..94b56fee5bbc89 100644 --- a/spec/ruby/language/private_spec.rb +++ b/spec/ruby/language/private_spec.rb @@ -4,12 +4,12 @@ describe "The private keyword" do it "marks following methods as being private" do a = Private::A.new - a.methods.should_not include(:bar) - -> { a.bar }.should raise_error(NoMethodError) + a.methods.should_not.include?(:bar) + -> { a.bar }.should.raise(NoMethodError) b = Private::B.new - b.methods.should_not include(:bar) - -> { b.bar }.should raise_error(NoMethodError) + b.methods.should_not.include?(:bar) + -> { b.bar }.should.raise(NoMethodError) end # def expr.meth() methods are always public @@ -19,15 +19,15 @@ it "is overridden when a new class is opened" do c = Private::B::C.new - c.methods.should include(:baz) + c.methods.should.include?(:baz) c.baz Private::B.public_class_method1.should == 1 - -> { Private::B.private_class_method1 }.should raise_error(NoMethodError) + -> { Private::B.private_class_method1 }.should.raise(NoMethodError) end it "is no longer in effect when the class is closed" do b = Private::B.new - b.methods.should include(:foo) + b.methods.should.include?(:foo) b.foo end @@ -42,7 +42,7 @@ def foo klass.class_eval do private :foo end - -> { f.foo }.should raise_error(NoMethodError) + -> { f.foo }.should.raise(NoMethodError) end it "changes visibility of previously called methods with same send/call site" do @@ -56,12 +56,12 @@ class G end end end - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end it "changes the visibility of the existing method in the subclass" do ::Private::A.new.foo.should == 'foo' - -> { ::Private::H.new.foo }.should raise_error(NoMethodError) + -> { ::Private::H.new.foo }.should.raise(NoMethodError) ::Private::H.new.send(:foo).should == 'foo' end end diff --git a/spec/ruby/language/proc_spec.rb b/spec/ruby/language/proc_spec.rb index f26f82b015588a..53a21d6b85ac3e 100644 --- a/spec/ruby/language/proc_spec.rb +++ b/spec/ruby/language/proc_spec.rb @@ -22,7 +22,7 @@ end it "raises an ArgumentError if a value is passed" do - lambda { @l.call(0) }.should raise_error(ArgumentError) + lambda { @l.call(0) }.should.raise(ArgumentError) end end @@ -36,7 +36,7 @@ end it "raises an ArgumentError if a value is passed" do - lambda { @l.call(0) }.should raise_error(ArgumentError) + lambda { @l.call(0) }.should.raise(ArgumentError) end end @@ -57,11 +57,11 @@ obj = mock("block yield to_ary") obj.should_not_receive(:to_ary) - @l.call(obj).should equal(obj) + @l.call(obj).should.equal?(obj) end it "raises an ArgumentError if no value is passed" do - lambda { @l.call }.should raise_error(ArgumentError) + lambda { @l.call }.should.raise(ArgumentError) end end @@ -71,11 +71,11 @@ end it "raises an ArgumentError if passed no values" do - lambda { @l.call }.should raise_error(ArgumentError) + lambda { @l.call }.should.raise(ArgumentError) end it "raises an ArgumentError if passed one value" do - lambda { @l.call(0) }.should raise_error(ArgumentError) + lambda { @l.call(0) }.should.raise(ArgumentError) end it "assigns the values passed to the arguments" do @@ -86,7 +86,7 @@ obj = mock("proc call to_ary") obj.should_not_receive(:to_ary) - lambda { @l.call(obj) }.should raise_error(ArgumentError) + lambda { @l.call(obj) }.should.raise(ArgumentError) end end @@ -96,7 +96,7 @@ end it "raises an ArgumentError if passed no values" do - lambda { @l.call }.should raise_error(ArgumentError) + lambda { @l.call }.should.raise(ArgumentError) end it "does not destructure a single Array value yielded" do @@ -179,11 +179,11 @@ end it "raises an ArgumentError when passed no values" do - lambda { @l.call }.should raise_error(ArgumentError) + lambda { @l.call }.should.raise(ArgumentError) end it "raises an ArgumentError when passed more than one value" do - lambda { @l.call(1, 2) }.should raise_error(ArgumentError) + lambda { @l.call(1, 2) }.should.raise(ArgumentError) end it "assigns the argument the value passed" do @@ -208,7 +208,7 @@ end it "raises an ArgumentError when passed no values" do - lambda { @l.call }.should raise_error(ArgumentError) + lambda { @l.call }.should.raise(ArgumentError) end it "destructures a single Array value yielded" do @@ -226,7 +226,7 @@ obj = mock("block yield to_ary invalid") obj.should_receive(:to_ary).and_return(1) - lambda { @l.call(obj) }.should raise_error(TypeError) + lambda { @l.call(obj) }.should.raise(TypeError) end end @@ -243,7 +243,7 @@ describe "taking |required keyword arguments, **kw| arguments" do it "raises ArgumentError for missing required argument" do p = proc { |a:, **kw| [a, kw] } - -> { p.call() }.should raise_error(ArgumentError) + -> { p.call() }.should.raise(ArgumentError) end end @@ -252,9 +252,9 @@ ruby @p.call().should == :ok - -> { @p.call(a: 1) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { @p.call(**{a: 1}) }.should raise_error(ArgumentError, 'no keywords accepted') - -> { @p.call("a" => 1) }.should raise_error(ArgumentError, 'no keywords accepted') + -> { @p.call(a: 1) }.should.raise(ArgumentError, 'no keywords accepted') + -> { @p.call(**{a: 1}) }.should.raise(ArgumentError, 'no keywords accepted') + -> { @p.call("a" => 1) }.should.raise(ArgumentError, 'no keywords accepted') end evaluate <<-ruby do @@ -262,6 +262,6 @@ ruby @p.call({a: 1}).should == {a: 1} - -> { @p.call(a: 1) }.should raise_error(ArgumentError, 'no keywords accepted') + -> { @p.call(a: 1) }.should.raise(ArgumentError, 'no keywords accepted') end end diff --git a/spec/ruby/language/redo_spec.rb b/spec/ruby/language/redo_spec.rb index 57532553b3473c..9b14c5add138ed 100644 --- a/spec/ruby/language/redo_spec.rb +++ b/spec/ruby/language/redo_spec.rb @@ -60,7 +60,7 @@ it "is invalid and raises a SyntaxError" do -> { eval("def m; redo; end") - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end end end diff --git a/spec/ruby/language/regexp/anchors_spec.rb b/spec/ruby/language/regexp/anchors_spec.rb index cdc06c0b4d3223..8e597b65e8bd0b 100644 --- a/spec/ruby/language/regexp/anchors_spec.rb +++ b/spec/ruby/language/regexp/anchors_spec.rb @@ -7,8 +7,8 @@ /^foo/.match("foo").to_a.should == ["foo"] /^bar/.match("foo\nbar").to_a.should == ["bar"] # Basic non-matching - /^foo/.match(" foo").should be_nil - /foo^/.match("foo\n\n\n").should be_nil + /^foo/.match(" foo").should == nil + /foo^/.match("foo\n\n\n").should == nil # A bit advanced /^^^foo/.match("foo").to_a.should == ["foo"] @@ -16,8 +16,8 @@ (/($^)($^)/ =~ "foo\n\n").should == "foo\n".size and $~.to_a.should == ["", "", ""] # Different start of line chars - /^bar/.match("foo\rbar").should be_nil - /^bar/.match("foo\0bar").should be_nil + /^bar/.match("foo\rbar").should == nil + /^bar/.match("foo\0bar").should == nil # Trivial /^/.match("foo").to_a.should == [""] @@ -29,7 +29,7 @@ end it "does not match ^ after trailing \\n" do - /^(?!\A)/.match("foo\n").should be_nil # There is no (empty) line after a trailing \n + /^(?!\A)/.match("foo\n").should == nil # There is no (empty) line after a trailing \n end it "supports $ (line end anchor)" do @@ -37,16 +37,16 @@ /foo$/.match("foo").to_a.should == ["foo"] /foo$/.match("foo\nbar").to_a.should == ["foo"] # Basic non-matching - /foo$/.match("foo ").should be_nil - /$foo/.match("\n\n\nfoo").should be_nil + /foo$/.match("foo ").should == nil + /$foo/.match("\n\n\nfoo").should == nil # A bit advanced /foo$$$/.match("foo").to_a.should == ["foo"] (/[^o]$/ =~ "foo\n\n").should == ("foo\n".size - 1) and $~.to_a.should == ["\n"] # Different end of line chars - /foo$/.match("foo\r\nbar").should be_nil - /foo$/.match("foo\0bar").should be_nil + /foo$/.match("foo\r\nbar").should == nil + /foo$/.match("foo\0bar").should == nil # Trivial (/$/ =~ "foo").should == "foo".size and $~.to_a.should == [""] @@ -61,15 +61,15 @@ # Basic matching /\Afoo/.match("foo").to_a.should == ["foo"] # Basic non-matching - /\Abar/.match("foo\nbar").should be_nil - /\Afoo/.match(" foo").should be_nil + /\Abar/.match("foo\nbar").should == nil + /\Afoo/.match(" foo").should == nil # A bit advanced /\A\A\Afoo/.match("foo").to_a.should == ["foo"] /(\A\Z)(\A\Z)/.match("").to_a.should == ["", "", ""] # Different start of line chars - /\Abar/.match("foo\0bar").should be_nil + /\Abar/.match("foo\0bar").should == nil # Grouping /(\Afoo)/.match("foo").to_a.should == ["foo", "foo"] @@ -81,8 +81,8 @@ /foo\Z/.match("foo").to_a.should == ["foo"] /foo\Z/.match("foo\n").to_a.should == ["foo"] # Basic non-matching - /foo\Z/.match("foo\nbar").should be_nil - /foo\Z/.match("foo ").should be_nil + /foo\Z/.match("foo\nbar").should == nil + /foo\Z/.match("foo ").should == nil # A bit advanced /foo\Z\Z\Z/.match("foo\n").to_a.should == ["foo"] @@ -90,8 +90,8 @@ (/(\z\Z)(\z\Z)/ =~ "foo\n").should == "foo\n".size and $~.to_a.should == ["", "", ""] # Different end of line chars - /foo\Z/.match("foo\0bar").should be_nil - /foo\Z/.match("foo\r\n").should be_nil + /foo\Z/.match("foo\0bar").should == nil + /foo\Z/.match("foo\r\n").should == nil # Grouping /(foo\Z)/.match("foo").to_a.should == ["foo", "foo"] @@ -102,17 +102,17 @@ # Basic matching /foo\z/.match("foo").to_a.should == ["foo"] # Basic non-matching - /foo\z/.match("foo\nbar").should be_nil - /foo\z/.match("foo\n").should be_nil - /foo\z/.match("foo ").should be_nil + /foo\z/.match("foo\nbar").should == nil + /foo\z/.match("foo\n").should == nil + /foo\z/.match("foo ").should == nil # A bit advanced /foo\z\z\z/.match("foo").to_a.should == ["foo"] (/($\z)($\z)/ =~ "foo").should == "foo".size and $~.to_a.should == ["", "", ""] # Different end of line chars - /foo\z/.match("foo\0bar").should be_nil - /foo\z/.match("foo\r\nbar").should be_nil + /foo\z/.match("foo\0bar").should == nil + /foo\z/.match("foo\r\nbar").should == nil # Grouping /(foo\z)/.match("foo").to_a.should == ["foo", "foo"] @@ -131,9 +131,9 @@ end /foo\b/.match("foo\0").to_a.should == ["foo"] # Basic non-matching - /foo\b/.match("foobar").should be_nil - /foo\b/.match("foo123").should be_nil - /foo\b/.match("foo_").should be_nil + /foo\b/.match("foobar").should == nil + /foo\b/.match("foo123").should == nil + /foo\b/.match("foo_").should == nil end it "supports \\B (non-word-boundary)" do @@ -142,15 +142,15 @@ /foo\B/.match("foo123").to_a.should == ["foo"] /foo\B/.match("foo_").to_a.should == ["foo"] # Basic non-matching - /foo\B/.match("foo").should be_nil - /foo\B/.match("foo\n").should be_nil + /foo\B/.match("foo").should == nil + /foo\B/.match("foo\n").should == nil LanguageSpecs.white_spaces.scan(/./).each do |c| - /foo\B/.match("foo" + c).should be_nil + /foo\B/.match("foo" + c).should == nil end LanguageSpecs.non_alphanum_non_space.scan(/./).each do |c| - /foo\B/.match("foo" + c).should be_nil + /foo\B/.match("foo" + c).should == nil end - /foo\B/.match("foo\0").should be_nil + /foo\B/.match("foo\0").should == nil end it "supports (?= ) (positive lookahead)" do diff --git a/spec/ruby/language/regexp/back-references_spec.rb b/spec/ruby/language/regexp/back-references_spec.rb index 627c8daacefa42..3b4c5656a2089e 100644 --- a/spec/ruby/language/regexp/back-references_spec.rb +++ b/spec/ruby/language/regexp/back-references_spec.rb @@ -49,7 +49,7 @@ it "supports \ (backreference to previous group match)" do /(foo.)\1/.match("foo1foo1").to_a.should == ["foo1foo1", "foo1"] - /(foo.)\1/.match("foo1foo2").should be_nil + /(foo.)\1/.match("foo1foo2").should == nil end it "resets nested \ backreference before match of outer subexpression" do @@ -82,7 +82,7 @@ end it "0 is not a valid backreference" do - -> { Regexp.new("\\k<0>") }.should raise_error(RegexpError) + -> { Regexp.new("\\k<0>") }.should.raise(RegexpError) end it "allows numeric conditional backreferences" do @@ -92,7 +92,7 @@ end it "allows either <> or '' in named conditional backreferences" do - -> { Regexp.new("(?a)(?(a)a|b)") }.should raise_error(RegexpError) + -> { Regexp.new("(?a)(?(a)a|b)") }.should.raise(RegexpError) /(?a)(?()a|b)/.match("aa").to_a.should == [ "aa", "a" ] /(?a)(?('a')a|b)/.match("aa").to_a.should == [ "aa", "a" ] end @@ -118,32 +118,32 @@ end it "named capture groups invalidate numeric backreferences" do - -> { Regexp.new("(?a)\\1") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)\\k<1>") }.should raise_error(RegexpError) - -> { Regexp.new("(a)(?a)\\1") }.should raise_error(RegexpError) - -> { Regexp.new("(a)(?a)\\k<1>") }.should raise_error(RegexpError) + -> { Regexp.new("(?a)\\1") }.should.raise(RegexpError) + -> { Regexp.new("(?a)\\k<1>") }.should.raise(RegexpError) + -> { Regexp.new("(a)(?a)\\1") }.should.raise(RegexpError) + -> { Regexp.new("(a)(?a)\\k<1>") }.should.raise(RegexpError) end it "treats + or - as the beginning of a level specifier in \\k<> backreferences and (?(...)...|...) conditional backreferences" do - -> { Regexp.new("(?a)\\k") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)\\k") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)\\k") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)\\k") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)\\k") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)\\k") }.should raise_error(RegexpError) - - -> { Regexp.new("(?a)(?()a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?()a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?()a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?()a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?()a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?()a|b)") }.should raise_error(RegexpError) - - -> { Regexp.new("(?a)(?('a+')a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?('a+b')a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?('a+1')a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?('a-')a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?('a-b')a|b)") }.should raise_error(RegexpError) - -> { Regexp.new("(?a)(?('a-1')a|b)") }.should raise_error(RegexpError) + -> { Regexp.new("(?a)\\k") }.should.raise(RegexpError) + -> { Regexp.new("(?a)\\k") }.should.raise(RegexpError) + -> { Regexp.new("(?a)\\k") }.should.raise(RegexpError) + -> { Regexp.new("(?a)\\k") }.should.raise(RegexpError) + -> { Regexp.new("(?a)\\k") }.should.raise(RegexpError) + -> { Regexp.new("(?a)\\k") }.should.raise(RegexpError) + + -> { Regexp.new("(?a)(?()a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?()a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?()a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?()a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?()a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?()a|b)") }.should.raise(RegexpError) + + -> { Regexp.new("(?a)(?('a+')a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?('a+b')a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?('a+1')a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?('a-')a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?('a-b')a|b)") }.should.raise(RegexpError) + -> { Regexp.new("(?a)(?('a-1')a|b)") }.should.raise(RegexpError) end end diff --git a/spec/ruby/language/regexp/character_classes_spec.rb b/spec/ruby/language/regexp/character_classes_spec.rb index 018757db41fdf6..c6ed92b78e9efc 100644 --- a/spec/ruby/language/regexp/character_classes_spec.rb +++ b/spec/ruby/language/regexp/character_classes_spec.rb @@ -9,9 +9,9 @@ /\w/.match("_").to_a.should == ["_"] # Non-matches - /\w/.match(LanguageSpecs.white_spaces).should be_nil - /\w/.match(LanguageSpecs.non_alphanum_non_space).should be_nil - /\w/.match("\0").should be_nil + /\w/.match(LanguageSpecs.white_spaces).should == nil + /\w/.match(LanguageSpecs.non_alphanum_non_space).should == nil + /\w/.match("\0").should == nil end it "supports \\W (non-word character)" do @@ -20,19 +20,19 @@ /\W/.match("\0").to_a.should == ["\0"] # Non-matches - /\W/.match("a").should be_nil - /\W/.match("1").should be_nil - /\W/.match("_").should be_nil + /\W/.match("a").should == nil + /\W/.match("1").should == nil + /\W/.match("_").should == nil end it "supports \\s (space character)" do /\s+/.match(LanguageSpecs.white_spaces).to_a.should == [LanguageSpecs.white_spaces] # Non-matches - /\s/.match("a").should be_nil - /\s/.match("1").should be_nil - /\s/.match(LanguageSpecs.non_alphanum_non_space).should be_nil - /\s/.match("\0").should be_nil + /\s/.match("a").should == nil + /\s/.match("1").should == nil + /\s/.match(LanguageSpecs.non_alphanum_non_space).should == nil + /\s/.match("\0").should == nil end it "supports \\S (non-space character)" do @@ -42,17 +42,17 @@ /\S/.match("\0").to_a.should == ["\0"] # Non-matches - /\S/.match(LanguageSpecs.white_spaces).should be_nil + /\S/.match(LanguageSpecs.white_spaces).should == nil end it "supports \\d (numeric digit)" do /\d/.match("1").to_a.should == ["1"] # Non-matches - /\d/.match("a").should be_nil - /\d/.match(LanguageSpecs.white_spaces).should be_nil - /\d/.match(LanguageSpecs.non_alphanum_non_space).should be_nil - /\d/.match("\0").should be_nil + /\d/.match("a").should == nil + /\d/.match(LanguageSpecs.white_spaces).should == nil + /\d/.match(LanguageSpecs.non_alphanum_non_space).should == nil + /\d/.match("\0").should == nil end it "supports \\D (non-digit)" do @@ -62,7 +62,7 @@ /\D/.match("\0").to_a.should == ["\0"] # Non-matches - /\D/.match("1").should be_nil + /\D/.match("1").should == nil end it "supports [] (character class)" do @@ -89,7 +89,7 @@ /[^[:lower:]A-C]+/.match("abcABCDEF123def").to_a.should == ["DEF123"] # negated character class /[:alnum:]+/.match("a:l:n:u:m").to_a.should == ["a:l:n:u:m"] # should behave like regular character class composed of the individual letters /[\[:alnum:]+/.match("[:a:l:n:u:m").to_a.should == ["[:a:l:n:u:m"] # should behave like regular character class composed of the individual letters - -> { eval('/[[:alpha:]-[:digit:]]/') }.should raise_error(SyntaxError) # can't use character class as a start value of range + -> { eval('/[[:alpha:]-[:digit:]]/') }.should.raise(SyntaxError) # can't use character class as a start value of range end it "matches ASCII characters with [[:ascii:]]" do @@ -99,8 +99,8 @@ not_supported_on :opal do it "doesn't match non-ASCII characters with [[:ascii:]]" do - /[[:ascii:]]/.match("\u{80}").should be_nil - /[[:ascii:]]/.match("\u{9898}").should be_nil + /[[:ascii:]]/.match("\u{80}").should == nil + /[[:ascii:]]/.match("\u{9898}").should == nil end end @@ -113,7 +113,7 @@ end it "doesn't matches Unicode marks with [[:alnum:]]" do - "\u{3099}".match(/[[:alnum:]]/).should be_nil + "\u{3099}".match(/[[:alnum:]]/).should == nil end it "doesn't match Unicode control characters with [[:alnum:]]" do @@ -133,7 +133,7 @@ end it "doesn't matches Unicode marks with [[:alpha:]]" do - "\u{3099}".match(/[[:alpha:]]/).should be_nil + "\u{3099}".match(/[[:alpha:]]/).should == nil end it "doesn't match Unicode control characters with [[:alpha:]]" do @@ -149,39 +149,39 @@ end it "doesn't match Unicode control characters with [[:blank:]]" do - "\u{16}".match(/[[:blank:]]/).should be_nil + "\u{16}".match(/[[:blank:]]/).should == nil end it "doesn't match Unicode punctuation characters with [[:blank:]]" do - "\u{3F}".match(/[[:blank:]]/).should be_nil + "\u{3F}".match(/[[:blank:]]/).should == nil end it "doesn't match Unicode letter characters with [[:blank:]]" do - "à".match(/[[:blank:]]/).should be_nil + "à".match(/[[:blank:]]/).should == nil end it "doesn't match Unicode digits with [[:blank:]]" do - "\u{0660}".match(/[[:blank:]]/).should be_nil + "\u{0660}".match(/[[:blank:]]/).should == nil end it "doesn't match Unicode marks with [[:blank:]]" do - "\u{36F}".match(/[[:blank:]]/).should be_nil + "\u{36F}".match(/[[:blank:]]/).should == nil end it "doesn't Unicode letter characters with [[:cntrl:]]" do - "à".match(/[[:cntrl:]]/).should be_nil + "à".match(/[[:cntrl:]]/).should == nil end it "doesn't match Unicode digits with [[:cntrl:]]" do - "\u{0660}".match(/[[:cntrl:]]/).should be_nil + "\u{0660}".match(/[[:cntrl:]]/).should == nil end it "doesn't match Unicode marks with [[:cntrl:]]" do - "\u{36F}".match(/[[:cntrl:]]/).should be_nil + "\u{36F}".match(/[[:cntrl:]]/).should == nil end it "doesn't match Unicode punctuation characters with [[:cntrl:]]" do - "\u{3F}".match(/[[:cntrl:]]/).should be_nil + "\u{3F}".match(/[[:cntrl:]]/).should == nil end it "matches Unicode control characters with [[:cntrl:]]" do @@ -189,15 +189,15 @@ end it "doesn't match Unicode format characters with [[:cntrl:]]" do - "\u{2060}".match(/[[:cntrl:]]/).should be_nil + "\u{2060}".match(/[[:cntrl:]]/).should == nil end it "doesn't match Unicode private-use characters with [[:cntrl:]]" do - "\u{E001}".match(/[[:cntrl:]]/).should be_nil + "\u{E001}".match(/[[:cntrl:]]/).should == nil end it "doesn't match Unicode letter characters with [[:digit:]]" do - "à".match(/[[:digit:]]/).should be_nil + "à".match(/[[:digit:]]/).should == nil end it "matches Unicode digits with [[:digit:]]" do @@ -206,23 +206,23 @@ end it "doesn't match Unicode marks with [[:digit:]]" do - "\u{36F}".match(/[[:digit:]]/).should be_nil + "\u{36F}".match(/[[:digit:]]/).should == nil end it "doesn't match Unicode punctuation characters with [[:digit:]]" do - "\u{3F}".match(/[[:digit:]]/).should be_nil + "\u{3F}".match(/[[:digit:]]/).should == nil end it "doesn't match Unicode control characters with [[:digit:]]" do - "\u{16}".match(/[[:digit:]]/).should be_nil + "\u{16}".match(/[[:digit:]]/).should == nil end it "doesn't match Unicode format characters with [[:digit:]]" do - "\u{2060}".match(/[[:digit:]]/).should be_nil + "\u{2060}".match(/[[:digit:]]/).should == nil end it "doesn't match Unicode private-use characters with [[:digit:]]" do - "\u{E001}".match(/[[:digit:]]/).should be_nil + "\u{E001}".match(/[[:digit:]]/).should == nil end it "matches Unicode letter characters with [[:graph:]]" do @@ -243,7 +243,7 @@ end it "doesn't match Unicode control characters with [[:graph:]]" do - "\u{16}".match(/[[:graph:]]/).should be_nil + "\u{16}".match(/[[:graph:]]/).should == nil end it "match Unicode format characters with [[:graph:]]" do @@ -261,40 +261,40 @@ end it "doesn't match Unicode uppercase letter characters with [[:lower:]]" do - "\u{100}".match(/[[:lower:]]/).should be_nil - "\u{130}".match(/[[:lower:]]/).should be_nil - "\u{405}".match(/[[:lower:]]/).should be_nil + "\u{100}".match(/[[:lower:]]/).should == nil + "\u{130}".match(/[[:lower:]]/).should == nil + "\u{405}".match(/[[:lower:]]/).should == nil end it "doesn't match Unicode title-case characters with [[:lower:]]" do - "\u{1F88}".match(/[[:lower:]]/).should be_nil - "\u{1FAD}".match(/[[:lower:]]/).should be_nil - "\u{01C5}".match(/[[:lower:]]/).should be_nil + "\u{1F88}".match(/[[:lower:]]/).should == nil + "\u{1FAD}".match(/[[:lower:]]/).should == nil + "\u{01C5}".match(/[[:lower:]]/).should == nil end it "doesn't match Unicode digits with [[:lower:]]" do - "\u{0660}".match(/[[:lower:]]/).should be_nil - "\u{FF12}".match(/[[:lower:]]/).should be_nil + "\u{0660}".match(/[[:lower:]]/).should == nil + "\u{FF12}".match(/[[:lower:]]/).should == nil end it "doesn't match Unicode marks with [[:lower:]]" do - "\u{36F}".match(/[[:lower:]]/).should be_nil + "\u{36F}".match(/[[:lower:]]/).should == nil end it "doesn't match Unicode punctuation characters with [[:lower:]]" do - "\u{3F}".match(/[[:lower:]]/).should be_nil + "\u{3F}".match(/[[:lower:]]/).should == nil end it "doesn't match Unicode control characters with [[:lower:]]" do - "\u{16}".match(/[[:lower:]]/).should be_nil + "\u{16}".match(/[[:lower:]]/).should == nil end it "doesn't match Unicode format characters with [[:lower:]]" do - "\u{2060}".match(/[[:lower:]]/).should be_nil + "\u{2060}".match(/[[:lower:]]/).should == nil end it "doesn't match Unicode private-use characters with [[:lower:]]" do - "\u{E001}".match(/[[:lower:]]/).should be_nil + "\u{E001}".match(/[[:lower:]]/).should == nil end it "matches Unicode lowercase letter characters with [[:print:]]" do @@ -329,7 +329,7 @@ end it "doesn't match Unicode control characters with [[:print:]]" do - "\u{16}".match(/[[:print:]]/).should be_nil + "\u{16}".match(/[[:print:]]/).should == nil end it "match Unicode format characters with [[:print:]]" do @@ -342,30 +342,30 @@ it "doesn't match Unicode lowercase letter characters with [[:punct:]]" do - "\u{FF41}".match(/[[:punct:]]/).should be_nil - "\u{1D484}".match(/[[:punct:]]/).should be_nil - "\u{E8}".match(/[[:punct:]]/).should be_nil + "\u{FF41}".match(/[[:punct:]]/).should == nil + "\u{1D484}".match(/[[:punct:]]/).should == nil + "\u{E8}".match(/[[:punct:]]/).should == nil end it "doesn't match Unicode uppercase letter characters with [[:punct:]]" do - "\u{100}".match(/[[:punct:]]/).should be_nil - "\u{130}".match(/[[:punct:]]/).should be_nil - "\u{405}".match(/[[:punct:]]/).should be_nil + "\u{100}".match(/[[:punct:]]/).should == nil + "\u{130}".match(/[[:punct:]]/).should == nil + "\u{405}".match(/[[:punct:]]/).should == nil end it "doesn't match Unicode title-case characters with [[:punct:]]" do - "\u{1F88}".match(/[[:punct:]]/).should be_nil - "\u{1FAD}".match(/[[:punct:]]/).should be_nil - "\u{01C5}".match(/[[:punct:]]/).should be_nil + "\u{1F88}".match(/[[:punct:]]/).should == nil + "\u{1FAD}".match(/[[:punct:]]/).should == nil + "\u{01C5}".match(/[[:punct:]]/).should == nil end it "doesn't match Unicode digits with [[:punct:]]" do - "\u{0660}".match(/[[:punct:]]/).should be_nil - "\u{FF12}".match(/[[:punct:]]/).should be_nil + "\u{0660}".match(/[[:punct:]]/).should == nil + "\u{FF12}".match(/[[:punct:]]/).should == nil end it "doesn't match Unicode marks with [[:punct:]]" do - "\u{36F}".match(/[[:punct:]]/).should be_nil + "\u{36F}".match(/[[:punct:]]/).should == nil end it "matches Unicode Pc characters with [[:punct:]]" do @@ -398,38 +398,38 @@ end it "doesn't match Unicode format characters with [[:punct:]]" do - "\u{2060}".match(/[[:punct:]]/).should be_nil + "\u{2060}".match(/[[:punct:]]/).should == nil end it "doesn't match Unicode private-use characters with [[:punct:]]" do - "\u{E001}".match(/[[:punct:]]/).should be_nil + "\u{E001}".match(/[[:punct:]]/).should == nil end it "doesn't match Unicode lowercase letter characters with [[:space:]]" do - "\u{FF41}".match(/[[:space:]]/).should be_nil - "\u{1D484}".match(/[[:space:]]/).should be_nil - "\u{E8}".match(/[[:space:]]/).should be_nil + "\u{FF41}".match(/[[:space:]]/).should == nil + "\u{1D484}".match(/[[:space:]]/).should == nil + "\u{E8}".match(/[[:space:]]/).should == nil end it "doesn't match Unicode uppercase letter characters with [[:space:]]" do - "\u{100}".match(/[[:space:]]/).should be_nil - "\u{130}".match(/[[:space:]]/).should be_nil - "\u{405}".match(/[[:space:]]/).should be_nil + "\u{100}".match(/[[:space:]]/).should == nil + "\u{130}".match(/[[:space:]]/).should == nil + "\u{405}".match(/[[:space:]]/).should == nil end it "doesn't match Unicode title-case characters with [[:space:]]" do - "\u{1F88}".match(/[[:space:]]/).should be_nil - "\u{1FAD}".match(/[[:space:]]/).should be_nil - "\u{01C5}".match(/[[:space:]]/).should be_nil + "\u{1F88}".match(/[[:space:]]/).should == nil + "\u{1FAD}".match(/[[:space:]]/).should == nil + "\u{01C5}".match(/[[:space:]]/).should == nil end it "doesn't match Unicode digits with [[:space:]]" do - "\u{0660}".match(/[[:space:]]/).should be_nil - "\u{FF12}".match(/[[:space:]]/).should be_nil + "\u{0660}".match(/[[:space:]]/).should == nil + "\u{FF12}".match(/[[:space:]]/).should == nil end it "doesn't match Unicode marks with [[:space:]]" do - "\u{36F}".match(/[[:space:]]/).should be_nil + "\u{36F}".match(/[[:space:]]/).should == nil end it "matches Unicode Zs characters with [[:space:]]" do @@ -445,17 +445,17 @@ end it "doesn't match Unicode format characters with [[:space:]]" do - "\u{2060}".match(/[[:space:]]/).should be_nil + "\u{2060}".match(/[[:space:]]/).should == nil end it "doesn't match Unicode private-use characters with [[:space:]]" do - "\u{E001}".match(/[[:space:]]/).should be_nil + "\u{E001}".match(/[[:space:]]/).should == nil end it "doesn't match Unicode lowercase characters with [[:upper:]]" do - "\u{FF41}".match(/[[:upper:]]/).should be_nil - "\u{1D484}".match(/[[:upper:]]/).should be_nil - "\u{E8}".match(/[[:upper:]]/).should be_nil + "\u{FF41}".match(/[[:upper:]]/).should == nil + "\u{1D484}".match(/[[:upper:]]/).should == nil + "\u{E8}".match(/[[:upper:]]/).should == nil end it "matches Unicode uppercase characters with [[:upper:]]" do @@ -465,40 +465,40 @@ end it "doesn't match Unicode title-case characters with [[:upper:]]" do - "\u{1F88}".match(/[[:upper:]]/).should be_nil - "\u{1FAD}".match(/[[:upper:]]/).should be_nil - "\u{01C5}".match(/[[:upper:]]/).should be_nil + "\u{1F88}".match(/[[:upper:]]/).should == nil + "\u{1FAD}".match(/[[:upper:]]/).should == nil + "\u{01C5}".match(/[[:upper:]]/).should == nil end it "doesn't match Unicode digits with [[:upper:]]" do - "\u{0660}".match(/[[:upper:]]/).should be_nil - "\u{FF12}".match(/[[:upper:]]/).should be_nil + "\u{0660}".match(/[[:upper:]]/).should == nil + "\u{FF12}".match(/[[:upper:]]/).should == nil end it "doesn't match Unicode marks with [[:upper:]]" do - "\u{36F}".match(/[[:upper:]]/).should be_nil + "\u{36F}".match(/[[:upper:]]/).should == nil end it "doesn't match Unicode punctuation characters with [[:upper:]]" do - "\u{3F}".match(/[[:upper:]]/).should be_nil + "\u{3F}".match(/[[:upper:]]/).should == nil end it "doesn't match Unicode control characters with [[:upper:]]" do - "\u{16}".match(/[[:upper:]]/).should be_nil + "\u{16}".match(/[[:upper:]]/).should == nil end it "doesn't match Unicode format characters with [[:upper:]]" do - "\u{2060}".match(/[[:upper:]]/).should be_nil + "\u{2060}".match(/[[:upper:]]/).should == nil end it "doesn't match Unicode private-use characters with [[:upper:]]" do - "\u{E001}".match(/[[:upper:]]/).should be_nil + "\u{E001}".match(/[[:upper:]]/).should == nil end it "doesn't match Unicode letter characters [^a-fA-F] with [[:xdigit:]]" do - "à".match(/[[:xdigit:]]/).should be_nil - "g".match(/[[:xdigit:]]/).should be_nil - "X".match(/[[:xdigit:]]/).should be_nil + "à".match(/[[:xdigit:]]/).should == nil + "g".match(/[[:xdigit:]]/).should == nil + "X".match(/[[:xdigit:]]/).should == nil end it "matches Unicode letter characters [a-fA-F] with [[:xdigit:]]" do @@ -507,28 +507,28 @@ end it "doesn't match Unicode digits [^0-9] with [[:xdigit:]]" do - "\u{0660}".match(/[[:xdigit:]]/).should be_nil - "\u{FF12}".match(/[[:xdigit:]]/).should be_nil + "\u{0660}".match(/[[:xdigit:]]/).should == nil + "\u{FF12}".match(/[[:xdigit:]]/).should == nil end it "doesn't match Unicode marks with [[:xdigit:]]" do - "\u{36F}".match(/[[:xdigit:]]/).should be_nil + "\u{36F}".match(/[[:xdigit:]]/).should == nil end it "doesn't match Unicode punctuation characters with [[:xdigit:]]" do - "\u{3F}".match(/[[:xdigit:]]/).should be_nil + "\u{3F}".match(/[[:xdigit:]]/).should == nil end it "doesn't match Unicode control characters with [[:xdigit:]]" do - "\u{16}".match(/[[:xdigit:]]/).should be_nil + "\u{16}".match(/[[:xdigit:]]/).should == nil end it "doesn't match Unicode format characters with [[:xdigit:]]" do - "\u{2060}".match(/[[:xdigit:]]/).should be_nil + "\u{2060}".match(/[[:xdigit:]]/).should == nil end it "doesn't match Unicode private-use characters with [[:xdigit:]]" do - "\u{E001}".match(/[[:xdigit:]]/).should be_nil + "\u{E001}".match(/[[:xdigit:]]/).should == nil end it "matches Unicode lowercase characters with [[:word:]]" do @@ -570,22 +570,22 @@ end it "doesn't match Unicode No characters with [[:word:]]" do - "\u{17F0}".match(/[[:word:]]/).should be_nil + "\u{17F0}".match(/[[:word:]]/).should == nil end it "doesn't match Unicode punctuation characters with [[:word:]]" do - "\u{3F}".match(/[[:word:]]/).should be_nil + "\u{3F}".match(/[[:word:]]/).should == nil end it "doesn't match Unicode control characters with [[:word:]]" do - "\u{16}".match(/[[:word:]]/).should be_nil + "\u{16}".match(/[[:word:]]/).should == nil end it "doesn't match Unicode format characters with [[:word:]]" do - "\u{2060}".match(/[[:word:]]/).should be_nil + "\u{2060}".match(/[[:word:]]/).should == nil end it "doesn't match Unicode private-use characters with [[:word:]]" do - "\u{E001}".match(/[[:word:]]/).should be_nil + "\u{E001}".match(/[[:word:]]/).should == nil end it "matches unicode named character properties" do @@ -617,12 +617,12 @@ end it "supports negated property condition" do - "a".match(eval("/\P{L}/")).should be_nil - "1".match(eval("/\P{N}/")).should be_nil + "a".match(eval("/\P{L}/")).should == nil + "1".match(eval("/\P{N}/")).should == nil end it "raises a RegexpError for an unterminated unicode property" do - -> { Regexp.new('\p{') }.should raise_error(RegexpError) + -> { Regexp.new('\p{') }.should.raise(RegexpError) end it "supports \\X (unicode 9.0 with UTR #51 workarounds)" do diff --git a/spec/ruby/language/regexp/encoding_spec.rb b/spec/ruby/language/regexp/encoding_spec.rb index ceb9cf823ac53c..81e845af0c1787 100644 --- a/spec/ruby/language/regexp/encoding_spec.rb +++ b/spec/ruby/language/regexp/encoding_spec.rb @@ -114,28 +114,28 @@ end it "raises Encoding::CompatibilityError when trying match against different encodings" do - -> { /\A[[:space:]]*\z/.match(" ".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError) + -> { /\A[[:space:]]*\z/.match(" ".encode("UTF-16LE")) }.should.raise(Encoding::CompatibilityError) end it "raises Encoding::CompatibilityError when trying match? against different encodings" do - -> { /\A[[:space:]]*\z/.match?(" ".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError) + -> { /\A[[:space:]]*\z/.match?(" ".encode("UTF-16LE")) }.should.raise(Encoding::CompatibilityError) end it "raises Encoding::CompatibilityError when trying =~ against different encodings" do - -> { /\A[[:space:]]*\z/ =~ " ".encode("UTF-16LE") }.should raise_error(Encoding::CompatibilityError) + -> { /\A[[:space:]]*\z/ =~ " ".encode("UTF-16LE") }.should.raise(Encoding::CompatibilityError) end it "raises Encoding::CompatibilityError when the regexp has a fixed, non-ASCII-compatible encoding" do - -> { Regexp.new("".dup.force_encoding("UTF-16LE"), Regexp::FIXEDENCODING) =~ " ".encode("UTF-8") }.should raise_error(Encoding::CompatibilityError) + -> { Regexp.new("".dup.force_encoding("UTF-16LE"), Regexp::FIXEDENCODING) =~ " ".encode("UTF-8") }.should.raise(Encoding::CompatibilityError) end it "raises Encoding::CompatibilityError when the regexp has a fixed encoding and the match string has non-ASCII characters" do - -> { Regexp.new("".dup.force_encoding("US-ASCII"), Regexp::FIXEDENCODING) =~ "\303\251".dup.force_encoding('UTF-8') }.should raise_error(Encoding::CompatibilityError) + -> { Regexp.new("".dup.force_encoding("US-ASCII"), Regexp::FIXEDENCODING) =~ "\303\251".dup.force_encoding('UTF-8') }.should.raise(Encoding::CompatibilityError) end it "raises ArgumentError when trying to match a broken String" do s = "\x80".dup.force_encoding('UTF-8') - -> { s =~ /./ }.should raise_error(ArgumentError, "invalid byte sequence in UTF-8") + -> { s =~ /./ }.should.raise(ArgumentError, "invalid byte sequence in UTF-8") end it "computes the Regexp Encoding for each interpolated Regexp instance" do diff --git a/spec/ruby/language/regexp/escapes_spec.rb b/spec/ruby/language/regexp/escapes_spec.rb index 541998b9373179..4a0e6115409682 100644 --- a/spec/ruby/language/regexp/escapes_spec.rb +++ b/spec/ruby/language/regexp/escapes_spec.rb @@ -116,11 +116,11 @@ it "supports \\x (hex characters)" do /\xA/.match("\nxyz").to_a.should == ["\n"] /\x0A/.match("\n").to_a.should == ["\n"] - /\xAA/.match("\nA").should be_nil + /\xAA/.match("\nA").should == nil /\x0AA/.match("\nA").to_a.should == ["\nA"] /\xAG/.match("\nG").to_a.should == ["\nG"] # Non-matches - -> { eval('/\xG/') }.should raise_error(SyntaxError) + -> { eval('/\xG/') }.should.raise(SyntaxError) # \x{7HHHHHHH} wide hexadecimal char (character code point value) end @@ -136,14 +136,14 @@ /\c,\cL\cl/.match("\f\f\f").to_a.should == ["\f\f\f"] /\c-\cM\cm/.match("\r\r\r").to_a.should == ["\r\r\r"] - /\cJ/.match("\r").should be_nil + /\cJ/.match("\r").should == nil # Parsing precedence /\cJ+/.match("\n\n").to_a.should == ["\n\n"] # Quantifiers apply to entire escape sequence /\\cJ/.match("\\cJ").to_a.should == ["\\cJ"] - -> { eval('/[abc\x]/') }.should raise_error(SyntaxError) # \x is treated as a escape sequence even inside a character class + -> { eval('/[abc\x]/') }.should.raise(SyntaxError) # \x is treated as a escape sequence even inside a character class # Syntax error - -> { eval('/\c/') }.should raise_error(SyntaxError) + -> { eval('/\c/') }.should.raise(SyntaxError) # \cx control char (character code point value) # \C-x control char (character code point value) diff --git a/spec/ruby/language/regexp/grouping_spec.rb b/spec/ruby/language/regexp/grouping_spec.rb index 313858f7141987..80ad7460da8dd6 100644 --- a/spec/ruby/language/regexp/grouping_spec.rb +++ b/spec/ruby/language/regexp/grouping_spec.rb @@ -12,7 +12,7 @@ end it "raises a SyntaxError when parentheses aren't balanced" do - -> { eval "/(hay(st)ack/" }.should raise_error(SyntaxError) + -> { eval "/(hay(st)ack/" }.should.raise(SyntaxError) end it "supports (?: ) (non-capturing group)" do @@ -22,8 +22,8 @@ end it "group names cannot start with digits or minus" do - -> { Regexp.new("(?<1a>a)") }.should raise_error(RegexpError) - -> { Regexp.new("(?<-a>a)") }.should raise_error(RegexpError) + -> { Regexp.new("(?<1a>a)") }.should.raise(RegexpError) + -> { Regexp.new("(?<-a>a)") }.should.raise(RegexpError) end it "ignore capture groups in line comments" do diff --git a/spec/ruby/language/regexp/interpolation_spec.rb b/spec/ruby/language/regexp/interpolation_spec.rb index 6951fd38cadb1d..f771d0a3959945 100644 --- a/spec/ruby/language/regexp/interpolation_spec.rb +++ b/spec/ruby/language/regexp/interpolation_spec.rb @@ -36,14 +36,14 @@ def o.to_s it "gives precedence to escape sequences over substitution" do str = "J" - /\c#{str}/.to_s.should include('{str}') + /\c#{str}/.to_s.should.include?('{str}') end it "throws RegexpError for malformed interpolation" do s = "" - -> { /(#{s}/ }.should raise_error(RegexpError) + -> { /(#{s}/ }.should.raise(RegexpError) s = "(" - -> { /#{s}/ }.should raise_error(RegexpError) + -> { /#{s}/ }.should.raise(RegexpError) end it "allows interpolation in extended mode" do diff --git a/spec/ruby/language/regexp/modifiers_spec.rb b/spec/ruby/language/regexp/modifiers_spec.rb index 2f5522bc8aec6f..c96fbfa983d536 100644 --- a/spec/ruby/language/regexp/modifiers_spec.rb +++ b/spec/ruby/language/regexp/modifiers_spec.rb @@ -8,7 +8,7 @@ it "supports /m (multiline)" do /foo.bar/m.match("foo\nbar").to_a.should == ["foo\nbar"] - /foo.bar/.match("foo\nbar").should be_nil + /foo.bar/.match("foo\nbar").should == nil end it "supports /x (extended syntax)" do @@ -36,7 +36,7 @@ def o.to_s /foo/imox.match("foo").to_a.should == ["foo"] /foo/imoximox.match("foo").to_a.should == ["foo"] - -> { eval('/foo/a') }.should raise_error(SyntaxError) + -> { eval('/foo/a') }.should.raise(SyntaxError) end it "supports (?~) (absent operator)" do @@ -46,57 +46,57 @@ def o.to_s it "supports (?imx-imx) (inline modifiers)" do /(?i)foo/.match("FOO").to_a.should == ["FOO"] - /foo(?i)/.match("FOO").should be_nil + /foo(?i)/.match("FOO").should == nil # Interaction with /i - /(?-i)foo/i.match("FOO").should be_nil + /(?-i)foo/i.match("FOO").should == nil /foo(?-i)/i.match("FOO").to_a.should == ["FOO"] # Multiple uses /foo (?i)bar (?-i)baz/.match("foo BAR baz").to_a.should == ["foo BAR baz"] - /foo (?i)bar (?-i)baz/.match("foo BAR BAZ").should be_nil + /foo (?i)bar (?-i)baz/.match("foo BAR BAZ").should == nil /(?m)./.match("\n").to_a.should == ["\n"] - /.(?m)/.match("\n").should be_nil + /.(?m)/.match("\n").should == nil # Interaction with /m - /(?-m)./m.match("\n").should be_nil + /(?-m)./m.match("\n").should == nil /.(?-m)/m.match("\n").to_a.should == ["\n"] # Multiple uses /. (?m). (?-m)./.match(". \n .").to_a.should == [". \n ."] - /. (?m). (?-m)./.match(". \n \n").should be_nil + /. (?m). (?-m)./.match(". \n \n").should == nil /(?x) foo /.match("foo").to_a.should == ["foo"] - / foo (?x)/.match("foo").should be_nil + / foo (?x)/.match("foo").should == nil # Interaction with /x - /(?-x) foo /x.match("foo").should be_nil + /(?-x) foo /x.match("foo").should == nil / foo (?-x)/x.match("foo").to_a.should == ["foo"] # Multiple uses /( foo )(?x)( bar )(?-x)( baz )/.match(" foo bar baz ").to_a.should == [" foo bar baz ", " foo ", "bar", " baz "] - /( foo )(?x)( bar )(?-x)( baz )/.match(" foo barbaz").should be_nil + /( foo )(?x)( bar )(?-x)( baz )/.match(" foo barbaz").should == nil # Parsing - /(?i-i)foo/.match("FOO").should be_nil + /(?i-i)foo/.match("FOO").should == nil /(?ii)foo/.match("FOO").to_a.should == ["FOO"] /(?-)foo/.match("foo").to_a.should == ["foo"] - -> { eval('/(?o)/') }.should raise_error(SyntaxError) + -> { eval('/(?o)/') }.should.raise(SyntaxError) end it "supports (?imx-imx:expr) (scoped inline modifiers)" do /foo (?i:bar) baz/.match("foo BAR baz").to_a.should == ["foo BAR baz"] - /foo (?i:bar) baz/.match("foo BAR BAZ").should be_nil - /foo (?-i:bar) baz/i.match("foo BAR BAZ").should be_nil + /foo (?i:bar) baz/.match("foo BAR BAZ").should == nil + /foo (?-i:bar) baz/i.match("foo BAR BAZ").should == nil /. (?m:.) ./.match(". \n .").to_a.should == [". \n ."] - /. (?m:.) ./.match(". \n \n").should be_nil - /. (?-m:.) ./m.match("\n \n \n").should be_nil + /. (?m:.) ./.match(". \n \n").should == nil + /. (?-m:.) ./m.match("\n \n \n").should == nil /( foo )(?x: bar )( baz )/.match(" foo bar baz ").to_a.should == [" foo bar baz ", " foo ", " baz "] - /( foo )(?x: bar )( baz )/.match(" foo barbaz").should be_nil + /( foo )(?x: bar )( baz )/.match(" foo barbaz").should == nil /( foo )(?-x: bar )( baz )/x.match("foo bar baz").to_a.should == ["foo bar baz", "foo", "baz"] # Parsing - /(?i-i:foo)/.match("FOO").should be_nil + /(?i-i:foo)/.match("FOO").should == nil /(?ii:foo)/.match("FOO").to_a.should == ["FOO"] /(?-:)foo/.match("foo").to_a.should == ["foo"] - -> { eval('/(?o:)/') }.should raise_error(SyntaxError) + -> { eval('/(?o:)/') }.should.raise(SyntaxError) end it "supports . with /m" do diff --git a/spec/ruby/language/regexp/repetition_spec.rb b/spec/ruby/language/regexp/repetition_spec.rb index d76619688f43ea..f24323de5c884c 100644 --- a/spec/ruby/language/regexp/repetition_spec.rb +++ b/spec/ruby/language/regexp/repetition_spec.rb @@ -15,7 +15,7 @@ it "supports + (1 or more of previous subexpression)" do /a+/.match("aaa").to_a.should == ["aaa"] - /a+/.match("bbb").should be_nil + /a+/.match("bbb").should == nil /<.+>/.match("foo").to_a.should == ["foo"] # it is greedy end diff --git a/spec/ruby/language/regexp_spec.rb b/spec/ruby/language/regexp_spec.rb index ce344b5b05f067..1452b01935fe56 100644 --- a/spec/ruby/language/regexp_spec.rb +++ b/spec/ruby/language/regexp_spec.rb @@ -15,7 +15,7 @@ end it "yields a Regexp" do - /Hello/.should be_kind_of(Regexp) + /Hello/.should.is_a?(Regexp) end it "is frozen" do @@ -27,11 +27,11 @@ 2.times do |i| rs << /foo/ end - rs[0].should equal(rs[1]) + rs[0].should.equal?(rs[1]) end it "throws SyntaxError for malformed literals" do - -> { eval('/(/') }.should raise_error(SyntaxError) + -> { eval('/(/') }.should.raise(SyntaxError) end ############################################################################# @@ -58,7 +58,7 @@ it "disallows first part of paired delimiters to be used as non-paired delimiters" do LanguageSpecs.paired_delimiters.each do |p0, p1| - -> { eval("%r#{p0} foo #{p0}") }.should raise_error(SyntaxError) + -> { eval("%r#{p0} foo #{p0}") }.should.raise(SyntaxError) end end @@ -69,11 +69,11 @@ end it "disallows alphabets as non-paired delimiter with %r" do - -> { eval('%ra foo a') }.should raise_error(SyntaxError) + -> { eval('%ra foo a') }.should.raise(SyntaxError) end it "disallows spaces after %r and delimiter" do - -> { eval('%r !foo!') }.should raise_error(SyntaxError) + -> { eval('%r !foo!') }.should.raise(SyntaxError) end it "allows unescaped / to be used with %r" do @@ -89,8 +89,8 @@ # Basic matching /./.match("foo").to_a.should == ["f"] # Basic non-matching - /./.match("").should be_nil - /./.match("\n").should be_nil + /./.match("").should == nil + /./.match("\n").should == nil /./.match("\0").to_a.should == ["\0"] end @@ -100,7 +100,7 @@ it "supports (?> ) (embedded subexpression)" do /(?>foo)(?>bar)/.match("foobar").to_a.should == ["foobar"] - /(?>foo*)obar/.match("foooooooobar").should be_nil # it is possessive + /(?>foo*)obar/.match("foooooooobar").should == nil # it is possessive end it "supports (?# )" do @@ -135,9 +135,9 @@ it "supports possessive quantifiers" do /fooA++bar/.match("fooAAAbar").to_a.should == ["fooAAAbar"] - /fooA++Abar/.match("fooAAAbar").should be_nil - /fooA?+Abar/.match("fooAAAbar").should be_nil - /fooA*+Abar/.match("fooAAAbar").should be_nil + /fooA++Abar/.match("fooAAAbar").should == nil + /fooA?+Abar/.match("fooAAAbar").should == nil + /fooA*+Abar/.match("fooAAAbar").should == nil end it "supports conditional regular expressions with positional capture groups" do diff --git a/spec/ruby/language/rescue_spec.rb b/spec/ruby/language/rescue_spec.rb index 6be3bfd023a36e..cf16d8f6f85718 100644 --- a/spec/ruby/language/rescue_spec.rb +++ b/spec/ruby/language/rescue_spec.rb @@ -59,7 +59,7 @@ class ArbitraryException < StandardError rescue SpecificExampleException => target&.captured_error :caught end.should == :caught - target.should be_nil + target.should == nil end it 'using a setter method' do @@ -186,7 +186,7 @@ class << Object.new rescue *exception_list caught_it = true end - caught_it.should be_true + caught_it.should == true caught = [] [->{raise ArbitraryException}, ->{raise SpecificExampleException}].each do |block| begin @@ -197,7 +197,7 @@ class << Object.new end caught.size.should == 2 exception_list.each do |exception_class| - caught.map{|e| e.class}.should include(exception_class) + caught.map{|e| e.class}.should.include?(exception_class) end end @@ -210,7 +210,7 @@ class << Object.new rescue *exceptions caught_it = true end - caught_it.should be_true + caught_it.should == true end it "can combine a splatted list of exceptions with a literal list of exceptions" do @@ -220,7 +220,7 @@ class << Object.new rescue ArbitraryException, *exception_list caught_it = true end - caught_it.should be_true + caught_it.should == true caught = [] [->{raise ArbitraryException}, ->{raise SpecificExampleException}].each do |block| begin @@ -231,7 +231,7 @@ class << Object.new end caught.size.should == 2 exception_list.each do |exception_class| - caught.map{|e| e.class}.should include(exception_class) + caught.map{|e| e.class}.should.include?(exception_class) end end @@ -241,7 +241,7 @@ class << Object.new raise OtherCustomException, "not rescued!" rescue *exception_list end - end.should raise_error(OtherCustomException) + end.should.raise(OtherCustomException) end it "can rescue different types of exceptions in different ways" do @@ -345,7 +345,7 @@ class << Object.new ScratchPad << :else end ruby - }.should raise_error(SyntaxError, /else without rescue is useless/) + }.should.raise(SyntaxError, /else without rescue is useless/) end it "will not execute an else block if an exception was raised" do @@ -413,7 +413,7 @@ class << Object.new ScratchPad << :two raise SpecificExampleException, "an error from else" end - end.should raise_error(SpecificExampleException) + end.should.raise(SpecificExampleException) ScratchPad.recorded.should == [:one, :two] end @@ -445,7 +445,7 @@ class << Object.new rescue ScratchPad << :caught end - }.should raise_error(exception.class) + }.should.raise(exception.class) end ScratchPad.recorded.should == [] end @@ -476,7 +476,7 @@ def rescuer.===(exception) raise "error" rescue rescuer end - }.should raise_error(TypeError) { |e| + }.should.raise(TypeError) { |e| e.message.should =~ /class or module required for rescue clause/ } end @@ -488,7 +488,7 @@ def rescuer.===(exception) raise "error" rescue *rescuer end - }.should raise_error(TypeError) { |e| + }.should.raise(TypeError) { |e| e.message.should =~ /class or module required for rescue clause/ } end @@ -508,7 +508,7 @@ def rescuer.===(exception) raise "from block" rescue (raise "from rescue expression") end - }.should raise_error(RuntimeError, "from rescue expression") { |e| + }.should.raise(RuntimeError, "from rescue expression") { |e| e.cause.message.should == "from block" } end @@ -542,7 +542,7 @@ class RescueInClassExample :caught } ruby - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "allows rescue in 'do end' block" do @@ -563,7 +563,7 @@ class RescueInClassExample end it "requires the 'rescue' in method arguments to be wrapped in parens" do - -> { eval '1.+(1 rescue 1)' }.should raise_error(SyntaxError) + -> { eval '1.+(1 rescue 1)' }.should.raise(SyntaxError) eval('1.+((1 rescue 1))').should == 2 end @@ -593,7 +593,7 @@ def foo eval <<-ruby a = 1 rescue RuntimeError 2 ruby - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "rescues only StandardError and its subclasses" do @@ -602,7 +602,7 @@ def foo -> { a = raise(Exception) rescue 1 - }.should raise_error(Exception) + }.should.raise(Exception) end it "rescues with multiple assignment" do diff --git a/spec/ruby/language/reserved_keywords.rb b/spec/ruby/language/reserved_keywords.rb index 6c40e34cccc92e..bd1a55feec6594 100644 --- a/spec/ruby/language/reserved_keywords.rb +++ b/spec/ruby/language/reserved_keywords.rb @@ -49,20 +49,20 @@ keywords.each do |name| describe "keyword '#{name}'" do it "can't be used as local variable name" do - -> { eval(<<~RUBY) }.should raise_error(SyntaxError) + -> { eval(<<~RUBY) }.should.raise(SyntaxError) #{name} = :local_variable RUBY end if name == "defined?" it "can't be used as an instance variable name" do - -> { eval(<<~RUBY) }.should raise_error(SyntaxError) + -> { eval(<<~RUBY) }.should.raise(SyntaxError) @#{name} = :instance_variable RUBY end it "can't be used as a class variable name" do - -> { eval(<<~RUBY) }.should raise_error(SyntaxError) + -> { eval(<<~RUBY) }.should.raise(SyntaxError) class C @@#{name} = :class_variable end @@ -70,7 +70,7 @@ class C end it "can't be used as a global variable name" do - -> { eval(<<~RUBY) }.should raise_error(SyntaxError) + -> { eval(<<~RUBY) }.should.raise(SyntaxError) $#{name} = :global_variable RUBY end @@ -106,7 +106,7 @@ class C end it "can't be used as a positional parameter name" do - -> { eval(<<~RUBY) }.should raise_error(SyntaxError) + -> { eval(<<~RUBY) }.should.raise(SyntaxError) def x(#{name}); end RUBY end @@ -115,7 +115,7 @@ def x(#{name}); end if invalid_kw_param_names.include?(name) it "can't be used a keyword parameter name" do - -> { eval(<<~RUBY) }.should raise_error(SyntaxError) + -> { eval(<<~RUBY) }.should.raise(SyntaxError) def m(#{name}:); end RUBY end diff --git a/spec/ruby/language/retry_spec.rb b/spec/ruby/language/retry_spec.rb index 669d5f0ff51904..39e58b7b5d4b87 100644 --- a/spec/ruby/language/retry_spec.rb +++ b/spec/ruby/language/retry_spec.rb @@ -32,10 +32,10 @@ end it "raises a SyntaxError when used outside of a rescue statement" do - -> { eval 'retry' }.should raise_error(SyntaxError) - -> { eval 'begin; retry; end' }.should raise_error(SyntaxError) - -> { eval 'def m; retry; end' }.should raise_error(SyntaxError) - -> { eval 'module RetrySpecs; retry; end' }.should raise_error(SyntaxError) + -> { eval 'retry' }.should.raise(SyntaxError) + -> { eval 'begin; retry; end' }.should.raise(SyntaxError) + -> { eval 'def m; retry; end' }.should.raise(SyntaxError) + -> { eval 'module RetrySpecs; retry; end' }.should.raise(SyntaxError) end end diff --git a/spec/ruby/language/return_spec.rb b/spec/ruby/language/return_spec.rb index a62ed1242d7007..36a3cba4d7f62d 100644 --- a/spec/ruby/language/return_spec.rb +++ b/spec/ruby/language/return_spec.rb @@ -19,7 +19,7 @@ def r; return [1,2]; end it "returns nil by default" do def r; return; end - r().should be_nil + r().should == nil end describe "in a Thread" do @@ -31,7 +31,7 @@ def r; return; end e end } - t.value.should be_an_instance_of(LocalJumpError) + t.value.should.instance_of?(LocalJumpError) end end @@ -176,11 +176,11 @@ def f() end it "causes lambda to return nil if invoked without any arguments" do - -> { return; 456 }.call.should be_nil + -> { return; 456 }.call.should == nil end it "causes lambda to return nil if invoked with an empty expression" do - -> { return (); 456 }.call.should be_nil + -> { return (); 456 }.call.should == nil end it "causes lambda to return the value passed to return" do @@ -229,7 +229,7 @@ def b def f 1.times { 1.times {return true}; false}; false end - f.should be_true + f.should == true end end @@ -417,7 +417,7 @@ class ReturnSpecs::A end END_OF_CODE - -> { load @filename }.should raise_error(SyntaxError) + -> { load @filename }.should.raise(SyntaxError) end end @@ -431,7 +431,7 @@ class ReturnSpecs::A end END_OF_CODE - -> { load @filename }.should raise_error(LocalJumpError) + -> { load @filename }.should.raise(LocalJumpError) end end diff --git a/spec/ruby/language/safe_navigator_spec.rb b/spec/ruby/language/safe_navigator_spec.rb index b1e28c3963f176..e8b429631d8274 100644 --- a/spec/ruby/language/safe_navigator_spec.rb +++ b/spec/ruby/language/safe_navigator_spec.rb @@ -2,7 +2,7 @@ describe "Safe navigator" do it "requires a method name to be provided" do - -> { eval("obj&. {}") }.should raise_error(SyntaxError) + -> { eval("obj&. {}") }.should.raise(SyntaxError) end context "when context is nil" do @@ -26,7 +26,7 @@ it "calls the method" do false&.to_s.should == "false" - -> { false&.unknown }.should raise_error(NoMethodError) + -> { false&.unknown }.should.raise(NoMethodError) end end @@ -34,7 +34,7 @@ it "calls the method" do 1&.to_s.should == "1" - -> { 1&.unknown }.should raise_error(NoMethodError) + -> { 1&.unknown }.should.raise(NoMethodError) end end @@ -140,7 +140,7 @@ def foo -> { obj&.foo += 3 - }.should raise_error(NoMethodError) { |e| + }.should.raise(NoMethodError) { |e| e.name.should == :+ } end diff --git a/spec/ruby/language/send_spec.rb b/spec/ruby/language/send_spec.rb index c60381cf55079c..f56a77d529f82e 100644 --- a/spec/ruby/language/send_spec.rb +++ b/spec/ruby/language/send_spec.rb @@ -22,7 +22,7 @@ it "raises ArgumentError if the method has a positive arity" do -> { specs.fooM1 - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -38,7 +38,7 @@ it "raises ArgumentError if the methods arity doesn't match" do -> { specs.fooM1(1,2) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -54,7 +54,7 @@ it "raises ArgumentError if extra arguments are passed" do -> { specs.fooM0O1(2,3) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -66,13 +66,13 @@ it "raises an ArgumentError if there are no values for the mandatory args" do -> { specs.fooM1O1 - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an ArgumentError if too many values are passed" do -> { specs.fooM1O1(1,2,3) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -94,7 +94,7 @@ it "with a block converts the block to a Proc" do prc = specs.makeproc { "hello" } - prc.should be_kind_of(Proc) + prc.should.is_a?(Proc) prc.call.should == "hello" end @@ -120,14 +120,14 @@ -> { specs.makeproc(&o) - }.should raise_error(TypeError, "no implicit conversion of Object into Proc") + }.should.raise(TypeError, "no implicit conversion of Object into Proc") end end it "raises a SyntaxError with both a literal block and an object as block" do -> { eval "specs.oneb(10, &l){ 42 }" - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "with same names as existing variables is ok" do @@ -212,21 +212,42 @@ def foobar; 200; end o.args.should == [1,2] end - it "raises NameError if invoked as a vcall" do - -> { no_such_method }.should raise_error NameError + describe "if invoked as a vcall" do + it "raises NameError" do + -> { no_such_method }.should.raise NameError + end + + it "raises NameError with $! as a cause" do + begin + raise RuntimeError.new + rescue => cause + -> { no_such_method }.should.raise(NameError, cause:) + end + end end it "should omit the method_missing call from the backtrace for NameError" do - -> { no_such_method }.should raise_error { |e| e.backtrace.first.should_not include("method_missing") } + -> { no_such_method }.should.raise { |e| e.backtrace.first.should_not.include?("method_missing") } end - it "raises NoMethodError if invoked as an unambiguous method call" do - -> { no_such_method() }.should raise_error NoMethodError - -> { no_such_method(1,2,3) }.should raise_error NoMethodError + describe "if invoked as an unambiguous method call" do + it "raises NoMethodError" do + -> { no_such_method() }.should.raise NoMethodError + -> { no_such_method(1,2,3) }.should.raise NoMethodError + end + + it "raises NoMethodError with $! as a cause" do + begin + raise + rescue => cause + -> { no_such_method() }.should.raise(NoMethodError, cause:) + -> { no_such_method(1,2,3) }.should.raise(NoMethodError, cause:) + end + end end it "should omit the method_missing call from the backtrace for NoMethodError" do - -> { no_such_method() }.should raise_error { |e| e.backtrace.first.should_not include("method_missing") } + -> { no_such_method() }.should.raise { |e| e.backtrace.first.should_not.include?("method_missing") } end end @@ -355,7 +376,7 @@ def []=(*) it "with splat operator * and non-Array value uses value unchanged if it does not respond_to?(:to_ary)" do obj = Object.new - obj.should_not respond_to(:to_a) + obj.should_not.respond_to?(:to_a) specs.fooM0R(*obj).should == [obj] specs.fooM1R(1,*obj).should == [1, [obj]] diff --git a/spec/ruby/language/shared/__FILE__.rb b/spec/ruby/language/shared/__FILE__.rb index 3e4f5c958dfc4f..7e2e8719328078 100644 --- a/spec/ruby/language/shared/__FILE__.rb +++ b/spec/ruby/language/shared/__FILE__.rb @@ -9,14 +9,14 @@ end it "equals the absolute path of a file loaded by an absolute path" do - @object.send(@method, @path).should be_true + @object.send(@method, @path).should == true ScratchPad.recorded.should == [@path] end it "equals the absolute path of a file loaded by a relative path" do $LOAD_PATH << "." Dir.chdir CODE_LOADING_DIR do - @object.send(@method, "file_fixture.rb").should be_true + @object.send(@method, "file_fixture.rb").should == true end ScratchPad.recorded.should == [@path] end diff --git a/spec/ruby/language/shared/__LINE__.rb b/spec/ruby/language/shared/__LINE__.rb index 076b74b3bac9d1..6bfc8c1c1797d5 100644 --- a/spec/ruby/language/shared/__LINE__.rb +++ b/spec/ruby/language/shared/__LINE__.rb @@ -9,7 +9,7 @@ end it "equals the line number of the text in a loaded file" do - @object.send(@method, @path).should be_true + @object.send(@method, @path).should == true ScratchPad.recorded.should == [1, 5] end end diff --git a/spec/ruby/language/singleton_class_spec.rb b/spec/ruby/language/singleton_class_spec.rb index 958bf464a7c9c0..20256a323ce58a 100644 --- a/spec/ruby/language/singleton_class_spec.rb +++ b/spec/ruby/language/singleton_class_spec.rb @@ -15,39 +15,39 @@ end it "raises a TypeError for Integer's" do - -> { 1.singleton_class }.should raise_error(TypeError) + -> { 1.singleton_class }.should.raise(TypeError) end it "raises a TypeError for symbols" do - -> { :symbol.singleton_class }.should raise_error(TypeError) + -> { :symbol.singleton_class }.should.raise(TypeError) end it "is a singleton Class instance" do o = mock('x') - o.singleton_class.should be_kind_of(Class) - o.singleton_class.should_not equal(Object) - o.should be_kind_of(o.singleton_class) + o.singleton_class.should.is_a?(Class) + o.singleton_class.should_not.equal?(Object) + o.should.is_a?(o.singleton_class) end it "is a Class for classes" do - ClassSpecs::A.singleton_class.should be_kind_of(Class) + ClassSpecs::A.singleton_class.should.is_a?(Class) end it "inherits from Class for classes" do - Class.should be_ancestor_of(Object.singleton_class) + Object.singleton_class.ancestors.should.include?(Class) end it "is a subclass of Class's singleton class" do ec = ClassSpecs::A.singleton_class - ec.should be_kind_of(Class.singleton_class) + ec.should.is_a?(Class.singleton_class) end it "is a subclass of the same level of Class's singleton class" do ecec = ClassSpecs::A.singleton_class.singleton_class class_ec = Class.singleton_class - ecec.should be_kind_of(class_ec.singleton_class) - ecec.should be_kind_of(class_ec) + ecec.should.is_a?(class_ec.singleton_class) + ecec.should.is_a?(class_ec) end it "is a subclass of a superclass's singleton class" do @@ -74,7 +74,7 @@ end it "doesn't have singleton class" do - -> { bignum_value.singleton_class }.should raise_error(TypeError) + -> { bignum_value.singleton_class }.should.raise(TypeError) end end @@ -105,20 +105,20 @@ class << @object end it "is not defined on the object's class" do - @object.class.const_defined?(:CONST).should be_false + @object.class.const_defined?(:CONST).should == false end it "is not defined in the singleton class opener's scope" do class << @object CONST end - -> { CONST }.should raise_error(NameError) + -> { CONST }.should.raise(NameError) end it "cannot be accessed via object::CONST" do -> do @object::CONST - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a NameError for anonymous_module::CONST" do @@ -129,15 +129,15 @@ class << @object -> do @object::CONST - end.should raise_error(NameError) + end.should.raise(NameError) end it "appears in the singleton class constant list" do - @object.singleton_class.should have_constant(:CONST) + @object.singleton_class.should.const_defined?(:CONST, false) end it "does not appear in the object's class constant list" do - @object.class.should_not have_constant(:CONST) + @object.class.should_not.const_defined?(:CONST) end it "is not preserved when the object is duped" do @@ -145,14 +145,14 @@ class << @object -> do class << @object; CONST; end - end.should raise_error(NameError) + end.should.raise(NameError) end it "is preserved when the object is cloned" do @object = @object.clone class << @object - CONST.should_not be_nil + CONST.should_not == nil end end end @@ -168,7 +168,7 @@ def singleton_method; 1 end end it "defines public methods" do - @k_sc.should have_public_instance_method(:singleton_method) + @k_sc.public_instance_methods(false).should.include?(:singleton_method) end end @@ -181,46 +181,46 @@ def singleton_method; 1 end end it "include ones of the object's class" do - @k_sc.should have_instance_method(:example_instance_method) + @k_sc.should.method_defined?(:example_instance_method, true) end it "does not include class methods of the object's class" do - @k_sc.should_not have_instance_method(:example_class_method) + @k_sc.should_not.method_defined?(:example_class_method) end it "include instance methods of Object" do - @a_sc.should have_instance_method(:example_instance_method_of_object) + @a_sc.should.method_defined?(:example_instance_method_of_object, true) end it "does not include class methods of Object" do - @a_sc.should_not have_instance_method(:example_class_method_of_object) + @a_sc.should_not.method_defined?(:example_class_method_of_object) end describe "for a class" do it "include instance methods of Class" do - @a_c_sc.should have_instance_method(:example_instance_method_of_class) + @a_c_sc.should.method_defined?(:example_instance_method_of_class, true) end it "does not include class methods of Class" do - @a_c_sc.should_not have_instance_method(:example_class_method_of_class) + @a_c_sc.should_not.method_defined?(:example_class_method_of_class) end it "does not include instance methods of the singleton class of Class" do - @a_c_sc.should_not have_instance_method(:example_instance_method_of_singleton_class) + @a_c_sc.should_not.method_defined?(:example_instance_method_of_singleton_class) end it "does not include class methods of the singleton class of Class" do - @a_c_sc.should_not have_instance_method(:example_class_method_of_singleton_class) + @a_c_sc.should_not.method_defined?(:example_class_method_of_singleton_class) end end describe "for a singleton class" do it "includes instance methods of the singleton class of Class" do - @a_c_sc.singleton_class.should have_instance_method(:example_instance_method_of_singleton_class) + @a_c_sc.singleton_class.should.method_defined?(:example_instance_method_of_singleton_class, true) end it "does not include class methods of the singleton class of Class" do - @a_c_sc.singleton_class.should_not have_instance_method(:example_class_method_of_singleton_class) + @a_c_sc.singleton_class.should_not.method_defined?(:example_class_method_of_singleton_class) end end end @@ -234,46 +234,46 @@ def singleton_method; 1 end end it "include ones of the object's class" do - @k_sc.should have_method(:example_class_method) + @k_sc.should.respond_to?(:example_class_method) end it "does not include instance methods of the object's class" do - @k_sc.should_not have_method(:example_instance_method) + @k_sc.should_not.respond_to?(:example_instance_method) end it "include instance methods of Class" do - @a_sc.should have_method(:example_instance_method_of_class) + @a_sc.should.respond_to?(:example_instance_method_of_class) end it "does not include class methods of Class" do - @a_sc.should_not have_method(:example_class_method_of_class) + @a_sc.should_not.respond_to?(:example_class_method_of_class) end describe "for a class" do it "include instance methods of Class" do - @a_c_sc.should have_method(:example_instance_method_of_class) + @a_c_sc.should.respond_to?(:example_instance_method_of_class) end it "include class methods of Class" do - @a_c_sc.should have_method(:example_class_method_of_class) + @a_c_sc.should.respond_to?(:example_class_method_of_class) end it "include instance methods of the singleton class of Class" do - @a_c_sc.should have_method(:example_instance_method_of_singleton_class) + @a_c_sc.should.respond_to?(:example_instance_method_of_singleton_class) end it "does not include class methods of the singleton class of Class" do - @a_c_sc.should_not have_method(:example_class_method_of_singleton_class) + @a_c_sc.should_not.respond_to?(:example_class_method_of_singleton_class) end end describe "for a singleton class" do it "include instance methods of the singleton class of Class" do - @a_c_sc.singleton_class.should have_method(:example_instance_method_of_singleton_class) + @a_c_sc.singleton_class.should.respond_to?(:example_instance_method_of_singleton_class) end it "include class methods of the singleton class of Class" do - @a_c_sc.singleton_class.should have_method(:example_class_method_of_singleton_class) + @a_c_sc.singleton_class.should.respond_to?(:example_class_method_of_singleton_class) end end end @@ -282,13 +282,13 @@ def singleton_method; 1 end it "raises a TypeError when new is called" do -> { Object.new.singleton_class.new - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a TypeError when allocate is called" do -> { Object.new.singleton_class.allocate - }.should raise_error(TypeError) + }.should.raise(TypeError) end end diff --git a/spec/ruby/language/string_spec.rb b/spec/ruby/language/string_spec.rb index 050ffaa4e777a9..163063032f61e5 100644 --- a/spec/ruby/language/string_spec.rb +++ b/spec/ruby/language/string_spec.rb @@ -136,7 +136,7 @@ class << obj it "raise NoMethodError when #to_s is not defined for the object" do obj = BasicObject.new - -> { "#{obj}" }.should raise_error(NoMethodError) + -> { "#{obj}" }.should.raise(NoMethodError) end it "uses an internal representation when #to_s doesn't return a String" do @@ -149,7 +149,7 @@ class << obj # is that if you interpolate an object that fails to return # a String, you will still get a String and not raise an # exception. - "#{obj}".should be_an_instance_of(String) + "#{obj}".should.instance_of?(String) end it "allows a dynamic string to parse a nested do...end block as an argument to a call without parens, interpolated" do @@ -287,7 +287,7 @@ def long_string_literals a = "\u3042" b = "\xff".dup.force_encoding "binary" - -> { "#{a} #{b}" }.should raise_error(Encoding::CompatibilityError) + -> { "#{a} #{b}" }.should.raise(Encoding::CompatibilityError) end it "creates a non-frozen String" do diff --git a/spec/ruby/language/super_spec.rb b/spec/ruby/language/super_spec.rb index e205fae13cedda..f595d49395d4df 100644 --- a/spec/ruby/language/super_spec.rb +++ b/spec/ruby/language/super_spec.rb @@ -83,8 +83,8 @@ def foo end end - -> {sub_normal.new.foo}.should raise_error(NoMethodError, /super/) - -> {sub_zsuper.new.foo}.should raise_error(NoMethodError, /super/) + -> {sub_normal.new.foo}.should.raise(NoMethodError, /super/) + -> {sub_zsuper.new.foo}.should.raise(NoMethodError, /super/) end it "uses given block even if arguments are passed explicitly" do @@ -130,7 +130,7 @@ def m(v) end end - c2.new.m('a') { raise }.should be_false + c2.new.m('a') { raise }.should == false end it "uses block argument given to method when used in a block" do @@ -200,7 +200,7 @@ def a(arg) end end - -> { klass.new.a(:a_called) }.should raise_error(RuntimeError) + -> { klass.new.a(:a_called) }.should.raise(RuntimeError) end it "is able to navigate to super, when a method is defined dynamically on the singleton class" do diff --git a/spec/ruby/language/symbol_spec.rb b/spec/ruby/language/symbol_spec.rb index 0801d3223ece0d..81fe06b50bd91d 100644 --- a/spec/ruby/language/symbol_spec.rb +++ b/spec/ruby/language/symbol_spec.rb @@ -3,7 +3,7 @@ describe "A Symbol literal" do it "is a ':' followed by any number of valid characters" do a = :foo - a.should be_kind_of(Symbol) + a.should.is_a?(Symbol) a.inspect.should == ':foo' end @@ -21,7 +21,7 @@ :_Foo, :&, :_9 - ].each { |s| s.should be_kind_of(Symbol) } + ].each { |s| s.should.is_a?(Symbol) } end it "is a ':' followed by a single- or double-quoted string that may contain otherwise invalid characters" do @@ -31,7 +31,7 @@ [:"foo #{1 + 1}", ':"foo 2"'], [:"foo\nbar", ':"foo\nbar"'], ].each { |sym, str| - sym.should be_kind_of(Symbol) + sym.should.is_a?(Symbol) sym.inspect.should == str } end @@ -42,22 +42,22 @@ end it "may contain '::' in the string" do - :'Some::Class'.should be_kind_of(Symbol) + :'Some::Class'.should.is_a?(Symbol) end it "is converted to a literal, unquoted representation if the symbol contains only valid characters" do a, b, c = :'foo', :'+', :'Foo__9' - a.should be_kind_of(Symbol) + a.should.is_a?(Symbol) a.inspect.should == ':foo' - b.should be_kind_of(Symbol) + b.should.is_a?(Symbol) b.inspect.should == ':+' - c.should be_kind_of(Symbol) + c.should.is_a?(Symbol) c.inspect.should == ':Foo__9' end it "can be created by the %s-delimited expression" do a, b = :'foo bar', %s{foo bar} - b.should be_kind_of(Symbol) + b.should.is_a?(Symbol) b.inspect.should == ':"foo bar"' b.should == a end @@ -68,7 +68,7 @@ [:'a string', :'a string'], [:"#{var}", :"#{var}"] ].each { |a, b| - a.should equal(b) + a.should.equal?(b) } end @@ -78,7 +78,7 @@ it "can be an empty string" do c = :'' - c.should be_kind_of(Symbol) + c.should.is_a?(Symbol) c.inspect.should == ':""' end @@ -101,7 +101,7 @@ ScratchPad.record [] -> { eval 'ScratchPad << 1; :"\xC3"' - }.should raise_error(SyntaxError, /invalid symbol/) + }.should.raise(SyntaxError, /invalid symbol/) ScratchPad.recorded.should == [] end end diff --git a/spec/ruby/language/throw_spec.rb b/spec/ruby/language/throw_spec.rb index d72384368868a4..73f64de17db51b 100644 --- a/spec/ruby/language/throw_spec.rb +++ b/spec/ruby/language/throw_spec.rb @@ -35,7 +35,7 @@ throw :exit end end - $!.should be_nil + $!.should == nil end it "allows any object as its argument" do @@ -45,7 +45,7 @@ end it "does not convert strings to a symbol" do - -> { catch(:exit) { throw "exit" } }.should raise_error(ArgumentError) + -> { catch(:exit) { throw "exit" } }.should.raise(ArgumentError) end it "unwinds stack from within a method" do @@ -64,8 +64,8 @@ def throw_method(handler, val) end it "raises an ArgumentError if outside of scope of a matching catch" do - -> { throw :test, 5 }.should raise_error(ArgumentError) - -> { catch(:different) { throw :test, 5 } }.should raise_error(ArgumentError) + -> { throw :test, 5 }.should.raise(ArgumentError) + -> { catch(:different) { throw :test, 5 } }.should.raise(ArgumentError) end it "raises an UncaughtThrowError if used to exit a thread" do @@ -73,7 +73,7 @@ def throw_method(handler, val) t = Thread.new { -> { throw :what - }.should raise_error(UncaughtThrowError) + }.should.raise(UncaughtThrowError) } t.join end diff --git a/spec/ruby/language/undef_spec.rb b/spec/ruby/language/undef_spec.rb index 268c0b84c3965e..98ecd99c21497e 100644 --- a/spec/ruby/language/undef_spec.rb +++ b/spec/ruby/language/undef_spec.rb @@ -14,42 +14,42 @@ def meth(o); o; end @undef_class.class_eval do undef meth end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end it "with a simple symbol" do @undef_class.class_eval do undef :meth end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end it "with a single quoted symbol" do @undef_class.class_eval do undef :'meth' end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end it "with a double quoted symbol" do @undef_class.class_eval do undef :"meth" end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end it "with an interpolated symbol" do @undef_class.class_eval do undef :"#{'meth'}" end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end it "with an interpolated symbol when interpolated expression is not a String literal" do @undef_class.class_eval do undef :"#{'meth'.to_sym}" end - -> { @obj.meth(5) }.should raise_error(NoMethodError) + -> { @obj.meth(5) }.should.raise(NoMethodError) end end @@ -70,7 +70,7 @@ def method2; :nope; end Class.new do -> { undef not_exist - }.should raise_error(NameError) { |e| + }.should.raise(NameError) { |e| # a NameError and not a NoMethodError e.class.should == NameError } diff --git a/spec/ruby/language/variables_spec.rb b/spec/ruby/language/variables_spec.rb index e1342719394bbc..e01e03f01e073c 100644 --- a/spec/ruby/language/variables_spec.rb +++ b/spec/ruby/language/variables_spec.rb @@ -91,7 +91,7 @@ class << x; private :to_ary; end x = mock("multi-assign single RHS") x.should_receive(:to_ary).and_return(1) - -> { a, b, c = x }.should raise_error(TypeError) + -> { a, b, c = x }.should.raise(TypeError) end it "does not call #to_a to convert an Object RHS when assigning a simple MLHS" do @@ -122,7 +122,7 @@ class << x; private :to_ary; end ary = [1, 2] x = (a, b = ary) - x.should equal(ary) + x.should.equal?(ary) end it "returns the RHS when it is an Array subclass" do @@ -130,7 +130,7 @@ class << x; private :to_ary; end ary = cls.new [1, 2] x = (a, b = ary) - x.should equal(ary) + x.should.equal?(ary) end it "does not call #to_ary on an Array subclass instance" do @@ -172,7 +172,7 @@ class << x; private :to_ary; end x = mock("multi-assign splat") x.should_receive(:to_ary).and_return(1) - -> { *a = x }.should raise_error(TypeError) + -> { *a = x }.should.raise(TypeError) end it "does not call #to_ary on an Array subclass" do @@ -189,8 +189,8 @@ class << x; private :to_ary; end ary = cls.new [1, 2] x = (*a = ary) - x.should equal(ary) - a.should be_an_instance_of(Array) + x.should.equal?(ary) + a.should.instance_of?(Array) end it "calls #to_ary to convert an Object RHS with MLHS" do @@ -205,7 +205,7 @@ class << x; private :to_ary; end x = mock("multi-assign splat") x.should_receive(:to_ary).and_return(1) - -> { a, *b, c = x }.should raise_error(TypeError) + -> { a, *b, c = x }.should.raise(TypeError) end it "does not call #to_a to convert an Object RHS with a MLHS" do @@ -301,7 +301,7 @@ def x(a) a end x = mock("multi-assign attributes") x.should_receive(:m).and_return(y) - -> { a, b = x.m }.should raise_error(TypeError) + -> { a, b = x.m }.should.raise(TypeError) end it "assigns values from a RHS method call with receiver and arguments" do @@ -393,7 +393,7 @@ module VariableSpecs ary = [1, 2] (a = *ary).should == [1, 2] - a.should_not equal(ary) + a.should_not.equal?(ary) end it "does not call #to_a on an Array subclass" do @@ -412,10 +412,10 @@ module VariableSpecs x = (a = *ary) x.should == [1, 2] - x.should be_an_instance_of(Array) + x.should.instance_of?(Array) a.should == [1, 2] - a.should be_an_instance_of(Array) + a.should.instance_of?(Array) end it "unfreezes the array returned from calling 'to_a' on the splatted value" do @@ -481,7 +481,7 @@ class << x; private :to_a; end x = mock("multi-assign RHS splat") x.should_receive(:to_a).and_return(1) - -> { *a = *x }.should raise_error(TypeError) + -> { *a = *x }.should.raise(TypeError) end it "does not call #to_ary to convert an Object RHS with a single splat LHS" do @@ -527,7 +527,7 @@ class << x; private :to_a; end x = mock("multi-assign splat") x.should_receive(:to_a).and_return(1) - -> { a = *x }.should raise_error(TypeError) + -> { a = *x }.should.raise(TypeError) end it "calls #to_a to convert an Object splat RHS when assigned to a simple MLHS" do @@ -542,7 +542,7 @@ class << x; private :to_a; end x = mock("multi-assign splat") x.should_receive(:to_a).and_return(1) - -> { a, b, c = *x }.should raise_error(TypeError) + -> { a, b, c = *x }.should.raise(TypeError) end it "does not call #to_ary to convert an Object splat RHS when assigned to a simple MLHS" do @@ -565,7 +565,7 @@ class << x; private :to_a; end x = mock("multi-assign splat") x.should_receive(:to_a).and_return(1) - -> { a, *b, c = *x }.should raise_error(TypeError) + -> { a, *b, c = *x }.should.raise(TypeError) end it "does not call #to_ary to convert an Object RHS with a MLHS" do @@ -645,7 +645,7 @@ module VariableSpecs x = mock("multi-assign splat MRHS") x.should_receive(:to_a).and_return(1) - -> { a, *b = 1, *x }.should raise_error(TypeError) + -> { a, *b = 1, *x }.should.raise(TypeError) end it "does not call #to_ary to convert a splatted Object as part of a MRHS with a splat MRHS" do @@ -668,7 +668,7 @@ module VariableSpecs x = mock("multi-assign splat MRHS") x.should_receive(:to_a).and_return(1) - -> { a, *b = *x, 1 }.should raise_error(TypeError) + -> { a, *b = *x, 1 }.should.raise(TypeError) end it "does not call #to_ary to convert a splatted Object with a splat MRHS" do @@ -717,7 +717,7 @@ module VariableSpecs x = mock("multi-assign mixed RHS") x.should_receive(:to_ary).and_return(x) - -> { a, (b, c), d = 1, x, 3, 4 }.should raise_error(TypeError) + -> { a, (b, c), d = 1, x, 3, 4 }.should.raise(TypeError) end it "calls #to_a to convert a splatted Object value in a MRHS" do @@ -741,7 +741,7 @@ module VariableSpecs x = mock("multi-assign mixed splatted RHS") x.should_receive(:to_ary).and_return(x) - -> { a, *b, (c, d) = 1, 2, 3, *x }.should raise_error(TypeError) + -> { a, *b, (c, d) = 1, 2, 3, *x }.should.raise(TypeError) end it "does not call #to_ary to convert an Object when the position receiving the value is a simple variable" do @@ -889,7 +889,7 @@ def test ἍBB = 1 end CODE - end.should raise_error(SyntaxError, /dynamic constant assignment/) + end.should.raise(SyntaxError, /dynamic constant assignment/) end end diff --git a/spec/ruby/language/while_spec.rb b/spec/ruby/language/while_spec.rb index e172453ca6d71b..b9bf32047d9aef 100644 --- a/spec/ruby/language/while_spec.rb +++ b/spec/ruby/language/while_spec.rb @@ -88,7 +88,7 @@ break if c c = false ) - end.should be_nil + end.should == nil end it "stops running body if interrupted by break in a begin ... end element op-assign-or value" do @@ -99,7 +99,7 @@ break if c c = false end - end.should be_nil + end.should == nil end it "stops running body if interrupted by break in a parenthesized element op-assign value" do @@ -111,7 +111,7 @@ break if c c = false ) - end.should be_nil + end.should == nil a.should == [1, 2] end @@ -123,7 +123,7 @@ break if c c = false end - end.should be_nil + end.should == nil a.should == [1, 2] end @@ -139,7 +139,7 @@ break unless d d = false ) - end.should be_nil + end.should == nil end it "stops running body if interrupted by break with unless in a begin ... end attribute op-assign-or value" do @@ -153,7 +153,7 @@ break unless d d = false end - end.should be_nil + end.should == nil end it "stops running body if interrupted by break in a parenthesized attribute op-assign-or value" do @@ -168,7 +168,7 @@ break if c c = false ) - end.should be_nil + end.should == nil end it "stops running body if interrupted by break in a begin ... end attribute op-assign-or value" do @@ -182,7 +182,7 @@ break if c c = false end - end.should be_nil + end.should == nil end it "returns value passed to break if interrupted by break" do diff --git a/spec/ruby/language/yield_spec.rb b/spec/ruby/language/yield_spec.rb index 3b1313914f2ede..3173f41b0c3991 100644 --- a/spec/ruby/language/yield_spec.rb +++ b/spec/ruby/language/yield_spec.rb @@ -13,7 +13,7 @@ describe "taking no arguments" do it "raises a LocalJumpError when the method is not passed a block" do - -> { @y.z }.should raise_error(LocalJumpError) + -> { @y.z }.should.raise(LocalJumpError) end it "ignores assignment to the explicit block argument and calls the passed block" do @@ -28,7 +28,7 @@ describe "taking a single argument" do describe "when no block is given" do it "raises a LocalJumpError" do - -> { @y.s(1) }.should raise_error(LocalJumpError) + -> { @y.s(1) }.should.raise(LocalJumpError) end end @@ -76,20 +76,20 @@ it "raises an ArgumentError if too few arguments are passed" do -> { @y.s(1, &-> a, b { [a,b] }) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "should not destructure an Array into multiple arguments" do -> { @y.s([1, 2], &-> a, b { [a,b] }) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end end describe "taking multiple arguments" do it "raises a LocalJumpError when the method is not passed a block" do - -> { @y.m(1, 2, 3) }.should raise_error(LocalJumpError) + -> { @y.m(1, 2, 3) }.should.raise(LocalJumpError) end it "passes the arguments to the block" do @@ -103,19 +103,19 @@ it "raises an ArgumentError if too many arguments are passed to a lambda" do -> { @y.m(1, 2, 3, &-> a { }) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an ArgumentError if too few arguments are passed to a lambda" do -> { @y.m(1, 2, 3, &-> a, b, c, d { }) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end describe "taking a single splatted argument" do it "raises a LocalJumpError when the method is not passed a block" do - -> { @y.r(0) }.should raise_error(LocalJumpError) + -> { @y.r(0) }.should.raise(LocalJumpError) end it "passes a single value" do @@ -147,7 +147,7 @@ describe "taking multiple arguments with a splat" do it "raises a LocalJumpError when the method is not passed a block" do - -> { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError) + -> { @y.rs(1, 2, [3, 4]) }.should.raise(LocalJumpError) end it "passes the arguments to the block" do @@ -172,7 +172,7 @@ describe "taking matching arguments with splats and post args" do it "raises a LocalJumpError when the method is not passed a block" do - -> { @y.rs(1, 2, [3, 4]) }.should raise_error(LocalJumpError) + -> { @y.rs(1, 2, [3, 4]) }.should.raise(LocalJumpError) end it "passes the arguments to the block" do @@ -199,7 +199,7 @@ class << Object.new end RUBY - -> { eval(code) }.should raise_error(SyntaxError, /Invalid yield/) + -> { eval(code) }.should.raise(SyntaxError, /Invalid yield/) end end @@ -209,7 +209,7 @@ class << Object.new 1.times { yield } RUBY - -> { eval(code) }.should raise_error(SyntaxError, /Invalid yield/) + -> { eval(code) }.should.raise(SyntaxError, /Invalid yield/) end end @@ -221,6 +221,6 @@ module YieldSpecs::ModuleWithYield end RUBY - -> { eval(code) }.should raise_error(SyntaxError, /Invalid yield/) + -> { eval(code) }.should.raise(SyntaxError, /Invalid yield/) end end diff --git a/spec/ruby/library/English/English_spec.rb b/spec/ruby/library/English/English_spec.rb index 166785f066640b..bdc3774608ab5d 100644 --- a/spec/ruby/library/English/English_spec.rb +++ b/spec/ruby/library/English/English_spec.rb @@ -7,26 +7,26 @@ begin raise "error" rescue - $ERROR_INFO.should_not be_nil + $ERROR_INFO.should_not == nil $ERROR_INFO.should == $! end - $ERROR_INFO.should be_nil + $ERROR_INFO.should == nil end it "aliases $ERROR_POSITION to $@" do begin raise "error" rescue - $ERROR_POSITION.should_not be_nil + $ERROR_POSITION.should_not == nil $ERROR_POSITION.should == $@ end - $ERROR_POSITION.should be_nil + $ERROR_POSITION.should == nil end it "aliases $FS to $;" do original = $; suppress_warning {$; = ","} - $FS.should_not be_nil + $FS.should_not == nil $FS.should == $; suppress_warning {$; = original} end @@ -34,7 +34,7 @@ it "aliases $FIELD_SEPARATOR to $;" do original = $; suppress_warning {$; = ","} - $FIELD_SEPARATOR.should_not be_nil + $FIELD_SEPARATOR.should_not == nil $FIELD_SEPARATOR.should == $; suppress_warning {$; = original} end @@ -42,7 +42,7 @@ it "aliases $OFS to $," do original = $, suppress_warning {$, = "|"} - $OFS.should_not be_nil + $OFS.should_not == nil $OFS.should == $, suppress_warning {$, = original} end @@ -50,25 +50,25 @@ it "aliases $OUTPUT_FIELD_SEPARATOR to $," do original = $, suppress_warning {$, = "|"} - $OUTPUT_FIELD_SEPARATOR.should_not be_nil + $OUTPUT_FIELD_SEPARATOR.should_not == nil $OUTPUT_FIELD_SEPARATOR.should == $, suppress_warning {$, = original} end it "aliases $RS to $/" do - $RS.should_not be_nil + $RS.should_not == nil $RS.should == $/ end it "aliases $INPUT_RECORD_SEPARATOR to $/" do - $INPUT_RECORD_SEPARATOR.should_not be_nil + $INPUT_RECORD_SEPARATOR.should_not == nil $INPUT_RECORD_SEPARATOR.should == $/ end it "aliases $ORS to $\\" do original = $\ suppress_warning {$\ = "\t"} - $ORS.should_not be_nil + $ORS.should_not == nil $ORS.should == $\ suppress_warning {$\ = original} end @@ -76,86 +76,86 @@ it "aliases $OUTPUT_RECORD_SEPARATOR to $\\" do original = $\ suppress_warning {$\ = "\t"} - $OUTPUT_RECORD_SEPARATOR.should_not be_nil + $OUTPUT_RECORD_SEPARATOR.should_not == nil $OUTPUT_RECORD_SEPARATOR.should == $\ suppress_warning {$\ = original} end it "aliases $INPUT_LINE_NUMBER to $." do - $INPUT_LINE_NUMBER.should_not be_nil + $INPUT_LINE_NUMBER.should_not == nil $INPUT_LINE_NUMBER.should == $. end it "aliases $NR to $." do - $NR.should_not be_nil + $NR.should_not == nil $NR.should == $. end it "aliases $LAST_READ_LINE to $_ needs to be reviewed for spec completeness" it "aliases $DEFAULT_OUTPUT to $>" do - $DEFAULT_OUTPUT.should_not be_nil + $DEFAULT_OUTPUT.should_not == nil $DEFAULT_OUTPUT.should == $> end it "aliases $DEFAULT_INPUT to $<" do - $DEFAULT_INPUT.should_not be_nil + $DEFAULT_INPUT.should_not == nil $DEFAULT_INPUT.should == $< end it "aliases $PID to $$" do - $PID.should_not be_nil + $PID.should_not == nil $PID.should == $$ end it "aliases $PID to $$" do - $PID.should_not be_nil + $PID.should_not == nil $PID.should == $$ end it "aliases $PROCESS_ID to $$" do - $PROCESS_ID.should_not be_nil + $PROCESS_ID.should_not == nil $PROCESS_ID.should == $$ end it "aliases $CHILD_STATUS to $?" do ruby_exe('exit 0') - $CHILD_STATUS.should_not be_nil + $CHILD_STATUS.should_not == nil $CHILD_STATUS.should == $? end it "aliases $LAST_MATCH_INFO to $~" do /c(a)t/ =~ "cat" - $LAST_MATCH_INFO.should_not be_nil + $LAST_MATCH_INFO.should_not == nil $LAST_MATCH_INFO.should == $~ end it "aliases $ARGV to $*" do - $ARGV.should_not be_nil + $ARGV.should_not == nil $ARGV.should == $* end it "aliases $MATCH to $&" do /c(a)t/ =~ "cat" - $MATCH.should_not be_nil + $MATCH.should_not == nil $MATCH.should == $& end it "aliases $PREMATCH to $`" do /c(a)t/ =~ "cat" - $PREMATCH.should_not be_nil + $PREMATCH.should_not == nil $PREMATCH.should == $` end it "aliases $POSTMATCH to $'" do /c(a)t/ =~ "cat" - $POSTMATCH.should_not be_nil + $POSTMATCH.should_not == nil $POSTMATCH.should == $' end it "aliases $LAST_PAREN_MATCH to $+" do /c(a)t/ =~ "cat" - $LAST_PAREN_MATCH.should_not be_nil + $LAST_PAREN_MATCH.should_not == nil $LAST_PAREN_MATCH.should == $+ end end diff --git a/spec/ruby/library/English/alias_spec.rb b/spec/ruby/library/English/alias_spec.rb index 78ccfb4398983b..3ff92f964d98ba 100644 --- a/spec/ruby/library/English/alias_spec.rb +++ b/spec/ruby/library/English/alias_spec.rb @@ -4,11 +4,11 @@ describe "English" do it "aliases $! to $ERROR_INFO and $ERROR_INFO still returns an Exception with a backtrace" do exception = (1 / 0 rescue $ERROR_INFO) - exception.should be_kind_of(Exception) - exception.backtrace.should be_kind_of(Array) + exception.should.is_a?(Exception) + exception.backtrace.should.is_a?(Array) end it "aliases $@ to $ERROR_POSITION and $ERROR_POSITION still returns a backtrace" do - (1 / 0 rescue $ERROR_POSITION).should be_kind_of(Array) + (1 / 0 rescue $ERROR_POSITION).should.is_a?(Array) end end diff --git a/spec/ruby/library/base64/strict_decode64_spec.rb b/spec/ruby/library/base64/strict_decode64_spec.rb index d258223c827277..7b52f0c92224d3 100644 --- a/spec/ruby/library/base64/strict_decode64_spec.rb +++ b/spec/ruby/library/base64/strict_decode64_spec.rb @@ -14,25 +14,25 @@ it "raises ArgumentError when the given string contains CR" do -> do Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\r") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises ArgumentError when the given string contains LF" do -> do Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises ArgumentError when the given string has wrong padding" do -> do Base64.strict_decode64("=U2VuZCByZWluZm9yY2VtZW50cw==") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises ArgumentError when the given string contains an invalid character" do -> do Base64.strict_decode64("%3D") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "returns a binary encoded string" do diff --git a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb index 8596356abdb444..6adebabe842e13 100644 --- a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb +++ b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb @@ -10,7 +10,7 @@ describe "Kernel#BigDecimal" do it "creates a new object of class BigDecimal" do - BigDecimal("3.14159").should be_kind_of(BigDecimal) + BigDecimal("3.14159").should.is_a?(BigDecimal) (0..9).each {|i| BigDecimal("1#{i}").should == 10 + i BigDecimal("-1#{i}").should == -10 - i @@ -53,15 +53,15 @@ 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) + -> { BigDecimal("123E45ruby") }.should.raise(ArgumentError) + -> { BigDecimal("123x45") }.should.raise(ArgumentError) + -> { BigDecimal("123.4%E5") }.should.raise(ArgumentError) + -> { BigDecimal("1E2E3E4E5E") }.should.raise(ArgumentError) end it "raises ArgumentError for invalid strings" do - -> { BigDecimal("ruby") }.should raise_error(ArgumentError) - -> { BigDecimal(" \t\n \r-\t\t\tInfinity \n") }.should raise_error(ArgumentError) + -> { BigDecimal("ruby") }.should.raise(ArgumentError) + -> { BigDecimal(" \t\n \r-\t\t\tInfinity \n") }.should.raise(ArgumentError) end it "allows omitting the integer part" do @@ -72,8 +72,8 @@ 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) + -> { BigDecimal("1_2_3_4_5_._6____7_E89") }.should.raise(ArgumentError) + -> { BigDecimal("12345_.67E_8__9_") }.should.raise(ArgumentError) end it "accepts NaN and [+-]Infinity" do @@ -91,13 +91,13 @@ 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("invalid", exception: false).should == nil + BigDecimal("0invalid", exception: false).should == nil + BigDecimal("invalid0", exception: false).should == nil if BigDecimal::VERSION >= "3.1.9" BigDecimal("0.", exception: false).to_i.should == 0 else - BigDecimal("0.", exception: false).should be_nil + BigDecimal("0.", exception: false).should == nil end end end diff --git a/spec/ruby/library/bigdecimal/add_spec.rb b/spec/ruby/library/bigdecimal/add_spec.rb index 9cdab7d910844d..a4237298f40e16 100644 --- a/spec/ruby/library/bigdecimal/add_spec.rb +++ b/spec/ruby/library/bigdecimal/add_spec.rb @@ -165,21 +165,21 @@ it "raises TypeError when adds nil" do -> { @one.add(nil, 10) - }.should raise_error(TypeError) + }.should.raise(TypeError) -> { @one.add(nil, 0) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises TypeError when precision parameter is nil" do -> { @one.add(@one, nil) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises ArgumentError when precision parameter is negative" do -> { @one.add(@one, -10) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/bigdecimal/ceil_spec.rb b/spec/ruby/library/bigdecimal/ceil_spec.rb index 60e71b12fb1528..3d94b8e578dba3 100644 --- a/spec/ruby/library/bigdecimal/ceil_spec.rb +++ b/spec/ruby/library/bigdecimal/ceil_spec.rb @@ -48,9 +48,9 @@ end it "raise exception, if self is special value" do - -> { @infinity.ceil }.should raise_error(FloatDomainError) - -> { @infinity_neg.ceil }.should raise_error(FloatDomainError) - -> { @nan.ceil }.should raise_error(FloatDomainError) + -> { @infinity.ceil }.should.raise(FloatDomainError) + -> { @infinity_neg.ceil }.should.raise(FloatDomainError) + -> { @nan.ceil }.should.raise(FloatDomainError) end it "returns n digits right of the decimal point if given n > 0" do diff --git a/spec/ruby/library/bigdecimal/constants_spec.rb b/spec/ruby/library/bigdecimal/constants_spec.rb index 8d879c036acc00..f2cc42dfc9e82f 100644 --- a/spec/ruby/library/bigdecimal/constants_spec.rb +++ b/spec/ruby/library/bigdecimal/constants_spec.rb @@ -3,17 +3,17 @@ describe "BigDecimal constants" do it "defines a VERSION value" do - BigDecimal.const_defined?(:VERSION).should be_true + BigDecimal.const_defined?(:VERSION).should == true end it "has a BASE value" do # The actual one is decided based on HAVE_INT64_T in MRI, # which is hard to check here. - [10000, 1000000000].should include(BigDecimal::BASE) + [10000, 1000000000].should.include?(BigDecimal::BASE) end it "has a NaN value" do - BigDecimal::NAN.nan?.should be_true + BigDecimal::NAN.nan?.should == true end it "has an INFINITY value" do diff --git a/spec/ruby/library/bigdecimal/core_spec.rb b/spec/ruby/library/bigdecimal/core_spec.rb index 5097d708656b73..8f64fdf388db0d 100644 --- a/spec/ruby/library/bigdecimal/core_spec.rb +++ b/spec/ruby/library/bigdecimal/core_spec.rb @@ -25,7 +25,7 @@ # log(BigDecimal(r, 1000), 50) result2 = BigDecimal('0.22314354220170971436137296411949880462556361100853e0') r = Rational(1_234_567_890, 987_654_321) - [result1, result2].should include(BigMath.log(r, 50).mult(1, 50)) + [result1, result2].should.include?(BigMath.log(r, 50).mult(1, 50)) end end @@ -33,15 +33,15 @@ 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 + result.first.is_a?(Float).should == true + result.last.is_a?(Float).should == 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 + result.first.is_a?(Rational).should == true + result.last.is_a?(Rational).should == true end it "coerces to Rational, when given a Complex" do @@ -56,7 +56,7 @@ 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/) + }.should.raise(TypeError, /BigDecimal can't be coerced into Rational/) end end end diff --git a/spec/ruby/library/bigdecimal/div_spec.rb b/spec/ruby/library/bigdecimal/div_spec.rb index 53ad6d04184d87..967d8b5221e2d9 100644 --- a/spec/ruby/library/bigdecimal/div_spec.rb +++ b/spec/ruby/library/bigdecimal/div_spec.rb @@ -51,9 +51,9 @@ end it "raises FloatDomainError if NaN is involved" do - -> { @one.div(@nan) }.should raise_error(FloatDomainError) - -> { @nan.div(@one) }.should raise_error(FloatDomainError) - -> { @nan.div(@nan) }.should raise_error(FloatDomainError) + -> { @one.div(@nan) }.should.raise(FloatDomainError) + -> { @nan.div(@one) }.should.raise(FloatDomainError) + -> { @nan.div(@nan) }.should.raise(FloatDomainError) end it "returns 0 if divided by Infinity and no precision given" do @@ -69,14 +69,14 @@ end it "raises ZeroDivisionError if divided by zero and no precision given" do - -> { @one.div(@zero) }.should raise_error(ZeroDivisionError) - -> { @one.div(@zero_plus) }.should raise_error(ZeroDivisionError) - -> { @one.div(@zero_minus) }.should raise_error(ZeroDivisionError) - - -> { @zero.div(@zero) }.should raise_error(ZeroDivisionError) - -> { @zero_minus.div(@zero_plus) }.should raise_error(ZeroDivisionError) - -> { @zero_minus.div(@zero_minus) }.should raise_error(ZeroDivisionError) - -> { @zero_plus.div(@zero_minus) }.should raise_error(ZeroDivisionError) + -> { @one.div(@zero) }.should.raise(ZeroDivisionError) + -> { @one.div(@zero_plus) }.should.raise(ZeroDivisionError) + -> { @one.div(@zero_minus) }.should.raise(ZeroDivisionError) + + -> { @zero.div(@zero) }.should.raise(ZeroDivisionError) + -> { @zero_minus.div(@zero_plus) }.should.raise(ZeroDivisionError) + -> { @zero_minus.div(@zero_minus) }.should.raise(ZeroDivisionError) + -> { @zero_plus.div(@zero_minus) }.should.raise(ZeroDivisionError) end it "returns NaN if zero is divided by zero" do @@ -90,9 +90,9 @@ end it "raises FloatDomainError if (+|-) Infinity divided by 1 and no precision given" do - -> { @infinity_minus.div(@one) }.should raise_error(FloatDomainError) - -> { @infinity.div(@one) }.should raise_error(FloatDomainError) - -> { @infinity_minus.div(@one_minus) }.should raise_error(FloatDomainError) + -> { @infinity_minus.div(@one) }.should.raise(FloatDomainError) + -> { @infinity.div(@one) }.should.raise(FloatDomainError) + -> { @infinity_minus.div(@one_minus) }.should.raise(FloatDomainError) end it "returns (+|-)Infinity if (+|-)Infinity by 1 and precision given" do diff --git a/spec/ruby/library/bigdecimal/divmod_spec.rb b/spec/ruby/library/bigdecimal/divmod_spec.rb index 85c014bb8c0c37..d170c6f8456589 100644 --- a/spec/ruby/library/bigdecimal/divmod_spec.rb +++ b/spec/ruby/library/bigdecimal/divmod_spec.rb @@ -40,9 +40,9 @@ class BigDecimal it "raises ZeroDivisionError if other is zero" do bd5667 = BigDecimal("5667.19") zero = BigDecimal("0") - -> { bd5667.mod_part_of_divmod(0) }.should raise_error(ZeroDivisionError) - -> { bd5667.mod_part_of_divmod(BigDecimal("0")) }.should raise_error(ZeroDivisionError) - -> { zero.mod_part_of_divmod(zero) }.should raise_error(ZeroDivisionError) + -> { bd5667.mod_part_of_divmod(0) }.should.raise(ZeroDivisionError) + -> { bd5667.mod_part_of_divmod(BigDecimal("0")) }.should.raise(ZeroDivisionError) + -> { zero.mod_part_of_divmod(zero) }.should.raise(ZeroDivisionError) end end @@ -145,8 +145,8 @@ class BigDecimal version_is BigDecimal::VERSION, "4.0.0" do it "raise FloatDomainError error if NaN is involved" do (@special_vals + @regular_vals + @zeroes).each do |val| - -> { val.divmod(@nan) }.should raise_error(FloatDomainError) - -> { @nan.divmod(val) }.should raise_error(FloatDomainError) + -> { val.divmod(@nan) }.should.raise(FloatDomainError) + -> { @nan.divmod(val) }.should.raise(FloatDomainError) end end end @@ -163,7 +163,7 @@ class BigDecimal it "raises ZeroDivisionError if the divisor is zero" do (@special_vals + @regular_vals + @zeroes - [@nan]).each do |val| @zeroes.each do |zero| - -> { val.divmod(zero) }.should raise_error(ZeroDivisionError) + -> { val.divmod(zero) }.should.raise(ZeroDivisionError) end end end @@ -206,7 +206,7 @@ class BigDecimal it "raises TypeError if the argument cannot be coerced to BigDecimal" do -> { @one.divmod('1') - }.should raise_error(TypeError) + }.should.raise(TypeError) end end diff --git a/spec/ruby/library/bigdecimal/fix_spec.rb b/spec/ruby/library/bigdecimal/fix_spec.rb index 2c6276899ed98c..dceb2ce86777cd 100644 --- a/spec/ruby/library/bigdecimal/fix_spec.rb +++ b/spec/ruby/library/bigdecimal/fix_spec.rb @@ -51,7 +51,7 @@ it "does not allow any arguments" do -> { @mixed.fix(10) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/bigdecimal/floor_spec.rb b/spec/ruby/library/bigdecimal/floor_spec.rb index a7dfec2c9a1fcb..c0666c668c11ab 100644 --- a/spec/ruby/library/bigdecimal/floor_spec.rb +++ b/spec/ruby/library/bigdecimal/floor_spec.rb @@ -41,9 +41,9 @@ end it "raise exception, if self is special value" do - -> { @infinity.floor }.should raise_error(FloatDomainError) - -> { @infinity_neg.floor }.should raise_error(FloatDomainError) - -> { @nan.floor }.should raise_error(FloatDomainError) + -> { @infinity.floor }.should.raise(FloatDomainError) + -> { @infinity_neg.floor }.should.raise(FloatDomainError) + -> { @nan.floor }.should.raise(FloatDomainError) end it "returns n digits right of the decimal point if given n > 0" do diff --git a/spec/ruby/library/bigdecimal/gt_spec.rb b/spec/ruby/library/bigdecimal/gt_spec.rb index 78547fb85f152f..e9c9a60e756226 100644 --- a/spec/ruby/library/bigdecimal/gt_spec.rb +++ b/spec/ruby/library/bigdecimal/gt_spec.rb @@ -86,11 +86,11 @@ def >(other) end it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do - -> {@zero > nil }.should raise_error(ArgumentError) - -> {@infinity > nil }.should raise_error(ArgumentError) - -> {@infinity_neg > nil }.should raise_error(ArgumentError) - -> {@mixed > nil }.should raise_error(ArgumentError) - -> {@pos_int > nil }.should raise_error(ArgumentError) - -> {@neg_frac > nil }.should raise_error(ArgumentError) + -> {@zero > nil }.should.raise(ArgumentError) + -> {@infinity > nil }.should.raise(ArgumentError) + -> {@infinity_neg > nil }.should.raise(ArgumentError) + -> {@mixed > nil }.should.raise(ArgumentError) + -> {@pos_int > nil }.should.raise(ArgumentError) + -> {@neg_frac > nil }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/bigdecimal/gte_spec.rb b/spec/ruby/library/bigdecimal/gte_spec.rb index 2a5cc025ba3821..548f3efe4c15dc 100644 --- a/spec/ruby/library/bigdecimal/gte_spec.rb +++ b/spec/ruby/library/bigdecimal/gte_spec.rb @@ -90,11 +90,11 @@ def >=(other) end it "returns nil if the argument is nil" do - -> {@zero >= nil }.should raise_error(ArgumentError) - -> {@infinity >= nil }.should raise_error(ArgumentError) - -> {@infinity_neg >= nil }.should raise_error(ArgumentError) - -> {@mixed >= nil }.should raise_error(ArgumentError) - -> {@pos_int >= nil }.should raise_error(ArgumentError) - -> {@neg_frac >= nil }.should raise_error(ArgumentError) + -> {@zero >= nil }.should.raise(ArgumentError) + -> {@infinity >= nil }.should.raise(ArgumentError) + -> {@infinity_neg >= nil }.should.raise(ArgumentError) + -> {@mixed >= nil }.should.raise(ArgumentError) + -> {@pos_int >= nil }.should.raise(ArgumentError) + -> {@neg_frac >= nil }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/bigdecimal/lt_spec.rb b/spec/ruby/library/bigdecimal/lt_spec.rb index 02390e76e33b61..c3f3573247858a 100644 --- a/spec/ruby/library/bigdecimal/lt_spec.rb +++ b/spec/ruby/library/bigdecimal/lt_spec.rb @@ -84,11 +84,11 @@ def <(other) end it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do - -> {@zero < nil }.should raise_error(ArgumentError) - -> {@infinity < nil }.should raise_error(ArgumentError) - -> {@infinity_neg < nil }.should raise_error(ArgumentError) - -> {@mixed < nil }.should raise_error(ArgumentError) - -> {@pos_int < nil }.should raise_error(ArgumentError) - -> {@neg_frac < nil }.should raise_error(ArgumentError) + -> {@zero < nil }.should.raise(ArgumentError) + -> {@infinity < nil }.should.raise(ArgumentError) + -> {@infinity_neg < nil }.should.raise(ArgumentError) + -> {@mixed < nil }.should.raise(ArgumentError) + -> {@pos_int < nil }.should.raise(ArgumentError) + -> {@neg_frac < nil }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/bigdecimal/lte_spec.rb b/spec/ruby/library/bigdecimal/lte_spec.rb index b92be04123f106..7918bde88b608e 100644 --- a/spec/ruby/library/bigdecimal/lte_spec.rb +++ b/spec/ruby/library/bigdecimal/lte_spec.rb @@ -90,11 +90,11 @@ def <=(other) end it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do - -> {@zero <= nil }.should raise_error(ArgumentError) - -> {@infinity <= nil }.should raise_error(ArgumentError) - -> {@infinity_neg <= nil }.should raise_error(ArgumentError) - -> {@mixed <= nil }.should raise_error(ArgumentError) - -> {@pos_int <= nil }.should raise_error(ArgumentError) - -> {@neg_frac <= nil }.should raise_error(ArgumentError) + -> {@zero <= nil }.should.raise(ArgumentError) + -> {@infinity <= nil }.should.raise(ArgumentError) + -> {@infinity_neg <= nil }.should.raise(ArgumentError) + -> {@mixed <= nil }.should.raise(ArgumentError) + -> {@pos_int <= nil }.should.raise(ArgumentError) + -> {@neg_frac <= nil }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/bigdecimal/mode_spec.rb b/spec/ruby/library/bigdecimal/mode_spec.rb index 73fa1a118eaf41..26e6d0ea752018 100644 --- a/spec/ruby/library/bigdecimal/mode_spec.rb +++ b/spec/ruby/library/bigdecimal/mode_spec.rb @@ -24,13 +24,13 @@ it "raise an exception if the flag is true" do BigDecimal.mode(BigDecimal::EXCEPTION_NaN, true) - -> { BigDecimal("NaN").add(BigDecimal("1"),0) }.should raise_error(FloatDomainError) + -> { BigDecimal("NaN").add(BigDecimal("1"),0) }.should.raise(FloatDomainError) BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, true) - -> { BigDecimal("0").add(BigDecimal("Infinity"),0) }.should raise_error(FloatDomainError) + -> { BigDecimal("0").add(BigDecimal("Infinity"),0) }.should.raise(FloatDomainError) BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, true) - -> { BigDecimal("1").quo(BigDecimal("0")) }.should raise_error(FloatDomainError) + -> { BigDecimal("1").quo(BigDecimal("0")) }.should.raise(FloatDomainError) BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true) - -> { BigDecimal("1E11111111111111111111") }.should raise_error(FloatDomainError) - -> { (BigDecimal("1E1000000000000000000")**10) }.should raise_error(FloatDomainError) + -> { BigDecimal("1E11111111111111111111") }.should.raise(FloatDomainError) + -> { (BigDecimal("1E1000000000000000000")**10) }.should.raise(FloatDomainError) end end diff --git a/spec/ruby/library/bigdecimal/nonzero_spec.rb b/spec/ruby/library/bigdecimal/nonzero_spec.rb index f43c4393cd3045..31421ebdf43639 100644 --- a/spec/ruby/library/bigdecimal/nonzero_spec.rb +++ b/spec/ruby/library/bigdecimal/nonzero_spec.rb @@ -10,11 +10,11 @@ infinity = BigDecimal("Infinity") infinity_minus = BigDecimal("-Infinity") nan = BigDecimal("NaN") - infinity.nonzero?.should equal(infinity) - infinity_minus.nonzero?.should equal(infinity_minus) - nan.nonzero?.should equal(nan) - e3_minus.nonzero?.should equal(e3_minus) - e2_plus.nonzero?.should equal(e2_plus) + infinity.nonzero?.should.equal?(infinity) + infinity_minus.nonzero?.should.equal?(infinity_minus) + nan.nonzero?.should.equal?(nan) + e3_minus.nonzero?.should.equal?(e3_minus) + e2_plus.nonzero?.should.equal?(e2_plus) end it "returns nil otherwise" do diff --git a/spec/ruby/library/bigdecimal/remainder_spec.rb b/spec/ruby/library/bigdecimal/remainder_spec.rb index b31967e76bd53c..27a2986570ef56 100644 --- a/spec/ruby/library/bigdecimal/remainder_spec.rb +++ b/spec/ruby/library/bigdecimal/remainder_spec.rb @@ -39,8 +39,8 @@ version_is BigDecimal::VERSION, "3.3.0" do it "raises ZeroDivisionError used with zero" do - -> { @mixed.remainder(@zero) }.should raise_error(ZeroDivisionError) - -> { @zero.remainder(@zero) }.should raise_error(ZeroDivisionError) + -> { @mixed.remainder(@zero) }.should.raise(ZeroDivisionError) + -> { @zero.remainder(@zero) }.should.raise(ZeroDivisionError) end end @@ -71,7 +71,7 @@ it "raises TypeError if the argument cannot be coerced to BigDecimal" do -> { @one.remainder('2') - }.should raise_error(TypeError) + }.should.raise(TypeError) end end diff --git a/spec/ruby/library/bigdecimal/round_spec.rb b/spec/ruby/library/bigdecimal/round_spec.rb index 6a4d220417c135..622e129d932e26 100644 --- a/spec/ruby/library/bigdecimal/round_spec.rb +++ b/spec/ruby/library/bigdecimal/round_spec.rb @@ -217,18 +217,18 @@ end it 'raise exception, if self is special value' do - -> { BigDecimal('NaN').round }.should raise_error(FloatDomainError) - -> { BigDecimal('Infinity').round }.should raise_error(FloatDomainError) - -> { BigDecimal('-Infinity').round }.should raise_error(FloatDomainError) + -> { BigDecimal('NaN').round }.should.raise(FloatDomainError) + -> { BigDecimal('Infinity').round }.should.raise(FloatDomainError) + -> { BigDecimal('-Infinity').round }.should.raise(FloatDomainError) end it 'do not raise exception, if self is special value and precision is given' do - -> { BigDecimal('NaN').round(2) }.should_not raise_error(FloatDomainError) - -> { BigDecimal('Infinity').round(2) }.should_not raise_error(FloatDomainError) - -> { BigDecimal('-Infinity').round(2) }.should_not raise_error(FloatDomainError) + -> { BigDecimal('NaN').round(2) }.should_not.raise(FloatDomainError) + -> { BigDecimal('Infinity').round(2) }.should_not.raise(FloatDomainError) + -> { BigDecimal('-Infinity').round(2) }.should_not.raise(FloatDomainError) end it 'raise for a non-existent round mode' do - -> { @p1_50.round(0, :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode (nonsense)") + -> { @p1_50.round(0, :nonsense) }.should.raise(ArgumentError, "invalid rounding mode (nonsense)") end end diff --git a/spec/ruby/library/bigdecimal/shared/clone.rb b/spec/ruby/library/bigdecimal/shared/clone.rb index 935ef76e7e3f8f..03de6d0fc3afb2 100644 --- a/spec/ruby/library/bigdecimal/shared/clone.rb +++ b/spec/ruby/library/bigdecimal/shared/clone.rb @@ -8,6 +8,6 @@ it "returns self" do copy = @obj.public_send(@method) - copy.should equal(@obj) + copy.should.equal?(@obj) end end diff --git a/spec/ruby/library/bigdecimal/shared/modulo.rb b/spec/ruby/library/bigdecimal/shared/modulo.rb index eeb030fd23c05c..63470d0977e52b 100644 --- a/spec/ruby/library/bigdecimal/shared/modulo.rb +++ b/spec/ruby/library/bigdecimal/shared/modulo.rb @@ -116,7 +116,7 @@ it "raises TypeError if the argument cannot be coerced to BigDecimal" do -> { @one.send(@method, '2') - }.should raise_error(TypeError) + }.should.raise(TypeError) end end @@ -124,8 +124,8 @@ it "raises ZeroDivisionError if other is zero" do bd5667 = BigDecimal("5667.19") - -> { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError) - -> { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError) - -> { @zero.send(@method, @zero) }.should raise_error(ZeroDivisionError) + -> { bd5667.send(@method, 0) }.should.raise(ZeroDivisionError) + -> { bd5667.send(@method, BigDecimal("0")) }.should.raise(ZeroDivisionError) + -> { @zero.send(@method, @zero) }.should.raise(ZeroDivisionError) end end diff --git a/spec/ruby/library/bigdecimal/shared/to_int.rb b/spec/ruby/library/bigdecimal/shared/to_int.rb index 44b6a3c7b28f93..3c9f3b4f97ae31 100644 --- a/spec/ruby/library/bigdecimal/shared/to_int.rb +++ b/spec/ruby/library/bigdecimal/shared/to_int.rb @@ -2,8 +2,8 @@ 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) + -> { BigDecimal("Infinity").send(@method) }.should.raise(FloatDomainError) + -> { BigDecimal("NaN").send(@method) }.should.raise(FloatDomainError) end it "returns Integer otherwise" do diff --git a/spec/ruby/library/bigdecimal/sqrt_spec.rb b/spec/ruby/library/bigdecimal/sqrt_spec.rb index 42cf4545cb3e26..1f3ef9a8c35148 100644 --- a/spec/ruby/library/bigdecimal/sqrt_spec.rb +++ b/spec/ruby/library/bigdecimal/sqrt_spec.rb @@ -45,37 +45,37 @@ it "raises ArgumentError when no argument is given" do -> { @one.sqrt - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises ArgumentError if a negative number is given" do -> { @one.sqrt(-1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises ArgumentError if 2 arguments are given" do -> { @one.sqrt(1, 1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises TypeError if nil is given" do -> { @one.sqrt(nil) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises TypeError if a string is given" do -> { @one.sqrt("stuff") - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises TypeError if a plain Object is given" do -> { @one.sqrt(Object.new) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "returns 1 if precision is 0 or 1" do @@ -86,7 +86,7 @@ it "raises FloatDomainError on negative values" do -> { BigDecimal('-1').sqrt(10) - }.should raise_error(FloatDomainError) + }.should.raise(FloatDomainError) end it "returns positive infinity for infinity" do @@ -96,13 +96,13 @@ it "raises FloatDomainError for negative infinity" do -> { @infinity_minus.sqrt(1) - }.should raise_error(FloatDomainError) + }.should.raise(FloatDomainError) end it "raises FloatDomainError for NaN" do -> { @nan.sqrt(1) - }.should raise_error(FloatDomainError) + }.should.raise(FloatDomainError) end it "returns 0 for 0, +0.0 and -0.0" do diff --git a/spec/ruby/library/bigdecimal/to_f_spec.rb b/spec/ruby/library/bigdecimal/to_f_spec.rb index 84d4d49de23c15..f5220d995a99b0 100644 --- a/spec/ruby/library/bigdecimal/to_f_spec.rb +++ b/spec/ruby/library/bigdecimal/to_f_spec.rb @@ -20,9 +20,9 @@ end it "returns number of type float" do - BigDecimal("3.14159").to_f.should be_kind_of(Float) - @vals.each { |val| val.to_f.should be_kind_of(Float) } - @spec_vals.each { |val| val.to_f.should be_kind_of(Float) } + BigDecimal("3.14159").to_f.should.is_a?(Float) + @vals.each { |val| val.to_f.should.is_a?(Float) } + @spec_vals.each { |val| val.to_f.should.is_a?(Float) } end it "rounds correctly to Float precision" do diff --git a/spec/ruby/library/bigdecimal/to_r_spec.rb b/spec/ruby/library/bigdecimal/to_r_spec.rb index c350beff08c765..a112c002ef8bbd 100644 --- a/spec/ruby/library/bigdecimal/to_r_spec.rb +++ b/spec/ruby/library/bigdecimal/to_r_spec.rb @@ -4,25 +4,25 @@ describe "BigDecimal#to_r" do it "returns a Rational" do - BigDecimal("3.14159").to_r.should be_kind_of(Rational) + BigDecimal("3.14159").to_r.should.is_a?(Rational) end it "returns a Rational with bignum values" do r = BigDecimal("3.141592653589793238462643").to_r - r.numerator.should eql(3141592653589793238462643) - r.denominator.should eql(1000000000000000000000000) + r.numerator.should.eql?(3141592653589793238462643) + 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) + 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) + 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 025057b4d7e873..5ec54765b5b443 100644 --- a/spec/ruby/library/bigdecimal/to_s_spec.rb +++ b/spec/ruby/library/bigdecimal/to_s_spec.rb @@ -31,7 +31,7 @@ end it "takes an optional argument" do - -> {@bigdec.to_s("F")}.should_not raise_error() + -> {@bigdec.to_s("F")}.should_not.raise() end it "starts with + if + is supplied and value is positive" do @@ -88,11 +88,11 @@ 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) + 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) + BigDecimal('1.23').to_s.encoding.should.equal?(Encoding::US_ASCII) end end diff --git a/spec/ruby/library/bigdecimal/truncate_spec.rb b/spec/ruby/library/bigdecimal/truncate_spec.rb index 0ae0421b30fbda..cedc662aebcaa8 100644 --- a/spec/ruby/library/bigdecimal/truncate_spec.rb +++ b/spec/ruby/library/bigdecimal/truncate_spec.rb @@ -74,8 +74,8 @@ end it "returns the same value if self is special value" do - -> { @nan.truncate }.should raise_error(FloatDomainError) - -> { @infinity.truncate }.should raise_error(FloatDomainError) - -> { @infinity_negative.truncate }.should raise_error(FloatDomainError) + -> { @nan.truncate }.should.raise(FloatDomainError) + -> { @infinity.truncate }.should.raise(FloatDomainError) + -> { @infinity_negative.truncate }.should.raise(FloatDomainError) end end diff --git a/spec/ruby/library/bigdecimal/util_spec.rb b/spec/ruby/library/bigdecimal/util_spec.rb index fc67fcf200bebd..69663d4bd2a6a4 100644 --- a/spec/ruby/library/bigdecimal/util_spec.rb +++ b/spec/ruby/library/bigdecimal/util_spec.rb @@ -20,7 +20,7 @@ it "should define #to_d on BigDecimal" do bd = BigDecimal("3.14") - bd.to_d.should equal(bd) + bd.to_d.should.equal?(bd) end it "should define #to_d on Rational" do diff --git a/spec/ruby/library/cgi/cookie/domain_spec.rb b/spec/ruby/library/cgi/cookie/domain_spec.rb index 0ed56d6d614841..c118ef6383b83f 100644 --- a/spec/ruby/library/cgi/cookie/domain_spec.rb +++ b/spec/ruby/library/cgi/cookie/domain_spec.rb @@ -6,7 +6,7 @@ describe "CGI::Cookie#domain" do it "returns self's domain" do cookie = CGI::Cookie.new("test-cookie") - cookie.domain.should be_nil + cookie.domain.should == nil cookie = CGI::Cookie.new("name" => "test-cookie", "domain" => "example.com") cookie.domain.should == "example.com" diff --git a/spec/ruby/library/cgi/cookie/expires_spec.rb b/spec/ruby/library/cgi/cookie/expires_spec.rb index c5b2c4faf95555..b9cc7d5b654241 100644 --- a/spec/ruby/library/cgi/cookie/expires_spec.rb +++ b/spec/ruby/library/cgi/cookie/expires_spec.rb @@ -6,7 +6,7 @@ describe "CGI::Cookie#expires" do it "returns self's expiration date" do cookie = CGI::Cookie.new("test-cookie") - cookie.expires.should be_nil + cookie.expires.should == nil cookie = CGI::Cookie.new("name" => "test-cookie", "expires" => Time.at(1196524602)) cookie.expires.should == Time.at(1196524602) diff --git a/spec/ruby/library/cgi/cookie/initialize_spec.rb b/spec/ruby/library/cgi/cookie/initialize_spec.rb index 248f35e78b58a0..80bc2c219645f8 100644 --- a/spec/ruby/library/cgi/cookie/initialize_spec.rb +++ b/spec/ruby/library/cgi/cookie/initialize_spec.rb @@ -20,7 +20,7 @@ it "sets self to a non-secure cookie" do @cookie.send(:initialize, "test") - @cookie.secure.should be_false + @cookie.secure.should == false end it "does set self's path to an empty String when ENV[\"SCRIPT_NAME\"] is not set" do @@ -49,11 +49,11 @@ end it "does not set self's expiration date" do - @cookie.expires.should be_nil + @cookie.expires.should == nil end it "does not set self's domain" do - @cookie.domain.should be_nil + @cookie.domain.should == nil end end @@ -76,7 +76,7 @@ @cookie.path.should == "some/path/" @cookie.domain.should == "example.com" @cookie.expires.should == Time.at(1196524602) - @cookie.secure.should be_true + @cookie.secure.should == true end it "does set self's path based on ENV[\"SCRIPT_NAME\"] when the Hash has no 'path' entry" do @@ -122,8 +122,8 @@ end it "raises a ArgumentError when the passed Hash has no 'name' entry" do - -> { @cookie.send(:initialize, {}) }.should raise_error(ArgumentError) - -> { @cookie.send(:initialize, "value" => "test") }.should raise_error(ArgumentError) + -> { @cookie.send(:initialize, {}) }.should.raise(ArgumentError) + -> { @cookie.send(:initialize, "value" => "test") }.should.raise(ArgumentError) end end @@ -144,7 +144,7 @@ it "sets self to a non-secure cookie" do @cookie.send(:initialize, "test", "one", "two", "three") - @cookie.secure.should be_false + @cookie.secure.should == false end end end diff --git a/spec/ruby/library/cgi/cookie/secure_spec.rb b/spec/ruby/library/cgi/cookie/secure_spec.rb index cb38c8c2e0c6e5..233881b173e6be 100644 --- a/spec/ruby/library/cgi/cookie/secure_spec.rb +++ b/spec/ruby/library/cgi/cookie/secure_spec.rb @@ -10,10 +10,10 @@ it "returns whether self is a secure cookie or not" do @cookie.secure = true - @cookie.secure.should be_true + @cookie.secure.should == true @cookie.secure = false - @cookie.secure.should be_false + @cookie.secure.should == false end end @@ -23,12 +23,12 @@ end it "returns true" do - (@cookie.secure = true).should be_true + (@cookie.secure = true).should == true end it "sets self to a secure cookie" do @cookie.secure = true - @cookie.secure.should be_true + @cookie.secure.should == true end end @@ -38,12 +38,12 @@ end it "returns false" do - (@cookie.secure = false).should be_false + (@cookie.secure = false).should == false end it "sets self to a non-secure cookie" do @cookie.secure = false - @cookie.secure.should be_false + @cookie.secure.should == false end end @@ -56,18 +56,18 @@ @cookie.secure = false @cookie.secure = Object.new - @cookie.secure.should be_false + @cookie.secure.should == false @cookie.secure = "Test" - @cookie.secure.should be_false + @cookie.secure.should == false @cookie.secure = true @cookie.secure = Object.new - @cookie.secure.should be_true + @cookie.secure.should == true @cookie.secure = "Test" - @cookie.secure.should be_true + @cookie.secure.should == true end end end diff --git a/spec/ruby/library/cgi/cookie/value_spec.rb b/spec/ruby/library/cgi/cookie/value_spec.rb index 672653d7f4125a..45032edcbf9044 100644 --- a/spec/ruby/library/cgi/cookie/value_spec.rb +++ b/spec/ruby/library/cgi/cookie/value_spec.rb @@ -37,7 +37,7 @@ cookie2.value.send(method, *args) fail << method unless cookie1.value == cookie2.value end - fail.should be_empty + fail.should.empty? end end diff --git a/spec/ruby/library/cgi/escapeURIComponent_spec.rb b/spec/ruby/library/cgi/escapeURIComponent_spec.rb index 1cea2b786a626b..98efa2e67e1f7e 100644 --- a/spec/ruby/library/cgi/escapeURIComponent_spec.rb +++ b/spec/ruby/library/cgi/escapeURIComponent_spec.rb @@ -64,7 +64,7 @@ it "raises a TypeError with nil" do -> { CGI.escapeURIComponent(nil) - }.should raise_error(TypeError, "no implicit conversion of nil into String") + }.should.raise(TypeError, "no implicit conversion of nil into String") end it "uses implicit type conversion to String" do diff --git a/spec/ruby/library/cgi/initialize_spec.rb b/spec/ruby/library/cgi/initialize_spec.rb index b8ecf5cac2bd88..6135522c54fa66 100644 --- a/spec/ruby/library/cgi/initialize_spec.rb +++ b/spec/ruby/library/cgi/initialize_spec.rb @@ -5,7 +5,7 @@ describe "CGI#initialize" do it "is private" do - CGI.should have_private_instance_method(:initialize) + CGI.private_instance_methods(false).should.include?(:initialize) end end @@ -21,21 +21,21 @@ it "extends self with CGI::QueryExtension" do @cgi.send(:initialize) - @cgi.should be_kind_of(CGI::QueryExtension) + @cgi.should.is_a?(CGI::QueryExtension) end it "does not extend self with CGI::HtmlExtension" do @cgi.send(:initialize) - @cgi.should_not be_kind_of(CGI::HtmlExtension) + @cgi.should_not.is_a?(CGI::HtmlExtension) end it "does not extend self with any of the other HTML modules" do @cgi.send(:initialize) - @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) + @cgi.should_not.is_a?(CGI::HtmlExtension) + @cgi.should_not.is_a?(CGI::Html3) + @cgi.should_not.is_a?(CGI::Html4) + @cgi.should_not.is_a?(CGI::Html4Tr) + @cgi.should_not.is_a?(CGI::Html4Fr) end it "sets #cookies based on ENV['HTTP_COOKIE']" do @@ -86,51 +86,51 @@ it "extends self with CGI::QueryExtension" do @cgi.send(:initialize, "test") - @cgi.should be_kind_of(CGI::QueryExtension) + @cgi.should.is_a?(CGI::QueryExtension) end it "extends self with CGI::QueryExtension, CGI::Html3 and CGI::HtmlExtension when the passed type is 'html3'" do @cgi.send(:initialize, "html3") - @cgi.should be_kind_of(CGI::Html3) - @cgi.should be_kind_of(CGI::HtmlExtension) - @cgi.should be_kind_of(CGI::QueryExtension) + @cgi.should.is_a?(CGI::Html3) + @cgi.should.is_a?(CGI::HtmlExtension) + @cgi.should.is_a?(CGI::QueryExtension) - @cgi.should_not be_kind_of(CGI::Html4) - @cgi.should_not be_kind_of(CGI::Html4Tr) - @cgi.should_not be_kind_of(CGI::Html4Fr) + @cgi.should_not.is_a?(CGI::Html4) + @cgi.should_not.is_a?(CGI::Html4Tr) + @cgi.should_not.is_a?(CGI::Html4Fr) end it "extends self with CGI::QueryExtension, CGI::Html4 and CGI::HtmlExtension when the passed type is 'html4'" do @cgi.send(:initialize, "html4") - @cgi.should be_kind_of(CGI::Html4) - @cgi.should be_kind_of(CGI::HtmlExtension) - @cgi.should be_kind_of(CGI::QueryExtension) + @cgi.should.is_a?(CGI::Html4) + @cgi.should.is_a?(CGI::HtmlExtension) + @cgi.should.is_a?(CGI::QueryExtension) - @cgi.should_not be_kind_of(CGI::Html3) - @cgi.should_not be_kind_of(CGI::Html4Tr) - @cgi.should_not be_kind_of(CGI::Html4Fr) + @cgi.should_not.is_a?(CGI::Html3) + @cgi.should_not.is_a?(CGI::Html4Tr) + @cgi.should_not.is_a?(CGI::Html4Fr) end it "extends self with CGI::QueryExtension, CGI::Html4Tr and CGI::HtmlExtension when the passed type is 'html4Tr'" do @cgi.send(:initialize, "html4Tr") - @cgi.should be_kind_of(CGI::Html4Tr) - @cgi.should be_kind_of(CGI::HtmlExtension) - @cgi.should be_kind_of(CGI::QueryExtension) + @cgi.should.is_a?(CGI::Html4Tr) + @cgi.should.is_a?(CGI::HtmlExtension) + @cgi.should.is_a?(CGI::QueryExtension) - @cgi.should_not be_kind_of(CGI::Html3) - @cgi.should_not be_kind_of(CGI::Html4) - @cgi.should_not be_kind_of(CGI::Html4Fr) + @cgi.should_not.is_a?(CGI::Html3) + @cgi.should_not.is_a?(CGI::Html4) + @cgi.should_not.is_a?(CGI::Html4Fr) end it "extends self with CGI::QueryExtension, CGI::Html4Tr, CGI::Html4Fr and CGI::HtmlExtension when the passed type is 'html4Fr'" do @cgi.send(:initialize, "html4Fr") - @cgi.should be_kind_of(CGI::Html4Tr) - @cgi.should be_kind_of(CGI::Html4Fr) - @cgi.should be_kind_of(CGI::HtmlExtension) - @cgi.should be_kind_of(CGI::QueryExtension) + @cgi.should.is_a?(CGI::Html4Tr) + @cgi.should.is_a?(CGI::Html4Fr) + @cgi.should.is_a?(CGI::HtmlExtension) + @cgi.should.is_a?(CGI::QueryExtension) - @cgi.should_not be_kind_of(CGI::Html3) - @cgi.should_not be_kind_of(CGI::Html4) + @cgi.should_not.is_a?(CGI::Html3) + @cgi.should_not.is_a?(CGI::Html4) end end end diff --git a/spec/ruby/library/cgi/out_spec.rb b/spec/ruby/library/cgi/out_spec.rb index 733e656ea1f877..e9eaf5e151100c 100644 --- a/spec/ruby/library/cgi/out_spec.rb +++ b/spec/ruby/library/cgi/out_spec.rb @@ -48,7 +48,7 @@ end it "raises a LocalJumpError" do - -> { @cgi.out }.should raise_error(LocalJumpError) + -> { @cgi.out }.should.raise(LocalJumpError) end end end diff --git a/spec/ruby/library/cgi/queryextension/content_length_spec.rb b/spec/ruby/library/cgi/queryextension/content_length_spec.rb index a8b87e148c9c87..bd02f3d8da394a 100644 --- a/spec/ruby/library/cgi/queryextension/content_length_spec.rb +++ b/spec/ruby/library/cgi/queryextension/content_length_spec.rb @@ -17,10 +17,10 @@ old_value = ENV['CONTENT_LENGTH'] begin ENV['CONTENT_LENGTH'] = nil - @cgi.content_length.should be_nil + @cgi.content_length.should == nil ENV['CONTENT_LENGTH'] = "100" - @cgi.content_length.should eql(100) + @cgi.content_length.should.eql?(100) ensure ENV['CONTENT_LENGTH'] = old_value end diff --git a/spec/ruby/library/cgi/queryextension/element_reference_spec.rb b/spec/ruby/library/cgi/queryextension/element_reference_spec.rb index 0b57387efc7bfe..c835f385f05383 100644 --- a/spec/ruby/library/cgi/queryextension/element_reference_spec.rb +++ b/spec/ruby/library/cgi/queryextension/element_reference_spec.rb @@ -24,7 +24,7 @@ end it "returns a String" do - @cgi["one"].should be_kind_of(String) + @cgi["one"].should.is_a?(String) end end end diff --git a/spec/ruby/library/cgi/queryextension/multipart_spec.rb b/spec/ruby/library/cgi/queryextension/multipart_spec.rb index 281791892c3818..1fa771ca1cf281 100644 --- a/spec/ruby/library/cgi/queryextension/multipart_spec.rb +++ b/spec/ruby/library/cgi/queryextension/multipart_spec.rb @@ -37,7 +37,7 @@ end it "returns true if the current Request is a multipart request" do - @cgi.multipart?.should be_true + @cgi.multipart?.should == true end end end diff --git a/spec/ruby/library/cgi/queryextension/server_port_spec.rb b/spec/ruby/library/cgi/queryextension/server_port_spec.rb index 60c03ea6392afc..1c88d3225d8c93 100644 --- a/spec/ruby/library/cgi/queryextension/server_port_spec.rb +++ b/spec/ruby/library/cgi/queryextension/server_port_spec.rb @@ -17,10 +17,10 @@ old_value = ENV['SERVER_PORT'] begin ENV['SERVER_PORT'] = nil - @cgi.server_port.should be_nil + @cgi.server_port.should == nil ENV['SERVER_PORT'] = "3000" - @cgi.server_port.should eql(3000) + @cgi.server_port.should.eql?(3000) ensure ENV['SERVER_PORT'] = old_value end diff --git a/spec/ruby/library/cgi/queryextension/shared/has_key.rb b/spec/ruby/library/cgi/queryextension/shared/has_key.rb index cfac5865fa87ae..6231cb548e15b4 100644 --- a/spec/ruby/library/cgi/queryextension/shared/has_key.rb +++ b/spec/ruby/library/cgi/queryextension/shared/has_key.rb @@ -12,8 +12,8 @@ end it "returns true when the passed key exists in the HTTP Query" do - @cgi.send(@method, "one").should be_true - @cgi.send(@method, "two").should be_true - @cgi.send(@method, "three").should be_false + @cgi.send(@method, "one").should == true + @cgi.send(@method, "two").should == true + @cgi.send(@method, "three").should == false end end diff --git a/spec/ruby/library/cgi/shared/http_header.rb b/spec/ruby/library/cgi/shared/http_header.rb index b225b5925ea94c..e739fed538ae42 100644 --- a/spec/ruby/library/cgi/shared/http_header.rb +++ b/spec/ruby/library/cgi/shared/http_header.rb @@ -63,11 +63,11 @@ header.should == "Content-Type: text/plain; charset=UTF-8\r\n\r\n" header = @cgi.send(@method, "nph" => true) - header.should include("HTTP/1.0 200 OK\r\n") - header.should include("Date: ") - header.should include("Server: ") - header.should include("Connection: close\r\n") - header.should include("Content-Type: text/html\r\n") + header.should.include?("HTTP/1.0 200 OK\r\n") + header.should.include?("Date: ") + header.should.include?("Server: ") + header.should.include?("Connection: close\r\n") + header.should.include?("Content-Type: text/html\r\n") header = @cgi.send(@method, "status" => "OK") header.should == "Status: 200 OK\r\nContent-Type: text/html\r\n\r\n" diff --git a/spec/ruby/library/cgi/unescapeURIComponent_spec.rb b/spec/ruby/library/cgi/unescapeURIComponent_spec.rb index f80eb1626b4454..e0bf4b70e0348a 100644 --- a/spec/ruby/library/cgi/unescapeURIComponent_spec.rb +++ b/spec/ruby/library/cgi/unescapeURIComponent_spec.rb @@ -44,7 +44,7 @@ end it "raises ArgumentError if specified encoding is unknown" do - -> { CGI.unescapeURIComponent("ABC", "ISO-JOKE-1") }.should raise_error(ArgumentError, "unknown encoding name - ISO-JOKE-1") + -> { CGI.unescapeURIComponent("ABC", "ISO-JOKE-1") }.should.raise(ArgumentError, "unknown encoding name - ISO-JOKE-1") end ruby_version_is ""..."4.0" do @@ -91,7 +91,7 @@ decoded = CGI.unescapeURIComponent(string, Encoding::US_ASCII) decoded.encoding.should == Encoding::SHIFT_JIS decoded.should == "「ヲ」".encode(Encoding::SHIFT_JIS) - decoded.valid_encoding?.should be_true + decoded.valid_encoding?.should == true end it "uses source string's encoding even if it's also invalid" do @@ -99,7 +99,7 @@ decoded = CGI.unescapeURIComponent(string, Encoding::SHIFT_JIS) decoded.encoding.should == Encoding::US_ASCII decoded.should == "\xFF".dup.force_encoding(Encoding::US_ASCII) - decoded.valid_encoding?.should be_false + decoded.valid_encoding?.should == false end end @@ -114,7 +114,7 @@ it "raises a TypeError with nil" do -> { CGI.unescapeURIComponent(nil) - }.should raise_error(TypeError, "no implicit conversion of nil into String") + }.should.raise(TypeError, "no implicit conversion of nil into String") end it "uses implicit type conversion to String" do diff --git a/spec/ruby/library/coverage/result_spec.rb b/spec/ruby/library/coverage/result_spec.rb index 0101eb6a643bce..2e7d598bb8ed54 100644 --- a/spec/ruby/library/coverage/result_spec.rb +++ b/spec/ruby/library/coverage/result_spec.rb @@ -80,7 +80,7 @@ Coverage.result -> { Coverage.result - }.should raise_error(RuntimeError, 'coverage measurement is not enabled') + }.should.raise(RuntimeError, 'coverage measurement is not enabled') end it 'second run should give same result' do @@ -108,7 +108,7 @@ it 'does not include the file starting coverage since it is not tracked' do require @config_file.chomp('.rb') - Coverage.result.should_not include(@config_file) + Coverage.result.should_not.include?(@config_file) end it 'returns the correct results when eval coverage is enabled' do diff --git a/spec/ruby/library/coverage/start_spec.rb b/spec/ruby/library/coverage/start_spec.rb index c921b854018392..11777347a28782 100644 --- a/spec/ruby/library/coverage/start_spec.rb +++ b/spec/ruby/library/coverage/start_spec.rb @@ -24,7 +24,7 @@ -> { Coverage.start - }.should raise_error(RuntimeError, 'coverage measurement is already setup') + }.should.raise(RuntimeError, 'coverage measurement is already setup') end it "accepts :all optional argument" do @@ -65,13 +65,13 @@ it "expects a Hash if not passed :all" do -> { Coverage.start(42) - }.should raise_error(TypeError, "no implicit conversion of Integer into Hash") + }.should.raise(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") + }.should.raise(RuntimeError, "cannot enable lines and oneshot_lines simultaneously") end it "enables the coverage measurement if passed options with `false` value" do diff --git a/spec/ruby/library/coverage/supported_spec.rb b/spec/ruby/library/coverage/supported_spec.rb index 9226548c1f5597..fcf8a76d7962b3 100644 --- a/spec/ruby/library/coverage/supported_spec.rb +++ b/spec/ruby/library/coverage/supported_spec.rb @@ -17,14 +17,14 @@ it "raise TypeError if argument is not Symbol" do -> { Coverage.supported?("lines") - }.should raise_error(TypeError, "wrong argument type String (expected Symbol)") + }.should.raise(TypeError, "wrong argument type String (expected Symbol)") -> { Coverage.supported?([]) - }.should raise_error(TypeError, "wrong argument type Array (expected Symbol)") + }.should.raise(TypeError, "wrong argument type Array (expected Symbol)") -> { Coverage.supported?(1) - }.should raise_error(TypeError, "wrong argument type Integer (expected Symbol)") + }.should.raise(TypeError, "wrong argument type Integer (expected Symbol)") end end diff --git a/spec/ruby/library/csv/generate_spec.rb b/spec/ruby/library/csv/generate_spec.rb index b45e2eb95ba262..62e19aa6e43ce8 100644 --- a/spec/ruby/library/csv/generate_spec.rb +++ b/spec/ruby/library/csv/generate_spec.rb @@ -26,7 +26,7 @@ csv.add_row [1, 2, 3] csv << [4, 5, 6] end - csv_str.should equal str + csv_str.should.equal? str str.should == "1,2,3\n4,5,6\n" end end diff --git a/spec/ruby/library/csv/parse_spec.rb b/spec/ruby/library/csv/parse_spec.rb index ef5d4ea3ca1f43..7000f03cdacf37 100644 --- a/spec/ruby/library/csv/parse_spec.rb +++ b/spec/ruby/library/csv/parse_spec.rb @@ -5,7 +5,7 @@ it "parses '' into []" do result = CSV.parse '' - result.should be_kind_of(Array) + result.should.is_a?(Array) result.should == [] end @@ -82,7 +82,7 @@ it "raises CSV::MalformedCSVError exception if input is illegal" do -> { CSV.parse('"quoted" field') - }.should raise_error(CSV::MalformedCSVError) + }.should.raise(CSV::MalformedCSVError) end it "handles illegal input with the liberal_parsing option" do diff --git a/spec/ruby/library/csv/readlines_spec.rb b/spec/ruby/library/csv/readlines_spec.rb index 14dea34381da2b..624f906489a4e1 100644 --- a/spec/ruby/library/csv/readlines_spec.rb +++ b/spec/ruby/library/csv/readlines_spec.rb @@ -23,7 +23,7 @@ it "raises CSV::MalformedCSVError exception if input is illegal" do csv = CSV.new('"quoted" field') - -> { csv.readlines }.should raise_error(CSV::MalformedCSVError) + -> { csv.readlines }.should.raise(CSV::MalformedCSVError) end it "handles illegal input with the liberal_parsing option" do diff --git a/spec/ruby/library/date/add_month_spec.rb b/spec/ruby/library/date/add_month_spec.rb index 40833f6487df80..ab802ea97a5985 100644 --- a/spec/ruby/library/date/add_month_spec.rb +++ b/spec/ruby/library/date/add_month_spec.rb @@ -21,18 +21,18 @@ end it "raise a TypeError when passed a Symbol" do - -> { Date.civil(2007,2,27) >> :hello }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) >> :hello }.should.raise(TypeError) end it "raise a TypeError when passed a String" do - -> { Date.civil(2007,2,27) >> "hello" }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) >> "hello" }.should.raise(TypeError) end it "raise a TypeError when passed a Date" do - -> { Date.civil(2007,2,27) >> Date.new }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) >> Date.new }.should.raise(TypeError) end it "raise a TypeError when passed an Object" do - -> { Date.civil(2007,2,27) >> Object.new }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) >> Object.new }.should.raise(TypeError) end end diff --git a/spec/ruby/library/date/add_spec.rb b/spec/ruby/library/date/add_spec.rb index 2b9cc62023e69b..5e368decdceae8 100644 --- a/spec/ruby/library/date/add_spec.rb +++ b/spec/ruby/library/date/add_spec.rb @@ -13,18 +13,18 @@ end it "raises a TypeError when passed a Symbol" do - -> { Date.civil(2007,2,27) + :hello }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) + :hello }.should.raise(TypeError) end it "raises a TypeError when passed a String" do - -> { Date.civil(2007,2,27) + "hello" }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) + "hello" }.should.raise(TypeError) end it "raises a TypeError when passed a Date" do - -> { Date.civil(2007,2,27) + Date.new }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) + Date.new }.should.raise(TypeError) end it "raises a TypeError when passed an Object" do - -> { Date.civil(2007,2,27) + Object.new }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) + Object.new }.should.raise(TypeError) end end diff --git a/spec/ruby/library/date/constants_spec.rb b/spec/ruby/library/date/constants_spec.rb index 1d18dd1b0c63a2..3494b0c296c96d 100644 --- a/spec/ruby/library/date/constants_spec.rb +++ b/spec/ruby/library/date/constants_spec.rb @@ -36,11 +36,11 @@ [Date::MONTHNAMES, Date::DAYNAMES, Date::ABBR_MONTHNAMES, Date::ABBR_DAYNAMES].each do |ary| -> { ary << "Unknown" - }.should raise_error(FrozenError, /frozen/) + }.should.raise(FrozenError, /frozen/) ary.compact.each do |name| -> { name << "modified" - }.should raise_error(FrozenError, /frozen/) + }.should.raise(FrozenError, /frozen/) end end end diff --git a/spec/ruby/library/date/deconstruct_keys_spec.rb b/spec/ruby/library/date/deconstruct_keys_spec.rb index b9dd6b88162d1f..1fa1e7025090a6 100644 --- a/spec/ruby/library/date/deconstruct_keys_spec.rb +++ b/spec/ruby/library/date/deconstruct_keys_spec.rb @@ -16,16 +16,16 @@ it "requires one argument" do -> { Date.new(2022, 10, 5).deconstruct_keys - }.should raise_error(ArgumentError) + }.should.raise(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)") + -> { d.deconstruct_keys(1) }.should.raise(TypeError, "wrong argument type Integer (expected Array or nil)") + -> { d.deconstruct_keys("asd") }.should.raise(TypeError, "wrong argument type String (expected Array or nil)") + -> { d.deconstruct_keys(:x) }.should.raise(TypeError, "wrong argument type Symbol (expected Array or nil)") + -> { d.deconstruct_keys({}) }.should.raise(TypeError, "wrong argument type Hash (expected Array or nil)") end it "returns {} when passed []" do diff --git a/spec/ruby/library/date/eql_spec.rb b/spec/ruby/library/date/eql_spec.rb index a1819cae3a60b6..79fabc47f45b76 100644 --- a/spec/ruby/library/date/eql_spec.rb +++ b/spec/ruby/library/date/eql_spec.rb @@ -3,10 +3,10 @@ describe "Date#eql?" do it "returns true if self is equal to another date" do - Date.civil(2007, 10, 11).eql?(Date.civil(2007, 10, 11)).should be_true + Date.civil(2007, 10, 11).eql?(Date.civil(2007, 10, 11)).should == true end it "returns false if self is not equal to another date" do - Date.civil(2007, 10, 11).eql?(Date.civil(2007, 10, 12)).should be_false + Date.civil(2007, 10, 11).eql?(Date.civil(2007, 10, 12)).should == false end end diff --git a/spec/ruby/library/date/friday_spec.rb b/spec/ruby/library/date/friday_spec.rb index 3dc040fabebda1..62f050346ed848 100644 --- a/spec/ruby/library/date/friday_spec.rb +++ b/spec/ruby/library/date/friday_spec.rb @@ -3,10 +3,10 @@ describe "Date#friday?" do it "should be friday" do - Date.new(2000, 1, 7).friday?.should be_true + Date.new(2000, 1, 7).friday?.should == true end it "should not be friday" do - Date.new(2000, 1, 8).friday?.should be_false + Date.new(2000, 1, 8).friday?.should == false end end diff --git a/spec/ruby/library/date/gregorian_leap_spec.rb b/spec/ruby/library/date/gregorian_leap_spec.rb index c3d25cf90f0f55..c27890faf45e9a 100644 --- a/spec/ruby/library/date/gregorian_leap_spec.rb +++ b/spec/ruby/library/date/gregorian_leap_spec.rb @@ -3,13 +3,13 @@ describe "Date#gregorian_leap?" do it "returns true if a year is a leap year in the Gregorian calendar" do - Date.gregorian_leap?(2000).should be_true - Date.gregorian_leap?(2004).should be_true + Date.gregorian_leap?(2000).should == true + Date.gregorian_leap?(2004).should == true end it "returns false if a year is not a leap year in the Gregorian calendar" do - Date.gregorian_leap?(1900).should be_false - Date.gregorian_leap?(1999).should be_false - Date.gregorian_leap?(2002).should be_false + Date.gregorian_leap?(1900).should == false + Date.gregorian_leap?(1999).should == false + Date.gregorian_leap?(2002).should == false end end diff --git a/spec/ruby/library/date/gregorian_spec.rb b/spec/ruby/library/date/gregorian_spec.rb index ea7ece2adef4f3..bbda13af08d4f2 100644 --- a/spec/ruby/library/date/gregorian_spec.rb +++ b/spec/ruby/library/date/gregorian_spec.rb @@ -4,13 +4,13 @@ describe "Date#gregorian?" do it "marks a day before the calendar reform as Julian" do - Date.civil(1007, 2, 27).gregorian?.should be_false - Date.civil(1907, 2, 27, Date.civil(1930, 1, 1).jd).gregorian?.should be_false + Date.civil(1007, 2, 27).gregorian?.should == false + Date.civil(1907, 2, 27, Date.civil(1930, 1, 1).jd).gregorian?.should == false end it "marks a day after the calendar reform as Julian" do Date.civil(2007, 2, 27).should.gregorian? - Date.civil(1607, 2, 27, Date.civil(1582, 1, 1).jd).gregorian?.should be_true + Date.civil(1607, 2, 27, Date.civil(1582, 1, 1).jd).gregorian?.should == true end end diff --git a/spec/ruby/library/date/iso8601_spec.rb b/spec/ruby/library/date/iso8601_spec.rb index af66845a6b4f81..26815bd76cdcae 100644 --- a/spec/ruby/library/date/iso8601_spec.rb +++ b/spec/ruby/library/date/iso8601_spec.rb @@ -25,17 +25,17 @@ it "raises a Date::Error if the argument is a invalid Date" do -> { Date.iso8601('invalid') - }.should raise_error(Date::Error, "invalid date") + }.should.raise(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") + }.should.raise(Date::Error, "invalid date") end it "raises a TypeError when passed an Object" do - -> { Date.iso8601(Object.new) }.should raise_error(TypeError) + -> { Date.iso8601(Object.new) }.should.raise(TypeError) end end @@ -51,6 +51,6 @@ end it "raises a TypeError when passed an Object" do - -> { Date._iso8601(Object.new) }.should raise_error(TypeError) + -> { Date._iso8601(Object.new) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/date/julian_leap_spec.rb b/spec/ruby/library/date/julian_leap_spec.rb index 2ef2d65d810a51..42231e012f5696 100644 --- a/spec/ruby/library/date/julian_leap_spec.rb +++ b/spec/ruby/library/date/julian_leap_spec.rb @@ -3,13 +3,13 @@ describe "Date.julian_leap?" do it "determines whether a year is a leap year in the Julian calendar" do - Date.julian_leap?(1900).should be_true - Date.julian_leap?(2000).should be_true - Date.julian_leap?(2004).should be_true + Date.julian_leap?(1900).should == true + Date.julian_leap?(2000).should == true + Date.julian_leap?(2004).should == true end it "determines whether a year is not a leap year in the Julian calendar" do - Date.julian_leap?(1999).should be_false - Date.julian_leap?(2002).should be_false + Date.julian_leap?(1999).should == false + Date.julian_leap?(2002).should == false end end diff --git a/spec/ruby/library/date/julian_spec.rb b/spec/ruby/library/date/julian_spec.rb index db2629d1e733b6..9f8a6708996eca 100644 --- a/spec/ruby/library/date/julian_spec.rb +++ b/spec/ruby/library/date/julian_spec.rb @@ -5,12 +5,12 @@ it "marks a day before the calendar reform as Julian" do Date.civil(1007, 2, 27).should.julian? - Date.civil(1907, 2, 27, Date.civil(1930, 1, 1).jd).julian?.should be_true + Date.civil(1907, 2, 27, Date.civil(1930, 1, 1).jd).julian?.should == true end it "marks a day after the calendar reform as Julian" do Date.civil(2007, 2, 27).should_not.julian? - Date.civil(1607, 2, 27, Date.civil(1582, 1, 1).jd).julian?.should be_false + Date.civil(1607, 2, 27, Date.civil(1582, 1, 1).jd).julian?.should == false end end diff --git a/spec/ruby/library/date/minus_month_spec.rb b/spec/ruby/library/date/minus_month_spec.rb index 470c4d8a765b86..d56e19dc31075b 100644 --- a/spec/ruby/library/date/minus_month_spec.rb +++ b/spec/ruby/library/date/minus_month_spec.rb @@ -14,10 +14,10 @@ end it "raises an error on non numeric parameters" do - -> { Date.civil(2007,2,27) << :hello }.should raise_error(TypeError) - -> { Date.civil(2007,2,27) << "hello" }.should raise_error(TypeError) - -> { Date.civil(2007,2,27) << Date.new }.should raise_error(TypeError) - -> { Date.civil(2007,2,27) << Object.new }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) << :hello }.should.raise(TypeError) + -> { Date.civil(2007,2,27) << "hello" }.should.raise(TypeError) + -> { Date.civil(2007,2,27) << Date.new }.should.raise(TypeError) + -> { Date.civil(2007,2,27) << Object.new }.should.raise(TypeError) end end diff --git a/spec/ruby/library/date/minus_spec.rb b/spec/ruby/library/date/minus_spec.rb index 5a2a29e04a8d0d..c2a08fa5b08c0f 100644 --- a/spec/ruby/library/date/minus_spec.rb +++ b/spec/ruby/library/date/minus_spec.rb @@ -22,9 +22,9 @@ end it "raises an error for non Numeric arguments" do - -> { Date.civil(2007,2,27) - :hello }.should raise_error(TypeError) - -> { Date.civil(2007,2,27) - "hello" }.should raise_error(TypeError) - -> { Date.civil(2007,2,27) - Object.new }.should raise_error(TypeError) + -> { Date.civil(2007,2,27) - :hello }.should.raise(TypeError) + -> { Date.civil(2007,2,27) - "hello" }.should.raise(TypeError) + -> { Date.civil(2007,2,27) - Object.new }.should.raise(TypeError) end end diff --git a/spec/ruby/library/date/monday_spec.rb b/spec/ruby/library/date/monday_spec.rb index 14a117b73c4e49..61d728f3c50e87 100644 --- a/spec/ruby/library/date/monday_spec.rb +++ b/spec/ruby/library/date/monday_spec.rb @@ -3,6 +3,6 @@ describe "Date#monday?" do it "should be monday" do - Date.new(2000, 1, 3).monday?.should be_true + Date.new(2000, 1, 3).monday?.should == true end end diff --git a/spec/ruby/library/date/parse_spec.rb b/spec/ruby/library/date/parse_spec.rb index 5ef4f6e9b5dd2f..4d655f516e35d3 100644 --- a/spec/ruby/library/date/parse_spec.rb +++ b/spec/ruby/library/date/parse_spec.rb @@ -23,7 +23,7 @@ # Specs using numbers it "throws an argument error for a single digit" do - ->{ Date.parse("1") }.should raise_error(ArgumentError) + ->{ Date.parse("1") }.should.raise(ArgumentError) end it "parses DD as month day number" do @@ -66,8 +66,8 @@ end it "raises a TypeError trying to parse non-String-like object" do - -> { Date.parse(1) }.should raise_error(TypeError) - -> { Date.parse([]) }.should raise_error(TypeError) + -> { Date.parse(1) }.should.raise(TypeError) + -> { Date.parse([]) }.should.raise(TypeError) end it "coerces using to_str" do diff --git a/spec/ruby/library/date/plus_spec.rb b/spec/ruby/library/date/plus_spec.rb index 0cb99fd4cae740..6179370fcac5c6 100644 --- a/spec/ruby/library/date/plus_spec.rb +++ b/spec/ruby/library/date/plus_spec.rb @@ -15,6 +15,6 @@ end it "raises TypeError if argument is not Numeric" do - -> { Date.today + Date.today }.should raise_error(TypeError) + -> { Date.today + Date.today }.should.raise(TypeError) end end diff --git a/spec/ruby/library/date/saturday_spec.rb b/spec/ruby/library/date/saturday_spec.rb index 1527b71d005bc9..29f8267a2b5566 100644 --- a/spec/ruby/library/date/saturday_spec.rb +++ b/spec/ruby/library/date/saturday_spec.rb @@ -3,6 +3,6 @@ describe "Date#saturday?" do it "should be saturday" do - Date.new(2000, 1, 1).saturday?.should be_true + Date.new(2000, 1, 1).saturday?.should == true end end diff --git a/spec/ruby/library/date/shared/civil.rb b/spec/ruby/library/date/shared/civil.rb index bbed4a88662eb4..4499cdf8e95daf 100644 --- a/spec/ruby/library/date/shared/civil.rb +++ b/spec/ruby/library/date/shared/civil.rb @@ -36,14 +36,14 @@ end it "doesn't create dates for invalid arguments" do - -> { Date.send(@method, 2000, 13, 31) }.should raise_error(ArgumentError) - -> { Date.send(@method, 2000, 12, 32) }.should raise_error(ArgumentError) - -> { Date.send(@method, 2000, 2, 30) }.should raise_error(ArgumentError) - -> { Date.send(@method, 1900, 2, 29) }.should raise_error(ArgumentError) - -> { Date.send(@method, 2000, 2, 29) }.should_not raise_error(ArgumentError) - - -> { Date.send(@method, 1582, 10, 14) }.should raise_error(ArgumentError) - -> { Date.send(@method, 1582, 10, 15) }.should_not raise_error(ArgumentError) + -> { Date.send(@method, 2000, 13, 31) }.should.raise(ArgumentError) + -> { Date.send(@method, 2000, 12, 32) }.should.raise(ArgumentError) + -> { Date.send(@method, 2000, 2, 30) }.should.raise(ArgumentError) + -> { Date.send(@method, 1900, 2, 29) }.should.raise(ArgumentError) + -> { Date.send(@method, 2000, 2, 29) }.should_not.raise(ArgumentError) + + -> { Date.send(@method, 1582, 10, 14) }.should.raise(ArgumentError) + -> { Date.send(@method, 1582, 10, 15) }.should_not.raise(ArgumentError) end diff --git a/spec/ruby/library/date/shared/commercial.rb b/spec/ruby/library/date/shared/commercial.rb index 39c9af47b6cc30..f53d83235aa0b6 100644 --- a/spec/ruby/library/date/shared/commercial.rb +++ b/spec/ruby/library/date/shared/commercial.rb @@ -25,15 +25,15 @@ end it "creates only Date objects for valid weeks" do - -> { Date.send(@method, 2004, 53, 1) }.should_not raise_error(ArgumentError) - -> { Date.send(@method, 2004, 53, 0) }.should raise_error(ArgumentError) - -> { Date.send(@method, 2004, 53, 8) }.should raise_error(ArgumentError) - -> { Date.send(@method, 2004, 54, 1) }.should raise_error(ArgumentError) - -> { Date.send(@method, 2004, 0, 1) }.should raise_error(ArgumentError) + -> { Date.send(@method, 2004, 53, 1) }.should_not.raise(ArgumentError) + -> { Date.send(@method, 2004, 53, 0) }.should.raise(ArgumentError) + -> { Date.send(@method, 2004, 53, 8) }.should.raise(ArgumentError) + -> { Date.send(@method, 2004, 54, 1) }.should.raise(ArgumentError) + -> { Date.send(@method, 2004, 0, 1) }.should.raise(ArgumentError) - -> { Date.send(@method, 2003, 52, 1) }.should_not raise_error(ArgumentError) - -> { Date.send(@method, 2003, 53, 1) }.should raise_error(ArgumentError) - -> { Date.send(@method, 2003, 52, 0) }.should raise_error(ArgumentError) - -> { Date.send(@method, 2003, 52, 8) }.should raise_error(ArgumentError) + -> { Date.send(@method, 2003, 52, 1) }.should_not.raise(ArgumentError) + -> { Date.send(@method, 2003, 53, 1) }.should.raise(ArgumentError) + -> { Date.send(@method, 2003, 52, 0) }.should.raise(ArgumentError) + -> { Date.send(@method, 2003, 52, 8) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/date/shared/valid_civil.rb b/spec/ruby/library/date/shared/valid_civil.rb index 545c207bbea0ab..425fee4d2d7fb0 100644 --- a/spec/ruby/library/date/shared/valid_civil.rb +++ b/spec/ruby/library/date/shared/valid_civil.rb @@ -9,8 +9,8 @@ # 31 it "returns true if it is a valid civil date" do - Date.send(@method, 1582, 10, 15).should be_true - Date.send(@method, 1582, 10, 14, Date::ENGLAND).should be_true + Date.send(@method, 1582, 10, 15).should == true + Date.send(@method, 1582, 10, 14, Date::ENGLAND).should == true end it "returns false if it is not a valid civil date" do @@ -24,13 +24,13 @@ # -15 -14 -13 -12 -11 -10 -9 # -8 -7 -6 -5 -4 -3 -2 # -1 - Date.send(@method, 1582, -3, -22).should be_false - Date.send(@method, 1582, -3, -21).should be_true - Date.send(@method, 1582, -3, -18).should be_true - Date.send(@method, 1582, -3, -17).should be_true + Date.send(@method, 1582, -3, -22).should == false + Date.send(@method, 1582, -3, -21).should == true + Date.send(@method, 1582, -3, -18).should == true + Date.send(@method, 1582, -3, -17).should == true - Date.send(@method, 2007, -11, -10).should be_true - Date.send(@method, 2008, -11, -10).should be_true + Date.send(@method, 2007, -11, -10).should == true + Date.send(@method, 2008, -11, -10).should == true end end diff --git a/spec/ruby/library/date/shared/valid_commercial.rb b/spec/ruby/library/date/shared/valid_commercial.rb index 117dfe1d3da3f0..573b851fdd4c88 100644 --- a/spec/ruby/library/date/shared/valid_commercial.rb +++ b/spec/ruby/library/date/shared/valid_commercial.rb @@ -6,16 +6,16 @@ # 39: 1 2 3 4 5 6 7 # 40: 1 2 3 4 5 6 7 # 41: 1 2 3 4 5 6 7 - Date.send(@method, 1582, 39, 4).should be_true - Date.send(@method, 1582, 39, 5).should be_true - Date.send(@method, 1582, 41, 4).should be_true - Date.send(@method, 1582, 41, 5).should be_true - Date.send(@method, 1582, 41, 4, Date::ENGLAND).should be_true - Date.send(@method, 1752, 37, 4, Date::ENGLAND).should be_true + Date.send(@method, 1582, 39, 4).should == true + Date.send(@method, 1582, 39, 5).should == true + Date.send(@method, 1582, 41, 4).should == true + Date.send(@method, 1582, 41, 5).should == true + Date.send(@method, 1582, 41, 4, Date::ENGLAND).should == true + Date.send(@method, 1752, 37, 4, Date::ENGLAND).should == true end it "returns false it is not a valid commercial date" do - Date.send(@method, 1999, 53, 1).should be_false + Date.send(@method, 1999, 53, 1).should == false end it "handles negative week and day numbers" do @@ -24,11 +24,11 @@ # -12: -7 -6 -5 -4 -3 -2 -1 # -11: -7 -6 -5 -4 -3 -2 -1 # -10: -7 -6 -5 -4 -3 -2 -1 - Date.send(@method, 1582, -12, -4).should be_true - Date.send(@method, 1582, -12, -3).should be_true - Date.send(@method, 2007, -44, -2).should be_true - Date.send(@method, 2008, -44, -2).should be_true - Date.send(@method, 1999, -53, -1).should be_false + Date.send(@method, 1582, -12, -4).should == true + Date.send(@method, 1582, -12, -3).should == true + Date.send(@method, 2007, -44, -2).should == true + Date.send(@method, 2008, -44, -2).should == true + Date.send(@method, 1999, -53, -1).should == false end end diff --git a/spec/ruby/library/date/shared/valid_jd.rb b/spec/ruby/library/date/shared/valid_jd.rb index e474dfb4501a43..0c01710208efe8 100644 --- a/spec/ruby/library/date/shared/valid_jd.rb +++ b/spec/ruby/library/date/shared/valid_jd.rb @@ -1,20 +1,20 @@ describe :date_valid_jd?, shared: true do it "returns true if passed a number value" do - Date.send(@method, -100).should be_true - Date.send(@method, 100.0).should be_true - Date.send(@method, 2**100).should be_true - Date.send(@method, Rational(1,2)).should be_true + Date.send(@method, -100).should == true + Date.send(@method, 100.0).should == true + Date.send(@method, 2**100).should == true + Date.send(@method, Rational(1,2)).should == true end it "returns false if passed nil" do - Date.send(@method, nil).should be_false + Date.send(@method, nil).should == false end it "returns false if passed symbol" do - Date.send(@method, :number).should be_false + Date.send(@method, :number).should == false end it "returns false if passed false" do - Date.send(@method, false).should be_false + Date.send(@method, false).should == false end end diff --git a/spec/ruby/library/date/sunday_spec.rb b/spec/ruby/library/date/sunday_spec.rb index c3a817fa86b0db..548f36a4f06558 100644 --- a/spec/ruby/library/date/sunday_spec.rb +++ b/spec/ruby/library/date/sunday_spec.rb @@ -3,6 +3,6 @@ describe "Date#sunday?" do it "should be sunday" do - Date.new(2000, 1, 2).sunday?.should be_true + Date.new(2000, 1, 2).sunday?.should == true end end diff --git a/spec/ruby/library/date/thursday_spec.rb b/spec/ruby/library/date/thursday_spec.rb index 74b5f403657e44..4df3b9103acffc 100644 --- a/spec/ruby/library/date/thursday_spec.rb +++ b/spec/ruby/library/date/thursday_spec.rb @@ -3,6 +3,6 @@ describe "Date#thursday?" do it "should be thursday" do - Date.new(2000, 1, 6).thursday?.should be_true + Date.new(2000, 1, 6).thursday?.should == true end end diff --git a/spec/ruby/library/date/today_spec.rb b/spec/ruby/library/date/today_spec.rb index 7c6ebc9cb48d23..4be8d8e93143cc 100644 --- a/spec/ruby/library/date/today_spec.rb +++ b/spec/ruby/library/date/today_spec.rb @@ -3,7 +3,7 @@ describe "Date.today" do it "returns a Date object" do - Date.today.should be_kind_of Date + Date.today.should.is_a? Date end it "sets Date object to the current date" do diff --git a/spec/ruby/library/date/tuesday_spec.rb b/spec/ruby/library/date/tuesday_spec.rb index 052837b54e0962..db31387aedfbfe 100644 --- a/spec/ruby/library/date/tuesday_spec.rb +++ b/spec/ruby/library/date/tuesday_spec.rb @@ -3,6 +3,6 @@ describe "Date#tuesday?" do it "should be tuesday" do - Date.new(2000, 1, 4).tuesday?.should be_true + Date.new(2000, 1, 4).tuesday?.should == true end end diff --git a/spec/ruby/library/date/wednesday_spec.rb b/spec/ruby/library/date/wednesday_spec.rb index e80ec23dd201bd..4bbeead5b8eceb 100644 --- a/spec/ruby/library/date/wednesday_spec.rb +++ b/spec/ruby/library/date/wednesday_spec.rb @@ -3,6 +3,6 @@ describe "Date#wednesday?" do it "should be wednesday" do - Date.new(2000, 1, 5).wednesday?.should be_true + Date.new(2000, 1, 5).wednesday?.should == true end end diff --git a/spec/ruby/library/datetime/deconstruct_keys_spec.rb b/spec/ruby/library/datetime/deconstruct_keys_spec.rb index 154c024a2397c6..07a7bda881ae5c 100644 --- a/spec/ruby/library/datetime/deconstruct_keys_spec.rb +++ b/spec/ruby/library/datetime/deconstruct_keys_spec.rb @@ -18,16 +18,16 @@ it "requires one argument" do -> { DateTime.new(2022, 10, 5, 13, 30).deconstruct_keys - }.should raise_error(ArgumentError) + }.should.raise(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)") + -> { d.deconstruct_keys(1) }.should.raise(TypeError, "wrong argument type Integer (expected Array or nil)") + -> { d.deconstruct_keys("asd") }.should.raise(TypeError, "wrong argument type String (expected Array or nil)") + -> { d.deconstruct_keys(:x) }.should.raise(TypeError, "wrong argument type Symbol (expected Array or nil)") + -> { d.deconstruct_keys({}) }.should.raise(TypeError, "wrong argument type Hash (expected Array or nil)") end it "returns {} when passed []" do diff --git a/spec/ruby/library/datetime/hour_spec.rb b/spec/ruby/library/datetime/hour_spec.rb index 8efd5f92f0606a..383a85fe6027b5 100644 --- a/spec/ruby/library/datetime/hour_spec.rb +++ b/spec/ruby/library/datetime/hour_spec.rb @@ -15,23 +15,23 @@ end it "raises an error for Rational" do - -> { new_datetime(hour: 1 + Rational(1,2)) }.should raise_error(ArgumentError) + -> { new_datetime(hour: 1 + Rational(1,2)) }.should.raise(ArgumentError) end it "raises an error for Float" do - -> { new_datetime(hour: 1.5).hour }.should raise_error(ArgumentError) + -> { new_datetime(hour: 1.5).hour }.should.raise(ArgumentError) end it "raises an error for Rational" do - -> { new_datetime(day: 1 + Rational(1,2)) }.should raise_error(ArgumentError) + -> { new_datetime(day: 1 + Rational(1,2)) }.should.raise(ArgumentError) end it "raises an error, when the hour is smaller than -24" do - -> { new_datetime(hour: -25) }.should raise_error(ArgumentError) + -> { new_datetime(hour: -25) }.should.raise(ArgumentError) end it "raises an error, when the hour is larger than 24" do - -> { new_datetime(hour: 25) }.should raise_error(ArgumentError) + -> { new_datetime(hour: 25) }.should.raise(ArgumentError) end it "raises an error for hour fractions smaller than -24" do diff --git a/spec/ruby/library/datetime/new_spec.rb b/spec/ruby/library/datetime/new_spec.rb index 6a4dced3845c6a..2b3c3f156cdea8 100644 --- a/spec/ruby/library/datetime/new_spec.rb +++ b/spec/ruby/library/datetime/new_spec.rb @@ -47,6 +47,6 @@ end it "raises an error on invalid arguments" do - -> { new_datetime(minute: 999) }.should raise_error(ArgumentError) + -> { new_datetime(minute: 999) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/datetime/now_spec.rb b/spec/ruby/library/datetime/now_spec.rb index 9f22153c15686a..5c0411c2be5d9f 100644 --- a/spec/ruby/library/datetime/now_spec.rb +++ b/spec/ruby/library/datetime/now_spec.rb @@ -3,7 +3,7 @@ describe "DateTime.now" do it "creates an instance of DateTime" do - DateTime.now.should be_an_instance_of(DateTime) + DateTime.now.should.instance_of?(DateTime) end it "sets the current date" do diff --git a/spec/ruby/library/datetime/parse_spec.rb b/spec/ruby/library/datetime/parse_spec.rb index e9bf4e2ed16925..0a965273a086a4 100644 --- a/spec/ruby/library/datetime/parse_spec.rb +++ b/spec/ruby/library/datetime/parse_spec.rb @@ -20,7 +20,7 @@ # Specs using numbers it "throws an argument error for a single digit" do - ->{ DateTime.parse("1") }.should raise_error(ArgumentError) + ->{ DateTime.parse("1") }.should.raise(ArgumentError) end it "parses DD as month day number" do @@ -54,23 +54,23 @@ end it "throws an argument error for invalid month values" do - ->{DateTime.parse("2012-13-08T15:43:59")}.should raise_error(ArgumentError) + ->{DateTime.parse("2012-13-08T15:43:59")}.should.raise(ArgumentError) end it "throws an argument error for invalid day values" do - ->{DateTime.parse("2012-12-32T15:43:59")}.should raise_error(ArgumentError) + ->{DateTime.parse("2012-12-32T15:43:59")}.should.raise(ArgumentError) end it "throws an argument error for invalid hour values" do - ->{DateTime.parse("2012-12-31T25:43:59")}.should raise_error(ArgumentError) + ->{DateTime.parse("2012-12-31T25:43:59")}.should.raise(ArgumentError) end it "throws an argument error for invalid minute values" do - ->{DateTime.parse("2012-12-31T25:43:59")}.should raise_error(ArgumentError) + ->{DateTime.parse("2012-12-31T25:43:59")}.should.raise(ArgumentError) end it "throws an argument error for invalid second values" do - ->{DateTime.parse("2012-11-08T15:43:61")}.should raise_error(ArgumentError) + ->{DateTime.parse("2012-11-08T15:43:61")}.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/datetime/rfc2822_spec.rb b/spec/ruby/library/datetime/rfc2822_spec.rb index 83f7fa8d5b19c1..11b79a1e84a835 100644 --- a/spec/ruby/library/datetime/rfc2822_spec.rb +++ b/spec/ruby/library/datetime/rfc2822_spec.rb @@ -5,6 +5,6 @@ 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") + -> { DateTime.rfc2822(nil) }.should.raise(Date::Error, "invalid date") end end diff --git a/spec/ruby/library/datetime/shared/min.rb b/spec/ruby/library/datetime/shared/min.rb index a35b83928191ba..04e5f3457a7397 100644 --- a/spec/ruby/library/datetime/shared/min.rb +++ b/spec/ruby/library/datetime/shared/min.rb @@ -14,23 +14,23 @@ end it "raises an error for Rational" do - -> { new_datetime minute: 5 + Rational(1,2) }.should raise_error(ArgumentError) + -> { new_datetime minute: 5 + Rational(1,2) }.should.raise(ArgumentError) end it "raises an error for Float" do - -> { new_datetime minute: 5.5 }.should raise_error(ArgumentError) + -> { new_datetime minute: 5.5 }.should.raise(ArgumentError) end it "raises an error for Rational" do - -> { new_datetime(hour: 2 + Rational(1,2)) }.should raise_error(ArgumentError) + -> { new_datetime(hour: 2 + Rational(1,2)) }.should.raise(ArgumentError) end it "raises an error, when the minute is smaller than -60" do - -> { new_datetime(minute: -61) }.should raise_error(ArgumentError) + -> { new_datetime(minute: -61) }.should.raise(ArgumentError) end it "raises an error, when the minute is greater or equal than 60" do - -> { new_datetime(minute: 60) }.should raise_error(ArgumentError) + -> { new_datetime(minute: 60) }.should.raise(ArgumentError) end it "raises an error for minute fractions smaller than -60" do diff --git a/spec/ruby/library/datetime/shared/sec.rb b/spec/ruby/library/datetime/shared/sec.rb index 60009213aa5356..5af5db4fb2cd8d 100644 --- a/spec/ruby/library/datetime/shared/sec.rb +++ b/spec/ruby/library/datetime/shared/sec.rb @@ -23,15 +23,15 @@ end it "raises an error when minute is given as a rational" do - -> { new_datetime(minute: 5 + Rational(1,2)) }.should raise_error(ArgumentError) + -> { new_datetime(minute: 5 + Rational(1,2)) }.should.raise(ArgumentError) end it "raises an error, when the second is smaller than -60" do - -> { new_datetime(second: -61) }.should raise_error(ArgumentError) + -> { new_datetime(second: -61) }.should.raise(ArgumentError) end it "raises an error, when the second is greater or equal than 60" do - -> { new_datetime(second: 60) }.should raise_error(ArgumentError) + -> { new_datetime(second: 60) }.should.raise(ArgumentError) end it "raises an error for second fractions smaller than -60" do diff --git a/spec/ruby/library/datetime/to_date_spec.rb b/spec/ruby/library/datetime/to_date_spec.rb index 48c05e7fed68a6..31ccf5ae98104c 100644 --- a/spec/ruby/library/datetime/to_date_spec.rb +++ b/spec/ruby/library/datetime/to_date_spec.rb @@ -4,7 +4,7 @@ describe "DateTime#to_date" do it "returns an instance of Date" do dt = DateTime.new(2012, 12, 24, 12, 23, 00, '+05:00') - dt.to_date.should be_kind_of(Date) + dt.to_date.should.is_a?(Date) end it "maintains the same year" do diff --git a/spec/ruby/library/datetime/to_s_spec.rb b/spec/ruby/library/datetime/to_s_spec.rb index 175fb807f41fa2..ed0746f42b050d 100644 --- a/spec/ruby/library/datetime/to_s_spec.rb +++ b/spec/ruby/library/datetime/to_s_spec.rb @@ -4,7 +4,7 @@ describe "DateTime#to_s" do it "returns a new String object" do dt = DateTime.new(2012, 12, 24, 1, 2, 3, "+03:00") - dt.to_s.should be_kind_of(String) + dt.to_s.should.is_a?(String) end it "maintains timezone regardless of local time" do diff --git a/spec/ruby/library/datetime/to_time_spec.rb b/spec/ruby/library/datetime/to_time_spec.rb index 58bb363653ba56..a3ffc019fb9ad6 100644 --- a/spec/ruby/library/datetime/to_time_spec.rb +++ b/spec/ruby/library/datetime/to_time_spec.rb @@ -4,7 +4,7 @@ describe "DateTime#to_time" do it "yields a new Time object" do - DateTime.now.to_time.should be_kind_of(Time) + DateTime.now.to_time.should.is_a?(Time) end it "returns a Time representing the same instant" do diff --git a/spec/ruby/library/delegate/delegate_class/instance_method_spec.rb b/spec/ruby/library/delegate/delegate_class/instance_method_spec.rb index 16bf8d734cdf3b..19ffc4cf85e5b2 100644 --- a/spec/ruby/library/delegate/delegate_class/instance_method_spec.rb +++ b/spec/ruby/library/delegate/delegate_class/instance_method_spec.rb @@ -9,44 +9,44 @@ it "returns a method object for public instance methods of the delegated class" do m = @klass.instance_method(:pub) - m.should be_an_instance_of(UnboundMethod) + m.should.instance_of?(UnboundMethod) m.bind(@obj).call.should == :foo end it "returns a method object for protected instance methods of the delegated class" do m = @klass.instance_method(:prot) - m.should be_an_instance_of(UnboundMethod) + m.should.instance_of?(UnboundMethod) m.bind(@obj).call.should == :protected end it "raises a NameError for a private instance methods of the delegated class" do -> { @klass.instance_method(:priv) - }.should raise_error(NameError) + }.should.raise(NameError) end it "returns a method object for public instance methods of the DelegateClass class" do m = @klass.instance_method(:extra) - m.should be_an_instance_of(UnboundMethod) + m.should.instance_of?(UnboundMethod) m.bind(@obj).call.should == :cheese end it "returns a method object for protected instance methods of the DelegateClass class" do m = @klass.instance_method(:extra_protected) - m.should be_an_instance_of(UnboundMethod) + m.should.instance_of?(UnboundMethod) m.bind(@obj).call.should == :baz end it "returns a method object for private instance methods of the DelegateClass class" do m = @klass.instance_method(:extra_private) - m.should be_an_instance_of(UnboundMethod) + m.should.instance_of?(UnboundMethod) m.bind(@obj).call.should == :bar end it "raises a NameError for an invalid method name" do -> { @klass.instance_method(:invalid_and_silly_method_name) - }.should raise_error(NameError) + }.should.raise(NameError) end end diff --git a/spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb b/spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb index 6012ff72de2517..586be56cae15fa 100644 --- a/spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb +++ b/spec/ruby/library/delegate/delegate_class/instance_methods_spec.rb @@ -7,20 +7,20 @@ end it "includes all public methods of the delegated class" do - @methods.should include :pub + @methods.should.include? :pub end it "includes all protected methods of the delegated class" do - @methods.should include :prot + @methods.should.include? :prot end it "includes instance methods of the DelegateClass class" do - @methods.should include :extra - @methods.should include :extra_protected + @methods.should.include? :extra + @methods.should.include? :extra_protected end it "does not include private methods" do - @methods.should_not include :priv - @methods.should_not include :extra_private + @methods.should_not.include? :priv + @methods.should_not.include? :extra_private end end diff --git a/spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb b/spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb index 06b2115cc5d496..18ca2a4c8818ec 100644 --- a/spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb +++ b/spec/ruby/library/delegate/delegate_class/private_instance_methods_spec.rb @@ -7,17 +7,17 @@ end it "does not include any instance methods of the delegated class" do - @methods.should_not include :pub - @methods.should_not include :prot - @methods.should_not include :priv # since these are not forwarded... + @methods.should_not.include? :pub + @methods.should_not.include? :prot + @methods.should_not.include? :priv # since these are not forwarded... end it "includes private instance methods of the DelegateClass class" do - @methods.should include :extra_private + @methods.should.include? :extra_private end it "does not include public or protected instance methods of the DelegateClass class" do - @methods.should_not include :extra - @methods.should_not include :extra_protected + @methods.should_not.include? :extra + @methods.should_not.include? :extra_protected end end diff --git a/spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb b/spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb index ac6659ec1e4e96..d540b4506507b5 100644 --- a/spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb +++ b/spec/ruby/library/delegate/delegate_class/protected_instance_methods_spec.rb @@ -7,23 +7,23 @@ end it "does not include public methods of the delegated class" do - @methods.should_not include :pub + @methods.should_not.include? :pub end it "includes the protected methods of the delegated class" do - @methods.should include :prot + @methods.should.include? :prot end it "includes protected instance methods of the DelegateClass class" do - @methods.should include :extra_protected + @methods.should.include? :extra_protected end it "does not include public instance methods of the DelegateClass class" do - @methods.should_not include :extra + @methods.should_not.include? :extra end it "does not include private methods" do - @methods.should_not include :priv - @methods.should_not include :extra_private + @methods.should_not.include? :priv + @methods.should_not.include? :extra_private end end diff --git a/spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb b/spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb index 6c0d9bcab1b4dd..124b92de8247a7 100644 --- a/spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb +++ b/spec/ruby/library/delegate/delegate_class/public_instance_methods_spec.rb @@ -7,19 +7,19 @@ end it "includes all public methods of the delegated class" do - @methods.should include :pub + @methods.should.include? :pub end it "does not include the protected methods of the delegated class" do - @methods.should_not include :prot + @methods.should_not.include? :prot end it "includes public instance methods of the DelegateClass class" do - @methods.should include :extra + @methods.should.include? :extra end it "does not include private methods" do - @methods.should_not include :priv - @methods.should_not include :extra_private + @methods.should_not.include? :priv + @methods.should_not.include? :extra_private end end diff --git a/spec/ruby/library/delegate/delegator/eql_spec.rb b/spec/ruby/library/delegate/delegator/eql_spec.rb index 34f56f44c95b8b..b302bb70165c31 100644 --- a/spec/ruby/library/delegate/delegator/eql_spec.rb +++ b/spec/ruby/library/delegate/delegator/eql_spec.rb @@ -6,14 +6,14 @@ base = mock('base') delegator = DelegateSpecs::Delegator.new(base) - delegator.eql?(delegator).should be_true + delegator.eql?(delegator).should == true end it "returns true when compared with the inner object" do base = mock('base') delegator = DelegateSpecs::Delegator.new(base) - delegator.eql?(base).should be_true + delegator.eql?(base).should == true end it "returns false when compared with the delegator with other object" do @@ -22,7 +22,7 @@ delegator0 = DelegateSpecs::Delegator.new(base) delegator1 = DelegateSpecs::Delegator.new(other) - delegator0.eql?(delegator1).should be_false + delegator0.eql?(delegator1).should == false end it "returns false when compared with the other object" do @@ -30,6 +30,6 @@ other = mock('other') delegator = DelegateSpecs::Delegator.new(base) - delegator.eql?(other).should be_false + delegator.eql?(other).should == false end end diff --git a/spec/ruby/library/delegate/delegator/equal_spec.rb b/spec/ruby/library/delegate/delegator/equal_spec.rb index c8711c74b5a900..97aabebabe2a1f 100644 --- a/spec/ruby/library/delegate/delegator/equal_spec.rb +++ b/spec/ruby/library/delegate/delegator/equal_spec.rb @@ -6,8 +6,8 @@ obj = mock('base') delegator = DelegateSpecs::Delegator.new(obj) obj.should_not_receive(:equal?) - delegator.equal?(obj).should be_false - delegator.equal?(nil).should be_false - delegator.equal?(delegator).should be_true + delegator.equal?(obj).should == false + delegator.equal?(nil).should == false + delegator.equal?(delegator).should == true end end diff --git a/spec/ruby/library/delegate/delegator/equal_value_spec.rb b/spec/ruby/library/delegate/delegator/equal_value_spec.rb index 0c967d5f9442a0..d70aad1e03d29e 100644 --- a/spec/ruby/library/delegate/delegator/equal_value_spec.rb +++ b/spec/ruby/library/delegate/delegator/equal_value_spec.rb @@ -9,16 +9,16 @@ it "is not delegated when passed self" do @base.should_not_receive(:==) - (@delegator == @delegator).should be_true + (@delegator == @delegator).should == true end it "is delegated when passed the delegated object" do @base.should_receive(:==).and_return(false) - (@delegator == @base).should be_false + (@delegator == @base).should == false end it "is delegated in general" do @base.should_receive(:==).and_return(true) - (@delegator == 42).should be_true + (@delegator == 42).should == true end end diff --git a/spec/ruby/library/delegate/delegator/frozen_spec.rb b/spec/ruby/library/delegate/delegator/frozen_spec.rb index b3145c54b1816a..ad87dc8bdf580e 100644 --- a/spec/ruby/library/delegate/delegator/frozen_spec.rb +++ b/spec/ruby/library/delegate/delegator/frozen_spec.rb @@ -10,30 +10,30 @@ it "is still readable" do @delegate.should == [42, :hello] - @delegate.include?("bar").should be_false + @delegate.include?("bar").should == false end it "is frozen" do - @delegate.frozen?.should be_true + @delegate.frozen?.should == true end it "is not writable" do - ->{ @delegate[0] += 2 }.should raise_error( RuntimeError ) + ->{ @delegate[0] += 2 }.should.raise( RuntimeError ) end it "creates a frozen clone" do - @delegate.clone.frozen?.should be_true + @delegate.clone.frozen?.should == true end it "creates an unfrozen dup" do - @delegate.dup.frozen?.should be_false + @delegate.dup.frozen?.should == false end it "causes mutative calls to raise RuntimeError" do - ->{ @delegate.__setobj__("hola!") }.should raise_error( RuntimeError ) + ->{ @delegate.__setobj__("hola!") }.should.raise( RuntimeError ) end it "returns false if only the delegated object is frozen" do - DelegateSpecs::Delegator.new([1,2,3].freeze).frozen?.should be_false + DelegateSpecs::Delegator.new([1,2,3].freeze).frozen?.should == false end end diff --git a/spec/ruby/library/delegate/delegator/marshal_spec.rb b/spec/ruby/library/delegate/delegator/marshal_spec.rb index 6c75c8f573c44e..2817ac7e0b8860 100644 --- a/spec/ruby/library/delegate/delegator/marshal_spec.rb +++ b/spec/ruby/library/delegate/delegator/marshal_spec.rb @@ -10,7 +10,7 @@ it "can be marshalled" do m = Marshal.load(Marshal.dump(@delegate)) m.class.should == SimpleDelegator - (m == @obj).should be_true + (m == @obj).should == true end it "can be marshalled with its instance variables intact" do diff --git a/spec/ruby/library/delegate/delegator/method_spec.rb b/spec/ruby/library/delegate/delegator/method_spec.rb index 81c8eea710ea2f..e41d3b4a532c41 100644 --- a/spec/ruby/library/delegate/delegator/method_spec.rb +++ b/spec/ruby/library/delegate/delegator/method_spec.rb @@ -9,7 +9,7 @@ it "returns a method object for public methods of the delegate object" do m = @delegate.method(:pub) - m.should be_an_instance_of(Method) + m.should.instance_of?(Method) m.call.should == :foo end @@ -18,7 +18,7 @@ -> { @delegate.method(:prot) }.should complain(/delegator does not forward private method #prot/) - }.should raise_error(NameError) + }.should.raise(NameError) end it "raises a NameError for a private methods of the delegate object" do @@ -26,36 +26,36 @@ -> { @delegate.method(:priv) }.should complain(/delegator does not forward private method #priv/) - }.should raise_error(NameError) + }.should.raise(NameError) end it "returns a method object for public methods of the Delegator class" do m = @delegate.method(:extra) - m.should be_an_instance_of(Method) + m.should.instance_of?(Method) m.call.should == :cheese end it "returns a method object for protected methods of the Delegator class" do m = @delegate.method(:extra_protected) - m.should be_an_instance_of(Method) + m.should.instance_of?(Method) m.call.should == :baz end it "returns a method object for private methods of the Delegator class" do m = @delegate.method(:extra_private) - m.should be_an_instance_of(Method) + m.should.instance_of?(Method) m.call.should == :bar end it "raises a NameError for an invalid method name" do -> { @delegate.method(:invalid_and_silly_method_name) - }.should raise_error(NameError) + }.should.raise(NameError) end it "returns a method that respond_to_missing?" do m = @delegate.method(:pub_too) - m.should be_an_instance_of(Method) + m.should.instance_of?(Method) m.call.should == :pub_too end @@ -64,6 +64,6 @@ @delegate.__setobj__([1,2,3]) -> { m.call - }.should raise_error(NameError) + }.should.raise(NameError) end end diff --git a/spec/ruby/library/delegate/delegator/methods_spec.rb b/spec/ruby/library/delegate/delegator/methods_spec.rb index b9942bd230f17b..928f63f21d3763 100644 --- a/spec/ruby/library/delegate/delegator/methods_spec.rb +++ b/spec/ruby/library/delegate/delegator/methods_spec.rb @@ -14,24 +14,24 @@ def singleton_method end it "returns singleton methods when passed false" do - @delegate.methods(false).should include(:singleton_method) + @delegate.methods(false).should.include?(:singleton_method) end it "includes all public methods of the delegate object" do - @methods.should include :pub + @methods.should.include? :pub end it "includes all protected methods of the delegate object" do - @methods.should include :prot + @methods.should.include? :prot end it "includes instance methods of the Delegator class" do - @methods.should include :extra - @methods.should include :extra_protected + @methods.should.include? :extra + @methods.should.include? :extra_protected end it "does not include private methods" do - @methods.should_not include :priv - @methods.should_not include :extra_private + @methods.should_not.include? :priv + @methods.should_not.include? :extra_private end end diff --git a/spec/ruby/library/delegate/delegator/not_equal_spec.rb b/spec/ruby/library/delegate/delegator/not_equal_spec.rb index 6f2df2171572f3..7fd234a6710dd1 100644 --- a/spec/ruby/library/delegate/delegator/not_equal_spec.rb +++ b/spec/ruby/library/delegate/delegator/not_equal_spec.rb @@ -9,16 +9,16 @@ it "is not delegated when passed self" do @base.should_not_receive(:"!=") - (@delegator != @delegator).should be_false + (@delegator != @delegator).should == false end it "is delegated when passed the delegated object" do @base.should_receive(:"!=").and_return(true) - (@delegator != @base).should be_true + (@delegator != @base).should == true end it "is delegated in general" do @base.should_receive(:"!=").and_return(false) - (@delegator != 42).should be_false + (@delegator != 42).should == false end end diff --git a/spec/ruby/library/delegate/delegator/private_methods_spec.rb b/spec/ruby/library/delegate/delegator/private_methods_spec.rb index 7724b8d413c835..5615ed066890d9 100644 --- a/spec/ruby/library/delegate/delegator/private_methods_spec.rb +++ b/spec/ruby/library/delegate/delegator/private_methods_spec.rb @@ -9,12 +9,12 @@ end it "does not include any method of the delegate object" do # since delegates does not forward private calls - @methods.should_not include :priv - @methods.should_not include :prot - @methods.should_not include :pub + @methods.should_not.include? :priv + @methods.should_not.include? :prot + @methods.should_not.include? :pub end it "includes all private instance methods of the Delegate class" do - @methods.should include :extra_private + @methods.should.include? :extra_private end end diff --git a/spec/ruby/library/delegate/delegator/protected_methods_spec.rb b/spec/ruby/library/delegate/delegator/protected_methods_spec.rb index fd7874fb213f27..3ee999fdac66ea 100644 --- a/spec/ruby/library/delegate/delegator/protected_methods_spec.rb +++ b/spec/ruby/library/delegate/delegator/protected_methods_spec.rb @@ -9,10 +9,10 @@ end it "includes protected methods of the delegate object" do - @methods.should include :prot + @methods.should.include? :prot end it "includes protected instance methods of the Delegator class" do - @methods.should include :extra_protected + @methods.should.include? :extra_protected end end diff --git a/spec/ruby/library/delegate/delegator/public_methods_spec.rb b/spec/ruby/library/delegate/delegator/public_methods_spec.rb index 18da16a613fca2..8cf6621e2dc4db 100644 --- a/spec/ruby/library/delegate/delegator/public_methods_spec.rb +++ b/spec/ruby/library/delegate/delegator/public_methods_spec.rb @@ -9,10 +9,10 @@ end it "includes public methods of the delegate object" do - @methods.should include :pub + @methods.should.include? :pub end it "includes public instance methods of the Delegator class" do - @methods.should include :extra + @methods.should.include? :extra end end diff --git a/spec/ruby/library/delegate/delegator/send_spec.rb b/spec/ruby/library/delegate/delegator/send_spec.rb index 3022c2ce91b6f5..cc18a2794b6dd8 100644 --- a/spec/ruby/library/delegate/delegator/send_spec.rb +++ b/spec/ruby/library/delegate/delegator/send_spec.rb @@ -12,15 +12,15 @@ end it "forwards protected method calls" do - ->{ @delegate.prot }.should raise_error( NoMethodError ) + ->{ @delegate.prot }.should.raise( NoMethodError ) end it "doesn't forward private method calls" do - ->{ @delegate.priv }.should raise_error( NoMethodError ) + ->{ @delegate.priv }.should.raise( NoMethodError ) end it "doesn't forward private method calls even via send or __send__" do - ->{ @delegate.send(:priv, 42) }.should raise_error( NoMethodError ) - ->{ @delegate.__send__(:priv, 42) }.should raise_error( NoMethodError ) + ->{ @delegate.send(:priv, 42) }.should.raise( NoMethodError ) + ->{ @delegate.__send__(:priv, 42) }.should.raise( NoMethodError ) end end diff --git a/spec/ruby/library/delegate/delegator/tap_spec.rb b/spec/ruby/library/delegate/delegator/tap_spec.rb index 34a88fa1d57cd4..916e4a37fe9be8 100644 --- a/spec/ruby/library/delegate/delegator/tap_spec.rb +++ b/spec/ruby/library/delegate/delegator/tap_spec.rb @@ -11,6 +11,6 @@ yielded << x end yielded.size.should == 1 - yielded[0].equal?(delegator).should be_true + yielded[0].equal?(delegator).should == true end end diff --git a/spec/ruby/library/digest/bubblebabble_spec.rb b/spec/ruby/library/digest/bubblebabble_spec.rb index bbc11ceec5702b..44a9bf0e266a48 100644 --- a/spec/ruby/library/digest/bubblebabble_spec.rb +++ b/spec/ruby/library/digest/bubblebabble_spec.rb @@ -3,7 +3,7 @@ describe "Digest.bubblebabble" do it "returns a String" do - Digest.bubblebabble('').should be_an_instance_of(String) + Digest.bubblebabble('').should.instance_of?(String) end it "returns a String in the Bubble Babble Binary Data Encoding format" do @@ -20,10 +20,10 @@ end it "raises a TypeError when passed nil" do - -> { Digest.bubblebabble(nil) }.should raise_error(TypeError) + -> { Digest.bubblebabble(nil) }.should.raise(TypeError) end it "raises a TypeError when passed an Integer" do - -> { Digest.bubblebabble(9001) }.should raise_error(TypeError) + -> { Digest.bubblebabble(9001) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/hexencode_spec.rb b/spec/ruby/library/digest/hexencode_spec.rb index 4b6db6eaff3253..3359303d15bd57 100644 --- a/spec/ruby/library/digest/hexencode_spec.rb +++ b/spec/ruby/library/digest/hexencode_spec.rb @@ -22,10 +22,10 @@ end it "raises a TypeError when passed nil" do - -> { Digest.hexencode(nil) }.should raise_error(TypeError) + -> { Digest.hexencode(nil) }.should.raise(TypeError) end it "raises a TypeError when passed an Integer" do - -> { Digest.hexencode(9001) }.should raise_error(TypeError) + -> { Digest.hexencode(9001) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/instance/shared/update.rb b/spec/ruby/library/digest/instance/shared/update.rb index 17779e54a48fe5..e064a90087e59d 100644 --- a/spec/ruby/library/digest/instance/shared/update.rb +++ b/spec/ruby/library/digest/instance/shared/update.rb @@ -3,6 +3,6 @@ c = Class.new do include Digest::Instance end - -> { c.new.send(@method, "test") }.should raise_error(RuntimeError) + -> { c.new.send(@method, "test") }.should.raise(RuntimeError) end end diff --git a/spec/ruby/library/digest/md5/file_spec.rb b/spec/ruby/library/digest/md5/file_spec.rb index 0c8d12cbc935f4..9a78a8c0559191 100644 --- a/spec/ruby/library/digest/md5/file_spec.rb +++ b/spec/ruby/library/digest/md5/file_spec.rb @@ -15,7 +15,7 @@ end it "returns a Digest::MD5 object" do - Digest::MD5.file(@file).should be_kind_of(Digest::MD5) + Digest::MD5.file(@file).should.is_a?(Digest::MD5) end it "returns a Digest::MD5 object with the correct digest" do @@ -26,7 +26,7 @@ obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::MD5.file(obj) - result.should be_kind_of(Digest::MD5) + result.should.is_a?(Digest::MD5) result.digest.should == MD5Constants::Digest end end @@ -34,10 +34,10 @@ it_behaves_like :file_read_directory, :file, Digest::MD5 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::MD5.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::MD5.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::MD5.file(nil) }.should raise_error(TypeError) + -> { Digest::MD5.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/sha1/file_spec.rb b/spec/ruby/library/digest/sha1/file_spec.rb index 9c15f5b02f7f1a..d36e560e210664 100644 --- a/spec/ruby/library/digest/sha1/file_spec.rb +++ b/spec/ruby/library/digest/sha1/file_spec.rb @@ -15,7 +15,7 @@ end it "returns a Digest::SHA1 object" do - Digest::SHA1.file(@file).should be_kind_of(Digest::SHA1) + Digest::SHA1.file(@file).should.is_a?(Digest::SHA1) end it "returns a Digest::SHA1 object with the correct digest" do @@ -26,7 +26,7 @@ obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::SHA1.file(obj) - result.should be_kind_of(Digest::SHA1) + result.should.is_a?(Digest::SHA1) result.digest.should == SHA1Constants::Digest end end @@ -34,10 +34,10 @@ it_behaves_like :file_read_directory, :file, Digest::SHA1 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::SHA1.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA1.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::SHA1.file(nil) }.should raise_error(TypeError) + -> { Digest::SHA1.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/sha256/file_spec.rb b/spec/ruby/library/digest/sha256/file_spec.rb index 8cbc5a2755894c..d67a9ebcd6b2f6 100644 --- a/spec/ruby/library/digest/sha256/file_spec.rb +++ b/spec/ruby/library/digest/sha256/file_spec.rb @@ -15,7 +15,7 @@ end it "returns a Digest::SHA256 object" do - Digest::SHA256.file(@file).should be_kind_of(Digest::SHA256) + Digest::SHA256.file(@file).should.is_a?(Digest::SHA256) end it "returns a Digest::SHA256 object with the correct digest" do @@ -30,7 +30,7 @@ obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::SHA256.file(obj) - result.should be_kind_of(Digest::SHA256) + result.should.is_a?(Digest::SHA256) result.digest.should == SHA256Constants::Digest end end @@ -38,10 +38,10 @@ it_behaves_like :file_read_directory, :file, Digest::SHA256 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::SHA256.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA256.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::SHA256.file(nil) }.should raise_error(TypeError) + -> { Digest::SHA256.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/sha384/file_spec.rb b/spec/ruby/library/digest/sha384/file_spec.rb index 8556f1017521ff..3726ad44235d17 100644 --- a/spec/ruby/library/digest/sha384/file_spec.rb +++ b/spec/ruby/library/digest/sha384/file_spec.rb @@ -15,7 +15,7 @@ end it "returns a Digest::SHA384 object" do - Digest::SHA384.file(@file).should be_kind_of(Digest::SHA384) + Digest::SHA384.file(@file).should.is_a?(Digest::SHA384) end it "returns a Digest::SHA384 object with the correct digest" do @@ -26,7 +26,7 @@ obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::SHA384.file(obj) - result.should be_kind_of(Digest::SHA384) + result.should.is_a?(Digest::SHA384) result.digest.should == SHA384Constants::Digest end end @@ -34,10 +34,10 @@ it_behaves_like :file_read_directory, :file, Digest::SHA384 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::SHA384.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA384.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::SHA384.file(nil) }.should raise_error(TypeError) + -> { Digest::SHA384.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/sha512/file_spec.rb b/spec/ruby/library/digest/sha512/file_spec.rb index 781ec781e501a9..78d6d3d4f31cf5 100644 --- a/spec/ruby/library/digest/sha512/file_spec.rb +++ b/spec/ruby/library/digest/sha512/file_spec.rb @@ -15,7 +15,7 @@ end it "returns a Digest::SHA512 object" do - Digest::SHA512.file(@file).should be_kind_of(Digest::SHA512) + Digest::SHA512.file(@file).should.is_a?(Digest::SHA512) end it "returns a Digest::SHA512 object with the correct digest" do @@ -26,7 +26,7 @@ obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::SHA512.file(obj) - result.should be_kind_of(Digest::SHA512) + result.should.is_a?(Digest::SHA512) result.digest.should == SHA512Constants::Digest end end @@ -34,10 +34,10 @@ it_behaves_like :file_read_directory, :file, Digest::SHA512 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::SHA512.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA512.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::SHA512.file(nil) }.should raise_error(TypeError) + -> { Digest::SHA512.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/erb/filename_spec.rb b/spec/ruby/library/erb/filename_spec.rb index 8ecaed734366e8..bbd2233bb34a11 100644 --- a/spec/ruby/library/erb/filename_spec.rb +++ b/spec/ruby/library/erb/filename_spec.rb @@ -13,7 +13,7 @@ @ex = e raise e end - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) expected = filename @ex.message =~ /^(.*?):(\d+): / @@ -30,7 +30,7 @@ @ex = e raise e end - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) expected = '(erb)' @ex.message =~ /^(.*?):(\d+): / diff --git a/spec/ruby/library/erb/new_spec.rb b/spec/ruby/library/erb/new_spec.rb index f8192bff9925cd..35ac0dfdfe021c 100644 --- a/spec/ruby/library/erb/new_spec.rb +++ b/spec/ruby/library/erb/new_spec.rb @@ -83,7 +83,7 @@ -> { ERBSpecs.new_erb(input, trim_mode: '-').result - }.should raise_error(SyntaxError) + }.should.raise(SyntaxError) end it "regards lines starting with '%' as '<% ... %>' when trim_mode is '%'" do @@ -136,7 +136,7 @@ it "forget local variables defined previous one" do ERB.new(@eruby_str).result - ->{ ERB.new("<%= list %>").result }.should raise_error(NameError) + ->{ ERB.new("<%= list %>").result }.should.raise(NameError) end version_is ERB.const_get(:VERSION, false), ""..."6.0.0" do diff --git a/spec/ruby/library/erb/result_spec.rb b/spec/ruby/library/erb/result_spec.rb index a29c1ccedbe27b..84333031ec177d 100644 --- a/spec/ruby/library/erb/result_spec.rb +++ b/spec/ruby/library/erb/result_spec.rb @@ -43,7 +43,7 @@ input = "<%=h '<>' %>" -> { ERB.new(input).result() - }.should raise_error(NameError) + }.should.raise(NameError) end @@ -81,6 +81,6 @@ def main2 -> { myerb2.new.main2() - }.should raise_error(NameError) + }.should.raise(NameError) end end diff --git a/spec/ruby/library/erb/run_spec.rb b/spec/ruby/library/erb/run_spec.rb index 602e53ab385855..d81d534087279d 100644 --- a/spec/ruby/library/erb/run_spec.rb +++ b/spec/ruby/library/erb/run_spec.rb @@ -54,7 +54,7 @@ def s.write(arg); self << arg.to_s; end input = "<%=h '<>' %>" -> { _steal_stdout { ERB.new(input).run() } - }.should raise_error(NameError) + }.should.raise(NameError) end it "is able to h() or u() if ERB::Util is included" do @@ -91,6 +91,6 @@ def main2 -> { _steal_stdout { myerb2.new.main2() } - }.should raise_error(NameError) + }.should.raise(NameError) end end diff --git a/spec/ruby/library/etc/confstr_spec.rb b/spec/ruby/library/etc/confstr_spec.rb index 5b434611505304..786cb16407bc80 100644 --- a/spec/ruby/library/etc/confstr_spec.rb +++ b/spec/ruby/library/etc/confstr_spec.rb @@ -4,11 +4,11 @@ platform_is_not :windows, :android do describe "Etc.confstr" do it "returns a String for Etc::CS_PATH" do - Etc.confstr(Etc::CS_PATH).should be_an_instance_of(String) + Etc.confstr(Etc::CS_PATH).should.instance_of?(String) end it "raises Errno::EINVAL for unknown configuration variables" do - -> { Etc.confstr(-1) }.should raise_error(Errno::EINVAL) + -> { Etc.confstr(-1) }.should.raise(Errno::EINVAL) end end end diff --git a/spec/ruby/library/etc/getgrgid_spec.rb b/spec/ruby/library/etc/getgrgid_spec.rb index 14da5e041d3cb3..472d4c82c8c444 100644 --- a/spec/ruby/library/etc/getgrgid_spec.rb +++ b/spec/ruby/library/etc/getgrgid_spec.rb @@ -34,7 +34,7 @@ it "returns the Etc::Group for a given gid if it exists" do grp = Etc.getgrgid(@gid) - grp.should be_kind_of(Etc::Group) + grp.should.is_a?(Etc::Group) grp.gid.should == @gid grp.name.should == @name end @@ -47,12 +47,12 @@ end it "raises if the group does not exist" do - -> { Etc.getgrgid(9876)}.should raise_error(ArgumentError) + -> { Etc.getgrgid(9876)}.should.raise(ArgumentError) end it "raises a TypeError if not passed an Integer" do - -> { Etc.getgrgid("foo") }.should raise_error(TypeError) - -> { Etc.getgrgid(nil) }.should raise_error(TypeError) + -> { Etc.getgrgid("foo") }.should.raise(TypeError) + -> { Etc.getgrgid(nil) }.should.raise(TypeError) end it "can be called safely by multiple threads" do diff --git a/spec/ruby/library/etc/getgrnam_spec.rb b/spec/ruby/library/etc/getgrnam_spec.rb index fa49f15349beea..325ea7b2973f12 100644 --- a/spec/ruby/library/etc/getgrnam_spec.rb +++ b/spec/ruby/library/etc/getgrnam_spec.rb @@ -24,7 +24,7 @@ -> { Etc.getgrnam(123) Etc.getgrnam(nil) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/etc/getlogin_spec.rb b/spec/ruby/library/etc/getlogin_spec.rb index 7a4fd79ae20e8c..2bc598c0af2e89 100644 --- a/spec/ruby/library/etc/getlogin_spec.rb +++ b/spec/ruby/library/etc/getlogin_spec.rb @@ -14,7 +14,7 @@ if ENV['TRAVIS'] and platform_is(:darwin) # See https://travis-ci.org/ruby/spec/jobs/285967744 # and https://travis-ci.org/ruby/spec/jobs/285999602 - Etc.getlogin.should be_an_instance_of(String) + Etc.getlogin.should.instance_of?(String) else # Etc.getlogin returns the same result of logname(2) # if it returns non NULL @@ -28,7 +28,7 @@ else # Etc.getlogin may return nil if the login name is not set # because of chroot or sudo or something. - Etc.getlogin.should be_nil + Etc.getlogin.should == nil getlogin_null = true end ensure diff --git a/spec/ruby/library/etc/getpwnam_spec.rb b/spec/ruby/library/etc/getpwnam_spec.rb index 3f4416aa9d2155..a0b3c9e1fe65f6 100644 --- a/spec/ruby/library/etc/getpwnam_spec.rb +++ b/spec/ruby/library/etc/getpwnam_spec.rb @@ -22,7 +22,7 @@ -> { Etc.getpwnam(123) Etc.getpwnam(nil) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/etc/getpwuid_spec.rb b/spec/ruby/library/etc/getpwuid_spec.rb index 5b98f0f8d9b248..3e35dfe6d547e0 100644 --- a/spec/ruby/library/etc/getpwuid_spec.rb +++ b/spec/ruby/library/etc/getpwuid_spec.rb @@ -30,7 +30,7 @@ -> { Etc.getpwuid("foo") Etc.getpwuid(nil) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/etc/group_spec.rb b/spec/ruby/library/etc/group_spec.rb index fda808eec9e05b..d7addbbec16929 100644 --- a/spec/ruby/library/etc/group_spec.rb +++ b/spec/ruby/library/etc/group_spec.rb @@ -9,7 +9,7 @@ it "returns a Etc::Group struct" do group = Etc.group begin - group.should be_an_instance_of(Etc::Group) + group.should.instance_of?(Etc::Group) ensure Etc.endgrent end @@ -21,7 +21,7 @@ Etc.group do | group2 | end end - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end end end diff --git a/spec/ruby/library/etc/nprocessors_spec.rb b/spec/ruby/library/etc/nprocessors_spec.rb index ec7ffc81da82e6..482719dde09e5b 100644 --- a/spec/ruby/library/etc/nprocessors_spec.rb +++ b/spec/ruby/library/etc/nprocessors_spec.rb @@ -3,7 +3,7 @@ describe "Etc.nprocessors" do it "returns the number of online processors" do - Etc.nprocessors.should be_kind_of(Integer) + Etc.nprocessors.should.is_a?(Integer) Etc.nprocessors.should >= 1 end end diff --git a/spec/ruby/library/etc/passwd_spec.rb b/spec/ruby/library/etc/passwd_spec.rb index 7157fd3f2e01d2..0602b7e10bf5ed 100644 --- a/spec/ruby/library/etc/passwd_spec.rb +++ b/spec/ruby/library/etc/passwd_spec.rb @@ -6,7 +6,7 @@ it "returns a Etc::Passwd struct" do passwd = Etc.passwd begin - passwd.should be_an_instance_of(Etc::Passwd) + passwd.should.instance_of?(Etc::Passwd) ensure Etc.endpwent end diff --git a/spec/ruby/library/etc/sysconf_spec.rb b/spec/ruby/library/etc/sysconf_spec.rb index 1f2c7a770ff53c..81ce1ca25801a1 100644 --- a/spec/ruby/library/etc/sysconf_spec.rb +++ b/spec/ruby/library/etc/sysconf_spec.rb @@ -14,7 +14,7 @@ if value.nil? value.should == nil else - value.should be_kind_of(Integer) + value.should.is_a?(Integer) end end end diff --git a/spec/ruby/library/etc/sysconfdir_spec.rb b/spec/ruby/library/etc/sysconfdir_spec.rb index 8538faa65b2931..eb2d6b649ab898 100644 --- a/spec/ruby/library/etc/sysconfdir_spec.rb +++ b/spec/ruby/library/etc/sysconfdir_spec.rb @@ -3,6 +3,6 @@ describe "Etc.sysconfdir" do it "returns a String" do - Etc.sysconfdir.should be_an_instance_of(String) + Etc.sysconfdir.should.instance_of?(String) end end diff --git a/spec/ruby/library/etc/systmpdir_spec.rb b/spec/ruby/library/etc/systmpdir_spec.rb index 5b007aa9f9ffcf..ed34cb43fc7539 100644 --- a/spec/ruby/library/etc/systmpdir_spec.rb +++ b/spec/ruby/library/etc/systmpdir_spec.rb @@ -3,6 +3,6 @@ describe "Etc.systmpdir" do it "returns a String" do - Etc.systmpdir.should be_an_instance_of(String) + Etc.systmpdir.should.instance_of?(String) end end diff --git a/spec/ruby/library/etc/uname_spec.rb b/spec/ruby/library/etc/uname_spec.rb index a42558f5932b9c..1c5fe2a741b21a 100644 --- a/spec/ruby/library/etc/uname_spec.rb +++ b/spec/ruby/library/etc/uname_spec.rb @@ -4,7 +4,7 @@ describe "Etc.uname" do it "returns a Hash with the documented keys" do uname = Etc.uname - uname.should be_kind_of(Hash) + uname.should.is_a?(Hash) uname.should.key?(:sysname) uname.should.key?(:nodename) uname.should.key?(:release) diff --git a/spec/ruby/library/expect/expect_spec.rb b/spec/ruby/library/expect/expect_spec.rb index 76ea3d54513e87..ba705c55355c3e 100644 --- a/spec/ruby/library/expect/expect_spec.rb +++ b/spec/ruby/library/expect/expect_spec.rb @@ -40,14 +40,14 @@ -> { @read.expect("hello") - }.should raise_error(IOError) + }.should.raise(IOError) end it "returns nil if eof is hit" do @write << "pro" @write.close - @read.expect("prompt").should be_nil + @read.expect("prompt").should == nil end it "yields the result if a block is given" do diff --git a/spec/ruby/library/fiddle/handle/initialize_spec.rb b/spec/ruby/library/fiddle/handle/initialize_spec.rb index 51c2470efdf381..84c809a7271c24 100644 --- a/spec/ruby/library/fiddle/handle/initialize_spec.rb +++ b/spec/ruby/library/fiddle/handle/initialize_spec.rb @@ -5,6 +5,6 @@ it "raises Fiddle::DLError if the library cannot be found" do -> { Fiddle::Handle.new("doesnotexist.doesnotexist") - }.should raise_error(Fiddle::DLError) + }.should.raise(Fiddle::DLError) end end diff --git a/spec/ruby/library/find/find_spec.rb b/spec/ruby/library/find/find_spec.rb index 7cd76fa01b50df..c4ccfa76fd1669 100644 --- a/spec/ruby/library/find/find_spec.rb +++ b/spec/ruby/library/find/find_spec.rb @@ -13,7 +13,7 @@ describe "when called without a block" do it "returns an Enumerator" do - Find.find(FindDirSpecs.mock_dir).should be_an_instance_of(Enumerator) + Find.find(FindDirSpecs.mock_dir).should.instance_of?(Enumerator) Find.find(FindDirSpecs.mock_dir).to_a.sort.should == FindDirSpecs.expected_paths end end diff --git a/spec/ruby/library/getoptlong/error_message_spec.rb b/spec/ruby/library/getoptlong/error_message_spec.rb index 1ed9419f6cc7df..10435b135058ef 100644 --- a/spec/ruby/library/getoptlong/error_message_spec.rb +++ b/spec/ruby/library/getoptlong/error_message_spec.rb @@ -14,7 +14,7 @@ opts.get -> { opts.ordering = GetoptLong::PERMUTE - }.should raise_error(ArgumentError) { |e| + }.should.raise(ArgumentError) { |e| e.message.should == "argument error" opts.error_message.should == "argument error" } diff --git a/spec/ruby/library/getoptlong/ordering_spec.rb b/spec/ruby/library/getoptlong/ordering_spec.rb index 695d1cafa7511f..60ce73afaa0572 100644 --- a/spec/ruby/library/getoptlong/ordering_spec.rb +++ b/spec/ruby/library/getoptlong/ordering_spec.rb @@ -11,7 +11,7 @@ -> { opts.ordering = GetoptLong::PERMUTE - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -20,7 +20,7 @@ -> { opts.ordering = 12345 - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "does not allow changing ordering to PERMUTE if ENV['POSIXLY_CORRECT'] is set" do diff --git a/spec/ruby/library/getoptlong/set_options_spec.rb b/spec/ruby/library/getoptlong/set_options_spec.rb index 36b9c579c41d9c..f60dcc87a39f7e 100644 --- a/spec/ruby/library/getoptlong/set_options_spec.rb +++ b/spec/ruby/library/getoptlong/set_options_spec.rb @@ -41,7 +41,7 @@ argv [] do -> { @opts.set_options(["--size", GetoptLong::NO_ARGUMENT, GetoptLong::REQUIRED_ARGUMENT]) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -50,7 +50,7 @@ @opts.get -> { @opts.set_options() - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end end @@ -58,7 +58,7 @@ argv [] do -> { @opts.set_options(["--size"]) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -68,7 +68,7 @@ @opts.set_options( ["--size", GetoptLong::REQUIRED_ARGUMENT], "test") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -78,13 +78,13 @@ @opts.set_options( ["--size", GetoptLong::NO_ARGUMENT], ["--size", GetoptLong::OPTIONAL_ARGUMENT]) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @opts.set_options( ["--size", GetoptLong::NO_ARGUMENT], ["-s", "--size", GetoptLong::OPTIONAL_ARGUMENT]) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -92,7 +92,7 @@ argv [] do -> { @opts.set_options(["-size", GetoptLong::NO_ARGUMENT]) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/library/getoptlong/shared/get.rb b/spec/ruby/library/getoptlong/shared/get.rb index f44cf583d2590c..8d24c4c25523f1 100644 --- a/spec/ruby/library/getoptlong/shared/get.rb +++ b/spec/ruby/library/getoptlong/shared/get.rb @@ -49,7 +49,7 @@ it "raises a if an argument was required, but none given" do argv [ "--size" ] do - -> { @opts.send(@method) }.should raise_error(GetoptLong::MissingArgument) + -> { @opts.send(@method) }.should.raise(GetoptLong::MissingArgument) end end diff --git a/spec/ruby/library/io-wait/wait_spec.rb b/spec/ruby/library/io-wait/wait_spec.rb index 6a3890a401a7eb..1d784e7aa4f1c2 100644 --- a/spec/ruby/library/io-wait/wait_spec.rb +++ b/spec/ruby/library/io-wait/wait_spec.rb @@ -56,12 +56,12 @@ it "raises IOError when io is closed (closed stream (IOError))" do @io.close - -> { @io.wait(IO::READABLE, 0) }.should raise_error(IOError, "closed stream") + -> { @io.wait(IO::READABLE, 0) }.should.raise(IOError, "closed stream") end 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!") + -> { @w.wait(0, 0) }.should.raise(ArgumentError, "Events must be positive integer!") + -> { @w.wait(-1, 0) }.should.raise(ArgumentError, "Events must be positive integer!") end it "changes thread status to 'sleep' when waits for READABLE event" do @@ -147,16 +147,16 @@ end it "raises ArgumentError when passed wrong Symbol value as mode argument" do - -> { @io.wait(0, :wrong) }.should raise_error(ArgumentError, "unsupported mode: wrong") + -> { @io.wait(0, :wrong) }.should.raise(ArgumentError, "unsupported mode: wrong") end it "raises ArgumentError when several Integer arguments passed" do - -> { @w.wait(0, 10, :r) }.should raise_error(ArgumentError, "timeout given more than once") + -> { @w.wait(0, 10, :r) }.should.raise(ArgumentError, "timeout given more than once") end it "raises IOError when io is closed (closed stream (IOError))" do @io.close - -> { @io.wait(0, :r) }.should raise_error(IOError, "closed stream") + -> { @io.wait(0, :r) }.should.raise(IOError, "closed stream") end end end diff --git a/spec/ruby/library/ipaddr/new_spec.rb b/spec/ruby/library/ipaddr/new_spec.rb index 2c0f44acf2e73c..7fba2b372ead8e 100644 --- a/spec/ruby/library/ipaddr/new_spec.rb +++ b/spec/ruby/library/ipaddr/new_spec.rb @@ -3,9 +3,9 @@ describe "IPAddr#new" do it "initializes IPAddr" do - ->{ IPAddr.new("3FFE:505:ffff::/48") }.should_not raise_error - ->{ IPAddr.new("0:0:0:1::") }.should_not raise_error - ->{ IPAddr.new("2001:200:300::/48") }.should_not raise_error + ->{ IPAddr.new("3FFE:505:ffff::/48") }.should_not.raise + ->{ IPAddr.new("0:0:0:1::") }.should_not.raise + ->{ IPAddr.new("2001:200:300::/48") }.should_not.raise end it "initializes IPAddr ipv6 address with short notation" do @@ -86,7 +86,7 @@ ].each { |args| ->{ IPAddr.new(*args) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) } end end diff --git a/spec/ruby/library/ipaddr/operator_spec.rb b/spec/ruby/library/ipaddr/operator_spec.rb index f90c56009cf716..3337d223009f55 100644 --- a/spec/ruby/library/ipaddr/operator_spec.rb +++ b/spec/ruby/library/ipaddr/operator_spec.rb @@ -66,17 +66,17 @@ end it "checks whether an address is included in a range" do - @a.should include(IPAddr.new("3ffe:505:2::")) - @a.should include(IPAddr.new("3ffe:505:2::1")) - @a.should_not include(IPAddr.new("3ffe:505:3::")) + @a.should.include?(IPAddr.new("3ffe:505:2::")) + @a.should.include?(IPAddr.new("3ffe:505:2::1")) + @a.should_not.include?(IPAddr.new("3ffe:505:3::")) net1 = IPAddr.new("192.168.2.0/24") - net1.should include(IPAddr.new("192.168.2.0")) - net1.should include(IPAddr.new("192.168.2.255")) - net1.should_not include(IPAddr.new("192.168.3.0")) + net1.should.include?(IPAddr.new("192.168.2.0")) + net1.should.include?(IPAddr.new("192.168.2.255")) + net1.should_not.include?(IPAddr.new("192.168.3.0")) # test with integer parameter int = (192 << 24) + (168 << 16) + (2 << 8) + 13 - net1.should include(int) - net1.should_not include(int+255) + net1.should.include?(int) + net1.should_not.include?(int+255) end end diff --git a/spec/ruby/library/ipaddr/reverse_spec.rb b/spec/ruby/library/ipaddr/reverse_spec.rb index 6ebb343269862b..9bda60ca709578 100644 --- a/spec/ruby/library/ipaddr/reverse_spec.rb +++ b/spec/ruby/library/ipaddr/reverse_spec.rb @@ -13,7 +13,7 @@ IPAddr.new("3ffe:505:2::f").ip6_arpa.should == "f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.arpa" ->{ IPAddr.new("192.168.2.1").ip6_arpa - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -22,6 +22,6 @@ IPAddr.new("3ffe:505:2::f").ip6_int.should == "f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.int" ->{ IPAddr.new("192.168.2.1").ip6_int - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/logger/device/new_spec.rb b/spec/ruby/library/logger/device/new_spec.rb index 26a38c2b8ce397..c943e7fbe2793f 100644 --- a/spec/ruby/library/logger/device/new_spec.rb +++ b/spec/ruby/library/logger/device/new_spec.rb @@ -14,11 +14,11 @@ it "creates a new log device" do l = Logger::LogDevice.new(@log_file) - l.dev.should be_kind_of(File) + l.dev.should.is_a?(File) end it "receives an IO object to log there as first argument" do - @log_file.should be_kind_of(IO) + @log_file.should.is_a?(IO) l = Logger::LogDevice.new(@log_file) l.write("foo") @log_file.rewind @@ -33,7 +33,7 @@ File.should.exist?(path) File.open(path) do |f| - f.readlines.should_not be_empty + f.readlines.should_not.empty? end rm_r path @@ -42,6 +42,6 @@ it "receives options via a hash as second argument" do -> { Logger::LogDevice.new(STDERR, shift_age: 8, shift_size: 10) - }.should_not raise_error + }.should_not.raise end end diff --git a/spec/ruby/library/logger/logger/add_spec.rb b/spec/ruby/library/logger/logger/add_spec.rb index 3f709e18ba24b6..98ac88f64fa390 100644 --- a/spec/ruby/library/logger/logger/add_spec.rb +++ b/spec/ruby/library/logger/logger/add_spec.rb @@ -56,7 +56,7 @@ @logger.log(nil, "test", "TestApp") do 1+1 end - }.should_not raise_error + }.should_not.raise end it "calls the block if message is nil" do @@ -65,7 +65,7 @@ @logger.log(nil, nil, "TestApp") do temp = 1+1 end - }.should_not raise_error + }.should_not.raise temp.should == 2 end @@ -75,7 +75,7 @@ @logger.log(nil, "not nil", "TestApp") do temp = 1+1 end - }.should_not raise_error + }.should_not.raise temp.should == 0 end end diff --git a/spec/ruby/library/logger/logger/datetime_format_spec.rb b/spec/ruby/library/logger/logger/datetime_format_spec.rb index 582b34bfdafd34..75a7f6cc0373e0 100644 --- a/spec/ruby/library/logger/logger/datetime_format_spec.rb +++ b/spec/ruby/library/logger/logger/datetime_format_spec.rb @@ -49,7 +49,7 @@ end it "follows the Time#strftime format" do - -> { @logger.datetime_format = "%Y-%m" }.should_not raise_error + -> { @logger.datetime_format = "%Y-%m" }.should_not.raise regex = /\d{4}-\d{2}-\d{2}oo-\w+ar/ @logger.datetime_format = "%Foo-%Bar" diff --git a/spec/ruby/library/logger/logger/new_spec.rb b/spec/ruby/library/logger/logger/new_spec.rb index 3db20e743230b9..b311c9613218cd 100644 --- a/spec/ruby/library/logger/logger/new_spec.rb +++ b/spec/ruby/library/logger/logger/new_spec.rb @@ -28,13 +28,13 @@ end it "receives a frequency rotation as second argument" do - -> { Logger.new(@log_file, "daily") }.should_not raise_error - -> { Logger.new(@log_file, "weekly") }.should_not raise_error - -> { Logger.new(@log_file, "monthly") }.should_not raise_error + -> { Logger.new(@log_file, "daily") }.should_not.raise + -> { Logger.new(@log_file, "weekly") }.should_not.raise + -> { Logger.new(@log_file, "monthly") }.should_not.raise end it "also receives a number of log files to keep as second argument" do - -> { Logger.new(@log_file, 1).close }.should_not raise_error + -> { Logger.new(@log_file, 1).close }.should_not.raise end it "receives a maximum logfile size as third argument" do @@ -94,7 +94,7 @@ def call(_severity, _time, _progname, _msg); end logger.formatter.should == formatter end - it "receives shift_period_suffix " do + it "receives shift_period_suffix" do shift_period_suffix = "%Y-%m-%d" path = tmp("shift_period_suffix_test.log") now = Time.now diff --git a/spec/ruby/library/logger/logger/unknown_spec.rb b/spec/ruby/library/logger/logger/unknown_spec.rb index b174b8b2c93b67..4d37c9797ecc98 100644 --- a/spec/ruby/library/logger/logger/unknown_spec.rb +++ b/spec/ruby/library/logger/logger/unknown_spec.rb @@ -29,7 +29,7 @@ end it "receives empty messages" do - -> { @logger.unknown("") }.should_not raise_error + -> { @logger.unknown("") }.should_not.raise @log_file.rewind LoggerSpecs.strip_date(@log_file.readlines.first).should == "ANY -- : \n" end diff --git a/spec/ruby/library/matrix/antisymmetric_spec.rb b/spec/ruby/library/matrix/antisymmetric_spec.rb index 200df703cb8a55..b4b8858f32acef 100644 --- a/spec/ruby/library/matrix/antisymmetric_spec.rb +++ b/spec/ruby/library/matrix/antisymmetric_spec.rb @@ -4,11 +4,11 @@ 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 + Matrix[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric?.should == true end it "returns true for a 0x0 empty matrix" do - Matrix.empty.antisymmetric?.should be_true + Matrix.empty.antisymmetric?.should == true end it "returns false for non-antisymmetric matrices" do @@ -17,7 +17,7 @@ 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 + matrix.antisymmetric?.should == false end end @@ -30,7 +30,7 @@ ].each do |rectangular_matrix| -> { rectangular_matrix.antisymmetric? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/build_spec.rb b/spec/ruby/library/matrix/build_spec.rb index 6d8017a3dfda7a..49eb2e69a54266 100644 --- a/spec/ruby/library/matrix/build_spec.rb +++ b/spec/ruby/library/matrix/build_spec.rb @@ -6,7 +6,7 @@ it "returns a Matrix object of the given size" do m = Matrix.build(3, 4){1} - m.should be_an_instance_of(Matrix) + m.should.instance_of?(Matrix) m.row_size.should == 3 m.column_size.should == 4 end @@ -24,32 +24,32 @@ it "returns an Enumerator is no block is given" do enum = Matrix.build(2, 1) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.each{1}.should == Matrix[[1], [1]] end it "requires integers as parameters" do - -> { Matrix.build("1", "2"){1} }.should raise_error(TypeError) - -> { Matrix.build(nil, nil){1} }.should raise_error(TypeError) - -> { Matrix.build(1..2){1} }.should raise_error(TypeError) + -> { Matrix.build("1", "2"){1} }.should.raise(TypeError) + -> { Matrix.build(nil, nil){1} }.should.raise(TypeError) + -> { Matrix.build(1..2){1} }.should.raise(TypeError) end it "requires non-negative integers" do - -> { Matrix.build(-1, 1){1} }.should raise_error(ArgumentError) - -> { Matrix.build(+1,-1){1} }.should raise_error(ArgumentError) + -> { Matrix.build(-1, 1){1} }.should.raise(ArgumentError) + -> { Matrix.build(+1,-1){1} }.should.raise(ArgumentError) end it "returns empty Matrix if one argument is zero" do m = Matrix.build(0, 3){ raise "Should not yield" } - m.should be_empty + m.should.empty? m.column_size.should == 3 m = Matrix.build(3, 0){ raise "Should not yield" } - m.should be_empty + m.should.empty? m.row_size.should == 3 end @@ -68,6 +68,6 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.build(3){1}.should be_an_instance_of(MatrixSub) + MatrixSub.build(3){1}.should.instance_of?(MatrixSub) end end diff --git a/spec/ruby/library/matrix/clone_spec.rb b/spec/ruby/library/matrix/clone_spec.rb index 74e5bf157e7cf5..51aefc6010b91c 100644 --- a/spec/ruby/library/matrix/clone_spec.rb +++ b/spec/ruby/library/matrix/clone_spec.rb @@ -9,17 +9,17 @@ it "returns a shallow copy of the matrix" do b = @a.clone - @a.should_not equal(b) - b.should be_kind_of(Matrix) + @a.should_not.equal?(b) + b.should.is_a?(Matrix) b.should == @a 0.upto(@a.row_size - 1) do |i| - @a.row(i).should_not equal(b.row(i)) + @a.row(i).should_not.equal?(b.row(i)) end end describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.ins.clone.should be_an_instance_of(MatrixSub) + MatrixSub.ins.clone.should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/coerce_spec.rb b/spec/ruby/library/matrix/coerce_spec.rb index 4022f00236a802..6032dd2f62fe69 100644 --- a/spec/ruby/library/matrix/coerce_spec.rb +++ b/spec/ruby/library/matrix/coerce_spec.rb @@ -2,7 +2,7 @@ require 'matrix' describe "Matrix#coerce" do - it "allows the division of integer by a Matrix " do + it "allows the division of integer by a Matrix" do (1/Matrix[[0,1],[-1,0]]).should == Matrix[[0,-1],[1,0]] end end diff --git a/spec/ruby/library/matrix/column_spec.rb b/spec/ruby/library/matrix/column_spec.rb index 1f3c80964a6ecc..d5d8c80c1a9c80 100644 --- a/spec/ruby/library/matrix/column_spec.rb +++ b/spec/ruby/library/matrix/column_spec.rb @@ -21,7 +21,7 @@ end it "returns self when called with a block" do - @m.column(0) { |x| x }.should equal(@m) + @m.column(0) { |x| x }.should.equal?(@m) end it "returns nil when out of bounds" do @@ -29,7 +29,7 @@ end it "never yields when out of bounds" do - -> { @m.column(3){ raise } }.should_not raise_error - -> { @m.column(-4){ raise } }.should_not raise_error + -> { @m.column(3){ raise } }.should_not.raise + -> { @m.column(-4){ raise } }.should_not.raise end end diff --git a/spec/ruby/library/matrix/column_vector_spec.rb b/spec/ruby/library/matrix/column_vector_spec.rb index 47e866a8d55a66..d86c3f9e42b33e 100644 --- a/spec/ruby/library/matrix/column_vector_spec.rb +++ b/spec/ruby/library/matrix/column_vector_spec.rb @@ -6,20 +6,20 @@ it "returns a single column Matrix when called with an Array" do m = Matrix.column_vector([4,5,6]) - m.should be_an_instance_of(Matrix) + m.should.instance_of?(Matrix) m.should == Matrix[ [4],[5],[6] ] end it "returns an empty Matrix when called with an empty Array" do m = Matrix.column_vector([]) - m.should be_an_instance_of(Matrix) + m.should.instance_of?(Matrix) m.row_size.should == 0 m.column_size.should == 1 end describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.column_vector([4,5,6]).should be_an_instance_of(MatrixSub) + MatrixSub.column_vector([4,5,6]).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/column_vectors_spec.rb b/spec/ruby/library/matrix/column_vectors_spec.rb index b0cb6f914cc284..7ac6871e7f1c07 100644 --- a/spec/ruby/library/matrix/column_vectors_spec.rb +++ b/spec/ruby/library/matrix/column_vectors_spec.rb @@ -8,11 +8,11 @@ end it "returns an Array" do - Matrix[ [1,2], [3,4] ].column_vectors.should be_an_instance_of(Array) + Matrix[ [1,2], [3,4] ].column_vectors.should.instance_of?(Array) end it "returns an Array of Vectors" do - @vectors.all? {|v| v.should be_an_instance_of(Vector)} + @vectors.all? {|v| v.should.instance_of?(Vector)} end it "returns each column as a Vector" do diff --git a/spec/ruby/library/matrix/columns_spec.rb b/spec/ruby/library/matrix/columns_spec.rb index 3095fdd7afb0c7..ac9587899ddabd 100644 --- a/spec/ruby/library/matrix/columns_spec.rb +++ b/spec/ruby/library/matrix/columns_spec.rb @@ -10,7 +10,7 @@ end it "creates a Matrix from argument columns" do - @m.should be_an_instance_of(Matrix) + @m.should.instance_of?(Matrix) @m.column(0).to_a.should == @a @m.column(1).to_a.should == @b end @@ -36,7 +36,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.columns([[1]]).should be_an_instance_of(MatrixSub) + MatrixSub.columns([[1]]).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/constructor_spec.rb b/spec/ruby/library/matrix/constructor_spec.rb index 70d77babbb955d..026525f36dab23 100644 --- a/spec/ruby/library/matrix/constructor_spec.rb +++ b/spec/ruby/library/matrix/constructor_spec.rb @@ -5,10 +5,10 @@ describe "Matrix.[]" do it "requires arrays as parameters" do - -> { Matrix[5] }.should raise_error(TypeError) - -> { Matrix[nil] }.should raise_error(TypeError) - -> { Matrix[1..2] }.should raise_error(TypeError) - -> { Matrix[[1, 2], 3] }.should raise_error(TypeError) + -> { Matrix[5] }.should.raise(TypeError) + -> { Matrix[nil] }.should.raise(TypeError) + -> { Matrix[1..2] }.should.raise(TypeError) + -> { Matrix[[1, 2], 3] }.should.raise(TypeError) end it "creates an empty Matrix with no arguments" do @@ -18,15 +18,13 @@ end it "raises for non-rectangular matrices" do - ->{ Matrix[ [0], [0,1] ] }.should \ - raise_error(Matrix::ErrDimensionMismatch) - ->{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should \ - raise_error(Matrix::ErrDimensionMismatch) + ->{ Matrix[ [0], [0,1] ] }.should.raise(Matrix::ErrDimensionMismatch) + ->{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should.raise(Matrix::ErrDimensionMismatch) end it "accepts vector arguments" do a = Matrix[Vector[1, 2], Vector[3, 4]] - a.should be_an_instance_of(Matrix) + a.should.instance_of?(Matrix) a.should == Matrix[ [1, 2], [3, 4] ] end @@ -38,7 +36,7 @@ it "returns a Matrix object" do - Matrix[ [1] ].should be_an_instance_of(Matrix) + Matrix[ [1] ].should.instance_of?(Matrix) end it "can create an nxn Matrix" do @@ -59,7 +57,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub[ [20,30], [40.5, 9] ].should be_an_instance_of(MatrixSub) + MatrixSub[ [20,30], [40.5, 9] ].should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/diagonal_spec.rb b/spec/ruby/library/matrix/diagonal_spec.rb index ef9738e73e3fde..ee84ac8c285cbe 100644 --- a/spec/ruby/library/matrix/diagonal_spec.rb +++ b/spec/ruby/library/matrix/diagonal_spec.rb @@ -8,7 +8,7 @@ end it "returns an object of type Matrix" do - @m.should be_kind_of(Matrix) + @m.should.is_a?(Matrix) end it "returns a square Matrix of the right size" do @@ -34,27 +34,27 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.diagonal(1).should be_an_instance_of(MatrixSub) + MatrixSub.diagonal(1).should.instance_of?(MatrixSub) end end end describe "Matrix.diagonal?" do it "returns true for a diagonal Matrix" do - Matrix.diagonal([1, 2, 3]).diagonal?.should be_true + Matrix.diagonal([1, 2, 3]).diagonal?.should == true end it "returns true for a zero square Matrix" do - Matrix.zero(3).diagonal?.should be_true + Matrix.zero(3).diagonal?.should == true end it "returns false for a non diagonal square Matrix" do - Matrix[[0, 1], [0, 0]].diagonal?.should be_false - Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].diagonal?.should be_false + Matrix[[0, 1], [0, 0]].diagonal?.should == false + Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].diagonal?.should == false end it "returns true for an empty 0x0 matrix" do - Matrix.empty(0,0).diagonal?.should be_true + Matrix.empty(0,0).diagonal?.should == true end it "raises an error for rectangular matrices" do @@ -66,7 +66,7 @@ ].each do |rectangular_matrix| -> { rectangular_matrix.diagonal? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/divide_spec.rb b/spec/ruby/library/matrix/divide_spec.rb index 2e3bb85bf656b6..711a5189e44a2b 100644 --- a/spec/ruby/library/matrix/divide_spec.rb +++ b/spec/ruby/library/matrix/divide_spec.rb @@ -30,25 +30,25 @@ end it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do - -> { @a / Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch) + -> { @a / Matrix[ [1] ] }.should.raise(Matrix::ErrDimensionMismatch) end it "returns an instance of Matrix" do - (@a / @b).should be_kind_of(Matrix) + (@a / @b).should.is_a?(Matrix) end describe "for a subclass of Matrix" do it "returns an instance of that subclass" do m = MatrixSub.ins - (m/m).should be_an_instance_of(MatrixSub) - (m/1).should be_an_instance_of(MatrixSub) + (m/m).should.instance_of?(MatrixSub) + (m/1).should.instance_of?(MatrixSub) end end it "raises a TypeError if other is of wrong type" do - -> { @a / nil }.should raise_error(TypeError) - -> { @a / "a" }.should raise_error(TypeError) - -> { @a / [ [1, 2] ] }.should raise_error(TypeError) - -> { @a / Object.new }.should raise_error(TypeError) + -> { @a / nil }.should.raise(TypeError) + -> { @a / "a" }.should.raise(TypeError) + -> { @a / [ [1, 2] ] }.should.raise(TypeError) + -> { @a / Object.new }.should.raise(TypeError) end end diff --git a/spec/ruby/library/matrix/each_spec.rb b/spec/ruby/library/matrix/each_spec.rb index f3b0f018678c63..b4bfd3c76fcf46 100644 --- a/spec/ruby/library/matrix/each_spec.rb +++ b/spec/ruby/library/matrix/each_spec.rb @@ -9,12 +9,12 @@ it "returns an Enumerator when called without a block" do enum = @m.each - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == @result end it "returns self" do - @m.each{}.should equal(@m) + @m.each{}.should.equal?(@m) end it "yields the elements starting with the those of the first row" do @@ -33,13 +33,13 @@ it "raises an ArgumentError for unrecognized argument" do -> { @m.each("all"){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @m.each(nil){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @m.each(:left){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "yields the rights elements when passed :diagonal" do diff --git a/spec/ruby/library/matrix/each_with_index_spec.rb b/spec/ruby/library/matrix/each_with_index_spec.rb index a005b886216761..17e3f3f44c807c 100644 --- a/spec/ruby/library/matrix/each_with_index_spec.rb +++ b/spec/ruby/library/matrix/each_with_index_spec.rb @@ -16,12 +16,12 @@ it "returns an Enumerator when called without a block" do enum = @m.each_with_index - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == @result end it "returns self" do - @m.each_with_index{}.should equal(@m) + @m.each_with_index{}.should.equal?(@m) end it "yields the elements starting with the those of the first row" do @@ -40,13 +40,13 @@ it "raises an ArgumentError for unrecognized argument" do -> { @m.each_with_index("all"){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @m.each_with_index(nil){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @m.each_with_index(:left){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "yields the rights elements when passed :diagonal" do diff --git a/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb b/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb index 8438f63133e318..cbda82a16ae251 100644 --- a/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb +++ b/spec/ruby/library/matrix/eigenvalue_decomposition/initialize_spec.rb @@ -5,16 +5,16 @@ it "raises an error if argument is not a matrix" do -> { Matrix::EigenvalueDecomposition.new([[]]) - }.should raise_error(TypeError) + }.should.raise(TypeError) -> { Matrix::EigenvalueDecomposition.new(42) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises an error if matrix is not square" do -> { Matrix::EigenvalueDecomposition.new(Matrix[[1, 2]]) - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end it "never hangs" do diff --git a/spec/ruby/library/matrix/element_reference_spec.rb b/spec/ruby/library/matrix/element_reference_spec.rb index b950d1c391f7b0..c6804b38460b4a 100644 --- a/spec/ruby/library/matrix/element_reference_spec.rb +++ b/spec/ruby/library/matrix/element_reference_spec.rb @@ -16,8 +16,8 @@ end it "returns nil for an invalid index pair" do - @m[8,1].should be_nil - @m[1,8].should be_nil + @m[8,1].should == nil + @m[1,8].should == nil end end diff --git a/spec/ruby/library/matrix/empty_spec.rb b/spec/ruby/library/matrix/empty_spec.rb index 5f294711db1847..7b0f0af9ebfb80 100644 --- a/spec/ruby/library/matrix/empty_spec.rb +++ b/spec/ruby/library/matrix/empty_spec.rb @@ -4,20 +4,20 @@ describe "Matrix#empty?" do it "returns true when the Matrix is empty" do - Matrix[ ].empty?.should be_true - Matrix[ [], [], [] ].empty?.should be_true - Matrix[ [], [], [] ].transpose.empty?.should be_true + Matrix[ ].empty?.should == true + Matrix[ [], [], [] ].empty?.should == true + Matrix[ [], [], [] ].transpose.empty?.should == true end it "returns false when the Matrix has elements" do - Matrix[ [1, 2] ].empty?.should be_false - Matrix[ [1], [2] ].empty?.should be_false + Matrix[ [1, 2] ].empty?.should == false + Matrix[ [1], [2] ].empty?.should == false end it "doesn't accept any parameter" do ->{ Matrix[ [1, 2] ].empty?(42) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -40,29 +40,29 @@ it "does not accept more than two parameters" do ->{ Matrix.empty(1, 2, 3) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an error if both dimensions are > 0" do ->{ Matrix.empty(1, 2) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "raises an error if any dimension is < 0" do ->{ Matrix.empty(-2, 0) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) ->{ Matrix.empty(0, -2) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.empty(0, 1).should be_an_instance_of(MatrixSub) + MatrixSub.empty(0, 1).should.instance_of?(MatrixSub) end end diff --git a/spec/ruby/library/matrix/eql_spec.rb b/spec/ruby/library/matrix/eql_spec.rb index ea26c3320d247c..cda122f4d821e3 100644 --- a/spec/ruby/library/matrix/eql_spec.rb +++ b/spec/ruby/library/matrix/eql_spec.rb @@ -6,6 +6,6 @@ it_behaves_like :equal, :eql? it "returns false if some elements are == but not eql?" do - Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should be_false + Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should == false end end diff --git a/spec/ruby/library/matrix/exponent_spec.rb b/spec/ruby/library/matrix/exponent_spec.rb index 38cdfa927626ce..4cbe63587d8bfb 100644 --- a/spec/ruby/library/matrix/exponent_spec.rb +++ b/spec/ruby/library/matrix/exponent_spec.rb @@ -17,8 +17,8 @@ it "raises a ErrDimensionMismatch for non square matrices" do m = Matrix[ [1, 1], [1, 2], [2, 3]] - -> { m ** 3 }.should raise_error(Matrix::ErrDimensionMismatch) - -> { m ** 0 }.should raise_error(Matrix::ErrDimensionMismatch) + -> { m ** 3 }.should.raise(Matrix::ErrDimensionMismatch) + -> { m ** 0 }.should.raise(Matrix::ErrDimensionMismatch) end describe "that is < 0" do @@ -30,7 +30,7 @@ it "raises a ErrNotRegular for irregular matrices" do m = Matrix[ [1, 1], [1, 1] ] - -> { m ** -2 }.should raise_error(Matrix::ErrNotRegular) + -> { m ** -2 }.should.raise(Matrix::ErrNotRegular) end end @@ -42,7 +42,7 @@ it "raises an ErrDimensionMismatch for non-square matrices" do m = Matrix[ [1, 1] ] - -> { m ** 0 }.should raise_error(Matrix::ErrDimensionMismatch) + -> { m ** 0 }.should.raise(Matrix::ErrDimensionMismatch) end end end @@ -56,7 +56,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - (MatrixSub.ins ** 1).should be_an_instance_of(MatrixSub) + (MatrixSub.ins ** 1).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/find_index_spec.rb b/spec/ruby/library/matrix/find_index_spec.rb index c2bfa6d61ab529..c7278fd4496cb9 100644 --- a/spec/ruby/library/matrix/find_index_spec.rb +++ b/spec/ruby/library/matrix/find_index_spec.rb @@ -8,12 +8,12 @@ it "returns an Enumerator when called without a block" do enum = @m.find_index - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == [1, 2, 3, 4, 5, 6, 7, 8] end it "returns nil if the block is always false" do - @m.find_index{false}.should be_nil + @m.find_index{false}.should == nil end it "returns the first index for which the block is true" do @@ -48,7 +48,7 @@ it "returns an Enumerator when called without a block" do @tests.each do |matrix, h| h.each do |selector, result| - matrix.find_index(selector).should be_an_instance_of(Enumerator) + matrix.find_index(selector).should.instance_of?(Enumerator) end end end @@ -116,7 +116,7 @@ end it "returns nil if the value is not found" do - @m.find_index(42).should be_nil + @m.find_index(42).should == nil end it "returns the first index for of the requested value" do @@ -132,15 +132,15 @@ it "raises an ArgumentError for an unrecognized last argument" do -> { @m.find_index(1, "all"){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @m.find_index(1, nil){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @m.find_index(1, :left){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @m.find_index(:diagonal, 1){} - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/matrix/hash_spec.rb b/spec/ruby/library/matrix/hash_spec.rb index 7dabcd3737cf3f..27bf7b97519267 100644 --- a/spec/ruby/library/matrix/hash_spec.rb +++ b/spec/ruby/library/matrix/hash_spec.rb @@ -4,7 +4,7 @@ describe "Matrix#hash" do it "returns an Integer" do - Matrix[ [1,2] ].hash.should be_an_instance_of(Integer) + Matrix[ [1,2] ].hash.should.instance_of?(Integer) end it "returns the same value for the same matrix" do diff --git a/spec/ruby/library/matrix/hermitian_spec.rb b/spec/ruby/library/matrix/hermitian_spec.rb index 177ca64d839c0b..94d0dbe6b62c4e 100644 --- a/spec/ruby/library/matrix/hermitian_spec.rb +++ b/spec/ruby/library/matrix/hermitian_spec.rb @@ -3,15 +3,15 @@ describe "Matrix.hermitian?" do it "returns true for a hermitian Matrix" do - Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, -3), 5, 6]].hermitian?.should be_true + Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, -3), 5, 6]].hermitian?.should == true end it "returns true for a 0x0 empty matrix" do - Matrix.empty.hermitian?.should be_true + Matrix.empty.hermitian?.should == true end it "returns false for an asymmetric Matrix" do - Matrix[[1, 2],[-2, 1]].hermitian?.should be_false + Matrix[[1, 2],[-2, 1]].hermitian?.should == false end it "raises an error for rectangular matrices" do @@ -23,12 +23,12 @@ ].each do |rectangular_matrix| -> { rectangular_matrix.hermitian? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end it "returns false for a matrix with complex values on the diagonal" do - Matrix[[Complex(1,1)]].hermitian?.should be_false - Matrix[[Complex(1,0)]].hermitian?.should be_true + Matrix[[Complex(1,1)]].hermitian?.should == false + Matrix[[Complex(1,0)]].hermitian?.should == true end end diff --git a/spec/ruby/library/matrix/lower_triangular_spec.rb b/spec/ruby/library/matrix/lower_triangular_spec.rb index f3aa4501f4f1b8..7e8688fd9b3722 100644 --- a/spec/ruby/library/matrix/lower_triangular_spec.rb +++ b/spec/ruby/library/matrix/lower_triangular_spec.rb @@ -3,22 +3,22 @@ describe "Matrix.lower_triangular?" do it "returns true for a square lower triangular Matrix" do - Matrix[[1, 0, 0], [1, 2, 0], [1, 2, 3]].lower_triangular?.should be_true - Matrix.diagonal([1, 2, 3]).lower_triangular?.should be_true - Matrix[[1, 0], [1, 2], [1, 2], [1, 2]].lower_triangular?.should be_true - Matrix[[1, 0, 0, 0], [1, 2, 0, 0]].lower_triangular?.should be_true + Matrix[[1, 0, 0], [1, 2, 0], [1, 2, 3]].lower_triangular?.should == true + Matrix.diagonal([1, 2, 3]).lower_triangular?.should == true + Matrix[[1, 0], [1, 2], [1, 2], [1, 2]].lower_triangular?.should == true + Matrix[[1, 0, 0, 0], [1, 2, 0, 0]].lower_triangular?.should == true end it "returns true for an empty Matrix" do - Matrix.empty(3, 0).lower_triangular?.should be_true - Matrix.empty(0, 3).lower_triangular?.should be_true - Matrix.empty(0, 0).lower_triangular?.should be_true + Matrix.empty(3, 0).lower_triangular?.should == true + Matrix.empty(0, 3).lower_triangular?.should == true + Matrix.empty(0, 0).lower_triangular?.should == true end it "returns false for a non lower triangular square Matrix" do - Matrix[[0, 1], [0, 0]].lower_triangular?.should be_false - Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].lower_triangular?.should be_false - Matrix[[0, 1], [0, 0], [0, 0], [0, 0]].lower_triangular?.should be_false - Matrix[[0, 0, 0, 1], [0, 0, 0, 0]].lower_triangular?.should be_false + Matrix[[0, 1], [0, 0]].lower_triangular?.should == false + Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].lower_triangular?.should == false + Matrix[[0, 1], [0, 0], [0, 0], [0, 0]].lower_triangular?.should == false + Matrix[[0, 0, 0, 1], [0, 0, 0, 0]].lower_triangular?.should == false end end diff --git a/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb b/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb index 9d733066c17977..98ac5c71a34f1f 100644 --- a/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/determinant_spec.rb @@ -15,7 +15,7 @@ lup = m.lup -> { lup.determinant - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb b/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb index 36afb349e60f4f..b813757525eefb 100644 --- a/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/initialize_spec.rb @@ -5,9 +5,9 @@ it "raises an error if argument is not a matrix" do -> { Matrix::LUPDecomposition.new([[]]) - }.should raise_error(TypeError) + }.should.raise(TypeError) -> { Matrix::LUPDecomposition.new(42) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end diff --git a/spec/ruby/library/matrix/lup_decomposition/l_spec.rb b/spec/ruby/library/matrix/lup_decomposition/l_spec.rb index 9514ab5d063561..0a6797cc85365d 100644 --- a/spec/ruby/library/matrix/lup_decomposition/l_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/l_spec.rb @@ -13,6 +13,6 @@ end it "returns a lower triangular matrix" do - @l.lower_triangular?.should be_true + @l.lower_triangular?.should == true end end diff --git a/spec/ruby/library/matrix/lup_decomposition/p_spec.rb b/spec/ruby/library/matrix/lup_decomposition/p_spec.rb index c7b5e9196e9808..2c44399b79cc25 100644 --- a/spec/ruby/library/matrix/lup_decomposition/p_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/p_spec.rb @@ -13,6 +13,6 @@ end it "returns a permutation matrix" do - @p.permutation?.should be_true + @p.permutation?.should == true end end diff --git a/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb b/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb index 66242627e9610c..9927e9672775a1 100644 --- a/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/solve_spec.rb @@ -8,7 +8,7 @@ lu = Matrix::LUPDecomposition.new(a) -> { lu.solve(a) - }.should raise_error(Matrix::ErrNotRegular) + }.should.raise(Matrix::ErrNotRegular) end describe "for non singular matrices" do @@ -33,7 +33,7 @@ values = Matrix[[1, 2, 3, 4], [0, 1, 2, 3]] -> { @lu.solve(values) - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end it "returns the right vector when given a vector of the appropriate size" do @@ -46,7 +46,7 @@ values = Vector[14, 55] -> { @lu.solve(values) - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb b/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb index 9b1dccbbacee9e..ab59677dd9d467 100644 --- a/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/to_a_spec.rb @@ -10,9 +10,9 @@ end it "returns an array of three matrices" do - @to_a.should be_kind_of(Array) + @to_a.should.is_a?(Array) @to_a.length.should == 3 - @to_a.each{|m| m.should be_kind_of(Matrix)} + @to_a.each{|m| m.should.is_a?(Matrix)} end it "returns [l, u, p] such that l*u == a*p" do diff --git a/spec/ruby/library/matrix/lup_decomposition/u_spec.rb b/spec/ruby/library/matrix/lup_decomposition/u_spec.rb index ca3dfc1f00e5d8..967bc669dc0a32 100644 --- a/spec/ruby/library/matrix/lup_decomposition/u_spec.rb +++ b/spec/ruby/library/matrix/lup_decomposition/u_spec.rb @@ -13,6 +13,6 @@ end it "returns an upper triangular matrix" do - @u.upper_triangular?.should be_true + @u.upper_triangular?.should == true end end diff --git a/spec/ruby/library/matrix/minor_spec.rb b/spec/ruby/library/matrix/minor_spec.rb index 009826c3d660c1..6b29db568b4044 100644 --- a/spec/ruby/library/matrix/minor_spec.rb +++ b/spec/ruby/library/matrix/minor_spec.rb @@ -79,7 +79,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.ins.minor(0, 1, 0, 1).should be_an_instance_of(MatrixSub) + MatrixSub.ins.minor(0, 1, 0, 1).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/minus_spec.rb b/spec/ruby/library/matrix/minus_spec.rb index 95cf4a6072279b..7426aa2d2c9fe8 100644 --- a/spec/ruby/library/matrix/minus_spec.rb +++ b/spec/ruby/library/matrix/minus_spec.rb @@ -13,30 +13,30 @@ end it "returns an instance of Matrix" do - (@a - @b).should be_kind_of(Matrix) + (@a - @b).should.is_a?(Matrix) end it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do - -> { @a - Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch) + -> { @a - Matrix[ [1] ] }.should.raise(Matrix::ErrDimensionMismatch) end it "raises a ExceptionForMatrix::ErrOperationNotDefined if other is a Numeric Type" do - -> { @a - 2 }.should raise_error(Matrix::ErrOperationNotDefined) - -> { @a - 1.2 }.should raise_error(Matrix::ErrOperationNotDefined) - -> { @a - bignum_value }.should raise_error(Matrix::ErrOperationNotDefined) + -> { @a - 2 }.should.raise(Matrix::ErrOperationNotDefined) + -> { @a - 1.2 }.should.raise(Matrix::ErrOperationNotDefined) + -> { @a - bignum_value }.should.raise(Matrix::ErrOperationNotDefined) end it "raises a TypeError if other is of wrong type" do - -> { @a - nil }.should raise_error(TypeError) - -> { @a - "a" }.should raise_error(TypeError) - -> { @a - [ [1, 2] ] }.should raise_error(TypeError) - -> { @a - Object.new }.should raise_error(TypeError) + -> { @a - nil }.should.raise(TypeError) + -> { @a - "a" }.should.raise(TypeError) + -> { @a - [ [1, 2] ] }.should.raise(TypeError) + -> { @a - Object.new }.should.raise(TypeError) end describe "for a subclass of Matrix" do it "returns an instance of that subclass" do m = MatrixSub.ins - (m-m).should be_an_instance_of(MatrixSub) + (m-m).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/multiply_spec.rb b/spec/ruby/library/matrix/multiply_spec.rb index 206868af92970f..6c495c5521bd91 100644 --- a/spec/ruby/library/matrix/multiply_spec.rb +++ b/spec/ruby/library/matrix/multiply_spec.rb @@ -33,7 +33,7 @@ end it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do - -> { @a * Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch) + -> { @a * Matrix[ [1] ] }.should.raise(Matrix::ErrDimensionMismatch) end it "returns a zero matrix if (nx0) * (0xn)" do @@ -53,17 +53,17 @@ end it "raises a TypeError if other is of wrong type" do - -> { @a * nil }.should raise_error(TypeError) - -> { @a * "a" }.should raise_error(TypeError) - -> { @a * [ [1, 2] ] }.should raise_error(TypeError) - -> { @a * Object.new }.should raise_error(TypeError) + -> { @a * nil }.should.raise(TypeError) + -> { @a * "a" }.should.raise(TypeError) + -> { @a * [ [1, 2] ] }.should.raise(TypeError) + -> { @a * Object.new }.should.raise(TypeError) end describe "for a subclass of Matrix" do it "returns an instance of that subclass" do m = MatrixSub.ins - (m*m).should be_an_instance_of(MatrixSub) - (m*1).should be_an_instance_of(MatrixSub) + (m*m).should.instance_of?(MatrixSub) + (m*1).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/new_spec.rb b/spec/ruby/library/matrix/new_spec.rb index 3005066846058d..bde9d9f4c89e6f 100644 --- a/spec/ruby/library/matrix/new_spec.rb +++ b/spec/ruby/library/matrix/new_spec.rb @@ -3,6 +3,6 @@ describe "Matrix.new" do it "is private" do - Matrix.should have_private_method(:new) + Matrix.private_methods(false).should.include?(:new) end end diff --git a/spec/ruby/library/matrix/normal_spec.rb b/spec/ruby/library/matrix/normal_spec.rb index a9e6c645faf75e..420d4b011fbb8b 100644 --- a/spec/ruby/library/matrix/normal_spec.rb +++ b/spec/ruby/library/matrix/normal_spec.rb @@ -20,7 +20,7 @@ ].each do |rectangular_matrix| -> { rectangular_matrix.normal? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/orthogonal_spec.rb b/spec/ruby/library/matrix/orthogonal_spec.rb index 26afe89ff08e75..71ac831fe836f0 100644 --- a/spec/ruby/library/matrix/orthogonal_spec.rb +++ b/spec/ruby/library/matrix/orthogonal_spec.rb @@ -20,7 +20,7 @@ ].each do |rectangular_matrix| -> { rectangular_matrix.orthogonal? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/permutation_spec.rb b/spec/ruby/library/matrix/permutation_spec.rb index 825a9d982c5cf2..43727edea1d595 100644 --- a/spec/ruby/library/matrix/permutation_spec.rb +++ b/spec/ruby/library/matrix/permutation_spec.rb @@ -3,18 +3,18 @@ describe "Matrix#permutation?" do it "returns true for a permutation Matrix" do - Matrix[[0, 1, 0], [0, 0, 1], [1, 0, 0]].permutation?.should be_true + Matrix[[0, 1, 0], [0, 0, 1], [1, 0, 0]].permutation?.should == true end it "returns false for a non permutation square Matrix" do - Matrix[[0, 1], [0, 0]].permutation?.should be_false - Matrix[[-1, 0], [0, -1]].permutation?.should be_false - Matrix[[1, 0], [1, 0]].permutation?.should be_false - Matrix[[1, 0], [1, 1]].permutation?.should be_false + Matrix[[0, 1], [0, 0]].permutation?.should == false + Matrix[[-1, 0], [0, -1]].permutation?.should == false + Matrix[[1, 0], [1, 0]].permutation?.should == false + Matrix[[1, 0], [1, 1]].permutation?.should == false end it "returns true for an empty 0x0 matrix" do - Matrix.empty(0,0).permutation?.should be_true + Matrix.empty(0,0).permutation?.should == true end it "raises an error for rectangular matrices" do @@ -26,7 +26,7 @@ ].each do |rectangular_matrix| -> { rectangular_matrix.permutation? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/plus_spec.rb b/spec/ruby/library/matrix/plus_spec.rb index 2706bad060ea44..72a9ba8f8fa1a8 100644 --- a/spec/ruby/library/matrix/plus_spec.rb +++ b/spec/ruby/library/matrix/plus_spec.rb @@ -13,30 +13,30 @@ end it "returns an instance of Matrix" do - (@a + @b).should be_kind_of(Matrix) + (@a + @b).should.is_a?(Matrix) end it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do - -> { @a + Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch) + -> { @a + Matrix[ [1] ] }.should.raise(Matrix::ErrDimensionMismatch) end it "raises a ExceptionForMatrix::ErrOperationNotDefined if other is a Numeric Type" do - -> { @a + 2 }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined) - -> { @a + 1.2 }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined) - -> { @a + bignum_value }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined) + -> { @a + 2 }.should.raise(ExceptionForMatrix::ErrOperationNotDefined) + -> { @a + 1.2 }.should.raise(ExceptionForMatrix::ErrOperationNotDefined) + -> { @a + bignum_value }.should.raise(ExceptionForMatrix::ErrOperationNotDefined) end it "raises a TypeError if other is of wrong type" do - -> { @a + nil }.should raise_error(TypeError) - -> { @a + "a" }.should raise_error(TypeError) - -> { @a + [ [1, 2] ] }.should raise_error(TypeError) - -> { @a + Object.new }.should raise_error(TypeError) + -> { @a + nil }.should.raise(TypeError) + -> { @a + "a" }.should.raise(TypeError) + -> { @a + [ [1, 2] ] }.should.raise(TypeError) + -> { @a + Object.new }.should.raise(TypeError) end describe "for a subclass of Matrix" do it "returns an instance of that subclass" do m = MatrixSub.ins - (m+m).should be_an_instance_of(MatrixSub) + (m+m).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/real_spec.rb b/spec/ruby/library/matrix/real_spec.rb index 38033c63c8f47d..4589dc22a5ffb9 100644 --- a/spec/ruby/library/matrix/real_spec.rb +++ b/spec/ruby/library/matrix/real_spec.rb @@ -4,22 +4,22 @@ describe "Matrix#real?" do it "returns true for matrices with all real entries" do - Matrix[ [1, 2], [3, 4] ].real?.should be_true - Matrix[ [1.9, 2], [3, 4] ].real?.should be_true + Matrix[ [1, 2], [3, 4] ].real?.should == true + Matrix[ [1.9, 2], [3, 4] ].real?.should == true end it "returns true for empty matrices" do - Matrix.empty.real?.should be_true + Matrix.empty.real?.should == true end it "returns false if one element is a Complex" do - Matrix[ [Complex(1,1), 2], [3, 4] ].real?.should be_false + Matrix[ [Complex(1,1), 2], [3, 4] ].real?.should == false end # Guard against the Mathn library guard -> { !defined?(Math.rsqrt) } do it "returns false if one element is a Complex whose imaginary part is 0" do - Matrix[ [Complex(1,0), 2], [3, 4] ].real?.should be_false + Matrix[ [Complex(1,0), 2], [3, 4] ].real?.should == false end end end @@ -37,7 +37,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.ins.real.should be_an_instance_of(MatrixSub) + MatrixSub.ins.real.should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/regular_spec.rb b/spec/ruby/library/matrix/regular_spec.rb index 3699d0ef8bdc8e..4cb00819ac7ccc 100644 --- a/spec/ruby/library/matrix/regular_spec.rb +++ b/spec/ruby/library/matrix/regular_spec.rb @@ -5,27 +5,27 @@ it "returns false for singular matrices" do m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ] - m.regular?.should be_false + m.regular?.should == false m = Matrix[ [1,2,9], [3,4,9], [1,2,9] ] - m.regular?.should be_false + m.regular?.should == false end it "returns true if the Matrix is regular" do - Matrix[ [0,1], [1,0] ].regular?.should be_true + Matrix[ [0,1], [1,0] ].regular?.should == true end it "returns true for an empty 0x0 matrix" do - Matrix.empty(0,0).regular?.should be_true + Matrix.empty(0,0).regular?.should == true end it "raises an error for rectangular matrices" do -> { Matrix[[1], [2], [3]].regular? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) -> { Matrix.empty(3,0).regular? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/round_spec.rb b/spec/ruby/library/matrix/round_spec.rb index 1dc29df890b01b..cdec646fa1bb30 100644 --- a/spec/ruby/library/matrix/round_spec.rb +++ b/spec/ruby/library/matrix/round_spec.rb @@ -15,7 +15,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.ins.round.should be_an_instance_of(MatrixSub) + MatrixSub.ins.round.should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/row_spec.rb b/spec/ruby/library/matrix/row_spec.rb index 00b1f02a8e0189..8a7662fdf273a6 100644 --- a/spec/ruby/library/matrix/row_spec.rb +++ b/spec/ruby/library/matrix/row_spec.rb @@ -21,7 +21,7 @@ end it "returns self when called with a block" do - @m.row(0) { |x| x }.should equal(@m) + @m.row(0) { |x| x }.should.equal?(@m) end it "returns nil when out of bounds" do @@ -30,7 +30,7 @@ end it "never yields when out of bounds" do - -> { @m.row(3){ raise } }.should_not raise_error - -> { @m.row(-4){ raise } }.should_not raise_error + -> { @m.row(3){ raise } }.should_not.raise + -> { @m.row(-4){ raise } }.should_not.raise end end diff --git a/spec/ruby/library/matrix/row_vector_spec.rb b/spec/ruby/library/matrix/row_vector_spec.rb index 341437ee05c0e3..f3919fb7d81852 100644 --- a/spec/ruby/library/matrix/row_vector_spec.rb +++ b/spec/ruby/library/matrix/row_vector_spec.rb @@ -5,7 +5,7 @@ describe "Matrix.row_vector" do it "returns a Matrix" do - Matrix.row_vector([]).should be_an_instance_of(Matrix) + Matrix.row_vector([]).should.instance_of?(Matrix) end it "returns a single-row Matrix with the specified values" do @@ -18,7 +18,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.row_vector([1]).should be_an_instance_of(MatrixSub) + MatrixSub.row_vector([1]).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/row_vectors_spec.rb b/spec/ruby/library/matrix/row_vectors_spec.rb index 6f99c439a67bb0..4a0db675274ad2 100644 --- a/spec/ruby/library/matrix/row_vectors_spec.rb +++ b/spec/ruby/library/matrix/row_vectors_spec.rb @@ -8,11 +8,11 @@ end it "returns an Array" do - Matrix[ [1,2], [3,4] ].row_vectors.should be_an_instance_of(Array) + Matrix[ [1,2], [3,4] ].row_vectors.should.instance_of?(Array) end it "returns an Array of Vectors" do - @vectors.all? {|v| v.should be_an_instance_of(Vector)} + @vectors.all? {|v| v.should.instance_of?(Vector)} end it "returns each row as a Vector" do diff --git a/spec/ruby/library/matrix/rows_spec.rb b/spec/ruby/library/matrix/rows_spec.rb index 41ba635775779e..9c248cd8a46682 100644 --- a/spec/ruby/library/matrix/rows_spec.rb +++ b/spec/ruby/library/matrix/rows_spec.rb @@ -10,7 +10,7 @@ end it "returns a Matrix" do - @m.should be_kind_of(Matrix) + @m.should.is_a?(Matrix) end it "creates a matrix from argument rows" do @@ -21,8 +21,8 @@ it "copies the original rows by default" do @a << 3 @b << 6 - @m.row(0).should_not equal(@a) - @m.row(1).should_not equal(@b) + @m.row(0).should_not.equal?(@a) + @m.row(1).should_not.equal?(@b) end it "references the original rows if copy is false" do @@ -35,7 +35,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.rows([[0, 1], [0, 1]]).should be_an_instance_of(MatrixSub) + MatrixSub.rows([[0, 1], [0, 1]]).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/scalar_spec.rb b/spec/ruby/library/matrix/scalar_spec.rb index 7fdd64c9d95026..5b93b60533bd5f 100644 --- a/spec/ruby/library/matrix/scalar_spec.rb +++ b/spec/ruby/library/matrix/scalar_spec.rb @@ -10,7 +10,7 @@ end it "returns a Matrix" do - @a.should be_kind_of(Matrix) + @a.should.is_a?(Matrix) end it "returns a n x n matrix" do @@ -41,7 +41,7 @@ end it "returns a Matrix" do - @a.should be_kind_of(Matrix) + @a.should.is_a?(Matrix) end it "returns a square matrix, where the first argument specifies the side of the square" do diff --git a/spec/ruby/library/matrix/shared/collect.rb b/spec/ruby/library/matrix/shared/collect.rb index 852f7fd6cfd85e..3a4dbe3a366c81 100644 --- a/spec/ruby/library/matrix/shared/collect.rb +++ b/spec/ruby/library/matrix/shared/collect.rb @@ -7,7 +7,7 @@ end it "returns an instance of Matrix" do - @m.send(@method){|n| n * 2 }.should be_kind_of(Matrix) + @m.send(@method){|n| n * 2 }.should.is_a?(Matrix) end it "returns a Matrix where each element is the result of the block" do @@ -15,12 +15,12 @@ end it "returns an enumerator if no block is given" do - @m.send(@method).should be_an_instance_of(Enumerator) + @m.send(@method).should.instance_of?(Enumerator) end describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.ins.send(@method){1}.should be_an_instance_of(MatrixSub) + MatrixSub.ins.send(@method){1}.should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/shared/conjugate.rb b/spec/ruby/library/matrix/shared/conjugate.rb index d87658f8558647..ffdf5ebca1713d 100644 --- a/spec/ruby/library/matrix/shared/conjugate.rb +++ b/spec/ruby/library/matrix/shared/conjugate.rb @@ -14,7 +14,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.ins.send(@method).should be_an_instance_of(MatrixSub) + MatrixSub.ins.send(@method).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/shared/determinant.rb b/spec/ruby/library/matrix/shared/determinant.rb index 9e0528c24bade3..b7c86393baf1e3 100644 --- a/spec/ruby/library/matrix/shared/determinant.rb +++ b/spec/ruby/library/matrix/shared/determinant.rb @@ -29,10 +29,10 @@ it "raises an error for rectangular matrices" do -> { Matrix[[1], [2], [3]].send(@method) - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) -> { Matrix.empty(3,0).send(@method) - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/shared/equal_value.rb b/spec/ruby/library/matrix/shared/equal_value.rb index 2b2311d49e8d98..9bc6ed908bd830 100644 --- a/spec/ruby/library/matrix/shared/equal_value.rb +++ b/spec/ruby/library/matrix/shared/equal_value.rb @@ -7,27 +7,27 @@ end it "returns true for self" do - @matrix.send(@method, @matrix).should be_true + @matrix.send(@method, @matrix).should == true end it "returns true for equal matrices" do - @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_true + @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should == true end it "returns false for different matrices" do - @matrix.send(@method, Matrix[ [42, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_false - @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7] ]).should be_false - @matrix.send(@method, Matrix[ [1, 2, 3], [2, 3, 4] ]).should be_false + @matrix.send(@method, Matrix[ [42, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should == false + @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7] ]).should == false + @matrix.send(@method, Matrix[ [1, 2, 3], [2, 3, 4] ]).should == false end it "returns false for different empty matrices" do - Matrix.empty(42, 0).send(@method, Matrix.empty(6, 0)).should be_false - Matrix.empty(0, 42).send(@method, Matrix.empty(0, 6)).should be_false - Matrix.empty(0, 0).send(@method, Matrix.empty(6, 0)).should be_false - Matrix.empty(0, 0).send(@method, Matrix.empty(0, 6)).should be_false + Matrix.empty(42, 0).send(@method, Matrix.empty(6, 0)).should == false + Matrix.empty(0, 42).send(@method, Matrix.empty(0, 6)).should == false + Matrix.empty(0, 0).send(@method, Matrix.empty(6, 0)).should == false + Matrix.empty(0, 0).send(@method, Matrix.empty(0, 6)).should == false end it "doesn't distinguish on subclasses" do - MatrixSub.ins.send(@method, Matrix.I(2)).should be_true + MatrixSub.ins.send(@method, Matrix.I(2)).should == true end end diff --git a/spec/ruby/library/matrix/shared/identity.rb b/spec/ruby/library/matrix/shared/identity.rb index 114f86e7b08826..df957b5a750306 100644 --- a/spec/ruby/library/matrix/shared/identity.rb +++ b/spec/ruby/library/matrix/shared/identity.rb @@ -3,7 +3,7 @@ describe :matrix_identity, shared: true do it "returns a Matrix" do - Matrix.send(@method, 2).should be_kind_of(Matrix) + Matrix.send(@method, 2).should.is_a?(Matrix) end it "returns a n x n identity matrix" do @@ -13,7 +13,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.send(@method, 2).should be_an_instance_of(MatrixSub) + MatrixSub.send(@method, 2).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/shared/imaginary.rb b/spec/ruby/library/matrix/shared/imaginary.rb index d28ecc69f1a155..16615213a245a6 100644 --- a/spec/ruby/library/matrix/shared/imaginary.rb +++ b/spec/ruby/library/matrix/shared/imaginary.rb @@ -14,7 +14,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.ins.send(@method).should be_an_instance_of(MatrixSub) + MatrixSub.ins.send(@method).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/shared/inverse.rb b/spec/ruby/library/matrix/shared/inverse.rb index c8a6b90da59166..ac463cf680828b 100644 --- a/spec/ruby/library/matrix/shared/inverse.rb +++ b/spec/ruby/library/matrix/shared/inverse.rb @@ -4,7 +4,7 @@ describe :inverse, shared: true do it "returns a Matrix" do - Matrix[ [1,2], [2,1] ].send(@method).should be_an_instance_of(Matrix) + Matrix[ [1,2], [2,1] ].send(@method).should.instance_of?(Matrix) end it "returns the inverse of the Matrix" do @@ -27,12 +27,12 @@ it "raises a ErrDimensionMismatch if the Matrix is not square" do ->{ Matrix[ [1,2,3], [1,2,3] ].send(@method) - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.ins.send(@method).should be_an_instance_of(MatrixSub) + MatrixSub.ins.send(@method).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/shared/rectangular.rb b/spec/ruby/library/matrix/shared/rectangular.rb index 3d9a0dfe8af4b9..0229e614c64557 100644 --- a/spec/ruby/library/matrix/shared/rectangular.rb +++ b/spec/ruby/library/matrix/shared/rectangular.rb @@ -12,7 +12,7 @@ describe "for a subclass of Matrix" do it "returns instances of that subclass" do - MatrixSub.ins.send(@method).each{|m| m.should be_an_instance_of(MatrixSub) } + MatrixSub.ins.send(@method).each{|m| m.should.instance_of?(MatrixSub) } end end end diff --git a/spec/ruby/library/matrix/shared/trace.rb b/spec/ruby/library/matrix/shared/trace.rb index 57b89863f8b561..c4a5491b226077 100644 --- a/spec/ruby/library/matrix/shared/trace.rb +++ b/spec/ruby/library/matrix/shared/trace.rb @@ -6,7 +6,7 @@ end it "returns the sum of diagonal elements in a rectangular Matrix" do - ->{ Matrix[[1,2,3], [4,5,6]].trace}.should raise_error(Matrix::ErrDimensionMismatch) + ->{ Matrix[[1,2,3], [4,5,6]].trace}.should.raise(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/shared/transpose.rb b/spec/ruby/library/matrix/shared/transpose.rb index 89b1d025be3222..a0b495359bb782 100644 --- a/spec/ruby/library/matrix/shared/transpose.rb +++ b/spec/ruby/library/matrix/shared/transpose.rb @@ -13,7 +13,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.ins.send(@method).should be_an_instance_of(MatrixSub) + MatrixSub.ins.send(@method).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/matrix/singular_spec.rb b/spec/ruby/library/matrix/singular_spec.rb index 7bba36a54ac1fc..00b93af4958126 100644 --- a/spec/ruby/library/matrix/singular_spec.rb +++ b/spec/ruby/library/matrix/singular_spec.rb @@ -4,28 +4,28 @@ describe "Matrix#singular?" do it "returns true for singular matrices" do m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ] - m.singular?.should be_true + m.singular?.should == true m = Matrix[ [1,2,9], [3,4,9], [1,2,9] ] - m.singular?.should be_true + m.singular?.should == true end it "returns false if the Matrix is regular" do - Matrix[ [0,1], [1,0] ].singular?.should be_false + Matrix[ [0,1], [1,0] ].singular?.should == false end it "returns false for an empty 0x0 matrix" do - Matrix.empty(0,0).singular?.should be_false + Matrix.empty(0,0).singular?.should == false end it "raises an error for rectangular matrices" do -> { Matrix[[1], [2], [3]].singular? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) -> { Matrix.empty(3,0).singular? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/square_spec.rb b/spec/ruby/library/matrix/square_spec.rb index 25d2d1ad9c25d9..b8cf4acf44c7af 100644 --- a/spec/ruby/library/matrix/square_spec.rb +++ b/spec/ruby/library/matrix/square_spec.rb @@ -4,25 +4,25 @@ describe "Matrix#square?" do it "returns true when the Matrix is square" do - Matrix[ [1,2], [2,4] ].square?.should be_true - Matrix[ [100,3,5], [9.5, 4.9, 8], [2,0,77] ].square?.should be_true + Matrix[ [1,2], [2,4] ].square?.should == true + Matrix[ [100,3,5], [9.5, 4.9, 8], [2,0,77] ].square?.should == true end it "returns true when the Matrix has only one element" do - Matrix[ [9] ].square?.should be_true + Matrix[ [9] ].square?.should == true end it "returns false when the Matrix is rectangular" do - Matrix[ [1, 2] ].square?.should be_false + Matrix[ [1, 2] ].square?.should == false end it "returns false when the Matrix is rectangular" do - Matrix[ [1], [2] ].square?.should be_false + Matrix[ [1], [2] ].square?.should == false end it "returns handles empty matrices" do - Matrix[].square?.should be_true - Matrix[[]].square?.should be_false - Matrix.columns([[]]).square?.should be_false + Matrix[].square?.should == true + Matrix[[]].square?.should == false + Matrix.columns([[]]).square?.should == false end end diff --git a/spec/ruby/library/matrix/symmetric_spec.rb b/spec/ruby/library/matrix/symmetric_spec.rb index 6f2a99276ab31b..4b86c19503230f 100644 --- a/spec/ruby/library/matrix/symmetric_spec.rb +++ b/spec/ruby/library/matrix/symmetric_spec.rb @@ -3,15 +3,15 @@ describe "Matrix.symmetric?" do it "returns true for a symmetric Matrix" do - Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, 3), 5, 6]].symmetric?.should be_true + Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, 3), 5, 6]].symmetric?.should == true end it "returns true for a 0x0 empty matrix" do - Matrix.empty.symmetric?.should be_true + Matrix.empty.symmetric?.should == true end it "returns false for an asymmetric Matrix" do - Matrix[[1, 2],[-2, 1]].symmetric?.should be_false + Matrix[[1, 2],[-2, 1]].symmetric?.should == false end it "raises an error for rectangular matrices" do @@ -23,7 +23,7 @@ ].each do |rectangular_matrix| -> { rectangular_matrix.symmetric? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb index c214ee9b2f6562..4490e8f8d4ef09 100644 --- a/spec/ruby/library/matrix/unitary_spec.rb +++ b/spec/ruby/library/matrix/unitary_spec.rb @@ -26,7 +26,7 @@ ].each do |rectangular_matrix| -> { rectangular_matrix.unitary? - }.should raise_error(Matrix::ErrDimensionMismatch) + }.should.raise(Matrix::ErrDimensionMismatch) end end end diff --git a/spec/ruby/library/matrix/upper_triangular_spec.rb b/spec/ruby/library/matrix/upper_triangular_spec.rb index 2514294a804c70..0e2bf611e20c31 100644 --- a/spec/ruby/library/matrix/upper_triangular_spec.rb +++ b/spec/ruby/library/matrix/upper_triangular_spec.rb @@ -3,22 +3,22 @@ describe "Matrix.upper_triangular?" do it "returns true for an upper triangular Matrix" do - Matrix[[1, 2, 3], [0, 2, 3], [0, 0, 3]].upper_triangular?.should be_true - Matrix.diagonal([1, 2, 3]).upper_triangular?.should be_true - Matrix[[1, 2], [0, 2], [0, 0], [0, 0]].upper_triangular?.should be_true - Matrix[[1, 2, 3, 4], [0, 2, 3, 4]].upper_triangular?.should be_true + Matrix[[1, 2, 3], [0, 2, 3], [0, 0, 3]].upper_triangular?.should == true + Matrix.diagonal([1, 2, 3]).upper_triangular?.should == true + Matrix[[1, 2], [0, 2], [0, 0], [0, 0]].upper_triangular?.should == true + Matrix[[1, 2, 3, 4], [0, 2, 3, 4]].upper_triangular?.should == true end it "returns false for a non upper triangular square Matrix" do - Matrix[[0, 0], [1, 0]].upper_triangular?.should be_false - Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].upper_triangular?.should be_false - Matrix[[0, 0], [0, 0], [0, 0], [0, 1]].upper_triangular?.should be_false - Matrix[[0, 0, 0, 0], [1, 0, 0, 0]].upper_triangular?.should be_false + Matrix[[0, 0], [1, 0]].upper_triangular?.should == false + Matrix[[1, 2, 3], [1, 2, 3], [1, 2, 3]].upper_triangular?.should == false + Matrix[[0, 0], [0, 0], [0, 0], [0, 1]].upper_triangular?.should == false + Matrix[[0, 0, 0, 0], [1, 0, 0, 0]].upper_triangular?.should == false end it "returns true for an empty matrix" do - Matrix.empty(3,0).upper_triangular?.should be_true - Matrix.empty(0,3).upper_triangular?.should be_true - Matrix.empty(0,0).upper_triangular?.should be_true + Matrix.empty(3,0).upper_triangular?.should == true + Matrix.empty(0,3).upper_triangular?.should == true + Matrix.empty(0,0).upper_triangular?.should == true end end diff --git a/spec/ruby/library/matrix/vector/cross_product_spec.rb b/spec/ruby/library/matrix/vector/cross_product_spec.rb index c2698ade4c7554..96a462c067d755 100644 --- a/spec/ruby/library/matrix/vector/cross_product_spec.rb +++ b/spec/ruby/library/matrix/vector/cross_product_spec.rb @@ -9,6 +9,6 @@ it "raises an error unless both vectors have dimension 3" do -> { Vector[1, 2, 3].cross_product(Vector[0, -4]) - }.should raise_error(Vector::ErrDimensionMismatch) + }.should.raise(Vector::ErrDimensionMismatch) end end diff --git a/spec/ruby/library/matrix/vector/each2_spec.rb b/spec/ruby/library/matrix/vector/each2_spec.rb index 10d2fc404d4425..86e7ed75aa4a05 100644 --- a/spec/ruby/library/matrix/vector/each2_spec.rb +++ b/spec/ruby/library/matrix/vector/each2_spec.rb @@ -8,8 +8,8 @@ end it "requires one argument" do - -> { @v.each2(@v2, @v2){} }.should raise_error(ArgumentError) - -> { @v.each2(){} }.should raise_error(ArgumentError) + -> { @v.each2(@v2, @v2){} }.should.raise(ArgumentError) + -> { @v.each2(){} }.should.raise(ArgumentError) end describe "given one argument" do @@ -20,8 +20,8 @@ end it "raises a DimensionMismatch error if the Vector size is different" do - -> { @v.each2(Vector[1,2]){} }.should raise_error(Vector::ErrDimensionMismatch) - -> { @v.each2(Vector[1,2,3,4]){} }.should raise_error(Vector::ErrDimensionMismatch) + -> { @v.each2(Vector[1,2]){} }.should.raise(Vector::ErrDimensionMismatch) + -> { @v.each2(Vector[1,2,3,4]){} }.should.raise(Vector::ErrDimensionMismatch) end it "yields arguments in sequence" do @@ -37,12 +37,12 @@ end it "returns self when given a block" do - @v.each2(@v2){}.should equal(@v) + @v.each2(@v2){}.should.equal?(@v) end it "returns an enumerator if no block given" do enum = @v.each2(@v2) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == [[1, 4], [2, 5], [3, 6]] end end diff --git a/spec/ruby/library/matrix/vector/eql_spec.rb b/spec/ruby/library/matrix/vector/eql_spec.rb index eb2451b550dd8b..6e2cd47b8e4e5f 100644 --- a/spec/ruby/library/matrix/vector/eql_spec.rb +++ b/spec/ruby/library/matrix/vector/eql_spec.rb @@ -7,10 +7,10 @@ end it "returns true for self" do - @vector.eql?(@vector).should be_true + @vector.eql?(@vector).should == true end it "returns false when there are a pair corresponding elements which are not equal in the sense of Kernel#eql?" do - @vector.eql?(Vector[1, 2, 3, 4, 5.0]).should be_false + @vector.eql?(Vector[1, 2, 3, 4, 5.0]).should == false end end diff --git a/spec/ruby/library/matrix/vector/inner_product_spec.rb b/spec/ruby/library/matrix/vector/inner_product_spec.rb index 1cf8771e0450b4..79dee108338b5a 100644 --- a/spec/ruby/library/matrix/vector/inner_product_spec.rb +++ b/spec/ruby/library/matrix/vector/inner_product_spec.rb @@ -13,7 +13,7 @@ it "raises an error for mismatched vectors" do -> { Vector[1, 2, 3].inner_product(Vector[0, -4]) - }.should raise_error(Vector::ErrDimensionMismatch) + }.should.raise(Vector::ErrDimensionMismatch) end it "uses the conjugate of its argument" do diff --git a/spec/ruby/library/matrix/vector/normalize_spec.rb b/spec/ruby/library/matrix/vector/normalize_spec.rb index 527c9260debf3f..bb1f04678650d5 100644 --- a/spec/ruby/library/matrix/vector/normalize_spec.rb +++ b/spec/ruby/library/matrix/vector/normalize_spec.rb @@ -10,9 +10,9 @@ it "raises an error for zero vectors" do -> { Vector[].normalize - }.should raise_error(Vector::ZeroVectorError) + }.should.raise(Vector::ZeroVectorError) -> { Vector[0, 0, 0].normalize - }.should raise_error(Vector::ZeroVectorError) + }.should.raise(Vector::ZeroVectorError) end end diff --git a/spec/ruby/library/matrix/zero_spec.rb b/spec/ruby/library/matrix/zero_spec.rb index 68e8567c260256..406bcad6eda217 100644 --- a/spec/ruby/library/matrix/zero_spec.rb +++ b/spec/ruby/library/matrix/zero_spec.rb @@ -4,7 +4,7 @@ describe "Matrix.zero" do it "returns an object of type Matrix" do - Matrix.zero(3).should be_kind_of(Matrix) + Matrix.zero(3).should.is_a?(Matrix) end it "creates a n x n matrix" do @@ -30,7 +30,7 @@ describe "for a subclass of Matrix" do it "returns an instance of that subclass" do - MatrixSub.zero(3).should be_an_instance_of(MatrixSub) + MatrixSub.zero(3).should.instance_of?(MatrixSub) end end end diff --git a/spec/ruby/library/monitor/exit_spec.rb b/spec/ruby/library/monitor/exit_spec.rb index 952ad9525db1c6..0748a523ace586 100644 --- a/spec/ruby/library/monitor/exit_spec.rb +++ b/spec/ruby/library/monitor/exit_spec.rb @@ -5,6 +5,6 @@ it "raises ThreadError when monitor is not entered" do m = Monitor.new - -> { m.exit }.should raise_error(ThreadError) + -> { m.exit }.should.raise(ThreadError) end end diff --git a/spec/ruby/library/monitor/mon_initialize_spec.rb b/spec/ruby/library/monitor/mon_initialize_spec.rb index e0fe6c2d979996..092aee929c50e9 100644 --- a/spec/ruby/library/monitor/mon_initialize_spec.rb +++ b/spec/ruby/library/monitor/mon_initialize_spec.rb @@ -26,6 +26,6 @@ def initialize_copy(other) instance = cls.new(1, 2, 3) copy = instance.dup - copy.should_not equal(instance) + copy.should_not.equal?(instance) end end diff --git a/spec/ruby/library/monitor/synchronize_spec.rb b/spec/ruby/library/monitor/synchronize_spec.rb index d78393eb3a44d2..27cc1258b442d0 100644 --- a/spec/ruby/library/monitor/synchronize_spec.rb +++ b/spec/ruby/library/monitor/synchronize_spec.rb @@ -31,11 +31,11 @@ end it "raises a LocalJumpError if not passed a block" do - -> { Monitor.new.synchronize }.should raise_error(LocalJumpError) + -> { Monitor.new.synchronize }.should.raise(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) + -> { monitor.synchronize { monitor.exit } }.should.raise(ThreadError) end end diff --git a/spec/ruby/library/net-ftp/abort_spec.rb b/spec/ruby/library/net-ftp/abort_spec.rb index d9fed456539940..9e8be53c6839a7 100644 --- a/spec/ruby/library/net-ftp/abort_spec.rb +++ b/spec/ruby/library/net-ftp/abort_spec.rb @@ -20,7 +20,7 @@ end it "sends the ABOR command to the server" do - -> { @ftp.abort }.should_not raise_error + -> { @ftp.abort }.should_not.raise end it "ignores the response" do @@ -34,32 +34,32 @@ it "does not raise any error when the response code is 225" do @server.should_receive(:abor).and_respond("225 Data connection open; no transfer in progress.") - -> { @ftp.abort }.should_not raise_error + -> { @ftp.abort }.should_not.raise end it "does not raise any error when the response code is 226" do @server.should_receive(:abor).and_respond("226 Closing data connection.") - -> { @ftp.abort }.should_not raise_error + -> { @ftp.abort }.should_not.raise end it "raises a Net::FTPProtoError when the response code is 500" do @server.should_receive(:abor).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.abort }.should raise_error(Net::FTPProtoError) + -> { @ftp.abort }.should.raise(Net::FTPProtoError) end it "raises a Net::FTPProtoError when the response code is 501" do @server.should_receive(:abor).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.abort }.should raise_error(Net::FTPProtoError) + -> { @ftp.abort }.should.raise(Net::FTPProtoError) end it "raises a Net::FTPProtoError when the response code is 502" do @server.should_receive(:abor).and_respond("502 Command not implemented.") - -> { @ftp.abort }.should raise_error(Net::FTPProtoError) + -> { @ftp.abort }.should.raise(Net::FTPProtoError) end it "raises a Net::FTPProtoError when the response code is 421" do @server.should_receive(:abor).and_respond("421 Service not available, closing control connection.") - -> { @ftp.abort }.should raise_error(Net::FTPProtoError) + -> { @ftp.abort }.should.raise(Net::FTPProtoError) end end end diff --git a/spec/ruby/library/net-ftp/acct_spec.rb b/spec/ruby/library/net-ftp/acct_spec.rb index 93214a84d71c3c..a64a0f48a82cd0 100644 --- a/spec/ruby/library/net-ftp/acct_spec.rb +++ b/spec/ruby/library/net-ftp/acct_spec.rb @@ -30,32 +30,32 @@ it "does not raise any error when the response code is 230" do @server.should_receive(:acct).and_respond("230 User logged in, proceed.") - -> { @ftp.acct("my_account") }.should_not raise_error + -> { @ftp.acct("my_account") }.should_not.raise end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:acct).and_respond("530 Not logged in.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError) + -> { @ftp.acct("my_account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:acct).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError) + -> { @ftp.acct("my_account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:acct).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError) + -> { @ftp.acct("my_account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 503" do @server.should_receive(:acct).and_respond("503 Bad sequence of commands.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError) + -> { @ftp.acct("my_account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:acct).and_respond("421 Service not available, closing control connection.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPTempError) + -> { @ftp.acct("my_account") }.should.raise(Net::FTPTempError) end end end diff --git a/spec/ruby/library/net-ftp/binary_spec.rb b/spec/ruby/library/net-ftp/binary_spec.rb index 22a5fe65ab9835..de8d0ac10385f6 100644 --- a/spec/ruby/library/net-ftp/binary_spec.rb +++ b/spec/ruby/library/net-ftp/binary_spec.rb @@ -6,10 +6,10 @@ describe "Net::FTP#binary" do it "returns true when self is in binary mode" do ftp = Net::FTP.new - ftp.binary.should be_true + ftp.binary.should == true ftp.binary = false - ftp.binary.should be_false + ftp.binary.should == false end end @@ -18,10 +18,10 @@ ftp = Net::FTP.new ftp.binary = true - ftp.binary.should be_true + ftp.binary.should == true ftp.binary = false - ftp.binary.should be_false + ftp.binary.should == false end end end diff --git a/spec/ruby/library/net-ftp/chdir_spec.rb b/spec/ruby/library/net-ftp/chdir_spec.rb index 46eda09d1d89cb..f8f352158cbb0c 100644 --- a/spec/ruby/library/net-ftp/chdir_spec.rb +++ b/spec/ruby/library/net-ftp/chdir_spec.rb @@ -26,37 +26,37 @@ end it "returns nil" do - @ftp.chdir("..").should be_nil + @ftp.chdir("..").should == nil end it "does not raise a Net::FTPPermError when the response code is 500" do @server.should_receive(:cdup).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.chdir("..") }.should_not raise_error(Net::FTPPermError) + -> { @ftp.chdir("..") }.should_not.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:cdup).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError) + -> { @ftp.chdir("..") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:cdup).and_respond("502 Command not implemented.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError) + -> { @ftp.chdir("..") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:cdup).and_respond("421 Service not available, closing control connection.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPTempError) + -> { @ftp.chdir("..") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:cdup).and_respond("530 Not logged in.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError) + -> { @ftp.chdir("..") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:cdup).and_respond("550 Requested action not taken.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError) + -> { @ftp.chdir("..") }.should.raise(Net::FTPPermError) end end @@ -66,37 +66,37 @@ end it "returns nil" do - @ftp.chdir("test").should be_nil + @ftp.chdir("test").should == nil end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:cwd).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) + -> { @ftp.chdir("test") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:cwd).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) + -> { @ftp.chdir("test") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:cwd).and_respond("502 Command not implemented.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) + -> { @ftp.chdir("test") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:cwd).and_respond("421 Service not available, closing control connection.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPTempError) + -> { @ftp.chdir("test") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:cwd).and_respond("530 Not logged in.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) + -> { @ftp.chdir("test") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:cwd).and_respond("550 Requested action not taken.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) + -> { @ftp.chdir("test") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/close_spec.rb b/spec/ruby/library/net-ftp/close_spec.rb index 57d06cc3e62a7e..9d5d4c638ada32 100644 --- a/spec/ruby/library/net-ftp/close_spec.rb +++ b/spec/ruby/library/net-ftp/close_spec.rb @@ -16,18 +16,18 @@ it "closes the socket" do @socket.should_receive(:close) - @ftp.close.should be_nil + @ftp.close.should == nil end it "does not try to close the socket if it has already been closed" do @socket.should_receive(:closed?).and_return(true) @socket.should_not_receive(:close) - @ftp.close.should be_nil + @ftp.close.should == nil end it "does not try to close the socket if it is nil" do @ftp.instance_variable_set(:@sock, nil) - @ftp.close.should be_nil + @ftp.close.should == nil end end end diff --git a/spec/ruby/library/net-ftp/closed_spec.rb b/spec/ruby/library/net-ftp/closed_spec.rb index 3dd0025aeea307..1c8693932e3042 100644 --- a/spec/ruby/library/net-ftp/closed_spec.rb +++ b/spec/ruby/library/net-ftp/closed_spec.rb @@ -13,12 +13,12 @@ it "returns true when the socket is closed" do @socket.should_receive(:closed?).and_return(true) - @ftp.closed?.should be_true + @ftp.closed?.should == true end it "returns true when the socket is nil" do @ftp.instance_variable_set(:@sock, nil) - @ftp.closed?.should be_true + @ftp.closed?.should == true end end end diff --git a/spec/ruby/library/net-ftp/connect_spec.rb b/spec/ruby/library/net-ftp/connect_spec.rb index 31d64ca7585306..597381f67c96bc 100644 --- a/spec/ruby/library/net-ftp/connect_spec.rb +++ b/spec/ruby/library/net-ftp/connect_spec.rb @@ -21,26 +21,26 @@ end it "tries to connect to the FTP Server on the given host and port" do - -> { @ftp.connect(@server.hostname, @server.server_port) }.should_not raise_error + -> { @ftp.connect(@server.hostname, @server.server_port) }.should_not.raise end it "returns nil" do - @ftp.connect(@server.hostname, @server.server_port).should be_nil + @ftp.connect(@server.hostname, @server.server_port).should == nil end it "does not raise any error when the response code is 220" do @server.connect_message = "220 Dummy FTP Server ready!" - -> { @ftp.connect(@server.hostname, @server.server_port) }.should_not raise_error + -> { @ftp.connect(@server.hostname, @server.server_port) }.should_not.raise end it "raises a Net::FTPReplyError when the response code is 120" do @server.connect_message = "120 Service ready in nnn minutes." - -> { @ftp.connect(@server.hostname, @server.server_port) }.should raise_error(Net::FTPReplyError) + -> { @ftp.connect(@server.hostname, @server.server_port) }.should.raise(Net::FTPReplyError) end it "raises a Net::FTPTempError when the response code is 421" do @server.connect_message = "421 Service not available, closing control connection." - -> { @ftp.connect(@server.hostname, @server.server_port) }.should raise_error(Net::FTPTempError) + -> { @ftp.connect(@server.hostname, @server.server_port) }.should.raise(Net::FTPTempError) end end end diff --git a/spec/ruby/library/net-ftp/debug_mode_spec.rb b/spec/ruby/library/net-ftp/debug_mode_spec.rb index 2a26e689e712eb..28765b9d1c7dcb 100644 --- a/spec/ruby/library/net-ftp/debug_mode_spec.rb +++ b/spec/ruby/library/net-ftp/debug_mode_spec.rb @@ -6,10 +6,10 @@ describe "Net::FTP#debug_mode" do it "returns true when self is in debug mode" do ftp = Net::FTP.new - ftp.debug_mode.should be_false + ftp.debug_mode.should == false ftp.debug_mode = true - ftp.debug_mode.should be_true + ftp.debug_mode.should == true end end @@ -17,10 +17,10 @@ it "sets self into debug mode when passed true" do ftp = Net::FTP.new ftp.debug_mode = true - ftp.debug_mode.should be_true + ftp.debug_mode.should == true ftp.debug_mode = false - ftp.debug_mode.should be_false + ftp.debug_mode.should == false end end end diff --git a/spec/ruby/library/net-ftp/delete_spec.rb b/spec/ruby/library/net-ftp/delete_spec.rb index 117ffd93bca811..40cd8f1d99af96 100644 --- a/spec/ruby/library/net-ftp/delete_spec.rb +++ b/spec/ruby/library/net-ftp/delete_spec.rb @@ -26,37 +26,37 @@ it "raises a Net::FTPTempError when the response code is 450" do @server.should_receive(:dele).and_respond("450 Requested file action not taken.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPTempError) + -> { @ftp.delete("test.file") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:dele).and_respond("550 Requested action not taken.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.delete("test.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:dele).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.delete("test.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:dele).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.delete("test.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:dele).and_respond("502 Command not implemented.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.delete("test.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:dele).and_respond("421 Service not available, closing control connection.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPTempError) + -> { @ftp.delete("test.file") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:dele).and_respond("530 Not logged in.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.delete("test.file") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/help_spec.rb b/spec/ruby/library/net-ftp/help_spec.rb index 442d8aa93d5828..bb52fb9e696c51 100644 --- a/spec/ruby/library/net-ftp/help_spec.rb +++ b/spec/ruby/library/net-ftp/help_spec.rb @@ -38,32 +38,32 @@ def with_connection it "does not raise any error when the response code is 211" do @server.should_receive(:help).and_respond("211 System status, or system help reply.") - -> { @ftp.help }.should_not raise_error + -> { @ftp.help }.should_not.raise end it "does not raise any error when the response code is 214" do @server.should_receive(:help).and_respond("214 Help message.") - -> { @ftp.help }.should_not raise_error + -> { @ftp.help }.should_not.raise end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:help).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.help }.should raise_error(Net::FTPPermError) + -> { @ftp.help }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:help).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.help }.should raise_error(Net::FTPPermError) + -> { @ftp.help }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:help).and_respond("502 Command not implemented.") - -> { @ftp.help }.should raise_error(Net::FTPPermError) + -> { @ftp.help }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:help).and_respond("421 Service not available, closing control connection.") - -> { @ftp.help }.should raise_error(Net::FTPTempError) + -> { @ftp.help }.should.raise(Net::FTPTempError) end end end diff --git a/spec/ruby/library/net-ftp/initialize_spec.rb b/spec/ruby/library/net-ftp/initialize_spec.rb index 8a22e5884272d1..9079ad6b795795 100644 --- a/spec/ruby/library/net-ftp/initialize_spec.rb +++ b/spec/ruby/library/net-ftp/initialize_spec.rb @@ -12,31 +12,31 @@ end it "is private" do - Net::FTP.should have_private_instance_method(:initialize) + Net::FTP.private_instance_methods(false).should.include?(:initialize) end it "sets self into binary mode" do - @ftp.binary.should be_nil + @ftp.binary.should == nil @ftp.send(:initialize) - @ftp.binary.should be_true + @ftp.binary.should == true end it "sets self into active mode" do - @ftp.passive.should be_nil + @ftp.passive.should == nil @ftp.send(:initialize) - @ftp.passive.should be_false + @ftp.passive.should == false end it "sets self into non-debug mode" do - @ftp.debug_mode.should be_nil + @ftp.debug_mode.should == nil @ftp.send(:initialize) - @ftp.debug_mode.should be_false + @ftp.debug_mode.should == false end it "sets self to not resume file uploads/downloads" do - @ftp.resume.should be_nil + @ftp.resume.should == nil @ftp.send(:initialize) - @ftp.resume.should be_false + @ftp.resume.should == false end describe "when passed no arguments" do @@ -388,7 +388,7 @@ -> { @ftp.send(:initialize, nil, options) - }.should raise_error(ArgumentError, /private_data_connection can be set to true only when ssl is enabled/) + }.should.raise(ArgumentError, /private_data_connection can be set to true only when ssl is enabled/) end end diff --git a/spec/ruby/library/net-ftp/login_spec.rb b/spec/ruby/library/net-ftp/login_spec.rb index 0959bbb1919257..05bb6b7f8123e4 100644 --- a/spec/ruby/library/net-ftp/login_spec.rb +++ b/spec/ruby/library/net-ftp/login_spec.rb @@ -34,7 +34,7 @@ it "raises a Net::FTPReplyError when the server requests an account" do @server.should_receive(:user).and_respond("331 User name okay, need password.") @server.should_receive(:pass).and_respond("332 Need account for login.") - -> { @ftp.login }.should raise_error(Net::FTPReplyError) + -> { @ftp.login }.should.raise(Net::FTPReplyError) end end @@ -46,13 +46,13 @@ it "raises a Net::FTPReplyError when the server requests a password, but none was given" do @server.should_receive(:user).and_respond("331 User name okay, need password.") - -> { @ftp.login("rubyspec") }.should raise_error(Net::FTPReplyError) + -> { @ftp.login("rubyspec") }.should.raise(Net::FTPReplyError) end it "raises a Net::FTPReplyError when the server requests an account, but none was given" do @server.should_receive(:user).and_respond("331 User name okay, need password.") @server.should_receive(:pass).and_respond("332 Need account for login.") - -> { @ftp.login("rubyspec") }.should raise_error(Net::FTPReplyError) + -> { @ftp.login("rubyspec") }.should.raise(Net::FTPReplyError) end end @@ -71,7 +71,7 @@ it "raises a Net::FTPReplyError when the server requests an account" do @server.should_receive(:user).and_respond("331 User name okay, need password.") @server.should_receive(:pass).and_respond("332 Need account for login.") - -> { @ftp.login("rubyspec", "rocks") }.should raise_error(Net::FTPReplyError) + -> { @ftp.login("rubyspec", "rocks") }.should.raise(Net::FTPReplyError) end end @@ -98,27 +98,27 @@ describe "when the USER command fails" do it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:user).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:user).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:user).and_respond("502 Command not implemented.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:user).and_respond("421 Service not available, closing control connection.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:user).and_respond("530 Not logged in.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end end @@ -129,32 +129,32 @@ it "does not raise an Error when the response code is 202" do @server.should_receive(:pass).and_respond("202 Command not implemented, superfluous at this site.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should_not raise_error + -> { @ftp.login("rubyspec", "rocks", "account") }.should_not.raise end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:pass).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:pass).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:pass).and_respond("502 Command not implemented.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:pass).and_respond("421 Service not available, closing control connection.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:pass).and_respond("530 Not logged in.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end end @@ -166,32 +166,32 @@ it "does not raise an Error when the response code is 202" do @server.should_receive(:acct).and_respond("202 Command not implemented, superfluous at this site.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should_not raise_error + -> { @ftp.login("rubyspec", "rocks", "account") }.should_not.raise end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:acct).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:acct).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:acct).and_respond("502 Command not implemented.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:acct).and_respond("421 Service not available, closing control connection.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:acct).and_respond("530 Not logged in.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) + -> { @ftp.login("rubyspec", "rocks", "account") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/mdtm_spec.rb b/spec/ruby/library/net-ftp/mdtm_spec.rb index 4334833215e4b6..effd22a6e4800e 100644 --- a/spec/ruby/library/net-ftp/mdtm_spec.rb +++ b/spec/ruby/library/net-ftp/mdtm_spec.rb @@ -30,12 +30,12 @@ it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:mdtm).and_respond("550 Requested action not taken.") - -> { @ftp.mdtm("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.mdtm("test.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:mdtm).and_respond("421 Service not available, closing control connection.") - -> { @ftp.mdtm("test.file") }.should raise_error(Net::FTPTempError) + -> { @ftp.mdtm("test.file") }.should.raise(Net::FTPTempError) end end end diff --git a/spec/ruby/library/net-ftp/mkdir_spec.rb b/spec/ruby/library/net-ftp/mkdir_spec.rb index 9fdaa62ae3bc23..6daeb7c0229360 100644 --- a/spec/ruby/library/net-ftp/mkdir_spec.rb +++ b/spec/ruby/library/net-ftp/mkdir_spec.rb @@ -33,32 +33,32 @@ it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:mkd).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.mkdir("test.folder") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:mkd).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.mkdir("test.folder") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:mkd).and_respond("502 Command not implemented.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.mkdir("test.folder") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:mkd).and_respond("421 Service not available, closing control connection.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPTempError) + -> { @ftp.mkdir("test.folder") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:mkd).and_respond("530 Not logged in.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.mkdir("test.folder") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:mkd).and_respond("550 Requested action not taken.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.mkdir("test.folder") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/mtime_spec.rb b/spec/ruby/library/net-ftp/mtime_spec.rb index 01b68ea674b3cb..694036a2960db4 100644 --- a/spec/ruby/library/net-ftp/mtime_spec.rb +++ b/spec/ruby/library/net-ftp/mtime_spec.rb @@ -42,12 +42,12 @@ it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:mdtm).and_respond("550 Requested action not taken.") - -> { @ftp.mtime("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.mtime("test.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:mdtm).and_respond("421 Service not available, closing control connection.") - -> { @ftp.mtime("test.file") }.should raise_error(Net::FTPTempError) + -> { @ftp.mtime("test.file") }.should.raise(Net::FTPTempError) end end end diff --git a/spec/ruby/library/net-ftp/nlst_spec.rb b/spec/ruby/library/net-ftp/nlst_spec.rb index c78717259f2340..87b80b43fde969 100644 --- a/spec/ruby/library/net-ftp/nlst_spec.rb +++ b/spec/ruby/library/net-ftp/nlst_spec.rb @@ -37,32 +37,32 @@ describe "when the NLST command fails" do it "raises a Net::FTPTempError when the response code is 450" do @server.should_receive(:nlst).and_respond("450 Requested file action not taken..") - -> { @ftp.nlst }.should raise_error(Net::FTPTempError) + -> { @ftp.nlst }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:nlst).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) + -> { @ftp.nlst }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:nlst).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) + -> { @ftp.nlst }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:nlst).and_respond("502 Command not implemented.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) + -> { @ftp.nlst }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:nlst).and_respond("421 Service not available, closing control connection.") - -> { @ftp.nlst }.should raise_error(Net::FTPTempError) + -> { @ftp.nlst }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:nlst).and_respond("530 Not logged in.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) + -> { @ftp.nlst }.should.raise(Net::FTPPermError) end end @@ -70,25 +70,25 @@ it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) + -> { @ftp.nlst }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) + -> { @ftp.nlst }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.nlst }.should raise_error(Net::FTPTempError) + -> { @ftp.nlst }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:eprt).and_respond("530 Not logged in.") @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) + -> { @ftp.nlst }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/noop_spec.rb b/spec/ruby/library/net-ftp/noop_spec.rb index 4995e781743ba1..43c48e355a3122 100644 --- a/spec/ruby/library/net-ftp/noop_spec.rb +++ b/spec/ruby/library/net-ftp/noop_spec.rb @@ -25,17 +25,17 @@ end it "returns nil" do - @ftp.noop.should be_nil + @ftp.noop.should == nil end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:noop).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.noop }.should raise_error(Net::FTPPermError) + -> { @ftp.noop }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:noop).and_respond("421 Service not available, closing control connection.") - -> { @ftp.noop }.should raise_error(Net::FTPTempError) + -> { @ftp.noop }.should.raise(Net::FTPTempError) end end end diff --git a/spec/ruby/library/net-ftp/open_spec.rb b/spec/ruby/library/net-ftp/open_spec.rb index 7678cee459679d..2d6477ec4d31df 100644 --- a/spec/ruby/library/net-ftp/open_spec.rb +++ b/spec/ruby/library/net-ftp/open_spec.rb @@ -11,7 +11,7 @@ describe "when passed no block" do it "returns a new Net::FTP instance" do - Net::FTP.open("localhost").should equal(@ftp) + Net::FTP.open("localhost").should.equal?(@ftp) end it "passes the passed arguments down to Net::FTP.new" do @@ -29,9 +29,9 @@ yielded = false Net::FTP.open("localhost") do |ftp| yielded = true - ftp.should equal(@ftp) + ftp.should.equal?(@ftp) end - yielded.should be_true + yielded.should == true end it "closes the Net::FTP instance after yielding" do diff --git a/spec/ruby/library/net-ftp/passive_spec.rb b/spec/ruby/library/net-ftp/passive_spec.rb index 29351846f9ec1d..6acabd3f989c42 100644 --- a/spec/ruby/library/net-ftp/passive_spec.rb +++ b/spec/ruby/library/net-ftp/passive_spec.rb @@ -6,10 +6,10 @@ describe "Net::FTP#passive" do it "returns true when self is in passive mode" do ftp = Net::FTP.new - ftp.passive.should be_false + ftp.passive.should == false ftp.passive = true - ftp.passive.should be_true + ftp.passive.should == true end it "is the value of Net::FTP.default_value by default" do @@ -22,10 +22,10 @@ ftp = Net::FTP.new ftp.passive = true - ftp.passive.should be_true + ftp.passive.should == true ftp.passive = false - ftp.passive.should be_false + ftp.passive.should == false end end end diff --git a/spec/ruby/library/net-ftp/pwd_spec.rb b/spec/ruby/library/net-ftp/pwd_spec.rb index 8358c68310bbf2..53692b553f38a3 100644 --- a/spec/ruby/library/net-ftp/pwd_spec.rb +++ b/spec/ruby/library/net-ftp/pwd_spec.rb @@ -30,27 +30,27 @@ it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:pwd).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.pwd }.should raise_error(Net::FTPPermError) + -> { @ftp.pwd }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:pwd).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.pwd }.should raise_error(Net::FTPPermError) + -> { @ftp.pwd }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:pwd).and_respond("502 Command not implemented.") - -> { @ftp.pwd }.should raise_error(Net::FTPPermError) + -> { @ftp.pwd }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:pwd).and_respond("421 Service not available, closing control connection.") - -> { @ftp.pwd }.should raise_error(Net::FTPTempError) + -> { @ftp.pwd }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:pwd).and_respond("550 Requested action not taken.") - -> { @ftp.pwd }.should raise_error(Net::FTPPermError) + -> { @ftp.pwd }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/quit_spec.rb b/spec/ruby/library/net-ftp/quit_spec.rb index 4a52f06963e578..1af0107d344261 100644 --- a/spec/ruby/library/net-ftp/quit_spec.rb +++ b/spec/ruby/library/net-ftp/quit_spec.rb @@ -26,11 +26,11 @@ it "does not close the socket automatically" do @ftp.quit - @ftp.closed?.should be_false + @ftp.closed?.should == false end it "returns nil" do - @ftp.quit.should be_nil + @ftp.quit.should == nil end end end diff --git a/spec/ruby/library/net-ftp/rename_spec.rb b/spec/ruby/library/net-ftp/rename_spec.rb index 85f97757bc744f..6541fe53013b89 100644 --- a/spec/ruby/library/net-ftp/rename_spec.rb +++ b/spec/ruby/library/net-ftp/rename_spec.rb @@ -26,71 +26,71 @@ end it "returns something" do - @ftp.rename("from.file", "to.file").should be_nil + @ftp.rename("from.file", "to.file").should == nil end end describe "when the RNFR command fails" do it "raises a Net::FTPTempError when the response code is 450" do @server.should_receive(:rnfr).and_respond("450 Requested file action not taken.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:rnfr).and_respond("550 Requested action not taken.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:rnfr).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:rnfr).and_respond("502 Command not implemented.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:rnfr).and_respond("421 Service not available, closing control connection.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:rnfr).and_respond("530 Not logged in.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPPermError) end end describe "when the RNTO command fails" do it "raises a Net::FTPPermError when the response code is 532" do @server.should_receive(:rnfr).and_respond("532 Need account for storing files.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 553" do @server.should_receive(:rnto).and_respond("553 Requested action not taken.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:rnto).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:rnto).and_respond("502 Command not implemented.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:rnto).and_respond("421 Service not available, closing control connection.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:rnto).and_respond("530 Not logged in.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.rename("from.file", "to.file") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/resume_spec.rb b/spec/ruby/library/net-ftp/resume_spec.rb index 079878d24b6367..5ec565d1559ba1 100644 --- a/spec/ruby/library/net-ftp/resume_spec.rb +++ b/spec/ruby/library/net-ftp/resume_spec.rb @@ -6,10 +6,10 @@ describe "Net::FTP#resume" do it "returns true when self is set to resume uploads/downloads" do ftp = Net::FTP.new - ftp.resume.should be_false + ftp.resume.should == false ftp.resume = true - ftp.resume.should be_true + ftp.resume.should == true end end @@ -17,10 +17,10 @@ it "sets self to resume uploads/downloads when set to true" do ftp = Net::FTP.new ftp.resume = true - ftp.resume.should be_true + ftp.resume.should == true ftp.resume = false - ftp.resume.should be_false + ftp.resume.should == false end end end diff --git a/spec/ruby/library/net-ftp/rmdir_spec.rb b/spec/ruby/library/net-ftp/rmdir_spec.rb index 0b52b53782fc85..23650ebcc86170 100644 --- a/spec/ruby/library/net-ftp/rmdir_spec.rb +++ b/spec/ruby/library/net-ftp/rmdir_spec.rb @@ -25,37 +25,37 @@ end it "returns nil" do - @ftp.rmdir("test.folder").should be_nil + @ftp.rmdir("test.folder").should == nil end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:rmd).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.rmdir("test.folder") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:rmd).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.rmdir("test.folder") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:rmd).and_respond("502 Command not implemented.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.rmdir("test.folder") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:rmd).and_respond("421 Service not available, closing control connection.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPTempError) + -> { @ftp.rmdir("test.folder") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:rmd).and_respond("530 Not logged in.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.rmdir("test.folder") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:rmd).and_respond("550 Requested action not taken.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) + -> { @ftp.rmdir("test.folder") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/sendcmd_spec.rb b/spec/ruby/library/net-ftp/sendcmd_spec.rb index 5deca804b28de6..67dbd3bdb84e9d 100644 --- a/spec/ruby/library/net-ftp/sendcmd_spec.rb +++ b/spec/ruby/library/net-ftp/sendcmd_spec.rb @@ -30,28 +30,28 @@ it "raises no error when the response code is 1xx, 2xx or 3xx" do @server.should_receive(:help).and_respond("120 Service ready in nnn minutes.") - -> { @ftp.sendcmd("HELP") }.should_not raise_error + -> { @ftp.sendcmd("HELP") }.should_not.raise @server.should_receive(:help).and_respond("200 Command okay.") - -> { @ftp.sendcmd("HELP") }.should_not raise_error + -> { @ftp.sendcmd("HELP") }.should_not.raise @server.should_receive(:help).and_respond("350 Requested file action pending further information.") - -> { @ftp.sendcmd("HELP") }.should_not raise_error + -> { @ftp.sendcmd("HELP") }.should_not.raise end it "raises a Net::FTPTempError when the response code is 4xx" do @server.should_receive(:help).and_respond("421 Service not available, closing control connection.") - -> { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPTempError) + -> { @ftp.sendcmd("HELP") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 5xx" do @server.should_receive(:help).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPPermError) + -> { @ftp.sendcmd("HELP") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPProtoError when the response code is not between 1xx-5xx" do @server.should_receive(:help).and_respond("999 Invalid response.") - -> { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPProtoError) + -> { @ftp.sendcmd("HELP") }.should.raise(Net::FTPProtoError) end end end diff --git a/spec/ruby/library/net-ftp/shared/getbinaryfile.rb b/spec/ruby/library/net-ftp/shared/getbinaryfile.rb index a5bf693fdc36be..4fc4731c455007 100644 --- a/spec/ruby/library/net-ftp/shared/getbinaryfile.rb +++ b/spec/ruby/library/net-ftp/shared/getbinaryfile.rb @@ -26,7 +26,7 @@ end it "returns nil" do - @ftp.send(@method, "test", @tmp_file).should be_nil + @ftp.send(@method, "test", @tmp_file).should == nil end it "saves the contents of the passed remote file to the passed local file" do @@ -61,32 +61,32 @@ describe "and the REST command fails" do it "raises a Net::FTPProtoError when the response code is 550" do @server.should_receive(:rest).and_respond("Requested action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPProtoError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:rest).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:rest).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:rest).and_respond("502 Command not implemented.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:rest).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:rest).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end end end @@ -94,32 +94,32 @@ describe "when the RETR command fails" do it "raises a Net::FTPTempError when the response code is 450" do @server.should_receive(:retr).and_respond("450 Requested file action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPProtoError when the response code is 550" do @server.should_receive(:retr).and_respond("Requested action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPProtoError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:retr).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:retr).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:retr).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:retr).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end end @@ -127,25 +127,25 @@ it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:eprt).and_respond("530 Not logged in.") @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/shared/gettextfile.rb b/spec/ruby/library/net-ftp/shared/gettextfile.rb index 4b40c3e5c2f60c..562c7a3047719b 100644 --- a/spec/ruby/library/net-ftp/shared/gettextfile.rb +++ b/spec/ruby/library/net-ftp/shared/gettextfile.rb @@ -25,7 +25,7 @@ end it "returns nil" do - @ftp.send(@method, "test", @tmp_file).should be_nil + @ftp.send(@method, "test", @tmp_file).should == nil end it "saves the contents of the passed remote file to the passed local file" do @@ -44,32 +44,32 @@ describe "when the RETR command fails" do it "raises a Net::FTPTempError when the response code is 450" do @server.should_receive(:retr).and_respond("450 Requested file action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPProtoError when the response code is 550" do @server.should_receive(:retr).and_respond("Requested action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPProtoError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:retr).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:retr).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:retr).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:retr).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end end @@ -77,25 +77,25 @@ it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:eprt).and_respond("530 Not logged in.") @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, "test", @tmp_file) }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/shared/list.rb b/spec/ruby/library/net-ftp/shared/list.rb index 72cfed178d8884..ec372447e87093 100644 --- a/spec/ruby/library/net-ftp/shared/list.rb +++ b/spec/ruby/library/net-ftp/shared/list.rb @@ -48,32 +48,32 @@ describe "when the LIST command fails" do it "raises a Net::FTPTempError when the response code is 450" do @server.should_receive(:list).and_respond("450 Requested file action not taken..") - -> { @ftp.send(@method) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:list).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:list).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:list).and_respond("502 Command not implemented.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:list).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:list).and_respond("530 Not logged in.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method) }.should.raise(Net::FTPPermError) end end @@ -81,25 +81,25 @@ it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method) }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method) }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:eprt).and_respond("530 Not logged in.") @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method) }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/shared/putbinaryfile.rb b/spec/ruby/library/net-ftp/shared/putbinaryfile.rb index 2024f384fd2514..afbe3c61f8132b 100644 --- a/spec/ruby/library/net-ftp/shared/putbinaryfile.rb +++ b/spec/ruby/library/net-ftp/shared/putbinaryfile.rb @@ -35,7 +35,7 @@ end it "returns nil" do - @ftp.send(@method, @local_fixture_file, "binary").should be_nil + @ftp.send(@method, @local_fixture_file, "binary").should == nil end describe "when passed a block" do @@ -68,32 +68,32 @@ describe "and the APPE command fails" do it "raises a Net::FTPProtoError when the response code is 550" do @server.should_receive(:appe).and_respond("Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPProtoError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPProtoError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:appe).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:appe).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:appe).and_respond("502 Command not implemented.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:appe).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:appe).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end end end @@ -101,42 +101,42 @@ describe "when the STOR command fails" do it "raises a Net::FTPPermError when the response code is 532" do @server.should_receive(:stor).and_respond("532 Need account for storing files.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 450" do @server.should_receive(:stor).and_respond("450 Requested file action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPTempError when the response code is 452" do @server.should_receive(:stor).and_respond("452 Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 553" do @server.should_receive(:stor).and_respond("553 Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:stor).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:stor).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:stor).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:stor).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end end @@ -144,25 +144,25 @@ it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:eprt).and_respond("530 Not logged in.") @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "binary") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/shared/puttextfile.rb b/spec/ruby/library/net-ftp/shared/puttextfile.rb index 0009d873de5766..3650cad23059cf 100644 --- a/spec/ruby/library/net-ftp/shared/puttextfile.rb +++ b/spec/ruby/library/net-ftp/shared/puttextfile.rb @@ -37,7 +37,7 @@ guard -> { Net::FTP::VERSION < '0.3.6' } do it "returns nil" do - @ftp.send(@method, @local_fixture_file, "text").should be_nil + @ftp.send(@method, @local_fixture_file, "text").should == nil end end @@ -62,42 +62,42 @@ describe "when the STOR command fails" do it "raises a Net::FTPPermError when the response code is 532" do @server.should_receive(:stor).and_respond("532 Need account for storing files.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 450" do @server.should_receive(:stor).and_respond("450 Requested file action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPTempError when the response code is 452" do @server.should_receive(:stor).and_respond("452 Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 553" do @server.should_receive(:stor).and_respond("553 Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:stor).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:stor).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:stor).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:stor).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPPermError) end end @@ -105,25 +105,25 @@ it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:eprt).and_respond("530 Not logged in.") @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) + -> { @ftp.send(@method, @local_fixture_file, "text") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/site_spec.rb b/spec/ruby/library/net-ftp/site_spec.rb index 14d17caa90cf90..adc7dfafdfcfa8 100644 --- a/spec/ruby/library/net-ftp/site_spec.rb +++ b/spec/ruby/library/net-ftp/site_spec.rb @@ -25,32 +25,32 @@ end it "returns nil" do - @ftp.site("param").should be_nil + @ftp.site("param").should == nil end it "does not raise an error when the response code is 202" do @server.should_receive(:site).and_respond("202 Command not implemented, superfluous at this site.") - -> { @ftp.site("param") }.should_not raise_error + -> { @ftp.site("param") }.should_not.raise end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:site).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.site("param") }.should raise_error(Net::FTPPermError) + -> { @ftp.site("param") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:site).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.site("param") }.should raise_error(Net::FTPPermError) + -> { @ftp.site("param") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:site).and_respond("421 Service not available, closing control connection.") - -> { @ftp.site("param") }.should raise_error(Net::FTPTempError) + -> { @ftp.site("param") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:site).and_respond("530 Requested action not taken.") - -> { @ftp.site("param") }.should raise_error(Net::FTPPermError) + -> { @ftp.site("param") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/size_spec.rb b/spec/ruby/library/net-ftp/size_spec.rb index 73536799eb7100..dd84e5a4498ca7 100644 --- a/spec/ruby/library/net-ftp/size_spec.rb +++ b/spec/ruby/library/net-ftp/size_spec.rb @@ -25,27 +25,27 @@ end it "returns the size of the passed file as Integer" do - @ftp.size("test.file").should eql(1024) + @ftp.size("test.file").should.eql?(1024) end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:size).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.size("test.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:size).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.size("test.file") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:size).and_respond("421 Service not available, closing control connection.") - -> { @ftp.size("test.file") }.should raise_error(Net::FTPTempError) + -> { @ftp.size("test.file") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 550" do @server.should_receive(:size).and_respond("550 Requested action not taken.") - -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError) + -> { @ftp.size("test.file") }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/status_spec.rb b/spec/ruby/library/net-ftp/status_spec.rb index d9a3b59ffb3074..ce29e215d44e97 100644 --- a/spec/ruby/library/net-ftp/status_spec.rb +++ b/spec/ruby/library/net-ftp/status_spec.rb @@ -34,37 +34,37 @@ it "does not raise an error when the response code is 212" do @server.should_receive(:stat).and_respond("212 Directory status.") - -> { @ftp.status }.should_not raise_error + -> { @ftp.status }.should_not.raise end it "does not raise an error when the response code is 213" do @server.should_receive(:stat).and_respond("213 File status.") - -> { @ftp.status }.should_not raise_error + -> { @ftp.status }.should_not.raise end it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:stat).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.status }.should raise_error(Net::FTPPermError) + -> { @ftp.status }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:stat).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.status }.should raise_error(Net::FTPPermError) + -> { @ftp.status }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:stat).and_respond("502 Command not implemented.") - -> { @ftp.status }.should raise_error(Net::FTPPermError) + -> { @ftp.status }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:stat).and_respond("421 Service not available, closing control connection.") - -> { @ftp.status }.should raise_error(Net::FTPTempError) + -> { @ftp.status }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 530" do @server.should_receive(:stat).and_respond("530 Requested action not taken.") - -> { @ftp.status }.should raise_error(Net::FTPPermError) + -> { @ftp.status }.should.raise(Net::FTPPermError) end end end diff --git a/spec/ruby/library/net-ftp/system_spec.rb b/spec/ruby/library/net-ftp/system_spec.rb index d1d4394d798f40..fa617762828fbf 100644 --- a/spec/ruby/library/net-ftp/system_spec.rb +++ b/spec/ruby/library/net-ftp/system_spec.rb @@ -30,22 +30,22 @@ it "raises a Net::FTPPermError when the response code is 500" do @server.should_receive(:syst).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.system }.should raise_error(Net::FTPPermError) + -> { @ftp.system }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 501" do @server.should_receive(:syst).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.system }.should raise_error(Net::FTPPermError) + -> { @ftp.system }.should.raise(Net::FTPPermError) end it "raises a Net::FTPPermError when the response code is 502" do @server.should_receive(:syst).and_respond("502 Command not implemented.") - -> { @ftp.system }.should raise_error(Net::FTPPermError) + -> { @ftp.system }.should.raise(Net::FTPPermError) end it "raises a Net::FTPTempError when the response code is 421" do @server.should_receive(:syst).and_respond("421 Service not available, closing control connection.") - -> { @ftp.system }.should raise_error(Net::FTPTempError) + -> { @ftp.system }.should.raise(Net::FTPTempError) end end end diff --git a/spec/ruby/library/net-ftp/voidcmd_spec.rb b/spec/ruby/library/net-ftp/voidcmd_spec.rb index bd12089c814b62..4f74da7a702940 100644 --- a/spec/ruby/library/net-ftp/voidcmd_spec.rb +++ b/spec/ruby/library/net-ftp/voidcmd_spec.rb @@ -21,37 +21,37 @@ it "sends the passed command to the server" do @server.should_receive(:help).and_respond("2xx Does not raise.") - -> { @ftp.voidcmd("HELP") }.should_not raise_error + -> { @ftp.voidcmd("HELP") }.should_not.raise end it "returns nil" do @server.should_receive(:help).and_respond("2xx Does not raise.") - @ftp.voidcmd("HELP").should be_nil + @ftp.voidcmd("HELP").should == nil end it "raises a Net::FTPReplyError when the response code is 1xx" do @server.should_receive(:help).and_respond("1xx Does raise a Net::FTPReplyError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPReplyError) + -> { @ftp.voidcmd("HELP") }.should.raise(Net::FTPReplyError) end it "raises a Net::FTPReplyError when the response code is 3xx" do @server.should_receive(:help).and_respond("3xx Does raise a Net::FTPReplyError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPReplyError) + -> { @ftp.voidcmd("HELP") }.should.raise(Net::FTPReplyError) end it "raises a Net::FTPTempError when the response code is 4xx" do @server.should_receive(:help).and_respond("4xx Does raise a Net::FTPTempError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPTempError) + -> { @ftp.voidcmd("HELP") }.should.raise(Net::FTPTempError) end it "raises a Net::FTPPermError when the response code is 5xx" do @server.should_receive(:help).and_respond("5xx Does raise a Net::FTPPermError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPPermError) + -> { @ftp.voidcmd("HELP") }.should.raise(Net::FTPPermError) end it "raises a Net::FTPProtoError when the response code is not valid" do @server.should_receive(:help).and_respond("999 Does raise a Net::FTPProtoError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPProtoError) + -> { @ftp.voidcmd("HELP") }.should.raise(Net::FTPProtoError) end end end diff --git a/spec/ruby/library/net-ftp/welcome_spec.rb b/spec/ruby/library/net-ftp/welcome_spec.rb index 0d67e109c955e4..761a0f9a3e5d5b 100644 --- a/spec/ruby/library/net-ftp/welcome_spec.rb +++ b/spec/ruby/library/net-ftp/welcome_spec.rb @@ -20,7 +20,7 @@ end it "returns the server's welcome message" do - @ftp.welcome.should be_nil + @ftp.welcome.should == nil @ftp.login @ftp.welcome.should == "230 User logged in, proceed. (USER anonymous)\n" end diff --git a/spec/ruby/library/net-http/http/Proxy_spec.rb b/spec/ruby/library/net-http/http/Proxy_spec.rb index a1a04fa00ba7a7..7753ce5e301957 100644 --- a/spec/ruby/library/net-http/http/Proxy_spec.rb +++ b/spec/ruby/library/net-http/http/Proxy_spec.rb @@ -13,7 +13,7 @@ it "sets the returned subclasses' proxy options based on the passed arguments" do http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") http_with_proxy.proxy_address.should == "localhost" - http_with_proxy.proxy_port.should eql(1234) + http_with_proxy.proxy_port.should.eql?(1234) http_with_proxy.proxy_user.should == "rspec" http_with_proxy.proxy_pass.should == "rocks" end @@ -22,14 +22,14 @@ describe "Net::HTTP#proxy?" do describe "when self is no proxy class instance" do it "returns false" do - Net::HTTP.new("localhost", 3333).proxy?.should be_false + Net::HTTP.new("localhost", 3333).proxy?.should == false end end describe "when self is a proxy class instance" do it "returns false" do http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.new("localhost", 3333).proxy?.should be_true + http_with_proxy.new("localhost", 3333).proxy?.should == true end end end diff --git a/spec/ruby/library/net-http/http/copy_spec.rb b/spec/ruby/library/net-http/http/copy_spec.rb index fba96c0f11c4b5..1f3e25009f21db 100644 --- a/spec/ruby/library/net-http/http/copy_spec.rb +++ b/spec/ruby/library/net-http/http/copy_spec.rb @@ -15,7 +15,7 @@ it "sends a COPY request to the passed path and returns the response" do response = @http.copy("/request") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) response.body.should == "Request type: COPY" end end 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 95b7316a0cf77b..20407d0b12d711 100644 --- a/spec/ruby/library/net-http/http/default_port_spec.rb +++ b/spec/ruby/library/net-http/http/default_port_spec.rb @@ -3,6 +3,6 @@ describe "Net::HTTP.default_port" do it "returns 80" do - Net::HTTP.http_default_port.should eql(80) + Net::HTTP.http_default_port.should.eql?(80) end end diff --git a/spec/ruby/library/net-http/http/delete_spec.rb b/spec/ruby/library/net-http/http/delete_spec.rb index d73aa5b375ac82..09ddd74000fbd7 100644 --- a/spec/ruby/library/net-http/http/delete_spec.rb +++ b/spec/ruby/library/net-http/http/delete_spec.rb @@ -15,7 +15,7 @@ it "sends a DELETE request to the passed path and returns the response" do response = @http.delete("/request") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) response.body.should == "Request type: DELETE" end end diff --git a/spec/ruby/library/net-http/http/finish_spec.rb b/spec/ruby/library/net-http/http/finish_spec.rb index d4aa00dffe1e28..0d466675f32e97 100644 --- a/spec/ruby/library/net-http/http/finish_spec.rb +++ b/spec/ruby/library/net-http/http/finish_spec.rb @@ -17,13 +17,13 @@ it "closes the tcp connection" do @http.start @http.finish - @http.started?.should be_false + @http.started?.should == false end end describe "when self has not been started yet" do it "raises an IOError" do - -> { @http.finish }.should raise_error(IOError) + -> { @http.finish }.should.raise(IOError) end end end diff --git a/spec/ruby/library/net-http/http/get_spec.rb b/spec/ruby/library/net-http/http/get_spec.rb index e64a61c52cfcea..9be726dc3b454f 100644 --- a/spec/ruby/library/net-http/http/get_spec.rb +++ b/spec/ruby/library/net-http/http/get_spec.rb @@ -74,7 +74,7 @@ def start_threads socket, client_thread = start_threads begin client_thread.raise my_exception, "my exception" - -> { client_thread.value }.should raise_error(my_exception) + -> { client_thread.value }.should.raise(my_exception) ensure socket.close end diff --git a/spec/ruby/library/net-http/http/head_spec.rb b/spec/ruby/library/net-http/http/head_spec.rb index 64621fa87b5eed..4824d225341eb2 100644 --- a/spec/ruby/library/net-http/http/head_spec.rb +++ b/spec/ruby/library/net-http/http/head_spec.rb @@ -16,10 +16,10 @@ it "sends a HEAD request to the passed path and returns the response" do response = @http.head("/request") # HEAD requests have no responses - response.body.should be_nil + response.body.should == nil end it "returns a Net::HTTPResponse" do - @http.head("/request").should be_kind_of(Net::HTTPResponse) + @http.head("/request").should.is_a?(Net::HTTPResponse) end end 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 3b17bcd0a5ccdb..82c88e58a8eefb 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 @@ -3,6 +3,6 @@ describe "Net::HTTP.http_default_port" do it "returns 80" do - Net::HTTP.http_default_port.should eql(80) + Net::HTTP.http_default_port.should.eql?(80) end end 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 8c24e1d97cdeec..24b9c3b462497b 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 @@ -3,6 +3,6 @@ describe "Net::HTTP.https_default_port" do it "returns 443" do - Net::HTTP.https_default_port.should eql(443) + Net::HTTP.https_default_port.should.eql?(443) end end diff --git a/spec/ruby/library/net-http/http/initialize_spec.rb b/spec/ruby/library/net-http/http/initialize_spec.rb index 78aa01e1aaecb3..907314cb258c9d 100644 --- a/spec/ruby/library/net-http/http/initialize_spec.rb +++ b/spec/ruby/library/net-http/http/initialize_spec.rb @@ -3,7 +3,7 @@ describe "Net::HTTP#initialize" do it "is private" do - Net::HTTP.should have_private_instance_method(:initialize) + Net::HTTP.private_instance_methods(false).should.include?(:initialize) end describe "when passed address" do @@ -17,11 +17,11 @@ end it "sets the new Net::HTTP instance's port to the default HTTP port" do - @net.port.should eql(Net::HTTP.default_port) + @net.port.should.eql?(Net::HTTP.default_port) end it "does not start the new Net::HTTP instance" do - @net.started?.should be_false + @net.started?.should == false end end @@ -36,11 +36,11 @@ end it "sets the new Net::HTTP instance's port to the passed port" do - @net.port.should eql(3333) + @net.port.should.eql?(3333) end it "does not start the new Net::HTTP instance" do - @net.started?.should be_false + @net.started?.should == false end end end diff --git a/spec/ruby/library/net-http/http/inspect_spec.rb b/spec/ruby/library/net-http/http/inspect_spec.rb index b8f650809e3f18..fd4e6116c712f1 100644 --- a/spec/ruby/library/net-http/http/inspect_spec.rb +++ b/spec/ruby/library/net-http/http/inspect_spec.rb @@ -15,7 +15,7 @@ end it "returns a String representation of self" do - @http.inspect.should be_kind_of(String) + @http.inspect.should.is_a?(String) @http.inspect.should == "#" @http.start diff --git a/spec/ruby/library/net-http/http/lock_spec.rb b/spec/ruby/library/net-http/http/lock_spec.rb index aa1f944196e917..12df138ad03800 100644 --- a/spec/ruby/library/net-http/http/lock_spec.rb +++ b/spec/ruby/library/net-http/http/lock_spec.rb @@ -15,7 +15,7 @@ it "sends a LOCK request to the passed path and returns the response" do response = @http.lock("/request", "test=test") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) response.body.should == "Request type: LOCK" end end diff --git a/spec/ruby/library/net-http/http/mkcol_spec.rb b/spec/ruby/library/net-http/http/mkcol_spec.rb index f8009f90592a6d..b1a50559827f72 100644 --- a/spec/ruby/library/net-http/http/mkcol_spec.rb +++ b/spec/ruby/library/net-http/http/mkcol_spec.rb @@ -15,7 +15,7 @@ it "sends a MKCOL request to the passed path and returns the response" do response = @http.mkcol("/request") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) response.body.should == "Request type: MKCOL" end end diff --git a/spec/ruby/library/net-http/http/move_spec.rb b/spec/ruby/library/net-http/http/move_spec.rb index ae43016a2cb7a9..a57c2a0f49470f 100644 --- a/spec/ruby/library/net-http/http/move_spec.rb +++ b/spec/ruby/library/net-http/http/move_spec.rb @@ -20,6 +20,6 @@ end it "returns a Net::HTTPResponse" do - @http.move("/request").should be_kind_of(Net::HTTPResponse) + @http.move("/request").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/new_spec.rb b/spec/ruby/library/net-http/http/new_spec.rb index 1ec6bbd0c043d7..8feb3d13515af2 100644 --- a/spec/ruby/library/net-http/http/new_spec.rb +++ b/spec/ruby/library/net-http/http/new_spec.rb @@ -8,8 +8,8 @@ end it "returns a Net::HTTP instance" do - @http.proxy?.should be_false - @http.instance_of?(Net::HTTP).should be_true + @http.proxy?.should == false + @http.instance_of?(Net::HTTP).should == true end it "sets the new Net::HTTP instance's address to the passed address" do @@ -17,11 +17,11 @@ end it "sets the new Net::HTTP instance's port to the default HTTP port" do - @http.port.should eql(Net::HTTP.default_port) + @http.port.should.eql?(Net::HTTP.default_port) end it "does not start the new Net::HTTP instance" do - @http.started?.should be_false + @http.started?.should == false end end @@ -31,8 +31,8 @@ end it "returns a Net::HTTP instance" do - @http.proxy?.should be_false - @http.instance_of?(Net::HTTP).should be_true + @http.proxy?.should == false + @http.instance_of?(Net::HTTP).should == true end it "sets the new Net::HTTP instance's address to the passed address" do @@ -40,44 +40,44 @@ end it "sets the new Net::HTTP instance's port to the passed port" do - @http.port.should eql(3333) + @http.port.should.eql?(3333) end it "does not start the new Net::HTTP instance" do - @http.started?.should be_false + @http.started?.should == false end end describe "when passed address, port, *proxy_options" do it "returns a Net::HTTP instance" do http = Net::HTTP.new("localhost", 3333, "localhost") - http.proxy?.should be_true - http.instance_of?(Net::HTTP).should be_true - http.should be_kind_of(Net::HTTP) + http.proxy?.should == true + http.instance_of?(Net::HTTP).should == true + http.should.is_a?(Net::HTTP) end it "correctly sets the passed Proxy options" do http = Net::HTTP.new("localhost", 3333, "localhost") http.proxy_address.should == "localhost" - http.proxy_port.should eql(80) - http.proxy_user.should be_nil - http.proxy_pass.should be_nil + http.proxy_port.should.eql?(80) + http.proxy_user.should == nil + http.proxy_pass.should == nil http = Net::HTTP.new("localhost", 3333, "localhost", 1234) http.proxy_address.should == "localhost" - http.proxy_port.should eql(1234) - http.proxy_user.should be_nil - http.proxy_pass.should be_nil + http.proxy_port.should.eql?(1234) + http.proxy_user.should == nil + http.proxy_pass.should == nil http = Net::HTTP.new("localhost", 3333, "localhost", 1234, "rubyspec") http.proxy_address.should == "localhost" - http.proxy_port.should eql(1234) + http.proxy_port.should.eql?(1234) http.proxy_user.should == "rubyspec" - http.proxy_pass.should be_nil + http.proxy_pass.should == nil http = Net::HTTP.new("localhost", 3333, "localhost", 1234, "rubyspec", "rocks") http.proxy_address.should == "localhost" - http.proxy_port.should eql(1234) + http.proxy_port.should.eql?(1234) http.proxy_user.should == "rubyspec" http.proxy_pass.should == "rocks" end diff --git a/spec/ruby/library/net-http/http/newobj_spec.rb b/spec/ruby/library/net-http/http/newobj_spec.rb index e19b30fca9becb..d398fb7d9ae975 100644 --- a/spec/ruby/library/net-http/http/newobj_spec.rb +++ b/spec/ruby/library/net-http/http/newobj_spec.rb @@ -8,7 +8,7 @@ describe "when passed address" do it "returns a new Net::HTTP instance" do - @net.should be_kind_of(Net::HTTP) + @net.should.is_a?(Net::HTTP) end it "sets the new Net::HTTP instance's address to the passed address" do @@ -16,11 +16,11 @@ end it "sets the new Net::HTTP instance's port to the default HTTP port" do - @net.port.should eql(Net::HTTP.default_port) + @net.port.should.eql?(Net::HTTP.default_port) end it "does not start the new Net::HTTP instance" do - @net.started?.should be_false + @net.started?.should == false end end @@ -30,7 +30,7 @@ end it "returns a new Net::HTTP instance" do - @net.should be_kind_of(Net::HTTP) + @net.should.is_a?(Net::HTTP) end it "sets the new Net::HTTP instance's address to the passed address" do @@ -38,11 +38,11 @@ end it "sets the new Net::HTTP instance's port to the passed port" do - @net.port.should eql(3333) + @net.port.should.eql?(3333) end it "does not start the new Net::HTTP instance" do - @net.started?.should be_false + @net.started?.should == false end end end 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 0d93752271898f..d00f844b38cab5 100644 --- a/spec/ruby/library/net-http/http/open_timeout_spec.rb +++ b/spec/ruby/library/net-http/http/open_timeout_spec.rb @@ -4,9 +4,9 @@ describe "Net::HTTP#open_timeout" do it "returns the seconds to wait till the connection is open" do net = Net::HTTP.new("localhost") - net.open_timeout.should eql(60) + net.open_timeout.should.eql?(60) net.open_timeout = 10 - net.open_timeout.should eql(10) + net.open_timeout.should.eql?(10) end end @@ -14,11 +14,11 @@ it "sets the seconds to wait till the connection is open" do net = Net::HTTP.new("localhost") net.open_timeout = 10 - net.open_timeout.should eql(10) + net.open_timeout.should.eql?(10) end it "returns the newly set value" do net = Net::HTTP.new("localhost") - (net.open_timeout = 10).should eql(10) + (net.open_timeout = 10).should.eql?(10) end end diff --git a/spec/ruby/library/net-http/http/options_spec.rb b/spec/ruby/library/net-http/http/options_spec.rb index 3d9887a557b447..3b90573cfa0e64 100644 --- a/spec/ruby/library/net-http/http/options_spec.rb +++ b/spec/ruby/library/net-http/http/options_spec.rb @@ -20,6 +20,6 @@ end it "returns a Net::HTTPResponse" do - @http.options("/request").should be_kind_of(Net::HTTPResponse) + @http.options("/request").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/port_spec.rb b/spec/ruby/library/net-http/http/port_spec.rb index 0984d5e6ce8c46..edb689f9cabab8 100644 --- a/spec/ruby/library/net-http/http/port_spec.rb +++ b/spec/ruby/library/net-http/http/port_spec.rb @@ -4,6 +4,6 @@ describe "Net::HTTP#port" do it "returns the current port number" do net = Net::HTTP.new("localhost", 3333) - net.port.should eql(3333) + net.port.should.eql?(3333) end end diff --git a/spec/ruby/library/net-http/http/post_spec.rb b/spec/ruby/library/net-http/http/post_spec.rb index b8b8d16ad1a76a..f2944111972819 100644 --- a/spec/ruby/library/net-http/http/post_spec.rb +++ b/spec/ruby/library/net-http/http/post_spec.rb @@ -22,13 +22,13 @@ it "returns a Net::HTTPResponse" do response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request"), "test=test") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end ruby_version_is ""..."4.0" 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" }.inspect.delete("{}")) + response.body.should.include?({ "Content-Type" => "application/x-www-form-urlencoded" }.inspect.delete("{}")) end end @@ -57,7 +57,7 @@ end it "returns a Net::HTTPResponse" do - @http.post("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.post("/request", "test=test").should.is_a?(Net::HTTPResponse) end describe "when passed a block" do @@ -70,7 +70,7 @@ end it "returns a Net::HTTPResponse" do - @http.post("/request", "test=test") {}.should be_kind_of(Net::HTTPResponse) + @http.post("/request", "test=test") {}.should.is_a?(Net::HTTPResponse) end end end diff --git a/spec/ruby/library/net-http/http/propfind_spec.rb b/spec/ruby/library/net-http/http/propfind_spec.rb index f3742d1b1ae9db..6a1be0392aa6be 100644 --- a/spec/ruby/library/net-http/http/propfind_spec.rb +++ b/spec/ruby/library/net-http/http/propfind_spec.rb @@ -19,6 +19,6 @@ end it "returns a Net::HTTPResponse" do - @http.propfind("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.propfind("/request", "test=test").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/proppatch_spec.rb b/spec/ruby/library/net-http/http/proppatch_spec.rb index 0163d24d46a2d3..074dfafaefe8f2 100644 --- a/spec/ruby/library/net-http/http/proppatch_spec.rb +++ b/spec/ruby/library/net-http/http/proppatch_spec.rb @@ -19,6 +19,6 @@ end it "returns a Net::HTTPResponse" do - @http.proppatch("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.proppatch("/request", "test=test").should.is_a?(Net::HTTPResponse) end end 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 5b5efb7ac00bb3..ba040336adc427 100644 --- a/spec/ruby/library/net-http/http/proxy_address_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_address_spec.rb @@ -4,7 +4,7 @@ describe "Net::HTTP.proxy_address" do describe "when self is no proxy class" do it "returns nil" do - Net::HTTP.proxy_address.should be_nil + Net::HTTP.proxy_address.should == nil end end @@ -18,7 +18,7 @@ describe "Net::HTTP#proxy_address" do describe "when self is no proxy class instance" do it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_address.should be_nil + Net::HTTP.new("localhost", 3333).proxy_address.should == nil end end 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 00975aef4ecfaa..eda027c893ef36 100644 --- a/spec/ruby/library/net-http/http/proxy_class_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_class_spec.rb @@ -3,7 +3,7 @@ describe "Net::HTTP.proxy_class?" do it "returns true if self is a class created with Net::HTTP.Proxy" do - Net::HTTP.proxy_class?.should be_false - Net::HTTP.Proxy("localhost").proxy_class?.should be_true + Net::HTTP.proxy_class?.should == false + Net::HTTP.Proxy("localhost").proxy_class?.should == true end end 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 4e393a53ff8530..ad02d896c0f2e2 100644 --- a/spec/ruby/library/net-http/http/proxy_pass_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_pass_spec.rb @@ -4,13 +4,13 @@ describe "Net::HTTP.proxy_pass" do describe "when self is no proxy class" do it "returns nil" do - Net::HTTP.proxy_pass.should be_nil + Net::HTTP.proxy_pass.should == nil end end describe "when self is a proxy class" do it "returns nil if no password was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").proxy_pass.should be_nil + Net::HTTP.Proxy("localhost").proxy_pass.should == nil end it "returns the password for self's proxy connection" do @@ -22,13 +22,13 @@ describe "Net::HTTP#proxy_pass" do describe "when self is no proxy class instance" do it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_pass.should be_nil + Net::HTTP.new("localhost", 3333).proxy_pass.should == nil end end describe "when self is a proxy class instance" do it "returns nil if no password was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_pass.should be_nil + Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_pass.should == nil end it "returns the password for self's proxy connection" 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 d7d37f39273543..21c1e4180ee266 100644 --- a/spec/ruby/library/net-http/http/proxy_port_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_port_spec.rb @@ -4,17 +4,17 @@ describe "Net::HTTP.proxy_port" do describe "when self is no proxy class" do it "returns nil" do - Net::HTTP.proxy_port.should be_nil + Net::HTTP.proxy_port.should == nil end end describe "when self is a proxy class" do it "returns 80 if no port was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").proxy_port.should eql(80) + Net::HTTP.Proxy("localhost").proxy_port.should.eql?(80) end it "returns the port for self's proxy connection" do - Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks").proxy_port.should eql(1234) + Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks").proxy_port.should.eql?(1234) end end end @@ -22,18 +22,18 @@ describe "Net::HTTP#proxy_port" do describe "when self is no proxy class instance" do it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_port.should be_nil + Net::HTTP.new("localhost", 3333).proxy_port.should == nil end end describe "when self is a proxy class instance" do it "returns 80 if no port was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_port.should eql(80) + Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_port.should.eql?(80) end it "returns the port for self's proxy connection" do http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.new("localhost", 3333).proxy_port.should eql(1234) + http_with_proxy.new("localhost", 3333).proxy_port.should.eql?(1234) end end end 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 ef7654425de2e7..492ea2e8ee7b52 100644 --- a/spec/ruby/library/net-http/http/proxy_user_spec.rb +++ b/spec/ruby/library/net-http/http/proxy_user_spec.rb @@ -4,13 +4,13 @@ describe "Net::HTTP.proxy_user" do describe "when self is no proxy class" do it "returns nil" do - Net::HTTP.proxy_user.should be_nil + Net::HTTP.proxy_user.should == nil end end describe "when self is a proxy class" do it "returns nil if no username was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").proxy_user.should be_nil + Net::HTTP.Proxy("localhost").proxy_user.should == nil end it "returns the username for self's proxy connection" do @@ -22,13 +22,13 @@ describe "Net::HTTP#proxy_user" do describe "when self is no proxy class instance" do it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_user.should be_nil + Net::HTTP.new("localhost", 3333).proxy_user.should == nil end end describe "when self is a proxy class instance" do it "returns nil if no username was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_user.should be_nil + Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_user.should == nil end it "returns the username for self's proxy connection" do diff --git a/spec/ruby/library/net-http/http/put_spec.rb b/spec/ruby/library/net-http/http/put_spec.rb index 75f3c243d4aa09..7ef9219f637fdf 100644 --- a/spec/ruby/library/net-http/http/put_spec.rb +++ b/spec/ruby/library/net-http/http/put_spec.rb @@ -19,6 +19,6 @@ end it "returns a Net::HTTPResponse" do - @http.put("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.put("/request", "test=test").should.is_a?(Net::HTTPResponse) end end 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 7a0d2f1d72adc0..81e71337bb65e2 100644 --- a/spec/ruby/library/net-http/http/read_timeout_spec.rb +++ b/spec/ruby/library/net-http/http/read_timeout_spec.rb @@ -4,9 +4,9 @@ describe "Net::HTTP#read_timeout" do it "returns the seconds to wait until reading one block" do net = Net::HTTP.new("localhost") - net.read_timeout.should eql(60) + net.read_timeout.should.eql?(60) net.read_timeout = 10 - net.read_timeout.should eql(10) + net.read_timeout.should.eql?(10) end end @@ -14,11 +14,11 @@ it "sets the seconds to wait till the connection is open" do net = Net::HTTP.new("localhost") net.read_timeout = 10 - net.read_timeout.should eql(10) + net.read_timeout.should.eql?(10) end it "returns the newly set value" do net = Net::HTTP.new("localhost") - (net.read_timeout = 10).should eql(10) + (net.read_timeout = 10).should.eql?(10) end end diff --git a/spec/ruby/library/net-http/http/request_spec.rb b/spec/ruby/library/net-http/http/request_spec.rb index 356e605b3b2017..e05ee96b556af6 100644 --- a/spec/ruby/library/net-http/http/request_spec.rb +++ b/spec/ruby/library/net-http/http/request_spec.rb @@ -19,7 +19,7 @@ response.body.should == "Request type: GET" response = @http.request(Net::HTTP::Head.new("/request"), "test=test") - response.body.should be_nil + response.body.should == nil response = @http.request(Net::HTTP::Post.new("/request"), "test=test") response.body.should == "Request type: POST" @@ -38,7 +38,7 @@ # TODO: Does not work? #response = @http.request(Net::HTTP::Options.new("/request"), "test=test") - #response.body.should be_nil + #response.body.should == nil response = @http.request(Net::HTTP::Propfind.new("/request"), "test=test") response.body.should == "Request type: PROPFIND" @@ -66,7 +66,7 @@ response.body.should == "test=test" response = @http.request(Net::HTTP::Head.new("/request/body"), "test=test") - response.body.should be_nil + response.body.should == nil response = @http.request(Net::HTTP::Post.new("/request/body"), "test=test") response.body.should == "test=test" @@ -85,7 +85,7 @@ # TODO: Does not work? #response = @http.request(Net::HTTP::Options.new("/request/body"), "test=test") - #response.body.should be_nil + #response.body.should == nil response = @http.request(Net::HTTP::Propfind.new("/request/body"), "test=test") response.body.should == "test=test" 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 53aef1ee58567a..0adc62597920f1 100644 --- a/spec/ruby/library/net-http/http/request_types_spec.rb +++ b/spec/ruby/library/net-http/http/request_types_spec.rb @@ -11,11 +11,11 @@ end it "has no Request Body" do - Net::HTTP::Get::REQUEST_HAS_BODY.should be_false + Net::HTTP::Get::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Get::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Get::RESPONSE_HAS_BODY.should == true end end @@ -29,11 +29,11 @@ end it "has no Request Body" do - Net::HTTP::Head::REQUEST_HAS_BODY.should be_false + Net::HTTP::Head::REQUEST_HAS_BODY.should == false end it "has no Response Body" do - Net::HTTP::Head::RESPONSE_HAS_BODY.should be_false + Net::HTTP::Head::RESPONSE_HAS_BODY.should == false end end @@ -47,11 +47,11 @@ end it "has a Request Body" do - Net::HTTP::Post::REQUEST_HAS_BODY.should be_true + Net::HTTP::Post::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Post::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Post::RESPONSE_HAS_BODY.should == true end end @@ -65,11 +65,11 @@ end it "has a Request Body" do - Net::HTTP::Put::REQUEST_HAS_BODY.should be_true + Net::HTTP::Put::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Put::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Put::RESPONSE_HAS_BODY.should == true end end @@ -83,11 +83,11 @@ end it "has no Request Body" do - Net::HTTP::Delete::REQUEST_HAS_BODY.should be_false + Net::HTTP::Delete::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Delete::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Delete::RESPONSE_HAS_BODY.should == true end end @@ -101,11 +101,11 @@ end it "has no Request Body" do - Net::HTTP::Options::REQUEST_HAS_BODY.should be_false + Net::HTTP::Options::REQUEST_HAS_BODY.should == false end it "has no Response Body" do - Net::HTTP::Options::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Options::RESPONSE_HAS_BODY.should == true end end @@ -119,11 +119,11 @@ end it "has no Request Body" do - Net::HTTP::Trace::REQUEST_HAS_BODY.should be_false + Net::HTTP::Trace::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Trace::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Trace::RESPONSE_HAS_BODY.should == true end end @@ -137,11 +137,11 @@ end it "has a Request Body" do - Net::HTTP::Propfind::REQUEST_HAS_BODY.should be_true + Net::HTTP::Propfind::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Propfind::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Propfind::RESPONSE_HAS_BODY.should == true end end @@ -155,11 +155,11 @@ end it "has a Request Body" do - Net::HTTP::Proppatch::REQUEST_HAS_BODY.should be_true + Net::HTTP::Proppatch::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Proppatch::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Proppatch::RESPONSE_HAS_BODY.should == true end end @@ -173,11 +173,11 @@ end it "has a Request Body" do - Net::HTTP::Mkcol::REQUEST_HAS_BODY.should be_true + Net::HTTP::Mkcol::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Mkcol::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Mkcol::RESPONSE_HAS_BODY.should == true end end @@ -191,11 +191,11 @@ end it "has no Request Body" do - Net::HTTP::Copy::REQUEST_HAS_BODY.should be_false + Net::HTTP::Copy::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Copy::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Copy::RESPONSE_HAS_BODY.should == true end end @@ -209,11 +209,11 @@ end it "has no Request Body" do - Net::HTTP::Move::REQUEST_HAS_BODY.should be_false + Net::HTTP::Move::REQUEST_HAS_BODY.should == false end it "has a Response Body" do - Net::HTTP::Move::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Move::RESPONSE_HAS_BODY.should == true end end @@ -227,11 +227,11 @@ end it "has a Request Body" do - Net::HTTP::Lock::REQUEST_HAS_BODY.should be_true + Net::HTTP::Lock::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Lock::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Lock::RESPONSE_HAS_BODY.should == true end end @@ -245,10 +245,10 @@ end it "has a Request Body" do - Net::HTTP::Unlock::REQUEST_HAS_BODY.should be_true + Net::HTTP::Unlock::REQUEST_HAS_BODY.should == true end it "has a Response Body" do - Net::HTTP::Unlock::RESPONSE_HAS_BODY.should be_true + Net::HTTP::Unlock::RESPONSE_HAS_BODY.should == true end end 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 af35c068ceaeaf..e2dfc505b6e01e 100644 --- a/spec/ruby/library/net-http/http/send_request_spec.rb +++ b/spec/ruby/library/net-http/http/send_request_spec.rb @@ -24,7 +24,7 @@ describe "when passed type, path" do it "sends a HTTP Request of the passed type to the passed path" do response = @http.send_request("HEAD", "/request") - response.body.should be_nil + response.body.should == nil (@methods - %w[POST PUT]).each do |method| response = @http.send_request(method, "/request") @@ -36,7 +36,7 @@ describe "when passed type, path, body" do it "sends a HTTP Request with the passed body" do response = @http.send_request("HEAD", "/request/body", "test=test") - response.body.should be_nil + response.body.should == nil @methods.each do |method| response = @http.send_request(method, "/request/body", "test=test") @@ -50,11 +50,11 @@ referer = 'https://www.ruby-lang.org/'.freeze response = @http.send_request("HEAD", "/request/header", "test=test", "referer" => referer) - response.body.should be_nil + response.body.should == nil @methods.each do |method| response = @http.send_request(method, "/request/header", "test=test", "referer" => referer) - response.body.should include({ "Referer" => referer }.inspect.delete("{}")) + response.body.should.include?({ "Referer" => referer }.inspect.delete("{}")) 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 5ceecb39fb9435..491ac38b5de25c 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 @@ -19,7 +19,7 @@ @http.set_debug_output(io) @http.start - io.string.should_not be_empty + io.string.should_not.empty? size = io.string.size @http.get("/") 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 d25f32049bfef1..4f2f152ea4d7a9 100644 --- a/spec/ruby/library/net-http/http/shared/request_get.rb +++ b/spec/ruby/library/net-http/http/shared/request_get.rb @@ -17,7 +17,7 @@ it "returns a Net::HTTPResponse object" do response = @http.send(@method, "/request") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end end @@ -35,7 +35,7 @@ it "returns a Net::HTTPResponse object" do response = @http.send(@method, "/request") {} - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end end end 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 78b555884b88d0..a5fe787d327f64 100644 --- a/spec/ruby/library/net-http/http/shared/request_head.rb +++ b/spec/ruby/library/net-http/http/shared/request_head.rb @@ -12,30 +12,30 @@ describe "when passed no block" do it "sends a head request to the passed path and returns the response" do response = @http.send(@method, "/request") - response.body.should be_nil + response.body.should == nil end it "returns a Net::HTTPResponse object" do response = @http.send(@method, "/request") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end end describe "when passed a block" do it "sends a head request to the passed path and returns the response" do response = @http.send(@method, "/request") {} - response.body.should be_nil + response.body.should == nil end it "yields the response to the passed block" do @http.send(@method, "/request") do |response| - response.body.should be_nil + response.body.should == nil end end it "returns a Net::HTTPResponse object" do response = @http.send(@method, "/request") {} - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end end end 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 e832411c488749..73cfd577cff321 100644 --- a/spec/ruby/library/net-http/http/shared/request_post.rb +++ b/spec/ruby/library/net-http/http/shared/request_post.rb @@ -17,7 +17,7 @@ it "returns a Net::HTTPResponse object" do response = @http.send(@method, "/request", "test=test") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end end @@ -35,7 +35,7 @@ it "returns a Net::HTTPResponse object" do response = @http.send(@method, "/request", "test=test") {} - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end end end 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 3b902f495724ce..3b64d7e055777c 100644 --- a/spec/ruby/library/net-http/http/shared/request_put.rb +++ b/spec/ruby/library/net-http/http/shared/request_put.rb @@ -17,7 +17,7 @@ it "returns a Net::HTTPResponse object" do response = @http.send(@method, "/request", "test=test") - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end end @@ -35,7 +35,7 @@ it "returns a Net::HTTPResponse object" do response = @http.send(@method, "/request", "test=test") {} - response.should be_kind_of(Net::HTTPResponse) + response.should.is_a?(Net::HTTPResponse) end end end diff --git a/spec/ruby/library/net-http/http/shared/started.rb b/spec/ruby/library/net-http/http/shared/started.rb index 9ff6272c314e1f..0ab18a4e83f3f0 100644 --- a/spec/ruby/library/net-http/http/shared/started.rb +++ b/spec/ruby/library/net-http/http/shared/started.rb @@ -11,16 +11,16 @@ it "returns true when self has been started" do @http.start - @http.send(@method).should be_true + @http.send(@method).should == true end it "returns false when self has not been started yet" do - @http.send(@method).should be_false + @http.send(@method).should == false end it "returns false when self has been stopped again" do @http.start @http.finish - @http.send(@method).should be_false + @http.send(@method).should == false end end 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 db3d6a986ddb20..84e7264eabfec0 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 @@ -1,6 +1,6 @@ describe :net_http_version_1_1_p, shared: true do it "returns the state of net/http 1.1 features" do Net::HTTP.version_1_2 - Net::HTTP.send(@method).should be_false + Net::HTTP.send(@method).should == false end end 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 b044182c609f67..dcf541970453ef 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 @@ -1,6 +1,6 @@ describe :net_http_version_1_2_p, shared: true do it "returns the state of net/http 1.2 features" do Net::HTTP.version_1_2 - Net::HTTP.send(@method).should be_true + Net::HTTP.send(@method).should == true end end diff --git a/spec/ruby/library/net-http/http/start_spec.rb b/spec/ruby/library/net-http/http/start_spec.rb index 0ce3e792690441..1aebc16f4d6215 100644 --- a/spec/ruby/library/net-http/http/start_spec.rb +++ b/spec/ruby/library/net-http/http/start_spec.rb @@ -22,13 +22,13 @@ end it "returns a new Net::HTTP object for the passed address and port" do - @http.should be_kind_of(Net::HTTP) + @http.should.is_a?(Net::HTTP) @http.address.should == "localhost" @http.port.should == @port end it "opens the tcp connection" do - @http.started?.should be_true + @http.started?.should == true end end @@ -41,19 +41,19 @@ yielded = false Net::HTTP.start("localhost", @port) do |net| yielded = true - net.should be_kind_of(Net::HTTP) + net.should.is_a?(Net::HTTP) end - yielded.should be_true + yielded.should == true end it "opens the tcp connection before yielding" do - Net::HTTP.start("localhost", @port) { |http| http.started?.should be_true } + Net::HTTP.start("localhost", @port) { |http| http.started?.should == true } end it "closes the tcp connection after yielding" do net = nil Net::HTTP.start("localhost", @port) { |x| net = x } - net.started?.should be_false + net.started?.should == false end end end @@ -70,18 +70,18 @@ end it "returns self" do - @http.start.should equal(@http) + @http.start.should.equal?(@http) end it "opens the tcp connection" do @http.start - @http.started?.should be_true + @http.started?.should == true end describe "when self has already been started" do it "raises an IOError" do @http.start - -> { @http.start }.should raise_error(IOError) + -> { @http.start }.should.raise(IOError) end end @@ -94,18 +94,18 @@ yielded = false @http.start do |http| yielded = true - http.should equal(@http) + http.should.equal?(@http) end - yielded.should be_true + yielded.should == true end it "opens the tcp connection before yielding" do - @http.start { |http| http.started?.should be_true } + @http.start { |http| http.started?.should == true } end it "closes the tcp connection after yielding" do @http.start { } - @http.started?.should be_false + @http.started?.should == false end end end diff --git a/spec/ruby/library/net-http/http/trace_spec.rb b/spec/ruby/library/net-http/http/trace_spec.rb index 9809d537c5e579..e0ff741b046bc4 100644 --- a/spec/ruby/library/net-http/http/trace_spec.rb +++ b/spec/ruby/library/net-http/http/trace_spec.rb @@ -19,6 +19,6 @@ end it "returns a Net::HTTPResponse" do - @http.trace("/request").should be_kind_of(Net::HTTPResponse) + @http.trace("/request").should.is_a?(Net::HTTPResponse) end end diff --git a/spec/ruby/library/net-http/http/unlock_spec.rb b/spec/ruby/library/net-http/http/unlock_spec.rb index adf0b49f6521aa..cbfc803f09d4a1 100644 --- a/spec/ruby/library/net-http/http/unlock_spec.rb +++ b/spec/ruby/library/net-http/http/unlock_spec.rb @@ -19,6 +19,6 @@ end it "returns a Net::HTTPResponse" do - @http.unlock("/request", "test=test").should be_kind_of(Net::HTTPResponse) + @http.unlock("/request", "test=test").should.is_a?(Net::HTTPResponse) end end 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 912a62a8ba61d4..b283655359383b 100644 --- a/spec/ruby/library/net-http/http/use_ssl_spec.rb +++ b/spec/ruby/library/net-http/http/use_ssl_spec.rb @@ -4,6 +4,6 @@ describe "Net::HTTP#use_ssl?" do it "returns false" do http = Net::HTTP.new("localhost") - http.use_ssl?.should be_false + http.use_ssl?.should == false end end 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 e994511aea1ae3..4918597234f4cc 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 @@ -6,12 +6,12 @@ it "turns on net/http 1.2 features" do Net::HTTP.version_1_2 - Net::HTTP.version_1_2?.should be_true - Net::HTTP.version_1_1?.should be_false + Net::HTTP.version_1_2?.should == true + Net::HTTP.version_1_1?.should == false end it "returns true" do - Net::HTTP.version_1_2.should be_true + Net::HTTP.version_1_2.should == true end end 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 6c886499ca7ff8..96a761929ea50c 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/body_exist_spec.rb @@ -4,10 +4,10 @@ describe "Net::HTTPGenericRequest#body_exist?" do it "returns true when the response is expected to have a body" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body_exist?.should be_true + request.body_exist?.should == true request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path") - request.body_exist?.should be_false + request.body_exist?.should == false end describe "when $VERBOSE is true" do diff --git a/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb index 5f7315f303b892..63cda994e5549c 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/body_spec.rb @@ -5,7 +5,7 @@ describe "Net::HTTPGenericRequest#body" do it "returns self's request body" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body.should be_nil + request.body.should == nil request.body = "Some Content" request.body.should == "Some Content" @@ -25,6 +25,6 @@ it "sets self's body stream to nil" do @request.body_stream = StringIO.new("") @request.body = "Some Content" - @request.body_stream.should be_nil + @request.body_stream.should == nil end end 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 dea1c8c8834dfc..3237dbb8611bcb 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/body_stream_spec.rb @@ -5,11 +5,11 @@ describe "Net::HTTPGenericRequest#body_stream" do it "returns self's body stream Object" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body_stream.should be_nil + request.body_stream.should == nil stream = StringIO.new("test") request.body_stream = stream - request.body_stream.should equal(stream) + request.body_stream.should.equal?(stream) end end @@ -21,12 +21,12 @@ it "sets self's body stream to the passed Object" do @request.body_stream = @stream - @request.body_stream.should equal(@stream) + @request.body_stream.should.equal?(@stream) end it "sets self's body to nil" do @request.body = "Some Content" @request.body_stream = @stream - @request.body.should be_nil + @request.body.should == nil end end diff --git a/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb index a09f9d5becec42..0ccf80e3b69e42 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb @@ -129,7 +129,7 @@ "Content-Type" => "text/html") request.body_stream = StringIO.new("Some Content") - -> { request.exec(@buffered_socket, "1.1", "/some/other/path") }.should raise_error(ArgumentError) + -> { request.exec(@buffered_socket, "1.1", "/some/other/path") }.should.raise(ArgumentError) end end end 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 1713b59baf5c46..ba836e813005ac 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 @@ -4,9 +4,9 @@ describe "Net::HTTPGenericRequest#request_body_permitted?" do it "returns true when the request is expected to have a body" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.request_body_permitted?.should be_true + request.request_body_permitted?.should == true request = Net::HTTPGenericRequest.new("POST", false, true, "/some/path") - request.request_body_permitted?.should be_false + request.request_body_permitted?.should == false end end 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 2f0751c344efa2..067500f60dcf14 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 @@ -4,9 +4,9 @@ describe "Net::HTTPGenericRequest#response_body_permitted?" do it "returns true when the response is expected to have a body" do request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.response_body_permitted?.should be_true + request.response_body_permitted?.should == true request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path") - request.response_body_permitted?.should be_false + request.response_body_permitted?.should == false end end 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 358aa6cde34877..f241d8d698ac88 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 @@ -13,9 +13,9 @@ it "raises an ArgumentError when the body or body_stream of self have already been set" do @request.body = "Some Content" - -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) + -> { @request.set_body_internal("Some other Content") }.should.raise(ArgumentError) @request.body_stream = "Some Content" - -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) + -> { @request.set_body_internal("Some other Content") }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/net-http/httpheader/chunked_spec.rb b/spec/ruby/library/net-http/httpheader/chunked_spec.rb index b32a0aab3882dc..4da218ae25ecef 100644 --- a/spec/ruby/library/net-http/httpheader/chunked_spec.rb +++ b/spec/ruby/library/net-http/httpheader/chunked_spec.rb @@ -8,15 +8,15 @@ end it "returns true if the 'Transfer-Encoding' header entry is set to chunked" do - @headers.chunked?.should be_false + @headers.chunked?.should == false @headers["Transfer-Encoding"] = "bla" - @headers.chunked?.should be_false + @headers.chunked?.should == false @headers["Transfer-Encoding"] = "blachunkedbla" - @headers.chunked?.should be_false + @headers.chunked?.should == false @headers["Transfer-Encoding"] = "chunked" - @headers.chunked?.should be_true + @headers.chunked?.should == true end end 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 f05c5f8d8b3f0e..c66d5673c1dda4 100644 --- a/spec/ruby/library/net-http/httpheader/content_length_spec.rb +++ b/spec/ruby/library/net-http/httpheader/content_length_spec.rb @@ -8,23 +8,23 @@ end it "returns nil if no 'Content-Length' header entry is set" do - @headers.content_length.should be_nil + @headers.content_length.should == nil end it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Length' header entry has an invalid format" do @headers["Content-Length"] = "invalid" - -> { @headers.content_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_length }.should.raise(Net::HTTPHeaderSyntaxError) end it "returns the value of the 'Content-Length' header entry as an Integer" do @headers["Content-Length"] = "123" - @headers.content_length.should eql(123) + @headers.content_length.should.eql?(123) @headers["Content-Length"] = "123valid" - @headers.content_length.should eql(123) + @headers.content_length.should.eql?(123) @headers["Content-Length"] = "valid123" - @headers.content_length.should eql(123) + @headers.content_length.should.eql?(123) end end @@ -36,7 +36,7 @@ it "removes the 'Content-Length' entry if passed false or nil" do @headers["Content-Length"] = "123" @headers.content_length = nil - @headers["Content-Length"].should be_nil + @headers["Content-Length"].should == nil end it "sets the 'Content-Length' entry to the passed value" do 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 09737141a5c4e4..3635fb3f1b1f3e 100644 --- a/spec/ruby/library/net-http/httpheader/content_range_spec.rb +++ b/spec/ruby/library/net-http/httpheader/content_range_spec.rb @@ -16,17 +16,17 @@ end it "returns nil when there is no 'Content-Range' header entry" do - @headers.content_range.should be_nil + @headers.content_range.should == nil end it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do @headers["Content-Range"] = "invalid" - -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_range }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes 123-abc" - -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_range }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes abc-123" - -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_range }.should.raise(Net::HTTPHeaderSyntaxError) end end 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 a6e1ae1093a7d2..c9c936ba0f224d 100644 --- a/spec/ruby/library/net-http/httpheader/content_type_spec.rb +++ b/spec/ruby/library/net-http/httpheader/content_type_spec.rb @@ -17,7 +17,7 @@ end it "returns nil if the 'Content-Type' header entry does not exist" do - @headers.content_type.should be_nil + @headers.content_type.should == nil end end diff --git a/spec/ruby/library/net-http/httpheader/delete_spec.rb b/spec/ruby/library/net-http/httpheader/delete_spec.rb index 8d929dbd862cf1..09bae65a139299 100644 --- a/spec/ruby/library/net-http/httpheader/delete_spec.rb +++ b/spec/ruby/library/net-http/httpheader/delete_spec.rb @@ -11,8 +11,8 @@ @headers["My-Header"] = "test" @headers.delete("My-Header") - @headers["My-Header"].should be_nil - @headers.size.should eql(0) + @headers["My-Header"].should == nil + @headers.size.should.eql?(0) end it "returns the removed values" do @@ -24,7 +24,7 @@ @headers["My-Header"] = "test" @headers.delete("my-header") - @headers["My-Header"].should be_nil - @headers.size.should eql(0) + @headers["My-Header"].should == nil + @headers.size.should.eql?(0) end end 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 27713577f97729..54874c05358e0b 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 @@ -23,7 +23,7 @@ describe "when passed no block" do it "returns an Enumerator" do enumerator = @headers.each_capitalized_name - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) res = [] enumerator.each do |key| 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 b71df58c658ccd..55ba4c1ef868a9 100644 --- a/spec/ruby/library/net-http/httpheader/each_value_spec.rb +++ b/spec/ruby/library/net-http/httpheader/each_value_spec.rb @@ -23,7 +23,7 @@ describe "when passed no block" do it "returns an Enumerator" do enumerator = @headers.each_value - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) res = [] enumerator.each do |key| 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 1003c41af93acb..f12f8494db6fc6 100644 --- a/spec/ruby/library/net-http/httpheader/element_reference_spec.rb +++ b/spec/ruby/library/net-http/httpheader/element_reference_spec.rb @@ -33,7 +33,7 @@ end it "returns nil for non-existing entries" do - @headers["My-Header"].should be_nil - @headers["My-Other-Header"].should be_nil + @headers["My-Header"].should == nil + @headers["My-Other-Header"].should == nil end end 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 376df2f977dc86..633fe18b2ed62d 100644 --- a/spec/ruby/library/net-http/httpheader/element_set_spec.rb +++ b/spec/ruby/library/net-http/httpheader/element_set_spec.rb @@ -26,16 +26,16 @@ @headers['MY-HEADER'] = "last one" @headers["My-Header"].should == "last one" - @headers.size.should eql(1) + @headers.size.should.eql?(1) end it "removes the header entry with the passed key when the value is false or nil" do @headers['My-Header'] = "test" @headers['My-Header'] = nil - @headers['My-Header'].should be_nil + @headers['My-Header'].should == nil @headers['My-Header'] = "test" @headers['My-Header'] = false - @headers['My-Header'].should be_nil + @headers['My-Header'].should == nil end end diff --git a/spec/ruby/library/net-http/httpheader/fetch_spec.rb b/spec/ruby/library/net-http/httpheader/fetch_spec.rb index 58c69c037736fd..d1c273dada0079 100644 --- a/spec/ruby/library/net-http/httpheader/fetch_spec.rb +++ b/spec/ruby/library/net-http/httpheader/fetch_spec.rb @@ -25,7 +25,7 @@ end it "returns nil when there is no entry for the passed key" do - -> { @headers.fetch("my-header") }.should raise_error(IndexError) + -> { @headers.fetch("my-header") }.should.raise(IndexError) end end 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 0278bcede21721..76da63bc314fb3 100644 --- a/spec/ruby/library/net-http/httpheader/get_fields_spec.rb +++ b/spec/ruby/library/net-http/httpheader/get_fields_spec.rb @@ -26,8 +26,8 @@ end it "returns nil for non-existing header entries" do - @headers.get_fields("My-Header").should be_nil - @headers.get_fields("My-Other-header").should be_nil + @headers.get_fields("My-Header").should == nil + @headers.get_fields("My-Other-header").should == nil end it "is case-insensitive" do diff --git a/spec/ruby/library/net-http/httpheader/key_spec.rb b/spec/ruby/library/net-http/httpheader/key_spec.rb index 2b7aeb9c2adc60..65662591eb4907 100644 --- a/spec/ruby/library/net-http/httpheader/key_spec.rb +++ b/spec/ruby/library/net-http/httpheader/key_spec.rb @@ -8,14 +8,14 @@ end it "returns true if the header entry with the passed key exists" do - @headers.key?("My-Header").should be_false + @headers.key?("My-Header").should == false @headers["My-Header"] = "test" - @headers.key?("My-Header").should be_true + @headers.key?("My-Header").should == true end it "is case-insensitive" do @headers["My-Header"] = "test" - @headers.key?("my-header").should be_true - @headers.key?("MY-HEADER").should be_true + @headers.key?("my-header").should == true + @headers.key?("MY-HEADER").should == true end end 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 4dd551d8f4fc86..af7d3e05a3a0bc 100644 --- a/spec/ruby/library/net-http/httpheader/main_type_spec.rb +++ b/spec/ruby/library/net-http/httpheader/main_type_spec.rb @@ -19,6 +19,6 @@ end it "returns nil if the 'Content-Type' header entry does not exist" do - @headers.main_type.should be_nil + @headers.main_type.should == nil end end 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 77323ac8726f42..34db7e61267924 100644 --- a/spec/ruby/library/net-http/httpheader/range_length_spec.rb +++ b/spec/ruby/library/net-http/httpheader/range_length_spec.rb @@ -9,24 +9,24 @@ it "returns the length of the Range represented by the 'Content-Range' header entry" do @headers["Content-Range"] = "bytes 0-499/1234" - @headers.range_length.should eql(500) + @headers.range_length.should.eql?(500) @headers["Content-Range"] = "bytes 500-1233/1234" - @headers.range_length.should eql(734) + @headers.range_length.should.eql?(734) end it "returns nil when there is no 'Content-Range' header entry" do - @headers.range_length.should be_nil + @headers.range_length.should == nil end it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do @headers["Content-Range"] = "invalid" - -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range_length }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes 123-abc" - -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range_length }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes abc-123" - -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range_length }.should.raise(Net::HTTPHeaderSyntaxError) end end diff --git a/spec/ruby/library/net-http/httpheader/range_spec.rb b/spec/ruby/library/net-http/httpheader/range_spec.rb index 2de80a825e7fd3..0fc0feb5c9b8be 100644 --- a/spec/ruby/library/net-http/httpheader/range_spec.rb +++ b/spec/ruby/library/net-http/httpheader/range_spec.rb @@ -23,23 +23,23 @@ end it "returns nil when there is no 'Range' header entry" do - @headers.range.should be_nil + @headers.range.should == nil end it "raises a Net::HTTPHeaderSyntaxError when the 'Range' has an invalid format" do @headers["Range"] = "invalid" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Range"] = "bytes 123-abc" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should.raise(Net::HTTPHeaderSyntaxError) @headers["Range"] = "bytes abc-123" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should.raise(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when the 'Range' was not specified" do @headers["Range"] = "bytes=-" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should.raise(Net::HTTPHeaderSyntaxError) end end 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 3bac4098760697..c12df62787e43e 100644 --- a/spec/ruby/library/net-http/httpheader/shared/each_capitalized.rb +++ b/spec/ruby/library/net-http/httpheader/shared/each_capitalized.rb @@ -19,7 +19,7 @@ describe "when passed no block" do it "returns an Enumerator" do enumerator = @headers.send(@method) - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) res = [] enumerator.each do |*key| 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 6bf3a6ddfe6580..5913665a4de203 100644 --- a/spec/ruby/library/net-http/httpheader/shared/each_header.rb +++ b/spec/ruby/library/net-http/httpheader/shared/each_header.rb @@ -19,7 +19,7 @@ describe "when passed no block" do it "returns an Enumerator" do enumerator = @headers.send(@method) - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) res = [] enumerator.each do |*key| 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 efc6a09dfd2cdf..29c9400fef161f 100644 --- a/spec/ruby/library/net-http/httpheader/shared/each_name.rb +++ b/spec/ruby/library/net-http/httpheader/shared/each_name.rb @@ -19,7 +19,7 @@ describe "when passed no block" do it "returns an Enumerator" do enumerator = @headers.send(@method) - enumerator.should be_an_instance_of(Enumerator) + enumerator.should.instance_of?(Enumerator) res = [] enumerator.each do |key| 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 87f51d46f359d9..9ab50a075e8388 100644 --- a/spec/ruby/library/net-http/httpheader/shared/set_range.rb +++ b/spec/ruby/library/net-http/httpheader/shared/set_range.rb @@ -5,13 +5,13 @@ describe "when passed nil" do it "returns nil" do - @headers.send(@method, nil).should be_nil + @headers.send(@method, nil).should == nil end it "deletes the 'Range' header entry" do @headers["Range"] = "bytes 0-499/1234" @headers.send(@method, nil) - @headers["Range"].should be_nil + @headers["Range"].should == nil end end @@ -50,15 +50,15 @@ end it "raises a Net::HTTPHeaderSyntaxError when the first Range element is negative" do - -> { @headers.send(@method, -10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, -10..5) }.should.raise(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when the last Range element is negative" do - -> { @headers.send(@method, 10..-5) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, 10..-5) }.should.raise(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when the last Range element is smaller than the first" do - -> { @headers.send(@method, 10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, 10..5) }.should.raise(Net::HTTPHeaderSyntaxError) end end @@ -75,15 +75,15 @@ end it "raises a Net::HTTPHeaderSyntaxError when start is negative" do - -> { @headers.send(@method, -10, 5) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, -10, 5) }.should.raise(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when start + length is negative" do - -> { @headers.send(@method, 10, -15) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, 10, -15) }.should.raise(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when length is negative" do - -> { @headers.send(@method, 10, -4) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, 10, -4) }.should.raise(Net::HTTPHeaderSyntaxError) end end end diff --git a/spec/ruby/library/net-http/httpheader/shared/size.rb b/spec/ruby/library/net-http/httpheader/shared/size.rb index e2b1e4c22b677d..b38310a940776e 100644 --- a/spec/ruby/library/net-http/httpheader/shared/size.rb +++ b/spec/ruby/library/net-http/httpheader/shared/size.rb @@ -4,15 +4,15 @@ end it "returns the number of header entries in self" do - @headers.send(@method).should eql(0) + @headers.send(@method).should.eql?(0) @headers["a"] = "b" - @headers.send(@method).should eql(1) + @headers.send(@method).should.eql?(1) @headers["b"] = "b" - @headers.send(@method).should eql(2) + @headers.send(@method).should.eql?(2) @headers["c"] = "c" - @headers.send(@method).should eql(3) + @headers.send(@method).should.eql?(3) end end 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 b39b57fe8d430d..9e7d2a53687959 100644 --- a/spec/ruby/library/net-http/httpheader/sub_type_spec.rb +++ b/spec/ruby/library/net-http/httpheader/sub_type_spec.rb @@ -20,13 +20,13 @@ it "returns nil if no 'sub-content-type' is set" do @headers["Content-Type"] = "text" - @headers.sub_type.should be_nil + @headers.sub_type.should == nil @headers["Content-Type"] = "text;charset=utf-8" - @headers.sub_type.should be_nil + @headers.sub_type.should == nil end it "returns nil if the 'Content-Type' header entry does not exist" do - @headers.sub_type.should be_nil + @headers.sub_type.should == nil end end 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 3cebc519a6c835..e245c20d4cd627 100644 --- a/spec/ruby/library/net-http/httpheader/to_hash_spec.rb +++ b/spec/ruby/library/net-http/httpheader/to_hash_spec.rb @@ -20,6 +20,6 @@ it "does not allow modifying the headers from the returned hash" do @headers.to_hash["my-header"] = ["test"] @headers.to_hash.should == {} - @headers.key?("my-header").should be_false + @headers.key?("my-header").should == false end end diff --git a/spec/ruby/library/net-http/httprequest/initialize_spec.rb b/spec/ruby/library/net-http/httprequest/initialize_spec.rb index d009a00ed2eba2..1229986bef0433 100644 --- a/spec/ruby/library/net-http/httprequest/initialize_spec.rb +++ b/spec/ruby/library/net-http/httprequest/initialize_spec.rb @@ -21,12 +21,12 @@ class TestRequest < Net::HTTPRequest it "uses the REQUEST_HAS_BODY to set whether the Request has a body or not" do @req.send(:initialize, "/some/path") - @req.request_body_permitted?.should be_false + @req.request_body_permitted?.should == false end it "uses the RESPONSE_HAS_BODY to set whether the Response can have a body or not" do @req.send(:initialize, "/some/path") - @req.response_body_permitted?.should be_true + @req.response_body_permitted?.should == true end describe "when passed path" do diff --git a/spec/ruby/library/net-http/httpresponse/error_spec.rb b/spec/ruby/library/net-http/httpresponse/error_spec.rb index 6ced90fa2347c7..e194df95afddd4 100644 --- a/spec/ruby/library/net-http/httpresponse/error_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/error_spec.rb @@ -4,21 +4,21 @@ describe "Net::HTTPResponse#error!" do it "raises self's class 'EXCEPTION_TYPE' Exception" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - -> { res.error! }.should raise_error(Net::HTTPError) + -> { res.error! }.should.raise(Net::HTTPError) res = Net::HTTPInformation.new("1.0", "1xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPError) + -> { res.error! }.should.raise(Net::HTTPError) res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPError) + -> { res.error! }.should.raise(Net::HTTPError) res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPRetriableError) + -> { res.error! }.should.raise(Net::HTTPRetriableError) res = Net::HTTPClientError.new("1.0", "4xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPClientException) + -> { res.error! }.should.raise(Net::HTTPClientException) res = Net::HTTPServerError.new("1.0", "5xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPFatalError) + -> { res.error! }.should.raise(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 a403dbd2c33191..3ddadfb8e4d2b8 100644 --- a/spec/ruby/library/net-http/httpresponse/header_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/header_spec.rb @@ -4,6 +4,6 @@ describe "Net::HTTPResponse#header" do it "returns self" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.response.should equal(res) + res.response.should.equal?(res) end end 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 4530a26bfc264b..d8b241862401d8 100644 --- a/spec/ruby/library/net-http/httpresponse/read_body_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/read_body_spec.rb @@ -17,7 +17,7 @@ it "returns the previously read body if called a second time" do @res.reading_body(@socket, true) do - @res.read_body.should equal(@res.read_body) + @res.read_body.should.equal?(@res.read_body) end end end @@ -34,14 +34,14 @@ it "returns the passed buffer" do @res.reading_body(@socket, true) do buffer = +"" - @res.read_body(buffer).should equal(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(+"") }.should.raise(IOError) end end end @@ -57,21 +57,21 @@ buffer << body end - yielded.should be_true + yielded.should == true buffer.should == "test body" end end it "returns the ReadAdapter" do @res.reading_body(@socket, true) do - @res.read_body { nil }.should be_kind_of(Net::ReadAdapter) + @res.read_body { nil }.should.is_a?(Net::ReadAdapter) 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 {} }.should.raise(IOError) end end end @@ -79,7 +79,7 @@ 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(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 3ea4ee834b4d3d..70ce9885023e8d 100644 --- a/spec/ruby/library/net-http/httpresponse/read_header_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/read_header_spec.rb @@ -4,6 +4,6 @@ describe "Net::HTTPResponse#read_header" do it "returns self" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.response.should equal(res) + res.response.should.equal?(res) end end 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 82f7a47ce8d020..3795e29d83d12f 100644 --- a/spec/ruby/library/net-http/httpresponse/read_new_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/read_new_spec.rb @@ -12,7 +12,7 @@ EOS response = Net::HTTPResponse.read_new(socket) - response.should be_kind_of(Net::HTTPOK) + response.should.is_a?(Net::HTTPOK) response.code.should == "200" response["Content-Type"].should == "text/html; charset=utf-8" 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 637a2806f89fa0..a3671d6eb549f2 100644 --- a/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb @@ -22,7 +22,7 @@ yielded = true end - yielded.should be_true + yielded.should == true end describe "but the response type is not allowed to have a body" do @@ -31,28 +31,28 @@ end it "returns nil" do - @res.reading_body(@socket, false) {}.should be_nil - @res.body.should be_nil + @res.reading_body(@socket, false) {}.should == nil + @res.body.should == nil end it "yields the passed block" do yielded = false @res.reading_body(@socket, true) { yielded = true } - yielded.should be_true + yielded.should == true end end end describe "when body_allowed is false" do it "returns nil" do - @res.reading_body(@socket, false) {}.should be_nil - @res.body.should be_nil + @res.reading_body(@socket, false) {}.should == nil + @res.body.should == nil end it "yields the passed block" do yielded = false @res.reading_body(@socket, true) { yielded = true } - yielded.should be_true + yielded.should == true end end end diff --git a/spec/ruby/library/net-http/httpresponse/response_spec.rb b/spec/ruby/library/net-http/httpresponse/response_spec.rb index caa0ca2d190be3..440c33c168bf53 100644 --- a/spec/ruby/library/net-http/httpresponse/response_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/response_spec.rb @@ -4,6 +4,6 @@ describe "Net::HTTPResponse#response" do it "returns self" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.response.should equal(res) + res.response.should.equal?(res) end end diff --git a/spec/ruby/library/net-http/httpresponse/shared/body.rb b/spec/ruby/library/net-http/httpresponse/shared/body.rb index 618e3936fb5fe2..368774fb52836f 100644 --- a/spec/ruby/library/net-http/httpresponse/shared/body.rb +++ b/spec/ruby/library/net-http/httpresponse/shared/body.rb @@ -14,7 +14,7 @@ it "returns the previously read body if called a second time" do @res.reading_body(@socket, true) do - @res.send(@method).should equal(@res.send(@method)) + @res.send(@method).should.equal?(@res.send(@method)) end end end diff --git a/spec/ruby/library/net-http/httpresponse/value_spec.rb b/spec/ruby/library/net-http/httpresponse/value_spec.rb index 2df8beaa10d9f8..e32d37500ab408 100644 --- a/spec/ruby/library/net-http/httpresponse/value_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/value_spec.rb @@ -4,21 +4,21 @@ describe "Net::HTTPResponse#value" do it "raises an HTTP error for non 2xx HTTP Responses" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - -> { res.value }.should raise_error(Net::HTTPError) + -> { res.value }.should.raise(Net::HTTPError) res = Net::HTTPInformation.new("1.0", "1xx", "test response") - -> { res.value }.should raise_error(Net::HTTPError) + -> { res.value }.should.raise(Net::HTTPError) res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - -> { res.value }.should_not raise_error(Net::HTTPError) + -> { res.value }.should_not.raise(Net::HTTPError) res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - -> { res.value }.should raise_error(Net::HTTPRetriableError) + -> { res.value }.should.raise(Net::HTTPRetriableError) res = Net::HTTPClientError.new("1.0", "4xx", "test response") - -> { res.value }.should raise_error(Net::HTTPClientException) + -> { res.value }.should.raise(Net::HTTPClientException) res = Net::HTTPServerError.new("1.0", "5xx", "test response") - -> { res.value }.should raise_error(Net::HTTPFatalError) + -> { res.value }.should.raise(Net::HTTPFatalError) end end diff --git a/spec/ruby/library/objectspace/dump_all_spec.rb b/spec/ruby/library/objectspace/dump_all_spec.rb index e9b449a90519b3..c92812ebd5af67 100644 --- a/spec/ruby/library/objectspace/dump_all_spec.rb +++ b/spec/ruby/library/objectspace/dump_all_spec.rb @@ -82,7 +82,7 @@ ObjectSpace.dump_all(output: :stdout) RUBY - stdout.should include('"value":"abc"') + stdout.should.include?('"value":"abc"') end it "dumps Ruby heap to provided IO when passed output: IO" do @@ -107,6 +107,6 @@ end it "raises ArgumentError when passed not supported :output value" do - -> { ObjectSpace.dump_all(output: Object.new) }.should raise_error(ArgumentError, /wrong output option/) + -> { ObjectSpace.dump_all(output: Object.new) }.should.raise(ArgumentError, /wrong output option/) end end diff --git a/spec/ruby/library/objectspace/dump_spec.rb b/spec/ruby/library/objectspace/dump_spec.rb index e22ee3df1ed6ba..4b5e0da198446a 100644 --- a/spec/ruby/library/objectspace/dump_spec.rb +++ b/spec/ruby/library/objectspace/dump_spec.rb @@ -13,23 +13,23 @@ 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"') + string.should.is_a?(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"') + string.should.is_a?(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.should.is_a?(File) file.rewind content = file.read - content.should include('"value":"abc"') + content.should.include?('"value":"abc"') ensure file.close File.unlink file.path @@ -37,10 +37,10 @@ it "dumps to a temporary file when passed output: :nil" do file = ObjectSpace.dump("abc", output: nil) - file.should be_kind_of(File) + file.should.is_a?(File) file.rewind - file.read.should include('"value":"abc"') + file.read.should.include?('"value":"abc"') ensure file.close File.unlink file.path @@ -48,7 +48,7 @@ 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"') + stdout.should.include?('"value":"abc"') end it "dumps to provided IO when passed output: IO" do @@ -58,13 +58,13 @@ result.should.equal? io io.rewind - io.read.should include('"value":"abc"') + 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/) + -> { ObjectSpace.dump("abc", output: Object.new) }.should.raise(ArgumentError, /wrong output option/) end end diff --git a/spec/ruby/library/objectspace/memsize_of_all_spec.rb b/spec/ruby/library/objectspace/memsize_of_all_spec.rb index c5a48165ce3cff..9fc6e8be9dc6b0 100644 --- a/spec/ruby/library/objectspace/memsize_of_all_spec.rb +++ b/spec/ruby/library/objectspace/memsize_of_all_spec.rb @@ -3,12 +3,12 @@ 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.is_a?(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.is_a?(Integer) ObjectSpace.memsize_of_all(Class).should > 0 end diff --git a/spec/ruby/library/objectspace/memsize_of_spec.rb b/spec/ruby/library/objectspace/memsize_of_spec.rb index cbb5a07d54f9f5..9c8aea4e84ea0a 100644 --- a/spec/ruby/library/objectspace/memsize_of_spec.rb +++ b/spec/ruby/library/objectspace/memsize_of_spec.rb @@ -18,7 +18,7 @@ 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.is_a?(Integer) ObjectSpace.memsize_of(obj).should > 0 end diff --git a/spec/ruby/library/objectspace/reachable_objects_from_spec.rb b/spec/ruby/library/objectspace/reachable_objects_from_spec.rb index dee5961663374d..4620bdec3121ac 100644 --- a/spec/ruby/library/objectspace/reachable_objects_from_spec.rb +++ b/spec/ruby/library/objectspace/reachable_objects_from_spec.rb @@ -16,7 +16,7 @@ end it "enumerates objects directly reachable from a given object" do - ObjectSpace.reachable_objects_from(['a', 'b', 'c']).should include(Array, 'a', 'b', 'c') + ObjectSpace.reachable_objects_from(['a', 'b', 'c']).to_set.should >= Set[Array, 'a', 'b', 'c'] ObjectSpace.reachable_objects_from(Object.new).should == [Object] end @@ -24,7 +24,7 @@ obj = Object.new ary = [obj] reachable = ObjectSpace.reachable_objects_from(ary) - reachable.should include(obj) + reachable.should.include?(obj) end it "finds an object stored in a copy-on-write Array" do @@ -33,8 +33,8 @@ ary = [removed, obj] ary.shift reachable = ObjectSpace.reachable_objects_from(ary) - reachable.should include(obj) - reachable.should_not include(removed) + reachable.should.include?(obj) + reachable.should_not.include?(removed) end it "finds an object stored in a Queue" do @@ -44,7 +44,7 @@ reachable = ObjectSpace.reachable_objects_from(q) reachable = reachable + reachable.flat_map { |r| ObjectSpace.reachable_objects_from(r) } - reachable.should include(o) + reachable.should.include?(o) end it "finds an object stored in a SizedQueue" do @@ -54,6 +54,6 @@ reachable = ObjectSpace.reachable_objects_from(q) reachable = reachable + reachable.flat_map { |r| ObjectSpace.reachable_objects_from(r) } - reachable.should include(o) + reachable.should.include?(o) end end diff --git a/spec/ruby/library/objectspace/trace_object_allocations_spec.rb b/spec/ruby/library/objectspace/trace_object_allocations_spec.rb index 0f1e2aa8b93abf..0bb6efbfa5f0af 100644 --- a/spec/ruby/library/objectspace/trace_object_allocations_spec.rb +++ b/spec/ruby/library/objectspace/trace_object_allocations_spec.rb @@ -74,7 +74,7 @@ def obj_class_path o = Object.new ObjectSpace.allocation_class_path(o).should == obj_class_path ObjectSpace.trace_object_allocations_clear - ObjectSpace.allocation_class_path(o).should be_nil + ObjectSpace.allocation_class_path(o).should == nil end end diff --git a/spec/ruby/library/observer/notify_observers_spec.rb b/spec/ruby/library/observer/notify_observers_spec.rb index 31f82e9266d760..6f3f9846377550 100644 --- a/spec/ruby/library/observer/notify_observers_spec.rb +++ b/spec/ruby/library/observer/notify_observers_spec.rb @@ -18,7 +18,7 @@ it "verifies observer responds to update" do -> { @observable.add_observer(@observable) - }.should raise_error(NoMethodError) + }.should.raise(NoMethodError) end it "receives the callback" do diff --git a/spec/ruby/library/open3/popen3_spec.rb b/spec/ruby/library/open3/popen3_spec.rb index d3103ad3cb978c..3651bd516ce564 100644 --- a/spec/ruby/library/open3/popen3_spec.rb +++ b/spec/ruby/library/open3/popen3_spec.rb @@ -5,10 +5,10 @@ it "returns in, out, err and a thread waiting the process" do stdin, out, err, waiter = Open3.popen3(ruby_cmd("print :foo")) begin - stdin.should be_kind_of IO - out.should be_kind_of IO - err.should be_kind_of IO - waiter.should be_kind_of Thread + stdin.should.is_a? IO + out.should.is_a? IO + err.should.is_a? IO + waiter.should.is_a? Thread out.read.should == "foo" ensure diff --git a/spec/ruby/library/openssl/cipher_spec.rb b/spec/ruby/library/openssl/cipher_spec.rb index f66f25f9c61ac3..91da1c592cf224 100644 --- a/spec/ruby/library/openssl/cipher_spec.rb +++ b/spec/ruby/library/openssl/cipher_spec.rb @@ -4,6 +4,6 @@ describe "OpenSSL::Cipher's CipherError" do it "exists under OpenSSL::Cipher namespace" do - OpenSSL::Cipher.should have_constant :CipherError + OpenSSL::Cipher.should.const_defined?(:CipherError, false) end end diff --git a/spec/ruby/library/openssl/digest/initialize_spec.rb b/spec/ruby/library/openssl/digest/initialize_spec.rb index b5911716ca8c14..e24ab51d1459bc 100644 --- a/spec/ruby/library/openssl/digest/initialize_spec.rb +++ b/spec/ruby/library/openssl/digest/initialize_spec.rb @@ -25,12 +25,12 @@ version_is OpenSSL::VERSION, "4.0.0" do it "throws an error when called with an unknown digest" do - -> { OpenSSL::Digest.new("wd40") }.should raise_error(OpenSSL::Digest::DigestError, /wd40/) + -> { OpenSSL::Digest.new("wd40") }.should.raise(OpenSSL::Digest::DigestError, /wd40/) end end it "cannot be called with a symbol" do - -> { OpenSSL::Digest.new(:SHA1) }.should raise_error(TypeError) + -> { OpenSSL::Digest.new(:SHA1) }.should.raise(TypeError) end end @@ -58,7 +58,7 @@ end it "cannot be called with a digest class" do - -> { OpenSSL::Digest.new(OpenSSL::Digest::SHA1) }.should raise_error(TypeError) + -> { OpenSSL::Digest.new(OpenSSL::Digest::SHA1) }.should.raise(TypeError) end context "when called without an initial String argument" do diff --git a/spec/ruby/library/openssl/digest/shared/update.rb b/spec/ruby/library/openssl/digest/shared/update.rb index e5ff9dcb16f6e3..37277c945dcb8a 100644 --- a/spec/ruby/library/openssl/digest/shared/update.rb +++ b/spec/ruby/library/openssl/digest/shared/update.rb @@ -96,28 +96,28 @@ digest = OpenSSL::Digest.new('sha1') -> { digest.send(@method, Object.new) - }.should raise_error(TypeError, 'no implicit conversion of Object into String') + }.should.raise(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') + }.should.raise(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') + }.should.raise(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') + }.should.raise(TypeError, 'no implicit conversion of Object into String') end end 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 index 5a2ca168b5367d..cc638e1f0de640 100644 --- a/spec/ruby/library/openssl/fixed_length_secure_compare_spec.rb +++ b/spec/ruby/library/openssl/fixed_length_secure_compare_spec.rb @@ -5,13 +5,13 @@ 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 + OpenSSL.fixed_length_secure_compare(input1, input2).should == 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 + OpenSSL.fixed_length_secure_compare(input1, input2).should == false end it "converts both arguments to strings using #to_str" do @@ -19,17 +19,17 @@ 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 + OpenSSL.fixed_length_secure_compare(input1, input2).should == 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') + }.should.raise(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') + }.should.raise(TypeError, 'no implicit conversion of Object into String') end it "raises an ArgumentError for two strings of different size" do @@ -37,6 +37,6 @@ input2 = "the quick brown fox" -> { OpenSSL.fixed_length_secure_compare(input1, input2) - }.should raise_error(ArgumentError, 'inputs must be of equal length') + }.should.raise(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 index 1112972060e18e..2558dbb9ec905d 100644 --- a/spec/ruby/library/openssl/kdf/pbkdf2_hmac_spec.rb +++ b/spec/ruby/library/openssl/kdf/pbkdf2_hmac_spec.rb @@ -83,80 +83,80 @@ 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") + }.should.raise(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") + }.should.raise(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") + }.should.raise(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") + }.should.raise(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) + }.should.raise(TypeError) end version_is OpenSSL::VERSION, "4.0.0" do it "raises a OpenSSL::Digest::DigestError for unknown digest algorithms" do -> { OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults, hash: "wd40") - }.should raise_error(OpenSSL::Digest::DigestError, /wd40/) + }.should.raise(OpenSSL::Digest::DigestError, /wd40/) end end it "treats salt as a required keyword" do -> { OpenSSL::KDF.pbkdf2_hmac("secret", **@defaults.except(:salt)) - }.should raise_error(ArgumentError, 'missing keyword: :salt') + }.should.raise(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') + }.should.raise(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') + }.should.raise(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') + }.should.raise(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') + }.should.raise(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") + }.should.raise(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/) + }.should.raise(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 index e01b8bca8a3f21..c00f91bb5b95f8 100644 --- a/spec/ruby/library/openssl/kdf/scrypt_spec.rb +++ b/spec/ruby/library/openssl/kdf/scrypt_spec.rb @@ -89,79 +89,79 @@ 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") + }.should.raise(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") + }.should.raise(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") + }.should.raise(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") + }.should.raise(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") + }.should.raise(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") + }.should.raise(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') + }.should.raise(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') + }.should.raise(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') + }.should.raise(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') + }.should.raise(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') + }.should.raise(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') + }.should.raise(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/) + }.should.raise(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) end it "requires N to be at least 2" do @@ -170,41 +170,41 @@ -> { OpenSSL::KDF.scrypt("secret", **@defaults, N: 1) - }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) + }.should.raise(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) -> { OpenSSL::KDF.scrypt("secret", **@defaults, N: 0) - }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) + }.should.raise(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) -> { OpenSSL::KDF.scrypt("secret", **@defaults, N: -1) - }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) + }.should.raise(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/) + }.should.raise(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) -> { OpenSSL::KDF.scrypt("secret", **@defaults, r: -1) - }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) + }.should.raise(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/) + }.should.raise(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) -> { OpenSSL::KDF.scrypt("secret", **@defaults, p: -1) - }.should raise_error(OpenSSL::KDF::KDFError, /EVP_PBE_scrypt/) + }.should.raise(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)") + }.should.raise(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 f97ccd99745370..4d1751e57e0286 100644 --- a/spec/ruby/library/openssl/random/shared/random_bytes.rb +++ b/spec/ruby/library/openssl/random/shared/random_bytes.rb @@ -5,7 +5,7 @@ it "generates a random binary string of specified length" do (1..64).each do |idx| bytes = OpenSSL::Random.send(@method, idx) - bytes.should be_kind_of(String) + bytes.should.is_a?(String) bytes.length.should == idx end end @@ -24,6 +24,6 @@ it "raises ArgumentError on negative arguments" do -> { OpenSSL::Random.send(@method, -1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/openssl/secure_compare_spec.rb b/spec/ruby/library/openssl/secure_compare_spec.rb index cec48e01e7b7a8..ce2a4a0d4334a2 100644 --- a/spec/ruby/library/openssl/secure_compare_spec.rb +++ b/spec/ruby/library/openssl/secure_compare_spec.rb @@ -5,13 +5,13 @@ 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 + OpenSSL.secure_compare(input1, input2).should == 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 + OpenSSL.secure_compare(input1, input2).should == false end it "converts both arguments to strings using #to_str, but adds equality check for the original objects" do @@ -19,20 +19,20 @@ 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 + OpenSSL.secure_compare(input1, input2).should == 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 + OpenSSL.secure_compare(input, input).should == 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') + }.should.raise(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') + }.should.raise(TypeError, 'no implicit conversion of Object into String') end end diff --git a/spec/ruby/library/openssl/x509/name/parse_spec.rb b/spec/ruby/library/openssl/x509/name/parse_spec.rb index 6624161d837181..84e3d442f64f69 100644 --- a/spec/ruby/library/openssl/x509/name/parse_spec.rb +++ b/spec/ruby/library/openssl/x509/name/parse_spec.rb @@ -37,12 +37,12 @@ it "raises TypeError if the given string contains no key/value pairs" do -> do OpenSSL::X509::Name.parse("hello") - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises OpenSSL::X509::NameError if the given string contains invalid keys" do -> do OpenSSL::X509::Name.parse("hello=goodbye") - end.should raise_error(OpenSSL::X509::NameError) + end.should.raise(OpenSSL::X509::NameError) end end diff --git a/spec/ruby/library/openstruct/delete_field_spec.rb b/spec/ruby/library/openstruct/delete_field_spec.rb index 9ac80196cc6933..12fed6c90dfacc 100644 --- a/spec/ruby/library/openstruct/delete_field_spec.rb +++ b/spec/ruby/library/openstruct/delete_field_spec.rb @@ -8,12 +8,12 @@ it "removes the named field from self's method/value table" do @os.delete_field(:name) - @os[:name].should be_nil + @os[:name].should == nil end it "does remove the accessor methods" do @os.delete_field(:name) - @os.respond_to?(:name).should be_false - @os.respond_to?(:name=).should be_false + @os.respond_to?(:name).should == false + @os.respond_to?(:name=).should == false end end diff --git a/spec/ruby/library/openstruct/equal_value_spec.rb b/spec/ruby/library/openstruct/equal_value_spec.rb index 103ac135886ab9..c72c09ce14a25f 100644 --- a/spec/ruby/library/openstruct/equal_value_spec.rb +++ b/spec/ruby/library/openstruct/equal_value_spec.rb @@ -8,21 +8,21 @@ end it "returns false when the passed argument is no OpenStruct" do - (@os == Object.new).should be_false - (@os == "Test").should be_false - (@os == 10).should be_false - (@os == :sym).should be_false + (@os == Object.new).should == false + (@os == "Test").should == false + (@os == 10).should == false + (@os == :sym).should == false end it "returns true when self and other are equal method/value wise" do - (@os == @os).should be_true - (@os == OpenStruct.new(name: "John")).should be_true - (@os == OpenStructSpecs::OpenStructSub.new(name: "John")).should be_true + (@os == @os).should == true + (@os == OpenStruct.new(name: "John")).should == true + (@os == OpenStructSpecs::OpenStructSub.new(name: "John")).should == true - (@os == OpenStruct.new(name: "Jonny")).should be_false - (@os == OpenStructSpecs::OpenStructSub.new(name: "Jonny")).should be_false + (@os == OpenStruct.new(name: "Jonny")).should == false + (@os == OpenStructSpecs::OpenStructSub.new(name: "Jonny")).should == false - (@os == OpenStruct.new(name: "John", age: 20)).should be_false - (@os == OpenStructSpecs::OpenStructSub.new(name: "John", age: 20)).should be_false + (@os == OpenStruct.new(name: "John", age: 20)).should == false + (@os == OpenStructSpecs::OpenStructSub.new(name: "John", age: 20)).should == false end end diff --git a/spec/ruby/library/openstruct/frozen_spec.rb b/spec/ruby/library/openstruct/frozen_spec.rb index c14a4bac55deb4..c37fd18c8ca579 100644 --- a/spec/ruby/library/openstruct/frozen_spec.rb +++ b/spec/ruby/library/openstruct/frozen_spec.rb @@ -9,25 +9,25 @@ # method_missing case handled in method_missing_spec.rb # it "is still readable" do - @os.age.should eql(70) - @os.pension.should eql(300) + @os.age.should.eql?(70) + @os.pension.should.eql?(300) @os.name.should == "John Smith" end it "is not writable" do - ->{ @os.age = 42 }.should raise_error( RuntimeError ) + ->{ @os.age = 42 }.should.raise( RuntimeError ) end it "cannot create new fields" do - ->{ @os.state = :new }.should raise_error( RuntimeError ) + ->{ @os.state = :new }.should.raise( RuntimeError ) end it "creates a frozen clone" do f = @os.clone f.frozen?.should == true f.age.should == 70 - ->{ f.age = 0 }.should raise_error( RuntimeError ) - ->{ f.state = :newer }.should raise_error( RuntimeError ) + ->{ f.age = 0 }.should.raise( RuntimeError ) + ->{ f.state = :newer }.should.raise( RuntimeError ) end it "creates an unfrozen dup" do diff --git a/spec/ruby/library/openstruct/initialize_spec.rb b/spec/ruby/library/openstruct/initialize_spec.rb index dee5de48c63d51..52304cf780927d 100644 --- a/spec/ruby/library/openstruct/initialize_spec.rb +++ b/spec/ruby/library/openstruct/initialize_spec.rb @@ -3,6 +3,6 @@ describe "OpenStruct#initialize" do it "is private" do - OpenStruct.should have_private_instance_method(:initialize) + OpenStruct.private_instance_methods(false).should.include?(:initialize) end end diff --git a/spec/ruby/library/openstruct/marshal_load_spec.rb b/spec/ruby/library/openstruct/marshal_load_spec.rb index 342e5e68cdaf29..a8cdda3b4358c5 100644 --- a/spec/ruby/library/openstruct/marshal_load_spec.rb +++ b/spec/ruby/library/openstruct/marshal_load_spec.rb @@ -6,7 +6,7 @@ os = OpenStruct.new os.send :marshal_load, age: 20, name: "John" - os.age.should eql(20) + os.age.should.eql?(20) os.name.should == "John" end end diff --git a/spec/ruby/library/openstruct/method_missing_spec.rb b/spec/ruby/library/openstruct/method_missing_spec.rb index 89f83d07b3cb9a..cf6734d6299a9c 100644 --- a/spec/ruby/library/openstruct/method_missing_spec.rb +++ b/spec/ruby/library/openstruct/method_missing_spec.rb @@ -7,18 +7,18 @@ end it "raises an ArgumentError when not passed any additional arguments" do - -> { @os.send(:test=) }.should raise_error(ArgumentError) + -> { @os.send(:test=) }.should.raise(ArgumentError) end end describe "OpenStruct#method_missing when passed additional arguments" do it "raises a NoMethodError when the key does not exist" do os = OpenStruct.new - -> { os.test(1, 2, 3) }.should raise_error(NoMethodError) + -> { os.test(1, 2, 3) }.should.raise(NoMethodError) end it "raises an ArgumentError when the key exists" do os = OpenStruct.new(test: 20) - -> { os.test(1, 2, 3) }.should raise_error(ArgumentError) + -> { os.test(1, 2, 3) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/openstruct/new_spec.rb b/spec/ruby/library/openstruct/new_spec.rb index 5d2cacea40566c..9e53948c82a674 100644 --- a/spec/ruby/library/openstruct/new_spec.rb +++ b/spec/ruby/library/openstruct/new_spec.rb @@ -7,8 +7,8 @@ end it "creates an attribute for each key of the passed Hash" do - @os.age.should eql(70) - @os.pension.should eql(300) + @os.age.should.eql?(70) + @os.pension.should.eql?(300) @os.name.should == "John Smith" end end diff --git a/spec/ruby/library/openstruct/shared/inspect.rb b/spec/ruby/library/openstruct/shared/inspect.rb index ffcd690e1f8fa2..d5fffa0e2e378e 100644 --- a/spec/ruby/library/openstruct/shared/inspect.rb +++ b/spec/ruby/library/openstruct/shared/inspect.rb @@ -4,7 +4,7 @@ os.send(@method).should == "#" os = OpenStruct.new(age: 20, name: "John Smith") - os.send(@method).should be_kind_of(String) + os.send(@method).should.is_a?(String) end it "correctly handles self-referential OpenStructs" do diff --git a/spec/ruby/library/openstruct/to_h_spec.rb b/spec/ruby/library/openstruct/to_h_spec.rb index 6c272bcc7135c4..7d9c7db5dc9884 100644 --- a/spec/ruby/library/openstruct/to_h_spec.rb +++ b/spec/ruby/library/openstruct/to_h_spec.rb @@ -19,7 +19,7 @@ end it "does not return the hash used as initializer" do - @to_h.should_not equal(@h) + @to_h.should_not.equal?(@h) end it "returns a Hash that is independent from the struct" do @@ -36,17 +36,17 @@ 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/) + end.should.raise(ArgumentError, /element has wrong array length/) -> do @os.to_h { |k, v| [k] } - end.should raise_error(ArgumentError, /element has wrong array length/) + end.should.raise(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.should.raise(TypeError, /wrong element type String/) end it "coerces returned pair to Array with #to_ary" do @@ -62,7 +62,7 @@ -> do @os.to_h { |k| x } - end.should raise_error(TypeError, /wrong element type MockObject/) + end.should.raise(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 index 109c1123032c5c..387f0aa54d630c 100644 --- a/spec/ruby/library/pathname/birthtime_spec.rb +++ b/spec/ruby/library/pathname/birthtime_spec.rb @@ -4,13 +4,13 @@ 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) + Pathname.new(__FILE__).birthtime.should.is_a?(Time) end end platform_is :openbsd do it "raises an NotImplementedError" do - -> { Pathname.new(__FILE__).birthtime }.should raise_error(NotImplementedError) + -> { Pathname.new(__FILE__).birthtime }.should.raise(NotImplementedError) end end end diff --git a/spec/ruby/library/pathname/empty_spec.rb b/spec/ruby/library/pathname/empty_spec.rb index 4deade5b6417a1..9f0305a0f04219 100644 --- a/spec/ruby/library/pathname/empty_spec.rb +++ b/spec/ruby/library/pathname/empty_spec.rb @@ -15,18 +15,18 @@ end it 'returns true when file is not empty' do - Pathname.new(__FILE__).empty?.should be_false + Pathname.new(__FILE__).empty?.should == false end it 'returns false when the directory is not empty' do - Pathname.new(__dir__).empty?.should be_false + Pathname.new(__dir__).empty?.should == false end it 'return true when file is empty' do - Pathname.new(@file).empty?.should be_true + Pathname.new(@file).empty?.should == true end it 'returns true when directory is empty' do - Pathname.new(@dir).empty?.should be_true + Pathname.new(@dir).empty?.should == true end end diff --git a/spec/ruby/library/pathname/glob_spec.rb b/spec/ruby/library/pathname/glob_spec.rb index 6249d0ae021bd6..e20e6f8f85eed7 100644 --- a/spec/ruby/library/pathname/glob_spec.rb +++ b/spec/ruby/library/pathname/glob_spec.rb @@ -41,7 +41,7 @@ it "raises an ArgumentError when supplied a keyword argument other than :base" do -> { Pathname.glob('*i*.rb', foo: @dir + 'lib') - }.should raise_error(ArgumentError, "unknown keyword: :foo") + }.should.raise(ArgumentError, "unknown keyword: :foo") end it "does not raise an ArgumentError when supplied a flag and :base keyword argument" do @@ -81,7 +81,7 @@ it 'yields matching file paths to block' do ary = [] - Pathname.new(@dir).glob('lib/*i*.rb') { |p| ary << p }.should be_nil + Pathname.new(@dir).glob('lib/*i*.rb') { |p| ary << p }.should == nil ary.sort.should == [Pathname.new(@file_1), Pathname.new(@file_2)].sort end diff --git a/spec/ruby/library/pathname/inspect_spec.rb b/spec/ruby/library/pathname/inspect_spec.rb index 304746fbe5c2c6..3abba6cbb5e641 100644 --- a/spec/ruby/library/pathname/inspect_spec.rb +++ b/spec/ruby/library/pathname/inspect_spec.rb @@ -4,7 +4,7 @@ describe "Pathname#inspect" do it "returns a consistent String" do result = Pathname.new('/tmp').inspect - result.should be_an_instance_of(String) + result.should.instance_of?(String) result.should == "#" end end diff --git a/spec/ruby/library/pathname/new_spec.rb b/spec/ruby/library/pathname/new_spec.rb index 36226ed515ad72..3ef9d9b76d42ee 100644 --- a/spec/ruby/library/pathname/new_spec.rb +++ b/spec/ruby/library/pathname/new_spec.rb @@ -3,18 +3,18 @@ describe "Pathname.new" do it "returns a new Pathname Object with 1 argument" do - Pathname.new('').should be_kind_of(Pathname) + Pathname.new('').should.is_a?(Pathname) end it "raises an ArgumentError when called with \0" do - -> { Pathname.new("\0")}.should raise_error(ArgumentError) + -> { Pathname.new("\0")}.should.raise(ArgumentError) 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) - -> { Pathname.new(true) }.should raise_error(TypeError) - -> { Pathname.new(false) }.should raise_error(TypeError) + -> { Pathname.new(nil) }.should.raise(TypeError) + -> { Pathname.new(0) }.should.raise(TypeError) + -> { Pathname.new(true) }.should.raise(TypeError) + -> { Pathname.new(false) }.should.raise(TypeError) end it "initializes with an object with to_path" do diff --git a/spec/ruby/library/pathname/pathname_spec.rb b/spec/ruby/library/pathname/pathname_spec.rb index 0fb28814685cfc..6fa6fd2bcba58d 100644 --- a/spec/ruby/library/pathname/pathname_spec.rb +++ b/spec/ruby/library/pathname/pathname_spec.rb @@ -3,11 +3,11 @@ describe "Kernel#Pathname" do it "is a private instance method" do - Kernel.should have_private_instance_method(:Pathname) + Kernel.private_instance_methods(false).should.include?(:Pathname) end it "is also a public method" do - Kernel.should have_method(:Pathname) + Kernel.should.respond_to?(:Pathname) end it "returns same argument when called with a pathname argument" do diff --git a/spec/ruby/library/pathname/realdirpath_spec.rb b/spec/ruby/library/pathname/realdirpath_spec.rb index a9e44e354e2dd7..e50741a737f286 100644 --- a/spec/ruby/library/pathname/realdirpath_spec.rb +++ b/spec/ruby/library/pathname/realdirpath_spec.rb @@ -4,7 +4,7 @@ describe "Pathname#realdirpath" do it "returns a Pathname" do - Pathname.pwd.realdirpath.should be_an_instance_of(Pathname) + Pathname.pwd.realdirpath.should.instance_of?(Pathname) end end diff --git a/spec/ruby/library/pathname/realpath_spec.rb b/spec/ruby/library/pathname/realpath_spec.rb index f2c654308e06dc..d8b87f57d0f8f6 100644 --- a/spec/ruby/library/pathname/realpath_spec.rb +++ b/spec/ruby/library/pathname/realpath_spec.rb @@ -4,7 +4,7 @@ describe "Pathname#realpath" do it "returns a Pathname" do - Pathname.pwd.realpath.should be_an_instance_of(Pathname) + Pathname.pwd.realpath.should.instance_of?(Pathname) 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 133a149849f0f3..7cbd22c3d6892e 100644 --- a/spec/ruby/library/pathname/relative_path_from_spec.rb +++ b/spec/ruby/library/pathname/relative_path_from_spec.rb @@ -7,11 +7,11 @@ def relative_path_str(dest, base) end it "raises an error when the two paths do not share a common prefix" do - -> { relative_path_str('/usr', 'foo') }.should raise_error(ArgumentError) + -> { relative_path_str('/usr', 'foo') }.should.raise(ArgumentError) end it "raises an error when the base directory has .." do - -> { relative_path_str('a', '..') }.should raise_error(ArgumentError) + -> { relative_path_str('a', '..') }.should.raise(ArgumentError) end it "returns a path relative from root" do diff --git a/spec/ruby/library/prime/each_spec.rb b/spec/ruby/library/prime/each_spec.rb index b99cf7cf0e0211..d81e952a88c0f1 100644 --- a/spec/ruby/library/prime/each_spec.rb +++ b/spec/ruby/library/prime/each_spec.rb @@ -32,11 +32,11 @@ all_prime &&= (2..Math.sqrt(prime)).all? { |d| prime % d != 0 } end - all_prime.should be_true + all_prime.should == true end it "returns the last evaluated expression in the passed block" do - @object.each { break :value }.should equal(:value) + @object.each { break :value }.should.equal?(:value) end describe "when not passed a block" do @@ -45,23 +45,23 @@ end it "returns an object that is Enumerable" do - @prime_enum.each.should be_kind_of(Enumerable) + @prime_enum.each.should.is_a?(Enumerable) end it "returns an object that responds to #with_index" do - @prime_enum.should respond_to(:with_index) + @prime_enum.should.respond_to?(:with_index) end it "returns an object that responds to #with_object" do - @prime_enum.should respond_to(:with_object) + @prime_enum.should.respond_to?(:with_object) end it "returns an object that responds to #next" do - @prime_enum.should respond_to(:next) + @prime_enum.should.respond_to?(:next) end it "returns an object that responds to #rewind" do - @prime_enum.should respond_to(:rewind) + @prime_enum.should.respond_to?(:rewind) end it "yields primes starting at 2 independent of prior enumerators" do @@ -106,13 +106,13 @@ ScratchPad.recorded.all? do |prime| (2..Math.sqrt(prime)).all? { |d| prime % d != 0 } - end.should be_true + end.should == true - ScratchPad.recorded.all? { |prime| prime <= bound }.should be_true + ScratchPad.recorded.all? { |prime| prime <= bound }.should == true end it "returns nil when no prime is generated" do - @object.each(1) { :value }.should be_nil + @object.each(1) { :value }.should == nil end it "yields primes starting at 2 independent of prior enumeration" do @@ -132,7 +132,7 @@ describe "when not passed a block" do it "returns an object that returns primes less than or equal to the bound" do bound = 100 - @object.each(bound).all? { |prime| prime <= bound }.should be_true + @object.each(bound).all? { |prime| prime <= bound }.should == true end end end diff --git a/spec/ruby/library/prime/instance_spec.rb b/spec/ruby/library/prime/instance_spec.rb index 5183f36901847e..680895eb645992 100644 --- a/spec/ruby/library/prime/instance_spec.rb +++ b/spec/ruby/library/prime/instance_spec.rb @@ -3,12 +3,12 @@ describe "Prime.instance" do it "returns a object representing the set of prime numbers" do - Prime.instance.should be_kind_of(Prime) + Prime.instance.should.is_a?(Prime) end it "returns a object with no obsolete features" do - Prime.instance.should_not respond_to(:succ) - Prime.instance.should_not respond_to(:next) + Prime.instance.should_not.respond_to?(:succ) + Prime.instance.should_not.respond_to?(:next) end it "does not complain anything" do @@ -16,6 +16,6 @@ end it "raises a ArgumentError when is called with some arguments" do - -> { Prime.instance(1) }.should raise_error(ArgumentError) + -> { Prime.instance(1) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/prime/integer/prime_division_spec.rb b/spec/ruby/library/prime/integer/prime_division_spec.rb index be03438a6f8afb..5631b22d0aceb2 100644 --- a/spec/ruby/library/prime/integer/prime_division_spec.rb +++ b/spec/ruby/library/prime/integer/prime_division_spec.rb @@ -14,6 +14,6 @@ -1.prime_division.should == [[-1, 1]] end it "raises ZeroDivisionError for 0" do - -> { 0.prime_division }.should raise_error(ZeroDivisionError) + -> { 0.prime_division }.should.raise(ZeroDivisionError) end end diff --git a/spec/ruby/library/prime/integer/prime_spec.rb b/spec/ruby/library/prime/integer/prime_spec.rb index 53de76d5ab337d..d24f883b1932d2 100644 --- a/spec/ruby/library/prime/integer/prime_spec.rb +++ b/spec/ruby/library/prime/integer/prime_spec.rb @@ -3,15 +3,15 @@ describe "Integer#prime?" do it "returns a true value for prime numbers" do - 2.prime?.should be_true - 3.prime?.should be_true - (2**31-1).prime?.should be_true # 8th Mersenne prime (M8) + 2.prime?.should == true + 3.prime?.should == true + (2**31-1).prime?.should == true # 8th Mersenne prime (M8) end it "returns a false value for composite numbers" do - 4.prime?.should be_false - 15.prime?.should be_false - (2**32-1).prime?.should be_false - ( (2**17-1)*(2**19-1) ).prime?.should be_false # M6*M7 + 4.prime?.should == false + 15.prime?.should == false + (2**32-1).prime?.should == false + ( (2**17-1)*(2**19-1) ).prime?.should == false # M6*M7 end end diff --git a/spec/ruby/library/prime/prime_division_spec.rb b/spec/ruby/library/prime/prime_division_spec.rb index 6293478f592cea..cc39969a56a6cf 100644 --- a/spec/ruby/library/prime/prime_division_spec.rb +++ b/spec/ruby/library/prime/prime_division_spec.rb @@ -16,10 +16,10 @@ end it "includes [[-1, 1]] in the divisors of a negative number" do - Prime.prime_division(-10).should include([-1, 1]) + Prime.prime_division(-10).should.include?([-1, 1]) end it "raises ZeroDivisionError for 0" do - -> { Prime.prime_division(0) }.should raise_error(ZeroDivisionError) + -> { Prime.prime_division(0) }.should.raise(ZeroDivisionError) end end diff --git a/spec/ruby/library/prime/prime_spec.rb b/spec/ruby/library/prime/prime_spec.rb index 0896c7f0f39a6a..207c763aedffac 100644 --- a/spec/ruby/library/prime/prime_spec.rb +++ b/spec/ruby/library/prime/prime_spec.rb @@ -3,15 +3,15 @@ describe "Prime#prime?" do it "returns a true value for prime numbers" do - Prime.prime?(2).should be_true - Prime.prime?(3).should be_true - Prime.prime?(2**31-1).should be_true # 8th Mersenne prime (M8) + Prime.prime?(2).should == true + Prime.prime?(3).should == true + Prime.prime?(2**31-1).should == true # 8th Mersenne prime (M8) end it "returns a false value for composite numbers" do - Prime.prime?(4).should be_false - Prime.prime?(15).should be_false - Prime.prime?(2**32-1).should be_false - Prime.prime?( (2**17-1)*(2**19-1) ).should be_false # M6*M7 + Prime.prime?(4).should == false + Prime.prime?(15).should == false + Prime.prime?(2**32-1).should == false + Prime.prime?( (2**17-1)*(2**19-1) ).should == false # M6*M7 end end diff --git a/spec/ruby/library/random/formatter/alphanumeric_spec.rb b/spec/ruby/library/random/formatter/alphanumeric_spec.rb index ce45b96dc2b7a7..62a4698d0db279 100644 --- a/spec/ruby/library/random/formatter/alphanumeric_spec.rb +++ b/spec/ruby/library/random/formatter/alphanumeric_spec.rb @@ -30,7 +30,7 @@ it "raises an ArgumentError if the size is not numeric" do -> { @object.alphanumeric("10") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "does not coerce the size argument with #to_int" do @@ -38,7 +38,7 @@ size.should_not_receive(:to_int) -> { @object.alphanumeric(size) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "accepts a 'chars' argument with the output alphabet" do diff --git a/spec/ruby/library/rbconfig/rbconfig_spec.rb b/spec/ruby/library/rbconfig/rbconfig_spec.rb index b9a4588bf0b627..4195128a05092b 100644 --- a/spec/ruby/library/rbconfig/rbconfig_spec.rb +++ b/spec/ruby/library/rbconfig/rbconfig_spec.rb @@ -4,8 +4,8 @@ describe 'RbConfig::CONFIG' do it 'values are all strings' do RbConfig::CONFIG.each do |k, v| - k.should be_kind_of String - v.should be_kind_of String + k.should.is_a? String + v.should.is_a? String end end @@ -32,7 +32,7 @@ it "['sitelibdir'] is set and is part of $LOAD_PATH" do sitelibdir = RbConfig::CONFIG['sitelibdir'] - sitelibdir.should be_kind_of String + sitelibdir.should.is_a? String $LOAD_PATH.map{|path| File.realpath(path) rescue path }.should.include? sitelibdir end end @@ -80,7 +80,7 @@ ar = RbConfig::CONFIG.fetch('AR') out = `#{ar} --version` $?.should.success? - out.should_not be_empty + out.should_not.empty? end it "['STRIP'] exists and can be executed" do diff --git a/spec/ruby/library/rbconfig/sizeof/limits_spec.rb b/spec/ruby/library/rbconfig/sizeof/limits_spec.rb index 776099da27c593..08b1185965bd0d 100644 --- a/spec/ruby/library/rbconfig/sizeof/limits_spec.rb +++ b/spec/ruby/library/rbconfig/sizeof/limits_spec.rb @@ -3,13 +3,13 @@ describe "RbConfig::LIMITS" do it "is a Hash" do - RbConfig::LIMITS.should be_kind_of(Hash) + RbConfig::LIMITS.should.is_a?(Hash) end it "has string keys and numeric values" do RbConfig::LIMITS.each do |key, value| - key.should be_kind_of String - value.should be_kind_of Numeric + key.should.is_a? String + value.should.is_a? Numeric end end diff --git a/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb b/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb index f2582dc4fd92f2..b74dae516681ca 100644 --- a/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb +++ b/spec/ruby/library/rbconfig/sizeof/sizeof_spec.rb @@ -3,13 +3,13 @@ describe "RbConfig::SIZEOF" do it "is a Hash" do - RbConfig::SIZEOF.should be_kind_of(Hash) + RbConfig::SIZEOF.should.is_a?(Hash) end it "has string keys and integer values" do RbConfig::SIZEOF.each do |key, value| - key.should be_kind_of String - value.should be_kind_of Integer + key.should.is_a? String + value.should.is_a? Integer end end diff --git a/spec/ruby/library/readline/basic_quote_characters_spec.rb b/spec/ruby/library/readline/basic_quote_characters_spec.rb index 216899d8750db2..f6467c8be4265f 100644 --- a/spec/ruby/library/readline/basic_quote_characters_spec.rb +++ b/spec/ruby/library/readline/basic_quote_characters_spec.rb @@ -4,7 +4,7 @@ with_feature :readline do describe "Readline.basic_quote_characters" do it "returns not nil" do - Readline.basic_quote_characters.should_not be_nil + Readline.basic_quote_characters.should_not == nil end end diff --git a/spec/ruby/library/readline/basic_word_break_characters_spec.rb b/spec/ruby/library/readline/basic_word_break_characters_spec.rb index daa0e1cb76053d..ef05d6560bc63b 100644 --- a/spec/ruby/library/readline/basic_word_break_characters_spec.rb +++ b/spec/ruby/library/readline/basic_word_break_characters_spec.rb @@ -3,7 +3,7 @@ with_feature :readline do describe "Readline.basic_word_break_characters" do it "returns not nil" do - Readline.basic_word_break_characters.should_not be_nil + Readline.basic_word_break_characters.should_not == nil end end diff --git a/spec/ruby/library/readline/completer_quote_characters_spec.rb b/spec/ruby/library/readline/completer_quote_characters_spec.rb index 86c58f3cf6818e..1109ea1f03e669 100644 --- a/spec/ruby/library/readline/completer_quote_characters_spec.rb +++ b/spec/ruby/library/readline/completer_quote_characters_spec.rb @@ -3,7 +3,7 @@ with_feature :readline do describe "Readline.completer_quote_characters" do it "returns nil" do - Readline.completer_quote_characters.should be_nil + Readline.completer_quote_characters.should == nil end end diff --git a/spec/ruby/library/readline/completer_word_break_characters_spec.rb b/spec/ruby/library/readline/completer_word_break_characters_spec.rb index c72f1135c4a478..91a002b9de517b 100644 --- a/spec/ruby/library/readline/completer_word_break_characters_spec.rb +++ b/spec/ruby/library/readline/completer_word_break_characters_spec.rb @@ -3,7 +3,7 @@ with_feature :readline do describe "Readline.completer_word_break_characters" do it "returns nil" do - Readline.completer_word_break_characters.should be_nil + Readline.completer_word_break_characters.should == nil end end diff --git a/spec/ruby/library/readline/completion_append_character_spec.rb b/spec/ruby/library/readline/completion_append_character_spec.rb index 615b523f4e640c..2a14d5d30e250d 100644 --- a/spec/ruby/library/readline/completion_append_character_spec.rb +++ b/spec/ruby/library/readline/completion_append_character_spec.rb @@ -3,7 +3,7 @@ with_feature :readline do describe "Readline.completion_append_character" do it "returns not nil" do - Readline.completion_append_character.should_not be_nil + Readline.completion_append_character.should_not == nil end end diff --git a/spec/ruby/library/readline/completion_case_fold_spec.rb b/spec/ruby/library/readline/completion_case_fold_spec.rb index 966f5d6c797761..b6a4aab101b523 100644 --- a/spec/ruby/library/readline/completion_case_fold_spec.rb +++ b/spec/ruby/library/readline/completion_case_fold_spec.rb @@ -3,7 +3,7 @@ with_feature :readline do describe "Readline.completion_case_fold" do it "returns nil" do - Readline.completion_case_fold.should be_nil + Readline.completion_case_fold.should == nil end end diff --git a/spec/ruby/library/readline/completion_proc_spec.rb b/spec/ruby/library/readline/completion_proc_spec.rb index 2d7a353ec52dbf..037fc6de21d52f 100644 --- a/spec/ruby/library/readline/completion_proc_spec.rb +++ b/spec/ruby/library/readline/completion_proc_spec.rb @@ -3,7 +3,7 @@ with_feature :readline do describe "Readline.completion_proc" do it "returns nil" do - Readline.completion_proc.should be_nil + Readline.completion_proc.should == nil end end @@ -16,7 +16,7 @@ end it "returns an ArgumentError if not given an Proc or #call" do - -> { Readline.completion_proc = "test" }.should raise_error(ArgumentError) + -> { Readline.completion_proc = "test" }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/library/readline/constants_spec.rb b/spec/ruby/library/readline/constants_spec.rb index 8fee2748665199..91536ce1cc4249 100644 --- a/spec/ruby/library/readline/constants_spec.rb +++ b/spec/ruby/library/readline/constants_spec.rb @@ -11,8 +11,8 @@ describe "Readline::VERSION" do it "is defined and is a non-empty String" do Readline.const_defined?(:VERSION).should == true - Readline::VERSION.should be_kind_of(String) - Readline::VERSION.should_not be_empty + Readline::VERSION.should.is_a?(String) + Readline::VERSION.should_not.empty? end end end diff --git a/spec/ruby/library/readline/emacs_editing_mode_spec.rb b/spec/ruby/library/readline/emacs_editing_mode_spec.rb index f7e8eda9828e3b..93ded3d023d621 100644 --- a/spec/ruby/library/readline/emacs_editing_mode_spec.rb +++ b/spec/ruby/library/readline/emacs_editing_mode_spec.rb @@ -4,7 +4,7 @@ with_feature :readline do describe "Readline.emacs_editing_mode" do it "returns nil" do - Readline.emacs_editing_mode.should be_nil + Readline.emacs_editing_mode.should == nil end end end diff --git a/spec/ruby/library/readline/filename_quote_characters_spec.rb b/spec/ruby/library/readline/filename_quote_characters_spec.rb index de8ce700a8fea7..6bcb04fc790fdb 100644 --- a/spec/ruby/library/readline/filename_quote_characters_spec.rb +++ b/spec/ruby/library/readline/filename_quote_characters_spec.rb @@ -4,7 +4,7 @@ with_feature :readline do describe "Readline.filename_quote_characters" do it "returns nil" do - Readline.filename_quote_characters.should be_nil + Readline.filename_quote_characters.should == nil end end diff --git a/spec/ruby/library/readline/history/append_spec.rb b/spec/ruby/library/readline/history/append_spec.rb index 53832713745806..be0e515b84df00 100644 --- a/spec/ruby/library/readline/history/append_spec.rb +++ b/spec/ruby/library/readline/history/append_spec.rb @@ -22,7 +22,7 @@ end it "raises a TypeError when the passed Object can't be converted to a String" do - -> { Readline::HISTORY << mock("Object") }.should raise_error(TypeError) + -> { Readline::HISTORY << mock("Object") }.should.raise(TypeError) 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 3bd577e75c8346..4383ff7e83e43d 100644 --- a/spec/ruby/library/readline/history/delete_at_spec.rb +++ b/spec/ruby/library/readline/history/delete_at_spec.rb @@ -31,8 +31,8 @@ end it "raises an IndexError when the given index is greater than the history size" do - -> { Readline::HISTORY.delete_at(10) }.should raise_error(IndexError) - -> { Readline::HISTORY.delete_at(-10) }.should raise_error(IndexError) + -> { Readline::HISTORY.delete_at(10) }.should.raise(IndexError) + -> { Readline::HISTORY.delete_at(-10) }.should.raise(IndexError) 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 0a74f3d62d733a..1f1642626f07f4 100644 --- a/spec/ruby/library/readline/history/element_reference_spec.rb +++ b/spec/ruby/library/readline/history/element_reference_spec.rb @@ -23,13 +23,13 @@ end it "raises an IndexError when there is no item at the passed index" do - -> { Readline::HISTORY[-10] }.should raise_error(IndexError) - -> { Readline::HISTORY[-9] }.should raise_error(IndexError) - -> { Readline::HISTORY[-8] }.should raise_error(IndexError) + -> { Readline::HISTORY[-10] }.should.raise(IndexError) + -> { Readline::HISTORY[-9] }.should.raise(IndexError) + -> { Readline::HISTORY[-8] }.should.raise(IndexError) - -> { Readline::HISTORY[8] }.should raise_error(IndexError) - -> { Readline::HISTORY[9] }.should raise_error(IndexError) - -> { Readline::HISTORY[10] }.should raise_error(IndexError) + -> { Readline::HISTORY[8] }.should.raise(IndexError) + -> { Readline::HISTORY[9] }.should.raise(IndexError) + -> { Readline::HISTORY[10] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/readline/history/element_set_spec.rb b/spec/ruby/library/readline/history/element_set_spec.rb index 776adaacd1e39f..0787b6343d6be3 100644 --- a/spec/ruby/library/readline/history/element_set_spec.rb +++ b/spec/ruby/library/readline/history/element_set_spec.rb @@ -17,7 +17,7 @@ end it "raises an IndexError when there is no item at the passed positive index" do - -> { Readline::HISTORY[10] = "test" }.should raise_error(IndexError) + -> { Readline::HISTORY[10] = "test" }.should.raise(IndexError) end it "sets the item at the given index" do @@ -29,7 +29,7 @@ end it "raises an IndexError when there is no item at the passed negative index" do - -> { Readline::HISTORY[10] = "test" }.should raise_error(IndexError) + -> { Readline::HISTORY[10] = "test" }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/readline/history/empty_spec.rb b/spec/ruby/library/readline/history/empty_spec.rb index 31d01d96018d58..5b722dccd346c5 100644 --- a/spec/ruby/library/readline/history/empty_spec.rb +++ b/spec/ruby/library/readline/history/empty_spec.rb @@ -3,11 +3,11 @@ with_feature :readline do describe "Readline::HISTORY.empty?" do it "returns true when the history is empty" do - Readline::HISTORY.should be_empty + Readline::HISTORY.should.empty? Readline::HISTORY.push("test") - Readline::HISTORY.should_not be_empty + Readline::HISTORY.should_not.empty? Readline::HISTORY.pop - Readline::HISTORY.should be_empty + Readline::HISTORY.should.empty? end end end diff --git a/spec/ruby/library/readline/history/history_spec.rb b/spec/ruby/library/readline/history/history_spec.rb index 927dd52ebfa2ec..3233071033fd3d 100644 --- a/spec/ruby/library/readline/history/history_spec.rb +++ b/spec/ruby/library/readline/history/history_spec.rb @@ -3,7 +3,7 @@ with_feature :readline do describe "Readline::HISTORY" do it "is extended with the Enumerable module" do - Readline::HISTORY.should be_kind_of(Enumerable) + Readline::HISTORY.should.is_a?(Enumerable) end end end diff --git a/spec/ruby/library/readline/history/pop_spec.rb b/spec/ruby/library/readline/history/pop_spec.rb index 156a8a06f8564f..0b780a38ccf15f 100644 --- a/spec/ruby/library/readline/history/pop_spec.rb +++ b/spec/ruby/library/readline/history/pop_spec.rb @@ -3,7 +3,7 @@ with_feature :readline do describe "Readline::HISTORY.pop" do it "returns nil when the history is empty" do - Readline::HISTORY.pop.should be_nil + Readline::HISTORY.pop.should == nil end it "returns and removes the last item from the history" do diff --git a/spec/ruby/library/readline/history/push_spec.rb b/spec/ruby/library/readline/history/push_spec.rb index 53505ccba6754d..4bbf1763a14e3a 100644 --- a/spec/ruby/library/readline/history/push_spec.rb +++ b/spec/ruby/library/readline/history/push_spec.rb @@ -20,7 +20,7 @@ end it "raises a TypeError when the passed Object can't be converted to a String" do - -> { Readline::HISTORY.push(mock("Object")) }.should raise_error(TypeError) + -> { Readline::HISTORY.push(mock("Object")) }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/readline/history/shift_spec.rb b/spec/ruby/library/readline/history/shift_spec.rb index 9aad7d53993854..d852480a2a3a0e 100644 --- a/spec/ruby/library/readline/history/shift_spec.rb +++ b/spec/ruby/library/readline/history/shift_spec.rb @@ -3,7 +3,7 @@ with_feature :readline do describe "Readline::HISTORY.shift" do it "returns nil when the history is empty" do - Readline::HISTORY.shift.should be_nil + Readline::HISTORY.shift.should == nil end it "returns and removes the first item from the history" do diff --git a/spec/ruby/library/readline/vi_editing_mode_spec.rb b/spec/ruby/library/readline/vi_editing_mode_spec.rb index 6622962cebbdf2..3ce4f5a7e6f99e 100644 --- a/spec/ruby/library/readline/vi_editing_mode_spec.rb +++ b/spec/ruby/library/readline/vi_editing_mode_spec.rb @@ -4,7 +4,7 @@ with_feature :readline do describe "Readline.vi_editing_mode" do it "returns nil" do - Readline.vi_editing_mode.should be_nil + Readline.vi_editing_mode.should == nil end end end diff --git a/spec/ruby/library/resolv/get_address_spec.rb b/spec/ruby/library/resolv/get_address_spec.rb index ecc2cdf7de2df6..9caa94643a3e9e 100644 --- a/spec/ruby/library/resolv/get_address_spec.rb +++ b/spec/ruby/library/resolv/get_address_spec.rb @@ -14,6 +14,6 @@ res = Resolv.new([]) -> { res.getaddress("should.raise.error.") - }.should raise_error(Resolv::ResolvError) + }.should.raise(Resolv::ResolvError) end end diff --git a/spec/ruby/library/resolv/get_name_spec.rb b/spec/ruby/library/resolv/get_name_spec.rb index 3ef97a2ceaf48d..81e0cda28d145a 100644 --- a/spec/ruby/library/resolv/get_name_spec.rb +++ b/spec/ruby/library/resolv/get_name_spec.rb @@ -13,6 +13,6 @@ res = Resolv.new([]) -> { res.getname("should.raise.error") - }.should raise_error(Resolv::ResolvError) + }.should.raise(Resolv::ResolvError) 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 index 9b37eaa43cdf9a..693c72a29ed298 100644 --- a/spec/ruby/library/rubygems/gem/load_path_insert_index_spec.rb +++ b/spec/ruby/library/rubygems/gem/load_path_insert_index_spec.rb @@ -4,7 +4,7 @@ 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 + Gem.load_path_insert_index.should.is_a? Integer end end end diff --git a/spec/ruby/library/securerandom/base64_spec.rb b/spec/ruby/library/securerandom/base64_spec.rb index 34cd419ce25388..49d4b8a0298748 100644 --- a/spec/ruby/library/securerandom/base64_spec.rb +++ b/spec/ruby/library/securerandom/base64_spec.rb @@ -6,13 +6,13 @@ it "generates a random base64 string out of specified number of random bytes" do (16..128).each do |idx| base64 = SecureRandom.base64(idx) - base64.should be_kind_of(String) + base64.should.is_a?(String) base64.length.should < 2 * idx base64.should =~ /^[A-Za-z0-9\+\/]+={0,2}$/ end base64 = SecureRandom.base64(16.5) - base64.should be_kind_of(String) + base64.should.is_a?(String) base64.length.should < 2 * 16 end @@ -32,19 +32,19 @@ end it "generates a random base64 string out of 32 random bytes" do - SecureRandom.base64.should be_kind_of(String) + SecureRandom.base64.should.is_a?(String) SecureRandom.base64.length.should < 32 * 2 end it "treats nil argument as default one and generates a random base64 string" do - SecureRandom.base64(nil).should be_kind_of(String) + SecureRandom.base64(nil).should.is_a?(String) SecureRandom.base64(nil).length.should < 32 * 2 end it "raises ArgumentError on negative arguments" do -> { SecureRandom.base64(-1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "tries to convert the passed argument to an Integer using #to_int" do diff --git a/spec/ruby/library/securerandom/hex_spec.rb b/spec/ruby/library/securerandom/hex_spec.rb index bdb920b2173d18..ec33aca1ee831b 100644 --- a/spec/ruby/library/securerandom/hex_spec.rb +++ b/spec/ruby/library/securerandom/hex_spec.rb @@ -6,13 +6,13 @@ it "generates a random hex string of length twice the specified argument" do (1..64).each do |idx| hex = SecureRandom.hex(idx) - hex.should be_kind_of(String) + hex.should.is_a?(String) hex.length.should == 2 * idx end base64 = SecureRandom.hex(5.5) - base64.should be_kind_of(String) - base64.length.should eql(10) + base64.should.is_a?(String) + base64.length.should.eql?(10) end it "returns an empty string when argument is 0" do @@ -31,24 +31,24 @@ end it "generates a random hex string of length 32 if no argument is provided" do - SecureRandom.hex.should be_kind_of(String) + SecureRandom.hex.should.is_a?(String) SecureRandom.hex.length.should == 32 end it "treats nil argument as default one and generates a random hex string of length 32" do - SecureRandom.hex(nil).should be_kind_of(String) + SecureRandom.hex(nil).should.is_a?(String) SecureRandom.hex(nil).length.should == 32 end it "raises ArgumentError on negative arguments" do -> { SecureRandom.hex(-1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "tries to convert the passed argument to an Integer using #to_int" do obj = mock("to_int") obj.should_receive(:to_int).and_return(5) - SecureRandom.hex(obj).size.should eql(10) + SecureRandom.hex(obj).size.should.eql?(10) end end diff --git a/spec/ruby/library/securerandom/random_bytes_spec.rb b/spec/ruby/library/securerandom/random_bytes_spec.rb index ed3a02255ca8b2..4e30a531632c9c 100644 --- a/spec/ruby/library/securerandom/random_bytes_spec.rb +++ b/spec/ruby/library/securerandom/random_bytes_spec.rb @@ -8,24 +8,24 @@ it "generates a random binary string of length 16 if no argument is provided" do bytes = SecureRandom.random_bytes - bytes.should be_kind_of(String) + bytes.should.is_a?(String) bytes.length.should == 16 end it "generates a random binary string of length 16 if argument is nil" do bytes = SecureRandom.random_bytes(nil) - bytes.should be_kind_of(String) + bytes.should.is_a?(String) bytes.length.should == 16 end it "generates a random binary string of specified length" do (1..64).each do |idx| bytes = SecureRandom.random_bytes(idx) - bytes.should be_kind_of(String) + bytes.should.is_a?(String) bytes.length.should == idx end - SecureRandom.random_bytes(2.2).length.should eql(2) + SecureRandom.random_bytes(2.2).length.should.eql?(2) end it "generates different binary strings with subsequent invocations" do @@ -42,12 +42,12 @@ it "raises ArgumentError on negative arguments" do -> { SecureRandom.random_bytes(-1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "tries to convert the passed argument to an Integer using #to_int" do obj = mock("to_int") obj.should_receive(:to_int).and_return(5) - SecureRandom.random_bytes(obj).size.should eql(5) + SecureRandom.random_bytes(obj).size.should.eql?(5) end end diff --git a/spec/ruby/library/securerandom/random_number_spec.rb b/spec/ruby/library/securerandom/random_number_spec.rb index bb25bc496ed901..97cd66f7bc927d 100644 --- a/spec/ruby/library/securerandom/random_number_spec.rb +++ b/spec/ruby/library/securerandom/random_number_spec.rb @@ -10,7 +10,7 @@ it "generates a random positive number smaller then the positive integer argument" do (1..64).each do |idx| num = SecureRandom.random_number(idx) - num.should be_kind_of(Integer) + num.should.is_a?(Integer) 0.should <= num num.should < idx end @@ -20,7 +20,7 @@ max = 12345678901234567890 11.times do num = SecureRandom.random_number max - num.should be_kind_of(Integer) + num.should.is_a?(Integer) 0.should <= num num.should < max end @@ -29,7 +29,7 @@ it "generates a random float number between 0.0 and 1.0 if no argument provided" do 64.times do num = SecureRandom.random_number - num.should be_kind_of(Float) + num.should.is_a?(Float) 0.0.should <= num num.should < 1.0 end @@ -38,7 +38,7 @@ it "generates a random value in given (integer) range limits" do 64.times do num = SecureRandom.random_number 11...13 - num.should be_kind_of(Integer) + num.should.is_a?(Integer) 11.should <= num num.should < 13 end @@ -49,7 +49,7 @@ upper = 12345678901234567890 + 5 32.times do num = SecureRandom.random_number lower..upper - num.should be_kind_of(Integer) + num.should.is_a?(Integer) lower.should <= num num.should <= upper end @@ -58,7 +58,7 @@ it "generates a random value in given (float) range limits" do 64.times do num = SecureRandom.random_number 0.6..0.9 - num.should be_kind_of(Float) + num.should.is_a?(Float) 0.6.should <= num num.should <= 0.9 end @@ -66,14 +66,14 @@ it "generates a random float number between 0.0 and 1.0 if argument is negative" do num = SecureRandom.random_number(-10) - num.should be_kind_of(Float) + num.should.is_a?(Float) 0.0.should <= num num.should < 1.0 end it "generates a random float number between 0.0 and 1.0 if argument is negative float" do num = SecureRandom.random_number(-11.1) - num.should be_kind_of(Float) + num.should.is_a?(Float) 0.0.should <= num num.should < 1.0 end @@ -84,7 +84,7 @@ 256.times do val = SecureRandom.random_number # make sure the random values are not repeating - values.should_not include(val) + values.should_not.include?(val) values << val end end @@ -92,6 +92,6 @@ it "raises ArgumentError if the argument is non-numeric" do -> { SecureRandom.random_number(Object.new) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/shellwords/shellwords_spec.rb b/spec/ruby/library/shellwords/shellwords_spec.rb index fe86b6faab0db8..d1b61e0a6eb211 100644 --- a/spec/ruby/library/shellwords/shellwords_spec.rb +++ b/spec/ruby/library/shellwords/shellwords_spec.rb @@ -19,11 +19,11 @@ end it "raises ArgumentError when double quoted strings are misquoted" do - -> { Shellwords.shellwords('a "b c d e') }.should raise_error(ArgumentError) + -> { Shellwords.shellwords('a "b c d e') }.should.raise(ArgumentError) end it "raises ArgumentError when single quoted strings are misquoted" do - -> { Shellwords.shellwords("a 'b c d e") }.should raise_error(ArgumentError) + -> { Shellwords.shellwords("a 'b c d e") }.should.raise(ArgumentError) end # https://bugs.ruby-lang.org/issues/10055 diff --git a/spec/ruby/library/singleton/allocate_spec.rb b/spec/ruby/library/singleton/allocate_spec.rb index 6a1512d53b99c6..a0094fb32abd79 100644 --- a/spec/ruby/library/singleton/allocate_spec.rb +++ b/spec/ruby/library/singleton/allocate_spec.rb @@ -3,6 +3,6 @@ describe "Singleton.allocate" do it "is a private method" do - -> { SingletonSpecs::MyClass.allocate }.should raise_error(NoMethodError) + -> { SingletonSpecs::MyClass.allocate }.should.raise(NoMethodError) end end diff --git a/spec/ruby/library/singleton/clone_spec.rb b/spec/ruby/library/singleton/clone_spec.rb index 3635bcd5947e07..a7b7b731f5e612 100644 --- a/spec/ruby/library/singleton/clone_spec.rb +++ b/spec/ruby/library/singleton/clone_spec.rb @@ -3,6 +3,6 @@ describe "Singleton#clone" do it "is prevented" do - -> { SingletonSpecs::MyClass.instance.clone }.should raise_error(TypeError) + -> { SingletonSpecs::MyClass.instance.clone }.should.raise(TypeError) end end diff --git a/spec/ruby/library/singleton/dup_spec.rb b/spec/ruby/library/singleton/dup_spec.rb index 13d5a213e9f842..a0455f37b76a99 100644 --- a/spec/ruby/library/singleton/dup_spec.rb +++ b/spec/ruby/library/singleton/dup_spec.rb @@ -3,6 +3,6 @@ describe "Singleton#dup" do it "is prevented" do - -> { SingletonSpecs::MyClass.instance.dup }.should raise_error(TypeError) + -> { SingletonSpecs::MyClass.instance.dup }.should.raise(TypeError) end end diff --git a/spec/ruby/library/singleton/instance_spec.rb b/spec/ruby/library/singleton/instance_spec.rb index 1679728d4cdb88..20cac602b54ff5 100644 --- a/spec/ruby/library/singleton/instance_spec.rb +++ b/spec/ruby/library/singleton/instance_spec.rb @@ -3,28 +3,28 @@ describe "Singleton.instance" do it "returns an instance of the singleton class" do - SingletonSpecs::MyClass.instance.should be_kind_of(SingletonSpecs::MyClass) + SingletonSpecs::MyClass.instance.should.is_a?(SingletonSpecs::MyClass) end it "returns the same instance for multiple calls to instance" do - SingletonSpecs::MyClass.instance.should equal(SingletonSpecs::MyClass.instance) + SingletonSpecs::MyClass.instance.should.equal?(SingletonSpecs::MyClass.instance) end it "returns an instance of the singleton's subclasses" do - SingletonSpecs::MyClassChild.instance.should be_kind_of(SingletonSpecs::MyClassChild) + SingletonSpecs::MyClassChild.instance.should.is_a?(SingletonSpecs::MyClassChild) end it "returns the same instance for multiple class to instance on subclasses" do - SingletonSpecs::MyClassChild.instance.should equal(SingletonSpecs::MyClassChild.instance) + SingletonSpecs::MyClassChild.instance.should.equal?(SingletonSpecs::MyClassChild.instance) end it "returns an instance of the singleton's clone" do klone = SingletonSpecs::MyClassChild.clone - klone.instance.should be_kind_of(klone) + klone.instance.should.is_a?(klone) end it "returns the same instance for multiple class to instance on clones" do klone = SingletonSpecs::MyClassChild.clone - klone.instance.should equal(klone.instance) + klone.instance.should.equal?(klone.instance) end end diff --git a/spec/ruby/library/singleton/load_spec.rb b/spec/ruby/library/singleton/load_spec.rb index 4c753f9e7a49d8..ab95d14640fd27 100644 --- a/spec/ruby/library/singleton/load_spec.rb +++ b/spec/ruby/library/singleton/load_spec.rb @@ -1,21 +1,20 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' -# TODO: change to a.should be_equal(b) # TODO: write spec for cloning classes and calling private methods # TODO: write spec for private_methods not showing up via extended describe "Singleton._load" do it "returns the singleton instance for anything passed in" do klass = SingletonSpecs::MyClass - klass._load("").should equal(klass.instance) - klass._load("42").should equal(klass.instance) - klass._load(42).should equal(klass.instance) + klass._load("").should.equal?(klass.instance) + klass._load("42").should.equal?(klass.instance) + klass._load(42).should.equal?(klass.instance) end it "returns the singleton instance for anything passed in to subclass" do subklass = SingletonSpecs::MyClassChild - subklass._load("").should equal(subklass.instance) - subklass._load("42").should equal(subklass.instance) - subklass._load(42).should equal(subklass.instance) + subklass._load("").should.equal?(subklass.instance) + subklass._load("42").should.equal?(subklass.instance) + subklass._load(42).should.equal?(subklass.instance) end end diff --git a/spec/ruby/library/singleton/new_spec.rb b/spec/ruby/library/singleton/new_spec.rb index 2f45db819cef1d..6167231a297e36 100644 --- a/spec/ruby/library/singleton/new_spec.rb +++ b/spec/ruby/library/singleton/new_spec.rb @@ -3,6 +3,6 @@ describe "Singleton.new" do it "is a private method" do - -> { SingletonSpecs::NewSpec.new }.should raise_error(NoMethodError) + -> { SingletonSpecs::NewSpec.new }.should.raise(NoMethodError) end end diff --git a/spec/ruby/library/socket/addrinfo/bind_spec.rb b/spec/ruby/library/socket/addrinfo/bind_spec.rb index 6f78890a4d2e66..cdd187771fdf78 100644 --- a/spec/ruby/library/socket/addrinfo/bind_spec.rb +++ b/spec/ruby/library/socket/addrinfo/bind_spec.rb @@ -13,16 +13,16 @@ it "returns a bound socket when no block is given" do @socket = @addrinfo.bind - @socket.should be_kind_of(Socket) - @socket.closed?.should be_false + @socket.should.is_a?(Socket) + @socket.closed?.should == false end it "yields the socket if a block is given" do @addrinfo.bind do |sock| @socket = sock - sock.should be_kind_of(Socket) + sock.should.is_a?(Socket) end - @socket.closed?.should be_true + @socket.closed?.should == true end end diff --git a/spec/ruby/library/socket/addrinfo/canonname_spec.rb b/spec/ruby/library/socket/addrinfo/canonname_spec.rb index a1cc8b39802230..efd3147125d07c 100644 --- a/spec/ruby/library/socket/addrinfo/canonname_spec.rb +++ b/spec/ruby/library/socket/addrinfo/canonname_spec.rb @@ -10,7 +10,7 @@ it "returns the canonical name for a host" do canonname = @addrinfos.map { |a| a.canonname }.find { |name| name and name.include?("localhost") } if canonname - canonname.should include("localhost") + canonname.should.include?("localhost") else canonname.should == nil end @@ -20,7 +20,7 @@ it 'returns nil' do addr = Addrinfo.new(Socket.sockaddr_in(0, '127.0.0.1')) - addr.canonname.should be_nil + addr.canonname.should == nil end end diff --git a/spec/ruby/library/socket/addrinfo/connect_from_spec.rb b/spec/ruby/library/socket/addrinfo/connect_from_spec.rb index 55fce2e1595aec..b1f6caa174e0a9 100644 --- a/spec/ruby/library/socket/addrinfo/connect_from_spec.rb +++ b/spec/ruby/library/socket/addrinfo/connect_from_spec.rb @@ -17,18 +17,18 @@ describe 'using separate arguments' do it 'returns a Socket when no block is given' do @socket = @addr.connect_from(ip_address, 0) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'yields the Socket when a block is given' do @addr.connect_from(ip_address, 0) do |socket| - socket.should be_an_instance_of(Socket) + socket.should.instance_of?(Socket) end end it 'treats the last argument as a set of options if it is a Hash' do @socket = @addr.connect_from(ip_address, 0, timeout: 2) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'binds the socket to the local address' do @@ -48,18 +48,18 @@ it 'returns a Socket when no block is given' do @socket = @addr.connect_from(@from_addr) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'yields the Socket when a block is given' do @addr.connect_from(@from_addr) do |socket| - socket.should be_an_instance_of(Socket) + socket.should.instance_of?(Socket) end end it 'treats the last argument as a set of options if it is a Hash' do @socket = @addr.connect_from(@from_addr, timeout: 2) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'binds the socket to the local address' do diff --git a/spec/ruby/library/socket/addrinfo/connect_spec.rb b/spec/ruby/library/socket/addrinfo/connect_spec.rb index 1c2dc609ca2992..a8494b5501eda2 100644 --- a/spec/ruby/library/socket/addrinfo/connect_spec.rb +++ b/spec/ruby/library/socket/addrinfo/connect_spec.rb @@ -16,20 +16,20 @@ it 'returns a Socket when no block is given' do addr = Addrinfo.tcp(ip_address, @port) @socket = addr.connect - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'yields a Socket when a block is given' do addr = Addrinfo.tcp(ip_address, @port) addr.connect do |socket| - socket.should be_an_instance_of(Socket) + socket.should.instance_of?(Socket) end end it 'accepts a Hash of options' do addr = Addrinfo.tcp(ip_address, @port) @socket = addr.connect(timeout: 2) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end end end diff --git a/spec/ruby/library/socket/addrinfo/connect_to_spec.rb b/spec/ruby/library/socket/addrinfo/connect_to_spec.rb index 69666da19b52a5..2bf49a38e8baa0 100644 --- a/spec/ruby/library/socket/addrinfo/connect_to_spec.rb +++ b/spec/ruby/library/socket/addrinfo/connect_to_spec.rb @@ -17,18 +17,18 @@ describe 'using separate arguments' do it 'returns a Socket when no block is given' do @socket = @addr.connect_to(ip_address, @port) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'yields the Socket when a block is given' do @addr.connect_to(ip_address, @port) do |socket| - socket.should be_an_instance_of(Socket) + socket.should.instance_of?(Socket) end end it 'treats the last argument as a set of options if it is a Hash' do @socket = @addr.connect_to(ip_address, @port, timeout: 2) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'binds the Addrinfo to the local address' do @@ -48,18 +48,18 @@ it 'returns a Socket when no block is given' do @socket = @addr.connect_to(@to_addr) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'yields the Socket when a block is given' do @addr.connect_to(@to_addr) do |socket| - socket.should be_an_instance_of(Socket) + socket.should.instance_of?(Socket) end end it 'treats the last argument as a set of options if it is a Hash' do @socket = @addr.connect_to(@to_addr, timeout: 2) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'binds the socket to the local address' do diff --git a/spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb b/spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb index 3c2f9f73d8a0a9..38834ade917836 100644 --- a/spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb +++ b/spec/ruby/library/socket/addrinfo/family_addrinfo_spec.rb @@ -4,7 +4,7 @@ it 'raises ArgumentError if no arguments are given' do addr = Addrinfo.tcp('127.0.0.1', 0) - -> { addr.family_addrinfo }.should raise_error(ArgumentError) + -> { addr.family_addrinfo }.should.raise(ArgumentError) end describe 'using multiple arguments' do @@ -14,17 +14,17 @@ end it 'raises ArgumentError if only 1 argument is given' do - -> { @source.family_addrinfo('127.0.0.1') }.should raise_error(ArgumentError) + -> { @source.family_addrinfo('127.0.0.1') }.should.raise(ArgumentError) end it 'raises ArgumentError if more than 2 arguments are given' do - -> { @source.family_addrinfo('127.0.0.1', 0, 666) }.should raise_error(ArgumentError) + -> { @source.family_addrinfo('127.0.0.1', 0, 666) }.should.raise(ArgumentError) end it 'returns an Addrinfo when a host and port are given' do addr = @source.family_addrinfo('127.0.0.1', 0) - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do @@ -56,13 +56,13 @@ end it 'raises ArgumentError if more than 1 argument is given' do - -> { @source.family_addrinfo('foo', 'bar') }.should raise_error(ArgumentError) + -> { @source.family_addrinfo('foo', 'bar') }.should.raise(ArgumentError) end it 'returns an Addrinfo when a UNIX socket path is given' do addr = @source.family_addrinfo('dogs') - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do @@ -97,17 +97,17 @@ it 'raises ArgumentError if more than 1 argument is given' do input = Addrinfo.tcp('127.0.0.2', 0) - -> { @source.family_addrinfo(input, 666) }.should raise_error(ArgumentError) + -> { @source.family_addrinfo(input, 666) }.should.raise(ArgumentError) end it "raises ArgumentError if the protocol families don't match" do input = Addrinfo.tcp('::1', 0) - -> { @source.family_addrinfo(input) }.should raise_error(ArgumentError) + -> { @source.family_addrinfo(input) }.should.raise(ArgumentError) end it "raises ArgumentError if the socket types don't match" do input = Addrinfo.udp('127.0.0.1', 0) - -> { @source.family_addrinfo(input) }.should raise_error(ArgumentError) + -> { @source.family_addrinfo(input) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/library/socket/addrinfo/foreach_spec.rb b/spec/ruby/library/socket/addrinfo/foreach_spec.rb index 6ec8fab905040c..8cbbddb8f0a4e0 100644 --- a/spec/ruby/library/socket/addrinfo/foreach_spec.rb +++ b/spec/ruby/library/socket/addrinfo/foreach_spec.rb @@ -3,7 +3,7 @@ describe 'Addrinfo.foreach' do it 'yields Addrinfo instances to the supplied block' do Addrinfo.foreach('127.0.0.1', 80) do |addr| - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) end end end diff --git a/spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb b/spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb index e05fe9967ad5f4..47393ee1678fba 100644 --- a/spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb +++ b/spec/ruby/library/socket/addrinfo/getaddrinfo_spec.rb @@ -5,8 +5,8 @@ it 'returns an Array of Addrinfo instances' do array = Addrinfo.getaddrinfo('127.0.0.1', 80) - array.should be_an_instance_of(Array) - array[0].should be_an_instance_of(Addrinfo) + array.should.instance_of?(Array) + array[0].should.instance_of?(Addrinfo) end SocketSpecs.each_ip_protocol do |family, ip_address| @@ -54,7 +54,7 @@ array = Addrinfo.getaddrinfo('127.0.0.1', 80) possible = [Socket::SOCK_STREAM, Socket::SOCK_DGRAM] - possible.should include(array[0].socktype) + possible.should.include?(array[0].socktype) end end @@ -69,7 +69,7 @@ array = Addrinfo.getaddrinfo('127.0.0.1', 80) possible = [Socket::IPPROTO_TCP, Socket::IPPROTO_UDP] - possible.should include(array[0].protocol) + possible.should.include?(array[0].protocol) end end @@ -82,6 +82,6 @@ it 'sets the canonical name when AI_CANONNAME is given as a flag' do array = Addrinfo.getaddrinfo('localhost', 80, nil, nil, nil, Socket::AI_CANONNAME) - array[0].canonname.should be_an_instance_of(String) + array[0].canonname.should.instance_of?(String) end end diff --git a/spec/ruby/library/socket/addrinfo/initialize_spec.rb b/spec/ruby/library/socket/addrinfo/initialize_spec.rb index 931984b6515b43..f33255e38be310 100644 --- a/spec/ruby/library/socket/addrinfo/initialize_spec.rb +++ b/spec/ruby/library/socket/addrinfo/initialize_spec.rb @@ -200,7 +200,7 @@ it 'raises SocketError' do block = -> { Addrinfo.new(['AF_INET6', 80, 'hostname', '127.0.0.1']) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end @@ -294,7 +294,7 @@ value = Socket::SOCK_RDM block = -> { Addrinfo.new(sockaddr, nil, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end @@ -340,7 +340,7 @@ value = Socket.const_get(constant) -> { Addrinfo.new(@sockaddr, value) - }.should raise_error(SocketError) + }.should.raise(SocketError) end end end @@ -368,7 +368,7 @@ value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, nil, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end @@ -396,7 +396,7 @@ value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end @@ -413,7 +413,7 @@ value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end @@ -444,7 +444,7 @@ value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end @@ -472,7 +472,7 @@ value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end @@ -501,7 +501,7 @@ value = Socket.const_get(type) block = -> { Addrinfo.new(@sockaddr, nil, @socktype, value) } - block.should raise_error(SocketError) + block.should.raise(SocketError) end end end diff --git a/spec/ruby/library/socket/addrinfo/ip_address_spec.rb b/spec/ruby/library/socket/addrinfo/ip_address_spec.rb index 193432e861cf0f..9a0ede4eebb2d0 100644 --- a/spec/ruby/library/socket/addrinfo/ip_address_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ip_address_spec.rb @@ -27,7 +27,7 @@ end it "raises an exception" do - -> { @addrinfo.ip_address }.should raise_error(SocketError) + -> { @addrinfo.ip_address }.should.raise(SocketError) end end diff --git a/spec/ruby/library/socket/addrinfo/ip_port_spec.rb b/spec/ruby/library/socket/addrinfo/ip_port_spec.rb index f10ce35143d822..00f74cdd467cb3 100644 --- a/spec/ruby/library/socket/addrinfo/ip_port_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ip_port_spec.rb @@ -27,7 +27,7 @@ end it "raises an exception" do - -> { @addrinfo.ip_port }.should raise_error(SocketError) + -> { @addrinfo.ip_port }.should.raise(SocketError) end end end diff --git a/spec/ruby/library/socket/addrinfo/ip_spec.rb b/spec/ruby/library/socket/addrinfo/ip_spec.rb index 09b93416055933..2237eca263f850 100644 --- a/spec/ruby/library/socket/addrinfo/ip_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ip_spec.rb @@ -8,7 +8,7 @@ end it "returns true" do - @addrinfo.ip?.should be_true + @addrinfo.ip?.should == true end end @@ -18,7 +18,7 @@ end it "returns true" do - @addrinfo.ip?.should be_true + @addrinfo.ip?.should == true end end @@ -28,7 +28,7 @@ end it "returns false" do - @addrinfo.ip?.should be_false + @addrinfo.ip?.should == false end end end @@ -36,7 +36,7 @@ describe 'Addrinfo.ip' do SocketSpecs.each_ip_protocol do |family, ip_address| it 'returns an Addrinfo instance' do - Addrinfo.ip(ip_address).should be_an_instance_of(Addrinfo) + Addrinfo.ip(ip_address).should.instance_of?(Addrinfo) end it 'sets the IP address' do diff --git a/spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb b/spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb index 58260c45578972..b48ca062eee406 100644 --- a/spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb @@ -27,7 +27,7 @@ end it "raises an exception" do - -> { @addrinfo.ip_unpack }.should raise_error(SocketError) + -> { @addrinfo.ip_unpack }.should.raise(SocketError) end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb index 3a584d4f52fbcd..266281ce7ad565 100644 --- a/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb @@ -10,7 +10,7 @@ end it "returns false for another address" do - Addrinfo.ip('255.255.255.0').ipv4_loopback?.should be_false + Addrinfo.ip('255.255.255.0').ipv4_loopback?.should == false end end @@ -21,11 +21,11 @@ end it "returns false for the loopback address" do - @loopback.ipv4_loopback?.should be_false + @loopback.ipv4_loopback?.should == false end it "returns false for another address" do - @other.ipv4_loopback?.should be_false + @other.ipv4_loopback?.should == false end end @@ -35,7 +35,7 @@ end it "returns false" do - @addrinfo.ipv4_loopback?.should be_false + @addrinfo.ipv4_loopback?.should == false end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb index e4b4cfcc84a773..bc8a31dfa8c41b 100644 --- a/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb @@ -21,7 +21,7 @@ end it "returns false" do - @addrinfo.ipv4_multicast?.should be_false + @addrinfo.ipv4_multicast?.should == false end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb index 97218b5ba327dd..8cfbf0a25e40ab 100644 --- a/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb @@ -19,7 +19,7 @@ end it "returns false for a public address" do - @other.ipv4_private?.should be_false + @other.ipv4_private?.should == false end end @@ -29,7 +29,7 @@ end it "returns false" do - @other.ipv4_private?.should be_false + @other.ipv4_private?.should == false end end @@ -39,7 +39,7 @@ end it "returns false" do - @addrinfo.ipv4_private?.should be_false + @addrinfo.ipv4_private?.should == false end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv4_spec.rb b/spec/ruby/library/socket/addrinfo/ipv4_spec.rb index 61f7759b108952..8fef94a8e82daf 100644 --- a/spec/ruby/library/socket/addrinfo/ipv4_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv4_spec.rb @@ -7,7 +7,7 @@ end it "returns true" do - @addrinfo.ipv4?.should be_true + @addrinfo.ipv4?.should == true end end @@ -17,7 +17,7 @@ end it "returns false" do - @addrinfo.ipv4?.should be_false + @addrinfo.ipv4?.should == false end end @@ -27,7 +27,7 @@ end it "returns false" do - @addrinfo.ipv4?.should be_false + @addrinfo.ipv4?.should == false end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb index ffc75185ead603..2e8241e3368c9a 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb @@ -8,11 +8,11 @@ end it "returns false for the loopback address" do - @loopback.ipv6_loopback?.should be_false + @loopback.ipv6_loopback?.should == false end it "returns false for another address" do - @other.ipv6_loopback?.should be_false + @other.ipv6_loopback?.should == false end end @@ -23,11 +23,11 @@ end it "returns true for the loopback address" do - @loopback.ipv6_loopback?.should be_true + @loopback.ipv6_loopback?.should == true end it "returns false for another address" do - @other.ipv6_loopback?.should be_false + @other.ipv6_loopback?.should == false end end @@ -37,7 +37,7 @@ end it "returns false" do - @addrinfo.ipv6_loopback?.should be_false + @addrinfo.ipv6_loopback?.should == false end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb index 99d4e8cf4d8577..52787e5e5311e5 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb @@ -8,11 +8,11 @@ end it "returns true for a multicast address" do - @multicast.ipv6_multicast?.should be_false + @multicast.ipv6_multicast?.should == false end it "returns false for another address" do - @other.ipv6_multicast?.should be_false + @other.ipv6_multicast?.should == false end end @@ -40,7 +40,7 @@ end it "returns false" do - @addrinfo.ipv6_multicast?.should be_false + @addrinfo.ipv6_multicast?.should == false end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_spec.rb index 436d5e930b415e..9fa8e9bd0c241b 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_spec.rb @@ -7,7 +7,7 @@ end it "returns true" do - @addrinfo.ipv6?.should be_false + @addrinfo.ipv6?.should == false end end @@ -17,7 +17,7 @@ end it "returns false" do - @addrinfo.ipv6?.should be_true + @addrinfo.ipv6?.should == true end end @@ -27,7 +27,7 @@ end it "returns false" do - @addrinfo.ipv6?.should be_false + @addrinfo.ipv6?.should == false end end end diff --git a/spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb b/spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb index 29050bec20e9cd..d1436d45270a75 100644 --- a/spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb +++ b/spec/ruby/library/socket/addrinfo/ipv6_to_ipv4_spec.rb @@ -6,7 +6,7 @@ it 'returns an Addrinfo for ::192.168.1.1' do addr = Addrinfo.ip('::192.168.1.1').ipv6_to_ipv4 - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) addr.afamily.should == Socket::AF_INET addr.ip_address.should == '192.168.1.1' @@ -16,7 +16,7 @@ it 'returns an Addrinfo for ::0.0.1.1' do addr = Addrinfo.ip('::0.0.1.1').ipv6_to_ipv4 - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) addr.afamily.should == Socket::AF_INET addr.ip_address.should == '0.0.1.1' @@ -25,7 +25,7 @@ it 'returns an Addrinfo for ::0.0.1.0' do addr = Addrinfo.ip('::0.0.1.0').ipv6_to_ipv4 - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) addr.afamily.should == Socket::AF_INET addr.ip_address.should == '0.0.1.0' @@ -34,7 +34,7 @@ it 'returns an Addrinfo for ::0.1.0.0' do addr = Addrinfo.ip('::0.1.0.0').ipv6_to_ipv4 - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) addr.afamily.should == Socket::AF_INET addr.ip_address.should == '0.1.0.0' @@ -44,27 +44,27 @@ it 'returns an Addrinfo for ::ffff:192.168.1.1' do addr = Addrinfo.ip('::ffff:192.168.1.1').ipv6_to_ipv4 - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) addr.afamily.should == Socket::AF_INET addr.ip_address.should == '192.168.1.1' end it 'returns nil for ::0.0.0.1' do - Addrinfo.ip('::0.0.0.1').ipv6_to_ipv4.should be_nil + Addrinfo.ip('::0.0.0.1').ipv6_to_ipv4.should == nil end it 'returns nil for a pure IPv6 Addrinfo' do - Addrinfo.ip('::1').ipv6_to_ipv4.should be_nil + Addrinfo.ip('::1').ipv6_to_ipv4.should == nil end it 'returns nil for an IPv4 Addrinfo' do - Addrinfo.ip('192.168.1.1').ipv6_to_ipv4.should be_nil + Addrinfo.ip('192.168.1.1').ipv6_to_ipv4.should == nil end describe 'for a unix socket' do it 'returns nil for a UNIX Addrinfo' do - Addrinfo.unix('foo').ipv6_to_ipv4.should be_nil + Addrinfo.unix('foo').ipv6_to_ipv4.should == nil end end end diff --git a/spec/ruby/library/socket/addrinfo/listen_spec.rb b/spec/ruby/library/socket/addrinfo/listen_spec.rb index 931093f7325c85..80bcdc7f83e2a1 100644 --- a/spec/ruby/library/socket/addrinfo/listen_spec.rb +++ b/spec/ruby/library/socket/addrinfo/listen_spec.rb @@ -13,12 +13,12 @@ it 'returns a Socket when no block is given' do @socket = @addr.listen - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'yields the Socket if a block is given' do @addr.listen do |socket| - socket.should be_an_instance_of(Socket) + socket.should.instance_of?(Socket) end end diff --git a/spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb b/spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb index e2c3497f7fc513..438b04a99c10b8 100644 --- a/spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb +++ b/spec/ruby/library/socket/addrinfo/marshal_dump_spec.rb @@ -8,7 +8,7 @@ end it 'returns an Array' do - @addr.marshal_dump.should be_an_instance_of(Array) + @addr.marshal_dump.should.instance_of?(Array) end describe 'the returned Array' do @@ -48,7 +48,7 @@ end it 'returns an Array' do - @addr.marshal_dump.should be_an_instance_of(Array) + @addr.marshal_dump.should.instance_of?(Array) end describe 'the returned Array' do diff --git a/spec/ruby/library/socket/addrinfo/tcp_spec.rb b/spec/ruby/library/socket/addrinfo/tcp_spec.rb index c74c9c21c21e64..0669de16a6f435 100644 --- a/spec/ruby/library/socket/addrinfo/tcp_spec.rb +++ b/spec/ruby/library/socket/addrinfo/tcp_spec.rb @@ -4,7 +4,7 @@ describe 'Addrinfo.tcp' do SocketSpecs.each_ip_protocol do |family, ip_address| it 'returns an Addrinfo instance' do - Addrinfo.tcp(ip_address, 80).should be_an_instance_of(Addrinfo) + Addrinfo.tcp(ip_address, 80).should.instance_of?(Addrinfo) end it 'sets the IP address' do diff --git a/spec/ruby/library/socket/addrinfo/udp_spec.rb b/spec/ruby/library/socket/addrinfo/udp_spec.rb index ac02e76ef58f28..51d7f5588eeff5 100644 --- a/spec/ruby/library/socket/addrinfo/udp_spec.rb +++ b/spec/ruby/library/socket/addrinfo/udp_spec.rb @@ -4,7 +4,7 @@ describe 'Addrinfo.udp' do SocketSpecs.each_ip_protocol do |family, ip_address| it 'returns an Addrinfo instance' do - Addrinfo.udp(ip_address, 80).should be_an_instance_of(Addrinfo) + Addrinfo.udp(ip_address, 80).should.instance_of?(Addrinfo) end it 'sets the IP address' do diff --git a/spec/ruby/library/socket/addrinfo/unix_path_spec.rb b/spec/ruby/library/socket/addrinfo/unix_path_spec.rb index 2a9076a3544271..c15075bce36b6c 100644 --- a/spec/ruby/library/socket/addrinfo/unix_path_spec.rb +++ b/spec/ruby/library/socket/addrinfo/unix_path_spec.rb @@ -8,7 +8,7 @@ end it "raises an exception" do - -> { @addrinfo.unix_path }.should raise_error(SocketError) + -> { @addrinfo.unix_path }.should.raise(SocketError) end end @@ -19,7 +19,7 @@ end it "raises an exception" do - -> { @addrinfo.unix_path }.should raise_error(SocketError) + -> { @addrinfo.unix_path }.should.raise(SocketError) end end diff --git a/spec/ruby/library/socket/addrinfo/unix_spec.rb b/spec/ruby/library/socket/addrinfo/unix_spec.rb index 7597533a769c7d..da65e13efb60bf 100644 --- a/spec/ruby/library/socket/addrinfo/unix_spec.rb +++ b/spec/ruby/library/socket/addrinfo/unix_spec.rb @@ -2,7 +2,7 @@ describe 'Addrinfo.unix' do it 'returns an Addrinfo instance' do - Addrinfo.unix('socket').should be_an_instance_of(Addrinfo) + Addrinfo.unix('socket').should.instance_of?(Addrinfo) end it 'sets the IP address' do @@ -40,7 +40,7 @@ end it "returns false" do - @addrinfo.unix?.should be_false + @addrinfo.unix?.should == false end end @@ -51,7 +51,7 @@ end it "returns false" do - @addrinfo.unix?.should be_false + @addrinfo.unix?.should == false end end @@ -62,7 +62,7 @@ end it "returns true" do - @addrinfo.unix?.should be_true + @addrinfo.unix?.should == true end end end diff --git a/spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb b/spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb index c54ee298259679..c77f3bdbaeb774 100644 --- a/spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/cmsg_is_spec.rb @@ -26,7 +26,7 @@ end it 'raises SocketError when comparing with :IPV6 and :RIGHTS' do - -> { @data.cmsg_is?(:IPV6, :RIGHTS) }.should raise_error(SocketError) + -> { @data.cmsg_is?(:IPV6, :RIGHTS) }.should.raise(SocketError) end end end diff --git a/spec/ruby/library/socket/ancillarydata/initialize_spec.rb b/spec/ruby/library/socket/ancillarydata/initialize_spec.rb index eca45599d777a8..60f5ac7a905c19 100644 --- a/spec/ruby/library/socket/ancillarydata/initialize_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/initialize_spec.rb @@ -115,25 +115,25 @@ it 'raises TypeError when using a numeric string as the type argument' do -> { Socket::AncillaryData.new(:INET, :IGMP, Socket::SCM_RIGHTS.to_s, '') - }.should raise_error(TypeError) + }.should.raise(TypeError) end it 'raises SocketError when using :RECVTTL as the type argument' do -> { Socket::AncillaryData.new(:INET, :SOCKET, :RECVTTL, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises SocketError when using :MOO as the type argument' do -> { Socket::AncillaryData.new(:INET, :SOCKET, :MOO, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises SocketError when using :IP_RECVTTL as the type argument' do -> { Socket::AncillaryData.new(:INET, :SOCKET, :IP_RECVTTL, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -157,13 +157,13 @@ it 'raises SocketError when using :RIGHTS as the type argument' do -> { Socket::AncillaryData.new(:INET, :IP, :RIGHTS, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises SocketError when using :MOO as the type argument' do -> { Socket::AncillaryData.new(:INET, :IP, :MOO, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -181,13 +181,13 @@ it 'raises SocketError when using :RIGHTS as the type argument' do -> { Socket::AncillaryData.new(:INET, :IPV6, :RIGHTS, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises SocketError when using :MOO as the type argument' do -> { Socket::AncillaryData.new(:INET, :IPV6, :MOO, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -207,13 +207,13 @@ it 'raises SocketError when using :RIGHTS as the type argument' do -> { Socket::AncillaryData.new(:INET, :TCP, :RIGHTS, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises SocketError when using :MOO as the type argument' do -> { Socket::AncillaryData.new(:INET, :TCP, :MOO, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -227,13 +227,13 @@ it 'raises SocketError when using :RIGHTS as the type argument' do -> { Socket::AncillaryData.new(:INET, :UDP, :RIGHTS, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises SocketError when using :MOO as the type argument' do -> { Socket::AncillaryData.new(:INET, :UDP, :MOO, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -245,7 +245,7 @@ it 'raises SocketError when using :CORK sa the type argument' do -> { Socket::AncillaryData.new(:UNIX, :SOCKET, :CORK, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -253,7 +253,7 @@ it 'raises SocketError' do -> { Socket::AncillaryData.new(:UNIX, :IP, :RECVTTL, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -261,7 +261,7 @@ it 'raises SocketError' do -> { Socket::AncillaryData.new(:UNIX, :IPV6, :NEXTHOP, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -269,7 +269,7 @@ it 'raises SocketError' do -> { Socket::AncillaryData.new(:UNIX, :TCP, :CORK, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -277,7 +277,7 @@ it 'raises SocketError' do -> { Socket::AncillaryData.new(:UNIX, :UDP, :CORK, '') - }.should raise_error(SocketError) + }.should.raise(SocketError) end end end diff --git a/spec/ruby/library/socket/ancillarydata/int_spec.rb b/spec/ruby/library/socket/ancillarydata/int_spec.rb index fe41a30a1a0caa..10c5dea436bf6f 100644 --- a/spec/ruby/library/socket/ancillarydata/int_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/int_spec.rb @@ -7,7 +7,7 @@ end it 'returns a Socket::AncillaryData' do - @data.should be_an_instance_of(Socket::AncillaryData) + @data.should.instance_of?(Socket::AncillaryData) end it 'sets the family to AF_INET' do @@ -37,7 +37,7 @@ it 'raises when the data is not an Integer' do data = Socket::AncillaryData.new(:UNIX, :SOCKET, :RIGHTS, 'ugh') - -> { data.int }.should raise_error(TypeError) + -> { data.int }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb b/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb index 84910a038a3f04..065bcf1f39b1ca 100644 --- a/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/ip_pktinfo_spec.rb @@ -8,7 +8,7 @@ end it 'returns a Socket::AncillaryData' do - @data.should be_an_instance_of(Socket::AncillaryData) + @data.should.instance_of?(Socket::AncillaryData) end it 'sets the family to AF_INET' do @@ -32,7 +32,7 @@ end it 'returns a Socket::AncillaryData' do - @data.should be_an_instance_of(Socket::AncillaryData) + @data.should.instance_of?(Socket::AncillaryData) end it 'sets the family to AF_INET' do @@ -58,7 +58,7 @@ end it 'returns an Array' do - @data.ip_pktinfo.should be_an_instance_of(Array) + @data.ip_pktinfo.should.instance_of?(Array) end describe 'the returned Array' do @@ -67,15 +67,15 @@ end it 'stores an Addrinfo at index 0' do - @info[0].should be_an_instance_of(Addrinfo) + @info[0].should.instance_of?(Addrinfo) end it 'stores the ifindex at index 1' do - @info[1].should be_kind_of(Integer) + @info[1].should.is_a?(Integer) end it 'stores an Addrinfo at index 2' do - @info[2].should be_an_instance_of(Addrinfo) + @info[2].should.instance_of?(Addrinfo) end end @@ -89,7 +89,7 @@ end it 'is not the same object as the input Addrinfo' do - @addr.should_not equal @source + @addr.should_not.equal? @source end end @@ -109,7 +109,7 @@ end it 'is not the same object as the input Addrinfo' do - @addr.should_not equal @dest + @addr.should_not.equal? @dest end end end diff --git a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb b/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb index f70fe27d6a665b..7c630218d1f8ff 100644 --- a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_addr_spec.rb @@ -5,7 +5,7 @@ it 'returns an Addrinfo' do data = Socket::AncillaryData.ipv6_pktinfo(Addrinfo.ip('::1'), 4) - data.ipv6_pktinfo_addr.should be_an_instance_of(Addrinfo) + data.ipv6_pktinfo_addr.should.instance_of?(Addrinfo) end end end diff --git a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb b/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb index 0fffc720dcd6fb..b5b779c36e5c1b 100644 --- a/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/ipv6_pktinfo_spec.rb @@ -7,7 +7,7 @@ end it 'returns a Socket::AncillaryData' do - @data.should be_an_instance_of(Socket::AncillaryData) + @data.should.instance_of?(Socket::AncillaryData) end it 'sets the family to AF_INET' do @@ -31,7 +31,7 @@ end it 'returns an Array' do - @data.ipv6_pktinfo.should be_an_instance_of(Array) + @data.ipv6_pktinfo.should.instance_of?(Array) end describe 'the returned Array' do @@ -40,11 +40,11 @@ end it 'stores an Addrinfo at index 0' do - @info[0].should be_an_instance_of(Addrinfo) + @info[0].should.instance_of?(Addrinfo) end it 'stores the ifindex at index 1' do - @info[1].should be_kind_of(Integer) + @info[1].should.is_a?(Integer) end end @@ -58,7 +58,7 @@ end it 'is not the same object as the input Addrinfo' do - @addr.should_not equal @source + @addr.should_not.equal? @source end end diff --git a/spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb b/spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb index 95052fd91c2d32..6dd144ba5ab840 100644 --- a/spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb +++ b/spec/ruby/library/socket/ancillarydata/unix_rights_spec.rb @@ -26,7 +26,7 @@ describe 'using non IO objects' do it 'raises TypeError' do - -> { Socket::AncillaryData.unix_rights(10) }.should raise_error(TypeError) + -> { Socket::AncillaryData.unix_rights(10) }.should.raise(TypeError) end end end @@ -41,20 +41,20 @@ it 'returns nil when the data is not a list of file descriptors' do data = Socket::AncillaryData.new(:UNIX, :SOCKET, :RIGHTS, '') - data.unix_rights.should be_nil + data.unix_rights.should == nil end it 'raises TypeError when the level is not SOL_SOCKET' do data = Socket::AncillaryData.new(:INET, :IP, :RECVTTL, '') - -> { data.unix_rights }.should raise_error(TypeError) + -> { data.unix_rights }.should.raise(TypeError) end platform_is_not :aix do it 'raises TypeError when the type is not SCM_RIGHTS' do data = Socket::AncillaryData.new(:INET, :SOCKET, :TIMESTAMP, '') - -> { data.unix_rights }.should raise_error(TypeError) + -> { data.unix_rights }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/socket/basicsocket/close_read_spec.rb b/spec/ruby/library/socket/basicsocket/close_read_spec.rb index f317b3495531bd..35bec203d7a7c1 100644 --- a/spec/ruby/library/socket/basicsocket/close_read_spec.rb +++ b/spec/ruby/library/socket/basicsocket/close_read_spec.rb @@ -12,32 +12,32 @@ it "closes the reading end of the socket" do @server.close_read - -> { @server.read }.should raise_error(IOError) + -> { @server.read }.should.raise(IOError) end it 'does not raise when called on a socket already closed for reading' do @server.close_read @server.close_read - -> { @server.read }.should raise_error(IOError) + -> { @server.read }.should.raise(IOError) end it 'does not fully close the socket' do @server.close_read - @server.closed?.should be_false + @server.closed?.should == false end it "fully closes the socket if it was already closed for writing" do @server.close_write @server.close_read - @server.closed?.should be_true + @server.closed?.should == true end it 'raises IOError when called on a fully closed socket' do @server.close - -> { @server.close_read }.should raise_error(IOError) + -> { @server.close_read }.should.raise(IOError) end it "returns nil" do - @server.close_read.should be_nil + @server.close_read.should == nil end end diff --git a/spec/ruby/library/socket/basicsocket/close_write_spec.rb b/spec/ruby/library/socket/basicsocket/close_write_spec.rb index 232cfbb7c67b48..c1b6d9e9ef2b44 100644 --- a/spec/ruby/library/socket/basicsocket/close_write_spec.rb +++ b/spec/ruby/library/socket/basicsocket/close_write_spec.rb @@ -12,18 +12,18 @@ it "closes the writing end of the socket" do @server.close_write - -> { @server.write("foo") }.should raise_error(IOError) + -> { @server.write("foo") }.should.raise(IOError) end it 'does not raise when called on a socket already closed for writing' do @server.close_write @server.close_write - -> { @server.write("foo") }.should raise_error(IOError) + -> { @server.write("foo") }.should.raise(IOError) end it 'does not fully close the socket' do @server.close_write - @server.closed?.should be_false + @server.closed?.should == false end it "does not prevent reading" do @@ -34,15 +34,15 @@ it "fully closes the socket if it was already closed for reading" do @server.close_read @server.close_write - @server.closed?.should be_true + @server.closed?.should == true end it 'raises IOError when called on a fully closed socket' do @server.close - -> { @server.close_write }.should raise_error(IOError) + -> { @server.close_write }.should.raise(IOError) end it "returns nil" do - @server.close_write.should be_nil + @server.close_write.should == nil end end diff --git a/spec/ruby/library/socket/basicsocket/connect_address_spec.rb b/spec/ruby/library/socket/basicsocket/connect_address_spec.rb index 2e318fcb851391..e330b6e1befd03 100644 --- a/spec/ruby/library/socket/basicsocket/connect_address_spec.rb +++ b/spec/ruby/library/socket/basicsocket/connect_address_spec.rb @@ -10,7 +10,7 @@ it 'raises SocketError' do @sock = Socket.new(:INET, :STREAM) - -> { @sock.connect_address }.should raise_error(SocketError) + -> { @sock.connect_address }.should.raise(SocketError) end end @@ -25,7 +25,7 @@ end it 'returns an Addrinfo' do - @sock.connect_address.should be_an_instance_of(Addrinfo) + @sock.connect_address.should.instance_of?(Addrinfo) end it 'uses 127.0.0.1 as the IP address' do @@ -65,7 +65,7 @@ end it 'returns an Addrinfo' do - @sock.connect_address.should be_an_instance_of(Addrinfo) + @sock.connect_address.should.instance_of?(Addrinfo) end it 'uses ::1 as the IP address' do @@ -109,7 +109,7 @@ end it 'raises SocketError' do - -> { @client.connect_address }.should raise_error(SocketError) + -> { @client.connect_address }.should.raise(SocketError) end end end @@ -126,7 +126,7 @@ end it 'returns an Addrinfo' do - @sock.connect_address.should be_an_instance_of(Addrinfo) + @sock.connect_address.should.instance_of?(Addrinfo) end it 'uses the correct socket path' do diff --git a/spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb b/spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb index a8800a849326a2..36338bfd594cf9 100644 --- a/spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb +++ b/spec/ruby/library/socket/basicsocket/do_not_reverse_lookup_spec.rb @@ -16,7 +16,7 @@ end it "defaults to true" do - BasicSocket.do_not_reverse_lookup.should be_true + BasicSocket.do_not_reverse_lookup.should == true end it "causes 'peeraddr' to avoid name lookups" do diff --git a/spec/ruby/library/socket/basicsocket/for_fd_spec.rb b/spec/ruby/library/socket/basicsocket/for_fd_spec.rb index 9c9e6a8b550329..8d5b71cfa9b375 100644 --- a/spec/ruby/library/socket/basicsocket/for_fd_spec.rb +++ b/spec/ruby/library/socket/basicsocket/for_fd_spec.rb @@ -15,7 +15,7 @@ it "return a Socket instance wrapped around the descriptor" do @s2 = TCPServer.for_fd(@server.fileno) @s2.autoclose = false - @s2.should be_kind_of(TCPServer) + @s2.should.is_a?(TCPServer) @s2.fileno.should == @server.fileno end @@ -24,7 +24,7 @@ socket2 = Socket.for_fd(@socket1.fileno) socket2.autoclose = false - socket2.should be_an_instance_of(Socket) + socket2.should.instance_of?(Socket) socket2.fileno.should == @socket1.fileno end @@ -33,6 +33,6 @@ socket2 = Socket.for_fd(@socket1.fileno) socket2.autoclose = false - socket2.binmode?.should be_true + socket2.binmode?.should == true end end diff --git a/spec/ruby/library/socket/basicsocket/getpeereid_spec.rb b/spec/ruby/library/socket/basicsocket/getpeereid_spec.rb index 2e03cd3684bd99..b9851bae153bb9 100644 --- a/spec/ruby/library/socket/basicsocket/getpeereid_spec.rb +++ b/spec/ruby/library/socket/basicsocket/getpeereid_spec.rb @@ -30,7 +30,7 @@ it 'raises NoMethodError' do @sock = TCPServer.new('127.0.0.1', 0) - -> { @sock.getpeereid }.should raise_error(NoMethodError) + -> { @sock.getpeereid }.should.raise(NoMethodError) end end end diff --git a/spec/ruby/library/socket/basicsocket/getpeername_spec.rb b/spec/ruby/library/socket/basicsocket/getpeername_spec.rb index 0b93f02eefc6e1..7e2f6f2e7b675f 100644 --- a/spec/ruby/library/socket/basicsocket/getpeername_spec.rb +++ b/spec/ruby/library/socket/basicsocket/getpeername_spec.rb @@ -20,6 +20,6 @@ end it 'raises Errno::ENOTCONN for a disconnected socket' do - -> { @server.getpeername }.should raise_error(Errno::ENOTCONN) + -> { @server.getpeername }.should.raise(Errno::ENOTCONN) end end diff --git a/spec/ruby/library/socket/basicsocket/getsockname_spec.rb b/spec/ruby/library/socket/basicsocket/getsockname_spec.rb index b33db088b6d075..a54626647e6091 100644 --- a/spec/ruby/library/socket/basicsocket/getsockname_spec.rb +++ b/spec/ruby/library/socket/basicsocket/getsockname_spec.rb @@ -3,7 +3,7 @@ describe "Socket::BasicSocket#getsockname" do after :each do - @socket.closed?.should be_false + @socket.closed?.should == false @socket.close end @@ -16,7 +16,7 @@ it "works on sockets listening in ipaddr_any" do @socket = TCPServer.new(0) sockaddr = Socket.unpack_sockaddr_in(@socket.getsockname) - ["::", "0.0.0.0", "::ffff:0.0.0.0"].include?(sockaddr[1]).should be_true + ["::", "0.0.0.0", "::ffff:0.0.0.0"].include?(sockaddr[1]).should == true sockaddr[0].should == @socket.addr[1] end diff --git a/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb b/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb index ce65d6c92bfbea..744297ad023f5e 100644 --- a/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb +++ b/spec/ruby/library/socket/basicsocket/getsockopt_spec.rb @@ -7,7 +7,7 @@ end after :each do - @sock.closed?.should be_false + @sock.closed?.should == false @sock.close end @@ -41,13 +41,13 @@ end it "raises a SystemCallError with an invalid socket option" do - -> { @sock.getsockopt Socket::SOL_SOCKET, -1 }.should raise_error(Errno::ENOPROTOOPT) + -> { @sock.getsockopt Socket::SOL_SOCKET, -1 }.should.raise(Errno::ENOPROTOOPT) end it 'returns a Socket::Option using a constant' do opt = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_TYPE) - opt.should be_an_instance_of(Socket::Option) + opt.should.instance_of?(Socket::Option) end it 'returns a Socket::Option for a boolean option' do @@ -59,7 +59,7 @@ it 'returns a Socket::Option for a numeric option' do opt = @sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL) - opt.int.should be_kind_of(Integer) + opt.int.should.is_a?(Integer) end it 'returns a Socket::Option for a struct option' do @@ -69,7 +69,7 @@ end it 'raises Errno::ENOPROTOOPT when requesting an invalid option' do - -> { @sock.getsockopt(Socket::SOL_SOCKET, -1) }.should raise_error(Errno::ENOPROTOOPT) + -> { @sock.getsockopt(Socket::SOL_SOCKET, -1) }.should.raise(Errno::ENOPROTOOPT) end describe 'using Symbols as arguments' do @@ -171,7 +171,7 @@ opt = @sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL).to_s array = opt.unpack('i') - array[0].should be_kind_of(Integer) + array[0].should.is_a?(Integer) array[0].should > 0 end diff --git a/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb index f2383513f286b2..8aca7d03323dc1 100644 --- a/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb @@ -16,7 +16,7 @@ platform_is_not :windows do describe 'using an unbound socket' do it 'raises an exception extending IO::WaitReadable' do - -> { @s1.recv_nonblock(1) }.should raise_error(IO::WaitReadable) + -> { @s1.recv_nonblock(1) }.should.raise(IO::WaitReadable) end end end @@ -25,12 +25,12 @@ @s1.bind(Socket.pack_sockaddr_in(0, ip_address)) -> { @s1.recv_nonblock(5) - }.should raise_error(IO::WaitReadable) { |e| + }.should.raise(IO::WaitReadable) { |e| platform_is_not :windows do - e.should be_kind_of(Errno::EAGAIN) + e.should.is_a?(Errno::EAGAIN) end platform_is :windows do - e.should be_kind_of(Errno::EWOULDBLOCK) + e.should.is_a?(Errno::EWOULDBLOCK) end } end @@ -74,7 +74,7 @@ @s1.recv_nonblock(1).should == "a" -> { @s1.recv_nonblock(5) - }.should raise_error(IO::WaitReadable) + }.should.raise(IO::WaitReadable) end end @@ -89,10 +89,10 @@ end it "raises Errno::ENOTCONN" do - -> { @server.recv_nonblock(1) }.should raise_error { |e| + -> { @server.recv_nonblock(1) }.should.raise { |e| [Errno::ENOTCONN, Errno::EINVAL].should.include?(e.class) } - -> { @server.recv_nonblock(1, exception: false) }.should raise_error { |e| + -> { @server.recv_nonblock(1, exception: false) }.should.raise { |e| [Errno::ENOTCONN, Errno::EINVAL].should.include?(e.class) } end @@ -129,13 +129,13 @@ end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil socket = TCPSocket.new('127.0.0.1', @port) socket.close ready = true - t.value.should be_nil + t.value.should == nil end end end diff --git a/spec/ruby/library/socket/basicsocket/recv_spec.rb b/spec/ruby/library/socket/basicsocket/recv_spec.rb index 7581f1bc1533fa..5c393218bc6c96 100644 --- a/spec/ruby/library/socket/basicsocket/recv_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recv_spec.rb @@ -22,7 +22,7 @@ client.close end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil socket = TCPSocket.new('127.0.0.1', @port) socket.send('hello', 0) @@ -44,7 +44,7 @@ client.close end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil socket = TCPSocket.new('127.0.0.1', @port) socket.send('helloU', Socket::MSG_OOB) @@ -64,7 +64,7 @@ client.close end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil socket = TCPSocket.new('127.0.0.1', @port) socket.write("firstline\377secondline\377") @@ -193,12 +193,12 @@ end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil socket = TCPSocket.new('127.0.0.1', @port) socket.close - t.value.should be_nil + t.value.should == nil end end diff --git a/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb index d1cde4411bd8bc..9d77f5df6b46e8 100644 --- a/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recvmsg_nonblock_spec.rb @@ -17,7 +17,7 @@ platform_is_not :windows do describe 'using an unbound socket' do it 'raises an exception extending IO::WaitReadable' do - -> { @server.recvmsg_nonblock }.should raise_error(IO::WaitReadable) + -> { @server.recvmsg_nonblock }.should.raise(IO::WaitReadable) end end end @@ -29,7 +29,7 @@ describe 'without any data available' do it 'raises an exception extending IO::WaitReadable' do - -> { @server.recvmsg_nonblock }.should raise_error(IO::WaitReadable) + -> { @server.recvmsg_nonblock }.should.raise(IO::WaitReadable) end it 'returns :wait_readable with exception: false' do @@ -47,7 +47,7 @@ end it 'returns an Array containing the data, an Addrinfo and the flags' do - @server.recvmsg_nonblock.should be_an_instance_of(Array) + @server.recvmsg_nonblock.should.instance_of?(Array) end describe 'without a maximum message length' do @@ -74,12 +74,12 @@ end it 'stores an Addrinfo at index 1' do - @array[1].should be_an_instance_of(Addrinfo) + @array[1].should.instance_of?(Addrinfo) end platform_is_not :windows do it 'stores the flags at index 2' do - @array[2].should be_kind_of(Integer) + @array[2].should.is_a?(Integer) end end @@ -124,8 +124,8 @@ end it "raises Errno::ENOTCONN" do - -> { @server.recvmsg_nonblock }.should raise_error(Errno::ENOTCONN) - -> { @server.recvmsg_nonblock(exception: false) }.should raise_error(Errno::ENOTCONN) + -> { @server.recvmsg_nonblock }.should.raise(Errno::ENOTCONN) + -> { @server.recvmsg_nonblock(exception: false) }.should.raise(Errno::ENOTCONN) end end @@ -154,7 +154,7 @@ ensure socket.close end - }.should raise_error(IO::WaitReadable) + }.should.raise(IO::WaitReadable) end end @@ -171,7 +171,7 @@ end it 'returns an Array containing the data, an Addrinfo and the flags' do - @socket.recvmsg_nonblock.should be_an_instance_of(Array) + @socket.recvmsg_nonblock.should.instance_of?(Array) end describe 'the returned Array' do @@ -184,11 +184,11 @@ end it 'stores an Addrinfo at index 1' do - @array[1].should be_an_instance_of(Addrinfo) + @array[1].should.instance_of?(Addrinfo) end it 'stores the flags at index 2' do - @array[2].should be_kind_of(Integer) + @array[2].should.is_a?(Integer) end describe 'the returned Addrinfo' do @@ -197,7 +197,7 @@ end it 'raises when receiving the ip_address message' do - -> { @addr.ip_address }.should raise_error(SocketError) + -> { @addr.ip_address }.should.raise(SocketError) end it 'uses the correct address family' do @@ -213,7 +213,7 @@ end it 'raises when receiving the ip_port message' do - -> { @addr.ip_port }.should raise_error(SocketError) + -> { @addr.ip_port }.should.raise(SocketError) end end end @@ -253,13 +253,13 @@ end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil socket = TCPSocket.new('127.0.0.1', @port) socket.close ready = true - t.value.should be_nil + t.value.should == nil end end end diff --git a/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb b/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb index cfa0f4c61d476f..eabfb9dd1809be 100644 --- a/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recvmsg_spec.rb @@ -41,7 +41,7 @@ end it 'returns an Array containing the data, an Addrinfo and the flags' do - @server.recvmsg.should be_an_instance_of(Array) + @server.recvmsg.should.instance_of?(Array) end describe 'without a maximum message length' do @@ -66,12 +66,12 @@ end it 'stores an Addrinfo at index 1' do - @array[1].should be_an_instance_of(Addrinfo) + @array[1].should.instance_of?(Addrinfo) end platform_is_not :windows do it 'stores the flags at index 2' do - @array[2].should be_kind_of(Integer) + @array[2].should.is_a?(Integer) end end @@ -144,7 +144,7 @@ end it 'returns an Array containing the data, an Addrinfo and the flags' do - @socket.recvmsg.should be_an_instance_of(Array) + @socket.recvmsg.should.instance_of?(Array) end describe 'the returned Array' do @@ -157,11 +157,11 @@ end it 'stores an Addrinfo at index 1' do - @array[1].should be_an_instance_of(Addrinfo) + @array[1].should.instance_of?(Addrinfo) end it 'stores the flags at index 2' do - @array[2].should be_kind_of(Integer) + @array[2].should.is_a?(Integer) end describe 'the returned Addrinfo' do @@ -170,7 +170,7 @@ end it 'raises when receiving the ip_address message' do - -> { @addr.ip_address }.should raise_error(SocketError) + -> { @addr.ip_address }.should.raise(SocketError) end it 'uses the correct address family' do @@ -186,7 +186,7 @@ end it 'raises when receiving the ip_port message' do - -> { @addr.ip_port }.should raise_error(SocketError) + -> { @addr.ip_port }.should.raise(SocketError) end end end @@ -218,12 +218,12 @@ end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil socket = TCPSocket.new('127.0.0.1', @port) socket.close - t.value.should be_nil + t.value.should == nil end end end diff --git a/spec/ruby/library/socket/basicsocket/send_spec.rb b/spec/ruby/library/socket/basicsocket/send_spec.rb index 25ba3f5655da7f..a2c2ee8de98cbe 100644 --- a/spec/ruby/library/socket/basicsocket/send_spec.rb +++ b/spec/ruby/library/socket/basicsocket/send_spec.rb @@ -9,8 +9,8 @@ end after :each do - @server.closed?.should be_false - @socket.closed?.should be_false + @server.closed?.should == false + @socket.closed?.should == false @server.close @socket.close @@ -28,7 +28,7 @@ client.close end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil @socket.send('hello', 0).should == 5 @socket.shutdown(1) # indicate, that we are done sending @@ -50,7 +50,7 @@ client.close end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil @socket.send('helloU', Socket::MSG_PEEK | Socket::MSG_OOB).should == 6 @socket.shutdown # indicate, that we are done sending @@ -73,7 +73,7 @@ client.close end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil sockaddr = Socket.pack_sockaddr_in(@port, "127.0.0.1") @socket.send('hello', 0, sockaddr).should == 5 @@ -109,7 +109,7 @@ describe 'without a destination address' do it "raises #{SocketSpecs.dest_addr_req_error}" do - -> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error) + -> { @client.send('hello', 0) }.should.raise(SocketSpecs.dest_addr_req_error) end end @@ -121,7 +121,7 @@ it 'does not persist the connection after writing to the socket' do @client.send('hello', 0, @server.getsockname) - -> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error) + -> { @client.send('hello', 0) }.should.raise(SocketSpecs.dest_addr_req_error) end end diff --git a/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb index 7acfc659bd90ee..4cd6e8bdca54e9 100644 --- a/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb +++ b/spec/ruby/library/socket/basicsocket/sendmsg_nonblock_spec.rb @@ -20,10 +20,10 @@ it "raises #{SocketSpecs.dest_addr_req_error}" do -> { @client.sendmsg_nonblock('hello') - }.should raise_error(SocketSpecs.dest_addr_req_error) + }.should.raise(SocketSpecs.dest_addr_req_error) -> { @client.sendmsg_nonblock('hello', exception: false) - }.should raise_error(SocketSpecs.dest_addr_req_error) + }.should.raise(SocketSpecs.dest_addr_req_error) end end @@ -101,7 +101,7 @@ it 'raises IO::WaitWritable when the underlying buffer is full' do -> { 10.times { @client.sendmsg_nonblock('hello' * 1_000_000) } - }.should raise_error(IO::WaitWritable) + }.should.raise(IO::WaitWritable) end it 'returns :wait_writable when the underlying buffer is full with exception: false' do diff --git a/spec/ruby/library/socket/basicsocket/sendmsg_spec.rb b/spec/ruby/library/socket/basicsocket/sendmsg_spec.rb index 7ff336c0b70777..dc999b32df5525 100644 --- a/spec/ruby/library/socket/basicsocket/sendmsg_spec.rb +++ b/spec/ruby/library/socket/basicsocket/sendmsg_spec.rb @@ -19,7 +19,7 @@ platform_is_not :windows do describe 'without a destination address' do it "raises #{SocketSpecs.dest_addr_req_error}" do - -> { @client.sendmsg('hello') }.should raise_error(SocketSpecs.dest_addr_req_error) + -> { @client.sendmsg('hello') }.should.raise(SocketSpecs.dest_addr_req_error) end end end diff --git a/spec/ruby/library/socket/basicsocket/setsockopt_spec.rb b/spec/ruby/library/socket/basicsocket/setsockopt_spec.rb index f686e673263789..e306581aa36f6b 100644 --- a/spec/ruby/library/socket/basicsocket/setsockopt_spec.rb +++ b/spec/ruby/library/socket/basicsocket/setsockopt_spec.rb @@ -40,7 +40,7 @@ it "raises EINVAL if passed wrong linger value" do -> do @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER, 0) - end.should raise_error(Errno::EINVAL) + end.should.raise(Errno::EINVAL) end end @@ -72,7 +72,7 @@ platform_is_not :windows do -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "") - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) end @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "blah").should == 0 @@ -82,7 +82,7 @@ platform_is_not :windows do -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "0") - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) end @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "\x00\x00\x00\x00").should == 0 @@ -92,13 +92,13 @@ platform_is_not :windows do -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "1") - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) end platform_is_not :windows do -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, "\x00\x00\x00") - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) end @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, [1].pack('i')).should == 0 @@ -127,7 +127,7 @@ -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, nil).should == 0 - }.should raise_error(TypeError) + }.should.raise(TypeError) @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, 1).should == 0 n = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF).to_s @@ -139,23 +139,23 @@ -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "") - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "bla") - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "0") - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "1") - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) -> { @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "\x00\x00\x00") - }.should raise_error(SystemCallError) + }.should.raise(SystemCallError) @sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, "\x00\x00\x01\x00").should == 0 n = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF).to_s @@ -207,7 +207,7 @@ onoff, seconds = @sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER).linger seconds.should == 10 # Both results can be produced depending on the OS and value of Socket::SO_LINGER - [true, Socket::SO_LINGER].should include(onoff) + [true, Socket::SO_LINGER].should.include?(onoff) end end end @@ -224,7 +224,7 @@ describe 'using separate arguments with Symbols' do it 'raises TypeError when the first argument is nil' do - -> { @socket.setsockopt(nil, :REUSEADDR, true) }.should raise_error(TypeError) + -> { @socket.setsockopt(nil, :REUSEADDR, true) }.should.raise(TypeError) end it 'sets a boolean option' do @@ -251,7 +251,7 @@ platform_is_not :windows do it 'raises Errno::EINVAL when setting an invalid option value' do - -> { @socket.setsockopt(:SOCKET, :OOBINLINE, 'bla') }.should raise_error(Errno::EINVAL) + -> { @socket.setsockopt(:SOCKET, :OOBINLINE, 'bla') }.should.raise(Errno::EINVAL) end end end @@ -305,12 +305,12 @@ it 'raises ArgumentError when passing 2 arguments' do option = Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true) - -> { @socket.setsockopt(option, :REUSEADDR) }.should raise_error(ArgumentError) + -> { @socket.setsockopt(option, :REUSEADDR) }.should.raise(ArgumentError) end it 'raises TypeError when passing 3 arguments' do option = Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true) - -> { @socket.setsockopt(option, :REUSEADDR, true) }.should raise_error(TypeError) + -> { @socket.setsockopt(option, :REUSEADDR, true) }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb index c78b32de38c3cd..c96c62abe1f759 100644 --- a/spec/ruby/library/socket/basicsocket/shutdown_spec.rb +++ b/spec/ruby/library/socket/basicsocket/shutdown_spec.rb @@ -23,25 +23,25 @@ it 'shuts down a socket for reading' do @client.shutdown(Socket::SHUT_RD) - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? end it 'shuts down a socket for writing' do @client.shutdown(Socket::SHUT_WR) - -> { @client.write('hello') }.should raise_error(Errno::EPIPE) + -> { @client.write('hello') }.should.raise(Errno::EPIPE) end it 'shuts down a socket for reading and writing' do @client.shutdown(Socket::SHUT_RDWR) - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? - -> { @client.write('hello') }.should raise_error(Errno::EPIPE) + -> { @client.write('hello') }.should.raise(Errno::EPIPE) end it 'raises ArgumentError when using an invalid option' do - -> { @server.shutdown(666) }.should raise_error(ArgumentError) + -> { @server.shutdown(666) }.should.raise(ArgumentError) end end @@ -49,37 +49,37 @@ it 'shuts down a socket for reading using :RD' do @client.shutdown(:RD) - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? end it 'shuts down a socket for reading using :SHUT_RD' do @client.shutdown(:SHUT_RD) - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? end it 'shuts down a socket for writing using :WR' do @client.shutdown(:WR) - -> { @client.write('hello') }.should raise_error(Errno::EPIPE) + -> { @client.write('hello') }.should.raise(Errno::EPIPE) end it 'shuts down a socket for writing using :SHUT_WR' do @client.shutdown(:SHUT_WR) - -> { @client.write('hello') }.should raise_error(Errno::EPIPE) + -> { @client.write('hello') }.should.raise(Errno::EPIPE) end it 'shuts down a socket for reading and writing' do @client.shutdown(:RDWR) - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? - -> { @client.write('hello') }.should raise_error(Errno::EPIPE) + -> { @client.write('hello') }.should.raise(Errno::EPIPE) end it 'raises ArgumentError when using an invalid option' do - -> { @server.shutdown(:Nope) }.should raise_error(SocketError) + -> { @server.shutdown(:Nope) }.should.raise(SocketError) end end @@ -87,29 +87,29 @@ it 'shuts down a socket for reading using "RD"' do @client.shutdown('RD') - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? end it 'shuts down a socket for reading using "SHUT_RD"' do @client.shutdown('SHUT_RD') - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? end it 'shuts down a socket for writing using "WR"' do @client.shutdown('WR') - -> { @client.write('hello') }.should raise_error(Errno::EPIPE) + -> { @client.write('hello') }.should.raise(Errno::EPIPE) end it 'shuts down a socket for writing using "SHUT_WR"' do @client.shutdown('SHUT_WR') - -> { @client.write('hello') }.should raise_error(Errno::EPIPE) + -> { @client.write('hello') }.should.raise(Errno::EPIPE) end it 'raises ArgumentError when using an invalid option' do - -> { @server.shutdown('Nope') }.should raise_error(SocketError) + -> { @server.shutdown('Nope') }.should.raise(SocketError) end end @@ -123,7 +123,7 @@ @client.shutdown(@dummy) - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? end it 'shuts down a socket for reading using "SHUT_RD"' do @@ -131,7 +131,7 @@ @client.shutdown(@dummy) - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? end it 'shuts down a socket for reading and writing' do @@ -139,15 +139,15 @@ @client.shutdown(@dummy) - @client.recv(1).to_s.should be_empty + @client.recv(1).to_s.should.empty? - -> { @client.write('hello') }.should raise_error(Errno::EPIPE) + -> { @client.write('hello') }.should.raise(Errno::EPIPE) end end describe 'using an object that does not respond to #to_str' do it 'raises TypeError' do - -> { @server.shutdown(mock(:dummy)) }.should raise_error(TypeError) + -> { @server.shutdown(mock(:dummy)) }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/socket/constants/constants_spec.rb b/spec/ruby/library/socket/constants/constants_spec.rb index b9a9d427253ff1..a936473bb6cef2 100644 --- a/spec/ruby/library/socket/constants/constants_spec.rb +++ b/spec/ruby/library/socket/constants/constants_spec.rb @@ -5,47 +5,47 @@ it "defines socket types" do consts = ["SOCK_DGRAM", "SOCK_RAW", "SOCK_RDM", "SOCK_SEQPACKET", "SOCK_STREAM"] consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end it "defines protocol families" do consts = ["PF_INET6", "PF_INET", "PF_UNIX", "PF_UNSPEC"] consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end platform_is_not :aix do it "defines PF_IPX protocol" do - Socket::Constants.should have_constant("PF_IPX") + Socket::Constants.should.const_defined?("PF_IPX", false) end end it "defines address families" do consts = ["AF_INET6", "AF_INET", "AF_UNIX", "AF_UNSPEC"] consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end platform_is_not :aix do it "defines AF_IPX address" do - Socket::Constants.should have_constant("AF_IPX") + Socket::Constants.should.const_defined?("AF_IPX", false) end end it "defines send/receive options" do consts = ["MSG_DONTROUTE", "MSG_OOB", "MSG_PEEK"] consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end it "defines socket level options" do consts = ["SOL_SOCKET"] consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end @@ -53,7 +53,7 @@ consts = ["SO_BROADCAST", "SO_DEBUG", "SO_DONTROUTE", "SO_ERROR", "SO_KEEPALIVE", "SO_LINGER", "SO_OOBINLINE", "SO_RCVBUF", "SO_REUSEADDR", "SO_SNDBUF", "SO_TYPE"] consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end @@ -64,7 +64,7 @@ consts += ["IP_DEFAULT_MULTICAST_LOOP", "IP_DEFAULT_MULTICAST_TTL"] end consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end @@ -72,7 +72,7 @@ it "defines multicast options" do consts = ["IP_MAX_MEMBERSHIPS"] consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end end @@ -83,13 +83,13 @@ consts << "TCP_MAXSEG" end consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end platform_is_not :windows do it 'defines SCM options' do - Socket::Constants.should have_constant('SCM_RIGHTS') + Socket::Constants.should.const_defined?('SCM_RIGHTS', false) end it 'defines error options' do @@ -101,7 +101,7 @@ end consts.each do |c| - Socket::Constants.should have_constant(c) + Socket::Constants.should.const_defined?(c, false) end end end diff --git a/spec/ruby/library/socket/ipsocket/addr_spec.rb b/spec/ruby/library/socket/ipsocket/addr_spec.rb index 199eb85ab71597..eb16a8efdfb64d 100644 --- a/spec/ruby/library/socket/ipsocket/addr_spec.rb +++ b/spec/ruby/library/socket/ipsocket/addr_spec.rb @@ -17,7 +17,7 @@ BasicSocket.do_not_reverse_lookup = false addrinfo = @socket.addr addrinfo[0].should == "AF_INET" - addrinfo[1].should be_kind_of(Integer) + addrinfo[1].should.is_a?(Integer) addrinfo[2].should == SocketSpecs.hostname addrinfo[3].should == "127.0.0.1" end @@ -27,7 +27,7 @@ BasicSocket.do_not_reverse_lookup = true addrinfo = @socket.addr addrinfo[0].should == "AF_INET" - addrinfo[1].should be_kind_of(Integer) + addrinfo[1].should.is_a?(Integer) addrinfo[2].should == "127.0.0.1" addrinfo[3].should == "127.0.0.1" end @@ -35,7 +35,7 @@ it "returns an address in the array if passed false" do addrinfo = @socket.addr(false) addrinfo[0].should == "AF_INET" - addrinfo[1].should be_kind_of(Integer) + addrinfo[1].should.is_a?(Integer) addrinfo[2].should == "127.0.0.1" addrinfo[3].should == "127.0.0.1" end @@ -81,7 +81,7 @@ describe 'using :cats as the argument' do it 'raises ArgumentError' do - -> { @server.addr(:cats) }.should raise_error(ArgumentError) + -> { @server.addr(:cats) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/library/socket/ipsocket/getaddress_spec.rb b/spec/ruby/library/socket/ipsocket/getaddress_spec.rb index 329f8267d3293d..d302cd6a8ae494 100644 --- a/spec/ruby/library/socket/ipsocket/getaddress_spec.rb +++ b/spec/ruby/library/socket/ipsocket/getaddress_spec.rb @@ -23,6 +23,6 @@ it "raises an error on unknown hostnames" do -> { IPSocket.getaddress("rubyspecdoesntexist.ruby-lang.org") - }.should raise_error(SocketError) + }.should.raise(SocketError) end end diff --git a/spec/ruby/library/socket/ipsocket/peeraddr_spec.rb b/spec/ruby/library/socket/ipsocket/peeraddr_spec.rb index 702650940bb52c..b79222000a9e47 100644 --- a/spec/ruby/library/socket/ipsocket/peeraddr_spec.rb +++ b/spec/ruby/library/socket/ipsocket/peeraddr_spec.rb @@ -18,7 +18,7 @@ it "raises error if socket is not connected" do -> { @server.peeraddr - }.should raise_error(Errno::ENOTCONN) + }.should.raise(Errno::ENOTCONN) end it "returns an array of information on the peer" do @@ -92,7 +92,7 @@ describe 'using :cats as the argument' do it 'raises ArgumentError' do - -> { @client.peeraddr(:cats) }.should raise_error(ArgumentError) + -> { @client.peeraddr(:cats) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/library/socket/ipsocket/recvfrom_spec.rb b/spec/ruby/library/socket/ipsocket/recvfrom_spec.rb index 5e6a145c9bdaeb..7af0078be13b7c 100644 --- a/spec/ruby/library/socket/ipsocket/recvfrom_spec.rb +++ b/spec/ruby/library/socket/ipsocket/recvfrom_spec.rb @@ -93,11 +93,11 @@ end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil @client.close - t.value.should be_nil + t.value.should == nil end end diff --git a/spec/ruby/library/socket/option/bool_spec.rb b/spec/ruby/library/socket/option/bool_spec.rb index 144a78043dcc94..9992e842b3fe9b 100644 --- a/spec/ruby/library/socket/option/bool_spec.rb +++ b/spec/ruby/library/socket/option/bool_spec.rb @@ -4,7 +4,7 @@ describe "Socket::Option.bool" do it "creates a new Socket::Option" do so = Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true) - so.should be_an_instance_of(Socket::Option) + so.should.instance_of?(Socket::Option) so.family.should == Socket::AF_INET so.level.should == Socket::SOL_SOCKET so.optname.should == Socket::SO_KEEPALIVE @@ -21,7 +21,7 @@ platform_is_not :windows do it 'raises TypeError when called on a non boolean option' do opt = Socket::Option.linger(1, 4) - -> { opt.bool }.should raise_error(TypeError) + -> { opt.bool }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/socket/option/initialize_spec.rb b/spec/ruby/library/socket/option/initialize_spec.rb index 8071ad7ef0c3a1..5af274f332aee3 100644 --- a/spec/ruby/library/socket/option/initialize_spec.rb +++ b/spec/ruby/library/socket/option/initialize_spec.rb @@ -10,7 +10,7 @@ opt = Socket::Option .new(Socket::AF_INET, Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, @bool) - opt.should be_an_instance_of(Socket::Option) + opt.should.instance_of?(Socket::Option) opt.family.should == Socket::AF_INET opt.level.should == Socket::SOL_SOCKET @@ -23,7 +23,7 @@ it 'returns a Socket::Option' do opt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, @bool) - opt.should be_an_instance_of(Socket::Option) + opt.should.instance_of?(Socket::Option) opt.family.should == Socket::AF_INET opt.level.should == Socket::SOL_SOCKET @@ -34,19 +34,19 @@ it 'raises when using an invalid address family' do -> { Socket::Option.new(:INET2, :SOCKET, :KEEPALIVE, @bool) - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises when using an invalid level' do -> { Socket::Option.new(:INET, :CATS, :KEEPALIVE, @bool) - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises when using an invalid option name' do -> { Socket::Option.new(:INET, :SOCKET, :CATS, @bool) - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -54,7 +54,7 @@ it 'returns a Socket::Option' do opt = Socket::Option.new('INET', 'SOCKET', 'KEEPALIVE', @bool) - opt.should be_an_instance_of(Socket::Option) + opt.should.instance_of?(Socket::Option) opt.family.should == Socket::AF_INET opt.level.should == Socket::SOL_SOCKET @@ -65,19 +65,19 @@ it 'raises when using an invalid address family' do -> { Socket::Option.new('INET2', 'SOCKET', 'KEEPALIVE', @bool) - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises when using an invalid level' do -> { Socket::Option.new('INET', 'CATS', 'KEEPALIVE', @bool) - }.should raise_error(SocketError) + }.should.raise(SocketError) end it 'raises when using an invalid option name' do -> { Socket::Option.new('INET', 'SOCKET', 'CATS', @bool) - }.should raise_error(SocketError) + }.should.raise(SocketError) end end end diff --git a/spec/ruby/library/socket/option/int_spec.rb b/spec/ruby/library/socket/option/int_spec.rb index 8c69ef6cbdfba5..0cd341f88a4740 100644 --- a/spec/ruby/library/socket/option/int_spec.rb +++ b/spec/ruby/library/socket/option/int_spec.rb @@ -4,7 +4,7 @@ describe "Socket::Option.int" do it "creates a new Socket::Option" do so = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 5) - so.should be_an_instance_of(Socket::Option) + so.should.instance_of?(Socket::Option) so.family.should == Socket::Constants::AF_INET so.level.should == Socket::Constants::SOL_SOCKET so.optname.should == Socket::Constants::SO_KEEPALIVE @@ -14,7 +14,7 @@ it 'returns a Socket::Option' do opt = Socket::Option.int(:INET, :IP, :TTL, 4) - opt.should be_an_instance_of(Socket::Option) + opt.should.instance_of?(Socket::Option) opt.family.should == Socket::AF_INET opt.level.should == Socket::IPPROTO_IP @@ -37,7 +37,7 @@ platform_is_not :windows do it 'raises TypeError when called on a non integer option' do opt = Socket::Option.linger(1, 4) - -> { opt.int }.should raise_error(TypeError) + -> { opt.int }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/socket/option/linger_spec.rb b/spec/ruby/library/socket/option/linger_spec.rb index ee987db85b7628..87c5e0982ef22d 100644 --- a/spec/ruby/library/socket/option/linger_spec.rb +++ b/spec/ruby/library/socket/option/linger_spec.rb @@ -9,7 +9,7 @@ describe "Socket::Option.linger" do it "creates a new Socket::Option for SO_LINGER" do so = Socket::Option.linger(1, 10) - so.should be_an_instance_of(Socket::Option) + so.should.instance_of?(Socket::Option) so.family.should == Socket::Constants::AF_UNSPEC so.level.should == Socket::Constants::SOL_SOCKET @@ -31,46 +31,46 @@ it "returns linger option" do so = Socket::Option.linger(0, 5) ary = so.linger - ary[0].should be_false + ary[0].should == false ary[1].should == 5 so = Socket::Option.linger(false, 4) ary = so.linger - ary[0].should be_false + ary[0].should == false ary[1].should == 4 so = Socket::Option.linger(1, 10) ary = so.linger - ary[0].should be_true + ary[0].should == true ary[1].should == 10 so = Socket::Option.linger(true, 9) ary = so.linger - ary[0].should be_true + ary[0].should == true ary[1].should == 9 end it "raises TypeError if not a SO_LINGER" do so = Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :KEEPALIVE, 1) - -> { so.linger }.should raise_error(TypeError) + -> { so.linger }.should.raise(TypeError) end it 'raises TypeError when called on a non SOL_SOCKET/SO_LINGER option' do opt = Socket::Option.int(:INET, :IP, :TTL, 4) - -> { opt.linger }.should raise_error(TypeError) + -> { opt.linger }.should.raise(TypeError) end platform_is_not :windows do it "raises TypeError if option has not good size" do so = Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1) - -> { so.linger }.should raise_error(TypeError) + -> { so.linger }.should.raise(TypeError) end end it 'raises TypeError when called on a non linger option' do opt = Socket::Option.new(:INET, :SOCKET, :LINGER, '') - -> { opt.linger }.should raise_error(TypeError) + -> { opt.linger }.should.raise(TypeError) end end diff --git a/spec/ruby/library/socket/option/new_spec.rb b/spec/ruby/library/socket/option/new_spec.rb index a9e6f09097b3c2..3721d63ee545a7 100644 --- a/spec/ruby/library/socket/option/new_spec.rb +++ b/spec/ruby/library/socket/option/new_spec.rb @@ -22,14 +22,14 @@ end it "should raise error on unknown family" do - -> { Socket::Option.new(:INET4, :SOCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError) + -> { Socket::Option.new(:INET4, :SOCKET, :KEEPALIVE, [0].pack('i')) }.should.raise(SocketError) end it "should raise error on unknown level" do - -> { Socket::Option.new(:INET, :ROCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError) + -> { Socket::Option.new(:INET, :ROCKET, :KEEPALIVE, [0].pack('i')) }.should.raise(SocketError) end it "should raise error on unknown option name" do - -> { Socket::Option.new(:INET, :SOCKET, :ALIVE, [0].pack('i')) }.should raise_error(SocketError) + -> { Socket::Option.new(:INET, :SOCKET, :ALIVE, [0].pack('i')) }.should.raise(SocketError) end end diff --git a/spec/ruby/library/socket/shared/address.rb b/spec/ruby/library/socket/shared/address.rb index 49ba17c400061e..c64602df2f37a0 100644 --- a/spec/ruby/library/socket/shared/address.rb +++ b/spec/ruby/library/socket/shared/address.rb @@ -46,7 +46,7 @@ end it 'returns an Addrinfo' do - @addr.should be_an_instance_of(Addrinfo) + @addr.should.instance_of?(Addrinfo) end it 'uses 0 as the protocol' do @@ -110,7 +110,7 @@ end it 'returns an Addrinfo' do - @addr.should be_an_instance_of(Addrinfo) + @addr.should.instance_of?(Addrinfo) end it 'uses 0 as the protocol' do @@ -184,7 +184,7 @@ end it 'returns an Addrinfo' do - @addr.should be_an_instance_of(Addrinfo) + @addr.should.instance_of?(Addrinfo) end it 'uses 0 as the protocol' do @@ -240,7 +240,7 @@ end it 'returns an Addrinfo' do - @addr.should be_an_instance_of(Addrinfo) + @addr.should.instance_of?(Addrinfo) end it 'uses 0 as the protocol' do diff --git a/spec/ruby/library/socket/shared/pack_sockaddr.rb b/spec/ruby/library/socket/shared/pack_sockaddr.rb index 4bfcf4edb9d908..db6f39612d08aa 100644 --- a/spec/ruby/library/socket/shared/pack_sockaddr.rb +++ b/spec/ruby/library/socket/shared/pack_sockaddr.rb @@ -31,7 +31,7 @@ it 'returns a String of 16 bytes' do str = Socket.public_send(@method, 80, '127.0.0.1') - str.should be_an_instance_of(String) + str.should.instance_of?(String) str.bytesize.should == 16 end end @@ -40,7 +40,7 @@ it 'returns a String of 28 bytes' do str = Socket.public_send(@method, 80, '::1') - str.should be_an_instance_of(String) + str.should.instance_of?(String) str.bytesize.should == 28 end end @@ -68,7 +68,7 @@ it 'returns a String of 110 bytes' do str = Socket.public_send(@method, '/tmp/test.sock') - str.should be_an_instance_of(String) + str.should.instance_of?(String) str.bytesize.should == 110 end end @@ -77,7 +77,7 @@ it 'returns a String of 106 bytes' do str = Socket.public_send(@method, '/tmp/test.sock') - str.should be_an_instance_of(String) + str.should.instance_of?(String) str.bytesize.should == 106 end end @@ -86,7 +86,7 @@ it "raises ArgumentError for paths that are too long" do # AIX doesn't raise error long_path = 'a' * 110 - -> { Socket.public_send(@method, long_path) }.should raise_error(ArgumentError) + -> { Socket.public_send(@method, long_path) }.should.raise(ArgumentError) end end end diff --git a/spec/ruby/library/socket/shared/socketpair.rb b/spec/ruby/library/socket/shared/socketpair.rb index 25146cfff6aec8..7fcd4d6b46b95b 100644 --- a/spec/ruby/library/socket/shared/socketpair.rb +++ b/spec/ruby/library/socket/shared/socketpair.rb @@ -12,8 +12,8 @@ begin s1, s2 = Socket.public_send(@method, :UNIX, :STREAM) - s1.should be_an_instance_of(Socket) - s2.should be_an_instance_of(Socket) + s1.should.instance_of?(Socket) + s2.should.instance_of?(Socket) ensure s1.close s2.close @@ -24,8 +24,8 @@ it 'returns two Socket objects' do s1, s2 = Socket.public_send(@method, Socket::AF_UNIX, Socket::SOCK_STREAM) - s1.should be_an_instance_of(Socket) - s2.should be_an_instance_of(Socket) + s1.should.instance_of?(Socket) + s2.should.instance_of?(Socket) s1.close s2.close end @@ -35,18 +35,18 @@ it 'returns two Socket objects' do s1, s2 = Socket.public_send(@method, :UNIX, :STREAM) - s1.should be_an_instance_of(Socket) - s2.should be_an_instance_of(Socket) + s1.should.instance_of?(Socket) + s2.should.instance_of?(Socket) s1.close s2.close end it 'raises SocketError for an unknown address family' do - -> { Socket.public_send(@method, :CATS, :STREAM) }.should raise_error(SocketError) + -> { Socket.public_send(@method, :CATS, :STREAM) }.should.raise(SocketError) end it 'raises SocketError for an unknown socket type' do - -> { Socket.public_send(@method, :UNIX, :CATS) }.should raise_error(SocketError) + -> { Socket.public_send(@method, :UNIX, :CATS) }.should.raise(SocketError) end end @@ -54,18 +54,18 @@ it 'returns two Socket objects' do s1, s2 = Socket.public_send(@method, 'UNIX', 'STREAM') - s1.should be_an_instance_of(Socket) - s2.should be_an_instance_of(Socket) + s1.should.instance_of?(Socket) + s2.should.instance_of?(Socket) s1.close s2.close end it 'raises SocketError for an unknown address family' do - -> { Socket.public_send(@method, 'CATS', 'STREAM') }.should raise_error(SocketError) + -> { Socket.public_send(@method, 'CATS', 'STREAM') }.should.raise(SocketError) end it 'raises SocketError for an unknown socket type' do - -> { Socket.public_send(@method, 'UNIX', 'CATS') }.should raise_error(SocketError) + -> { Socket.public_send(@method, 'UNIX', 'CATS') }.should.raise(SocketError) end end @@ -79,8 +79,8 @@ s1, s2 = Socket.public_send(@method, family, type) - s1.should be_an_instance_of(Socket) - s2.should be_an_instance_of(Socket) + s1.should.instance_of?(Socket) + s2.should.instance_of?(Socket) s1.close s2.close end @@ -92,7 +92,7 @@ family.stub!(:to_str).and_return(Socket::AF_UNIX) type.stub!(:to_str).and_return(Socket::SOCK_STREAM) - -> { Socket.public_send(@method, family, type) }.should raise_error(TypeError) + -> { Socket.public_send(@method, family, type) }.should.raise(TypeError) end it 'raises SocketError for an unknown address family' do @@ -102,7 +102,7 @@ family.stub!(:to_str).and_return('CATS') type.stub!(:to_str).and_return('STREAM') - -> { Socket.public_send(@method, family, type) }.should raise_error(SocketError) + -> { Socket.public_send(@method, family, type) }.should.raise(SocketError) end it 'raises SocketError for an unknown socket type' do @@ -112,14 +112,14 @@ family.stub!(:to_str).and_return('UNIX') type.stub!(:to_str).and_return('CATS') - -> { Socket.public_send(@method, family, type) }.should raise_error(SocketError) + -> { Socket.public_send(@method, family, type) }.should.raise(SocketError) end end it 'accepts a custom protocol as an Integer as the 3rd argument' do s1, s2 = Socket.public_send(@method, :UNIX, :STREAM, Socket::IPPROTO_IP) - s1.should be_an_instance_of(Socket) - s2.should be_an_instance_of(Socket) + s1.should.instance_of?(Socket) + s2.should.instance_of?(Socket) s1.close s2.close end diff --git a/spec/ruby/library/socket/socket/accept_loop_spec.rb b/spec/ruby/library/socket/socket/accept_loop_spec.rb index 78e8c3fa4af965..6c65b192edd33c 100644 --- a/spec/ruby/library/socket/socket/accept_loop_spec.rb +++ b/spec/ruby/library/socket/socket/accept_loop_spec.rb @@ -41,8 +41,8 @@ end begin - conn.should be_an_instance_of(Socket) - addr.should be_an_instance_of(Addrinfo) + conn.should.instance_of?(Socket) + addr.should.instance_of?(Addrinfo) ensure conn.close end @@ -73,8 +73,8 @@ end begin - conn.should be_an_instance_of(Socket) - addr.should be_an_instance_of(Addrinfo) + conn.should.instance_of?(Socket) + addr.should.instance_of?(Addrinfo) ensure conn.close end diff --git a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb index 011622988c4dac..09cdbaa7b40a30 100644 --- a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb +++ b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb @@ -17,12 +17,12 @@ it "raises IO::WaitReadable if the connection is not accepted yet" do -> { @socket.accept_nonblock - }.should raise_error(IO::WaitReadable) { |e| + }.should.raise(IO::WaitReadable) { |e| platform_is_not :windows do - e.should be_kind_of(Errno::EAGAIN) + e.should.is_a?(Errno::EAGAIN) end platform_is :windows do - e.should be_kind_of(Errno::EWOULDBLOCK) + e.should.is_a?(Errno::EWOULDBLOCK) end } end @@ -45,8 +45,8 @@ 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) + -> { @server.accept_nonblock }.should.raise(Errno::EINVAL) + -> { @server.accept_nonblock(exception: false) }.should.raise(Errno::EINVAL) end end @@ -56,8 +56,8 @@ end it 'raises Errno::EINVAL' do - -> { @server.accept_nonblock }.should raise_error(Errno::EINVAL) - -> { @server.accept_nonblock(exception: false) }.should raise_error(Errno::EINVAL) + -> { @server.accept_nonblock }.should.raise(Errno::EINVAL) + -> { @server.accept_nonblock(exception: false) }.should.raise(Errno::EINVAL) end end @@ -65,8 +65,8 @@ it 'raises IOError' do @server.close - -> { @server.accept_nonblock }.should raise_error(IOError) - -> { @server.accept_nonblock(exception: false) }.should raise_error(IOError) + -> { @server.accept_nonblock }.should.raise(IOError) + -> { @server.accept_nonblock(exception: false) }.should.raise(IOError) end end @@ -78,7 +78,7 @@ describe 'without a connected client' do it 'raises IO::WaitReadable' do - -> { @server.accept_nonblock }.should raise_error(IO::WaitReadable) + -> { @server.accept_nonblock }.should.raise(IO::WaitReadable) end end @@ -100,8 +100,8 @@ IO.select([@server]) @socket, addrinfo = @server.accept_nonblock - @socket.should be_an_instance_of(Socket) - addrinfo.should be_an_instance_of(Addrinfo) + @socket.should.instance_of?(Socket) + addrinfo.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/socket/accept_spec.rb b/spec/ruby/library/socket/socket/accept_spec.rb index 417f996c550b4d..fca727ab08ad25 100644 --- a/spec/ruby/library/socket/socket/accept_spec.rb +++ b/spec/ruby/library/socket/socket/accept_spec.rb @@ -15,7 +15,7 @@ platform_is :linux do # hangs on other platforms describe 'using an unbound socket' do it 'raises Errno::EINVAL' do - -> { @server.accept }.should raise_error(Errno::EINVAL) + -> { @server.accept }.should.raise(Errno::EINVAL) end end @@ -25,7 +25,7 @@ end it 'raises Errno::EINVAL' do - -> { @server.accept }.should raise_error(Errno::EINVAL) + -> { @server.accept }.should.raise(Errno::EINVAL) end end end @@ -34,7 +34,7 @@ it 'raises IOError' do @server.close - -> { @server.accept }.should raise_error(IOError) + -> { @server.accept }.should.raise(IOError) end end @@ -58,7 +58,7 @@ value = thread.value begin - value.should be_an_instance_of(Array) + value.should.instance_of?(Array) ensure client.close value[0].close @@ -82,8 +82,8 @@ it 'returns an Array containing a Socket and an Addrinfo' do @socket, addrinfo = @server.accept - @socket.should be_an_instance_of(Socket) - addrinfo.should be_an_instance_of(Addrinfo) + @socket.should.instance_of?(Socket) + addrinfo.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/socket/bind_spec.rb b/spec/ruby/library/socket/socket/bind_spec.rb index e76336eafac36d..164df92205ae27 100644 --- a/spec/ruby/library/socket/socket/bind_spec.rb +++ b/spec/ruby/library/socket/socket/bind_spec.rb @@ -8,12 +8,12 @@ end after :each do - @sock.closed?.should be_false + @sock.closed?.should == false @sock.close end it "binds to a port" do - -> { @sock.bind(@sockaddr) }.should_not raise_error + -> { @sock.bind(@sockaddr) }.should_not.raise end it "returns 0 if successful" do @@ -23,12 +23,12 @@ it "raises Errno::EINVAL when already bound" do @sock.bind(@sockaddr) - -> { @sock.bind(@sockaddr) }.should raise_error(Errno::EINVAL) + -> { @sock.bind(@sockaddr) }.should.raise(Errno::EINVAL) end it "raises Errno::EADDRNOTAVAIL when the specified sockaddr is not available from the local machine" do sockaddr1 = Socket.pack_sockaddr_in(0, "4.3.2.1") - -> { @sock.bind(sockaddr1) }.should raise_error(Errno::EADDRNOTAVAIL) + -> { @sock.bind(sockaddr1) }.should.raise(Errno::EADDRNOTAVAIL) end platform_is_not :windows, :cygwin do @@ -36,7 +36,7 @@ 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) + -> { @sock.bind(sockaddr1) }.should.raise(Errno::EACCES) end end end @@ -50,12 +50,12 @@ end after :each do - @sock.closed?.should be_false + @sock.closed?.should == false @sock.close end it "binds to a port" do - -> { @sock.bind(@sockaddr) }.should_not raise_error + -> { @sock.bind(@sockaddr) }.should_not.raise end it "returns 0 if successful" do @@ -65,12 +65,12 @@ it "raises Errno::EINVAL when already bound" do @sock.bind(@sockaddr) - -> { @sock.bind(@sockaddr) }.should raise_error(Errno::EINVAL) + -> { @sock.bind(@sockaddr) }.should.raise(Errno::EINVAL) end it "raises Errno::EADDRNOTAVAIL when the specified sockaddr is not available from the local machine" do sockaddr1 = Socket.pack_sockaddr_in(0, "4.3.2.1") - -> { @sock.bind(sockaddr1) }.should raise_error(Errno::EADDRNOTAVAIL) + -> { @sock.bind(sockaddr1) }.should.raise(Errno::EADDRNOTAVAIL) end platform_is_not :windows, :cygwin do @@ -78,7 +78,7 @@ 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) + -> { @sock.bind(sockaddr1) }.should.raise(Errno::EACCES) end end end @@ -103,14 +103,14 @@ it 'raises Errno::EINVAL when binding to an already bound port' do @socket.bind(@sockaddr) - -> { @socket.bind(@sockaddr) }.should raise_error(Errno::EINVAL) + -> { @socket.bind(@sockaddr) }.should.raise(Errno::EINVAL) end it 'raises Errno::EADDRNOTAVAIL when the specified sockaddr is not available' do ip = family == Socket::AF_INET ? '4.3.2.1' : '::2' sockaddr1 = Socket.sockaddr_in(0, ip) - -> { @socket.bind(sockaddr1) }.should raise_error(Errno::EADDRNOTAVAIL) + -> { @socket.bind(sockaddr1) }.should.raise(Errno::EADDRNOTAVAIL) end platform_is_not :windows do @@ -120,7 +120,7 @@ it 'raises Errno::EACCES when the user is not allowed to bind to the port' do sockaddr1 = Socket.pack_sockaddr_in(1, ip_address) - -> { @socket.bind(sockaddr1) }.should raise_error(Errno::EACCES) + -> { @socket.bind(sockaddr1) }.should.raise(Errno::EACCES) end end end @@ -138,7 +138,7 @@ it 'binds to an Addrinfo' do @socket.bind(@addr).should == 0 - @socket.local_address.should be_an_instance_of(Addrinfo) + @socket.local_address.should.instance_of?(Addrinfo) end it 'uses a new Addrinfo for the local address' do diff --git a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb index 359b8719fb06af..dac24e3e5b4ad6 100644 --- a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb +++ b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb @@ -53,13 +53,13 @@ it "raises Errno::EINPROGRESS when the connect would block" do -> do @socket.connect_nonblock(@addr) - end.should raise_error(Errno::EINPROGRESS) + end.should.raise(Errno::EINPROGRESS) end it "raises Errno::EINPROGRESS with IO::WaitWritable mixed in when the connect would block" do -> do @socket.connect_nonblock(@addr) - end.should raise_error(IO::WaitWritable) + end.should.raise(IO::WaitWritable) end it "returns :wait_writable in exceptionless mode when the connect would block" do @@ -93,7 +93,7 @@ end it 'raises TypeError when passed an Integer' do - -> { @client.connect_nonblock(666) }.should raise_error(TypeError) + -> { @client.connect_nonblock(666) }.should.raise(TypeError) end end @@ -122,7 +122,7 @@ # as it's too implementation-dependent and checking for connect() # errors is futile anyways because of TOCTOU @client.connect_nonblock(@server.connect_address) - }.should raise_error(Errno::EISCONN) + }.should.raise(Errno::EISCONN) end it 'returns 0 when already connected in exceptionless mode' do @@ -139,7 +139,7 @@ -> { @client.connect_nonblock(@server.connect_address) - }.should raise_error(IO::EINPROGRESSWaitWritable) + }.should.raise(IO::EINPROGRESSWaitWritable) end end end diff --git a/spec/ruby/library/socket/socket/connect_spec.rb b/spec/ruby/library/socket/socket/connect_spec.rb index 130379ce2b5ebf..c928b66c535f0e 100644 --- a/spec/ruby/library/socket/socket/connect_spec.rb +++ b/spec/ruby/library/socket/socket/connect_spec.rb @@ -40,7 +40,7 @@ # as it's too implementation-dependent and checking for connect() # errors is futile anyways because of TOCTOU @client.connect(@server.getsockname) - }.should raise_error(Errno::EISCONN) + }.should.raise(Errno::EISCONN) end platform_is_not :darwin do @@ -70,7 +70,7 @@ rescue Errno::ENETUNREACH skip "Off line" end - }.should raise_error(IO::TimeoutError) + }.should.raise(IO::TimeoutError) ensure client.close end diff --git a/spec/ruby/library/socket/socket/getaddrinfo_spec.rb b/spec/ruby/library/socket/socket/getaddrinfo_spec.rb index 17ffeaccaf498b..7e5bdc9b255e57 100644 --- a/spec/ruby/library/socket/socket/getaddrinfo_spec.rb +++ b/spec/ruby/library/socket/socket/getaddrinfo_spec.rb @@ -43,7 +43,7 @@ addrinfo.each do |a| case a.last when Socket::IPPROTO_UDP, Socket::IPPROTO_TCP - expected.should include(a) + expected.should.include?(a) else # don't check this. It's some weird protocol we don't know about # so we can't spec it. @@ -90,7 +90,7 @@ ["AF_INET6", 9, "::", "::", Socket::AF_INET6, Socket::SOCK_STREAM, Socket::IPPROTO_TCP], ["AF_INET6", 9, "0:0:0:0:0:0:0:0", "0:0:0:0:0:0:0:0", Socket::AF_INET6, Socket::SOCK_STREAM, Socket::IPPROTO_TCP] ] - res.each { |a| expected.should include(a) } + res.each { |a| expected.should.include?(a) } end it "accepts empty addresses for IPv6 non-passive sockets" do @@ -104,13 +104,13 @@ ["AF_INET6", 9, "::1", "::1", Socket::AF_INET6, Socket::SOCK_STREAM, Socket::IPPROTO_TCP], ["AF_INET6", 9, "0:0:0:0:0:0:0:1", "0:0:0:0:0:0:0:1", Socket::AF_INET6, Socket::SOCK_STREAM, Socket::IPPROTO_TCP] ] - res.each { |a| expected.should include(a) } + res.each { |a| expected.should.include?(a) } end it "raises ResolutionError when fails to resolve address" do -> { Socket.getaddrinfo("www.kame.net", 80, "AF_UNIX") - }.should raise_error(Socket::ResolutionError) { |e| + }.should.raise(Socket::ResolutionError) { |e| [Socket::EAI_FAMILY, Socket::EAI_FAIL].should.include?(e.error_code) } end @@ -120,7 +120,7 @@ describe 'Socket.getaddrinfo' do describe 'without global reverse lookups' do it 'returns an Array' do - Socket.getaddrinfo(nil, 'ftp').should be_an_instance_of(Array) + Socket.getaddrinfo(nil, 'ftp').should.instance_of?(Array) end it 'accepts an Integer as the address family' do @@ -131,8 +131,8 @@ array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_kind_of(Integer) - array[6].should be_kind_of(Integer) + array[5].should.is_a?(Integer) + array[6].should.is_a?(Integer) end it 'accepts an Integer as the address family using IPv6' do @@ -143,8 +143,8 @@ array[2].should == '::1' array[3].should == '::1' array[4].should == Socket::AF_INET6 - array[5].should be_kind_of(Integer) - array[6].should be_kind_of(Integer) + array[5].should.is_a?(Integer) + array[6].should.is_a?(Integer) end it 'accepts a Symbol as the address family' do @@ -155,8 +155,8 @@ array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_kind_of(Integer) - array[6].should be_kind_of(Integer) + array[5].should.is_a?(Integer) + array[6].should.is_a?(Integer) end it 'accepts a Symbol as the address family using IPv6' do @@ -167,8 +167,8 @@ array[2].should == '::1' array[3].should == '::1' array[4].should == Socket::AF_INET6 - array[5].should be_kind_of(Integer) - array[6].should be_kind_of(Integer) + array[5].should.is_a?(Integer) + array[6].should.is_a?(Integer) end it 'accepts a String as the address family' do @@ -179,8 +179,8 @@ array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_kind_of(Integer) - array[6].should be_kind_of(Integer) + array[5].should.is_a?(Integer) + array[6].should.is_a?(Integer) end it 'accepts a String as the address family using IPv6' do @@ -191,8 +191,8 @@ array[2].should == '::1' array[3].should == '::1' array[4].should == Socket::AF_INET6 - array[5].should be_kind_of(Integer) - array[6].should be_kind_of(Integer) + array[5].should.is_a?(Integer) + array[6].should.is_a?(Integer) end it 'accepts an object responding to #to_str as the host' do @@ -207,8 +207,8 @@ array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_kind_of(Integer) - array[6].should be_kind_of(Integer) + array[5].should.is_a?(Integer) + array[6].should.is_a?(Integer) end it 'accepts an object responding to #to_str as the address family' do @@ -223,8 +223,8 @@ array[2].should == '127.0.0.1' array[3].should == '127.0.0.1' array[4].should == Socket::AF_INET - array[5].should be_kind_of(Integer) - array[6].should be_kind_of(Integer) + array[5].should.is_a?(Integer) + array[6].should.is_a?(Integer) end it 'accepts an Integer as the socket type' do @@ -237,7 +237,7 @@ Socket::AF_INET, Socket::SOCK_STREAM, ] - [0, Socket::IPPROTO_TCP].should include(proto) + [0, Socket::IPPROTO_TCP].should.include?(proto) end it 'accepts a Symbol as the socket type' do @@ -250,7 +250,7 @@ Socket::AF_INET, Socket::SOCK_STREAM, ] - [0, Socket::IPPROTO_TCP].should include(proto) + [0, Socket::IPPROTO_TCP].should.include?(proto) end it 'accepts a String as the socket type' do @@ -263,7 +263,7 @@ Socket::AF_INET, Socket::SOCK_STREAM, ] - [0, Socket::IPPROTO_TCP].should include(proto) + [0, Socket::IPPROTO_TCP].should.include?(proto) end it 'accepts an object responding to #to_str as the socket type' do @@ -280,7 +280,7 @@ Socket::AF_INET, Socket::SOCK_STREAM, ] - [0, Socket::IPPROTO_TCP].should include(proto) + [0, Socket::IPPROTO_TCP].should.include?(proto) end platform_is_not :windows do @@ -294,7 +294,7 @@ Socket::AF_INET, Socket::SOCK_DGRAM, ] - [0, Socket::IPPROTO_UDP].should include(proto) + [0, Socket::IPPROTO_UDP].should.include?(proto) end end @@ -309,7 +309,7 @@ Socket::AF_INET, Socket::SOCK_STREAM, ] - [0, Socket::IPPROTO_TCP].should include(proto) + [0, Socket::IPPROTO_TCP].should.include?(proto) end it 'performs a reverse lookup when the reverse_lookup argument is true' do @@ -319,7 +319,7 @@ addr[0].should == 'AF_INET' addr[1].should == 21 - addr[2].should be_an_instance_of(String) + addr[2].should.instance_of?(String) addr[2].should_not == addr[3] addr[3].should == '127.0.0.1' @@ -332,7 +332,7 @@ addr[0].should == 'AF_INET' addr[1].should == 21 - addr[2].should be_an_instance_of(String) + addr[2].should.instance_of?(String) addr[2].should_not == addr[3] addr[3].should == '127.0.0.1' @@ -349,7 +349,7 @@ Socket::AF_INET, Socket::SOCK_STREAM, ] - [0, Socket::IPPROTO_TCP].should include(proto) + [0, Socket::IPPROTO_TCP].should.include?(proto) end end @@ -372,7 +372,7 @@ # We don't have control over this value and there's no way to test this # without relying on Socket.getaddrinfo()'s own behaviour (meaning this # test would faily any way of the method was not implemented correctly). - addr[2].should be_an_instance_of(String) + addr[2].should.instance_of?(String) addr[2].should_not == addr[3] addr[3].should == '127.0.0.1' diff --git a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb index 5d936046f5cb1a..bf6d63dbe95c8d 100644 --- a/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb +++ b/spec/ruby/library/socket/socket/gethostbyaddr_spec.rb @@ -10,7 +10,7 @@ describe 'without an explicit address family' do it 'returns an Array' do - suppress_warning { Socket.gethostbyaddr(@addr) }.should be_an_instance_of(Array) + suppress_warning { Socket.gethostbyaddr(@addr) }.should.instance_of?(Array) end describe 'the returned Array' do @@ -23,10 +23,10 @@ end it 'includes the aliases as the 2nd value' do - @array[1].should be_an_instance_of(Array) + @array[1].should.instance_of?(Array) @array[1].each do |val| - val.should be_an_instance_of(String) + val.should.instance_of?(String) end end @@ -38,7 +38,7 @@ @array[3].should == @addr @array[4..-1].each do |val| - val.should be_an_instance_of(String) + val.should.instance_of?(String) end end end @@ -46,15 +46,15 @@ describe 'with an explicit address family' do it 'returns an Array when using an Integer as the address family' do - suppress_warning { Socket.gethostbyaddr(@addr, Socket::AF_INET) }.should be_an_instance_of(Array) + suppress_warning { Socket.gethostbyaddr(@addr, Socket::AF_INET) }.should.instance_of?(Array) end it 'returns an Array when using a Symbol as the address family' do - suppress_warning { Socket.gethostbyaddr(@addr, :INET) }.should be_an_instance_of(Array) + suppress_warning { Socket.gethostbyaddr(@addr, :INET) }.should.instance_of?(Array) end it 'raises SocketError when the address is not supported by the family' do - -> { suppress_warning { Socket.gethostbyaddr(@addr, :INET6) } }.should raise_error(SocketError) + -> { suppress_warning { Socket.gethostbyaddr(@addr, :INET6) } }.should.raise(SocketError) end end end @@ -67,7 +67,7 @@ describe 'without an explicit address family' do it 'returns an Array' do - suppress_warning { Socket.gethostbyaddr(@addr) }.should be_an_instance_of(Array) + suppress_warning { Socket.gethostbyaddr(@addr) }.should.instance_of?(Array) end describe 'the returned Array' do @@ -80,10 +80,10 @@ end it 'includes the aliases as the 2nd value' do - @array[1].should be_an_instance_of(Array) + @array[1].should.instance_of?(Array) @array[1].each do |val| - val.should be_an_instance_of(String) + val.should.instance_of?(String) end end @@ -92,10 +92,10 @@ end it 'includes all address strings as the remaining values' do - @array[3].should be_an_instance_of(String) + @array[3].should.instance_of?(String) @array[4..-1].each do |val| - val.should be_an_instance_of(String) + val.should.instance_of?(String) end end end @@ -103,16 +103,16 @@ describe 'with an explicit address family' do it 'returns an Array when using an Integer as the address family' do - suppress_warning { Socket.gethostbyaddr(@addr, Socket::AF_INET6) }.should be_an_instance_of(Array) + suppress_warning { Socket.gethostbyaddr(@addr, Socket::AF_INET6) }.should.instance_of?(Array) end it 'returns an Array when using a Symbol as the address family' do - suppress_warning { Socket.gethostbyaddr(@addr, :INET6) }.should be_an_instance_of(Array) + suppress_warning { Socket.gethostbyaddr(@addr, :INET6) }.should.instance_of?(Array) end platform_is_not :windows, :wsl do it 'raises SocketError when the address is not supported by the family' do - -> { suppress_warning { Socket.gethostbyaddr(@addr, :INET) } }.should raise_error(SocketError) + -> { suppress_warning { Socket.gethostbyaddr(@addr, :INET) } }.should.raise(SocketError) end end end diff --git a/spec/ruby/library/socket/socket/gethostbyname_spec.rb b/spec/ruby/library/socket/socket/gethostbyname_spec.rb index 618ef853877911..326fe26094053c 100644 --- a/spec/ruby/library/socket/socket/gethostbyname_spec.rb +++ b/spec/ruby/library/socket/socket/gethostbyname_spec.rb @@ -16,7 +16,7 @@ describe 'Socket.gethostbyname' do it 'returns an Array' do - suppress_warning { Socket.gethostbyname('127.0.0.1') }.should be_an_instance_of(Array) + suppress_warning { Socket.gethostbyname('127.0.0.1') }.should.instance_of?(Array) end describe 'the returned Array' do @@ -29,10 +29,10 @@ end it 'includes the aliases as the 2nd value' do - @array[1].should be_an_instance_of(Array) + @array[1].should.instance_of?(Array) @array[1].each do |val| - val.should be_an_instance_of(String) + val.should.instance_of?(String) end end @@ -43,10 +43,10 @@ end it 'includes the address strings as the remaining values' do - @array[3].should be_an_instance_of(String) + @array[3].should.instance_of?(String) @array[4..-1].each do |val| - val.should be_an_instance_of(String) + val.should.instance_of?(String) end end end diff --git a/spec/ruby/library/socket/socket/getifaddrs_spec.rb b/spec/ruby/library/socket/socket/getifaddrs_spec.rb index 839854ea2711fc..1b326605c8b3aa 100644 --- a/spec/ruby/library/socket/socket/getifaddrs_spec.rb +++ b/spec/ruby/library/socket/socket/getifaddrs_spec.rb @@ -7,17 +7,17 @@ end it 'returns an Array' do - @ifaddrs.should be_an_instance_of(Array) + @ifaddrs.should.instance_of?(Array) end describe 'the returned Array' do it 'should not be empty' do - @ifaddrs.should_not be_empty + @ifaddrs.should_not.empty? end it 'contains instances of Socket::Ifaddr' do @ifaddrs.each do |ifaddr| - ifaddr.should be_an_instance_of(Socket::Ifaddr) + ifaddr.should.instance_of?(Socket::Ifaddr) end end end @@ -25,19 +25,19 @@ describe 'each returned Socket::Ifaddr' do it 'has an interface index' do @ifaddrs.each do |ifaddr| - ifaddr.ifindex.should be_kind_of(Integer) + ifaddr.ifindex.should.is_a?(Integer) end end it 'has an interface name' do @ifaddrs.each do |ifaddr| - ifaddr.name.should be_an_instance_of(String) + ifaddr.name.should.instance_of?(String) end end it 'has a set of flags' do @ifaddrs.each do |ifaddr| - ifaddr.flags.should be_kind_of(Integer) + ifaddr.flags.should.is_a?(Integer) end end end @@ -49,17 +49,17 @@ it 'is an Addrinfo' do @addrs.all? do |addr| - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) true - end.should be_true + end.should == true end it 'has an address family' do @addrs.all? do |addr| - addr.afamily.should be_kind_of(Integer) + addr.afamily.should.is_a?(Integer) addr.afamily.should_not == Socket::AF_UNSPEC true - end.should be_true + end.should == true end end @@ -71,17 +71,17 @@ it 'is an Addrinfo' do @addrs.all? do |addr| - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) true - end.should be_true + end.should == true end it 'has an address family' do @addrs.all? do |addr| - addr.afamily.should be_kind_of(Integer) + addr.afamily.should.is_a?(Integer) addr.afamily.should_not == Socket::AF_UNSPEC true - end.should be_true + end.should == true end end @@ -92,24 +92,24 @@ it 'is an Addrinfo' do @addrs.all? do |addr| - addr.should be_an_instance_of(Addrinfo) + addr.should.instance_of?(Addrinfo) true - end.should be_true + end.should == true end it 'has an address family' do @addrs.all? do |addr| - addr.afamily.should be_kind_of(Integer) + addr.afamily.should.is_a?(Integer) addr.afamily.should_not == Socket::AF_UNSPEC true - end.should be_true + end.should == true end it 'has an IP address' do @addrs.all? do |addr| - addr.ip_address.should be_an_instance_of(String) + addr.ip_address.should.instance_of?(String) true - end.should be_true + end.should == true end end end diff --git a/spec/ruby/library/socket/socket/getnameinfo_spec.rb b/spec/ruby/library/socket/socket/getnameinfo_spec.rb index 48cc94bcd182ab..d0b77004de6c70 100644 --- a/spec/ruby/library/socket/socket/getnameinfo_spec.rb +++ b/spec/ruby/library/socket/socket/getnameinfo_spec.rb @@ -64,7 +64,7 @@ def should_be_valid_dns_name(name) it "raises ResolutionError when fails to resolve address" do -> { Socket.getnameinfo(["AF_UNIX", 80, "0.0.0.0"]) - }.should raise_error(Socket::ResolutionError) { |e| + }.should.raise(Socket::ResolutionError) { |e| [Socket::EAI_FAMILY, Socket::EAI_FAIL].should.include?(e.error_code) } end @@ -77,7 +77,7 @@ def should_be_valid_dns_name(name) end it 'raises SocketError or TypeError when using an invalid String' do - -> { Socket.getnameinfo('cats') }.should raise_error(Exception) { |e| + -> { Socket.getnameinfo('cats') }.should.raise(Exception) { |e| (e.is_a?(SocketError) || e.is_a?(TypeError)).should == true } end @@ -110,7 +110,7 @@ def should_be_valid_dns_name(name) end it 'raises ArgumentError when using an invalid Array' do - -> { Socket.getnameinfo([family_name]) }.should raise_error(ArgumentError) + -> { Socket.getnameinfo([family_name]) }.should.raise(ArgumentError) end platform_is_not :windows do @@ -130,7 +130,7 @@ def should_be_valid_dns_name(name) describe 'without custom flags' do it 'returns an Array containing the hostname and service name' do array = Socket.getnameinfo(@addr) - array.should be_an_instance_of(Array) + array.should.instance_of?(Array) array[0].should == @hostname array[1].should == 'ftp' end @@ -139,7 +139,7 @@ def should_be_valid_dns_name(name) addr = [family_name, 21, ip_address, nil] array = Socket.getnameinfo(addr) - array.should be_an_instance_of(Array) + array.should.instance_of?(Array) array[0].should == @hostname array[1].should == 'ftp' end diff --git a/spec/ruby/library/socket/socket/getservbyname_spec.rb b/spec/ruby/library/socket/socket/getservbyname_spec.rb index d361e619f2106f..4a88444fffd2e6 100644 --- a/spec/ruby/library/socket/socket/getservbyname_spec.rb +++ b/spec/ruby/library/socket/socket/getservbyname_spec.rb @@ -27,6 +27,6 @@ end it "raises a SocketError when the service or port is invalid" do - -> { Socket.getservbyname('invalid') }.should raise_error(SocketError) + -> { Socket.getservbyname('invalid') }.should.raise(SocketError) end end diff --git a/spec/ruby/library/socket/socket/getservbyport_spec.rb b/spec/ruby/library/socket/socket/getservbyport_spec.rb index 563c592b549335..7e4b75fa52cc4f 100644 --- a/spec/ruby/library/socket/socket/getservbyport_spec.rb +++ b/spec/ruby/library/socket/socket/getservbyport_spec.rb @@ -18,6 +18,6 @@ end it 'raises SocketError for an unknown port number' do - -> { Socket.getservbyport(0) }.should raise_error(SocketError) + -> { Socket.getservbyport(0) }.should.raise(SocketError) end end diff --git a/spec/ruby/library/socket/socket/initialize_spec.rb b/spec/ruby/library/socket/socket/initialize_spec.rb index f8337bcaa5d234..a8fb1c61fada6b 100644 --- a/spec/ruby/library/socket/socket/initialize_spec.rb +++ b/spec/ruby/library/socket/socket/initialize_spec.rb @@ -13,7 +13,7 @@ it 'returns a Socket' do @socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end end @@ -21,7 +21,7 @@ it 'returns a Socket' do @socket = Socket.new(:INET, :STREAM) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end end @@ -29,7 +29,7 @@ it 'returns a Socket' do @socket = Socket.new('INET', 'STREAM') - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end end @@ -43,7 +43,7 @@ @socket = Socket.new(family, type) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'raises TypeError when the #to_str method does not return a String' do @@ -53,7 +53,7 @@ family.stub!(:to_str).and_return(Socket::AF_INET) type.stub!(:to_str).and_return(Socket::SOCK_STREAM) - -> { Socket.new(family, type) }.should raise_error(TypeError) + -> { Socket.new(family, type) }.should.raise(TypeError) end end @@ -61,11 +61,11 @@ it 'returns a Socket when using an Integer' do @socket = Socket.new(:INET, :STREAM, Socket::IPPROTO_TCP) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end it 'raises TypeError when using a Symbol' do - -> { Socket.new(:INET, :STREAM, :TCP) }.should raise_error(TypeError) + -> { Socket.new(:INET, :STREAM, :TCP) }.should.raise(TypeError) end end @@ -82,6 +82,6 @@ it "sets the socket to binary mode" do @socket = Socket.new(:INET, :STREAM) - @socket.binmode?.should be_true + @socket.binmode?.should == true end end diff --git a/spec/ruby/library/socket/socket/ip_address_list_spec.rb b/spec/ruby/library/socket/socket/ip_address_list_spec.rb index f97c2d7f85b249..2c4e008af190fc 100644 --- a/spec/ruby/library/socket/socket/ip_address_list_spec.rb +++ b/spec/ruby/library/socket/socket/ip_address_list_spec.rb @@ -2,7 +2,7 @@ describe 'Socket.ip_address_list' do it 'returns an Array' do - Socket.ip_address_list.should be_an_instance_of(Array) + Socket.ip_address_list.should.instance_of?(Array) end describe 'the returned Array' do @@ -11,12 +11,12 @@ end it 'is not empty' do - @array.should_not be_empty + @array.should_not.empty? end it 'contains Addrinfo objects' do @array.each do |klass| - klass.should be_an_instance_of(Addrinfo) + klass.should.instance_of?(Addrinfo) end end end @@ -28,8 +28,8 @@ it 'has a non-empty IP address' do @array.each do |addr| - addr.ip_address.should be_an_instance_of(String) - addr.ip_address.should_not be_empty + addr.ip_address.should.instance_of?(String) + addr.ip_address.should_not.empty? end end diff --git a/spec/ruby/library/socket/socket/listen_spec.rb b/spec/ruby/library/socket/socket/listen_spec.rb index 4d2aedab191333..7986a0225cca24 100644 --- a/spec/ruby/library/socket/socket/listen_spec.rb +++ b/spec/ruby/library/socket/socket/listen_spec.rb @@ -7,7 +7,7 @@ end after :each do - @socket.closed?.should be_false + @socket.closed?.should == false @socket.close end @@ -35,7 +35,7 @@ end it 'raises Errno::EOPNOTSUPP or Errno::EACCES' do - -> { @server.listen(1) }.should raise_error { |e| + -> { @server.listen(1) }.should.raise { |e| [Errno::EOPNOTSUPP, Errno::EACCES].should.include?(e.class) } end @@ -59,7 +59,7 @@ end it "raises when the given argument can't be coerced to an Integer" do - -> { @server.listen('cats') }.should raise_error(TypeError) + -> { @server.listen('cats') }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/socket/socket/local_address_spec.rb b/spec/ruby/library/socket/socket/local_address_spec.rb index 3687f93a0c487a..86b053fc3e25f9 100644 --- a/spec/ruby/library/socket/socket/local_address_spec.rb +++ b/spec/ruby/library/socket/socket/local_address_spec.rb @@ -10,7 +10,7 @@ end it 'returns an Addrinfo' do - @sock.local_address.should be_an_instance_of(Addrinfo) + @sock.local_address.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb b/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb index 38a9f5ff5bc3fe..ab29435a1d793f 100644 --- a/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb +++ b/spec/ruby/library/socket/socket/recvfrom_nonblock_spec.rb @@ -16,7 +16,7 @@ platform_is_not :windows do describe 'using an unbound socket' do it 'raises IO::WaitReadable' do - -> { @server.recvfrom_nonblock(1) }.should raise_error(IO::WaitReadable) + -> { @server.recvfrom_nonblock(1) }.should.raise(IO::WaitReadable) end end end @@ -29,7 +29,7 @@ describe 'without any data available' do it 'raises IO::WaitReadable' do - -> { @server.recvfrom_nonblock(1) }.should raise_error(IO::WaitReadable) + -> { @server.recvfrom_nonblock(1) }.should.raise(IO::WaitReadable) end it 'returns :wait_readable with exception: false' do @@ -47,7 +47,7 @@ IO.select([@server]) ret = @server.recvfrom_nonblock(1) - ret.should be_an_instance_of(Array) + ret.should.instance_of?(Array) ret.length.should == 2 end end @@ -98,7 +98,7 @@ end it 'contains an Addrinfo at index 1' do - @array[1].should be_an_instance_of(Addrinfo) + @array[1].should.instance_of?(Addrinfo) end end @@ -175,13 +175,13 @@ end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil @client.connect(@server_addr) @client.close ready = true - t.value.should be_nil + t.value.should == nil end end end diff --git a/spec/ruby/library/socket/socket/recvfrom_spec.rb b/spec/ruby/library/socket/socket/recvfrom_spec.rb index cbbc162f6b0d28..0f319fc47cead2 100644 --- a/spec/ruby/library/socket/socket/recvfrom_spec.rb +++ b/spec/ruby/library/socket/socket/recvfrom_spec.rb @@ -39,7 +39,7 @@ it 'returns an Array containing the data and an Addrinfo' do ret = @server.recvfrom(1) - ret.should be_an_instance_of(Array) + ret.should.instance_of?(Array) ret.length.should == 2 end @@ -53,7 +53,7 @@ end it 'contains an Addrinfo at index 1' do - @array[1].should be_an_instance_of(Addrinfo) + @array[1].should.instance_of?(Addrinfo) end end @@ -120,12 +120,12 @@ end Thread.pass while t.status and t.status != "sleep" - t.status.should_not be_nil + t.status.should_not == nil @client.connect(@server_addr) @client.close - t.value.should be_nil + t.value.should == nil end end diff --git a/spec/ruby/library/socket/socket/remote_address_spec.rb b/spec/ruby/library/socket/socket/remote_address_spec.rb index 24d60d7f582fb1..f72ec50ed7ab9c 100644 --- a/spec/ruby/library/socket/socket/remote_address_spec.rb +++ b/spec/ruby/library/socket/socket/remote_address_spec.rb @@ -22,7 +22,7 @@ end it 'returns an Addrinfo' do - @client.remote_address.should be_an_instance_of(Addrinfo) + @client.remote_address.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/socket/sysaccept_spec.rb b/spec/ruby/library/socket/socket/sysaccept_spec.rb index 92ac21124eda23..3e7078f74593b0 100644 --- a/spec/ruby/library/socket/socket/sysaccept_spec.rb +++ b/spec/ruby/library/socket/socket/sysaccept_spec.rb @@ -15,7 +15,7 @@ platform_is :linux do # hangs on other platforms describe 'using an unbound socket' do it 'raises Errno::EINVAL' do - -> { @server.sysaccept }.should raise_error(Errno::EINVAL) + -> { @server.sysaccept }.should.raise(Errno::EINVAL) end end @@ -25,7 +25,7 @@ end it 'raises Errno::EINVAL' do - -> { @server.sysaccept }.should raise_error(Errno::EINVAL) + -> { @server.sysaccept }.should.raise(Errno::EINVAL) end end end @@ -59,7 +59,7 @@ @client.connect(@server_addr) - thread.value.should be_an_instance_of(Array) + thread.value.should.instance_of?(Array) end end @@ -76,8 +76,8 @@ it 'returns an Array containing an Integer and an Addrinfo' do @fd, addrinfo = @server.sysaccept - @fd.should be_kind_of(Integer) - addrinfo.should be_an_instance_of(Addrinfo) + @fd.should.is_a?(Integer) + addrinfo.should.instance_of?(Addrinfo) end it 'returns a new file descriptor' do diff --git a/spec/ruby/library/socket/socket/tcp_server_loop_spec.rb b/spec/ruby/library/socket/socket/tcp_server_loop_spec.rb index a46c6df5c65388..4e39d01d722adc 100644 --- a/spec/ruby/library/socket/socket/tcp_server_loop_spec.rb +++ b/spec/ruby/library/socket/socket/tcp_server_loop_spec.rb @@ -47,8 +47,8 @@ # complete. thread.join - @sock.should be_an_instance_of(Socket) - addr.should be_an_instance_of(Addrinfo) + @sock.should.instance_of?(Socket) + addr.should.instance_of?(Addrinfo) end end end diff --git a/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb b/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb index bd496d301560b3..b6cdb3c583922b 100644 --- a/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb +++ b/spec/ruby/library/socket/socket/tcp_server_sockets_spec.rb @@ -13,16 +13,16 @@ it 'returns an Array of Socket objects' do @sockets = Socket.tcp_server_sockets(0) - @sockets.should be_an_instance_of(Array) - @sockets[0].should be_an_instance_of(Socket) + @sockets.should.instance_of?(Array) + @sockets[0].should.instance_of?(Socket) end end describe 'with a block' do it 'yields the sockets to the supplied block' do Socket.tcp_server_sockets(0) do |sockets| - sockets.should be_an_instance_of(Array) - sockets[0].should be_an_instance_of(Socket) + sockets.should.instance_of?(Array) + sockets[0].should.instance_of?(Socket) end end diff --git a/spec/ruby/library/socket/socket/tcp_spec.rb b/spec/ruby/library/socket/socket/tcp_spec.rb index faf020b1ead615..f52198b0028be2 100644 --- a/spec/ruby/library/socket/socket/tcp_spec.rb +++ b/spec/ruby/library/socket/socket/tcp_spec.rb @@ -22,12 +22,12 @@ it 'returns a Socket when no block is given' do @client = Socket.tcp(@host, @port) - @client.should be_an_instance_of(Socket) + @client.should.instance_of?(Socket) end it 'yields the Socket when a block is given' do Socket.tcp(@host, @port) do |socket| - socket.should be_an_instance_of(Socket) + socket.should.instance_of?(Socket) end end @@ -51,7 +51,7 @@ it 'raises ArgumentError when 6 arguments are provided' do -> { Socket.tcp(@host, @port, @host, 0, {:connect_timeout => 1}, 10) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it 'connects to the server' do diff --git a/spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb b/spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb index cb8c5c5587ca30..9197509f1f7c2d 100644 --- a/spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb +++ b/spec/ruby/library/socket/socket/udp_server_loop_on_spec.rb @@ -41,7 +41,7 @@ end msg.should == 'hello' - src.should be_an_instance_of(Socket::UDPSource) + src.should.instance_of?(Socket::UDPSource) end end end diff --git a/spec/ruby/library/socket/socket/udp_server_loop_spec.rb b/spec/ruby/library/socket/socket/udp_server_loop_spec.rb index cd22ea56cffe8b..d44d522c20c7e9 100644 --- a/spec/ruby/library/socket/socket/udp_server_loop_spec.rb +++ b/spec/ruby/library/socket/socket/udp_server_loop_spec.rb @@ -53,7 +53,7 @@ thread.join msg.should == 'hello' - src.should be_an_instance_of(Socket::UDPSource) + src.should.instance_of?(Socket::UDPSource) end end end diff --git a/spec/ruby/library/socket/socket/udp_server_recv_spec.rb b/spec/ruby/library/socket/socket/udp_server_recv_spec.rb index 47ed74bc0300d1..34e228055860aa 100644 --- a/spec/ruby/library/socket/socket/udp_server_recv_spec.rb +++ b/spec/ruby/library/socket/socket/udp_server_recv_spec.rb @@ -30,6 +30,6 @@ end msg.should == 'hello' - src.should be_an_instance_of(Socket::UDPSource) + src.should.instance_of?(Socket::UDPSource) end end diff --git a/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb b/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb index f8be672612aa8f..cb357977d66249 100644 --- a/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb +++ b/spec/ruby/library/socket/socket/udp_server_sockets_spec.rb @@ -13,16 +13,16 @@ it 'returns an Array of Socket objects' do @sockets = Socket.udp_server_sockets(0) - @sockets.should be_an_instance_of(Array) - @sockets[0].should be_an_instance_of(Socket) + @sockets.should.instance_of?(Array) + @sockets[0].should.instance_of?(Socket) end end describe 'with a block' do it 'yields the sockets to the supplied block' do Socket.udp_server_sockets(0) do |sockets| - sockets.should be_an_instance_of(Array) - sockets[0].should be_an_instance_of(Socket) + sockets.should.instance_of?(Array) + sockets[0].should.instance_of?(Socket) end end diff --git a/spec/ruby/library/socket/socket/unix_server_loop_spec.rb b/spec/ruby/library/socket/socket/unix_server_loop_spec.rb index 6192bc8bf6d166..9d35a995bc42a5 100644 --- a/spec/ruby/library/socket/socket/unix_server_loop_spec.rb +++ b/spec/ruby/library/socket/socket/unix_server_loop_spec.rb @@ -49,8 +49,8 @@ thread.join - @sock.should be_an_instance_of(Socket) - addr.should be_an_instance_of(Addrinfo) + @sock.should.instance_of?(Socket) + addr.should.instance_of?(Addrinfo) end end end diff --git a/spec/ruby/library/socket/socket/unix_server_socket_spec.rb b/spec/ruby/library/socket/socket/unix_server_socket_spec.rb index 34c3b96d077e7f..da9671bf8c7a58 100644 --- a/spec/ruby/library/socket/socket/unix_server_socket_spec.rb +++ b/spec/ruby/library/socket/socket/unix_server_socket_spec.rb @@ -22,14 +22,14 @@ it 'returns a Socket' do @socket = Socket.unix_server_socket(@path) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end end describe 'when a block is given' do it 'yields a Socket' do Socket.unix_server_socket(@path) do |sock| - sock.should be_an_instance_of(Socket) + sock.should.instance_of?(Socket) end end @@ -40,7 +40,7 @@ socket = sock end - socket.should be_an_instance_of(Socket) + socket.should.instance_of?(Socket) end end end diff --git a/spec/ruby/library/socket/socket/unix_spec.rb b/spec/ruby/library/socket/socket/unix_spec.rb index 2a5d77f96fd34e..87f4938871a41a 100644 --- a/spec/ruby/library/socket/socket/unix_spec.rb +++ b/spec/ruby/library/socket/socket/unix_spec.rb @@ -19,14 +19,14 @@ it 'returns a Socket' do @socket = Socket.unix(@path) - @socket.should be_an_instance_of(Socket) + @socket.should.instance_of?(Socket) end end describe 'when a block is given' do it 'yields a Socket' do Socket.unix(@path) do |sock| - sock.should be_an_instance_of(Socket) + sock.should.instance_of?(Socket) end end diff --git a/spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb b/spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb index 935b5cb5439c32..35d46b0fd09162 100644 --- a/spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb +++ b/spec/ruby/library/socket/socket/unpack_sockaddr_in_spec.rb @@ -34,11 +34,11 @@ it "raises an ArgumentError when the sin_family is not AF_INET" do sockaddr = Socket.sockaddr_un '/tmp/x' - -> { Socket.unpack_sockaddr_in sockaddr }.should raise_error(ArgumentError) + -> { Socket.unpack_sockaddr_in sockaddr }.should.raise(ArgumentError) end it "raises an ArgumentError when passed addrinfo is not AF_INET/AF_INET6" do addrinfo = Addrinfo.unix('/tmp/sock') - -> { Socket.unpack_sockaddr_in(addrinfo) }.should raise_error(ArgumentError) + -> { Socket.unpack_sockaddr_in(addrinfo) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb b/spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb index 6e0f11de3d2db3..85a941cfc22e53 100644 --- a/spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb +++ b/spec/ruby/library/socket/socket/unpack_sockaddr_un_spec.rb @@ -14,11 +14,11 @@ it 'raises an ArgumentError when the sa_family is not AF_UNIX' do sockaddr = Socket.sockaddr_in(0, '127.0.0.1') - -> { Socket.unpack_sockaddr_un(sockaddr) }.should raise_error(ArgumentError) + -> { Socket.unpack_sockaddr_un(sockaddr) }.should.raise(ArgumentError) end it 'raises an ArgumentError when passed addrinfo is not AF_UNIX' do addrinfo = Addrinfo.tcp('127.0.0.1', 0) - -> { Socket.unpack_sockaddr_un(addrinfo) }.should raise_error(ArgumentError) + -> { Socket.unpack_sockaddr_un(addrinfo) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb b/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb index 91f6a327f038d9..ac08fe37c6ed77 100644 --- a/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb +++ b/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb @@ -15,7 +15,7 @@ @server.listen(5) -> { @server.accept_nonblock - }.should raise_error(IO::WaitReadable) + }.should.raise(IO::WaitReadable) c = TCPSocket.new("127.0.0.1", @port) IO.select([@server]) @@ -25,7 +25,7 @@ port.should == @port address.should == "127.0.0.1" - s.should be_kind_of(TCPSocket) + s.should.is_a?(TCPSocket) c.close s.close @@ -33,12 +33,12 @@ it "raises an IOError if the socket is closed" do @server.close - -> { @server.accept }.should raise_error(IOError) + -> { @server.accept }.should.raise(IOError) end describe 'without a connected client' do it 'raises error' do - -> { @server.accept_nonblock }.should raise_error(IO::WaitReadable) + -> { @server.accept_nonblock }.should.raise(IO::WaitReadable) end it 'returns :wait_readable in exceptionless mode' do @@ -59,7 +59,7 @@ describe 'without a connected client' do it 'raises IO::WaitReadable' do - -> { @server.accept_nonblock }.should raise_error(IO::WaitReadable) + -> { @server.accept_nonblock }.should.raise(IO::WaitReadable) end end @@ -77,7 +77,7 @@ it 'returns a TCPSocket' do IO.select([@server]) @socket = @server.accept_nonblock - @socket.should be_an_instance_of(TCPSocket) + @socket.should.instance_of?(TCPSocket) end end end diff --git a/spec/ruby/library/socket/tcpserver/accept_spec.rb b/spec/ruby/library/socket/tcpserver/accept_spec.rb index d8892cd5f061d3..f2aa0bf8e1e415 100644 --- a/spec/ruby/library/socket/tcpserver/accept_spec.rb +++ b/spec/ruby/library/socket/tcpserver/accept_spec.rb @@ -15,7 +15,7 @@ data = nil t = Thread.new do client = @server.accept - client.should be_kind_of(TCPSocket) + client.should.is_a?(TCPSocket) data = client.read(5) client << "goodbye" client.close @@ -50,7 +50,7 @@ t = Thread.new { -> { @server.accept - }.should raise_error(Exception, "interrupted") + }.should.raise(Exception, "interrupted") } Thread.pass while t.status and t.status != "sleep" @@ -80,7 +80,7 @@ it "raises an IOError if the socket is closed" do @server.close - -> { @server.accept }.should raise_error(IOError) + -> { @server.accept }.should.raise(IOError) end end @@ -112,7 +112,7 @@ it 'returns a TCPSocket' do @socket = @server.accept - @socket.should be_an_instance_of(TCPSocket) + @socket.should.instance_of?(TCPSocket) end platform_is_not :windows do diff --git a/spec/ruby/library/socket/tcpserver/gets_spec.rb b/spec/ruby/library/socket/tcpserver/gets_spec.rb index 417976d737544d..72a72fa2dc43b6 100644 --- a/spec/ruby/library/socket/tcpserver/gets_spec.rb +++ b/spec/ruby/library/socket/tcpserver/gets_spec.rb @@ -11,6 +11,6 @@ end it "raises Errno::ENOTCONN on gets" do - -> { @server.gets }.should raise_error(Errno::ENOTCONN) + -> { @server.gets }.should.raise(Errno::ENOTCONN) end end diff --git a/spec/ruby/library/socket/tcpserver/initialize_spec.rb b/spec/ruby/library/socket/tcpserver/initialize_spec.rb index 4ddd1f465fd5ff..517b014edc3423 100644 --- a/spec/ruby/library/socket/tcpserver/initialize_spec.rb +++ b/spec/ruby/library/socket/tcpserver/initialize_spec.rb @@ -12,7 +12,7 @@ end it 'sets the port to the given argument' do - @server.local_address.ip_port.should be_kind_of(Integer) + @server.local_address.ip_port.should.is_a?(Integer) @server.local_address.ip_port.should > 0 end @@ -24,7 +24,7 @@ end it "sets the socket to binmode" do - @server.binmode?.should be_true + @server.binmode?.should == true end end @@ -38,7 +38,7 @@ end it 'sets the port to the given argument' do - @server.local_address.ip_port.should be_kind_of(Integer) + @server.local_address.ip_port.should.is_a?(Integer) @server.local_address.ip_port.should > 0 end @@ -52,7 +52,7 @@ describe 'with a single String argument containing a non numeric value' do it 'raises SocketError' do - -> { TCPServer.new('cats') }.should raise_error(SocketError) + -> { TCPServer.new('cats') }.should.raise(SocketError) end end @@ -67,7 +67,7 @@ end it 'sets the port to the given port argument' do - @server.local_address.ip_port.should be_kind_of(Integer) + @server.local_address.ip_port.should.is_a?(Integer) @server.local_address.ip_port.should > 0 end @@ -90,7 +90,7 @@ end it 'sets the port to the given port argument' do - @server.local_address.ip_port.should be_kind_of(Integer) + @server.local_address.ip_port.should.is_a?(Integer) @server.local_address.ip_port.should > 0 end diff --git a/spec/ruby/library/socket/tcpserver/listen_spec.rb b/spec/ruby/library/socket/tcpserver/listen_spec.rb index c877fdced653f0..5b046ef6f720d0 100644 --- a/spec/ruby/library/socket/tcpserver/listen_spec.rb +++ b/spec/ruby/library/socket/tcpserver/listen_spec.rb @@ -16,7 +16,7 @@ end it "raises when the given argument can't be coerced to an Integer" do - -> { @server.listen('cats') }.should raise_error(TypeError) + -> { @server.listen('cats') }.should.raise(TypeError) end end end diff --git a/spec/ruby/library/socket/tcpserver/new_spec.rb b/spec/ruby/library/socket/tcpserver/new_spec.rb index dd1ba676bd9e95..70b8d4352ee698 100644 --- a/spec/ruby/library/socket/tcpserver/new_spec.rb +++ b/spec/ruby/library/socket/tcpserver/new_spec.rb @@ -10,7 +10,7 @@ @server = TCPServer.new('127.0.0.1', 0) addr = @server.addr addr[0].should == 'AF_INET' - addr[1].should be_kind_of(Integer) + addr[1].should.is_a?(Integer) # on some platforms (Mac), MRI # returns comma at the end. addr[2].should =~ /^#{SocketSpecs.hostname}\b/ @@ -20,7 +20,7 @@ it "binds to localhost and a port with either IPv4 or IPv6" do @server = TCPServer.new(SocketSpecs.hostname, 0) addr = @server.addr - addr[1].should be_kind_of(Integer) + addr[1].should.is_a?(Integer) if addr[0] == 'AF_INET' addr[2].should =~ /^#{SocketSpecs.hostname}\b/ addr[3].should == '127.0.0.1' @@ -34,7 +34,7 @@ @server = TCPServer.new('', 0) addr = @server.addr addr[0].should == 'AF_INET' - addr[1].should be_kind_of(Integer) + addr[1].should.is_a?(Integer) addr[2].should == '0.0.0.0' addr[3].should == '0.0.0.0' end @@ -43,7 +43,7 @@ @server = TCPServer.new('', '0') addr = @server.addr addr[0].should == 'AF_INET' - addr[1].should be_kind_of(Integer) + addr[1].should.is_a?(Integer) addr[2].should == '0.0.0.0' addr[3].should == '0.0.0.0' end @@ -52,7 +52,7 @@ @server = TCPServer.new('', nil) addr = @server.addr addr[0].should == 'AF_INET' - addr[1].should be_kind_of(Integer) + addr[1].should.is_a?(Integer) addr[2].should == '0.0.0.0' addr[3].should == '0.0.0.0' end @@ -61,20 +61,20 @@ @server = TCPServer.new('', '') addr = @server.addr addr[0].should == 'AF_INET' - addr[1].should be_kind_of(Integer) + addr[1].should.is_a?(Integer) addr[2].should == '0.0.0.0' addr[3].should == '0.0.0.0' end it "coerces port to string, then determines port from that number or service name" do - -> { TCPServer.new(SocketSpecs.hostname, Object.new) }.should raise_error(TypeError) + -> { TCPServer.new(SocketSpecs.hostname, Object.new) }.should.raise(TypeError) port = Object.new port.should_receive(:to_str).and_return("0") @server = TCPServer.new(SocketSpecs.hostname, port) addr = @server.addr - addr[1].should be_kind_of(Integer) + addr[1].should.is_a?(Integer) # TODO: This should also accept strings like 'https', but I don't know how to # pick such a service port that will be able to reliably bind... @@ -83,18 +83,18 @@ it "has a single argument form and treats it as a port number" do @server = TCPServer.new(0) addr = @server.addr - addr[1].should be_kind_of(Integer) + addr[1].should.is_a?(Integer) end it "coerces port to a string when it is the only argument" do - -> { TCPServer.new(Object.new) }.should raise_error(TypeError) + -> { TCPServer.new(Object.new) }.should.raise(TypeError) port = Object.new port.should_receive(:to_str).and_return("0") @server = TCPServer.new(port) addr = @server.addr - addr[1].should be_kind_of(Integer) + addr[1].should.is_a?(Integer) end it "does not use the given block and warns to use TCPServer::open" do @@ -104,7 +104,7 @@ end it "raises Errno::EADDRNOTAVAIL when the address is unknown" do - -> { TCPServer.new("1.2.3.4", 0) }.should raise_error(Errno::EADDRNOTAVAIL) + -> { TCPServer.new("1.2.3.4", 0) }.should.raise(Errno::EADDRNOTAVAIL) end # There is no way to make this fail-proof on all machines, because @@ -114,7 +114,7 @@ it "raises a SocketError when the host is unknown" do -> { TCPServer.new("--notavalidname", 0) - }.should raise_error(SocketError) + }.should.raise(SocketError) end end @@ -122,7 +122,7 @@ @server = TCPServer.new('127.0.0.1', 0) -> { @server = TCPServer.new('127.0.0.1', @server.addr[1]) - }.should raise_error(Errno::EADDRINUSE) + }.should.raise(Errno::EADDRINUSE) end platform_is_not :windows, :aix do diff --git a/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb b/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb index bd7d33faf4730e..ed23bced235482 100644 --- a/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb +++ b/spec/ruby/library/socket/tcpserver/sysaccept_spec.rb @@ -21,7 +21,7 @@ fd = @server.sysaccept - fd.should be_kind_of(Integer) + fd.should.is_a?(Integer) ensure sock.close if sock && !sock.closed? IO.for_fd(fd).close if fd @@ -58,7 +58,7 @@ it 'returns a new file descriptor as an Integer' do @fd = @server.sysaccept - @fd.should be_kind_of(Integer) + @fd.should.is_a?(Integer) @fd.should_not == @client.fileno end end diff --git a/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb b/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb index 5a2c704f352091..c6fe0078271819 100644 --- a/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb +++ b/spec/ruby/library/socket/tcpsocket/gethostbyname_spec.rb @@ -10,7 +10,7 @@ end it "returns an array elements of information on the hostname" do - @host_info.should be_kind_of(Array) + @host_info.should.is_a?(Array) end platform_is_not :windows do @@ -20,12 +20,12 @@ it "returns the address type as the third value" do address_type = @host_info[2] - [Socket::AF_INET, Socket::AF_INET6].include?(address_type).should be_true + [Socket::AF_INET, Socket::AF_INET6].include?(address_type).should == true end it "returns the IP address as the fourth value" do ip = @host_info[3] - ["127.0.0.1", "::1"].include?(ip).should be_true + ["127.0.0.1", "::1"].include?(ip).should == true end end @@ -48,14 +48,14 @@ end it "returns any aliases to the address as second value" do - @host_info[1].should be_kind_of(Array) + @host_info[1].should.is_a?(Array) end end describe 'TCPSocket.gethostbyname' do it 'returns an Array' do suppress_warning do - TCPSocket.gethostbyname('127.0.0.1').should be_an_instance_of(Array) + TCPSocket.gethostbyname('127.0.0.1').should.instance_of?(Array) end end @@ -72,11 +72,11 @@ end it 'includes an array of alternative hostnames as the 2nd value' do - @array[1].should be_an_instance_of(Array) + @array[1].should.instance_of?(Array) end it 'includes the address family as the 3rd value' do - @array[2].should be_kind_of(Integer) + @array[2].should.is_a?(Integer) end it 'includes the IP addresses as all the remaining values' do diff --git a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb b/spec/ruby/library/socket/tcpsocket/initialize_spec.rb index d7feb9751bb95f..a33d0b16bacb0e 100644 --- a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb +++ b/spec/ruby/library/socket/tcpsocket/initialize_spec.rb @@ -31,7 +31,7 @@ SocketSpecs.each_ip_protocol do |family, ip_address| describe 'when no server is listening on the given address' do it 'raises Errno::ECONNREFUSED' do - -> { TCPSocket.new(ip_address, 666) }.should raise_error(Errno::ECONNREFUSED) + -> { TCPSocket.new(ip_address, 666) }.should.raise(Errno::ECONNREFUSED) end end @@ -48,21 +48,21 @@ it 'returns a TCPSocket when using an Integer as the port' do @client = TCPSocket.new(ip_address, @port) - @client.should be_an_instance_of(TCPSocket) + @client.should.instance_of?(TCPSocket) end it 'returns a TCPSocket when using a String as the port' do @client = TCPSocket.new(ip_address, @port.to_s) - @client.should be_an_instance_of(TCPSocket) + @client.should.instance_of?(TCPSocket) end it 'raises SocketError when the port number is a non numeric String' do - -> { TCPSocket.new(ip_address, 'cats') }.should raise_error(SocketError) + -> { TCPSocket.new(ip_address, 'cats') }.should.raise(SocketError) end it 'set the socket to binmode' do @client = TCPSocket.new(ip_address, @port) - @client.binmode?.should be_true + @client.binmode?.should == true end it 'connects to the right address' do diff --git a/spec/ruby/library/socket/tcpsocket/local_address_spec.rb b/spec/ruby/library/socket/tcpsocket/local_address_spec.rb index ce66d5ff8fbb6f..5dcf741f2904b6 100644 --- a/spec/ruby/library/socket/tcpsocket/local_address_spec.rb +++ b/spec/ruby/library/socket/tcpsocket/local_address_spec.rb @@ -23,7 +23,7 @@ end it 'returns an Addrinfo' do - @sock.local_address.should be_an_instance_of(Addrinfo) + @sock.local_address.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/tcpsocket/remote_address_spec.rb b/spec/ruby/library/socket/tcpsocket/remote_address_spec.rb index eb9dabc0756856..085d57b3f9fed9 100644 --- a/spec/ruby/library/socket/tcpsocket/remote_address_spec.rb +++ b/spec/ruby/library/socket/tcpsocket/remote_address_spec.rb @@ -23,7 +23,7 @@ end it 'returns an Addrinfo' do - @sock.remote_address.should be_an_instance_of(Addrinfo) + @sock.remote_address.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/tcpsocket/shared/new.rb b/spec/ruby/library/socket/tcpsocket/shared/new.rb index 0e405253c84324..cf4834526d391b 100644 --- a/spec/ruby/library/socket/tcpsocket/shared/new.rb +++ b/spec/ruby/library/socket/tcpsocket/shared/new.rb @@ -3,21 +3,21 @@ describe :tcpsocket_new, shared: true do it "requires a hostname and a port as arguments" do - -> { TCPSocket.send(@method) }.should raise_error(ArgumentError) + -> { TCPSocket.send(@method) }.should.raise(ArgumentError) end it "refuses the connection when there is no server to connect to" do -> do TCPSocket.send(@method, SocketSpecs.hostname, SocketSpecs.reserved_unused_port) - end.should raise_error(SystemCallError) {|e| - [Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL].should include(e.class) + end.should.raise(SystemCallError) {|e| + [Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL].should.include?(e.class) } end 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) + }.should.raise(IO::TimeoutError) rescue Errno::ENETUNREACH # In the case all network interfaces down. # raise_error cannot deal with multiple expected exceptions @@ -39,17 +39,17 @@ it "silently ignores 'nil' as the third parameter" do @socket = TCPSocket.send(@method, @hostname, @server.port, nil) - @socket.should be_an_instance_of(TCPSocket) + @socket.should.instance_of?(TCPSocket) end it "connects to a listening server with host and port" do @socket = TCPSocket.send(@method, @hostname, @server.port) - @socket.should be_an_instance_of(TCPSocket) + @socket.should.instance_of?(TCPSocket) end it "connects to a server when passed local_host argument" do @socket = TCPSocket.send(@method, @hostname, @server.port, @hostname) - @socket.should be_an_instance_of(TCPSocket) + @socket.should.instance_of?(TCPSocket) end it "connects to a server when passed local_host and local_port arguments" do @@ -70,12 +70,12 @@ raise if retries >= max_retries retry end - @socket.should be_an_instance_of(TCPSocket) + @socket.should.instance_of?(TCPSocket) end it "has an address once it has connected to a listening server" do @socket = TCPSocket.send(@method, @hostname, @server.port) - @socket.should be_an_instance_of(TCPSocket) + @socket.should.instance_of?(TCPSocket) # TODO: Figure out how to abstract this. You can get AF_INET # from 'Socket.getaddrinfo(hostname, nil)[0][3]' but socket.addr @@ -90,13 +90,13 @@ @socket.addr[3].should == SocketSpecs.addr(:ipv6) end - @socket.addr[1].should be_kind_of(Integer) + @socket.addr[1].should.is_a?(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) + @socket.should.instance_of?(TCPSocket) end end end diff --git a/spec/ruby/library/socket/udpsocket/bind_spec.rb b/spec/ruby/library/socket/udpsocket/bind_spec.rb index 08b386e941fc53..974e701e71e32f 100644 --- a/spec/ruby/library/socket/udpsocket/bind_spec.rb +++ b/spec/ruby/library/socket/udpsocket/bind_spec.rb @@ -12,7 +12,7 @@ it "binds the socket to a port" do @socket.bind(SocketSpecs.hostname, 0) - @socket.addr[1].should be_kind_of(Integer) + @socket.addr[1].should.is_a?(Integer) end it "raises Errno::EINVAL when already bound" do @@ -20,7 +20,7 @@ -> { @socket.bind(SocketSpecs.hostname, @socket.addr[1]) - }.should raise_error(Errno::EINVAL) + }.should.raise(Errno::EINVAL) end it "receives a hostname and a port" do diff --git a/spec/ruby/library/socket/udpsocket/initialize_spec.rb b/spec/ruby/library/socket/udpsocket/initialize_spec.rb index ecf0043c10a29c..c040187400732a 100644 --- a/spec/ruby/library/socket/udpsocket/initialize_spec.rb +++ b/spec/ruby/library/socket/udpsocket/initialize_spec.rb @@ -7,27 +7,27 @@ it 'initializes a new UDPSocket' do @socket = UDPSocket.new - @socket.should be_an_instance_of(UDPSocket) + @socket.should.instance_of?(UDPSocket) end it 'initializes a new UDPSocket using an Integer' do @socket = UDPSocket.new(Socket::AF_INET) - @socket.should be_an_instance_of(UDPSocket) + @socket.should.instance_of?(UDPSocket) end it 'initializes a new UDPSocket using a Symbol' do @socket = UDPSocket.new(:INET) - @socket.should be_an_instance_of(UDPSocket) + @socket.should.instance_of?(UDPSocket) end it 'initializes a new UDPSocket using a String' do @socket = UDPSocket.new('INET') - @socket.should be_an_instance_of(UDPSocket) + @socket.should.instance_of?(UDPSocket) end it 'sets the socket to binmode' do @socket = UDPSocket.new(:INET) - @socket.binmode?.should be_true + @socket.binmode?.should == true end platform_is_not :windows do @@ -46,8 +46,8 @@ it 'raises Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT when given an invalid address family' do -> { UDPSocket.new(666) - }.should raise_error(SystemCallError) { |e| - [Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT].should include(e.class) + }.should.raise(SystemCallError) { |e| + [Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT].should.include?(e.class) } end end diff --git a/spec/ruby/library/socket/udpsocket/local_address_spec.rb b/spec/ruby/library/socket/udpsocket/local_address_spec.rb index 92e4cc10c76578..868d2f537e56ee 100644 --- a/spec/ruby/library/socket/udpsocket/local_address_spec.rb +++ b/spec/ruby/library/socket/udpsocket/local_address_spec.rb @@ -28,7 +28,7 @@ end it 'returns an Addrinfo' do - @sock.local_address.should be_an_instance_of(Addrinfo) + @sock.local_address.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/udpsocket/new_spec.rb b/spec/ruby/library/socket/udpsocket/new_spec.rb index 79bfcb624d2b69..aff111927cd206 100644 --- a/spec/ruby/library/socket/udpsocket/new_spec.rb +++ b/spec/ruby/library/socket/udpsocket/new_spec.rb @@ -8,22 +8,22 @@ it 'without arguments' do @socket = UDPSocket.new - @socket.should be_an_instance_of(UDPSocket) + @socket.should.instance_of?(UDPSocket) end it 'using Integer argument' do @socket = UDPSocket.new(Socket::AF_INET) - @socket.should be_an_instance_of(UDPSocket) + @socket.should.instance_of?(UDPSocket) end it 'using Symbol argument' do @socket = UDPSocket.new(:INET) - @socket.should be_an_instance_of(UDPSocket) + @socket.should.instance_of?(UDPSocket) end it 'using String argument' do @socket = UDPSocket.new('INET') - @socket.should be_an_instance_of(UDPSocket) + @socket.should.instance_of?(UDPSocket) end it "does not use the given block and warns to use UDPSocket::open" do @@ -33,8 +33,8 @@ 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) + -> { UDPSocket.new(-1) }.should.raise(SystemCallError) { |e| + [Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT].should.include?(e.class) } end end diff --git a/spec/ruby/library/socket/udpsocket/open_spec.rb b/spec/ruby/library/socket/udpsocket/open_spec.rb index e4dbb2ee2abcc6..7c778553724bcc 100644 --- a/spec/ruby/library/socket/udpsocket/open_spec.rb +++ b/spec/ruby/library/socket/udpsocket/open_spec.rb @@ -8,6 +8,6 @@ it "allows calls to open without arguments" do @socket = UDPSocket.open - @socket.should be_kind_of(UDPSocket) + @socket.should.is_a?(UDPSocket) end end diff --git a/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb b/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb index b8040995897c34..460cf2c9a2aff3 100644 --- a/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb +++ b/spec/ruby/library/socket/udpsocket/recvfrom_nonblock_spec.rb @@ -16,7 +16,7 @@ platform_is_not :windows do describe 'using an unbound socket' do it 'raises IO::WaitReadable' do - -> { @server.recvfrom_nonblock(1) }.should raise_error(IO::WaitReadable) + -> { @server.recvfrom_nonblock(1) }.should.raise(IO::WaitReadable) end end end @@ -32,7 +32,7 @@ describe 'without any data available' do it 'raises IO::WaitReadable' do - -> { @server.recvfrom_nonblock(1) }.should raise_error(IO::WaitReadable) + -> { @server.recvfrom_nonblock(1) }.should.raise(IO::WaitReadable) end it 'returns :wait_readable with exception: false' do @@ -48,7 +48,7 @@ it 'returns an Array containing the data and an Array' do IO.select([@server]) - @server.recvfrom_nonblock(1).should be_an_instance_of(Array) + @server.recvfrom_nonblock(1).should.instance_of?(Array) end it 'writes the data to the buffer when one is present' do @@ -78,7 +78,7 @@ end it 'contains an Array at index 1' do - @array[1].should be_an_instance_of(Array) + @array[1].should.instance_of?(Array) end end diff --git a/spec/ruby/library/socket/udpsocket/remote_address_spec.rb b/spec/ruby/library/socket/udpsocket/remote_address_spec.rb index 94889ce560c5d3..d1310200fc86d0 100644 --- a/spec/ruby/library/socket/udpsocket/remote_address_spec.rb +++ b/spec/ruby/library/socket/udpsocket/remote_address_spec.rb @@ -28,7 +28,7 @@ end it 'returns an Addrinfo' do - @sock.remote_address.should be_an_instance_of(Addrinfo) + @sock.remote_address.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/udpsocket/send_spec.rb b/spec/ruby/library/socket/udpsocket/send_spec.rb index 6dd5f67bea1fa0..63f5b0dcc6b289 100644 --- a/spec/ruby/library/socket/udpsocket/send_spec.rb +++ b/spec/ruby/library/socket/udpsocket/send_spec.rb @@ -34,7 +34,7 @@ @msg[0].should == "ad hoc" @msg[1][0].should == "AF_INET" - @msg[1][1].should be_kind_of(Integer) + @msg[1][1].should.is_a?(Integer) @msg[1][3].should == "127.0.0.1" end @@ -46,7 +46,7 @@ @msg[0].should == "ad hoc" @msg[1][0].should == "AF_INET" - @msg[1][1].should be_kind_of(Integer) + @msg[1][1].should.is_a?(Integer) @msg[1][3].should == "127.0.0.1" end @@ -59,7 +59,7 @@ @msg[0].should == "connection-based" @msg[1][0].should == "AF_INET" - @msg[1][1].should be_kind_of(Integer) + @msg[1][1].should.is_a?(Integer) @msg[1][3].should == "127.0.0.1" end @@ -68,7 +68,7 @@ begin -> do @socket.send('1' * 100_000, 0, SocketSpecs.hostname, @port.to_s) - end.should raise_error(Errno::EMSGSIZE) + end.should.raise(Errno::EMSGSIZE) ensure @socket.send("ad hoc", 0, SocketSpecs.hostname, @port) @socket.close @@ -96,7 +96,7 @@ describe 'using a disconnected socket' do describe 'without a destination address' do it "raises #{SocketSpecs.dest_addr_req_error}" do - -> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error) + -> { @client.send('hello', 0) }.should.raise(SocketSpecs.dest_addr_req_error) end end @@ -108,7 +108,7 @@ it 'does not persist the connection after sending data' do @client.send('hello', 0, @addr.ip_address, @addr.ip_port) - -> { @client.send('hello', 0) }.should raise_error(SocketSpecs.dest_addr_req_error) + -> { @client.send('hello', 0) }.should.raise(SocketSpecs.dest_addr_req_error) end end diff --git a/spec/ruby/library/socket/udpsocket/write_spec.rb b/spec/ruby/library/socket/udpsocket/write_spec.rb index c971f29b6289f6..d41ee078d84273 100644 --- a/spec/ruby/library/socket/udpsocket/write_spec.rb +++ b/spec/ruby/library/socket/udpsocket/write_spec.rb @@ -12,7 +12,7 @@ -> do s2.write('1' * 100_000) - end.should raise_error(Errno::EMSGSIZE) + end.should.raise(Errno::EMSGSIZE) ensure s1.close if s1 && !s1.closed? s2.close if s2 && !s2.closed? diff --git a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb index f67941b296dca1..531d8516580a89 100644 --- a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb +++ b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb @@ -24,7 +24,7 @@ end it "returns a UNIXSocket" do - @socket.should be_kind_of(UNIXSocket) + @socket.should.is_a?(UNIXSocket) end it 'returns :wait_readable in exceptionless mode' do @@ -45,7 +45,7 @@ describe 'without a client' do it 'raises IO::WaitReadable' do - -> { @server.accept_nonblock }.should raise_error(IO::WaitReadable) + -> { @server.accept_nonblock }.should.raise(IO::WaitReadable) end end @@ -62,7 +62,7 @@ describe 'without any data' do it 'returns a UNIXSocket' do @socket = @server.accept_nonblock - @socket.should be_an_instance_of(UNIXSocket) + @socket.should.instance_of?(UNIXSocket) end end @@ -73,7 +73,7 @@ it 'returns a UNIXSocket' do @socket = @server.accept_nonblock - @socket.should be_an_instance_of(UNIXSocket) + @socket.should.instance_of?(UNIXSocket) end describe 'the returned UNIXSocket' do diff --git a/spec/ruby/library/socket/unixserver/accept_spec.rb b/spec/ruby/library/socket/unixserver/accept_spec.rb index cc2c922b6fca23..8f3ea50966fbe3 100644 --- a/spec/ruby/library/socket/unixserver/accept_spec.rb +++ b/spec/ruby/library/socket/unixserver/accept_spec.rb @@ -22,7 +22,7 @@ data, info = sock.recvfrom(5) data.should == 'hello' - info.should_not be_empty + info.should_not.empty? ensure sock.close client.close @@ -49,7 +49,7 @@ t = Thread.new { -> { @server.accept - }.should raise_error(Exception, "interrupted") + }.should.raise(Exception, "interrupted") } Thread.pass while t.status and t.status != "sleep" @@ -88,7 +88,7 @@ describe 'without any data' do it 'returns a UNIXSocket' do @socket = @server.accept - @socket.should be_an_instance_of(UNIXSocket) + @socket.should.instance_of?(UNIXSocket) end end @@ -99,7 +99,7 @@ it 'returns a UNIXSocket' do @socket = @server.accept - @socket.should be_an_instance_of(UNIXSocket) + @socket.should.instance_of?(UNIXSocket) end describe 'the returned UNIXSocket' do diff --git a/spec/ruby/library/socket/unixserver/initialize_spec.rb b/spec/ruby/library/socket/unixserver/initialize_spec.rb index 3728a307b05c2d..ca1dd301f0fb00 100644 --- a/spec/ruby/library/socket/unixserver/initialize_spec.rb +++ b/spec/ruby/library/socket/unixserver/initialize_spec.rb @@ -13,14 +13,14 @@ end it 'returns a new UNIXServer' do - @server.should be_an_instance_of(UNIXServer) + @server.should.instance_of?(UNIXServer) end it 'sets the socket to binmode' do - @server.binmode?.should be_true + @server.binmode?.should == true end it 'raises Errno::EADDRINUSE when the socket is already in use' do - -> { UNIXServer.new(@path) }.should raise_error(Errno::EADDRINUSE) + -> { UNIXServer.new(@path) }.should.raise(Errno::EADDRINUSE) end end diff --git a/spec/ruby/library/socket/unixserver/sysaccept_spec.rb b/spec/ruby/library/socket/unixserver/sysaccept_spec.rb index c4a4ecc824b618..5970c01114792e 100644 --- a/spec/ruby/library/socket/unixserver/sysaccept_spec.rb +++ b/spec/ruby/library/socket/unixserver/sysaccept_spec.rb @@ -32,7 +32,7 @@ describe 'without any data' do it 'returns an Integer' do @fd = @server.sysaccept - @fd.should be_kind_of(Integer) + @fd.should.is_a?(Integer) end end @@ -43,7 +43,7 @@ it 'returns an Integer' do @fd = @server.sysaccept - @fd.should be_kind_of(Integer) + @fd.should.is_a?(Integer) end end end diff --git a/spec/ruby/library/socket/unixsocket/addr_spec.rb b/spec/ruby/library/socket/unixsocket/addr_spec.rb index 1afe9b12dc4477..b3ae2af5d83671 100644 --- a/spec/ruby/library/socket/unixsocket/addr_spec.rb +++ b/spec/ruby/library/socket/unixsocket/addr_spec.rb @@ -15,7 +15,7 @@ end it "returns an array" do - @client.addr.should be_kind_of(Array) + @client.addr.should.is_a?(Array) end it "returns the address family of this socket in an array" do diff --git a/spec/ruby/library/socket/unixsocket/initialize_spec.rb b/spec/ruby/library/socket/unixsocket/initialize_spec.rb index 5dccfcc7456d24..ac30b93de0c3e5 100644 --- a/spec/ruby/library/socket/unixsocket/initialize_spec.rb +++ b/spec/ruby/library/socket/unixsocket/initialize_spec.rb @@ -5,14 +5,14 @@ describe 'using a non existing path' do platform_is_not :windows do it 'raises Errno::ENOENT' do - -> { UNIXSocket.new(SocketSpecs.socket_path) }.should raise_error(Errno::ENOENT) + -> { UNIXSocket.new(SocketSpecs.socket_path) }.should.raise(Errno::ENOENT) end end platform_is :windows do # Why, Windows, why? it 'raises Errno::ECONNREFUSED' do - -> { UNIXSocket.new(SocketSpecs.socket_path) }.should raise_error(Errno::ECONNREFUSED) + -> { UNIXSocket.new(SocketSpecs.socket_path) }.should.raise(Errno::ECONNREFUSED) end end end @@ -31,7 +31,7 @@ end it 'returns a new UNIXSocket' do - @socket.should be_an_instance_of(UNIXSocket) + @socket.should.instance_of?(UNIXSocket) end it 'sets the socket path to an empty String' do @@ -39,7 +39,7 @@ end it 'sets the socket to binmode' do - @socket.binmode?.should be_true + @socket.binmode?.should == true end platform_is_not :windows do diff --git a/spec/ruby/library/socket/unixsocket/local_address_spec.rb b/spec/ruby/library/socket/unixsocket/local_address_spec.rb index 0fdec3829305ad..fc504698c3b7e6 100644 --- a/spec/ruby/library/socket/unixsocket/local_address_spec.rb +++ b/spec/ruby/library/socket/unixsocket/local_address_spec.rb @@ -16,7 +16,7 @@ end it 'returns an Addrinfo' do - @client.local_address.should be_an_instance_of(Addrinfo) + @client.local_address.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do @@ -57,7 +57,7 @@ end it 'returns an Addrinfo' do - @sock.local_address.should be_an_instance_of(Addrinfo) + @sock.local_address.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do @@ -76,13 +76,13 @@ it 'raises SocketError for #ip_address' do -> { @sock.local_address.ip_address - }.should raise_error(SocketError, "need IPv4 or IPv6 address") + }.should.raise(SocketError, "need IPv4 or IPv6 address") end it 'raises SocketError for #ip_port' do -> { @sock.local_address.ip_port - }.should raise_error(SocketError, "need IPv4 or IPv6 address") + }.should.raise(SocketError, "need IPv4 or IPv6 address") end it 'uses 0 as the protocol' do diff --git a/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb b/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb index 10cab13b422a73..b586b1fcbb690e 100644 --- a/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb +++ b/spec/ruby/library/socket/unixsocket/peeraddr_spec.rb @@ -21,6 +21,6 @@ it "raises an error in server sockets" do -> { @server.peeraddr - }.should raise_error(Errno::ENOTCONN) + }.should.raise(Errno::ENOTCONN) 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 f0b408f30945fd..ac9d8923756a61 100644 --- a/spec/ruby/library/socket/unixsocket/recv_io_spec.rb +++ b/spec/ruby/library/socket/unixsocket/recv_io_spec.rb @@ -37,7 +37,7 @@ @socket = @server.accept @io = @socket.recv_io(File) - @io.should be_an_instance_of(File) + @io.should.instance_of?(File) end end @@ -59,7 +59,7 @@ @client.send_io(@file) @io = @server.recv_io - @io.should be_an_instance_of(IO) + @io.should.instance_of?(IO) end end @@ -68,7 +68,7 @@ @client.send_io(@file) @io = @server.recv_io(File) - @io.should be_an_instance_of(File) + @io.should.instance_of?(File) end end @@ -77,7 +77,7 @@ @client.send_io(@file) @io = @server.recv_io(File, File::WRONLY) - @io.should be_an_instance_of(File) + @io.should.instance_of?(File) end end end diff --git a/spec/ruby/library/socket/unixsocket/remote_address_spec.rb b/spec/ruby/library/socket/unixsocket/remote_address_spec.rb index 84bdff0a6a7dc5..d2303a6587c508 100644 --- a/spec/ruby/library/socket/unixsocket/remote_address_spec.rb +++ b/spec/ruby/library/socket/unixsocket/remote_address_spec.rb @@ -16,7 +16,7 @@ end it 'returns an Addrinfo' do - @client.remote_address.should be_an_instance_of(Addrinfo) + @client.remote_address.should.instance_of?(Addrinfo) end describe 'the returned Addrinfo' do diff --git a/spec/ruby/library/socket/unixsocket/send_io_spec.rb b/spec/ruby/library/socket/unixsocket/send_io_spec.rb index 52186ec3cf60f1..0063fc7d3f6d73 100644 --- a/spec/ruby/library/socket/unixsocket/send_io_spec.rb +++ b/spec/ruby/library/socket/unixsocket/send_io_spec.rb @@ -49,7 +49,7 @@ @client.send_io(@file) @io = @server.recv_io - @io.should be_an_instance_of(IO) + @io.should.instance_of?(IO) end end end diff --git a/spec/ruby/library/socket/unixsocket/shared/pair.rb b/spec/ruby/library/socket/unixsocket/shared/pair.rb index d68ee466bf1d61..49b6a6a4137808 100644 --- a/spec/ruby/library/socket/unixsocket/shared/pair.rb +++ b/spec/ruby/library/socket/unixsocket/shared/pair.rb @@ -3,8 +3,8 @@ describe :unixsocket_pair, shared: true do it "returns two UNIXSockets" do - @s1.should be_an_instance_of(UNIXSocket) - @s2.should be_an_instance_of(UNIXSocket) + @s1.should.instance_of?(UNIXSocket) + @s2.should.instance_of?(UNIXSocket) end it "returns a pair of connected sockets" do diff --git a/spec/ruby/library/stringio/append_spec.rb b/spec/ruby/library/stringio/append_spec.rb index cb50d73d1bf1b7..c21ba005080e20 100644 --- a/spec/ruby/library/stringio/append_spec.rb +++ b/spec/ruby/library/stringio/append_spec.rb @@ -7,7 +7,7 @@ end it "returns self" do - (@io << "just testing").should equal(@io) + (@io << "just testing").should.equal?(@io) end it "writes the passed argument onto self" do @@ -31,7 +31,7 @@ it "updates self's position" do @io << "test" - @io.pos.should eql(4) + @io.pos.should.eql?(4) end it "tries to convert the passed argument to a String using #to_s" do @@ -45,11 +45,11 @@ describe "StringIO#<< when self is not writable" do it "raises an IOError" do io = StringIO.new(+"test", "r") - -> { io << "test" }.should raise_error(IOError) + -> { io << "test" }.should.raise(IOError) io = StringIO.new(+"test") io.close_write - -> { io << "test" }.should raise_error(IOError) + -> { io << "test" }.should.raise(IOError) end end @@ -69,6 +69,6 @@ it "correctly updates self's position" do @io << ", testing" - @io.pos.should eql(16) + @io.pos.should.eql?(16) end end diff --git a/spec/ruby/library/stringio/binmode_spec.rb b/spec/ruby/library/stringio/binmode_spec.rb index 9e92c63814e84a..bc7ccda0a235fe 100644 --- a/spec/ruby/library/stringio/binmode_spec.rb +++ b/spec/ruby/library/stringio/binmode_spec.rb @@ -4,7 +4,7 @@ describe "StringIO#binmode" do it "returns self" do io = StringIO.new(+"example") - io.binmode.should equal(io) + io.binmode.should.equal?(io) end it "changes external encoding to BINARY" do diff --git a/spec/ruby/library/stringio/close_read_spec.rb b/spec/ruby/library/stringio/close_read_spec.rb index 0f08e1ff2e5958..dd46a927bee18d 100644 --- a/spec/ruby/library/stringio/close_read_spec.rb +++ b/spec/ruby/library/stringio/close_read_spec.rb @@ -7,12 +7,12 @@ end it "returns nil" do - @io.close_read.should be_nil + @io.close_read.should == nil end it "prevents further reading" do @io.close_read - -> { @io.read(1) }.should raise_error(IOError) + -> { @io.read(1) }.should.raise(IOError) end it "allows further writing" do @@ -22,7 +22,7 @@ it "raises an IOError when in write-only mode" do io = StringIO.new(+"example", "w") - -> { io.close_read }.should raise_error(IOError) + -> { io.close_read }.should.raise(IOError) io = StringIO.new("example") io.close_read diff --git a/spec/ruby/library/stringio/close_spec.rb b/spec/ruby/library/stringio/close_spec.rb index 520a8de7824d5e..6febd14a2602df 100644 --- a/spec/ruby/library/stringio/close_spec.rb +++ b/spec/ruby/library/stringio/close_spec.rb @@ -7,17 +7,17 @@ end it "returns nil" do - @io.close.should be_nil + @io.close.should == nil end it "prevents further reading and/or writing" do @io.close - -> { @io.read(1) }.should raise_error(IOError) - -> { @io.write('x') }.should raise_error(IOError) + -> { @io.read(1) }.should.raise(IOError) + -> { @io.write('x') }.should.raise(IOError) end it "does not raise anything when self was already closed" do @io.close - -> { @io.close }.should_not raise_error(IOError) + -> { @io.close }.should_not.raise(IOError) end end diff --git a/spec/ruby/library/stringio/close_write_spec.rb b/spec/ruby/library/stringio/close_write_spec.rb index c86c3f982622ed..b74b9961662846 100644 --- a/spec/ruby/library/stringio/close_write_spec.rb +++ b/spec/ruby/library/stringio/close_write_spec.rb @@ -7,12 +7,12 @@ end it "returns nil" do - @io.close_write.should be_nil + @io.close_write.should == nil end it "prevents further writing" do @io.close_write - -> { @io.write('x') }.should raise_error(IOError) + -> { @io.write('x') }.should.raise(IOError) end it "allows further reading" do @@ -22,7 +22,7 @@ it "raises an IOError when in read-only mode" do io = StringIO.new(+"example", "r") - -> { io.close_write }.should raise_error(IOError) + -> { io.close_write }.should.raise(IOError) io = StringIO.new(+"example") io.close_write diff --git a/spec/ruby/library/stringio/closed_read_spec.rb b/spec/ruby/library/stringio/closed_read_spec.rb index b4dcadc3a43e10..2e3813b1bce8b9 100644 --- a/spec/ruby/library/stringio/closed_read_spec.rb +++ b/spec/ruby/library/stringio/closed_read_spec.rb @@ -5,8 +5,8 @@ it "returns true if self is not readable" do io = StringIO.new(+"example", "r+") io.close_write - io.closed_read?.should be_false + io.closed_read?.should == false io.close_read - io.closed_read?.should be_true + io.closed_read?.should == true end end diff --git a/spec/ruby/library/stringio/closed_spec.rb b/spec/ruby/library/stringio/closed_spec.rb index bf7ba63184e7cb..647fe445da67b9 100644 --- a/spec/ruby/library/stringio/closed_spec.rb +++ b/spec/ruby/library/stringio/closed_spec.rb @@ -5,12 +5,12 @@ it "returns true if self is completely closed" do io = StringIO.new(+"example", "r+") io.close_read - io.closed?.should be_false + io.closed?.should == false io.close_write - io.closed?.should be_true + io.closed?.should == true io = StringIO.new(+"example", "r+") io.close - io.closed?.should be_true + io.closed?.should == true end end diff --git a/spec/ruby/library/stringio/closed_write_spec.rb b/spec/ruby/library/stringio/closed_write_spec.rb index 2bd3e6fa8b6a11..339691cd826182 100644 --- a/spec/ruby/library/stringio/closed_write_spec.rb +++ b/spec/ruby/library/stringio/closed_write_spec.rb @@ -5,8 +5,8 @@ it "returns true if self is not writable" do io = StringIO.new(+"example", "r+") io.close_read - io.closed_write?.should be_false + io.closed_write?.should == false io.close_write - io.closed_write?.should be_true + io.closed_write?.should == true end end diff --git a/spec/ruby/library/stringio/fcntl_spec.rb b/spec/ruby/library/stringio/fcntl_spec.rb index a78004d868dbc8..6108130db7e8ee 100644 --- a/spec/ruby/library/stringio/fcntl_spec.rb +++ b/spec/ruby/library/stringio/fcntl_spec.rb @@ -3,6 +3,6 @@ describe "StringIO#fcntl" do it "raises a NotImplementedError" do - -> { StringIO.new("boom").fcntl }.should raise_error(NotImplementedError) + -> { StringIO.new("boom").fcntl }.should.raise(NotImplementedError) end end diff --git a/spec/ruby/library/stringio/fileno_spec.rb b/spec/ruby/library/stringio/fileno_spec.rb index 5a9f440a0fc6f8..f5d1e83776fc69 100644 --- a/spec/ruby/library/stringio/fileno_spec.rb +++ b/spec/ruby/library/stringio/fileno_spec.rb @@ -3,6 +3,6 @@ describe "StringIO#fileno" do it "returns nil" do - StringIO.new("nuffin").fileno.should be_nil + StringIO.new("nuffin").fileno.should == nil end end diff --git a/spec/ruby/library/stringio/flush_spec.rb b/spec/ruby/library/stringio/flush_spec.rb index 4dc58b1d486128..48be44773ca87b 100644 --- a/spec/ruby/library/stringio/flush_spec.rb +++ b/spec/ruby/library/stringio/flush_spec.rb @@ -4,6 +4,6 @@ describe "StringIO#flush" do it "returns self" do io = StringIO.new(+"flush") - io.flush.should equal(io) + 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 85053cb2e5335a..30fae15c8e985c 100644 --- a/spec/ruby/library/stringio/fsync_spec.rb +++ b/spec/ruby/library/stringio/fsync_spec.rb @@ -4,6 +4,6 @@ describe "StringIO#fsync" do it "returns zero" do io = StringIO.new(+"fsync") - io.fsync.should eql(0) + 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 ac876f0b4f3521..5dc572fba563ae 100644 --- a/spec/ruby/library/stringio/gets_spec.rb +++ b/spec/ruby/library/stringio/gets_spec.rb @@ -10,8 +10,8 @@ @io = StringIO.new("this>is>an>example") @io.pos = 36 - @io.gets(">").should be_nil - @io.gets(">").should be_nil + @io.gets(">").should == nil + @io.gets(">").should == nil end end @@ -22,8 +22,8 @@ @io = StringIO.new("this>is>an>example") @io.pos = 36 - @io.gets(3).should be_nil - @io.gets(3).should be_nil + @io.gets(3).should == nil + @io.gets(3).should == nil end end @@ -34,8 +34,8 @@ @io = StringIO.new("this>is>an>example") @io.pos = 36 - @io.gets(">", 3).should be_nil - @io.gets(">", 3).should be_nil + @io.gets(">", 3).should == nil + @io.gets(">", 3).should == nil end end @@ -46,8 +46,8 @@ @io = StringIO.new("this>is>an>example") @io.pos = 36 - @io.gets.should be_nil - @io.gets.should be_nil + @io.gets.should == nil + @io.gets.should == nil end end diff --git a/spec/ruby/library/stringio/initialize_spec.rb b/spec/ruby/library/stringio/initialize_spec.rb index 6f4d2e456c2f70..413e0aacc048f3 100644 --- a/spec/ruby/library/stringio/initialize_spec.rb +++ b/spec/ruby/library/stringio/initialize_spec.rb @@ -8,111 +8,111 @@ it "uses the passed Object as the StringIO backend" do @io.send(:initialize, str = "example", "r") - @io.string.should equal(str) + @io.string.should.equal?(str) end it "sets the mode based on the passed mode" do io = StringIO.allocate io.send(:initialize, +"example", "r") - io.closed_read?.should be_false - io.closed_write?.should be_true + io.closed_read?.should == false + io.closed_write?.should == true io = StringIO.allocate io.send(:initialize, +"example", "rb") - io.closed_read?.should be_false - io.closed_write?.should be_true + io.closed_read?.should == false + io.closed_write?.should == true io = StringIO.allocate io.send(:initialize, +"example", "r+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", "rb+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", "w") - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", "wb") - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", "w+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", "wb+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", "a") - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", "ab") - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", "a+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", "ab+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false end it "allows passing the mode as an Integer" do io = StringIO.allocate io.send(:initialize, +"example", IO::RDONLY) - io.closed_read?.should be_false - io.closed_write?.should be_true + io.closed_read?.should == false + io.closed_write?.should == true io = StringIO.allocate io.send(:initialize, +"example", IO::RDWR) - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", IO::WRONLY) - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", IO::WRONLY | IO::TRUNC) - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", IO::RDWR | IO::TRUNC) - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", IO::WRONLY | IO::APPEND) - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.allocate io.send(:initialize, +"example", IO::RDWR | IO::APPEND) - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false end it "raises a FrozenError when passed a frozen String in truncate mode as StringIO backend" do io = StringIO.allocate - -> { io.send(:initialize, "example".freeze, IO::TRUNC) }.should raise_error(FrozenError) + -> { io.send(:initialize, "example".freeze, IO::TRUNC) }.should.raise(FrozenError) end it "tries to convert the passed mode to a String using #to_str" do @@ -120,15 +120,15 @@ obj.should_receive(:to_str).and_return("r") @io.send(:initialize, +"example", obj) - @io.closed_read?.should be_false - @io.closed_write?.should be_true + @io.closed_read?.should == false + @io.closed_write?.should == true end it "raises an Errno::EACCES error when passed a frozen string with a write-mode" do (str = "example").freeze - -> { @io.send(:initialize, str, "r+") }.should raise_error(Errno::EACCES) - -> { @io.send(:initialize, str, "w") }.should raise_error(Errno::EACCES) - -> { @io.send(:initialize, str, "a") }.should raise_error(Errno::EACCES) + -> { @io.send(:initialize, str, "r+") }.should.raise(Errno::EACCES) + -> { @io.send(:initialize, str, "w") }.should.raise(Errno::EACCES) + -> { @io.send(:initialize, str, "a") }.should.raise(Errno::EACCES) end it "truncates all the content if passed w mode" do @@ -159,19 +159,19 @@ it "uses the passed Object as the StringIO backend" do @io.send(:initialize, str = "example") - @io.string.should equal(str) + @io.string.should.equal?(str) end 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 + @io.closed_read?.should == false + @io.closed_write?.should == 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 + @io.closed_read?.should == false + @io.closed_write?.should == true end it "tries to convert the passed Object to a String using #to_str" do @@ -184,8 +184,8 @@ it "automatically sets the mode to read-only when passed a frozen string" do (str = "example").freeze @io.send(:initialize, str) - @io.closed_read?.should be_false - @io.closed_write?.should be_true + @io.closed_read?.should == false + @io.closed_write?.should == true end end @@ -193,8 +193,8 @@ describe "StringIO#initialize when passed keyword arguments" do it "sets the mode based on the passed :mode option" do io = StringIO.new("example", mode: "r") - io.closed_read?.should be_false - io.closed_write?.should be_true + io.closed_read?.should == false + io.closed_write?.should == true end it "accepts a mode argument set to nil with a valid :mode option" do @@ -223,54 +223,54 @@ 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) + }.should.raise(ArgumentError) -> { @io = StringIO.new(+'', 'w:ISO-8859-1', external_encoding: 'ISO-8859-1') - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = StringIO.new(+'', 'w:ISO-8859-1:UTF-8', internal_encoding: 'ISO-8859-1') - }.should raise_error(ArgumentError) + }.should.raise(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) + }.should.raise(ArgumentError) -> { @io = StringIO.new(+'', "wt", textmode: true) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = StringIO.new(+'', "wb", textmode: false) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = StringIO.new(+'', "wt", binmode: false) - }.should raise_error(ArgumentError) + }.should.raise(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) + }.should.raise(ArgumentError) -> { @io = StringIO.new(+'', "wt", textmode: false) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = StringIO.new(+'', "wb", textmode: true) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) -> { @io = StringIO.new(+'', "wt", binmode: true) - }.should raise_error(ArgumentError) + }.should.raise(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) + }.should.raise(ArgumentError) -> { @io = StringIO.new(+'', File::Constants::WRONLY, textmode: true, binmode: true) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -280,13 +280,13 @@ end it "is private" do - StringIO.should have_private_instance_method(:initialize) + StringIO.private_instance_methods(false).should.include?(:initialize) end it "sets the mode to read-write" do @io.send(:initialize) - @io.closed_read?.should be_false - @io.closed_write?.should be_false + @io.closed_read?.should == false + @io.closed_write?.should == false end it "uses an empty String as the StringIO backend" do diff --git a/spec/ruby/library/stringio/inspect_spec.rb b/spec/ruby/library/stringio/inspect_spec.rb index 7c02f8d3609ae9..962d858e4826b8 100644 --- a/spec/ruby/library/stringio/inspect_spec.rb +++ b/spec/ruby/library/stringio/inspect_spec.rb @@ -9,7 +9,7 @@ it "does not include the contents" do io = StringIO.new("contents") - io.inspect.should_not include("contents") + io.inspect.should_not.include?("contents") end it "uses the regular Object#inspect without any instance variable" do diff --git a/spec/ruby/library/stringio/lineno_spec.rb b/spec/ruby/library/stringio/lineno_spec.rb index c620a1a68683f2..a96dc05927cd4e 100644 --- a/spec/ruby/library/stringio/lineno_spec.rb +++ b/spec/ruby/library/stringio/lineno_spec.rb @@ -10,7 +10,7 @@ @io.gets @io.gets @io.gets - @io.lineno.should eql(3) + @io.lineno.should.eql?(3) end end @@ -21,10 +21,10 @@ it "sets the current line number, but has no impact on the position" do @io.lineno = 3 - @io.pos.should eql(0) + @io.pos.should.eql?(0) @io.gets.should == "this\n" - @io.lineno.should eql(4) - @io.pos.should eql(5) + @io.lineno.should.eql?(4) + @io.pos.should.eql?(5) end end diff --git a/spec/ruby/library/stringio/open_spec.rb b/spec/ruby/library/stringio/open_spec.rb index b7c90661f992a3..23c7b34e0936c5 100644 --- a/spec/ruby/library/stringio/open_spec.rb +++ b/spec/ruby/library/stringio/open_spec.rb @@ -4,24 +4,24 @@ describe "StringIO.open when passed [Object, mode]" do it "uses the passed Object as the StringIO backend" do io = StringIO.open(str = "example", "r") - io.string.should equal(str) + io.string.should.equal?(str) end it "returns the blocks return value when yielding" do ret = StringIO.open(+"example", "r") { :test } - ret.should equal(:test) + ret.should.equal?(:test) end it "yields self to the passed block" do io = nil StringIO.open(+"example", "r") { |strio| io = strio } - io.should be_kind_of(StringIO) + io.should.is_a?(StringIO) end it "closes self after yielding" do io = nil StringIO.open(+"example", "r") { |strio| io = strio } - io.closed?.should be_true + io.closed?.should == true end it "even closes self when an exception is raised while yielding" do @@ -33,13 +33,13 @@ end rescue end - io.closed?.should be_true + io.closed?.should == true end it "sets self's string to nil after yielding" do io = nil StringIO.open(+"example", "r") { |strio| io = strio } - io.string.should be_nil + io.string.should == nil end it "even sets self's string to nil when an exception is raised while yielding" do @@ -51,91 +51,91 @@ end rescue end - io.string.should be_nil + io.string.should == nil end it "sets the mode based on the passed mode" do io = StringIO.open(+"example", "r") - io.closed_read?.should be_false - io.closed_write?.should be_true + io.closed_read?.should == false + io.closed_write?.should == true io = StringIO.open(+"example", "rb") - io.closed_read?.should be_false - io.closed_write?.should be_true + io.closed_read?.should == false + io.closed_write?.should == true io = StringIO.open(+"example", "r+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.open(+"example", "rb+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.open(+"example", "w") - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.open(+"example", "wb") - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.open(+"example", "w+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.open(+"example", "wb+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.open(+"example", "a") - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.open(+"example", "ab") - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.open(+"example", "a+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.open(+"example", "ab+") - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false end it "allows passing the mode as an Integer" do io = StringIO.open(+"example", IO::RDONLY) - io.closed_read?.should be_false - io.closed_write?.should be_true + io.closed_read?.should == false + io.closed_write?.should == true io = StringIO.open(+"example", IO::RDWR) - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.open(+"example", IO::WRONLY) - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.open(+"example", IO::WRONLY | IO::TRUNC) - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.open(+"example", IO::RDWR | IO::TRUNC) - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false io = StringIO.open(+"example", IO::WRONLY | IO::APPEND) - io.closed_read?.should be_true - io.closed_write?.should be_false + io.closed_read?.should == true + io.closed_write?.should == false io = StringIO.open(+"example", IO::RDWR | IO::APPEND) - io.closed_read?.should be_false - io.closed_write?.should be_false + io.closed_read?.should == false + io.closed_write?.should == false end it "raises a FrozenError when passed a frozen String in truncate mode as StringIO backend" do - -> { StringIO.open("example".freeze, IO::TRUNC) }.should raise_error(FrozenError) + -> { StringIO.open("example".freeze, IO::TRUNC) }.should.raise(FrozenError) end it "tries to convert the passed mode to a String using #to_str" do @@ -143,34 +143,34 @@ obj.should_receive(:to_str).and_return("r") io = StringIO.open(+"example", obj) - io.closed_read?.should be_false - io.closed_write?.should be_true + io.closed_read?.should == false + io.closed_write?.should == true end it "raises an Errno::EACCES error when passed a frozen string with a write-mode" do (str = "example").freeze - -> { StringIO.open(str, "r+") }.should raise_error(Errno::EACCES) - -> { StringIO.open(str, "w") }.should raise_error(Errno::EACCES) - -> { StringIO.open(str, "a") }.should raise_error(Errno::EACCES) + -> { StringIO.open(str, "r+") }.should.raise(Errno::EACCES) + -> { StringIO.open(str, "w") }.should.raise(Errno::EACCES) + -> { StringIO.open(str, "a") }.should.raise(Errno::EACCES) end end describe "StringIO.open when passed [Object]" do it "uses the passed Object as the StringIO backend" do io = StringIO.open(str = "example") - io.string.should equal(str) + io.string.should.equal?(str) end it "yields self to the passed block" do io = nil ret = StringIO.open(+"example") { |strio| io = strio } - io.should equal(ret) + io.should.equal?(ret) end 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.closed_read?.should == false + io.closed_write?.should == false io = StringIO.new(+"example") io.printf("%d", 123) @@ -187,8 +187,8 @@ it "automatically sets the mode to read-only when passed a frozen string" do (str = "example").freeze io = StringIO.open(str) - io.closed_read?.should be_false - io.closed_write?.should be_true + io.closed_read?.should == false + io.closed_write?.should == true end end @@ -196,13 +196,13 @@ it "yields self to the passed block" do io = nil ret = StringIO.open { |strio| io = strio } - io.should equal(ret) + io.should.equal?(ret) end 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.closed_read?.should == false + io.closed_write?.should == false io = StringIO.new(+"example") io.printf("%d", 123) diff --git a/spec/ruby/library/stringio/path_spec.rb b/spec/ruby/library/stringio/path_spec.rb index 1184ca523ff962..dcb77b1df8b3d6 100644 --- a/spec/ruby/library/stringio/path_spec.rb +++ b/spec/ruby/library/stringio/path_spec.rb @@ -3,6 +3,6 @@ describe "StringIO#path" do it "is not defined" do - -> { StringIO.new("path").path }.should raise_error(NoMethodError) + -> { StringIO.new("path").path }.should.raise(NoMethodError) end end diff --git a/spec/ruby/library/stringio/pid_spec.rb b/spec/ruby/library/stringio/pid_spec.rb index 08f2d7ab1a9636..7a729fbe41e16e 100644 --- a/spec/ruby/library/stringio/pid_spec.rb +++ b/spec/ruby/library/stringio/pid_spec.rb @@ -3,6 +3,6 @@ describe "StringIO#pid" do it "returns nil" do - StringIO.new("pid").pid.should be_nil + StringIO.new("pid").pid.should == nil end end diff --git a/spec/ruby/library/stringio/pos_spec.rb b/spec/ruby/library/stringio/pos_spec.rb index 81be5f01a52880..ba640f8c18e022 100644 --- a/spec/ruby/library/stringio/pos_spec.rb +++ b/spec/ruby/library/stringio/pos_spec.rb @@ -17,7 +17,7 @@ end it "raises an EINVAL if given a negative argument" do - -> { @io.pos = -10 }.should raise_error(Errno::EINVAL) + -> { @io.pos = -10 }.should.raise(Errno::EINVAL) end it "updates the current byte offset after reaching EOF" do diff --git a/spec/ruby/library/stringio/print_spec.rb b/spec/ruby/library/stringio/print_spec.rb index 00c33367dc695e..48728e5f14419c 100644 --- a/spec/ruby/library/stringio/print_spec.rb +++ b/spec/ruby/library/stringio/print_spec.rb @@ -29,7 +29,7 @@ end it "returns nil" do - @io.print(1, 2, 3).should be_nil + @io.print(1, 2, 3).should == nil end it "pads self with \\000 when the current position is after the end" do @@ -52,10 +52,10 @@ it "updates the current position" do @io.print(1, 2, 3) - @io.pos.should eql(3) + @io.pos.should.eql?(3) @io.print(1, 2, 3) - @io.pos.should eql(6) + @io.pos.should.eql?(6) end it "correctly updates the current position when honoring the output record separator global" do @@ -64,7 +64,7 @@ begin @io.print(5, 6, 7, 8) - @io.pos.should eql(5) + @io.pos.should.eql?(5) ensure suppress_warning {$\ = old_rs} end @@ -86,17 +86,17 @@ it "correctly updates self's position" do @io.print(", testing") - @io.pos.should eql(16) + @io.pos.should.eql?(16) end end describe "StringIO#print when self is not writable" do it "raises an IOError" do io = StringIO.new(+"test", "r") - -> { io.print("test") }.should raise_error(IOError) + -> { io.print("test") }.should.raise(IOError) io = StringIO.new(+"test") io.close_write - -> { io.print("test") }.should raise_error(IOError) + -> { io.print("test") }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/printf_spec.rb b/spec/ruby/library/stringio/printf_spec.rb index ca82e847575e1d..ae7e0af729c3ec 100644 --- a/spec/ruby/library/stringio/printf_spec.rb +++ b/spec/ruby/library/stringio/printf_spec.rb @@ -8,7 +8,7 @@ end it "returns nil" do - @io.printf("%d %04x", 123, 123).should be_nil + @io.printf("%d %04x", 123, 123).should == nil end it "pads self with \\000 when the current position is after the end" do @@ -24,10 +24,10 @@ it "updates the current position" do @io.printf("%d %04x", 123, 123) - @io.pos.should eql(8) + @io.pos.should.eql?(8) @io.printf("%d %04x", 123, 123) - @io.pos.should eql(16) + @io.pos.should.eql?(16) end describe "formatting" do @@ -56,7 +56,7 @@ it "correctly updates self's position" do @io.printf("%s", "abc") - @io.pos.should eql(3) + @io.pos.should.eql?(3) end end @@ -75,17 +75,17 @@ it "correctly updates self's position" do @io.printf("%d %04x", 123, 123) - @io.pos.should eql(15) + @io.pos.should.eql?(15) end end describe "StringIO#printf when self is not writable" do it "raises an IOError" do io = StringIO.new(+"test", "r") - -> { io.printf("test") }.should raise_error(IOError) + -> { io.printf("test") }.should.raise(IOError) io = StringIO.new(+"test") io.close_write - -> { io.printf("test") }.should raise_error(IOError) + -> { io.printf("test") }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/putc_spec.rb b/spec/ruby/library/stringio/putc_spec.rb index 9f1ac8ffb2b50e..742f8623eb8bb5 100644 --- a/spec/ruby/library/stringio/putc_spec.rb +++ b/spec/ruby/library/stringio/putc_spec.rb @@ -22,7 +22,7 @@ it "returns the passed String" do str = "test" - @io.putc(str).should equal(str) + @io.putc(str).should.equal?(str) end it "correctly updates the current position" do @@ -79,7 +79,7 @@ end it "raises a TypeError when the passed argument can't be coerced to Integer" do - -> { @io.putc(Object.new) }.should raise_error(TypeError) + -> { @io.putc(Object.new) }.should.raise(TypeError) end end @@ -94,10 +94,10 @@ describe "StringIO#putc when self is not writable" do it "raises an IOError" do io = StringIO.new(+"test", "r") - -> { io.putc(?a) }.should raise_error(IOError) + -> { io.putc(?a) }.should.raise(IOError) io = StringIO.new(+"test") io.close_write - -> { io.putc("t") }.should raise_error(IOError) + -> { io.putc("t") }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/puts_spec.rb b/spec/ruby/library/stringio/puts_spec.rb index 054ec8227f5563..ebe74d4a45e3d3 100644 --- a/spec/ruby/library/stringio/puts_spec.rb +++ b/spec/ruby/library/stringio/puts_spec.rb @@ -123,7 +123,7 @@ end it "returns nil" do - @io.puts.should be_nil + @io.puts.should == nil end it "prints a newline" do @@ -158,18 +158,18 @@ it "correctly updates self's position" do @io.puts(", testing") - @io.pos.should eql(17) + @io.pos.should.eql?(17) end end describe "StringIO#puts when self is not writable" do it "raises an IOError" do io = StringIO.new(+"test", "r") - -> { io.puts }.should raise_error(IOError) + -> { io.puts }.should.raise(IOError) io = StringIO.new(+"test") io.close_write - -> { io.puts }.should raise_error(IOError) + -> { io.puts }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/read_nonblock_spec.rb b/spec/ruby/library/stringio/read_nonblock_spec.rb index 74736f7792dc86..38ae7541ca5753 100644 --- a/spec/ruby/library/stringio/read_nonblock_spec.rb +++ b/spec/ruby/library/stringio/read_nonblock_spec.rb @@ -45,7 +45,7 @@ stringio.rewind stringio.read_nonblock(5).should == "hello" - stringio.read_nonblock(5, exception: false).should be_nil + stringio.read_nonblock(5, exception: false).should == nil end end end diff --git a/spec/ruby/library/stringio/read_spec.rb b/spec/ruby/library/stringio/read_spec.rb index e49f26212719f2..9a2086a6827885 100644 --- a/spec/ruby/library/stringio/read_spec.rb +++ b/spec/ruby/library/stringio/read_spec.rb @@ -39,7 +39,7 @@ it "returns nil when self's position is at the end" do @io.pos = 7 - @io.read(10).should be_nil + @io.read(10).should == nil end it "returns an empty String when length is 0" do @@ -57,6 +57,6 @@ result = @io.read(10, buf) buf.should == "abcdefghij" - result.should equal(buf) + result.should.equal?(buf) end end diff --git a/spec/ruby/library/stringio/readline_spec.rb b/spec/ruby/library/stringio/readline_spec.rb index 085360707f8634..3f026080e21960 100644 --- a/spec/ruby/library/stringio/readline_spec.rb +++ b/spec/ruby/library/stringio/readline_spec.rb @@ -11,7 +11,7 @@ @io = StringIO.new("this>is>an>example") @io.pos = 36 - -> { @io.readline(">") }.should raise_error(IOError) + -> { @io.readline(">") }.should.raise(IOError) end end @@ -22,7 +22,7 @@ @io = StringIO.new("this>is>an>example") @io.pos = 36 - -> { @io.readline(3) }.should raise_error(IOError) + -> { @io.readline(3) }.should.raise(IOError) end end @@ -33,7 +33,7 @@ @io = StringIO.new("this>is>an>example") @io.pos = 36 - -> { @io.readline(">", 3) }.should raise_error(IOError) + -> { @io.readline(">", 3) }.should.raise(IOError) end end @@ -44,7 +44,7 @@ @io = StringIO.new("this>is>an>example") @io.pos = 36 - -> { @io.readline }.should raise_error(IOError) + -> { @io.readline }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/readlines_spec.rb b/spec/ruby/library/stringio/readlines_spec.rb index ed7cc22b3d7ca4..821a8169e7ac66 100644 --- a/spec/ruby/library/stringio/readlines_spec.rb +++ b/spec/ruby/library/stringio/readlines_spec.rb @@ -12,12 +12,12 @@ it "updates self's position based on the number of read bytes" do @io.readlines(">") - @io.pos.should eql(18) + @io.pos.should.eql?(18) end it "updates self's lineno based on the number of read lines" do @io.readlines(">") - @io.lineno.should eql(4) + @io.lineno.should.eql?(4) end it "does not change $_" do @@ -61,12 +61,12 @@ it "updates self's position based on the number of read bytes" do @io.readlines - @io.pos.should eql(41) + @io.pos.should.eql?(41) end it "updates self's lineno based on the number of read lines" do @io.readlines - @io.lineno.should eql(3) + @io.lineno.should.eql?(3) end it "does not change $_" do @@ -84,11 +84,11 @@ describe "StringIO#readlines when in write-only mode" do it "raises an IOError" do io = StringIO.new(+"xyz", "w") - -> { io.readlines }.should raise_error(IOError) + -> { io.readlines }.should.raise(IOError) io = StringIO.new("xyz") io.close_read - -> { io.readlines }.should raise_error(IOError) + -> { io.readlines }.should.raise(IOError) end end @@ -109,7 +109,7 @@ end it "raises ArgumentError when limit is 0" do - -> { @io.readlines(0) }.should raise_error(ArgumentError) + -> { @io.readlines(0) }.should.raise(ArgumentError) end it "ignores it when the limit is negative" do diff --git a/spec/ruby/library/stringio/readpartial_spec.rb b/spec/ruby/library/stringio/readpartial_spec.rb index dadefb783732a1..e05d9bded445a7 100644 --- a/spec/ruby/library/stringio/readpartial_spec.rb +++ b/spec/ruby/library/stringio/readpartial_spec.rb @@ -57,23 +57,23 @@ it "raises EOFError on EOF" do @string.readpartial(18).should == 'Stop, look, listen' - -> { @string.readpartial(10) }.should raise_error(EOFError) + -> { @string.readpartial(10) }.should.raise(EOFError) end it "discards the existing buffer content upon error" do buffer = +'hello' @string.readpartial(100) - -> { @string.readpartial(1, buffer) }.should raise_error(EOFError) - buffer.should be_empty + -> { @string.readpartial(1, buffer) }.should.raise(EOFError) + buffer.should.empty? end it "raises IOError if the stream is closed" do @string.close - -> { @string.readpartial(1) }.should raise_error(IOError, "not opened for reading") + -> { @string.readpartial(1) }.should.raise(IOError, "not opened for reading") end it "raises ArgumentError if the negative argument is provided" do - -> { @string.readpartial(-1) }.should raise_error(ArgumentError, "negative length -1 given") + -> { @string.readpartial(-1) }.should.raise(ArgumentError, "negative length -1 given") end it "immediately returns an empty string if the length argument is 0" do @@ -82,7 +82,7 @@ it "raises IOError if the stream is closed and the length argument is 0" do @string.close - -> { @string.readpartial(0) }.should raise_error(IOError, "not opened for reading") + -> { @string.readpartial(0) }.should.raise(IOError, "not opened for reading") end it "clears and returns the given buffer if the length argument is 0" do diff --git a/spec/ruby/library/stringio/reopen_spec.rb b/spec/ruby/library/stringio/reopen_spec.rb index 7021ff17e5cd9d..3d4ae3a698399f 100644 --- a/spec/ruby/library/stringio/reopen_spec.rb +++ b/spec/ruby/library/stringio/reopen_spec.rb @@ -8,18 +8,18 @@ it "reopens self with the passed Object in the passed mode" do @io.reopen("reopened", IO::RDONLY) - @io.closed_read?.should be_false - @io.closed_write?.should be_true + @io.closed_read?.should == false + @io.closed_write?.should == true @io.string.should == "reopened" @io.reopen(+"reopened, twice", IO::WRONLY) - @io.closed_read?.should be_true - @io.closed_write?.should be_false + @io.closed_read?.should == true + @io.closed_write?.should == false @io.string.should == "reopened, twice" @io.reopen(+"reopened, another time", IO::RDWR) - @io.closed_read?.should be_false - @io.closed_write?.should be_false + @io.closed_read?.should == false + @io.closed_write?.should == false @io.string.should == "reopened, another time" end @@ -31,16 +31,16 @@ end it "raises a TypeError when the passed Object can't be converted to a String" do - -> { @io.reopen(Object.new, IO::RDWR) }.should raise_error(TypeError) + -> { @io.reopen(Object.new, IO::RDWR) }.should.raise(TypeError) end it "raises an Errno::EACCES when trying to reopen self with a frozen String in write-mode" do - -> { @io.reopen("burn".freeze, IO::WRONLY) }.should raise_error(Errno::EACCES) - -> { @io.reopen("burn".freeze, IO::WRONLY | IO::APPEND) }.should raise_error(Errno::EACCES) + -> { @io.reopen("burn".freeze, IO::WRONLY) }.should.raise(Errno::EACCES) + -> { @io.reopen("burn".freeze, IO::WRONLY | IO::APPEND) }.should.raise(Errno::EACCES) end it "raises a FrozenError when trying to reopen self with a frozen String in truncate-mode" do - -> { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should raise_error(FrozenError) + -> { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should.raise(FrozenError) end it "does not raise IOError when passed a frozen String in read-mode" do @@ -56,23 +56,23 @@ it "reopens self with the passed Object in the passed mode" do @io.reopen("reopened", "r") - @io.closed_read?.should be_false - @io.closed_write?.should be_true + @io.closed_read?.should == false + @io.closed_write?.should == true @io.string.should == "reopened" @io.reopen(+"reopened, twice", "r+") - @io.closed_read?.should be_false - @io.closed_write?.should be_false + @io.closed_read?.should == false + @io.closed_write?.should == false @io.string.should == "reopened, twice" @io.reopen(+"reopened, another", "w+") - @io.closed_read?.should be_false - @io.closed_write?.should be_false + @io.closed_read?.should == false + @io.closed_write?.should == false @io.string.should == "" @io.reopen(+"reopened, another time", "r+") - @io.closed_read?.should be_false - @io.closed_write?.should be_false + @io.closed_read?.should == false + @io.closed_write?.should == false @io.string.should == "reopened, another time" end @@ -89,35 +89,35 @@ end it "raises a TypeError when the passed Object can't be converted to a String using #to_str" do - -> { @io.reopen(Object.new, "r") }.should raise_error(TypeError) + -> { @io.reopen(Object.new, "r") }.should.raise(TypeError) end it "resets self's position to 0" do @io.read(5) @io.reopen(+"reopened") - @io.pos.should eql(0) + @io.pos.should.eql?(0) end it "resets self's line number to 0" do @io.gets @io.reopen(+"reopened") - @io.lineno.should eql(0) + @io.lineno.should.eql?(0) end it "tries to convert the passed mode Object to an Integer using #to_str" do obj = mock("to_str") obj.should_receive(:to_str).and_return("r") @io.reopen("reopened", obj) - @io.closed_read?.should be_false - @io.closed_write?.should be_true + @io.closed_read?.should == false + @io.closed_write?.should == true @io.string.should == "reopened" end it "raises an Errno::EACCES error when trying to reopen self with a frozen String in write-mode" do - -> { @io.reopen("burn".freeze, 'w') }.should raise_error(Errno::EACCES) - -> { @io.reopen("burn".freeze, 'w+') }.should raise_error(Errno::EACCES) - -> { @io.reopen("burn".freeze, 'a') }.should raise_error(Errno::EACCES) - -> { @io.reopen("burn".freeze, "r+") }.should raise_error(Errno::EACCES) + -> { @io.reopen("burn".freeze, 'w') }.should.raise(Errno::EACCES) + -> { @io.reopen("burn".freeze, 'w+') }.should.raise(Errno::EACCES) + -> { @io.reopen("burn".freeze, 'a') }.should.raise(Errno::EACCES) + -> { @io.reopen("burn".freeze, "r+") }.should.raise(Errno::EACCES) end it "does not raise IOError if a frozen string is passed in read mode" do @@ -136,8 +136,8 @@ @io.reopen(+"reopened") - @io.closed_write?.should be_false - @io.closed_read?.should be_false + @io.closed_write?.should == false + @io.closed_read?.should == false @io.string.should == "reopened" end @@ -145,13 +145,13 @@ it "resets self's position to 0" do @io.read(5) @io.reopen(+"reopened") - @io.pos.should eql(0) + @io.pos.should.eql?(0) end it "resets self's line number to 0" do @io.gets @io.reopen(+"reopened") - @io.lineno.should eql(0) + @io.lineno.should.eql?(0) end end @@ -161,13 +161,13 @@ end it "raises a TypeError when passed an Object that can't be converted to a StringIO" do - -> { @io.reopen(Object.new) }.should raise_error(TypeError) + -> { @io.reopen(Object.new) }.should.raise(TypeError) end it "does not try to convert the passed Object to a String using #to_str" do obj = mock("not to_str") obj.should_not_receive(:to_str) - -> { @io.reopen(obj) }.should raise_error(TypeError) + -> { @io.reopen(obj) }.should.raise(TypeError) end it "tries to convert the passed Object to a StringIO using #to_strio" do @@ -186,20 +186,20 @@ it "resets self's mode to read-write" do @io.close @io.reopen - @io.closed_read?.should be_false - @io.closed_write?.should be_false + @io.closed_read?.should == false + @io.closed_write?.should == false end it "resets self's position to 0" do @io.read(5) @io.reopen - @io.pos.should eql(0) + @io.pos.should.eql?(0) end it "resets self's line number to 0" do @io.gets @io.reopen - @io.lineno.should eql(0) + @io.lineno.should.eql?(0) end end diff --git a/spec/ruby/library/stringio/rewind_spec.rb b/spec/ruby/library/stringio/rewind_spec.rb index 5f885ecf814118..8c48709d89073a 100644 --- a/spec/ruby/library/stringio/rewind_spec.rb +++ b/spec/ruby/library/stringio/rewind_spec.rb @@ -9,7 +9,7 @@ end it "returns 0" do - @io.rewind.should eql(0) + @io.rewind.should.eql?(0) end it "resets the position" do diff --git a/spec/ruby/library/stringio/seek_spec.rb b/spec/ruby/library/stringio/seek_spec.rb index 253b5027a97da9..9043e0338fb380 100644 --- a/spec/ruby/library/stringio/seek_spec.rb +++ b/spec/ruby/library/stringio/seek_spec.rb @@ -9,18 +9,18 @@ it "seeks from the current position when whence is IO::SEEK_CUR" do @io.pos = 1 @io.seek(1, IO::SEEK_CUR) - @io.pos.should eql(2) + @io.pos.should.eql?(2) @io.seek(-1, IO::SEEK_CUR) - @io.pos.should eql(1) + @io.pos.should.eql?(1) end it "seeks from the end of self when whence is IO::SEEK_END" do @io.seek(3, IO::SEEK_END) - @io.pos.should eql(11) # Outside of the StringIO's content + @io.pos.should.eql?(11) # Outside of the StringIO's content @io.seek(-2, IO::SEEK_END) - @io.pos.should eql(6) + @io.pos.should.eql?(6) end it "seeks to an absolute position when whence is IO::SEEK_SET" do @@ -33,25 +33,25 @@ end it "raises an Errno::EINVAL error on negative amounts when whence is IO::SEEK_SET" do - -> { @io.seek(-5, IO::SEEK_SET) }.should raise_error(Errno::EINVAL) + -> { @io.seek(-5, IO::SEEK_SET) }.should.raise(Errno::EINVAL) end it "raises an Errno::EINVAL error on incorrect whence argument" do - -> { @io.seek(0, 3) }.should raise_error(Errno::EINVAL) - -> { @io.seek(0, -1) }.should raise_error(Errno::EINVAL) - -> { @io.seek(0, 2**16) }.should raise_error(Errno::EINVAL) - -> { @io.seek(0, -2**16) }.should raise_error(Errno::EINVAL) + -> { @io.seek(0, 3) }.should.raise(Errno::EINVAL) + -> { @io.seek(0, -1) }.should.raise(Errno::EINVAL) + -> { @io.seek(0, 2**16) }.should.raise(Errno::EINVAL) + -> { @io.seek(0, -2**16) }.should.raise(Errno::EINVAL) end it "tries to convert the passed Object to a String using #to_int" do obj = mock("to_int") obj.should_receive(:to_int).and_return(2) @io.seek(obj) - @io.pos.should eql(2) + @io.pos.should.eql?(2) end it "raises a TypeError when the passed Object can't be converted to an Integer" do - -> { @io.seek(Object.new) }.should raise_error(TypeError) + -> { @io.seek(Object.new) }.should.raise(TypeError) end end @@ -62,6 +62,6 @@ end it "raises an IOError" do - -> { @io.seek(5) }.should raise_error(IOError) + -> { @io.seek(5) }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/set_encoding_by_bom_spec.rb b/spec/ruby/library/stringio/set_encoding_by_bom_spec.rb index 1030aad042c419..b4583a7ad77af3 100644 --- a/spec/ruby/library/stringio/set_encoding_by_bom_spec.rb +++ b/spec/ruby/library/stringio/set_encoding_by_bom_spec.rb @@ -6,7 +6,7 @@ it "returns nil if not readable" do io = StringIO.new("".b, "wb") - io.set_encoding_by_bom.should be_nil + io.set_encoding_by_bom.should == nil io.external_encoding.should == Encoding::ASCII_8BIT end @@ -82,7 +82,7 @@ it "returns nil if io is empty" do io = StringIO.new("".b, "rb") - io.set_encoding_by_bom.should be_nil + io.set_encoding_by_bom.should == nil io.external_encoding.should == Encoding::ASCII_8BIT end @@ -227,7 +227,7 @@ it "raises FrozenError when io is frozen" do io = StringIO.new() io.freeze - -> { io.set_encoding_by_bom }.should raise_error(FrozenError) + -> { io.set_encoding_by_bom }.should.raise(FrozenError) end it "does not raise FrozenError when initial string is frozen" do diff --git a/spec/ruby/library/stringio/shared/codepoints.rb b/spec/ruby/library/stringio/shared/codepoints.rb index 25333bb0fd2f52..e35a02ccb48cc2 100644 --- a/spec/ruby/library/stringio/shared/codepoints.rb +++ b/spec/ruby/library/stringio/shared/codepoints.rb @@ -6,7 +6,7 @@ end it "returns an Enumerator" do - @enum.should be_an_instance_of(Enumerator) + @enum.should.instance_of?(Enumerator) end it "yields each codepoint code in turn" do @@ -20,15 +20,15 @@ it "raises an error if reading invalid sequence" do @io.pos = 1 # inside of a multibyte sequence - -> { @enum.first }.should raise_error(ArgumentError) + -> { @enum.first }.should.raise(ArgumentError) end it "raises an IOError if not readable" do @io.close_read - -> { @enum.to_a }.should raise_error(IOError) + -> { @enum.to_a }.should.raise(IOError) io = StringIO.new(+"xyz", "w") - -> { io.send(@method).to_a }.should raise_error(IOError) + -> { io.send(@method).to_a }.should.raise(IOError) end @@ -39,7 +39,7 @@ end it "returns self" do - @io.send(@method) {|l| l }.should equal(@io) + @io.send(@method) {|l| l }.should.equal?(@io) end end diff --git a/spec/ruby/library/stringio/shared/each.rb b/spec/ruby/library/stringio/shared/each.rb index 626b41a4d36318..04e40b6b2a7650 100644 --- a/spec/ruby/library/stringio/shared/each.rb +++ b/spec/ruby/library/stringio/shared/each.rb @@ -16,7 +16,7 @@ end it "returns self" do - @io.send(@method) {|l| l }.should equal(@io) + @io.send(@method) {|l| l }.should.equal?(@io) end it "tries to convert the passed separator to a String using #to_str" do @@ -74,19 +74,19 @@ old_rs = $/ suppress_warning {$/ = " "} @io.send(@method) {|s| seen << s } - seen.should eql(["a ", "b ", "c ", "d ", "e\n1 ", "2 ", "3 ", "4 ", "5"]) + seen.should.eql?(["a ", "b ", "c ", "d ", "e\n1 ", "2 ", "3 ", "4 ", "5"]) ensure suppress_warning {$/ = old_rs} end end it "returns self" do - @io.send(@method) {|l| l }.should equal(@io) + @io.send(@method) {|l| l }.should.equal?(@io) end it "returns an Enumerator when passed no block" do enum = @io.send(@method) - enum.instance_of?(Enumerator).should be_true + enum.instance_of?(Enumerator).should == true seen = [] enum.each { |b| seen << b } @@ -97,11 +97,11 @@ describe :stringio_each_not_readable, shared: true do it "raises an IOError" do io = StringIO.new(+"a b c d e", "w") - -> { io.send(@method) { |b| b } }.should raise_error(IOError) + -> { io.send(@method) { |b| b } }.should.raise(IOError) io = StringIO.new("a b c d e") io.close_read - -> { io.send(@method) { |b| b } }.should raise_error(IOError) + -> { io.send(@method) { |b| b } }.should.raise(IOError) end end @@ -176,13 +176,13 @@ it "updates self's lineno by one" do @io.send(@method, '>', 3) { |s| break s } - @io.lineno.should eql(1) + @io.lineno.should.eql?(1) @io.send(@method, '>', 3) { |s| break s } - @io.lineno.should eql(2) + @io.lineno.should.eql?(2) @io.send(@method, '>', 3) { |s| break s } - @io.lineno.should eql(3) + @io.lineno.should.eql?(3) end it "tries to convert the passed separator to a String using #to_str" do # TODO diff --git a/spec/ruby/library/stringio/shared/each_byte.rb b/spec/ruby/library/stringio/shared/each_byte.rb index b51fa38f2f5295..b3939c26de4984 100644 --- a/spec/ruby/library/stringio/shared/each_byte.rb +++ b/spec/ruby/library/stringio/shared/each_byte.rb @@ -19,16 +19,16 @@ @io.pos = 1000 seen = nil @io.send(@method) { |b| seen = b } - seen.should be_nil + seen.should == nil end it "returns self" do - @io.send(@method) {}.should equal(@io) + @io.send(@method) {}.should.equal?(@io) end it "returns an Enumerator when passed no block" do enum = @io.send(@method) - enum.instance_of?(Enumerator).should be_true + enum.instance_of?(Enumerator).should == true seen = [] enum.each { |b| seen << b } @@ -39,10 +39,10 @@ describe :stringio_each_byte_not_readable, shared: true do it "raises an IOError" do io = StringIO.new(+"xyz", "w") - -> { io.send(@method) { |b| b } }.should raise_error(IOError) + -> { io.send(@method) { |b| b } }.should.raise(IOError) io = StringIO.new("xyz") io.close_read - -> { io.send(@method) { |b| b } }.should raise_error(IOError) + -> { io.send(@method) { |b| b } }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/shared/each_char.rb b/spec/ruby/library/stringio/shared/each_char.rb index 197237c1c85094..4215a9952b8d6f 100644 --- a/spec/ruby/library/stringio/shared/each_char.rb +++ b/spec/ruby/library/stringio/shared/each_char.rb @@ -11,12 +11,12 @@ end it "returns self" do - @io.send(@method) {}.should equal(@io) + @io.send(@method) {}.should.equal?(@io) end it "returns an Enumerator when passed no block" do enum = @io.send(@method) - enum.instance_of?(Enumerator).should be_true + enum.instance_of?(Enumerator).should == true seen = [] enum.each { |c| seen << c } @@ -27,10 +27,10 @@ describe :stringio_each_char_not_readable, shared: true do it "raises an IOError" do io = StringIO.new(+"xyz", "w") - -> { io.send(@method) { |b| b } }.should raise_error(IOError) + -> { io.send(@method) { |b| b } }.should.raise(IOError) io = StringIO.new("xyz") io.close_read - -> { io.send(@method) { |b| b } }.should raise_error(IOError) + -> { io.send(@method) { |b| b } }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/shared/eof.rb b/spec/ruby/library/stringio/shared/eof.rb index e0368a2892c4a0..a9489581fcca57 100644 --- a/spec/ruby/library/stringio/shared/eof.rb +++ b/spec/ruby/library/stringio/shared/eof.rb @@ -5,20 +5,20 @@ it "returns true when self's position is greater than or equal to self's size" do @io.pos = 3 - @io.send(@method).should be_true + @io.send(@method).should == true @io.pos = 6 - @io.send(@method).should be_true + @io.send(@method).should == true end it "returns false when self's position is less than self's size" do @io.pos = 0 - @io.send(@method).should be_false + @io.send(@method).should == false @io.pos = 1 - @io.send(@method).should be_false + @io.send(@method).should == false @io.pos = 2 - @io.send(@method).should be_false + @io.send(@method).should == false end end diff --git a/spec/ruby/library/stringio/shared/getc.rb b/spec/ruby/library/stringio/shared/getc.rb index ba65040bce0798..a146b2d4cfa3f4 100644 --- a/spec/ruby/library/stringio/shared/getc.rb +++ b/spec/ruby/library/stringio/shared/getc.rb @@ -5,39 +5,39 @@ it "increases self's position by one" do @io.send(@method) - @io.pos.should eql(1) + @io.pos.should.eql?(1) @io.send(@method) - @io.pos.should eql(2) + @io.pos.should.eql?(2) @io.send(@method) - @io.pos.should eql(3) + @io.pos.should.eql?(3) end it "returns nil when called at the end of self" do @io.pos = 7 - @io.send(@method).should be_nil - @io.send(@method).should be_nil - @io.send(@method).should be_nil + @io.send(@method).should == nil + @io.send(@method).should == nil + @io.send(@method).should == nil end it "does not increase self's position when called at the end of file" do @io.pos = 7 @io.send(@method) - @io.pos.should eql(7) + @io.pos.should.eql?(7) @io.send(@method) - @io.pos.should eql(7) + @io.pos.should.eql?(7) end end describe :stringio_getc_not_readable, shared: true do it "raises an IOError" do io = StringIO.new(+"xyz", "w") - -> { io.send(@method) }.should raise_error(IOError) + -> { io.send(@method) }.should.raise(IOError) io = StringIO.new("xyz") io.close_read - -> { io.send(@method) }.should raise_error(IOError) + -> { io.send(@method) }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/shared/gets.rb b/spec/ruby/library/stringio/shared/gets.rb index 8396b161f1d03a..16039b18efbc72 100644 --- a/spec/ruby/library/stringio/shared/gets.rb +++ b/spec/ruby/library/stringio/shared/gets.rb @@ -33,13 +33,13 @@ it "updates self's lineno by one" do @io.send(@method, ">") - @io.lineno.should eql(1) + @io.lineno.should.eql?(1) @io.send(@method, ">") - @io.lineno.should eql(2) + @io.lineno.should.eql?(2) @io.send(@method, ">") - @io.lineno.should eql(3) + @io.lineno.should.eql?(3) end it "returns the next paragraph when the passed separator is an empty String" do @@ -88,13 +88,13 @@ it "updates self's lineno by one" do @io.send(@method, 3) - @io.lineno.should eql(1) + @io.lineno.should.eql?(1) @io.send(@method, 3) - @io.lineno.should eql(2) + @io.lineno.should.eql?(2) @io.send(@method, 3) - @io.lineno.should eql(3) + @io.lineno.should.eql?(3) end it "tries to convert the passed limit to an Integer using #to_int" do @@ -146,13 +146,13 @@ it "updates self's lineno by one" do @io.send(@method, '>', 3) - @io.lineno.should eql(1) + @io.lineno.should.eql?(1) @io.send(@method, '>', 3) - @io.lineno.should eql(2) + @io.lineno.should.eql?(2) @io.send(@method, '>', 3) - @io.lineno.should eql(3) + @io.lineno.should.eql?(3) end it "tries to convert the passed separator to a String using #to_str" do @@ -204,24 +204,24 @@ it "updates self's position" do @io.send(@method) - @io.pos.should eql(8) + @io.pos.should.eql?(8) @io.send(@method) - @io.pos.should eql(19) + @io.pos.should.eql?(19) @io.send(@method) - @io.pos.should eql(36) + @io.pos.should.eql?(36) end it "updates self's lineno" do @io.send(@method) - @io.lineno.should eql(1) + @io.lineno.should.eql?(1) @io.send(@method) - @io.lineno.should eql(2) + @io.lineno.should.eql?(2) @io.send(@method) - @io.lineno.should eql(3) + @io.lineno.should.eql?(3) end end end @@ -239,11 +239,11 @@ describe "when in write-only mode" do it "raises an IOError" do io = StringIO.new(+"xyz", "w") - -> { io.send(@method) }.should raise_error(IOError) + -> { io.send(@method) }.should.raise(IOError) io = StringIO.new("xyz") io.close_read - -> { io.send(@method) }.should raise_error(IOError) + -> { io.send(@method) }.should.raise(IOError) end end end diff --git a/spec/ruby/library/stringio/shared/isatty.rb b/spec/ruby/library/stringio/shared/isatty.rb index c9e7ee73214cc7..2b92e8d6563517 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 == false end end diff --git a/spec/ruby/library/stringio/shared/read.rb b/spec/ruby/library/stringio/shared/read.rb index 22f76b0fb01bbe..6e04e75dbaf6b7 100644 --- a/spec/ruby/library/stringio/shared/read.rb +++ b/spec/ruby/library/stringio/shared/read.rb @@ -5,9 +5,9 @@ it "returns the passed buffer String" do # Note: Rubinius bug: - # @io.send(@method, 7, buffer = +"").should equal(buffer) + # @io.send(@method, 7, buffer = +"").should.equal?(buffer) ret = @io.send(@method, 7, buffer = +"") - ret.should equal(buffer) + ret.should.equal?(buffer) end it "reads length bytes and writes them to the buffer String" do @@ -42,11 +42,11 @@ end it "raises a TypeError when the passed buffer Object can't be converted to a String" do - -> { @io.send(@method, 7, Object.new) }.should raise_error(TypeError) + -> { @io.send(@method, 7, Object.new) }.should.raise(TypeError) end it "raises a FrozenError error when passed a frozen String as buffer" do - -> { @io.send(@method, 7, "".freeze) }.should raise_error(FrozenError) + -> { @io.send(@method, 7, "".freeze) }.should.raise(FrozenError) end end @@ -66,10 +66,10 @@ it "correctly updates the position" do @io.send(@method, 3) - @io.pos.should eql(3) + @io.pos.should.eql?(3) @io.send(@method, 999) - @io.pos.should eql(7) + @io.pos.should.eql?(7) end it "tries to convert the passed length to an Integer using #to_int" do @@ -79,11 +79,11 @@ end it "raises a TypeError when the passed length can't be converted to an Integer" do - -> { @io.send(@method, Object.new) }.should raise_error(TypeError) + -> { @io.send(@method, Object.new) }.should.raise(TypeError) end it "raises a TypeError when the passed length is negative" do - -> { @io.send(@method, -2) }.should raise_error(ArgumentError) + -> { @io.send(@method, -2) }.should.raise(ArgumentError) end it "returns a binary String" do @@ -105,13 +105,13 @@ it "correctly updates the current position" do @io.send(@method) - @io.pos.should eql(7) + @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) + @io.pos.should.eql?(9) end end @@ -129,17 +129,17 @@ it "updates the current position" do @io.send(@method, nil) - @io.pos.should eql(7) + @io.pos.should.eql?(7) end end describe :stringio_read_not_readable, shared: true do it "raises an IOError" do io = StringIO.new(+"test", "w") - -> { io.send(@method) }.should raise_error(IOError) + -> { io.send(@method) }.should.raise(IOError) io = StringIO.new("test") io.close_read - -> { io.send(@method) }.should raise_error(IOError) + -> { io.send(@method) }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/shared/readchar.rb b/spec/ruby/library/stringio/shared/readchar.rb index 72d7446c362d15..5ac28e07435f02 100644 --- a/spec/ruby/library/stringio/shared/readchar.rb +++ b/spec/ruby/library/stringio/shared/readchar.rb @@ -13,17 +13,17 @@ it "raises an EOFError when self is at the end" do @io.pos = 7 - -> { @io.send(@method) }.should raise_error(EOFError) + -> { @io.send(@method) }.should.raise(EOFError) end end describe :stringio_readchar_not_readable, shared: true do it "raises an IOError" do io = StringIO.new(+"a b c d e", "w") - -> { io.send(@method) }.should raise_error(IOError) + -> { io.send(@method) }.should.raise(IOError) io = StringIO.new("a b c d e") io.close_read - -> { io.send(@method) }.should raise_error(IOError) + -> { io.send(@method) }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/shared/sysread.rb b/spec/ruby/library/stringio/shared/sysread.rb index 3e23fbc2335129..bc448d33796bcb 100644 --- a/spec/ruby/library/stringio/shared/sysread.rb +++ b/spec/ruby/library/stringio/shared/sysread.rb @@ -10,6 +10,6 @@ it "raises an EOFError when passed length > 0 and no data remains" do @io.read.should == "example" - -> { @io.send(@method, 1) }.should raise_error(EOFError) + -> { @io.send(@method, 1) }.should.raise(EOFError) end end diff --git a/spec/ruby/library/stringio/shared/write.rb b/spec/ruby/library/stringio/shared/write.rb index 4661658bafaee3..b6bffe7f12458c 100644 --- a/spec/ruby/library/stringio/shared/write.rb +++ b/spec/ruby/library/stringio/shared/write.rb @@ -42,7 +42,7 @@ it "updates self's position" do @io.send(@method, 'test') - @io.pos.should eql(4) + @io.pos.should.eql?(4) end it "handles concurrent writes correctly" do @@ -107,11 +107,11 @@ describe :stringio_write_not_writable, shared: true do it "raises an IOError" do io = StringIO.new(+"test", "r") - -> { io.send(@method, "test") }.should raise_error(IOError) + -> { io.send(@method, "test") }.should.raise(IOError) io = StringIO.new(+"test") io.close_write - -> { io.send(@method, "test") }.should raise_error(IOError) + -> { io.send(@method, "test") }.should.raise(IOError) end end @@ -130,6 +130,6 @@ it "correctly updates self's position" do @io.send(@method, ", testing") - @io.pos.should eql(16) + @io.pos.should.eql?(16) end end diff --git a/spec/ruby/library/stringio/string_spec.rb b/spec/ruby/library/stringio/string_spec.rb index 1ed5233ba66131..3b27243da90928 100644 --- a/spec/ruby/library/stringio/string_spec.rb +++ b/spec/ruby/library/stringio/string_spec.rb @@ -4,7 +4,7 @@ describe "StringIO#string" do it "returns the underlying string" do io = StringIO.new(str = "hello") - io.string.should equal(str) + io.string.should.equal?(str) end end @@ -15,25 +15,25 @@ it "returns the passed String" do str = "test" - (@io.string = str).should equal(str) + (@io.string = str).should.equal?(str) end it "changes the underlying string" do str = "hello" @io.string = str - @io.string.should equal(str) + @io.string.should.equal?(str) end it "resets the position" do @io.pos = 1 @io.string = "other" - @io.pos.should eql(0) + @io.pos.should.eql?(0) end it "resets the line number" do @io.lineno = 1 @io.string = "other" - @io.lineno.should eql(0) + @io.lineno.should.eql?(0) end it "tries to convert the passed Object to a String using #to_str" do @@ -45,6 +45,6 @@ end it "raises a TypeError when the passed Object can't be converted to an Integer" do - -> { @io.seek(Object.new) }.should raise_error(TypeError) + -> { @io.seek(Object.new) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/stringio/stringio_spec.rb b/spec/ruby/library/stringio/stringio_spec.rb index 5ef42b3390c5b1..dee0364ab0e97f 100644 --- a/spec/ruby/library/stringio/stringio_spec.rb +++ b/spec/ruby/library/stringio/stringio_spec.rb @@ -3,6 +3,6 @@ describe "StringIO" do it "includes the Enumerable module" do - StringIO.should include(Enumerable) + StringIO.should.include?(Enumerable) end end diff --git a/spec/ruby/library/stringio/sync_spec.rb b/spec/ruby/library/stringio/sync_spec.rb index e717a5697b18ce..d7d1209047b507 100644 --- a/spec/ruby/library/stringio/sync_spec.rb +++ b/spec/ruby/library/stringio/sync_spec.rb @@ -3,7 +3,7 @@ describe "StringIO#sync" do it "returns true" do - StringIO.new('').sync.should be_true + StringIO.new('').sync.should == true end end @@ -14,6 +14,6 @@ it "does not change 'sync' status" do @io.sync = false - @io.sync.should be_true + @io.sync.should == true end end diff --git a/spec/ruby/library/stringio/sysread_spec.rb b/spec/ruby/library/stringio/sysread_spec.rb index fabb06dd9a66b3..1403dab5cb31b9 100644 --- a/spec/ruby/library/stringio/sysread_spec.rb +++ b/spec/ruby/library/stringio/sysread_spec.rb @@ -44,7 +44,7 @@ it "raises an EOFError when self's position is at the end" do @io.pos = 7 - -> { @io.sysread(10) }.should raise_error(EOFError) + -> { @io.sysread(10) }.should.raise(EOFError) end it "returns an empty String when length is 0" do diff --git a/spec/ruby/library/stringio/truncate_spec.rb b/spec/ruby/library/stringio/truncate_spec.rb index 592ca5a6e1854d..7205261141d208 100644 --- a/spec/ruby/library/stringio/truncate_spec.rb +++ b/spec/ruby/library/stringio/truncate_spec.rb @@ -7,7 +7,7 @@ end it "returns an Integer" do - @io.truncate(4).should be_kind_of(Integer) + @io.truncate(4).should.is_a?(Integer) end it "truncated the underlying string down to the passed length" do @@ -18,13 +18,13 @@ it "does not create a copy of the underlying string" do io = StringIO.new(str = +"123456789") io.truncate(4) - io.string.should equal(str) + io.string.should.equal?(str) end it "does not change the position" do @io.pos = 7 @io.truncate(4) - @io.pos.should eql(7) + @io.pos.should.eql?(7) end it "can grow a string to a larger size, padding it with \\000" do @@ -33,8 +33,8 @@ end it "raises an Errno::EINVAL when the passed length is negative" do - -> { @io.truncate(-1) }.should raise_error(Errno::EINVAL) - -> { @io.truncate(-10) }.should raise_error(Errno::EINVAL) + -> { @io.truncate(-1) }.should.raise(Errno::EINVAL) + -> { @io.truncate(-10) }.should.raise(Errno::EINVAL) end it "tries to convert the passed length to an Integer using #to_int" do @@ -46,17 +46,17 @@ 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) + -> { @io.truncate(Object.new) }.should.raise(TypeError) end end describe "StringIO#truncate when self is not writable" do it "raises an IOError" do io = StringIO.new(+"test", "r") - -> { io.truncate(2) }.should raise_error(IOError) + -> { io.truncate(2) }.should.raise(IOError) io = StringIO.new(+"test") io.close_write - -> { io.truncate(2) }.should raise_error(IOError) + -> { io.truncate(2) }.should.raise(IOError) end end diff --git a/spec/ruby/library/stringio/ungetc_spec.rb b/spec/ruby/library/stringio/ungetc_spec.rb index bceafa79ffa007..8753ac9666e55b 100644 --- a/spec/ruby/library/stringio/ungetc_spec.rb +++ b/spec/ruby/library/stringio/ungetc_spec.rb @@ -14,13 +14,13 @@ it "returns nil" do @io.pos = 1 - @io.ungetc(?A).should be_nil + @io.ungetc(?A).should == nil end it "decreases the current position by one" do @io.pos = 2 @io.ungetc(?A) - @io.pos.should eql(1) + @io.pos.should.eql?(1) end it "pads with \\000 when the current position is after the end" do @@ -39,7 +39,7 @@ end it "raises a TypeError when the passed length can't be converted to an Integer or String" do - -> { @io.ungetc(Object.new) }.should raise_error(TypeError) + -> { @io.ungetc(Object.new) }.should.raise(TypeError) end end @@ -47,12 +47,12 @@ it "raises an IOError" do io = StringIO.new(+"test", "w") io.pos = 1 - -> { io.ungetc(?A) }.should raise_error(IOError) + -> { io.ungetc(?A) }.should.raise(IOError) io = StringIO.new(+"test") io.pos = 1 io.close_read - -> { io.ungetc(?A) }.should raise_error(IOError) + -> { io.ungetc(?A) }.should.raise(IOError) end end @@ -62,11 +62,11 @@ # it "raises an IOError" do # io = StringIO.new(+"test", "r") # io.pos = 1 -# lambda { io.ungetc(?A) }.should raise_error(IOError) +# lambda { io.ungetc(?A) }.should.raise(IOError) # # io = StringIO.new(+"test") # io.pos = 1 # io.close_write -# lambda { io.ungetc(?A) }.should raise_error(IOError) +# lambda { io.ungetc(?A) }.should.raise(IOError) # end # end diff --git a/spec/ruby/library/stringscanner/check_spec.rb b/spec/ruby/library/stringscanner/check_spec.rb index 5e855e154ad4de..232158b09e997a 100644 --- a/spec/ruby/library/stringscanner/check_spec.rb +++ b/spec/ruby/library/stringscanner/check_spec.rb @@ -33,7 +33,7 @@ it "returns nil when matching failed" do @s.check(/(?2008)/) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end @@ -43,21 +43,21 @@ it "returns nil when matching succeeded" do @s.check("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4" it "raises IndexError when matching succeeded" do @s.check("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end it "returns nil when matching failed" do @s.check("2008") @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end it "returns a matching substring when given Integer index" do @@ -74,7 +74,7 @@ @s.check("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.0"..."3.4.3" @@ -85,7 +85,7 @@ @s.check("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/check_until_spec.rb b/spec/ruby/library/stringscanner/check_until_spec.rb index 582da66b375a9f..b4ef35d9f76828 100644 --- a/spec/ruby/library/stringscanner/check_until_spec.rb +++ b/spec/ruby/library/stringscanner/check_until_spec.rb @@ -24,7 +24,7 @@ it "raises TypeError if given a String" do -> { @s.check_until('T') - }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)') + }.should.raise(TypeError, 'wrong argument type String (expected Regexp)') end end @@ -67,7 +67,7 @@ it "returns nil when matching failed" do @s.check_until(/(?2008)/) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end @@ -78,21 +78,21 @@ it "returns nil when matching succeeded" do @s.check_until("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3" it "raises IndexError when matching succeeded" do @s.check_until("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end it "returns nil when matching failed" do @s.check_until("2008") @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end it "returns a matching substring when given Integer index" do @@ -109,7 +109,7 @@ @s.check_until("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.0"..."3.4.3" @@ -120,7 +120,7 @@ @s.check_until("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/dup_spec.rb b/spec/ruby/library/stringscanner/dup_spec.rb index 0fc52a1477ef72..0118964526941e 100644 --- a/spec/ruby/library/stringscanner/dup_spec.rb +++ b/spec/ruby/library/stringscanner/dup_spec.rb @@ -15,7 +15,7 @@ it "copies the passed StringScanner's position to self" do @orig_s.pos = 5 s = @orig_s.dup - s.pos.should eql(5) + s.pos.should.eql?(5) end it "copies previous match state" do @@ -34,6 +34,6 @@ it "copies the passed StringScanner scan pointer to self" do @orig_s.terminate s = @orig_s.dup - s.eos?.should be_true + s.eos?.should == true end end diff --git a/spec/ruby/library/stringscanner/element_reference_spec.rb b/spec/ruby/library/stringscanner/element_reference_spec.rb index 91b6d86dc75155..bcd48ede61aded 100644 --- a/spec/ruby/library/stringscanner/element_reference_spec.rb +++ b/spec/ruby/library/stringscanner/element_reference_spec.rb @@ -7,8 +7,8 @@ end it "returns nil if there is no current match" do - @s[0].should be_nil - @s[:wday].should be_nil + @s[0].should == nil + @s[:wday].should == nil end it "returns the n-th subgroup in the most recent match" do @@ -35,24 +35,24 @@ it "raises a TypeError if the given index is nil" do @s.scan(/(\w+) (\w+) (\d+) /) - -> { @s[nil]}.should raise_error(TypeError) + -> { @s[nil]}.should.raise(TypeError) end it "raises a TypeError when a Range is as argument" do @s.scan(/(\w+) (\w+) (\d+) /) - -> { @s[0..2]}.should raise_error(TypeError) + -> { @s[0..2]}.should.raise(TypeError) end it "raises a IndexError when there's no any named capture group in the regexp" do @s.scan(/(\w+) (\w+) (\d+) /) - -> { @s["wday"]}.should raise_error(IndexError) - -> { @s[:wday]}.should raise_error(IndexError) + -> { @s["wday"]}.should.raise(IndexError) + -> { @s[:wday]}.should.raise(IndexError) end it "raises a IndexError when given a not existing capture group name" do @s.scan(/(?\w+) (?\w+) (?\d+) /) - -> { @s["wday"]}.should raise_error(IndexError) - -> { @s[:wday]}.should raise_error(IndexError) + -> { @s["wday"]}.should.raise(IndexError) + -> { @s[:wday]}.should.raise(IndexError) end it "returns named capture" do diff --git a/spec/ruby/library/stringscanner/exist_spec.rb b/spec/ruby/library/stringscanner/exist_spec.rb index a408fd0b8dc1c7..22076223669412 100644 --- a/spec/ruby/library/stringscanner/exist_spec.rb +++ b/spec/ruby/library/stringscanner/exist_spec.rb @@ -32,7 +32,7 @@ it "raises TypeError if given a String" do -> { @s.exist?('T') - }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)') + }.should.raise(TypeError, 'wrong argument type String (expected Regexp)') end end @@ -57,7 +57,7 @@ it "returns nil when matching failed" do @s.exist?(/(?2008)/) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end @@ -68,21 +68,21 @@ it "returns nil when matching succeeded" do @s.exist?("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3" it "raises IndexError when matching succeeded" do @s.exist?("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end it "returns nil when matching failed" do @s.exist?("2008") @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end it "returns a matching substring when given Integer index" do @@ -99,7 +99,7 @@ @s.exist?("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.0"..."3.4.3" @@ -110,7 +110,7 @@ @s.exist?("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/get_byte_spec.rb b/spec/ruby/library/stringscanner/get_byte_spec.rb index 144859abc92a8c..b989b73883c22c 100644 --- a/spec/ruby/library/stringscanner/get_byte_spec.rb +++ b/spec/ruby/library/stringscanner/get_byte_spec.rb @@ -37,7 +37,7 @@ s = StringScanner.new("This is a test") s.get_byte s.should.matched? - s[:a].should be_nil + s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3" @@ -45,7 +45,7 @@ s = StringScanner.new("This is a test") s.get_byte s.should.matched? - -> { s[:a] }.should raise_error(IndexError) + -> { s[:a] }.should.raise(IndexError) end end @@ -65,7 +65,7 @@ s.get_byte s.should.matched? - s[:a].should be_nil + s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3" @@ -77,7 +77,7 @@ s.get_byte s.should.matched? - -> { s[:a] }.should raise_error(IndexError) + -> { s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/getch_spec.rb b/spec/ruby/library/stringscanner/getch_spec.rb index 868422047dd1a1..cd41b4336a67b7 100644 --- a/spec/ruby/library/stringscanner/getch_spec.rb +++ b/spec/ruby/library/stringscanner/getch_spec.rb @@ -45,7 +45,7 @@ s = StringScanner.new("This is a test") s.getch s.should.matched? - s[:a].should be_nil + s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3" @@ -53,7 +53,7 @@ s = StringScanner.new("This is a test") s.getch s.should.matched? - -> { s[:a] }.should raise_error(IndexError) + -> { s[:a] }.should.raise(IndexError) end end @@ -74,7 +74,7 @@ s.getch s.should.matched? - s[:a].should be_nil + s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.0"..."3.4.3" @@ -87,7 +87,7 @@ s.getch s.should.matched? - -> { s[:a] }.should raise_error(IndexError) + -> { s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/initialize_spec.rb b/spec/ruby/library/stringscanner/initialize_spec.rb index 77f6084c1b7768..fdab4d381ca834 100644 --- a/spec/ruby/library/stringscanner/initialize_spec.rb +++ b/spec/ruby/library/stringscanner/initialize_spec.rb @@ -7,12 +7,12 @@ end it "is a private method" do - StringScanner.should have_private_instance_method(:initialize) + StringScanner.private_instance_methods(false).should.include?(:initialize) end it "returns an instance of StringScanner" do - @s.should be_kind_of(StringScanner) - @s.eos?.should be_false + @s.should.is_a?(StringScanner) + @s.eos?.should == false end it "converts the argument into a string using #to_str" do diff --git a/spec/ruby/library/stringscanner/inspect_spec.rb b/spec/ruby/library/stringscanner/inspect_spec.rb index ff6b97eb9166a0..570d0b7b10641b 100644 --- a/spec/ruby/library/stringscanner/inspect_spec.rb +++ b/spec/ruby/library/stringscanner/inspect_spec.rb @@ -7,7 +7,7 @@ end it "returns a String object" do - @s.inspect.should be_kind_of(String) + @s.inspect.should.is_a?(String) end it "returns a string that represents the StringScanner object" do diff --git a/spec/ruby/library/stringscanner/match_spec.rb b/spec/ruby/library/stringscanner/match_spec.rb index a27bb51d72c9c2..c2bc49324b43fc 100644 --- a/spec/ruby/library/stringscanner/match_spec.rb +++ b/spec/ruby/library/stringscanner/match_spec.rb @@ -45,7 +45,7 @@ it "returns nil when matching failed" do @s.match?(/(?2008)/) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end end diff --git a/spec/ruby/library/stringscanner/matched_spec.rb b/spec/ruby/library/stringscanner/matched_spec.rb index c020bd3eae2852..95b57574c52fff 100644 --- a/spec/ruby/library/stringscanner/matched_spec.rb +++ b/spec/ruby/library/stringscanner/matched_spec.rb @@ -31,11 +31,11 @@ it "returns true if the last match was successful" do @s.match?(/\w+/) - @s.matched?.should be_true + @s.matched?.should == true end it "returns false if there's no match" do @s.match?(/\d+/) - @s.matched?.should be_false + @s.matched?.should == false end end diff --git a/spec/ruby/library/stringscanner/peek_spec.rb b/spec/ruby/library/stringscanner/peek_spec.rb index d490abecf9661e..5b54c6be0b6db3 100644 --- a/spec/ruby/library/stringscanner/peek_spec.rb +++ b/spec/ruby/library/stringscanner/peek_spec.rb @@ -22,11 +22,11 @@ end it "raises a ArgumentError when the passed argument is negative" do - -> { @s.peek(-2) }.should raise_error(ArgumentError) + -> { @s.peek(-2) }.should.raise(ArgumentError) end it "raises a RangeError when the passed argument is a Bignum" do - -> { @s.peek(bignum_value) }.should raise_error(RangeError) + -> { @s.peek(bignum_value) }.should.raise(RangeError) end it "returns an instance of String when passed a String subclass" do @@ -36,7 +36,7 @@ s = StringScanner.new(sub) ch = s.peek(1) - ch.should_not be_kind_of(cls) - ch.should be_an_instance_of(String) + ch.should_not.is_a?(cls) + ch.should.instance_of?(String) end end diff --git a/spec/ruby/library/stringscanner/rest_spec.rb b/spec/ruby/library/stringscanner/rest_spec.rb index 67072f880de2ce..40f073058cb888 100644 --- a/spec/ruby/library/stringscanner/rest_spec.rb +++ b/spec/ruby/library/stringscanner/rest_spec.rb @@ -32,14 +32,14 @@ end it "returns true if there is more data in the string" do - @s.rest?.should be_true + @s.rest?.should == true @s.scan(/This/) - @s.rest?.should be_true + @s.rest?.should == true end it "returns false if there is no more data in the string" do @s.terminate - @s.rest?.should be_false + @s.rest?.should == false end it "is the opposite of eos?" do diff --git a/spec/ruby/library/stringscanner/scan_byte_spec.rb b/spec/ruby/library/stringscanner/scan_byte_spec.rb index aa2decc8f747ba..8fd77270e4f152 100644 --- a/spec/ruby/library/stringscanner/scan_byte_spec.rb +++ b/spec/ruby/library/stringscanner/scan_byte_spec.rb @@ -48,7 +48,7 @@ s = StringScanner.new("abc") s.scan_byte s.should.matched? - s[:a].should be_nil + s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3" @@ -56,7 +56,7 @@ s = StringScanner.new("abc") s.scan_byte s.should.matched? - -> { s[:a] }.should raise_error(IndexError) + -> { s[:a] }.should.raise(IndexError) end end @@ -90,7 +90,7 @@ s.scan_byte s.should.matched? - -> { s[:a] }.should raise_error(IndexError) + -> { s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/scan_full_spec.rb b/spec/ruby/library/stringscanner/scan_full_spec.rb index 967313f5ca8a6c..7633c178603a83 100644 --- a/spec/ruby/library/stringscanner/scan_full_spec.rb +++ b/spec/ruby/library/stringscanner/scan_full_spec.rb @@ -38,7 +38,7 @@ it "returns nil when matching failed" do @s.scan_full(/(?2008)/, false, false) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end end diff --git a/spec/ruby/library/stringscanner/scan_integer_spec.rb b/spec/ruby/library/stringscanner/scan_integer_spec.rb index 84a8fa744c0568..d83149344a5212 100644 --- a/spec/ruby/library/stringscanner/scan_integer_spec.rb +++ b/spec/ruby/library/stringscanner/scan_integer_spec.rb @@ -44,7 +44,7 @@ -> { s.scan_integer - }.should raise_error(Encoding::CompatibilityError, /ASCII incompatible encoding: UTF-16BE|incompatible encoding regexp match/) + }.should.raise(Encoding::CompatibilityError, /ASCII incompatible encoding: UTF-16BE|incompatible encoding regexp match/) end context "given base" do @@ -65,7 +65,7 @@ it "raises ArgumentError when passed not supported base" do -> { StringScanner.new("42").scan_integer(base: 5) - }.should raise_error(ArgumentError, "Unsupported integer base: 5, expected 10 or 16") + }.should.raise(ArgumentError, "Unsupported integer base: 5, expected 10 or 16") end version_is StringScanner::Version, "3.1.1"..."3.1.3" do # ruby_version_is "3.4.0"..."3.4.3" @@ -107,7 +107,7 @@ s = StringScanner.new("42") s.scan_integer s.should.matched? - -> { s[:a] }.should raise_error(IndexError) + -> { s[:a] }.should.raise(IndexError) end end @@ -115,7 +115,7 @@ s = StringScanner.new("a42") s.scan_integer s.should_not.matched? - s[:a].should be_nil + s[:a].should == nil end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4" @@ -150,7 +150,7 @@ s.scan_integer s.should.matched? - -> { s[:a] }.should raise_error(IndexError) + -> { s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/scan_spec.rb b/spec/ruby/library/stringscanner/scan_spec.rb index 088c3419fbce39..ee8a9eb103d18f 100644 --- a/spec/ruby/library/stringscanner/scan_spec.rb +++ b/spec/ruby/library/stringscanner/scan_spec.rb @@ -15,7 +15,7 @@ it "treats ^ as matching from the beginning of the current position" do @s.scan(/\w+/).should == "This" - @s.scan(/^\d/).should be_nil + @s.scan(/^\d/).should == nil @s.scan(/^\s/).should == " " end @@ -26,7 +26,7 @@ it "treats \\A as matching from the beginning of the current position" do @s.scan(/\w+/).should == "This" - @s.scan(/\A\d/).should be_nil + @s.scan(/\A\d/).should == nil @s.scan(/\A\s/).should == " " end @@ -41,24 +41,24 @@ it "returns nil when there is no more to scan" do @s.scan(/[\w\s]+/).should == "This is a test" - @s.scan(/\w+/).should be_nil + @s.scan(/\w+/).should == nil end it "returns an empty string when the pattern matches empty" do @s.scan(/.*/).should == "This is a test" @s.scan(/.*/).should == "" - @s.scan(/./).should be_nil + @s.scan(/./).should == nil end it "treats String as the pattern itself" do - @s.scan("this").should be_nil + @s.scan("this").should == nil @s.scan("This").should == "This" end it "raises a TypeError if pattern isn't a Regexp nor String" do - -> { @s.scan(5) }.should raise_error(TypeError) - -> { @s.scan(:test) }.should raise_error(TypeError) - -> { @s.scan(mock('x')) }.should raise_error(TypeError) + -> { @s.scan(5) }.should.raise(TypeError) + -> { @s.scan(:test) }.should.raise(TypeError) + -> { @s.scan(mock('x')) }.should.raise(TypeError) end describe "#[] successive call with a capture group name" do @@ -71,7 +71,7 @@ it "returns nil when matching failed" do @s.scan(/(?2008)/) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end end @@ -91,11 +91,11 @@ 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 + @s.scan(/^\w/).should == 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 + @s.scan(/\A\w/).should == nil end end diff --git a/spec/ruby/library/stringscanner/scan_until_spec.rb b/spec/ruby/library/stringscanner/scan_until_spec.rb index 610060d6f1ee25..df83f3916a9843 100644 --- a/spec/ruby/library/stringscanner/scan_until_spec.rb +++ b/spec/ruby/library/stringscanner/scan_until_spec.rb @@ -31,7 +31,7 @@ it "raises TypeError if given a String" do -> { @s.scan_until('T') - }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)') + }.should.raise(TypeError, 'wrong argument type String (expected Regexp)') end end @@ -73,7 +73,7 @@ it "returns nil when matching failed" do @s.scan_until(/(?2008)/) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end @@ -84,21 +84,21 @@ it "returns nil when matching succeeded" do @s.scan_until("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3" it "raises IndexError when matching succeeded" do @s.scan_until("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end it "returns nil when matching failed" do @s.scan_until("2008") @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end it "returns a matching substring when given Integer index" do @@ -115,7 +115,7 @@ @s.scan_until("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4" @@ -126,7 +126,7 @@ @s.scan_until("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/search_full_spec.rb b/spec/ruby/library/stringscanner/search_full_spec.rb index 197adfda4d4519..656884f46b7a74 100644 --- a/spec/ruby/library/stringscanner/search_full_spec.rb +++ b/spec/ruby/library/stringscanner/search_full_spec.rb @@ -40,7 +40,7 @@ it "raises TypeError if given a String" do -> { @s.search_full('T', true, true) - }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)') + }.should.raise(TypeError, 'wrong argument type String (expected Regexp)') end end @@ -82,7 +82,7 @@ it "returns nil when matching failed" do @s.search_full(/(?2008)/, false, false) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end @@ -93,21 +93,21 @@ it "returns nil when matching succeeded" do @s.search_full("This", false, false) @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3" it "raises IndexError when matching succeeded" do @s.search_full("This", false, false) @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end it "returns nil when matching failed" do @s.search_full("2008", false, false) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end it "returns a matching substring when given Integer index" do @@ -124,7 +124,7 @@ @s.search_full("This", false, false) @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/shared/bol.rb b/spec/ruby/library/stringscanner/shared/bol.rb index ebcdd7938ffff4..ec5c2051b51f83 100644 --- a/spec/ruby/library/stringscanner/shared/bol.rb +++ b/spec/ruby/library/stringscanner/shared/bol.rb @@ -1,25 +1,25 @@ describe :strscan_bol, shared: true do it "returns true if the scan pointer is at the beginning of the line, false otherwise" do s = StringScanner.new("This is a test") - s.send(@method).should be_true + s.send(@method).should == true s.scan(/This/) - s.send(@method).should be_false + s.send(@method).should == false s.terminate - s.send(@method).should be_false + s.send(@method).should == false s = StringScanner.new("hello\nworld") - s.bol?.should be_true + s.bol?.should == true s.scan(/\w+/) - s.bol?.should be_false + s.bol?.should == false s.scan(/\n/) - s.bol?.should be_true + s.bol?.should == true s.unscan - s.bol?.should be_false + s.bol?.should == false end it "returns true if the scan pointer is at the end of the line of an empty string." do s = StringScanner.new('') s.terminate - s.send(@method).should be_true + s.send(@method).should == true end end diff --git a/spec/ruby/library/stringscanner/shared/concat.rb b/spec/ruby/library/stringscanner/shared/concat.rb index 1dbae11f7cc799..8138b0f8dcd9f9 100644 --- a/spec/ruby/library/stringscanner/shared/concat.rb +++ b/spec/ruby/library/stringscanner/shared/concat.rb @@ -3,28 +3,28 @@ s = StringScanner.new(+"hello ") s.send(@method, 'world').should == s s.string.should == "hello world" - s.eos?.should be_false + s.eos?.should == false end it "raises a TypeError if the given argument can't be converted to a String" do - -> { StringScanner.new('hello').send(@method, :world) }.should raise_error(TypeError) - -> { StringScanner.new('hello').send(@method, mock('x')) }.should raise_error(TypeError) + -> { StringScanner.new('hello').send(@method, :world) }.should.raise(TypeError) + -> { StringScanner.new('hello').send(@method, mock('x')) }.should.raise(TypeError) end end describe :strscan_concat_fixnum, shared: true do it "raises a TypeError" do a = StringScanner.new("hello world") - -> { a.send(@method, 333) }.should raise_error(TypeError) + -> { a.send(@method, 333) }.should.raise(TypeError) b = StringScanner.new("") - -> { b.send(@method, (256 * 3 + 64)) }.should raise_error(TypeError) - -> { b.send(@method, -200) }.should raise_error(TypeError) + -> { b.send(@method, (256 * 3 + 64)) }.should.raise(TypeError) + -> { b.send(@method, -200) }.should.raise(TypeError) end it "doesn't call to_int on the argument" do x = mock('x') x.should_not_receive(:to_int) - -> { StringScanner.new("").send(@method, x) }.should raise_error(TypeError) + -> { StringScanner.new("").send(@method, x) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/stringscanner/shared/extract_range.rb b/spec/ruby/library/stringscanner/shared/extract_range.rb index e7404fd0cb1eea..c64cc41fa735d1 100644 --- a/spec/ruby/library/stringscanner/shared/extract_range.rb +++ b/spec/ruby/library/stringscanner/shared/extract_range.rb @@ -5,7 +5,7 @@ s = StringScanner.new(sub) ch = s.send(@method) - ch.should_not be_kind_of(cls) - ch.should be_an_instance_of(String) + ch.should_not.is_a?(cls) + ch.should.instance_of?(String) 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 070a1328126b75..8a6349bec172b6 100644 --- a/spec/ruby/library/stringscanner/shared/extract_range_matched.rb +++ b/spec/ruby/library/stringscanner/shared/extract_range_matched.rb @@ -7,7 +7,7 @@ s.scan(/\w{1}/) ch = s.send(@method) - ch.should_not be_kind_of(cls) - ch.should be_an_instance_of(String) + ch.should_not.is_a?(cls) + ch.should.instance_of?(String) end end diff --git a/spec/ruby/library/stringscanner/shared/pos.rb b/spec/ruby/library/stringscanner/shared/pos.rb index eea7ead6b5e2e8..91f80fdf0842f0 100644 --- a/spec/ruby/library/stringscanner/shared/pos.rb +++ b/spec/ruby/library/stringscanner/shared/pos.rb @@ -50,10 +50,10 @@ it "raises a RangeError if position too far backward" do -> { @s.send(@method, -20) - }.should raise_error(RangeError) + }.should.raise(RangeError) end it "raises a RangeError when the passed argument is out of range" do - -> { @s.send(@method, 20) }.should raise_error(RangeError) + -> { @s.send(@method, 20) }.should.raise(RangeError) end end diff --git a/spec/ruby/library/stringscanner/skip_spec.rb b/spec/ruby/library/stringscanner/skip_spec.rb index 12f5b7781c824f..2b955b31725b4f 100644 --- a/spec/ruby/library/stringscanner/skip_spec.rb +++ b/spec/ruby/library/stringscanner/skip_spec.rb @@ -26,7 +26,7 @@ it "returns nil when matching failed" do @s.skip(/(?2008)/) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end end diff --git a/spec/ruby/library/stringscanner/skip_until_spec.rb b/spec/ruby/library/stringscanner/skip_until_spec.rb index 5d73d8f0b91104..508db285ba25ac 100644 --- a/spec/ruby/library/stringscanner/skip_until_spec.rb +++ b/spec/ruby/library/stringscanner/skip_until_spec.rb @@ -27,7 +27,7 @@ it "raises TypeError if given a String" do -> { @s.skip_until('T') - }.should raise_error(TypeError, 'wrong argument type String (expected Regexp)') + }.should.raise(TypeError, 'wrong argument type String (expected Regexp)') end end @@ -70,7 +70,7 @@ it "returns nil when matching failed" do @s.skip_until(/(?2008)/) @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end end @@ -81,21 +81,21 @@ it "returns nil when matching succeeded" do @s.skip_until("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3" it "raises IndexError when matching succeeded" do @s.skip_until("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end it "returns nil when matching failed" do @s.skip_until("2008") @s.should_not.matched? - @s[:a].should be_nil + @s[:a].should == nil end it "returns a matching substring when given Integer index" do @@ -112,7 +112,7 @@ @s.skip_until("This") @s.should.matched? - @s[:a].should be_nil + @s[:a].should == nil end end version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4" @@ -123,7 +123,7 @@ @s.skip_until("This") @s.should.matched? - -> { @s[:a] }.should raise_error(IndexError) + -> { @s[:a] }.should.raise(IndexError) end end end diff --git a/spec/ruby/library/stringscanner/string_spec.rb b/spec/ruby/library/stringscanner/string_spec.rb index cba6bd51dd6cc8..6cbbff48227a69 100644 --- a/spec/ruby/library/stringscanner/string_spec.rb +++ b/spec/ruby/library/stringscanner/string_spec.rb @@ -14,7 +14,7 @@ end it "returns the identical object passed in" do - @s.string.equal?(@string).should be_true + @s.string.equal?(@string).should == true end end diff --git a/spec/ruby/library/stringscanner/unscan_spec.rb b/spec/ruby/library/stringscanner/unscan_spec.rb index b7b4876b8afa6a..f7387782735552 100644 --- a/spec/ruby/library/stringscanner/unscan_spec.rb +++ b/spec/ruby/library/stringscanner/unscan_spec.rb @@ -22,7 +22,7 @@ end it "raises a StringScanner::Error when the previous match had failed" do - -> { @s.unscan }.should raise_error(StringScanner::Error) - -> { @s.scan(/\d/); @s.unscan }.should raise_error(StringScanner::Error) + -> { @s.unscan }.should.raise(StringScanner::Error) + -> { @s.scan(/\d/); @s.unscan }.should.raise(StringScanner::Error) end end diff --git a/spec/ruby/library/stringscanner/values_at_spec.rb b/spec/ruby/library/stringscanner/values_at_spec.rb index 14d4a5f6a7a0c3..b00cce0ffad461 100644 --- a/spec/ruby/library/stringscanner/values_at_spec.rb +++ b/spec/ruby/library/stringscanner/values_at_spec.rb @@ -35,7 +35,7 @@ -> { @s.values_at("foo") - }.should raise_error(IndexError, "undefined group name reference: foo") + }.should.raise(IndexError, "undefined group name reference: foo") end end @@ -54,7 +54,7 @@ -> { @s.values_at([]) - }.should raise_error(TypeError, "no implicit conversion of Array into Integer") + }.should.raise(TypeError, "no implicit conversion of Array into Integer") end it "returns nil if the most recent matching fails" do diff --git a/spec/ruby/library/syslog/close_spec.rb b/spec/ruby/library/syslog/close_spec.rb index 8c3b67c05bd8d6..713ef701d298a7 100644 --- a/spec/ruby/library/syslog/close_spec.rb +++ b/spec/ruby/library/syslog/close_spec.rb @@ -7,29 +7,29 @@ platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "closes the log" do - Syslog.opened?.should be_false + Syslog.opened?.should == false Syslog.open - Syslog.opened?.should be_true + Syslog.opened?.should == true Syslog.close - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "raises a RuntimeError if the log's already closed" do - -> { Syslog.close }.should raise_error(RuntimeError) + -> { Syslog.close }.should.raise(RuntimeError) end it "it does not work inside blocks" do -> { Syslog.open { |s| s.close } - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) Syslog.should_not.opened? end @@ -37,7 +37,7 @@ Syslog.open("rubyspec") Syslog.ident.should == "rubyspec" Syslog.close - Syslog.ident.should be_nil + Syslog.ident.should == nil end it "sets the options to nil" do diff --git a/spec/ruby/library/syslog/constants_spec.rb b/spec/ruby/library/syslog/constants_spec.rb index fc9db47dd81956..a6ac355dddb611 100644 --- a/spec/ruby/library/syslog/constants_spec.rb +++ b/spec/ruby/library/syslog/constants_spec.rb @@ -17,7 +17,7 @@ it "includes the Syslog constants" do @constants.each do |c| - Syslog::Constants.should have_constant(c) + Syslog::Constants.should.const_defined?(c, true) end end end diff --git a/spec/ruby/library/syslog/facility_spec.rb b/spec/ruby/library/syslog/facility_spec.rb index 550ca70b112cf9..79a685c201032f 100644 --- a/spec/ruby/library/syslog/facility_spec.rb +++ b/spec/ruby/library/syslog/facility_spec.rb @@ -7,11 +7,11 @@ platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the logging facility" do @@ -21,7 +21,7 @@ end it "returns nil if the log is closed" do - Syslog.opened?.should be_false + Syslog.opened?.should == false Syslog.facility.should == nil end diff --git a/spec/ruby/library/syslog/ident_spec.rb b/spec/ruby/library/syslog/ident_spec.rb index 3b083271406a68..80302a42b8f39b 100644 --- a/spec/ruby/library/syslog/ident_spec.rb +++ b/spec/ruby/library/syslog/ident_spec.rb @@ -7,11 +7,11 @@ platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the logging identity" do diff --git a/spec/ruby/library/syslog/inspect_spec.rb b/spec/ruby/library/syslog/inspect_spec.rb index f45231f8e31def..6407423fd32353 100644 --- a/spec/ruby/library/syslog/inspect_spec.rb +++ b/spec/ruby/library/syslog/inspect_spec.rb @@ -7,11 +7,11 @@ platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns a string a closed log" do diff --git a/spec/ruby/library/syslog/log_spec.rb b/spec/ruby/library/syslog/log_spec.rb index 0c855b8257ea45..16502833716f83 100644 --- a/spec/ruby/library/syslog/log_spec.rb +++ b/spec/ruby/library/syslog/log_spec.rb @@ -7,11 +7,11 @@ platform_is_not :windows, :darwin, :aix, :android do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "receives a priority as first argument" do @@ -34,14 +34,14 @@ it "fails with TypeError on nil log messages" do Syslog.open do |s| - -> { s.log(1, nil) }.should raise_error(TypeError) + -> { s.log(1, nil) }.should.raise(TypeError) end end it "fails if the log is closed" do -> { Syslog.log(Syslog::LOG_ALERT, "test") - }.should raise_error(RuntimeError) + }.should.raise(RuntimeError) end it "accepts printf parameters" do diff --git a/spec/ruby/library/syslog/mask_spec.rb b/spec/ruby/library/syslog/mask_spec.rb index b3f1250b24ac9d..23cca6fa8d6c3d 100644 --- a/spec/ruby/library/syslog/mask_spec.rb +++ b/spec/ruby/library/syslog/mask_spec.rb @@ -7,11 +7,11 @@ platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false # make sure we return the mask to the default value Syslog.open { |s| s.mask = 255 } end @@ -74,11 +74,11 @@ platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false # make sure we return the mask to the default value Syslog.open { |s| s.mask = 255 } end @@ -91,7 +91,7 @@ end it "raises an error if the log is closed" do - -> { Syslog.mask = 1337 }.should raise_error(RuntimeError) + -> { Syslog.mask = 1337 }.should.raise(RuntimeError) end it "only accepts numbers" do @@ -103,8 +103,8 @@ Syslog.mask = 3.1416 Syslog.mask.should == 3 - -> { Syslog.mask = "oh hai" }.should raise_error(TypeError) - -> { Syslog.mask = "43" }.should raise_error(TypeError) + -> { Syslog.mask = "oh hai" }.should.raise(TypeError) + -> { Syslog.mask = "43" }.should.raise(TypeError) end end diff --git a/spec/ruby/library/syslog/open_spec.rb b/spec/ruby/library/syslog/open_spec.rb index 543f5d418b3c09..73e3780d785f5d 100644 --- a/spec/ruby/library/syslog/open_spec.rb +++ b/spec/ruby/library/syslog/open_spec.rb @@ -8,11 +8,11 @@ platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the module" do @@ -69,18 +69,18 @@ it "closes the log if after it receives a block" do Syslog.open{ } - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "raises an error if the log is opened" do Syslog.open -> { Syslog.open - }.should raise_error(RuntimeError, /syslog already open/) + }.should.raise(RuntimeError, /syslog already open/) -> { Syslog.close Syslog.open - }.should_not raise_error + }.should_not.raise Syslog.close end end diff --git a/spec/ruby/library/syslog/opened_spec.rb b/spec/ruby/library/syslog/opened_spec.rb index 94432e65a440d7..ad4311d15af38a 100644 --- a/spec/ruby/library/syslog/opened_spec.rb +++ b/spec/ruby/library/syslog/opened_spec.rb @@ -7,32 +7,32 @@ platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns true if the log is opened" do Syslog.open - Syslog.opened?.should be_true + Syslog.opened?.should == true Syslog.close end it "returns false otherwise" do - Syslog.opened?.should be_false + Syslog.opened?.should == false Syslog.open Syslog.close - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "works inside a block" do Syslog.open do |s| - s.opened?.should be_true - Syslog.opened?.should be_true + s.opened?.should == true + Syslog.opened?.should == true end - Syslog.opened?.should be_false + Syslog.opened?.should == false end end end diff --git a/spec/ruby/library/syslog/options_spec.rb b/spec/ruby/library/syslog/options_spec.rb index 83ba43503ec674..2035272f703506 100644 --- a/spec/ruby/library/syslog/options_spec.rb +++ b/spec/ruby/library/syslog/options_spec.rb @@ -7,11 +7,11 @@ platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the logging options" do @@ -21,7 +21,7 @@ end it "returns nil when the log is closed" do - Syslog.opened?.should be_false + Syslog.opened?.should == false Syslog.options.should == nil end diff --git a/spec/ruby/library/syslog/shared/log.rb b/spec/ruby/library/syslog/shared/log.rb index 9f9302b214407c..98ce4f54b268b2 100644 --- a/spec/ruby/library/syslog/shared/log.rb +++ b/spec/ruby/library/syslog/shared/log.rb @@ -1,11 +1,11 @@ describe :syslog_log, shared: true do platform_is_not :windows, :darwin, :aix, :android do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "logs a message" do diff --git a/spec/ruby/library/syslog/shared/reopen.rb b/spec/ruby/library/syslog/shared/reopen.rb index 621437a01d8528..f04408e8078c8e 100644 --- a/spec/ruby/library/syslog/shared/reopen.rb +++ b/spec/ruby/library/syslog/shared/reopen.rb @@ -1,22 +1,22 @@ describe :syslog_reopen, shared: true do platform_is_not :windows do before :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end after :each do - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "reopens the log" do Syslog.open - -> { Syslog.send(@method)}.should_not raise_error - Syslog.opened?.should be_true + -> { Syslog.send(@method)}.should_not.raise + Syslog.opened?.should == true Syslog.close end it "fails with RuntimeError if the log is closed" do - -> { Syslog.send(@method)}.should raise_error(RuntimeError) + -> { Syslog.send(@method)}.should.raise(RuntimeError) end it "receives the same parameters as Syslog.open" do @@ -26,9 +26,9 @@ s.ident.should == "rubyspec" s.options.should == 3 s.facility.should == Syslog::LOG_USER - s.opened?.should be_true + s.opened?.should == true end - Syslog.opened?.should be_false + Syslog.opened?.should == false end it "returns the module" do diff --git a/spec/ruby/library/tempfile/_close_spec.rb b/spec/ruby/library/tempfile/_close_spec.rb index c08f425b6f39e9..344b08dc176643 100644 --- a/spec/ruby/library/tempfile/_close_spec.rb +++ b/spec/ruby/library/tempfile/_close_spec.rb @@ -11,11 +11,11 @@ end it "is protected" do - Tempfile.should have_protected_instance_method(:_close) + Tempfile.protected_instance_methods(false).should.include?(:_close) end it "closes self" do @tempfile.send(:_close) - @tempfile.closed?.should be_true + @tempfile.closed?.should == true end end diff --git a/spec/ruby/library/tempfile/close_spec.rb b/spec/ruby/library/tempfile/close_spec.rb index db0eae3fa58b1b..7e95ae1d7e05d3 100644 --- a/spec/ruby/library/tempfile/close_spec.rb +++ b/spec/ruby/library/tempfile/close_spec.rb @@ -12,7 +12,7 @@ it "closes self" do @tempfile.close - @tempfile.closed?.should be_true + @tempfile.closed?.should == true end it "does not unlink self" do @@ -29,7 +29,7 @@ it "closes self" do @tempfile.close(true) - @tempfile.closed?.should be_true + @tempfile.closed?.should == true end it "unlinks self" do @@ -46,7 +46,7 @@ it "closes self" do @tempfile.close! - @tempfile.closed?.should be_true + @tempfile.closed?.should == true end it "unlinks self" do diff --git a/spec/ruby/library/tempfile/create_spec.rb b/spec/ruby/library/tempfile/create_spec.rb index 74c48bf32a9a07..be6d21e2184cc6 100644 --- a/spec/ruby/library/tempfile/create_spec.rb +++ b/spec/ruby/library/tempfile/create_spec.rb @@ -12,11 +12,11 @@ it "returns a new, open regular File instance placed in tmpdir" do @tempfile = Tempfile.create # Unlike Tempfile.open this returns a true File, - # but `.should be_an_instance_of(File)` would be true either way. - @tempfile.instance_of?(File).should be_true + # but `.should.instance_of?(File)` would be true either way. + @tempfile.instance_of?(File).should == true @tempfile.should_not.closed? - File.file?(@tempfile.path).should be_true + File.file?(@tempfile.path).should == true @tempfile.path.should.start_with?(Dir.tmpdir) @tempfile.path.should_not == "#{Dir.tmpdir}/" @@ -72,11 +72,11 @@ Tempfile.create do |tempfile| @tempfile = tempfile @tempfile.should_not.closed? - File.exist?(@tempfile.path).should be_true + File.exist?(@tempfile.path).should == true end @tempfile.should.closed? - File.exist?(@tempfile.path).should be_false + File.exist?(@tempfile.path).should == false end end @@ -106,9 +106,9 @@ end it "raises ArgumentError if passed something else than a String or an array of Strings" do - -> { Tempfile.create(:create_spec) }.should raise_error(ArgumentError, "unexpected prefix: :create_spec") - -> { Tempfile.create([:create_spec]) }.should raise_error(ArgumentError, "unexpected prefix: :create_spec") - -> { Tempfile.create(["create_spec", :temp]) }.should raise_error(ArgumentError, "unexpected suffix: :temp") + -> { Tempfile.create(:create_spec) }.should.raise(ArgumentError, "unexpected prefix: :create_spec") + -> { Tempfile.create([:create_spec]) }.should.raise(ArgumentError, "unexpected prefix: :create_spec") + -> { Tempfile.create(["create_spec", :temp]) }.should.raise(ArgumentError, "unexpected suffix: :temp") end end @@ -119,7 +119,7 @@ end it "raises TypeError if argument can not be converted to a String" do - -> { Tempfile.create("create_spec", :temp) }.should raise_error(TypeError, "no implicit conversion of Symbol into String") + -> { Tempfile.create("create_spec", :temp) }.should.raise(TypeError, "no implicit conversion of Symbol into String") end end @@ -132,7 +132,7 @@ end it "raises NoMethodError if passed a String mode" do - -> { Tempfile.create(mode: "wb") }.should raise_error(NoMethodError, /undefined method ['`]|' for .+String/) + -> { Tempfile.create(mode: "wb") }.should.raise(NoMethodError, /undefined method ['`]|' for .+String/) end end @@ -142,7 +142,7 @@ @tempfile = Tempfile.create(anonymous: true) @tempfile.should_not.closed? @tempfile.path.should == "#{Dir.tmpdir}/" - File.file?(@tempfile.path).should be_false + File.file?(@tempfile.path).should == false end it "unlinks file before calling the block" do @@ -150,7 +150,7 @@ @tempfile = tempfile @tempfile.should_not.closed? @tempfile.path.should == "#{Dir.tmpdir}/" - File.file?(@tempfile.path).should be_false + File.file?(@tempfile.path).should == false end @tempfile.should.closed? end @@ -161,7 +161,7 @@ @tempfile = Tempfile.create(anonymous: false) @tempfile.should_not.closed? @tempfile.path.should.start_with?(Dir.tmpdir) - File.file?(@tempfile.path).should be_true + File.file?(@tempfile.path).should == true end end end @@ -170,7 +170,7 @@ it "passes them along to File.open" do @tempfile = Tempfile.create(encoding: "IBM037:IBM037", binmode: true) @tempfile.external_encoding.should == Encoding.find("IBM037") - @tempfile.binmode?.should be_true + @tempfile.binmode?.should == true end end end diff --git a/spec/ruby/library/tempfile/initialize_spec.rb b/spec/ruby/library/tempfile/initialize_spec.rb index f2e786d7d86e24..0e882a3f0ce371 100644 --- a/spec/ruby/library/tempfile/initialize_spec.rb +++ b/spec/ruby/library/tempfile/initialize_spec.rb @@ -24,7 +24,7 @@ end path[0, tmpdir.length].should == tmpdir - path.should include("basename") + path.should.include?("basename") end platform_is_not :windows do diff --git a/spec/ruby/library/tempfile/open_spec.rb b/spec/ruby/library/tempfile/open_spec.rb index ef2c95376f2ce6..0993a2c5eedd6c 100644 --- a/spec/ruby/library/tempfile/open_spec.rb +++ b/spec/ruby/library/tempfile/open_spec.rb @@ -14,7 +14,7 @@ it "reopens self" do @tempfile.close @tempfile.open - @tempfile.closed?.should be_false + @tempfile.closed?.should == false end it "reopens self in read and write mode and does not truncate" do @@ -33,8 +33,8 @@ it "returns a new, open Tempfile instance" do @tempfile = Tempfile.open("specs") - # Delegation messes up .should be_an_instance_of(Tempfile) - @tempfile.instance_of?(Tempfile).should be_true + # Delegation messes up .should.instance_of?(Tempfile) + @tempfile.instance_of?(Tempfile).should == true end it "is passed an array [base, suffix] as first argument" do @@ -46,14 +46,14 @@ Tempfile.open("specs", Dir.tmpdir, encoding: "IBM037:IBM037", binmode: true) do |tempfile| @tempfile = tempfile tempfile.external_encoding.should == Encoding.find("IBM037") - tempfile.binmode?.should be_true + tempfile.binmode?.should == true end end it "uses a blank string for basename when passed no arguments" do Tempfile.open() do |tempfile| @tempfile = tempfile - tempfile.closed?.should be_false + tempfile.closed?.should == false end @tempfile.should_not == nil end @@ -74,9 +74,9 @@ @tempfile = tempfile ScratchPad.record :yielded - # Delegation messes up .should be_an_instance_of(Tempfile) - tempfile.instance_of?(Tempfile).should be_true - tempfile.closed?.should be_false + # Delegation messes up .should.instance_of?(Tempfile) + tempfile.instance_of?(Tempfile).should == true + tempfile.closed?.should == false end ScratchPad.recorded.should == :yielded @@ -92,6 +92,6 @@ it "closes the yielded Tempfile after the block" do Tempfile.open("specs") { |tempfile| @tempfile = tempfile } - @tempfile.closed?.should be_true + @tempfile.closed?.should == true end end diff --git a/spec/ruby/library/tempfile/path_spec.rb b/spec/ruby/library/tempfile/path_spec.rb index 07f75b3e1044e4..be56bd87c8ede2 100644 --- a/spec/ruby/library/tempfile/path_spec.rb +++ b/spec/ruby/library/tempfile/path_spec.rb @@ -21,6 +21,6 @@ end path[0, tmpdir.length].should == tmpdir - path.should include("specs") + path.should.include?("specs") end end diff --git a/spec/ruby/library/tempfile/shared/length.rb b/spec/ruby/library/tempfile/shared/length.rb index 4d18d1f3852336..1a89ff7b4d070d 100644 --- a/spec/ruby/library/tempfile/shared/length.rb +++ b/spec/ruby/library/tempfile/shared/length.rb @@ -8,14 +8,14 @@ end it "returns the size of self" do - @tempfile.send(@method).should eql(0) + @tempfile.send(@method).should.eql?(0) @tempfile.print("Test!") - @tempfile.send(@method).should eql(5) + @tempfile.send(@method).should.eql?(5) end it "returns the size of self even if self is closed" do @tempfile.print("Test!") @tempfile.close - @tempfile.send(@method).should eql(5) + @tempfile.send(@method).should.eql?(5) end end diff --git a/spec/ruby/library/thread/queue_spec.rb b/spec/ruby/library/thread/queue_spec.rb index c7e2bb1b501f55..b6c4fef08f9640 100644 --- a/spec/ruby/library/thread/queue_spec.rb +++ b/spec/ruby/library/thread/queue_spec.rb @@ -2,7 +2,7 @@ describe "Thread::Queue" do it "is the same class as ::Queue" do - Thread.should have_constant(:Queue) - Thread::Queue.should equal ::Queue + Thread.should.const_defined?(:Queue, false) + Thread::Queue.should.equal? ::Queue end end diff --git a/spec/ruby/library/thread/sizedqueue_spec.rb b/spec/ruby/library/thread/sizedqueue_spec.rb index 6151ff437c4853..ffa66bcd35faa8 100644 --- a/spec/ruby/library/thread/sizedqueue_spec.rb +++ b/spec/ruby/library/thread/sizedqueue_spec.rb @@ -2,7 +2,7 @@ describe "Thread::SizedQueue" do it "is the same class as ::SizedQueue" do - Thread.should have_constant(:SizedQueue) - Thread::SizedQueue.should equal ::SizedQueue + Thread.should.const_defined?(:SizedQueue, false) + Thread::SizedQueue.should.equal? ::SizedQueue end end diff --git a/spec/ruby/library/time/shared/rfc2822.rb b/spec/ruby/library/time/shared/rfc2822.rb index e460d655a68dd0..49ef76db47f9a5 100644 --- a/spec/ruby/library/time/shared/rfc2822.rb +++ b/spec/ruby/library/time/shared/rfc2822.rb @@ -60,6 +60,6 @@ -> { # inner comment is not supported. Time.send(@method, "Fri, 21 Nov 1997 09(comment): 55 : 06 -0600") - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/time/to_time_spec.rb b/spec/ruby/library/time/to_time_spec.rb index 7e6c75a003517e..d2b89cb11233aa 100644 --- a/spec/ruby/library/time/to_time_spec.rb +++ b/spec/ruby/library/time/to_time_spec.rb @@ -6,10 +6,10 @@ time = Time.new(2012, 2, 21, 10, 11, 12) with_timezone("America/Regina") do - time.to_time.should equal time + time.to_time.should.equal? time end time2 = Time.utc(2012, 2, 21, 10, 11, 12) - time2.to_time.should equal time2 + time2.to_time.should.equal? time2 end end diff --git a/spec/ruby/library/timeout/error_spec.rb b/spec/ruby/library/timeout/error_spec.rb index 6c236e51282ac1..2c28236e290130 100644 --- a/spec/ruby/library/timeout/error_spec.rb +++ b/spec/ruby/library/timeout/error_spec.rb @@ -3,6 +3,6 @@ describe "Timeout::Error" do it "is a subclass of RuntimeError" do - RuntimeError.should be_ancestor_of(Timeout::Error) + Timeout::Error.ancestors.should.include?(RuntimeError) end end diff --git a/spec/ruby/library/timeout/timeout_spec.rb b/spec/ruby/library/timeout/timeout_spec.rb index e16bcaea6ab298..9ae70bf60065b5 100644 --- a/spec/ruby/library/timeout/timeout_spec.rb +++ b/spec/ruby/library/timeout/timeout_spec.rb @@ -7,7 +7,7 @@ Timeout.timeout(1) do sleep end - }.should raise_error(Timeout::Error) + }.should.raise(Timeout::Error) end it "raises specified error type when it times out" do @@ -15,7 +15,7 @@ Timeout.timeout(1, StandardError) do sleep end - end.should raise_error(StandardError) + end.should.raise(StandardError) end it "raises specified error type with specified message when it times out" do @@ -23,7 +23,7 @@ Timeout.timeout(1, StandardError, "foobar") do sleep end - end.should raise_error(StandardError, "foobar") + end.should.raise(StandardError, "foobar") end it "raises specified error type with a default message when it times out if message is nil" do @@ -31,7 +31,7 @@ Timeout.timeout(1, StandardError, nil) do sleep end - end.should raise_error(StandardError, "execution expired") + end.should.raise(StandardError, "execution expired") end it "returns back the last value in the block" do @@ -44,7 +44,7 @@ it "raises an ArgumentError when provided with a negative duration" do -> { Timeout.timeout(-1) - }.should raise_error(ArgumentError, "Timeout sec must be a non-negative number") + }.should.raise(ArgumentError, "Timeout sec must be a non-negative number") end end end diff --git a/spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb b/spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb index 8165c2d8a8e917..edc4795efb550e 100644 --- a/spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb +++ b/spec/ruby/library/tmpdir/dir/mktmpdir_spec.rb @@ -16,8 +16,8 @@ it "creates a new writable directory in the path provided by Dir.tmpdir" do Dir.should_receive(:tmpdir).and_return(tmp("")) @tmpdir = Dir.mktmpdir - File.directory?(@tmpdir).should be_true - File.writable?(@tmpdir).should be_true + File.directory?(@tmpdir).should == true + File.writable?(@tmpdir).should == true end end @@ -41,15 +41,15 @@ called = true path.should.start_with?(@real_tmp_root) end - called.should be_true + called.should == true end it "creates the tmp-dir before yielding" do Dir.should_receive(:tmpdir).and_return(tmp("")) Dir.mktmpdir do |path| @tmpdir = path - File.directory?(path).should be_true - File.writable?(path).should be_true + File.directory?(path).should == true + File.writable?(path).should == true end end @@ -67,7 +67,7 @@ @tmpdir = path :test end - result.should equal(:test) + result.should.equal?(:test) end end @@ -110,8 +110,8 @@ describe "Dir.mktmpdir when passed [Object]" do it "raises an ArgumentError" do - -> { Dir.mktmpdir(Object.new) }.should raise_error(ArgumentError) - -> { Dir.mktmpdir(:symbol) }.should raise_error(ArgumentError) - -> { Dir.mktmpdir(10) }.should raise_error(ArgumentError) + -> { Dir.mktmpdir(Object.new) }.should.raise(ArgumentError) + -> { Dir.mktmpdir(:symbol) }.should.raise(ArgumentError) + -> { Dir.mktmpdir(10) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/tmpdir/dir/tmpdir_spec.rb b/spec/ruby/library/tmpdir/dir/tmpdir_spec.rb index f4ab5e40b89694..330f04458ff40d 100644 --- a/spec/ruby/library/tmpdir/dir/tmpdir_spec.rb +++ b/spec/ruby/library/tmpdir/dir/tmpdir_spec.rb @@ -4,7 +4,7 @@ describe "Dir.tmpdir" do it "returns the path to a writable and readable directory" do dir = Dir.tmpdir - File.directory?(dir).should be_true - File.writable?(dir).should be_true + File.directory?(dir).should == true + File.writable?(dir).should == true end end diff --git a/spec/ruby/library/uri/join_spec.rb b/spec/ruby/library/uri/join_spec.rb index 796f74134f1c29..17773033609a60 100644 --- a/spec/ruby/library/uri/join_spec.rb +++ b/spec/ruby/library/uri/join_spec.rb @@ -23,7 +23,7 @@ it "raises an error if given no argument" do -> { URI.join - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "doesn't create redundant '/'s" do diff --git a/spec/ruby/library/uri/mailto/build_spec.rb b/spec/ruby/library/uri/mailto/build_spec.rb index 2c011626ab70cc..081707b1cfb1ce 100644 --- a/spec/ruby/library/uri/mailto/build_spec.rb +++ b/spec/ruby/library/uri/mailto/build_spec.rb @@ -84,7 +84,7 @@ end bad.each do |x| - -> { URI::MailTo.build(x) }.should raise_error(URI::InvalidComponentError) + -> { URI::MailTo.build(x) }.should.raise(URI::InvalidComponentError) end ok.flatten.join("\0").should == ok_all diff --git a/spec/ruby/library/uri/parse_spec.rb b/spec/ruby/library/uri/parse_spec.rb index e9ec59b49055d6..f0373fbf5e6b27 100644 --- a/spec/ruby/library/uri/parse_spec.rb +++ b/spec/ruby/library/uri/parse_spec.rb @@ -4,7 +4,7 @@ describe "URI.parse" do it "returns a URI::HTTP object when parsing an HTTP URI" do - URI.parse("http://www.example.com/").should be_kind_of(URI::HTTP) + URI.parse("http://www.example.com/").should.is_a?(URI::HTTP) end it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do @@ -47,7 +47,7 @@ end it "returns a URI::HTTPS object when parsing an HTTPS URI" do - URI.parse("https://important-intern-net.net").should be_kind_of(URI::HTTPS) + URI.parse("https://important-intern-net.net").should.is_a?(URI::HTTPS) end it "sets the port of a parsed https URI to 443 by default" do @@ -57,7 +57,7 @@ it "populates the components of a parsed URI::FTP object" do # generic, empty password. url = URI.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i") - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: "anonymous", @@ -69,7 +69,7 @@ # multidomain, no user or password url = URI.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: nil, @@ -81,7 +81,7 @@ # empty user url = URI.parse('ftp://:pass@localhost/') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: ":pass", @@ -97,7 +97,7 @@ #taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like ldap_uris = %w{ ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one ldap://ldap.question.com/o=Question%3f,c=US?mail ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04) ldap:///??sub??bindname=cn=Manager%2co=Foo ldap:///??sub??!bindname=cn=Manager%2co=Foo } ldap_uris.each do |ldap_uri| - URI.parse(ldap_uri).should be_kind_of(URI::LDAP) + URI.parse(ldap_uri).should.is_a?(URI::LDAP) end end @@ -115,7 +115,7 @@ end it "returns a URI::MailTo object when passed a mailto URI" do - URI.parse("mailto:spam@mailinator.com").should be_kind_of(URI::MailTo) + URI.parse("mailto:spam@mailinator.com").should.is_a?(URI::MailTo) end it "populates the components of a parsed URI::MailTo object" do @@ -145,7 +145,7 @@ # gopher gopher = URI.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles') - gopher.should be_kind_of(URI::Generic) + gopher.should.is_a?(URI::Generic) URISpec.components(gopher).should == { scheme: "gopher", @@ -161,7 +161,7 @@ # news news = URI.parse('news:comp.infosystems.www.servers.unix') - news.should be_kind_of(URI::Generic) + news.should.is_a?(URI::Generic) URISpec.components(news).should == { scheme: "news", userinfo: nil, @@ -176,7 +176,7 @@ # telnet telnet = URI.parse('telnet://melvyl.ucop.edu/') - telnet.should be_kind_of(URI::Generic) + telnet.should.is_a?(URI::Generic) URISpec.components(telnet).should == { scheme: "telnet", userinfo: nil, @@ -191,9 +191,9 @@ # files file_l = URI.parse('file:///foo/bar.txt') - file_l.should be_kind_of(URI::Generic) + file_l.should.is_a?(URI::Generic) file = URI.parse('file:/foo/bar.txt') - file.should be_kind_of(URI::Generic) + file.should.is_a?(URI::Generic) end it "doesn't raise errors on URIs which has underscore in reg_name" do diff --git a/spec/ruby/library/uri/plus_spec.rb b/spec/ruby/library/uri/plus_spec.rb index b84b0767c1f009..51fb5e3750658d 100644 --- a/spec/ruby/library/uri/plus_spec.rb +++ b/spec/ruby/library/uri/plus_spec.rb @@ -36,7 +36,7 @@ end it "raises a URI::BadURIError when adding two relative URIs" do - -> {URI.parse('a/b/c') + "d"}.should raise_error(URI::BadURIError) + -> {URI.parse('a/b/c') + "d"}.should.raise(URI::BadURIError) end #Todo: make more BDD? @@ -47,403 +47,403 @@ # http://a/b/c/d;p?q # g:h = g:h url = @base_url.merge('g:h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g:h' url = @base_url.route_to('g:h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g:h' # http://a/b/c/d;p?q # g = http://a/b/c/g url = @base_url.merge('g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g' url = @base_url.route_to('http://a/b/c/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g' # http://a/b/c/d;p?q # ./g = http://a/b/c/g url = @base_url.merge('./g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g' url = @base_url.route_to('http://a/b/c/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == './g' # ok url.to_s.should == 'g' # http://a/b/c/d;p?q # g/ = http://a/b/c/g/ url = @base_url.merge('g/') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g/' url = @base_url.route_to('http://a/b/c/g/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g/' # http://a/b/c/d;p?q # /g = http://a/g url = @base_url.merge('/g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '/g' # ok url.to_s.should == '../../g' # http://a/b/c/d;p?q # //g = http://g url = @base_url.merge('//g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://g' url = @base_url.route_to('http://g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '//g' # http://a/b/c/d;p?q # ?y = http://a/b/c/?y url = @base_url.merge('?y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/d;p?y' url = @base_url.route_to('http://a/b/c/?y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '?y' # http://a/b/c/d;p?q # g?y = http://a/b/c/g?y url = @base_url.merge('g?y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y' url = @base_url.route_to('http://a/b/c/g?y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y' # http://a/b/c/d;p?q # #s = (current document)#s url = @base_url.merge('#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == @base_url.to_s + '#s' url = @base_url.route_to(@base_url.to_s + '#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '#s' # http://a/b/c/d;p?q # g#s = http://a/b/c/g#s url = @base_url.merge('g#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g#s' url = @base_url.route_to('http://a/b/c/g#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g#s' # http://a/b/c/d;p?q # g?y#s = http://a/b/c/g?y#s url = @base_url.merge('g?y#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y#s' url = @base_url.route_to('http://a/b/c/g?y#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y#s' # http://a/b/c/d;p?q # ;x = http://a/b/c/;x url = @base_url.merge(';x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/;x' url = @base_url.route_to('http://a/b/c/;x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == ';x' # http://a/b/c/d;p?q # g;x = http://a/b/c/g;x url = @base_url.merge('g;x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g;x' url = @base_url.route_to('http://a/b/c/g;x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g;x' # http://a/b/c/d;p?q # g;x?y#s = http://a/b/c/g;x?y#s url = @base_url.merge('g;x?y#s') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g;x?y#s' url = @base_url.route_to('http://a/b/c/g;x?y#s') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g;x?y#s' # http://a/b/c/d;p?q # . = http://a/b/c/ url = @base_url.merge('.') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/' url = @base_url.route_to('http://a/b/c/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '.' # ok url.to_s.should == './' # http://a/b/c/d;p?q # ./ = http://a/b/c/ url = @base_url.merge('./') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/' url = @base_url.route_to('http://a/b/c/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == './' # http://a/b/c/d;p?q # .. = http://a/b/ url = @base_url.merge('..') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/' url = @base_url.route_to('http://a/b/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '..' # ok url.to_s.should == '../' # http://a/b/c/d;p?q # ../ = http://a/b/ url = @base_url.merge('../') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/' url = @base_url.route_to('http://a/b/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../' # http://a/b/c/d;p?q # ../g = http://a/b/g url = @base_url.merge('../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/g' url = @base_url.route_to('http://a/b/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../g' # http://a/b/c/d;p?q # ../.. = http://a/ url = @base_url.merge('../..') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/' url = @base_url.route_to('http://a/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '../..' # ok url.to_s.should == '../../' # http://a/b/c/d;p?q # ../../ = http://a/ url = @base_url.merge('../../') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/' url = @base_url.route_to('http://a/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../../' # http://a/b/c/d;p?q # ../../g = http://a/g url = @base_url.merge('../../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '../../g' # http://a/b/c/d;p?q # <> = (current document) url = @base_url.merge('') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/d;p?q' url = @base_url.route_to('http://a/b/c/d;p?q') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '' # http://a/b/c/d;p?q # /./g = http://a/./g url = @base_url.merge('/./g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/./g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '/./g' # http://a/b/c/d;p?q # /../g = http://a/../g url = @base_url.merge('/../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/../g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '/../g' # http://a/b/c/d;p?q # g. = http://a/b/c/g. url = @base_url.merge('g.') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g.' url = @base_url.route_to('http://a/b/c/g.') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g.' # http://a/b/c/d;p?q # .g = http://a/b/c/.g url = @base_url.merge('.g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/.g' url = @base_url.route_to('http://a/b/c/.g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '.g' # http://a/b/c/d;p?q # g.. = http://a/b/c/g.. url = @base_url.merge('g..') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g..' url = @base_url.route_to('http://a/b/c/g..') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g..' # http://a/b/c/d;p?q # ..g = http://a/b/c/..g url = @base_url.merge('..g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/..g' url = @base_url.route_to('http://a/b/c/..g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == '..g' # http://a/b/c/d;p?q # ../../../g = http://a/../g url = @base_url.merge('../../../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/../g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '../../../g' # ok? yes, it confuses you url.to_s.should == '/../g' # and it is clearly # http://a/b/c/d;p?q # ../../../../g = http://a/../../g url = @base_url.merge('../../../../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/g' url = @base_url.route_to('http://a/../../g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == '../../../../g' # ok? yes, it confuses you url.to_s.should == '/../../g' # and it is clearly # http://a/b/c/d;p?q # ./../g = http://a/b/g url = @base_url.merge('./../g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/g' url = @base_url.route_to('http://a/b/g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == './../g' # ok url.to_s.should == '../g' # http://a/b/c/d;p?q # ./g/. = http://a/b/c/g/ url = @base_url.merge('./g/.') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g/' url = @base_url.route_to('http://a/b/c/g/') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == './g/.' # ok url.to_s.should == 'g/' # http://a/b/c/d;p?q # g/./h = http://a/b/c/g/h url = @base_url.merge('g/./h') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g/h' url = @base_url.route_to('http://a/b/c/g/h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g/./h' # ok url.to_s.should == 'g/h' # http://a/b/c/d;p?q # g/../h = http://a/b/c/h url = @base_url.merge('g/../h') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/h' url = @base_url.route_to('http://a/b/c/h') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g/../h' # ok url.to_s.should == 'h' # http://a/b/c/d;p?q # g;x=1/./y = http://a/b/c/g;x=1/y url = @base_url.merge('g;x=1/./y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g;x=1/y' url = @base_url.route_to('http://a/b/c/g;x=1/y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g;x=1/./y' # ok url.to_s.should == 'g;x=1/y' # http://a/b/c/d;p?q # g;x=1/../y = http://a/b/c/y url = @base_url.merge('g;x=1/../y') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/y' url = @base_url.route_to('http://a/b/c/y') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should_not == 'g;x=1/../y' # ok url.to_s.should == 'y' # http://a/b/c/d;p?q # g?y/./x = http://a/b/c/g?y/./x url = @base_url.merge('g?y/./x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y/./x' url = @base_url.route_to('http://a/b/c/g?y/./x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y/./x' # http://a/b/c/d;p?q # g?y/../x = http://a/b/c/g?y/../x url = @base_url.merge('g?y/../x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g?y/../x' url = @base_url.route_to('http://a/b/c/g?y/../x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g?y/../x' # http://a/b/c/d;p?q # g#s/./x = http://a/b/c/g#s/./x url = @base_url.merge('g#s/./x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g#s/./x' url = @base_url.route_to('http://a/b/c/g#s/./x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g#s/./x' # http://a/b/c/d;p?q # g#s/../x = http://a/b/c/g#s/../x url = @base_url.merge('g#s/../x') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http://a/b/c/g#s/../x' url = @base_url.route_to('http://a/b/c/g#s/../x') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'g#s/../x' # http://a/b/c/d;p?q # http:g = http:g ; for validating parsers # | http://a/b/c/g ; for backwards compatibility url = @base_url.merge('http:g') - url.should be_kind_of(URI::HTTP) + url.should.is_a?(URI::HTTP) url.to_s.should == 'http:g' url = @base_url.route_to('http:g') - url.should be_kind_of(URI::Generic) + url.should.is_a?(URI::Generic) url.to_s.should == 'http:g' end end diff --git a/spec/ruby/library/uri/select_spec.rb b/spec/ruby/library/uri/select_spec.rb index 839b68b3a12394..27591f69f20b35 100644 --- a/spec/ruby/library/uri/select_spec.rb +++ b/spec/ruby/library/uri/select_spec.rb @@ -15,13 +15,13 @@ end it "raises an ArgumentError if a component is requested that isn't valid under the given scheme" do - -> { URI("mailto:spam@mailinator.com").select(:path) }.should raise_error(ArgumentError) - -> { URI("http://blog.blag.web").select(:typecode) }.should raise_error(ArgumentError) + -> { URI("mailto:spam@mailinator.com").select(:path) }.should.raise(ArgumentError) + -> { URI("http://blog.blag.web").select(:typecode) }.should.raise(ArgumentError) end it "raises an ArgumentError if given strings rather than symbols" do -> { URI("http://host:8080/path/").select("scheme","host","port",'path') - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end diff --git a/spec/ruby/library/uri/set_component_spec.rb b/spec/ruby/library/uri/set_component_spec.rb index 1d4165c5351b13..15f1ed1f87af32 100644 --- a/spec/ruby/library/uri/set_component_spec.rb +++ b/spec/ruby/library/uri/set_component_spec.rb @@ -29,19 +29,19 @@ end uri = URI.parse('http://example.com') - -> { uri.password = 'bar' }.should raise_error(URI::InvalidURIError) + -> { uri.password = 'bar' }.should.raise(URI::InvalidURIError) uri.userinfo = 'foo:bar' uri.to_s.should == 'http://foo:bar@example.com' - -> { uri.registry = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.opaque = 'bar' }.should raise_error(URI::InvalidURIError) + -> { uri.registry = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.opaque = 'bar' }.should.raise(URI::InvalidURIError) uri = URI.parse('mailto:foo@example.com') - -> { uri.user = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.password = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.userinfo = ['bar', 'baz'] }.should raise_error(URI::InvalidURIError) - -> { uri.host = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.port = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.path = 'bar' }.should raise_error(URI::InvalidURIError) - -> { uri.query = 'bar' }.should raise_error(URI::InvalidURIError) + -> { uri.user = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.password = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.userinfo = ['bar', 'baz'] }.should.raise(URI::InvalidURIError) + -> { uri.host = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.port = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.path = 'bar' }.should.raise(URI::InvalidURIError) + -> { uri.query = 'bar' }.should.raise(URI::InvalidURIError) end end diff --git a/spec/ruby/library/uri/shared/eql.rb b/spec/ruby/library/uri/shared/eql.rb index 2cc960d39a1ef1..978c4aae051189 100644 --- a/spec/ruby/library/uri/shared/eql.rb +++ b/spec/ruby/library/uri/shared/eql.rb @@ -3,7 +3,7 @@ URISpec::NORMALIZED_FORMS.each do |form| normal_uri = URI(form[:normalized]) form[:different].each do |other| - URI(other).send(@method, normal_uri).should be_false + URI(other).send(@method, normal_uri).should == false end end end @@ -11,7 +11,7 @@ describe :uri_eql_against_other_types, shared: true do it "returns false for when compared to non-uri objects" do - URI("http://example.com/").send(@method, "http://example.com/").should be_false - URI("http://example.com/").send(@method, nil).should be_false + URI("http://example.com/").send(@method, "http://example.com/").should == false + URI("http://example.com/").send(@method, nil).should == false end end diff --git a/spec/ruby/library/uri/shared/join.rb b/spec/ruby/library/uri/shared/join.rb index 4df0782b374906..b1f5f1c72b3706 100644 --- a/spec/ruby/library/uri/shared/join.rb +++ b/spec/ruby/library/uri/shared/join.rb @@ -20,7 +20,7 @@ it "raises an error if given no argument" do -> { @object.join - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "doesn't create redundant '/'s" do diff --git a/spec/ruby/library/uri/shared/parse.rb b/spec/ruby/library/uri/shared/parse.rb index c5057b6c4bbb22..7ec71795264677 100644 --- a/spec/ruby/library/uri/shared/parse.rb +++ b/spec/ruby/library/uri/shared/parse.rb @@ -1,6 +1,6 @@ describe :uri_parse, shared: true do it "returns a URI::HTTP object when parsing an HTTP URI" do - @object.parse("http://www.example.com/").should be_kind_of(URI::HTTP) + @object.parse("http://www.example.com/").should.is_a?(URI::HTTP) end it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do @@ -43,7 +43,7 @@ end it "returns a URI::HTTPS object when parsing an HTTPS URI" do - @object.parse("https://important-intern-net.net").should be_kind_of(URI::HTTPS) + @object.parse("https://important-intern-net.net").should.is_a?(URI::HTTPS) end it "sets the port of a parsed https URI to 443 by default" do @@ -53,7 +53,7 @@ it "populates the components of a parsed URI::FTP object" do # generic, empty password. url = @object.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i") - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: "anonymous", @@ -65,7 +65,7 @@ # multidomain, no user or password url = @object.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: nil, @@ -77,7 +77,7 @@ # empty user url = @object.parse('ftp://:pass@localhost/') - url.should be_kind_of(URI::FTP) + url.should.is_a?(URI::FTP) URISpec.components(url).should == { scheme: "ftp", userinfo: ":pass", @@ -93,7 +93,7 @@ #taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like ldap_uris = %w{ ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one ldap://ldap.question.com/o=Question%3f,c=US?mail ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04) ldap:///??sub??bindname=cn=Manager%2co=Foo ldap:///??sub??!bindname=cn=Manager%2co=Foo } ldap_uris.each do |ldap_uri| - @object.parse(ldap_uri).should be_kind_of(URI::LDAP) + @object.parse(ldap_uri).should.is_a?(URI::LDAP) end end @@ -111,7 +111,7 @@ end it "returns a URI::MailTo object when passed a mailto URI" do - @object.parse("mailto:spam@mailinator.com").should be_kind_of(URI::MailTo) + @object.parse("mailto:spam@mailinator.com").should.is_a?(URI::MailTo) end it "populates the components of a parsed URI::MailTo object" do @@ -141,7 +141,7 @@ # gopher gopher = @object.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles') - gopher.should be_kind_of(URI::Generic) + gopher.should.is_a?(URI::Generic) URISpec.components(gopher).should == { scheme: "gopher", @@ -157,7 +157,7 @@ # news news = @object.parse('news:comp.infosystems.www.servers.unix') - news.should be_kind_of(URI::Generic) + news.should.is_a?(URI::Generic) URISpec.components(news).should == { scheme: "news", userinfo: nil, @@ -172,7 +172,7 @@ # telnet telnet = @object.parse('telnet://melvyl.ucop.edu/') - telnet.should be_kind_of(URI::Generic) + telnet.should.is_a?(URI::Generic) URISpec.components(telnet).should == { scheme: "telnet", userinfo: nil, @@ -187,20 +187,20 @@ # files file_l = @object.parse('file:///foo/bar.txt') - file_l.should be_kind_of(URI::Generic) + file_l.should.is_a?(URI::Generic) file = @object.parse('file:/foo/bar.txt') - file.should be_kind_of(URI::Generic) + file.should.is_a?(URI::Generic) end if URI::DEFAULT_PARSER == URI::RFC2396_Parser it "raises errors on malformed URIs" do - -> { @object.parse('http://a_b:80/') }.should raise_error(URI::InvalidURIError) - -> { @object.parse('http://a_b/') }.should raise_error(URI::InvalidURIError) + -> { @object.parse('http://a_b:80/') }.should.raise(URI::InvalidURIError) + -> { @object.parse('http://a_b/') }.should.raise(URI::InvalidURIError) end elsif URI::DEFAULT_PARSER == URI::RFC3986_Parser it "does not raise errors on URIs contained underscore" do - -> { @object.parse('http://a_b:80/') }.should_not raise_error(URI::InvalidURIError) - -> { @object.parse('http://a_b/') }.should_not raise_error(URI::InvalidURIError) + -> { @object.parse('http://a_b:80/') }.should_not.raise(URI::InvalidURIError) + -> { @object.parse('http://a_b/') }.should_not.raise(URI::InvalidURIError) end end end diff --git a/spec/ruby/library/uri/uri_spec.rb b/spec/ruby/library/uri/uri_spec.rb index 45a7502052ac0a..eab4e7176ca99e 100644 --- a/spec/ruby/library/uri/uri_spec.rb +++ b/spec/ruby/library/uri/uri_spec.rb @@ -19,11 +19,11 @@ it "returns the argument if it is a URI object" do result = URI.parse("http://ruby-lang.org") - URI(result).should equal(result) + URI(result).should.equal?(result) end #apparently this was a concern? imported from MRI tests it "does not add a URI method to Object instances" do - -> {Object.new.URI("http://ruby-lang.org/")}.should raise_error(NoMethodError) + -> {Object.new.URI("http://ruby-lang.org/")}.should.raise(NoMethodError) end end diff --git a/spec/ruby/library/weakref/__getobj___spec.rb b/spec/ruby/library/weakref/__getobj___spec.rb index 79b06f5c96d8f2..fa507384c28100 100644 --- a/spec/ruby/library/weakref/__getobj___spec.rb +++ b/spec/ruby/library/weakref/__getobj___spec.rb @@ -5,13 +5,13 @@ it "returns the object if it is reachable" do obj = Object.new ref = WeakRef.new(obj) - ref.__getobj__.should equal(obj) + ref.__getobj__.should.equal?(obj) end it "raises WeakRef::RefError if the object is no longer reachable" do ref = WeakRefSpec.make_dead_weakref -> { ref.__getobj__ - }.should raise_error(WeakRef::RefError) + }.should.raise(WeakRef::RefError) end end diff --git a/spec/ruby/library/weakref/allocate_spec.rb b/spec/ruby/library/weakref/allocate_spec.rb index e734cfd23d206e..0438d093c4d524 100644 --- a/spec/ruby/library/weakref/allocate_spec.rb +++ b/spec/ruby/library/weakref/allocate_spec.rb @@ -3,6 +3,6 @@ describe "WeakRef#allocate" do it "assigns nil as the reference" do - -> { WeakRef.allocate.__getobj__ }.should raise_error(WeakRef::RefError) + -> { WeakRef.allocate.__getobj__ }.should.raise(WeakRef::RefError) end end diff --git a/spec/ruby/library/weakref/send_spec.rb b/spec/ruby/library/weakref/send_spec.rb index 9591657e01a3fa..da8660066fcefb 100644 --- a/spec/ruby/library/weakref/send_spec.rb +++ b/spec/ruby/library/weakref/send_spec.rb @@ -27,11 +27,11 @@ def private_method it "delegates to protected methods of the weakly-referenced object" do wr = WeakRef.new(WeakRefSpecs) - -> { wr.protected_method }.should raise_error(NameError) + -> { wr.protected_method }.should.raise(NameError) end it "does not delegate to private methods of the weakly-referenced object" do wr = WeakRef.new(WeakRefSpecs) - -> { wr.private_method }.should raise_error(NameError) + -> { wr.private_method }.should.raise(NameError) end end diff --git a/spec/ruby/library/weakref/weakref_alive_spec.rb b/spec/ruby/library/weakref/weakref_alive_spec.rb index 1ebf9c1ee39821..1b12ffbbec16b1 100644 --- a/spec/ruby/library/weakref/weakref_alive_spec.rb +++ b/spec/ruby/library/weakref/weakref_alive_spec.rb @@ -5,11 +5,11 @@ it "returns true if the object is reachable" do obj = Object.new ref = WeakRef.new(obj) - ref.weakref_alive?.should be_true + ref.weakref_alive?.should == true end it "returns a falsy value if the object is no longer reachable" do ref = WeakRefSpec.make_dead_weakref - [false, nil].should include(ref.weakref_alive?) + [false, nil].should.include?(ref.weakref_alive?) end end diff --git a/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb index 994c2e6d364f37..747121aeba8261 100644 --- a/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/_invoke_spec.rb @@ -8,9 +8,9 @@ end it "raises ArgumentError if insufficient number of arguments are given" do - -> { @shell._invoke() }.should raise_error ArgumentError - -> { @shell._invoke(0) }.should raise_error ArgumentError - -> { @shell._invoke(0, []) }.should raise_error ArgumentError + -> { @shell._invoke() }.should.raise ArgumentError + -> { @shell._invoke(0) }.should.raise ArgumentError + -> { @shell._invoke(0, []) }.should.raise ArgumentError end it "dispatches the method bound to a specific ID" do diff --git a/spec/ruby/library/win32ole/win32ole/connect_spec.rb b/spec/ruby/library/win32ole/win32ole/connect_spec.rb index ac0976ddc12a7d..3a1caf85d3c9c5 100644 --- a/spec/ruby/library/win32ole/win32ole/connect_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/connect_spec.rb @@ -5,11 +5,11 @@ describe "WIN32OLE.connect" do it "creates WIN32OLE object given valid argument" do obj = WIN32OLE.connect("winmgmts:") - obj.should be_kind_of WIN32OLE + obj.should.is_a? WIN32OLE end it "raises TypeError when given invalid argument" do - -> { WIN32OLE.connect 1 }.should raise_error TypeError + -> { WIN32OLE.connect 1 }.should.raise TypeError end end diff --git a/spec/ruby/library/win32ole/win32ole/const_load_spec.rb b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb index 2099c4aa66d4e6..b0ba0235366609 100644 --- a/spec/ruby/library/win32ole/win32ole/const_load_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/const_load_spec.rb @@ -8,9 +8,9 @@ end it "loads constant SsfWINDOWS into WIN32OLE namespace" do - WIN32OLE.const_defined?(:SsfWINDOWS).should be_false + WIN32OLE.const_defined?(:SsfWINDOWS).should == false WIN32OLE.const_load @win32ole - WIN32OLE.const_defined?(:SsfWINDOWS).should be_true + WIN32OLE.const_defined?(:SsfWINDOWS).should == true end end @@ -23,9 +23,9 @@ module WIN32OLE_RUBYSPEC; end it "loads constants into given namespace" do module WIN32OLE_RUBYSPEC; end - WIN32OLE_RUBYSPEC.const_defined?(:SsfWINDOWS).should be_false + WIN32OLE_RUBYSPEC.const_defined?(:SsfWINDOWS).should == false WIN32OLE.const_load @win32ole, WIN32OLE_RUBYSPEC - WIN32OLE_RUBYSPEC.const_defined?(:SsfWINDOWS).should be_true + WIN32OLE_RUBYSPEC.const_defined?(:SsfWINDOWS).should == true end end diff --git a/spec/ruby/library/win32ole/win32ole/locale_spec.rb b/spec/ruby/library/win32ole/win32ole/locale_spec.rb index 89e84d8038520c..390c41d1a299ca 100644 --- a/spec/ruby/library/win32ole/win32ole/locale_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/locale_spec.rb @@ -20,7 +20,7 @@ WIN32OLE.locale.should == 1041 WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT - -> { WIN32OLE.locale = 111 }.should raise_error WIN32OLE::RuntimeError + -> { WIN32OLE.locale = 111 }.should.raise WIN32OLE::RuntimeError WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT ensure WIN32OLE.locale.should == WIN32OLE::LOCALE_SYSTEM_DEFAULT diff --git a/spec/ruby/library/win32ole/win32ole/new_spec.rb b/spec/ruby/library/win32ole/win32ole/new_spec.rb index b2a0a5da18549d..4f54c724d9a113 100644 --- a/spec/ruby/library/win32ole/win32ole/new_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/new_spec.rb @@ -5,20 +5,20 @@ describe "WIN32OLESpecs.new_ole" do it "creates a WIN32OLE object from OLE server name" do shell = WIN32OLESpecs.new_ole 'Shell.Application' - shell.should be_kind_of WIN32OLE + shell.should.is_a? WIN32OLE end it "creates a WIN32OLE object from valid CLSID" do shell = WIN32OLESpecs.new_ole("{13709620-C279-11CE-A49E-444553540000}") - shell.should be_kind_of WIN32OLE + shell.should.is_a? WIN32OLE end it "raises TypeError if argument cannot be converted to String" do - -> { WIN32OLESpecs.new_ole(42) }.should raise_error( TypeError ) + -> { WIN32OLESpecs.new_ole(42) }.should.raise( TypeError ) end it "raises WIN32OLE::RuntimeError if invalid string is given" do - -> { WIN32OLE.new('foo') }.should raise_error( WIN32OLE::RuntimeError ) + -> { WIN32OLE.new('foo') }.should.raise( WIN32OLE::RuntimeError ) end end 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 b846685518f1a9..33e3e23b1bcd16 100644 --- a/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb @@ -8,15 +8,15 @@ end it "raises ArgumentError if argument is given" do - -> { @dict.ole_func_methods(1) }.should raise_error ArgumentError + -> { @dict.ole_func_methods(1) }.should.raise ArgumentError end it "returns an array of WIN32OLE::Methods" do - @dict.ole_func_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should be_true + @dict.ole_func_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should == true end it "contains a 'AddRef' method for Scripting Dictionary" do - @dict.ole_func_methods.map { |m| m.name }.include?('AddRef').should be_true + @dict.ole_func_methods.map { |m| m.name }.include?('AddRef').should == true end end end 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 b6e7f960bbb7f9..168a225d5837b5 100644 --- a/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb @@ -9,7 +9,7 @@ end it "returns an array of WIN32OLE::Method objects" do - @win32ole.ole_get_methods.all? {|m| m.kind_of? WIN32OLE::Method}.should be_true + @win32ole.ole_get_methods.all? {|m| m.kind_of? WIN32OLE::Method}.should == true end end diff --git a/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb index 92c4363f78c1b7..5152deeaf45409 100644 --- a/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb @@ -8,15 +8,15 @@ end it "raises ArgumentError if argument is given" do - -> { @dict.ole_methods(1) }.should raise_error ArgumentError + -> { @dict.ole_methods(1) }.should.raise ArgumentError end it "returns an array of WIN32OLE::Methods" do - @dict.ole_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should be_true + @dict.ole_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should == true end it "contains a 'AddRef' method for Scripting Dictionary" do - @dict.ole_methods.map { |m| m.name }.include?('AddRef').should be_true + @dict.ole_methods.map { |m| m.name }.include?('AddRef').should == true end end end 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 f298f19dba1aff..1478804b55459f 100644 --- a/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb @@ -9,11 +9,11 @@ end it "raises ArgumentError if argument is given" do - -> { @dict.ole_obj_help(1) }.should raise_error ArgumentError + -> { @dict.ole_obj_help(1) }.should.raise ArgumentError end it "returns an instance of WIN32OLE::Type" do - @dict.ole_obj_help.kind_of?(WIN32OLE::Type).should be_true + @dict.ole_obj_help.kind_of?(WIN32OLE::Type).should == true end end end 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 2b46ae47ded6b2..b03a5d4b06265e 100644 --- a/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb +++ b/spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb @@ -8,15 +8,15 @@ end it "raises ArgumentError if argument is given" do - -> { @dict.ole_put_methods(1) }.should raise_error ArgumentError + -> { @dict.ole_put_methods(1) }.should.raise ArgumentError end it "returns an array of WIN32OLE::Methods" do - @dict.ole_put_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should be_true + @dict.ole_put_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should == true end it "contains a 'Key' method for Scripting Dictionary" do - @dict.ole_put_methods.map { |m| m.name }.include?('Key').should be_true + @dict.ole_put_methods.map { |m| m.name }.include?('Key').should == true end end end diff --git a/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb index bae424a604e5b8..9e4b7e7c20863a 100644 --- a/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb +++ b/spec/ruby/library/win32ole/win32ole/shared/ole_method.rb @@ -7,12 +7,12 @@ end it "raises ArgumentError if no argument is given" do - -> { @dict.send(@method) }.should raise_error ArgumentError + -> { @dict.send(@method) }.should.raise ArgumentError end it "returns the WIN32OLE::Method 'Add' if given 'Add'" do result = @dict.send(@method, "Add") - result.kind_of?(WIN32OLE::Method).should be_true + result.kind_of?(WIN32OLE::Method).should == true result.name.should == 'Add' end end diff --git a/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb b/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb index b9267aef71aee8..de3ad7b2868876 100644 --- a/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb +++ b/spec/ruby/library/win32ole/win32ole/shared/setproperty.rb @@ -7,7 +7,7 @@ end it "raises ArgumentError if no argument is given" do - -> { @dict.send(@method) }.should raise_error ArgumentError + -> { @dict.send(@method) }.should.raise ArgumentError end it "sets key to newkey and returns nil" do diff --git a/spec/ruby/library/win32ole/win32ole_event/new_spec.rb b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb index 4efd4c3e0fa9ae..d09c38b78d175e 100644 --- a/spec/ruby/library/win32ole/win32ole_event/new_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_event/new_spec.rb @@ -13,21 +13,21 @@ end it "raises TypeError given invalid argument" do - -> { WIN32OLE::Event.new "A" }.should raise_error TypeError + -> { WIN32OLE::Event.new "A" }.should.raise TypeError end it "raises RuntimeError if event does not exist" do - -> { WIN32OLE::Event.new(@xml_dom, 'A') }.should raise_error RuntimeError + -> { WIN32OLE::Event.new(@xml_dom, 'A') }.should.raise RuntimeError end it "raises RuntimeError if OLE object has no events" do dict = WIN32OLESpecs.new_ole('Scripting.Dictionary') - -> { WIN32OLE::Event.new(dict) }.should raise_error RuntimeError + -> { WIN32OLE::Event.new(dict) }.should.raise RuntimeError end it "creates WIN32OLE::Event object" do ev = WIN32OLE::Event.new(@xml_dom) - ev.should be_kind_of WIN32OLE::Event + ev.should.is_a? WIN32OLE::Event end end end diff --git a/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb index e5f55f2d38f8c0..43084eb943b99c 100644 --- a/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m.dispid(0) }.should raise_error ArgumentError + -> { @m.dispid(0) }.should.raise ArgumentError end it "returns expected dispatch ID for Shell's 'namespace' method" do 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 bea47348eee6fc..1d00fb9696c4c3 100644 --- a/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb @@ -12,7 +12,7 @@ end it "raises ArgumentError if argument is given" do - -> { @on_dbl_click_method.event_interface(1) }.should raise_error ArgumentError + -> { @on_dbl_click_method.event_interface(1) }.should.raise ArgumentError end it "returns expected string for System Monitor Control's 'OnDblClick' method" do @@ -20,7 +20,7 @@ end it "returns nil if method has no event interface" do - @namespace_method.event_interface.should be_nil + @namespace_method.event_interface.should == nil end end diff --git a/spec/ruby/library/win32ole/win32ole_method/event_spec.rb b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb index 5a94cf5ce6e07e..fd611519cbbe9a 100644 --- a/spec/ruby/library/win32ole/win32ole_method/event_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/event_spec.rb @@ -10,11 +10,11 @@ end it "raises ArgumentError if argument is given" do - -> { @on_dbl_click_method.event?(1) }.should raise_error ArgumentError + -> { @on_dbl_click_method.event?(1) }.should.raise ArgumentError end it "returns true for System Monitor Control's 'OnDblClick' method" do - @on_dbl_click_method.event?.should be_true + @on_dbl_click_method.event?.should == true end end diff --git a/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb index 83f34b9c109088..88164bcd1f8d1f 100644 --- a/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb @@ -11,7 +11,7 @@ end it "raises ArgumentError if argument is given" do - -> { @get_file_version.helpcontext(1) }.should raise_error ArgumentError + -> { @get_file_version.helpcontext(1) }.should.raise ArgumentError end it "returns expected value for FileSystemObject's 'GetFileVersion' method" do diff --git a/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb index 9cf9d63d3b406e..314f58c062a750 100644 --- a/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_file_name.helpfile(1) }.should raise_error ArgumentError + -> { @m_file_name.helpfile(1) }.should.raise ArgumentError end it "returns expected value for Scripting Runtime's 'File' method" do diff --git a/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb index 5ae4a5e0909322..2a93acdb379ab1 100644 --- a/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_file_name.helpstring(1) }.should raise_error ArgumentError + -> { @m_file_name.helpstring(1) }.should.raise ArgumentError end it "returns expected value for Scripting Runtime's 'File' method" do diff --git a/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb index 06acbb58a54ae4..16e5412a364f2e 100644 --- a/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_file_name.invkind(1) }.should raise_error ArgumentError + -> { @m_file_name.invkind(1) }.should.raise ArgumentError end it "returns expected value for Scripting Runtime's 'name' method" do 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 0e97ec3305af6c..312860a9c59b9e 100644 --- a/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_file_name.invoke_kind(1) }.should raise_error ArgumentError + -> { @m_file_name.invoke_kind(1) }.should.raise ArgumentError end it "returns expected value for Scripting Runtime's 'name' method" do diff --git a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb index 46186ae566fe3a..d805d801285df8 100644 --- a/spec/ruby/library/win32ole/win32ole_method/new_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/new_spec.rb @@ -8,25 +8,25 @@ end it "raises TypeError when given non-strings" do - -> { WIN32OLE::Method.new(1, 2) }.should raise_error TypeError + -> { WIN32OLE::Method.new(1, 2) }.should.raise TypeError end it "raises ArgumentError if only 1 argument is given" do - -> { WIN32OLE::Method.new("hello") }.should raise_error ArgumentError - -> { WIN32OLE::Method.new(@ole_type) }.should raise_error ArgumentError + -> { WIN32OLE::Method.new("hello") }.should.raise ArgumentError + -> { WIN32OLE::Method.new(@ole_type) }.should.raise ArgumentError end it "returns a valid WIN32OLE::Method object" do - WIN32OLE::Method.new(@ole_type, "Open").should be_kind_of WIN32OLE::Method - WIN32OLE::Method.new(@ole_type, "open").should be_kind_of WIN32OLE::Method + WIN32OLE::Method.new(@ole_type, "Open").should.is_a? WIN32OLE::Method + WIN32OLE::Method.new(@ole_type, "open").should.is_a? WIN32OLE::Method end it "raises WIN32OLE::RuntimeError if the method does not exist" do - -> { WIN32OLE::Method.new(@ole_type, "NonexistentMethod") }.should raise_error WIN32OLE::RuntimeError + -> { WIN32OLE::Method.new(@ole_type, "NonexistentMethod") }.should.raise WIN32OLE::RuntimeError end it "raises TypeError if second argument is not a String" do - -> { WIN32OLE::Method.new(@ole_type, 5) }.should raise_error TypeError + -> { WIN32OLE::Method.new(@ole_type, 5) }.should.raise TypeError end end 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 3c80cb3c2ae9cf..7c7e49ff3acffe 100644 --- a/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_file_name.offset_vtbl(1) }.should raise_error ArgumentError + -> { @m_file_name.offset_vtbl(1) }.should.raise ArgumentError end it "returns expected value for Scripting Runtime's 'name' method" do diff --git a/spec/ruby/library/win32ole/win32ole_method/params_spec.rb b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb index 0b1b4595a313a2..40a543fa559cb5 100644 --- a/spec/ruby/library/win32ole/win32ole_method/params_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/params_spec.rb @@ -11,16 +11,16 @@ end it "raises ArgumentError if argument is given" do - -> { @m_file_name.params(1) }.should raise_error ArgumentError + -> { @m_file_name.params(1) }.should.raise ArgumentError end it "returns empty array for Scripting Runtime's 'name' method" do - @m_file_name.params.should be_kind_of Array - @m_file_name.params.should be_empty + @m_file_name.params.should.is_a? Array + @m_file_name.params.should.empty? end it "returns 4-element array of WIN32OLE::Param for Shell's 'BrowseForFolder' method" do - @m_browse_for_folder.params.all? { |p| p.kind_of? WIN32OLE::Param }.should be_true + @m_browse_for_folder.params.all? { |p| p.kind_of? WIN32OLE::Param }.should == true @m_browse_for_folder.params.size == 4 end 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 c3725bfef20d07..6d46c705c6865d 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 @@ -9,11 +9,11 @@ end it "raises ArgumentError if argument is given" do - -> { @m_browse_for_folder.return_type_detail(1) }.should raise_error ArgumentError + -> { @m_browse_for_folder.return_type_detail(1) }.should.raise ArgumentError end it "returns expected value for Shell Control's 'BrowseForFolder' method" do - @m_browse_for_folder.return_type_detail.should be_kind_of Array + @m_browse_for_folder.return_type_detail.should.is_a? Array @m_browse_for_folder.return_type_detail.should == ['PTR', 'USERDEFINED', 'Folder'] end 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 9e5a1eb1dfc3ec..5afaf202f297c9 100644 --- a/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_file_name.return_type(1) }.should raise_error ArgumentError + -> { @m_file_name.return_type(1) }.should.raise ArgumentError end it "returns expected value for Scripting Runtime's 'name' method" do 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 34fd135b8cc599..882b5eaf4340d2 100644 --- a/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_browse_for_folder.return_vtype(1) }.should raise_error ArgumentError + -> { @m_browse_for_folder.return_vtype(1) }.should.raise ArgumentError end it "returns expected value for Shell Control's 'BrowseForFolder' method" do diff --git a/spec/ruby/library/win32ole/win32ole_method/shared/name.rb b/spec/ruby/library/win32ole/win32ole_method/shared/name.rb index 7e2197ca5a2d5d..ef639998363070 100644 --- a/spec/ruby/library/win32ole/win32ole_method/shared/name.rb +++ b/spec/ruby/library/win32ole/win32ole_method/shared/name.rb @@ -8,7 +8,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_file_name.send(@method, 1) }.should raise_error ArgumentError + -> { @m_file_name.send(@method, 1) }.should.raise ArgumentError end it "returns expected value for Scripting Runtime's 'name' method" do 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 38cb21ccef9ac6..e03a97c6c06319 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 @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_browse_for_folder.size_opt_params(1) }.should raise_error ArgumentError + -> { @m_browse_for_folder.size_opt_params(1) }.should.raise ArgumentError end it "returns expected value for Shell Control's 'BrowseForFolder' method" do 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 5d0a35a0ef559b..f64f77af467d30 100644 --- a/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @m_browse_for_folder.size_params(1) }.should raise_error ArgumentError + -> { @m_browse_for_folder.size_params(1) }.should.raise ArgumentError end it "returns expected value for Shell Control's 'BrowseForFolder' method" do diff --git a/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb index 2f02c15c8b9719..a04ac6570b2e42 100644 --- a/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_method/visible_spec.rb @@ -9,11 +9,11 @@ end it "raises ArgumentError if argument is given" do - -> { @m_browse_for_folder.visible?(1) }.should raise_error ArgumentError + -> { @m_browse_for_folder.visible?(1) }.should.raise ArgumentError end it "returns true for Shell Control's 'BrowseForFolder' method" do - @m_browse_for_folder.visible?.should be_true + @m_browse_for_folder.visible?.should == true end end diff --git a/spec/ruby/library/win32ole/win32ole_param/default_spec.rb b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb index a37b03866d79ec..dded6833d48c5f 100644 --- a/spec/ruby/library/win32ole/win32ole_param/default_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_param/default_spec.rb @@ -14,12 +14,12 @@ end it "raises ArgumentError if argument is given" do - -> { @params[0].default(1) }.should raise_error ArgumentError + -> { @params[0].default(1) }.should.raise ArgumentError end it "returns nil for each of WIN32OLE::Param for Shell's 'BrowseForFolder' method" do @params.each do |p| - p.default.should be_nil + p.default.should == nil end end diff --git a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb index d7e27d7739000b..46dc305d2b608c 100644 --- a/spec/ruby/library/win32ole/win32ole_param/input_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_param/input_spec.rb @@ -10,7 +10,7 @@ end it "raises ArgumentError if argument is given" do - -> { @param_overwritefiles.input?(1) }.should raise_error ArgumentError + -> { @param_overwritefiles.input?(1) }.should.raise ArgumentError end it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" 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 e3379dbf3e3f39..bd25ec325a6b6f 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 @@ -10,7 +10,7 @@ end it "raises ArgumentError if argument is given" do - -> { @param_overwritefiles.ole_type_detail(1) }.should raise_error ArgumentError + -> { @param_overwritefiles.ole_type_detail(1) }.should.raise ArgumentError end it "returns ['BOOL'] for 3rd parameter of FileSystemObject's 'CopyFile' method" do 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 a7b66668077552..3f0c27931618d8 100644 --- a/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb @@ -10,7 +10,7 @@ end it "raises ArgumentError if argument is given" do - -> { @param_overwritefiles.ole_type(1) }.should raise_error ArgumentError + -> { @param_overwritefiles.ole_type(1) }.should.raise ArgumentError end it "returns 'BOOL' for 3rd parameter of FileSystemObject's 'CopyFile' method" do diff --git a/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb index 50e95fc77fa170..ca676e09508a75 100644 --- a/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_param/optional_spec.rb @@ -10,11 +10,11 @@ end it "raises ArgumentError if argument is given" do - -> { @param_overwritefiles.optional?(1) }.should raise_error ArgumentError + -> { @param_overwritefiles.optional?(1) }.should.raise ArgumentError end it "returns true for 3rd parameter of FileSystemObject's 'CopyFile' method" do - @param_overwritefiles.optional?.should be_true + @param_overwritefiles.optional?.should == true end end diff --git a/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb index fa4a09ea0c3de8..f25b1e7e14c094 100644 --- a/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_param/retval_spec.rb @@ -10,11 +10,11 @@ end it "raises ArgumentError if argument is given" do - -> { @param_overwritefiles.retval?(1) }.should raise_error ArgumentError + -> { @param_overwritefiles.retval?(1) }.should.raise ArgumentError end it "returns false for 3rd parameter of FileSystemObject's 'CopyFile' method" do - @param_overwritefiles.retval?.should be_false + @param_overwritefiles.retval?.should == false end end diff --git a/spec/ruby/library/win32ole/win32ole_param/shared/name.rb b/spec/ruby/library/win32ole/win32ole_param/shared/name.rb index 56ff24ddc83c96..1f6cbea7a03f62 100644 --- a/spec/ruby/library/win32ole/win32ole_param/shared/name.rb +++ b/spec/ruby/library/win32ole/win32ole_param/shared/name.rb @@ -9,7 +9,7 @@ end it "raises ArgumentError if argument is given" do - -> { @param_overwritefiles.send(@method, 1) }.should raise_error ArgumentError + -> { @param_overwritefiles.send(@method, 1) }.should.raise ArgumentError end it "returns expected value for Scripting Runtime's 'name' method" do diff --git a/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb index 35911fec52c1bd..7b605a038b39b7 100644 --- a/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb @@ -12,7 +12,7 @@ end it "returns an Integer" do - @ole_type.helpcontext.should be_kind_of Integer + @ole_type.helpcontext.should.is_a? Integer end end diff --git a/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb b/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb index 7bd61a1c401984..43a979882a45ab 100644 --- a/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb @@ -12,7 +12,7 @@ end it "returns an empty string" do - @ole_type.helpfile.should be_empty + @ole_type.helpfile.should.empty? end end 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 598e5bcef8a7b4..66fdbc9ab063b0 100644 --- a/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb @@ -12,7 +12,7 @@ end it "returns an Integer" do - @ole_type.major_version.should be_kind_of Integer + @ole_type.major_version.should.is_a? Integer end end 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 59cfb940126aee..afb50865659721 100644 --- a/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb @@ -12,7 +12,7 @@ end it "returns an Integer" do - @ole_type.minor_version.should be_kind_of Integer + @ole_type.minor_version.should.is_a? Integer end end diff --git a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb index 185a23594053eb..9d92177a4b46d5 100644 --- a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb @@ -4,37 +4,37 @@ describe "WIN32OLE::Type.new" do it "raises ArgumentError with no argument" do - -> { WIN32OLE::Type.new }.should raise_error ArgumentError + -> { WIN32OLE::Type.new }.should.raise ArgumentError end it "raises ArgumentError with invalid string" do - -> { WIN32OLE::Type.new("foo") }.should raise_error ArgumentError + -> { WIN32OLE::Type.new("foo") }.should.raise ArgumentError end it "raises TypeError if second argument is not a String" do - -> { WIN32OLE::Type.new(1,2) }.should raise_error TypeError + -> { WIN32OLE::Type.new(1,2) }.should.raise TypeError -> { WIN32OLE::Type.new('Microsoft Shell Controls And Automation',2) - }.should raise_error TypeError + }.should.raise TypeError end it "raise WIN32OLE::RuntimeError if OLE object specified is not found" do -> { WIN32OLE::Type.new('Microsoft Shell Controls And Automation','foo') - }.should raise_error WIN32OLE::RuntimeError + }.should.raise WIN32OLE::RuntimeError -> { WIN32OLE::Type.new('Microsoft Shell Controls And Automation','Application') - }.should raise_error WIN32OLE::RuntimeError + }.should.raise WIN32OLE::RuntimeError end it "creates WIN32OLE::Type object from name and valid type" do ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell") - ole_type.should be_kind_of WIN32OLE::Type + ole_type.should.is_a? WIN32OLE::Type end it "creates WIN32OLE::Type object from CLSID and valid type" do ole_type2 = WIN32OLE::Type.new("{13709620-C279-11CE-A49E-444553540000}", "Shell") - ole_type2.should be_kind_of WIN32OLE::Type + ole_type2.should.is_a? WIN32OLE::Type end end 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 ed14e37a958f1a..7db08dc90099bf 100644 --- a/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb @@ -12,7 +12,7 @@ end it "returns array of WIN32OLE_TYPEs" do - WIN32OLE::Type.ole_classes("Microsoft Shell Controls And Automation").all? {|e| e.kind_of? WIN32OLE::Type }.should be_true + WIN32OLE::Type.ole_classes("Microsoft Shell Controls And Automation").all? {|e| e.kind_of? WIN32OLE::Type }.should == true end end 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 0c031abaa6ea60..bdf668e53b6b80 100644 --- a/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb @@ -12,7 +12,7 @@ end it "returns an Integer" do - @ole_type.ole_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should be_true + @ole_type.ole_methods.all? { |m| m.kind_of? WIN32OLE::Method }.should == true end end diff --git a/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb index b1b57960cd6202..cbb9247da123d4 100644 --- a/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/progids_spec.rb @@ -4,11 +4,11 @@ describe "WIN32OLE::Type.progids" do it "raises ArgumentError if an argument is given" do - -> { WIN32OLE::Type.progids(1) }.should raise_error ArgumentError + -> { WIN32OLE::Type.progids(1) }.should.raise ArgumentError end it "returns an array containing 'Shell.Explorer'" do - WIN32OLE::Type.progids().include?('Shell.Explorer').should be_true + WIN32OLE::Type.progids().include?('Shell.Explorer').should == true end end diff --git a/spec/ruby/library/win32ole/win32ole_type/shared/name.rb b/spec/ruby/library/win32ole/win32ole_type/shared/name.rb index efae7aeec16224..707149a5bb6eba 100644 --- a/spec/ruby/library/win32ole/win32ole_type/shared/name.rb +++ b/spec/ruby/library/win32ole/win32ole_type/shared/name.rb @@ -7,7 +7,7 @@ end it "raises ArgumentError if argument is given" do - -> { @ole_type.send(@method, 1) }.should raise_error ArgumentError + -> { @ole_type.send(@method, 1) }.should.raise ArgumentError end it "returns a String" do 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 3c7651cc1fd250..9f0893b75006ee 100644 --- a/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb @@ -12,7 +12,7 @@ end it "returns nil" do - @ole_type.src_type.should be_nil + @ole_type.src_type.should == nil end end diff --git a/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb b/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb index 8b62f3e2ebb5c9..10516270250f0e 100644 --- a/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb @@ -12,7 +12,7 @@ end it "returns an Integer" do - @ole_type.typekind.should be_kind_of Integer + @ole_type.typekind.should.is_a? Integer end end diff --git a/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb index 71d7cf00f76a3e..36400d75f2ae88 100644 --- a/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb @@ -12,11 +12,11 @@ end it "raises ArgumentError if any argument is give" do - -> { WIN32OLE::Type.typelibs(1) }.should raise_error ArgumentError + -> { WIN32OLE::Type.typelibs(1) }.should.raise ArgumentError end it "returns array of type libraries" do - WIN32OLE::Type.typelibs().include?("Microsoft Shell Controls And Automation").should be_true + WIN32OLE::Type.typelibs().include?("Microsoft Shell Controls And Automation").should == true end end diff --git a/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb index 05c54c8838a560..bca9159d53da16 100644 --- a/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_type/visible_spec.rb @@ -12,7 +12,7 @@ end it "returns true" do - @ole_type.visible?.should be_true + @ole_type.visible?.should == true end end 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 89576ceedc69e2..a9232d2b28b8e0 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 @@ -11,8 +11,8 @@ end it "returns a nonempty Array" do - @var.ole_type_detail.should be_kind_of Array - @var.ole_type_detail.should_not be_empty + @var.ole_type_detail.should.is_a? Array + @var.ole_type_detail.should_not.empty? end end 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 441011f1e7feff..f28cbfd37a910f 100644 --- a/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb @@ -11,7 +11,7 @@ end it "returns a String" do - @var.ole_type.should be_kind_of String + @var.ole_type.should.is_a? String end end diff --git a/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb b/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb index d02942ce0a89ad..d0790666162a68 100644 --- a/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb +++ b/spec/ruby/library/win32ole/win32ole_variable/shared/name.rb @@ -10,7 +10,7 @@ end it "returns a String" do - @var.send(@method).should be_kind_of String + @var.send(@method).should.is_a? String end end diff --git a/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb index d26273ebeda6ee..33066e40efef9e 100644 --- a/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_variable/value_spec.rb @@ -12,7 +12,7 @@ it "returns an Integer" do # according to doc, this could return nil - @var.value.should be_kind_of Integer + @var.value.should.is_a? Integer end end 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 17bc47160affb9..2cf1d7f1f268d2 100644 --- a/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb @@ -11,7 +11,7 @@ end it "returns a String" do - @var.variable_kind.should be_kind_of String + @var.variable_kind.should.is_a? String @var.variable_kind.should == 'CONSTANT' end diff --git a/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb index c5f81645099287..04ccb8d46f52eb 100644 --- a/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb @@ -12,7 +12,7 @@ end it "returns an Integer" do - @var.varkind.should be_kind_of Integer + @var.varkind.should.is_a? Integer end end diff --git a/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb b/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb index ba53a81de0bfc1..939468122cd390 100644 --- a/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb +++ b/spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb @@ -11,7 +11,7 @@ end it "returns a String" do - @var.visible?.should be_true + @var.visible?.should == true end end diff --git a/spec/ruby/library/yaml/parse_file_spec.rb b/spec/ruby/library/yaml/parse_file_spec.rb index 7bffcdc62f9bf7..a29377f163856c 100644 --- a/spec/ruby/library/yaml/parse_file_spec.rb +++ b/spec/ruby/library/yaml/parse_file_spec.rb @@ -5,6 +5,6 @@ describe "YAML.parse_file" do it "returns a YAML::Syck::Map object after parsing a YAML file" do test_parse_file = fixture __FILE__, "test_yaml.yml" - YAML.parse_file(test_parse_file).should be_kind_of(Psych::Nodes::Document) + YAML.parse_file(test_parse_file).should.is_a?(Psych::Nodes::Document) end end diff --git a/spec/ruby/library/yaml/parse_spec.rb b/spec/ruby/library/yaml/parse_spec.rb index 37e2b7fa0a5420..832cd99d039398 100644 --- a/spec/ruby/library/yaml/parse_spec.rb +++ b/spec/ruby/library/yaml/parse_spec.rb @@ -4,7 +4,7 @@ describe "YAML.parse with an empty string" do it "returns false" do - YAML.parse('').should be_false + YAML.parse('').should == false end end diff --git a/spec/ruby/library/yaml/shared/load.rb b/spec/ruby/library/yaml/shared/load.rb index b8bb605b0a02fd..7e5669f2d0fdbb 100644 --- a/spec/ruby/library/yaml/shared/load.rb +++ b/spec/ruby/library/yaml/shared/load.rb @@ -60,7 +60,7 @@ else error = ArgumentError end - -> { YAML.send(@method, "key1: value\ninvalid_key") }.should raise_error(error) + -> { YAML.send(@method, "key1: value\ninvalid_key") }.should.raise(error) end it "accepts symbols" do @@ -117,7 +117,7 @@ ].should be_computed_by(:usec) end - it "rounds values smaller than 1 usec to 0 " do + 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 @@ -137,6 +137,6 @@ loaded = YAML.send(@method, "--- !ruby/object:File {}\n") -> { loaded.read(1) - }.should raise_error(IOError) + }.should.raise(IOError) end end diff --git a/spec/ruby/library/yaml/to_yaml_spec.rb b/spec/ruby/library/yaml/to_yaml_spec.rb index 08c545141629ee..328ab25552876e 100644 --- a/spec/ruby/library/yaml/to_yaml_spec.rb +++ b/spec/ruby/library/yaml/to_yaml_spec.rb @@ -32,25 +32,25 @@ it "returns the YAML representation of a FalseClass" do false_klass = false - false_klass.should be_kind_of(FalseClass) + false_klass.should.is_a?(FalseClass) false_klass.to_yaml.should match_yaml("--- false\n") end it "returns the YAML representation of a Float object" do float = 1.2 - float.should be_kind_of(Float) + float.should.is_a?(Float) float.to_yaml.should match_yaml("--- 1.2\n") end it "returns the YAML representation of an Integer object" do int = 20 - int.should be_kind_of(Integer) + int.should.is_a?(Integer) int.to_yaml.should match_yaml("--- 20\n") end it "returns the YAML representation of a NilClass object" do nil_klass = nil - nil_klass.should be_kind_of(NilClass) + nil_klass.should.is_a?(NilClass) nil_klass.to_yaml.should match_yaml("--- \n") end @@ -84,7 +84,7 @@ it "returns the YAML representation of a TrueClass" do true_klass = true - true_klass.should be_kind_of(TrueClass) + true_klass.should.is_a?(TrueClass) true_klass.to_yaml.should match_yaml("--- true\n") end @@ -94,10 +94,10 @@ it "returns the YAML representation for Range objects" do yaml = Range.new(1,3).to_yaml - yaml.include?("!ruby/range").should be_true - yaml.include?("begin: 1").should be_true - yaml.include?("end: 3").should be_true - yaml.include?("excl: false").should be_true + yaml.include?("!ruby/range").should == true + yaml.include?("begin: 1").should == true + yaml.include?("end: 3").should == true + yaml.include?("excl: false").should == true end it "returns the YAML representation of numeric constants" do diff --git a/spec/ruby/library/zlib/adler32_spec.rb b/spec/ruby/library/zlib/adler32_spec.rb index 226aa18522c4a9..887c22d059ec16 100644 --- a/spec/ruby/library/zlib/adler32_spec.rb +++ b/spec/ruby/library/zlib/adler32_spec.rb @@ -19,7 +19,7 @@ Zlib.adler32(test_string, 1).should == 66391324 Zlib.adler32(test_string, 2**8).should == 701435419 Zlib.adler32(test_string, 2**16).should == 63966491 - -> { Zlib.adler32(test_string, 2**128) }.should raise_error(RangeError) + -> { Zlib.adler32(test_string, 2**128) }.should.raise(RangeError) end it "calculates the Adler checksum for string and initial Adler value for Integers" do diff --git a/spec/ruby/library/zlib/crc32_spec.rb b/spec/ruby/library/zlib/crc32_spec.rb index d5f5c199cc0216..b94b5c627cda00 100644 --- a/spec/ruby/library/zlib/crc32_spec.rb +++ b/spec/ruby/library/zlib/crc32_spec.rb @@ -26,7 +26,7 @@ Zlib.crc32(test_string, 2**16).should == 1932511220 Zlib.crc32("p", ~305419896).should == 4046865307 Zlib.crc32("p", -305419897).should == 4046865307 - -> { Zlib.crc32(test_string, 2**128) }.should raise_error(RangeError) + -> { Zlib.crc32(test_string, 2**128) }.should.raise(RangeError) end it "calculates the CRC checksum for string and initial CRC value for Integers" do diff --git a/spec/ruby/library/zlib/gzipfile/close_spec.rb b/spec/ruby/library/zlib/gzipfile/close_spec.rb index 964b5ffb4dcd44..07bafac9619a7d 100644 --- a/spec/ruby/library/zlib/gzipfile/close_spec.rb +++ b/spec/ruby/library/zlib/gzipfile/close_spec.rb @@ -10,10 +10,8 @@ gzio.should.closed? - -> { gzio.orig_name }.should \ - raise_error(Zlib::GzipFile::Error, 'closed gzip stream') - -> { gzio.comment }.should \ - raise_error(Zlib::GzipFile::Error, 'closed gzip stream') + -> { gzio.orig_name }.should.raise(Zlib::GzipFile::Error, 'closed gzip stream') + -> { gzio.comment }.should.raise(Zlib::GzipFile::Error, 'closed gzip stream') end io.string[10..-1].should == ([3] + Array.new(9,0)).pack('C*') diff --git a/spec/ruby/library/zlib/gzipfile/comment_spec.rb b/spec/ruby/library/zlib/gzipfile/comment_spec.rb index 70d97ecaf6edf0..845224df98ada0 100644 --- a/spec/ruby/library/zlib/gzipfile/comment_spec.rb +++ b/spec/ruby/library/zlib/gzipfile/comment_spec.rb @@ -19,8 +19,7 @@ Zlib::GzipWriter.wrap @io do |gzio| gzio.close - -> { gzio.comment }.should \ - raise_error(Zlib::GzipFile::Error, 'closed gzip stream') + -> { gzio.comment }.should.raise(Zlib::GzipFile::Error, 'closed gzip stream') end end end diff --git a/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb b/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb index ebfd3692aff998..1da375390bda03 100644 --- a/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb +++ b/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb @@ -19,8 +19,7 @@ Zlib::GzipWriter.wrap @io do |gzio| gzio.close - -> { gzio.orig_name }.should \ - raise_error(Zlib::GzipFile::Error, 'closed gzip stream') + -> { gzio.orig_name }.should.raise(Zlib::GzipFile::Error, 'closed gzip stream') end end end diff --git a/spec/ruby/library/zlib/gzipreader/eof_spec.rb b/spec/ruby/library/zlib/gzipreader/eof_spec.rb index 673220fdfd6e67..a38e144c7231a2 100644 --- a/spec/ruby/library/zlib/gzipreader/eof_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/eof_spec.rb @@ -12,31 +12,31 @@ it "returns true when at EOF" do gz = Zlib::GzipReader.new @io - gz.eof?.should be_false + gz.eof?.should == false gz.read - gz.eof?.should be_true + gz.eof?.should == true end it "returns true when at EOF with the exact length of uncompressed data" do gz = Zlib::GzipReader.new @io - gz.eof?.should be_false + gz.eof?.should == false gz.read(10) - gz.eof?.should be_true + gz.eof?.should == true end it "returns true when at EOF with a length greater than the size of uncompressed data" do gz = Zlib::GzipReader.new @io - gz.eof?.should be_false + gz.eof?.should == false gz.read(11) - gz.eof?.should be_true + gz.eof?.should == true end it "returns false when at EOF when there's data left in the buffer to read" do gz = Zlib::GzipReader.new @io gz.read(9) - gz.eof?.should be_false + gz.eof?.should == false gz.read - gz.eof?.should be_true + gz.eof?.should == true end # This is especially important for JRuby, since eof? there @@ -44,11 +44,11 @@ it "does not affect the reading data" do gz = Zlib::GzipReader.new @io 0.upto(9) do |i| - gz.eof?.should be_false + gz.eof?.should == false gz.read(1).should == @data[i, 1] end - gz.eof?.should be_true + gz.eof?.should == true gz.read.should == "" - gz.eof?.should be_true + gz.eof?.should == true end end diff --git a/spec/ruby/library/zlib/gzipreader/getc_spec.rb b/spec/ruby/library/zlib/gzipreader/getc_spec.rb index e5672319402b20..be135921891581 100644 --- a/spec/ruby/library/zlib/gzipreader/getc_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/getc_spec.rb @@ -33,7 +33,7 @@ gz = Zlib::GzipReader.new @io gz.read pos = gz.pos - gz.getc.should be_nil + gz.getc.should == nil gz.pos.should == pos end end diff --git a/spec/ruby/library/zlib/gzipreader/gets_spec.rb b/spec/ruby/library/zlib/gzipreader/gets_spec.rb index d3a2e7d263b131..5d0809f833b145 100644 --- a/spec/ruby/library/zlib/gzipreader/gets_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/gets_spec.rb @@ -16,7 +16,7 @@ gz.gets('').should == "123\n45\n\n" gz.gets('').should == "abc\nde\n\n" - gz.eof?.should be_true + gz.eof?.should == true end end end diff --git a/spec/ruby/library/zlib/gzipreader/read_spec.rb b/spec/ruby/library/zlib/gzipreader/read_spec.rb index b81954b5ce1ab0..b07d433bdddc04 100644 --- a/spec/ruby/library/zlib/gzipreader/read_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/read_spec.rb @@ -30,7 +30,7 @@ gz = Zlib::GzipReader.new @io -> { gz.read(-1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "returns an empty string if a 0 length is given" do @@ -59,8 +59,8 @@ it "returns nil if length parameter is positive" do gz = Zlib::GzipReader.new @io gz.read # read till the end - gz.read(1).should be_nil - gz.read(2**16).should be_nil + gz.read(1).should == nil + gz.read(2**16).should == nil end end end diff --git a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb index 7fa0608f9f396c..53870b91776763 100644 --- a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb @@ -94,7 +94,7 @@ it 'makes eof? false' do @gz.ungetbyte 0x21 - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -112,7 +112,7 @@ it 'does not make eof? false' do @gz.ungetbyte nil - @gz.eof?.should be_true + @gz.eof?.should == true end end end diff --git a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb index 34f2a1a2ca7f55..46dcfde98966d2 100644 --- a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb @@ -190,7 +190,7 @@ it 'makes eof? false' do @gz.ungetc 'x' - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -207,7 +207,7 @@ it 'makes eof? false' do @gz.ungetc 'ŷ' - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -224,7 +224,7 @@ it 'makes eof? false' do @gz.ungetc 'xŷž' - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -241,7 +241,7 @@ it 'makes eof? false' do @gz.ungetc 0x21 - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -258,7 +258,7 @@ it 'does not make eof? false' do @gz.ungetc '' - @gz.eof?.should be_true + @gz.eof?.should == true end end @@ -276,7 +276,7 @@ it 'does not make eof? false' do @gz.ungetc nil - @gz.eof?.should be_true + @gz.eof?.should == true end end end diff --git a/spec/ruby/library/zlib/gzipwriter/append_spec.rb b/spec/ruby/library/zlib/gzipwriter/append_spec.rb index 6aa282418002ee..ef9e3d3a6ba972 100644 --- a/spec/ruby/library/zlib/gzipwriter/append_spec.rb +++ b/spec/ruby/library/zlib/gzipwriter/append_spec.rb @@ -9,7 +9,7 @@ it "returns self" do Zlib::GzipWriter.wrap @io do |gzio| - (gzio << "test").should equal(gzio) + (gzio << "test").should.equal?(gzio) end end end diff --git a/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb b/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb index 621b602dc7c914..a70fa680696234 100644 --- a/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb +++ b/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb @@ -31,8 +31,7 @@ Zlib::GzipWriter.wrap @io do |gzio| gzio.write '' - -> { gzio.mtime = nil }.should \ - raise_error(Zlib::GzipFile::Error, 'header is already written') + -> { gzio.mtime = nil }.should.raise(Zlib::GzipFile::Error, 'header is already written') end end end diff --git a/spec/ruby/library/zlib/inflate/append_spec.rb b/spec/ruby/library/zlib/inflate/append_spec.rb index f121e665667ab2..a4c791e31e9842 100644 --- a/spec/ruby/library/zlib/inflate/append_spec.rb +++ b/spec/ruby/library/zlib/inflate/append_spec.rb @@ -41,7 +41,7 @@ it "properly handles incomplete data" do # add bytes, one by one @foo_deflated[0, 5].each_byte { |d| @z << d.chr} - -> { @z.finish }.should raise_error(Zlib::BufError) + -> { @z.finish }.should.raise(Zlib::BufError) end it "properly handles excessive data, byte-by-byte" do diff --git a/spec/ruby/library/zlib/inflate/finish_spec.rb b/spec/ruby/library/zlib/inflate/finish_spec.rb index 3e0663e265e829..b7494e419c3ae6 100644 --- a/spec/ruby/library/zlib/inflate/finish_spec.rb +++ b/spec/ruby/library/zlib/inflate/finish_spec.rb @@ -23,7 +23,7 @@ end it "each chunk should have the same prefix" do - @chunks.all? { |chunk| chunk =~ /\A0+\z/ }.should be_true + @chunks.all? { |chunk| chunk =~ /\A0+\z/ }.should == true end end diff --git a/spec/ruby/library/zlib/inflate/inflate_spec.rb b/spec/ruby/library/zlib/inflate/inflate_spec.rb index b308a4ba67b8ce..92e52363db6207 100644 --- a/spec/ruby/library/zlib/inflate/inflate_spec.rb +++ b/spec/ruby/library/zlib/inflate/inflate_spec.rb @@ -84,7 +84,7 @@ # add bytes, one by one, but not all result = +"" data.each_byte { |d| result << z.inflate(d.chr)} - -> { result << z.finish }.should raise_error(Zlib::BufError) + -> { result << z.finish }.should.raise(Zlib::BufError) end it "properly handles excessive data, byte-by-byte" do @@ -138,7 +138,7 @@ end it "properly handles chunked data" do - @chunks.all? { |chunk| chunk =~ /\A0+\z/ }.should be_true + @chunks.all? { |chunk| chunk =~ /\A0+\z/ }.should == true end end diff --git a/spec/ruby/library/zlib/zlib_version_spec.rb b/spec/ruby/library/zlib/zlib_version_spec.rb index f83dfae66dd534..7edc76cdd5117c 100644 --- a/spec/ruby/library/zlib/zlib_version_spec.rb +++ b/spec/ruby/library/zlib/zlib_version_spec.rb @@ -3,6 +3,6 @@ describe "Zlib.zlib_version" do it "returns the version of the libz library" do - Zlib.zlib_version.should be_an_instance_of(String) + Zlib.zlib_version.should.instance_of?(String) end end diff --git a/spec/ruby/optional/capi/array_spec.rb b/spec/ruby/optional/capi/array_spec.rb index 7e878598566659..0b997f774ca470 100644 --- a/spec/ruby/optional/capi/array_spec.rb +++ b/spec/ruby/optional/capi/array_spec.rb @@ -8,7 +8,7 @@ end it "raises an ArgumentError when the given argument is negative" do - -> { @s.send(@method, -1) }.should raise_error(ArgumentError) + -> { @s.send(@method, -1) }.should.raise(ArgumentError) end end @@ -84,7 +84,7 @@ end it "raises a FrozenError if the array is frozen" do - -> { @s.rb_ary_cat([].freeze, 1) }.should raise_error(FrozenError) + -> { @s.rb_ary_cat([].freeze, 1) }.should.raise(FrozenError) end end @@ -120,7 +120,7 @@ it "returns the original array" do a = [1,2,3] - @s.rb_ary_reverse(a).should equal(a) + @s.rb_ary_reverse(a).should.equal?(a) end end @@ -131,7 +131,7 @@ end it "raises a FrozenError if the array is frozen" do - -> { @s.rb_ary_rotate([].freeze, 1) }.should raise_error(FrozenError) + -> { @s.rb_ary_rotate([].freeze, 1) }.should.raise(FrozenError) end end @@ -166,7 +166,7 @@ b = @s.rb_ary_dup(a) b.should == a - b.should_not equal(a) + b.should_not.equal?(a) end end @@ -221,7 +221,7 @@ it "raises an IndexError if the negative index is greater than the length" do a = [1, 2, 3] - -> { @s.rb_ary_store(a, -10, 5) }.should raise_error(IndexError) + -> { @s.rb_ary_store(a, -10, 5) }.should.raise(IndexError) end it "enlarges the array as needed" do @@ -232,7 +232,7 @@ it "raises a FrozenError if the array is frozen" do a = [1, 2, 3].freeze - -> { @s.rb_ary_store(a, 1, 5) }.should raise_error(FrozenError) + -> { @s.rb_ary_store(a, 1, 5) }.should.raise(FrozenError) end end @@ -307,11 +307,11 @@ describe "rb_ary_includes" do it "returns true if the array includes the element" do - @s.rb_ary_includes([1, 2, 3], 2).should be_true + @s.rb_ary_includes([1, 2, 3], 2).should == true end it "returns false if the array does not include the element" do - @s.rb_ary_includes([1, 2, 3], 4).should be_false + @s.rb_ary_includes([1, 2, 3], 4).should == false end end @@ -322,7 +322,7 @@ end it "returns nil for an out of range index" do - @s.rb_ary_aref([1, 2, 3], 6).should be_nil + @s.rb_ary_aref([1, 2, 3], 6).should == nil end it "returns a new array where the first argument is the index and the second is the length" do @@ -335,7 +335,7 @@ end it "returns nil when the start of a range is out of bounds" do - @s.rb_ary_aref([1, 2, 3, 4], 6..10).should be_nil + @s.rb_ary_aref([1, 2, 3, 4], 6..10).should == nil end it "returns an empty array when the start of a range equals the last element" do @@ -352,7 +352,7 @@ s2.should == s # Make sure they're different objects - s2.equal?(s).should be_false + s2.equal?(s).should == false end it "calls a function with the other function available as a block" do @@ -387,7 +387,7 @@ def o.each s2.should == s # Make sure they're different objects - s2.equal?(s).should be_false + s2.equal?(s).should == false end it "calls a function with the other function available as a block" do @@ -422,7 +422,7 @@ def o.each it "returns nil if the element is not in the array" do ary = [1, 2, 3, 4] - @s.rb_ary_delete(ary, 5).should be_nil + @s.rb_ary_delete(ary, 5).should == nil ary.should == [1, 2, 3, 4] end end @@ -437,7 +437,7 @@ def o.each it "freezes the object exactly like Kernel#freeze" do ary = [1,2] @s.rb_ary_freeze(ary) - ary.frozen?.should be_true + ary.frozen?.should == true end end @@ -457,12 +457,12 @@ def o.each end it "returns nil if the index is out of bounds" do - @s.rb_ary_delete_at(@array, 4).should be_nil + @s.rb_ary_delete_at(@array, 4).should == nil @array.should == [1, 2, 3, 4] end it "returns nil if the negative index is out of bounds" do - @s.rb_ary_delete_at(@array, -5).should be_nil + @s.rb_ary_delete_at(@array, -5).should == nil @array.should == [1, 2, 3, 4] end end @@ -473,7 +473,7 @@ def o.each it "returns the given array" do array = [1, 2, 3] - @s.rb_ary_to_ary(array).should equal(array) + @s.rb_ary_to_ary(array).should.equal?(array) end end @@ -519,7 +519,7 @@ def o.each end it "returns nil if the begin index is out of bound" do - @s.rb_ary_subseq([1, 2, 3, 4, 5], 6, 3).should be_nil + @s.rb_ary_subseq([1, 2, 3, 4, 5], 6, 3).should == nil end it "returns the existing subsequence of the length is out of bounds" do @@ -527,7 +527,7 @@ def o.each end it "returns nil if the size is negative" do - @s.rb_ary_subseq([1, 2, 3, 4, 5], 1, -1).should be_nil + @s.rb_ary_subseq([1, 2, 3, 4, 5], 1, -1).should == nil end end end diff --git a/spec/ruby/optional/capi/bignum_spec.rb b/spec/ruby/optional/capi/bignum_spec.rb index 179f053eec4b48..ae7552b3f5f4d3 100644 --- a/spec/ruby/optional/capi/bignum_spec.rb +++ b/spec/ruby/optional/capi/bignum_spec.rb @@ -35,8 +35,8 @@ def ensure_bignum(n) end it "raises RangeError if passed Bignum overflow long" do - -> { @s.rb_big2long(ensure_bignum(@max_long + 1)) }.should raise_error(RangeError) - -> { @s.rb_big2long(ensure_bignum(@min_long - 1)) }.should raise_error(RangeError) + -> { @s.rb_big2long(ensure_bignum(@max_long + 1)) }.should.raise(RangeError) + -> { @s.rb_big2long(ensure_bignum(@min_long - 1)) }.should.raise(RangeError) end end @@ -49,8 +49,8 @@ def ensure_bignum(n) end it "raises RangeError if passed Bignum overflow long" do - -> { @s.rb_big2ll(ensure_bignum(@max_long << 40)) }.should raise_error(RangeError) - -> { @s.rb_big2ll(ensure_bignum(@min_long << 40)) }.should raise_error(RangeError) + -> { @s.rb_big2ll(ensure_bignum(@max_long << 40)) }.should.raise(RangeError) + -> { @s.rb_big2ll(ensure_bignum(@min_long << 40)) }.should.raise(RangeError) end end @@ -67,8 +67,8 @@ def ensure_bignum(n) end it "raises RangeError if passed Bignum overflow long" do - -> { @s.rb_big2ulong(ensure_bignum(@max_ulong + 1)) }.should raise_error(RangeError) - -> { @s.rb_big2ulong(ensure_bignum(@min_long - 1)) }.should raise_error(RangeError) + -> { @s.rb_big2ulong(ensure_bignum(@max_ulong + 1)) }.should.raise(RangeError) + -> { @s.rb_big2ulong(ensure_bignum(@min_long - 1)) }.should.raise(RangeError) end end @@ -214,13 +214,13 @@ def ensure_bignum(n) it "raises FloatDomainError for Infinity values" do inf = 1.0 / 0 - -> { @s.rb_dbl2big(inf) }.should raise_error(FloatDomainError) + -> { @s.rb_dbl2big(inf) }.should.raise(FloatDomainError) end it "raises FloatDomainError for NaN values" do nan = 0.0 / 0 - -> { @s.rb_dbl2big(nan) }.should raise_error(FloatDomainError) + -> { @s.rb_dbl2big(nan) }.should.raise(FloatDomainError) end end end diff --git a/spec/ruby/optional/capi/binding_spec.rb b/spec/ruby/optional/capi/binding_spec.rb index 5d0ef2efb87dba..1edd20b8f32bb7 100644 --- a/spec/ruby/optional/capi/binding_spec.rb +++ b/spec/ruby/optional/capi/binding_spec.rb @@ -10,7 +10,7 @@ describe "Kernel#binding" do it "raises when called from C" do foo = 14 - -> { @b.get_binding }.should raise_error(RuntimeError) + -> { @b.get_binding }.should.raise(RuntimeError) end end end diff --git a/spec/ruby/optional/capi/class_spec.rb b/spec/ruby/optional/capi/class_spec.rb index 7abb5d4ed95888..07e9e42ad10a83 100644 --- a/spec/ruby/optional/capi/class_spec.rb +++ b/spec/ruby/optional/capi/class_spec.rb @@ -11,8 +11,8 @@ describe :rb_path_to_class, shared: true do it "returns a class or module from a scoped String" do - @s.send(@method, "CApiClassSpecs::A::B").should equal(CApiClassSpecs::A::B) - @s.send(@method, "CApiClassSpecs::A::M").should equal(CApiClassSpecs::A::M) + @s.send(@method, "CApiClassSpecs::A::B").should.equal?(CApiClassSpecs::A::B) + @s.send(@method, "CApiClassSpecs::A::M").should.equal?(CApiClassSpecs::A::M) end it "resolves autoload constants" do @@ -20,21 +20,21 @@ end it "raises an ArgumentError if a constant in the path does not exist" do - -> { @s.send(@method, "CApiClassSpecs::NotDefined::B") }.should raise_error(ArgumentError) + -> { @s.send(@method, "CApiClassSpecs::NotDefined::B") }.should.raise(ArgumentError) end it "raises an ArgumentError if the final constant does not exist" do - -> { @s.send(@method, "CApiClassSpecs::NotDefined") }.should raise_error(ArgumentError) + -> { @s.send(@method, "CApiClassSpecs::NotDefined") }.should.raise(ArgumentError) end it "raises a TypeError if the constant is not a class or module" do -> { @s.send(@method, "CApiClassSpecs::A::C") - }.should raise_error(TypeError, 'CApiClassSpecs::A::C does not refer to class/module') + }.should.raise(TypeError, 'CApiClassSpecs::A::C does not refer to class/module') end it "raises an ArgumentError even if a constant in the path exists on toplevel" do - -> { @s.send(@method, "CApiClassSpecs::Object") }.should raise_error(ArgumentError) + -> { @s.send(@method, "CApiClassSpecs::Object") }.should.raise(ArgumentError) end end @@ -46,29 +46,31 @@ describe "rb_class_instance_methods" do it "returns the public and protected methods of self and its ancestors" do methods = @s.rb_class_instance_methods(ModuleSpecs::Basic) - methods.should include(:protected_module, :public_module) + methods.should.include?(:protected_module) + methods.should.include?(:public_module) methods = @s.rb_class_instance_methods(ModuleSpecs::Basic, true) - methods.should include(:protected_module, :public_module) + methods.should.include?(:protected_module) + methods.should.include?(:public_module) end it "when passed false as a parameter, returns the instance methods of the class" do methods = @s.rb_class_instance_methods(ModuleSpecs::Child, false) - methods.should include(:protected_child, :public_child) + methods.to_set.should >= Set[:protected_child, :public_child] end end describe "rb_class_public_instance_methods" do it "returns a list of public methods in module and its ancestors" do methods = @s.rb_class_public_instance_methods(ModuleSpecs::CountsChild) - methods.should include(:public_3) - methods.should include(:public_2) - methods.should include(:public_1) + methods.should.include?(:public_3) + methods.should.include?(:public_2) + methods.should.include?(:public_1) methods = @s.rb_class_public_instance_methods(ModuleSpecs::CountsChild, true) - methods.should include(:public_3) - methods.should include(:public_2) - methods.should include(:public_1) + methods.should.include?(:public_3) + methods.should.include?(:public_2) + methods.should.include?(:public_1) end it "when passed false as a parameter, should return only methods defined in that module" do @@ -79,14 +81,14 @@ describe "rb_class_protected_instance_methods" do it "returns a list of protected methods in module and its ancestors" do methods = @s.rb_class_protected_instance_methods(ModuleSpecs::CountsChild) - methods.should include(:protected_3) - methods.should include(:protected_2) - methods.should include(:protected_1) + methods.should.include?(:protected_3) + methods.should.include?(:protected_2) + methods.should.include?(:protected_1) methods = @s.rb_class_protected_instance_methods(ModuleSpecs::CountsChild, true) - methods.should include(:protected_3) - methods.should include(:protected_2) - methods.should include(:protected_1) + methods.should.include?(:protected_3) + methods.should.include?(:protected_2) + methods.should.include?(:protected_1) end it "when passed false as a parameter, should return only methods defined in that module" do @@ -110,7 +112,7 @@ it "allocates and initializes a new object" do o = @s.rb_class_new_instance([], CApiClassSpecs::Alloc) o.class.should == CApiClassSpecs::Alloc - o.initialized.should be_true + o.initialized.should == true end it "passes arguments to the #initialize method" do @@ -133,7 +135,7 @@ it "raises TypeError if the last argument is not a Hash" do -> { @s.rb_class_new_instance_kw([42], CApiClassSpecs::KeywordAlloc) - }.should raise_error(TypeError, 'no implicit conversion of Integer into Hash') + }.should.raise(TypeError, 'no implicit conversion of Integer into Hash') end end @@ -141,9 +143,9 @@ it "includes a module into a class" do c = Class.new o = c.new - -> { o.included? }.should raise_error(NameError) + -> { o.included? }.should.raise(NameError) @s.rb_include_module(c, CApiClassSpecs::M) - o.included?.should be_true + o.included?.should == true end end @@ -155,12 +157,12 @@ it "defines an attr_reader when passed true, false" do @s.rb_define_attr(CApiClassSpecs::Attr, :foo, true, false) @a.foo.should == 1 - -> { @a.foo = 5 }.should raise_error(NameError) + -> { @a.foo = 5 }.should.raise(NameError) end it "defines an attr_writer when passed false, true" do @s.rb_define_attr(CApiClassSpecs::Attr, :bar, false, true) - -> { @a.bar }.should raise_error(NameError) + -> { @a.bar }.should.raise(NameError) @a.bar = 5 @a.instance_variable_get(:@bar).should == 5 end @@ -183,7 +185,7 @@ it "calls the method in the superclass with the correct self" do @s.define_call_super_method CApiClassSpecs::SubSelf, "call_super_method" obj = CApiClassSpecs::SubSelf.new - obj.call_super_method.should equal obj + obj.call_super_method.should.equal? obj end it "calls the method in the superclass through two native levels" do @@ -200,7 +202,7 @@ end it "returns a string for an anonymous class" do - @s.rb_class2name(Class.new).should be_kind_of(String) + @s.rb_class2name(Class.new).should.is_a?(String) end it "returns a string beginning with # for an anonymous class" do @@ -224,7 +226,7 @@ end it "returns a string for an anonymous class" do - @s.rb_class_name(Class.new).should be_kind_of(String) + @s.rb_class_name(Class.new).should.is_a?(String) end end @@ -238,22 +240,22 @@ describe "rb_cvar_defined" do it "returns false when the class variable is not defined" do - @s.rb_cvar_defined(CApiClassSpecs::CVars, "@@nocvar").should be_false + @s.rb_cvar_defined(CApiClassSpecs::CVars, "@@nocvar").should == false end it "returns true when the class variable is defined" do - @s.rb_cvar_defined(CApiClassSpecs::CVars, "@@cvar").should be_true + @s.rb_cvar_defined(CApiClassSpecs::CVars, "@@cvar").should == true end it "returns true if the class instance variable is defined" do - @s.rb_cvar_defined(CApiClassSpecs::CVars, "@c_ivar").should be_true + @s.rb_cvar_defined(CApiClassSpecs::CVars, "@c_ivar").should == true end end describe "rb_cv_set" do it "sets a class variable" do o = CApiClassSpecs::CVars.new - o.new_cv.should be_nil + o.new_cv.should == nil @s.rb_cv_set(CApiClassSpecs::CVars, "@@new_cv", 1) o.new_cv.should == 1 CApiClassSpecs::CVars.remove_class_variable :@@new_cv @@ -268,14 +270,14 @@ it "raises a NameError if the class variable is not defined" do -> { @s.rb_cv_get(CApiClassSpecs::CVars, "@@no_cvar") - }.should raise_error(NameError, /class variable @@no_cvar/) + }.should.raise(NameError, /class variable @@no_cvar/) end end describe "rb_cvar_set" do it "sets a class variable" do o = CApiClassSpecs::CVars.new - o.new_cvar.should be_nil + o.new_cvar.should == nil @s.rb_cvar_set(CApiClassSpecs::CVars, "@@new_cvar", 1) o.new_cvar.should == 1 CApiClassSpecs::CVars.remove_class_variable :@@new_cvar @@ -289,8 +291,8 @@ end it "creates a subclass of the superclass" do - @cls.should be_kind_of(Class) - ClassSpecDefineClass.should equal(@cls) + @cls.should.is_a?(Class) + ClassSpecDefineClass.should.equal?(@cls) @cls.superclass.should == CApiClassSpecs::Super end @@ -307,19 +309,19 @@ it "raises a TypeError when given a non class object to superclass" do -> { @s.rb_define_class("ClassSpecDefineClass3", Module.new) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a TypeError when given a mismatched class to superclass" do -> { @s.rb_define_class("ClassSpecDefineClass", Object) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a ArgumentError when given NULL as superclass" do -> { @s.rb_define_class("ClassSpecDefineClass4", nil) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "allows arbitrary names, including constant names not valid in Ruby" do @@ -328,7 +330,7 @@ -> { Object.const_get(cls.name) - }.should raise_error(NameError, /wrong constant name/) + }.should.raise(NameError, /wrong constant name/) end end @@ -337,8 +339,8 @@ cls = @s.rb_define_class_under(CApiClassSpecs, "ClassUnder1", CApiClassSpecs::Super) - cls.should be_kind_of(Class) - CApiClassSpecs::Super.should be_ancestor_of(CApiClassSpecs::ClassUnder1) + cls.should.is_a?(Class) + CApiClassSpecs::ClassUnder1.ancestors.should.include?(CApiClassSpecs::Super) end it "sets the class name" do @@ -356,7 +358,7 @@ -> { @s.rb_define_class_under(CApiClassSpecs, "ClassUnder5", Module.new) - }.should raise_error(TypeError) + }.should.raise(TypeError) end it "raises a TypeError when given a mismatched class to superclass" do @@ -364,7 +366,7 @@ -> { @s.rb_define_class_under(CApiClassSpecs, "ClassUnder6", Class.new) - }.should raise_error(TypeError) + }.should.raise(TypeError) ensure CApiClassSpecs.send(:remove_const, :ClassUnder6) end @@ -374,7 +376,7 @@ end it "raises a TypeError if class is defined and its superclass mismatches the given one" do - -> { @s.rb_define_class_under(CApiClassSpecs, "Sub", Object) }.should raise_error(TypeError) + -> { @s.rb_define_class_under(CApiClassSpecs, "Sub", Object) }.should.raise(TypeError) end it "allows arbitrary names, including constant names not valid in Ruby" do @@ -383,15 +385,15 @@ -> { CApiClassSpecs.const_get(cls.name) - }.should raise_error(NameError, /wrong constant name/) + }.should.raise(NameError, /wrong constant name/) end end describe "rb_define_class_id_under" do it "creates a subclass of the superclass contained in a module" do cls = @s.rb_define_class_id_under(CApiClassSpecs, :ClassIdUnder1, CApiClassSpecs::Super) - cls.should be_kind_of(Class) - CApiClassSpecs::Super.should be_ancestor_of(CApiClassSpecs::ClassIdUnder1) + cls.should.is_a?(Class) + CApiClassSpecs::ClassIdUnder1.ancestors.should.include?(CApiClassSpecs::Super) end it "sets the class name" do @@ -410,7 +412,7 @@ end it "raises a TypeError if class is defined and its superclass mismatches the given one" do - -> { @s.rb_define_class_id_under(CApiClassSpecs, :Sub, Object) }.should raise_error(TypeError) + -> { @s.rb_define_class_id_under(CApiClassSpecs, :Sub, Object) }.should.raise(TypeError) end it "allows arbitrary names, including constant names not valid in Ruby" do @@ -419,14 +421,14 @@ -> { CApiClassSpecs.const_get(cls.name) - }.should raise_error(NameError, /wrong constant name/) + }.should.raise(NameError, /wrong constant name/) end end describe "rb_define_class_variable" do it "sets a class variable" do o = CApiClassSpecs::CVars.new - o.rbdcv_cvar.should be_nil + o.rbdcv_cvar.should == nil @s.rb_define_class_variable(CApiClassSpecs::CVars, "@@rbdcv_cvar", 1) o.rbdcv_cvar.should == 1 CApiClassSpecs::CVars.remove_class_variable :@@rbdcv_cvar @@ -441,23 +443,23 @@ it "raises a NameError if the class variable is not defined" do -> { @s.rb_cvar_get(CApiClassSpecs::CVars, "@@no_cvar") - }.should raise_error(NameError, /class variable @@no_cvar/) + }.should.raise(NameError, /class variable @@no_cvar/) end end describe "rb_class_new" do it "returns a new subclass of the superclass" do subclass = @s.rb_class_new(CApiClassSpecs::NewClass) - CApiClassSpecs::NewClass.should be_ancestor_of(subclass) + subclass.ancestors.should.include?(CApiClassSpecs::NewClass) end it "raises a TypeError if passed Class as the superclass" do - -> { @s.rb_class_new(Class) }.should raise_error(TypeError) + -> { @s.rb_class_new(Class) }.should.raise(TypeError) end it "raises a TypeError if passed a singleton class as the superclass" do metaclass = Object.new.singleton_class - -> { @s.rb_class_new(metaclass) }.should raise_error(TypeError) + -> { @s.rb_class_new(metaclass) }.should.raise(TypeError) end end @@ -468,7 +470,7 @@ end it "returns nil if the class has no superclass" do - @s.rb_class_superclass(BasicObject).should be_nil + @s.rb_class_superclass(BasicObject).should == nil end end diff --git a/spec/ruby/optional/capi/constants_spec.rb b/spec/ruby/optional/capi/constants_spec.rb index 172d10a788e899..74584690ad4c76 100644 --- a/spec/ruby/optional/capi/constants_spec.rb +++ b/spec/ruby/optional/capi/constants_spec.rb @@ -199,7 +199,7 @@ specify "rb_eFatal references the fatal class" do fatal = @s.rb_eFatal - fatal.should be_kind_of(Class) + fatal.should.is_a?(Class) fatal.should < Exception end diff --git a/spec/ruby/optional/capi/data_spec.rb b/spec/ruby/optional/capi/data_spec.rb index d000eba6e31cd3..af1da10f48331a 100644 --- a/spec/ruby/optional/capi/data_spec.rb +++ b/spec/ruby/optional/capi/data_spec.rb @@ -32,7 +32,7 @@ end it "raises a TypeError if the object does not wrap a struct" do - -> { @s.get_struct(Object.new) }.should raise_error(TypeError) + -> { @s.get_struct(Object.new) }.should.raise(TypeError) end end diff --git a/spec/ruby/optional/capi/debug_spec.rb b/spec/ruby/optional/capi/debug_spec.rb index 14ba25609c555b..547b24cfcc7e41 100644 --- a/spec/ruby/optional/capi/debug_spec.rb +++ b/spec/ruby/optional/capi/debug_spec.rb @@ -9,7 +9,7 @@ describe "rb_debug_inspector_open" do it "creates a debug context and calls the given callback" do - @o.rb_debug_inspector_open(42).should be_kind_of(Array) + @o.rb_debug_inspector_open(42).should.is_a?(Array) @o.debug_spec_callback_data.should == 42 end end @@ -31,7 +31,7 @@ it "returns the current binding" do a = "test" b = @o.rb_debug_inspector_frame_binding_get(1) - b.should be_an_instance_of(Binding) + b.should.instance_of?(Binding) b.local_variable_get(:a).should == "test" end @@ -55,7 +55,7 @@ describe "rb_debug_inspector_frame_iseq_get" do it "returns an InstructionSequence" do if defined?(RubyVM::InstructionSequence) - @o.rb_debug_inspector_frame_iseq_get(1).should be_an_instance_of(RubyVM::InstructionSequence) + @o.rb_debug_inspector_frame_iseq_get(1).should.instance_of?(RubyVM::InstructionSequence) else @o.rb_debug_inspector_frame_iseq_get(1).should == nil end @@ -66,9 +66,9 @@ it "returns an array of Thread::Backtrace::Location" do bts = @o.rb_debug_inspector_backtrace_locations bts.should_not.empty? - bts.each { |bt| bt.should be_kind_of(Thread::Backtrace::Location) } + bts.each { |bt| bt.should.is_a?(Thread::Backtrace::Location) } location = "#{__FILE__}:#{__LINE__ - 3}" - bts[1].to_s.should include(location) + bts[1].to_s.should.include?(location) end end end diff --git a/spec/ruby/optional/capi/encoding_spec.rb b/spec/ruby/optional/capi/encoding_spec.rb index a4a42be7561f65..b77a967b1e11e9 100644 --- a/spec/ruby/optional/capi/encoding_spec.rb +++ b/spec/ruby/optional/capi/encoding_spec.rb @@ -36,7 +36,7 @@ obj = Object.new -> { result = @s.send(@method, obj, 1) - }.should raise_error(ArgumentError, "cannot set encoding on non-encoding capable object") + }.should.raise(ArgumentError, "cannot set encoding on non-encoding capable object") end end @@ -165,7 +165,7 @@ describe "rb_enc_from_index" do it "returns an Encoding" do - @s.rb_enc_from_index(0).should be_an_instance_of(String) + @s.rb_enc_from_index(0).should.instance_of?(String) end end @@ -298,7 +298,7 @@ it "returns a String in US-ASCII encoding when high bits are set" do xEE = [0xEE].pack('C').force_encoding('utf-8') result = @s.rb_enc_str_new(xEE, 1, Encoding::US_ASCII) - result.encoding.should equal(Encoding::US_ASCII) + result.encoding.should.equal?(Encoding::US_ASCII) end end @@ -389,12 +389,12 @@ it "returns true if the object encoding is only ASCII" do str = "abc".force_encoding("us-ascii") str.valid_encoding? # make sure to set the coderange - @s.ENC_CODERANGE_ASCIIONLY(str).should be_true + @s.ENC_CODERANGE_ASCIIONLY(str).should == true end it "returns false if the object encoding is not ASCII only" do str = "ありがとう".force_encoding("utf-8") - @s.ENC_CODERANGE_ASCIIONLY(str).should be_false + @s.ENC_CODERANGE_ASCIIONLY(str).should == false end end @@ -421,7 +421,7 @@ describe "when the rb_encoding struct is stored in native memory" do it "can still read the name of the encoding" do address = @s.rb_to_encoding_native_store(Encoding::UTF_8) - address.should be_kind_of(Integer) + address.should.is_a?(Integer) @s.rb_to_encoding_native_name(address).should == "UTF-8" end end @@ -476,7 +476,7 @@ it "raises Encoding::CompatibilityError if the encodings are not compatible" do a = [0xff].pack('C').b b = "あ" - -> { @s.rb_enc_check(a, b) }.should raise_error(Encoding::CompatibilityError) + -> { @s.rb_enc_check(a, b) }.should.raise(Encoding::CompatibilityError) end end @@ -490,12 +490,12 @@ end it "raises a RuntimeError if the first argument is a Symbol" do - -> { @s.rb_enc_copy(:symbol, @obj) }.should raise_error(RuntimeError) + -> { @s.rb_enc_copy(:symbol, @obj) }.should.raise(RuntimeError) end ruby_version_is "4.1" do it "raises a FrozenError if the first argument is a Regexp" do - -> { @s.rb_enc_copy(/regexp/.dup, @obj) }.should raise_error(FrozenError) + -> { @s.rb_enc_copy(/regexp/.dup, @obj) }.should.raise(FrozenError) end end @@ -517,7 +517,7 @@ it "returns 0 if Encoding.default_internal is nil" do Encoding.default_internal = nil - @s.rb_default_internal_encoding.should be_nil + @s.rb_default_internal_encoding.should == nil end it "returns the encoding for Encoding.default_internal" do @@ -549,12 +549,12 @@ end it "raises a RuntimeError if the argument is Symbol" do - -> { @s.rb_enc_associate(:symbol, "US-ASCII") }.should raise_error(RuntimeError) + -> { @s.rb_enc_associate(:symbol, "US-ASCII") }.should.raise(RuntimeError) end ruby_version_is "4.1" do it "raises a FrozenError if the argument is a Regexp" do - -> { @s.rb_enc_associate(/regexp/.dup, "BINARY") }.should raise_error(FrozenError) + -> { @s.rb_enc_associate(/regexp/.dup, "BINARY") }.should.raise(FrozenError) end end @@ -579,7 +579,7 @@ ruby_version_is "4.1" do it "raises a FrozenError if the argument is a Regexp" do index = @s.rb_enc_find_index("UTF-8") - -> { @s.rb_enc_associate_index(/regexp/.dup, index) }.should raise_error(FrozenError) + -> { @s.rb_enc_associate_index(/regexp/.dup, index) }.should.raise(FrozenError) end end @@ -593,7 +593,7 @@ it "sets the encoding of a Symbol to the encoding" do index = @s.rb_enc_find_index("UTF-8") - -> { @s.rb_enc_associate_index(:symbol, index) }.should raise_error(RuntimeError) + -> { @s.rb_enc_associate_index(:symbol, index) }.should.raise(RuntimeError) end end @@ -649,13 +649,13 @@ it "raises ArgumentError if an empty string is given" do -> do @s.rb_enc_codepoint_len("") - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "raises ArgumentError if an invalid byte sequence is given" do -> do @s.rb_enc_codepoint_len([0xa0, 0xa1].pack('CC').force_encoding('utf-8')) # Invalid sequence identifier - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "returns codepoint 0x24 and length 1 for character '$'" do @@ -689,11 +689,11 @@ describe "rb_enc_str_asciionly_p" do it "returns true for an ASCII string" do - @s.rb_enc_str_asciionly_p("hello").should be_true + @s.rb_enc_str_asciionly_p("hello").should == true end it "returns false for a non-ASCII string" do - @s.rb_enc_str_asciionly_p("hüllo").should be_false + @s.rb_enc_str_asciionly_p("hüllo").should == false end end @@ -703,7 +703,7 @@ -> { @s.rb_enc_raise(Encoding::UTF_8, RuntimeError, utf_8_incompatible_string) - }.should raise_error { |e| + }.should.raise { |e| e.message.encoding.should == Encoding::UTF_8 e.message.valid_encoding?.should == false e.message.bytes.should == utf_8_incompatible_string.bytes diff --git a/spec/ruby/optional/capi/exception_spec.rb b/spec/ruby/optional/capi/exception_spec.rb index 5bc8e26c6241e8..429da093d1adc7 100644 --- a/spec/ruby/optional/capi/exception_spec.rb +++ b/spec/ruby/optional/capi/exception_spec.rb @@ -28,13 +28,13 @@ describe "rb_exc_raise" do it "raises passed exception" do runtime_error = RuntimeError.new '42' - -> { @s.rb_exc_raise(runtime_error) }.should raise_error(RuntimeError, '42') + -> { @s.rb_exc_raise(runtime_error) }.should.raise(RuntimeError, '42') end it "raises an exception with an empty backtrace" do runtime_error = RuntimeError.new '42' runtime_error.set_backtrace [] - -> { @s.rb_exc_raise(runtime_error) }.should raise_error(RuntimeError, '42') + -> { @s.rb_exc_raise(runtime_error) }.should.raise(RuntimeError, '42') end it "sets $! to the raised exception when not rescuing from an another exception" do @@ -88,15 +88,15 @@ end it "accepts nil" do - @s.rb_set_errinfo(nil).should be_nil + @s.rb_set_errinfo(nil).should == nil end it "accepts an Exception instance" do - @s.rb_set_errinfo(Exception.new).should be_nil + @s.rb_set_errinfo(Exception.new).should == nil end it "raises a TypeError if the object is not nil or an Exception instance" do - -> { @s.rb_set_errinfo("error") }.should raise_error(TypeError) + -> { @s.rb_set_errinfo("error") }.should.raise(TypeError) end end @@ -104,8 +104,8 @@ it "raises a FrozenError regardless of the object's frozen state" do # The type of the argument we supply doesn't matter. The choice here is arbitrary and we only change the type # of the argument to ensure the exception messages are set correctly. - -> { @s.rb_error_frozen_object(Array.new) }.should raise_error(FrozenError, "can't modify frozen Array: []") - -> { @s.rb_error_frozen_object(Array.new.freeze) }.should raise_error(FrozenError, "can't modify frozen Array: []") + -> { @s.rb_error_frozen_object(Array.new) }.should.raise(FrozenError, "can't modify frozen Array: []") + -> { @s.rb_error_frozen_object(Array.new.freeze) }.should.raise(FrozenError, "can't modify frozen Array: []") end it "properly handles recursive rb_error_frozen_object calls" do @@ -116,7 +116,7 @@ s.rb_error_frozen_object(object) end - -> { @s.rb_error_frozen_object(object) }.should raise_error(FrozenError, "can't modify frozen #{klass}: ...") + -> { @s.rb_error_frozen_object(object) }.should.raise(FrozenError, "can't modify frozen #{klass}: ...") end end @@ -124,14 +124,14 @@ it "returns system error with default message when passed message is NULL" do exception = @s.rb_syserr_new(Errno::ENOENT::Errno, nil) exception.class.should == Errno::ENOENT - exception.message.should include("No such file or directory") + exception.message.should.include?("No such file or directory") exception.should.is_a?(SystemCallError) end it "returns system error with custom message" do exception = @s.rb_syserr_new(Errno::ENOENT::Errno, "custom message") - exception.message.should include("custom message") + exception.message.should.include?("custom message") exception.class.should == Errno::ENOENT exception.should.is_a?(SystemCallError) end @@ -141,14 +141,14 @@ it "returns system error with default message when passed message is nil" do exception = @s.rb_syserr_new_str(Errno::ENOENT::Errno, nil) - exception.message.should include("No such file or directory") + exception.message.should.include?("No such file or directory") exception.class.should == Errno::ENOENT exception.should.is_a?(SystemCallError) end it "returns system error with custom message" do exception = @s.rb_syserr_new_str(Errno::ENOENT::Errno, "custom message") - exception.message.should include("custom message") + exception.message.should.include?("custom message") exception.class.should == Errno::ENOENT exception.should.is_a?(SystemCallError) end @@ -181,17 +181,17 @@ end it "raises a TypeError for incorrect types" do - -> { @s.rb_make_exception([nil]) }.should raise_error(TypeError) - -> { @s.rb_make_exception([Object.new]) }.should raise_error(TypeError) + -> { @s.rb_make_exception([nil]) }.should.raise(TypeError) + -> { @s.rb_make_exception([Object.new]) }.should.raise(TypeError) obj = Object.new def obj.exception "not exception type" end - -> { @s.rb_make_exception([obj]) }.should raise_error(TypeError) + -> { @s.rb_make_exception([obj]) }.should.raise(TypeError) end it "raises an ArgumentError for too many arguments" do - -> { @s.rb_make_exception([Exception, "Message", ["backtrace 1"], "extra"]) }.should raise_error(ArgumentError) + -> { @s.rb_make_exception([Exception, "Message", ["backtrace 1"], "extra"]) }.should.raise(ArgumentError) end it "returns nil for empty arguments" do diff --git a/spec/ruby/optional/capi/fiber_spec.rb b/spec/ruby/optional/capi/fiber_spec.rb index 05d867498ce3a3..c820ba17c2f6ae 100644 --- a/spec/ruby/optional/capi/fiber_spec.rb +++ b/spec/ruby/optional/capi/fiber_spec.rb @@ -10,7 +10,7 @@ describe "rb_fiber_current" do it "returns the current fiber" do result = @s.rb_fiber_current() - result.should be_an_instance_of(Fiber) + result.should.instance_of?(Fiber) result.should == Fiber.current end end @@ -19,9 +19,9 @@ it "returns the fibers alive status" do fiber = Fiber.new { Fiber.yield } fiber.resume - @s.rb_fiber_alive_p(fiber).should be_true + @s.rb_fiber_alive_p(fiber).should == true fiber.resume - @s.rb_fiber_alive_p(fiber).should be_false + @s.rb_fiber_alive_p(fiber).should == false end end @@ -43,7 +43,7 @@ describe "rb_fiber_new" do it "returns a new fiber" do fiber = @s.rb_fiber_new - fiber.should be_an_instance_of(Fiber) + fiber.should.instance_of?(Fiber) fiber.resume(42).should == "42" end end @@ -61,7 +61,7 @@ fiber.resume result = @s.rb_fiber_raise(fiber, "Boom!") - result.should be_an_instance_of(RuntimeError) + result.should.instance_of?(RuntimeError) result.message.should == "Boom!" end @@ -79,7 +79,7 @@ fiber.transfer result = @s.rb_fiber_raise(fiber, "Boom!") - result.should be_an_instance_of(RuntimeError) + result.should.instance_of?(RuntimeError) result.message.should == "Boom!" end end diff --git a/spec/ruby/optional/capi/file_spec.rb b/spec/ruby/optional/capi/file_spec.rb index 12449b4e34d7d9..fd63aed3160eeb 100644 --- a/spec/ruby/optional/capi/file_spec.rb +++ b/spec/ruby/optional/capi/file_spec.rb @@ -5,13 +5,13 @@ describe :rb_file_open, shared: true do it "raises an ArgumentError if passed an empty mode string" do touch @name - -> { @s.rb_file_open(@name, "") }.should raise_error(ArgumentError) + -> { @s.rb_file_open(@name, "") }.should.raise(ArgumentError) end it "opens a file in read-only mode with 'r'" do touch(@name) { |f| f.puts "readable" } @file = @s.send(@method, @name, "r") - @file.should be_an_instance_of(File) + @file.should.instance_of?(File) @file.read.chomp.should == "readable" end @@ -65,13 +65,13 @@ describe "FilePathValue" do it "returns a String argument unchanged" do obj = "path" - @s.FilePathValue(obj).should eql(obj) + @s.FilePathValue(obj).should.eql?(obj) end it "does not call #to_str on a String" do obj = +"path" obj.should_not_receive(:to_str) - @s.FilePathValue(obj).should eql(obj) + @s.FilePathValue(obj).should.eql?(obj) end it "calls #to_path to convert an object to a String" do diff --git a/spec/ruby/optional/capi/fixnum_spec.rb b/spec/ruby/optional/capi/fixnum_spec.rb index e691aa389365ad..73751c48951754 100644 --- a/spec/ruby/optional/capi/fixnum_spec.rb +++ b/spec/ruby/optional/capi/fixnum_spec.rb @@ -27,7 +27,7 @@ platform_is c_long_size: 64 do # sizeof(long) > sizeof(int) it "raises a TypeError if passed nil" do - -> { @s.FIX2INT(nil) }.should raise_error(TypeError) + -> { @s.FIX2INT(nil) }.should.raise(TypeError) end it "converts a Float" do @@ -39,16 +39,16 @@ end it "raises a RangeError if the value does not fit a native int" do - -> { @s.FIX2INT(0x7fff_ffff+1) }.should raise_error(RangeError) - -> { @s.FIX2INT(-(1 << 31) - 1) }.should raise_error(RangeError) + -> { @s.FIX2INT(0x7fff_ffff+1) }.should.raise(RangeError) + -> { @s.FIX2INT(-(1 << 31) - 1) }.should.raise(RangeError) end it "raises a RangeError if the value is more than 32bits" do - -> { @s.FIX2INT(0xffff_ffff+1) }.should raise_error(RangeError) + -> { @s.FIX2INT(0xffff_ffff+1) }.should.raise(RangeError) end it "raises a RangeError if the value is more than 64bits" do - -> { @s.FIX2INT(0xffff_ffff_ffff_ffff+1) }.should raise_error(RangeError) + -> { @s.FIX2INT(0xffff_ffff_ffff_ffff+1) }.should.raise(RangeError) end it "calls #to_int to coerce the value" do @@ -76,7 +76,7 @@ platform_is c_long_size: 64 do # sizeof(long) > sizeof(int) it "raises a TypeError if passed nil" do - -> { @s.FIX2UINT(nil) }.should raise_error(TypeError) + -> { @s.FIX2UINT(nil) }.should.raise(TypeError) end it "converts a Float" do @@ -85,16 +85,16 @@ it "raises a RangeError if the value does not fit a native uint" do # Interestingly, on MRI FIX2UINT(-1) is allowed - -> { @s.FIX2UINT(0xffff_ffff+1) }.should raise_error(RangeError) - -> { @s.FIX2UINT(-(1 << 31) - 1) }.should raise_error(RangeError) + -> { @s.FIX2UINT(0xffff_ffff+1) }.should.raise(RangeError) + -> { @s.FIX2UINT(-(1 << 31) - 1) }.should.raise(RangeError) end it "raises a RangeError if the value is more than 32bits" do - -> { @s.FIX2UINT(0xffff_ffff+1) }.should raise_error(RangeError) + -> { @s.FIX2UINT(0xffff_ffff+1) }.should.raise(RangeError) end it "raises a RangeError if the value is more than 64bits" do - -> { @s.FIX2UINT(0xffff_ffff_ffff_ffff+1) }.should raise_error(RangeError) + -> { @s.FIX2UINT(0xffff_ffff_ffff_ffff+1) }.should.raise(RangeError) end end end diff --git a/spec/ruby/optional/capi/float_spec.rb b/spec/ruby/optional/capi/float_spec.rb index 4b98902b59edae..5b02483b287e05 100644 --- a/spec/ruby/optional/capi/float_spec.rb +++ b/spec/ruby/optional/capi/float_spec.rb @@ -23,8 +23,8 @@ describe "rb_Float" do it "creates a new Float from a String" do f = @f.rb_Float("101.99") - f.should be_kind_of(Float) - f.should eql(101.99) + f.should.is_a?(Float) + f.should.eql?(101.99) end end diff --git a/spec/ruby/optional/capi/gc_spec.rb b/spec/ruby/optional/capi/gc_spec.rb index d9661328ab39a0..6695026c6f9d88 100644 --- a/spec/ruby/optional/capi/gc_spec.rb +++ b/spec/ruby/optional/capi/gc_spec.rb @@ -10,9 +10,9 @@ describe "rb_gc_register_address" do it "correctly gets the value from a registered address" do @f.registered_tagged_address.should == 10 - @f.registered_tagged_address.should equal(@f.registered_tagged_address) + @f.registered_tagged_address.should.equal?(@f.registered_tagged_address) @f.registered_reference_address.should == "Globally registered data" - @f.registered_reference_address.should equal(@f.registered_reference_address) + @f.registered_reference_address.should.equal?(@f.registered_reference_address) end it "keeps the value alive even if the value is assigned after rb_gc_register_address() is called" do @@ -67,22 +67,22 @@ it "enables GC when disabled" do GC.disable - @f.rb_gc_enable.should be_true + @f.rb_gc_enable.should == true end it "GC stays enabled when enabled" do GC.enable - @f.rb_gc_enable.should be_false + @f.rb_gc_enable.should == false end it "disables GC when enabled" do GC.enable - @f.rb_gc_disable.should be_false + @f.rb_gc_disable.should == false end it "GC stays disabled when disabled" do GC.disable - @f.rb_gc_disable.should be_true + @f.rb_gc_disable.should == true end end @@ -100,13 +100,13 @@ -> { @f.rb_gc_adjust_memory_usage(8) @f.rb_gc_adjust_memory_usage(-8) - }.should_not raise_error + }.should_not.raise end end describe "rb_gc_register_mark_object" do it "can be called with an object" do - @f.rb_gc_register_mark_object(Object.new).should be_nil + @f.rb_gc_register_mark_object(Object.new).should == nil end it "keeps the value alive even if the value is not referenced by any Ruby object" do @@ -116,11 +116,11 @@ describe "rb_gc_latest_gc_info" do it "raises a TypeError when hash or symbol not given" do - -> { @f.rb_gc_latest_gc_info("foo") }.should raise_error(TypeError) + -> { @f.rb_gc_latest_gc_info("foo") }.should.raise(TypeError) end it "raises an ArgumentError when unknown symbol given" do - -> { @f.rb_gc_latest_gc_info(:unknown) }.should raise_error(ArgumentError) + -> { @f.rb_gc_latest_gc_info(:unknown) }.should.raise(ArgumentError) end it "returns the populated hash when a hash is given" do @@ -130,7 +130,7 @@ end it "returns a value when symbol is given" do - @f.rb_gc_latest_gc_info(:state).should be_kind_of(Symbol) + @f.rb_gc_latest_gc_info(:state).should.is_a?(Symbol) end end end diff --git a/spec/ruby/optional/capi/globals_spec.rb b/spec/ruby/optional/capi/globals_spec.rb index 4657293e15824d..03316c256c98ac 100644 --- a/spec/ruby/optional/capi/globals_spec.rb +++ b/spec/ruby/optional/capi/globals_spec.rb @@ -52,7 +52,7 @@ @f.rb_define_readonly_variable("#{name}", 15) $#{name}.should == 15 - -> { $#{name} = 10 }.should raise_error(NameError) + -> { $#{name} = 10 }.should.raise(NameError) RUBY end @@ -80,7 +80,7 @@ end it "is read-only" do - -> { $virtual_variable_default_accessors = 10 }.should raise_error(NameError, /read-only/) + -> { $virtual_variable_default_accessors = 10 }.should.raise(NameError, /read-only/) end it "returns false with the default getter" do @@ -164,7 +164,7 @@ it "returns $stdin" do $stdin = @stream - @f.rb_stdin.should equal($stdin) + @f.rb_stdin.should.equal?($stdin) end end @@ -175,7 +175,7 @@ it "returns $stdout" do $stdout = @stream - @f.rb_stdout.should equal($stdout) + @f.rb_stdout.should.equal?($stdout) end end @@ -186,7 +186,7 @@ it "returns $stderr" do $stderr = @stream - @f.rb_stderr.should equal($stderr) + @f.rb_stderr.should.equal?($stderr) end end @@ -197,7 +197,7 @@ it "is an alias of rb_stdout" do $stdout = @stream - @f.rb_defout.should equal($stdout) + @f.rb_defout.should.equal?($stdout) end end end @@ -218,7 +218,7 @@ end it "returns nil by default" do - @f.rb_output_rs.should be_nil + @f.rb_output_rs.should == nil end it "returns the value of $\\" do @@ -237,7 +237,7 @@ end it "returns nil by default" do - @f.rb_output_fs.should be_nil + @f.rb_output_fs.should == nil end it "returns the value of $\\" do @@ -263,7 +263,7 @@ end Thread.pass while thr.status and !running - $_.should be_nil + $_.should == nil thr.join end @@ -290,7 +290,7 @@ end Thread.pass while thr.status and !running - $_.should be_nil + $_.should == nil thr.join end diff --git a/spec/ruby/optional/capi/hash_spec.rb b/spec/ruby/optional/capi/hash_spec.rb index 3a27de3bfa2984..842bc82b970901 100644 --- a/spec/ruby/optional/capi/hash_spec.rb +++ b/spec/ruby/optional/capi/hash_spec.rb @@ -36,7 +36,7 @@ obj = mock("rb_hash no to_int") obj.should_receive(:hash).and_return(nil) - -> { @s.rb_hash(obj) }.should raise_error(TypeError) + -> { @s.rb_hash(obj) }.should.raise(TypeError) end end @@ -46,7 +46,7 @@ end it "creates a hash with no default proc" do - @s.rb_hash_new {}.default_proc.should be_nil + @s.rb_hash_new {}.default_proc.should == nil end end @@ -56,11 +56,11 @@ end it "creates a hash with no default proc" do - @s.rb_hash_new_capa(3) {}.default_proc.should be_nil + @s.rb_hash_new_capa(3) {}.default_proc.should == nil end it "raises RuntimeError when negative index is provided" do - -> { @s.rb_hash_new_capa(-1) }.should raise_error(RuntimeError, "st_table too big") + -> { @s.rb_hash_new_capa(-1) }.should.raise(RuntimeError, "st_table too big") end end @@ -77,13 +77,13 @@ hsh = {} dup = @s.rb_hash_dup(hsh) dup.should == hsh - dup.should_not equal(hsh) + dup.should_not.equal?(hsh) end end describe "rb_hash_freeze" do it "freezes the hash" do - @s.rb_hash_freeze({}).frozen?.should be_true + @s.rb_hash_freeze({}).frozen?.should == true end end @@ -96,13 +96,13 @@ it "returns the default value if it exists" do hsh = Hash.new(0) @s.rb_hash_aref(hsh, :chunky).should == 0 - @s.rb_hash_aref_nil(hsh, :chunky).should be_false + @s.rb_hash_aref_nil(hsh, :chunky).should == false end it "returns nil if the key does not exist" do hsh = { } - @s.rb_hash_aref(hsh, :chunky).should be_nil - @s.rb_hash_aref_nil(hsh, :chunky).should be_true + @s.rb_hash_aref(hsh, :chunky).should == nil + @s.rb_hash_aref_nil(hsh, :chunky).should == true end end @@ -117,7 +117,7 @@ describe "rb_hash_clear" do it "returns self that cleared keys and values" do hsh = { :key => 'value' } - @s.rb_hash_clear(hsh).should equal(hsh) + @s.rb_hash_clear(hsh).should.equal?(hsh) hsh.should == {} end end @@ -138,7 +138,7 @@ end it "returns an Enumerator when no block is passed" do - @s.rb_hash_delete_if({a: 1}).should be_an_instance_of(Enumerator) + @s.rb_hash_delete_if({a: 1}).should.instance_of?(Enumerator) end end @@ -153,11 +153,11 @@ it "raises a KeyError if the key is not found and default is set" do @hsh.default = :d - -> { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError) + -> { @s.rb_hash_fetch(@hsh, :c) }.should.raise(KeyError) end it "raises a KeyError if the key is not found and no default is set" do - -> { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError) + -> { @s.rb_hash_fetch(@hsh, :c) }.should.raise(KeyError) end context "when key is not found" do @@ -266,14 +266,14 @@ it "does not return the default value if it exists" do hsh = Hash.new(0) - @s.rb_hash_lookup(hsh, :chunky).should be_nil - @s.rb_hash_lookup_nil(hsh, :chunky).should be_true + @s.rb_hash_lookup(hsh, :chunky).should == nil + @s.rb_hash_lookup_nil(hsh, :chunky).should == true end it "returns nil if the key does not exist" do hsh = { } - @s.rb_hash_lookup(hsh, :chunky).should be_nil - @s.rb_hash_lookup_nil(hsh, :chunky).should be_true + @s.rb_hash_lookup(hsh, :chunky).should == nil + @s.rb_hash_lookup_nil(hsh, :chunky).should == true end describe "rb_hash_lookup2" do @@ -291,7 +291,7 @@ it "returns undefined if that is the default value specified" do hsh = Hash.new(0) - @s.rb_hash_lookup2_default_undef(hsh, :chunky).should be_true + @s.rb_hash_lookup2_default_undef(hsh, :chunky).should == true end end end @@ -322,20 +322,20 @@ def h.to_hash; {"bar" => "foo"}; end end it "raises a TypeError if the argument does not respond to #to_hash" do - -> { @s.rb_Hash(42) }.should raise_error(TypeError) + -> { @s.rb_Hash(42) }.should.raise(TypeError) end it "raises a TypeError if #to_hash does not return a hash" do h = BasicObject.new def h.to_hash; 42; end - -> { @s.rb_Hash(h) }.should raise_error(TypeError) + -> { @s.rb_Hash(h) }.should.raise(TypeError) end end describe "hash code functions" do it "computes a deterministic number" do hash_code = @s.compute_a_hash_code(53) - hash_code.should be_an_instance_of(Integer) + hash_code.should.instance_of?(Integer) hash_code.should == @s.compute_a_hash_code(53) @s.compute_a_hash_code(90).should == @s.compute_a_hash_code(90) end diff --git a/spec/ruby/optional/capi/io_spec.rb b/spec/ruby/optional/capi/io_spec.rb index 94874c7ae2bd27..35bd856e001471 100644 --- a/spec/ruby/optional/capi/io_spec.rb +++ b/spec/ruby/optional/capi/io_spec.rb @@ -34,7 +34,7 @@ end it "returns the io" do - @o.rb_io_addstr(@io, "rb_io_addstr data").should eql(@io) + @o.rb_io_addstr(@io, "rb_io_addstr data").should.eql?(@io) end end @@ -124,9 +124,9 @@ describe "rb_io_close" do it "closes an IO object" do - @io.closed?.should be_false + @io.closed?.should == false @o.rb_io_close(@io) - @io.closed?.should be_true + @io.closed?.should == true end end @@ -136,19 +136,19 @@ end it "returns nil for non IO objects" do - @o.rb_io_check_io({}).should be_nil + @o.rb_io_check_io({}).should == nil end end describe "rb_io_check_closed" do it "does not raise an exception if the IO is not closed" do # The MRI function is void, so we use should_not raise_error - -> { @o.rb_io_check_closed(@io) }.should_not raise_error + -> { @o.rb_io_check_closed(@io) }.should_not.raise end it "raises an error if the IO is closed" do @io.close - -> { @o.rb_io_check_closed(@io) }.should raise_error(IOError) + -> { @o.rb_io_check_closed(@io) }.should.raise(IOError) end end @@ -157,7 +157,7 @@ it "returns true when nonblock flag is set" do require 'io/nonblock' @o.rb_io_set_nonblock(@io) - @io.nonblock?.should be_true + @io.nonblock?.should == true end end end @@ -166,13 +166,13 @@ # object is frozen, *not* if it's tainted. describe "rb_io_taint_check" do it "does not raise an exception if the IO is not frozen" do - -> { @o.rb_io_taint_check(@io) }.should_not raise_error + -> { @o.rb_io_taint_check(@io) }.should_not.raise end it "raises an exception if the IO is frozen" do @io.freeze - -> { @o.rb_io_taint_check(@io) }.should raise_error(RuntimeError) + -> { @o.rb_io_taint_check(@io) }.should.raise(RuntimeError) end end @@ -186,7 +186,7 @@ it "raises IOError if the IO is closed" do @io.close - -> { @o.GetOpenFile_fd(@io) }.should raise_error(IOError, "closed stream") + -> { @o.GetOpenFile_fd(@io) }.should.raise(IOError, "closed stream") end end @@ -197,7 +197,7 @@ it "sets binmode" do @o.rb_io_binmode(@io) - @io.binmode?.should be_true + @io.binmode?.should == true end end end @@ -222,15 +222,15 @@ describe "rb_io_check_readable" do it "does not raise an exception if the IO is opened for reading" do # The MRI function is void, so we use should_not raise_error - -> { @o.rb_io_check_readable(@r_io) }.should_not raise_error + -> { @o.rb_io_check_readable(@r_io) }.should_not.raise end it "does not raise an exception if the IO is opened for read and write" do - -> { @o.rb_io_check_readable(@rw_io) }.should_not raise_error + -> { @o.rb_io_check_readable(@rw_io) }.should_not.raise end it "raises an IOError if the IO is not opened for reading" do - -> { @o.rb_io_check_readable(@w_io) }.should raise_error(IOError) + -> { @o.rb_io_check_readable(@w_io) }.should.raise(IOError) end end @@ -238,27 +238,27 @@ describe "rb_io_check_writable" do it "does not raise an exception if the IO is opened for writing" do # The MRI function is void, so we use should_not raise_error - -> { @o.rb_io_check_writable(@w_io) }.should_not raise_error + -> { @o.rb_io_check_writable(@w_io) }.should_not.raise end it "does not raise an exception if the IO is opened for read and write" do - -> { @o.rb_io_check_writable(@rw_io) }.should_not raise_error + -> { @o.rb_io_check_writable(@rw_io) }.should_not.raise end it "raises an IOError if the IO is not opened for reading" do - -> { @o.rb_io_check_writable(@r_io) }.should raise_error(IOError) + -> { @o.rb_io_check_writable(@r_io) }.should.raise(IOError) end end describe "rb_io_wait_writable" do it "returns false if there is no error condition" do @o.errno = 0 - @o.rb_io_wait_writable(@w_io).should be_false + @o.rb_io_wait_writable(@w_io).should == false end it "raises an IOError if the IO is closed" do @w_io.close - -> { @o.rb_io_wait_writable(@w_io) }.should raise_error(IOError) + -> { @o.rb_io_wait_writable(@w_io) }.should.raise(IOError) end end @@ -273,11 +273,11 @@ it "raises an IOError if the IO is closed" do @w_io.close - -> { @o.rb_io_maybe_wait_writable(0, @w_io, nil) }.should raise_error(IOError, "closed stream") + -> { @o.rb_io_maybe_wait_writable(0, @w_io, nil) }.should.raise(IOError, "closed stream") end it "raises an IOError if the IO is not initialized" do - -> { @o.rb_io_maybe_wait_writable(0, IO.allocate, nil) }.should raise_error(IOError, "uninitialized stream") + -> { @o.rb_io_maybe_wait_writable(0, IO.allocate, nil) }.should.raise(IOError, "uninitialized stream") end it "can be interrupted" do @@ -299,7 +299,7 @@ describe "rb_thread_fd_writable" do it "waits til an fd is ready for writing" do - @o.rb_thread_fd_writable(@w_io).should be_nil + @o.rb_thread_fd_writable(@w_io).should == nil end end @@ -322,14 +322,14 @@ describe "rb_io_wait_readable" do it "returns false if there is no error condition" do @o.errno = 0 - @o.rb_io_wait_readable(@r_io, false).should be_false + @o.rb_io_wait_readable(@r_io, false).should == false end it "raises and IOError if passed a closed stream" do @r_io.close -> { @o.rb_io_wait_readable(@r_io, false) - }.should raise_error(IOError) + }.should.raise(IOError) end it "blocks until the io is readable and returns true" do @@ -340,7 +340,7 @@ end @o.errno = Errno::EAGAIN.new.errno - @o.rb_io_wait_readable(@r_io, true).should be_true + @o.rb_io_wait_readable(@r_io, true).should == true @o.instance_variable_get(:@read_data).should == "rb_io_wait_re" thr.join @@ -386,11 +386,11 @@ it "raises an IOError if the IO is closed" do @r_io.close - -> { @o.rb_io_maybe_wait_readable(0, @r_io, nil, false) }.should raise_error(IOError, "closed stream") + -> { @o.rb_io_maybe_wait_readable(0, @r_io, nil, false) }.should.raise(IOError, "closed stream") end it "raises an IOError if the IO is not initialized" do - -> { @o.rb_io_maybe_wait_readable(0, IO.allocate, nil, false) }.should raise_error(IOError, "uninitialized stream") + -> { @o.rb_io_maybe_wait_readable(0, IO.allocate, nil, false) }.should.raise(IOError, "uninitialized stream") end end end @@ -406,7 +406,7 @@ Thread.pass until start - @o.rb_thread_wait_fd(@r_io).should be_nil + @o.rb_thread_wait_fd(@r_io).should == nil thr.join end @@ -455,11 +455,11 @@ it "raises an IOError if the IO is closed" do @w_io.close - -> { @o.rb_io_maybe_wait(0, @w_io, IO::WRITABLE, nil) }.should raise_error(IOError, "closed stream") + -> { @o.rb_io_maybe_wait(0, @w_io, IO::WRITABLE, nil) }.should.raise(IOError, "closed stream") end it "raises an IOError if the IO is not initialized" do - -> { @o.rb_io_maybe_wait(0, IO.allocate, IO::WRITABLE, nil) }.should raise_error(IOError, "uninitialized stream") + -> { @o.rb_io_maybe_wait(0, IO.allocate, IO::WRITABLE, nil) }.should.raise(IOError, "uninitialized stream") end it "can be interrupted when waiting for READABLE event" do @@ -622,11 +622,11 @@ io.should.is_a?(File) platform_is_not :windows do - -> { io.read_nonblock(1) }.should raise_error(Errno::EBADF) + -> { io.read_nonblock(1) }.should.raise(Errno::EBADF) end platform_is :windows do - -> { io.read_nonblock(1) }.should raise_error(IO::EWOULDBLOCKWaitReadable) + -> { io.read_nonblock(1) }.should.raise(IO::EWOULDBLOCKWaitReadable) end end @@ -638,11 +638,11 @@ it "deduplicates path String" do path = "a.txt".dup io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, path, 60, "US-ASCII", "UTF-8", 0, {}) - io.path.should_not equal(path) + io.path.should_not.equal?(path) path = "a.txt".freeze io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, path, 60, "US-ASCII", "UTF-8", 0, {}) - io.path.should_not equal(path) + io.path.should_not.equal?(path) end it "calls #to_str to convert a path to a String" do @@ -684,7 +684,7 @@ def path.to_str; "a.txt"; end it "sets close_on_exec on the IO" do @o.rb_fd_fix_cloexec(@io) - @io.close_on_exec?.should be_true + @io.close_on_exec?.should == true end end @@ -705,7 +705,7 @@ def path.to_str; "a.txt"; end it "sets close_on_exec on the newly-opened IO" do @io = @o.rb_cloexec_open(@name, 0, 0) - @io.close_on_exec?.should be_true + @io.close_on_exec?.should == true end end @@ -750,14 +750,14 @@ def path.to_str; "a.txt"; end it "duplicates a file descriptor and sets close_on_exec" do @dup = @o.rb_cloexec_fcntl_dupfd(@io, 3) - @dup.close_on_exec?.should be_true + @dup.close_on_exec?.should == true @dup.fileno.should_not == @io.fileno end it "returns a file descriptor greater than or equal to minfd" do @dup = @o.rb_cloexec_fcntl_dupfd(@io, 100) @dup.fileno.should >= 100 - @dup.close_on_exec?.should be_true + @dup.close_on_exec?.should == true end end diff --git a/spec/ruby/optional/capi/kernel_spec.rb b/spec/ruby/optional/capi/kernel_spec.rb index 0a2362fb304ab8..62eb21448b24ca 100644 --- a/spec/ruby/optional/capi/kernel_spec.rb +++ b/spec/ruby/optional/capi/kernel_spec.rb @@ -28,7 +28,7 @@ class CApiKernelSpecs::Exc < StandardError describe "rb_need_block" do it "raises a LocalJumpError if no block is given" do - -> { @s.rb_need_block }.should raise_error(LocalJumpError) + -> { @s.rb_need_block }.should.raise(LocalJumpError) end it "does not raise a LocalJumpError if a block is given" do @@ -53,7 +53,7 @@ class CApiKernelSpecs::Exc < StandardError it "calls the method with no function callback and no block" do ary = [1, 3, 5] - @s.rb_block_call_no_func(ary).should be_kind_of(Enumerator) + @s.rb_block_call_no_func(ary).should.is_a?(Enumerator) end it "calls the method with no function callback and a block" do @@ -65,7 +65,7 @@ class CApiKernelSpecs::Exc < StandardError it "can pass extra data to the function" do ary = [3] - @s.rb_block_call_extra_data(ary).should equal(ary) + @s.rb_block_call_extra_data(ary).should.equal?(ary) end end @@ -78,12 +78,12 @@ class CApiKernelSpecs::Exc < StandardError describe "rb_raise" do it "raises an exception" do - -> { @s.rb_raise({}) }.should raise_error(TypeError) + -> { @s.rb_raise({}) }.should.raise(TypeError) end it "terminates the function at the point it was called" do h = {} - -> { @s.rb_raise(h) }.should raise_error(TypeError) + -> { @s.rb_raise(h) }.should.raise(TypeError) h[:stage].should == :before end @@ -100,7 +100,7 @@ class CApiKernelSpecs::Exc < StandardError # should raise StandardError "aaa" raise end - end.should raise_error(StandardError, "aaa") + end.should.raise(StandardError, "aaa") end end @@ -125,7 +125,7 @@ class CApiKernelSpecs::Exc < StandardError end it "raises an ArgumentError if there is no catch block for the symbol" do - -> { @s.rb_throw(nil) }.should raise_error(ArgumentError) + -> { @s.rb_throw(nil) }.should.raise(ArgumentError) end end @@ -151,7 +151,7 @@ class CApiKernelSpecs::Exc < StandardError end it "raises an ArgumentError if there is no catch block for the symbol" do - -> { @s.rb_throw(nil) }.should raise_error(ArgumentError) + -> { @s.rb_throw(nil) }.should.raise(ArgumentError) end end @@ -173,13 +173,13 @@ class CApiKernelSpecs::Exc < StandardError it "raises an exception from the value of errno" do -> do @s.rb_sys_fail("additional info") - end.should raise_error(SystemCallError, /additional info/) + end.should.raise(SystemCallError, /additional info/) end it "can take a NULL message" do -> do @s.rb_sys_fail(nil) - end.should raise_error(Errno::EPERM) + end.should.raise(Errno::EPERM) end end @@ -187,17 +187,17 @@ class CApiKernelSpecs::Exc < StandardError it "raises an exception from the given error" do -> do @s.rb_syserr_fail(Errno::EINVAL::Errno, "additional info") - end.should raise_error(Errno::EINVAL, "Invalid argument - additional info") + end.should.raise(Errno::EINVAL, "Invalid argument - additional info") end it "can take a NULL message" do -> do @s.rb_syserr_fail(Errno::EINVAL::Errno, nil) - end.should raise_error(Errno::EINVAL, "Invalid argument") + end.should.raise(Errno::EINVAL, "Invalid argument") end it "uses some kind of string as message when errno is unknown" do - -> { @s.rb_syserr_fail(-10, nil) }.should raise_error(SystemCallError, /[[:graph:]]+/) + -> { @s.rb_syserr_fail(-10, nil) }.should.raise(SystemCallError, /[[:graph:]]+/) end end @@ -205,17 +205,17 @@ class CApiKernelSpecs::Exc < StandardError it "raises an exception from the given error" do -> do @s.rb_syserr_fail_str(Errno::EINVAL::Errno, "additional info") - end.should raise_error(Errno::EINVAL, "Invalid argument - additional info") + end.should.raise(Errno::EINVAL, "Invalid argument - additional info") end it "can take nil as a message" do -> do @s.rb_syserr_fail_str(Errno::EINVAL::Errno, nil) - end.should raise_error(Errno::EINVAL, "Invalid argument") + end.should.raise(Errno::EINVAL, "Invalid argument") end it "uses some kind of string as message when errno is unknown" do - -> { @s.rb_syserr_fail_str(-10, nil) }.should raise_error(SystemCallError, /[[:graph:]]+/) + -> { @s.rb_syserr_fail_str(-10, nil) }.should.raise(SystemCallError, /[[:graph:]]+/) end end @@ -231,7 +231,7 @@ class CApiKernelSpecs::Exc < StandardError end it "raises LocalJumpError when no block is given" do - -> { @s.rb_yield(1) }.should raise_error(LocalJumpError) + -> { @s.rb_yield(1) }.should.raise(LocalJumpError) end it "rb_yield to a block that breaks does not raise an error" do @@ -269,7 +269,7 @@ class CApiKernelSpecs::Exc < StandardError end it "raises LocalJumpError when no block is given" do - -> { @s.rb_yield_splat([1, 2]) }.should raise_error(LocalJumpError) + -> { @s.rb_yield_splat([1, 2]) }.should.raise(LocalJumpError) end end @@ -301,7 +301,7 @@ class CApiKernelSpecs::Exc < StandardError end it "raises LocalJumpError when no block is given" do - -> { @s.rb_yield_splat([1, 2]) }.should raise_error(LocalJumpError) + -> { @s.rb_yield_splat([1, 2]) }.should.raise(LocalJumpError) end end @@ -330,7 +330,7 @@ class CApiKernelSpecs::Exc < StandardError proof = [] # Hold proof of work performed after the yield. -> do @s.rb_protect_yield(77, proof) { |x| raise NameError } - end.should raise_error(NameError) + end.should.raise(NameError) proof[0].should == 23 end @@ -338,7 +338,7 @@ class CApiKernelSpecs::Exc < StandardError proof = [] # Hold proof of work performed after the yield. -> do @s.rb_protect_yield(77, proof) { |x| raise NameError } - end.should raise_error(NameError) + end.should.raise(NameError) proof[0].should == 23 proof[1].should == nil end @@ -375,7 +375,7 @@ class CApiKernelSpecs::Exc < StandardError proof = [] -> do @s.rb_eval_string_protect('raise RuntimeError', proof) - end.should raise_error(RuntimeError) + end.should.raise(RuntimeError) proof.should == [23, nil] end end @@ -416,11 +416,11 @@ class CApiKernelSpecs::Exc < StandardError end it "raises an exception if passed function raises an exception other than StandardError" do - -> { @s.rb_rescue(@exc_error_proc, nil, @rescue_proc_returns_arg, nil) }.should raise_error(Exception) + -> { @s.rb_rescue(@exc_error_proc, nil, @rescue_proc_returns_arg, nil) }.should.raise(Exception) end it "raises an exception if any exception is raised inside the 'rescue function'" do - -> { @s.rb_rescue(@std_error_proc, nil, @std_error_proc, nil) }.should raise_error(StandardError) + -> { @s.rb_rescue(@std_error_proc, nil, @std_error_proc, nil) }.should.raise(StandardError) end it "sets $! and rb_errinfo() during the 'rescue function' execution" do @@ -463,13 +463,13 @@ def proc_caller @s.rb_rescue2(run_error_proc, :no_exc, proc, :exc, ArgumentError, RuntimeError).should == :exc -> { @s.rb_rescue2(type_error_proc, :no_exc, proc, :exc, ArgumentError, RuntimeError) - }.should raise_error(Exception, 'custom error') + }.should.raise(Exception, 'custom error') end it "raises TypeError if one of the passed exceptions is not a Module" do -> { @s.rb_rescue2(-> *_ { raise RuntimeError, "foo" }, :no_exc, -> x { x }, :exc, Object.new, 42) - }.should raise_error(TypeError, /class or module required/) + }.should.raise(TypeError, /class or module required/) end it "sets $! and rb_errinfo() during the 'rescue function' execution" do @@ -505,12 +505,12 @@ def proc_caller throw :thrown_value ScratchPad << :after_throw end - @s.rb_catch("thrown_value", proc).should be_nil + @s.rb_catch("thrown_value", proc).should == nil ScratchPad.recorded.should == [:before_throw] end it "raises an ArgumentError if the throw symbol isn't caught" do - -> { @s.rb_catch("foo", -> { throw :bar }) }.should raise_error(ArgumentError) + -> { @s.rb_catch("foo", -> { throw :bar }) }.should.raise(ArgumentError) end end @@ -531,12 +531,12 @@ def proc_caller throw @tag ScratchPad << :after_throw end - @s.rb_catch_obj(@tag, proc).should be_nil + @s.rb_catch_obj(@tag, proc).should == nil ScratchPad.recorded.should == [:before_throw] end it "raises an ArgumentError if the throw symbol isn't caught" do - -> { @s.rb_catch("foo", -> { throw :bar }) }.should raise_error(ArgumentError) + -> { @s.rb_catch("foo", -> { throw :bar }) }.should.raise(ArgumentError) end end @@ -594,7 +594,7 @@ def proc_caller ensure_proc = -> x { foo = x } -> { @s.rb_ensure(raise_proc, nil, ensure_proc, :foo) - }.should raise_error(exception_class) + }.should.raise(exception_class) foo.should == :foo end @@ -604,14 +604,14 @@ def proc_caller $!.should.is_a?(exception_class) @s.rb_errinfo.should.is_a?(exception_class) }, nil) - }.should raise_error(exception_class) + }.should.raise(exception_class) -> { @s.rb_ensure(-> _ { @s.rb_raise({}) }, nil, -> _ { $!.should.is_a?(TypeError) @s.rb_errinfo.should.is_a?(TypeError) }, nil) - }.should raise_error(TypeError) + }.should.raise(TypeError) $!.should == nil @s.rb_errinfo.should == nil @@ -620,7 +620,7 @@ def proc_caller it "raises the same exception raised inside passed function" do raise_proc = -> *_ { raise RuntimeError, 'foo' } proc = -> *_ { } - -> { @s.rb_ensure(raise_proc, nil, proc, nil) }.should raise_error(RuntimeError, 'foo') + -> { @s.rb_ensure(raise_proc, nil, proc, nil) }.should.raise(RuntimeError, 'foo') end end @@ -659,7 +659,7 @@ def proc_caller describe "rb_block_proc" do it "converts the implicit block into a proc" do proc = @s.rb_block_proc { 1+1 } - proc.should be_kind_of(Proc) + proc.should.is_a?(Proc) proc.call.should == 2 proc.should_not.lambda? end @@ -667,7 +667,7 @@ def proc_caller it "passes through an existing lambda and does not convert to a proc" do b = -> { 1+1 } proc = @s.rb_block_proc(&b) - proc.should equal(b) + proc.should.equal?(b) proc.call.should == 2 proc.should.lambda? end @@ -676,7 +676,7 @@ def proc_caller describe "rb_block_lambda" do it "converts the implicit block into a lambda" do proc = @s.rb_block_lambda { 1+1 } - proc.should be_kind_of(Proc) + proc.should.is_a?(Proc) proc.call.should == 2 proc.should.lambda? end @@ -684,7 +684,7 @@ def proc_caller it "passes through an existing Proc and does not convert to a lambda" do b = proc { 1+1 } proc = @s.rb_block_lambda(&b) - proc.should equal(b) + proc.should.equal?(b) proc.call.should == 2 proc.should_not.lambda? end @@ -719,7 +719,7 @@ def proc_caller it "returns a caller backtrace" do backtrace = @s.rb_make_backtrace lines = backtrace.select {|l| l =~ /#{__FILE__}/ } - lines.should_not be_empty + lines.should_not.empty? end end @@ -777,7 +777,7 @@ def m(*args, **kwargs) -> { @s.rb_funcallv_kw(self, :m, [42]) - }.should raise_error(TypeError, 'no implicit conversion of Integer into Hash') + }.should.raise(TypeError, 'no implicit conversion of Integer into Hash') end end @@ -813,7 +813,7 @@ def method_private; :method_private end end it "does not call a private method" do - -> { @s.rb_funcallv_public(@obj, :method_private) }.should raise_error(NoMethodError, /private/) + -> { @s.rb_funcallv_public(@obj, :method_private) }.should.raise(NoMethodError, /private/) end end @@ -847,7 +847,7 @@ def method_public(*args); [args, yield] end -> { @s.rb_funcall_with_block(object, :private_method, [], proc { }) - }.should raise_error(NoMethodError, /private/) + }.should.raise(NoMethodError, /private/) end it "does not call a protected method" do @@ -855,7 +855,7 @@ def method_public(*args); [args, yield] end -> { @s.rb_funcall_with_block(object, :protected_method, [], proc { }) - }.should raise_error(NoMethodError, /protected/) + }.should.raise(NoMethodError, /protected/) end end @@ -874,7 +874,7 @@ def method_public(*args, **kw, &block); [args, kw, block.call] end -> { @s.rb_funcall_with_block_kw(object, :private_method, [{}], proc { }) - }.should raise_error(NoMethodError, /private/) + }.should.raise(NoMethodError, /private/) end it "does not call a protected method" do @@ -882,7 +882,7 @@ def method_public(*args, **kw, &block); [args, kw, block.call] end -> { @s.rb_funcall_with_block_kw(object, :protected_method, [{}], proc { }) - }.should raise_error(NoMethodError, /protected/) + }.should.raise(NoMethodError, /protected/) end end diff --git a/spec/ruby/optional/capi/module_spec.rb b/spec/ruby/optional/capi/module_spec.rb index af39ec01927b83..b9c36f569fcd0f 100644 --- a/spec/ruby/optional/capi/module_spec.rb +++ b/spec/ruby/optional/capi/module_spec.rb @@ -36,7 +36,7 @@ it "allows arbitrary names, including constant names not valid in Ruby" do -> { CApiModuleSpecs::C.const_set(:_INVALID, 1) - }.should raise_error(NameError, /wrong constant name/) + }.should.raise(NameError, /wrong constant name/) suppress_warning { @m.rb_const_set(CApiModuleSpecs::C, :_INVALID, 2) } @m.rb_const_get(CApiModuleSpecs::C, :_INVALID).should == 2 @@ -44,7 +44,7 @@ # Ruby-level should still not allow access -> { CApiModuleSpecs::C.const_get(:_INVALID) - }.should raise_error(NameError, /wrong constant name/) + }.should.raise(NameError, /wrong constant name/) end end @@ -56,15 +56,15 @@ it "raises a TypeError if the constant is not a module" do ::CApiModuleSpecsGlobalConst = 7 - -> { @m.rb_define_module("CApiModuleSpecsGlobalConst") }.should raise_error(TypeError) + -> { @m.rb_define_module("CApiModuleSpecsGlobalConst") }.should.raise(TypeError) Object.send :remove_const, :CApiModuleSpecsGlobalConst end it "defines a new module at toplevel" do mod = @m.rb_define_module("CApiModuleSpecsModuleB") - mod.should be_kind_of(Module) + mod.should.is_a?(Module) mod.name.should == "CApiModuleSpecsModuleB" - ::CApiModuleSpecsModuleB.should be_kind_of(Module) + ::CApiModuleSpecsModuleB.should.is_a?(Module) Object.send :remove_const, :CApiModuleSpecsModuleB end end @@ -72,7 +72,7 @@ describe "rb_define_module_under" do it "creates a new module inside the inner class" do mod = @m.rb_define_module_under(CApiModuleSpecs, "ModuleSpecsModuleUnder1") - mod.should be_kind_of(Module) + mod.should.is_a?(Module) end it "sets the module name" do @@ -110,26 +110,26 @@ describe "rb_const_defined" do # The fixture converts C boolean test to Ruby 'true' / 'false' it "returns C non-zero if a constant is defined" do - @m.rb_const_defined(CApiModuleSpecs::A, :X).should be_true + @m.rb_const_defined(CApiModuleSpecs::A, :X).should == true end it "returns C non-zero if a constant is defined in Object" do - @m.rb_const_defined(CApiModuleSpecs::A, :Module).should be_true + @m.rb_const_defined(CApiModuleSpecs::A, :Module).should == true end end describe "rb_const_defined_at" do # The fixture converts C boolean test to Ruby 'true' / 'false' it "returns C non-zero if a constant is defined" do - @m.rb_const_defined_at(CApiModuleSpecs::A, :X).should be_true + @m.rb_const_defined_at(CApiModuleSpecs::A, :X).should == true end it "does not search in ancestors for the constant" do - @m.rb_const_defined_at(CApiModuleSpecs::B, :X).should be_false + @m.rb_const_defined_at(CApiModuleSpecs::B, :X).should == false end it "does not search in Object" do - @m.rb_const_defined_at(CApiModuleSpecs::A, :Module).should be_false + @m.rb_const_defined_at(CApiModuleSpecs::A, :Module).should == false end end @@ -166,11 +166,11 @@ it "allows arbitrary names, including constant names not valid in Ruby" do -> { CApiModuleSpecs::A.const_get(:_INVALID) - }.should raise_error(NameError, /wrong constant name/) + }.should.raise(NameError, /wrong constant name/) -> { @m.rb_const_get(CApiModuleSpecs::A, :_INVALID) - }.should raise_error(NameError, /uninitialized constant/) + }.should.raise(NameError, /uninitialized constant/) end end @@ -237,7 +237,7 @@ def method_to_be_aliased describe "rb_define_global_function" do it "defines a method on Kernel" do @m.rb_define_global_function("module_specs_global_function") - Kernel.should have_method(:module_specs_global_function) + Kernel.should.respond_to?(:module_specs_global_function) module_specs_global_function.should == :test_method end end @@ -246,7 +246,7 @@ def method_to_be_aliased it "defines a method on a class" do cls = Class.new @m.rb_define_method(cls, "test_method") - cls.should have_instance_method(:test_method) + cls.should.method_defined?(:test_method, false) cls.new.test_method.should == :test_method end @@ -285,7 +285,7 @@ def method_to_be_aliased it "defines a method on a module" do mod = Module.new @m.rb_define_method(mod, "test_method") - mod.should have_instance_method(:test_method) + mod.should.method_defined?(:test_method, false) end it "returns the correct arity of the method in module" do @@ -313,7 +313,7 @@ def method_to_be_aliased cls = Class.new cls.include(@mod) - cls.should have_private_instance_method(:test_module_function) + cls.private_instance_methods(true).should.include?(:test_module_function) end it "returns the correct arity for private instance method" do @@ -328,14 +328,14 @@ def method_to_be_aliased it "defines a private method on a class" do cls = Class.new @m.rb_define_private_method(cls, "test_method") - cls.should have_private_instance_method(:test_method) + cls.private_instance_methods(false).should.include?(:test_method) cls.new.send(:test_method).should == :test_method end it "defines a private method on a module" do mod = Module.new @m.rb_define_private_method(mod, "test_method") - mod.should have_private_instance_method(:test_method) + mod.private_instance_methods(false).should.include?(:test_method) end end @@ -343,14 +343,14 @@ def method_to_be_aliased it "defines a protected method on a class" do cls = Class.new @m.rb_define_protected_method(cls, "test_method") - cls.should have_protected_instance_method(:test_method) + cls.protected_instance_methods(false).should.include?(:test_method) cls.new.send(:test_method).should == :test_method end it "defines a protected method on a module" do mod = Module.new @m.rb_define_protected_method(mod, "test_method") - mod.should have_protected_instance_method(:test_method) + mod.protected_instance_methods(false).should.include?(:test_method) end end @@ -360,7 +360,7 @@ def method_to_be_aliased a = cls.new @m.rb_define_singleton_method a, "module_specs_singleton_method" a.module_specs_singleton_method.should == :test_method - -> { cls.new.module_specs_singleton_method }.should raise_error(NoMethodError) + -> { cls.new.module_specs_singleton_method }.should.raise(NoMethodError) end end @@ -376,16 +376,16 @@ def ruby_test_method it "undef'ines a method on a class" do @class.new.ruby_test_method.should == :ruby_test_method @m.rb_undef_method @class, "ruby_test_method" - @class.should_not have_instance_method(:ruby_test_method) + @class.should_not.method_defined?(:ruby_test_method) end it "undefines private methods also" do @m.rb_undef_method @class, "initialize_copy" - -> { @class.new.dup }.should raise_error(NoMethodError) + -> { @class.new.dup }.should.raise(NoMethodError) end it "does not raise exceptions when passed a missing name" do - -> { @m.rb_undef_method @class, "not_exist" }.should_not raise_error + -> { @m.rb_undef_method @class, "not_exist" }.should_not.raise end describe "when given a frozen Class" do @@ -394,11 +394,11 @@ def ruby_test_method end it "raises a FrozenError when passed a name" do - -> { @m.rb_undef_method @frozen, "ruby_test_method" }.should raise_error(FrozenError) + -> { @m.rb_undef_method @frozen, "ruby_test_method" }.should.raise(FrozenError) end it "raises a FrozenError when passed a missing name" do - -> { @m.rb_undef_method @frozen, "not_exist" }.should raise_error(FrozenError) + -> { @m.rb_undef_method @frozen, "not_exist" }.should.raise(FrozenError) end end end @@ -413,7 +413,7 @@ def ruby_test_method cls.new.ruby_test_method.should == :ruby_test_method @m.rb_undef cls, :ruby_test_method - cls.should_not have_instance_method(:ruby_test_method) + cls.should_not.method_defined?(:ruby_test_method) end end diff --git a/spec/ruby/optional/capi/mutex_spec.rb b/spec/ruby/optional/capi/mutex_spec.rb index 71a2212e36c3ad..fad9b4d1a25fae 100644 --- a/spec/ruby/optional/capi/mutex_spec.rb +++ b/spec/ruby/optional/capi/mutex_spec.rb @@ -10,64 +10,64 @@ describe "rb_mutex_new" do it "creates a new mutex" do - @s.rb_mutex_new.should be_an_instance_of(Mutex) + @s.rb_mutex_new.should.instance_of?(Mutex) end end describe "rb_mutex_locked_p" do it "returns false if the mutex is not locked" do - @s.rb_mutex_locked_p(@m).should be_false + @s.rb_mutex_locked_p(@m).should == false end it "returns true if the mutex is locked" do @m.lock - @s.rb_mutex_locked_p(@m).should be_true + @s.rb_mutex_locked_p(@m).should == true end end describe "rb_mutex_trylock" do it "locks the mutex if not locked" do - @s.rb_mutex_trylock(@m).should be_true - @m.locked?.should be_true + @s.rb_mutex_trylock(@m).should == true + @m.locked?.should == true end it "returns false if the mutex is already locked" do @m.lock - @s.rb_mutex_trylock(@m).should be_false - @m.locked?.should be_true + @s.rb_mutex_trylock(@m).should == false + @m.locked?.should == true end end describe "rb_mutex_lock" do it "returns when the mutex isn't locked" do @s.rb_mutex_lock(@m).should == @m - @m.locked?.should be_true + @m.locked?.should == true end it "throws an exception when already locked in the same thread" do @m.lock - -> { @s.rb_mutex_lock(@m) }.should raise_error(ThreadError) - @m.locked?.should be_true + -> { @s.rb_mutex_lock(@m) }.should.raise(ThreadError) + @m.locked?.should == true end end describe "rb_mutex_unlock" do it "raises an exception when not locked" do - -> { @s.rb_mutex_unlock(@m) }.should raise_error(ThreadError) - @m.locked?.should be_false + -> { @s.rb_mutex_unlock(@m) }.should.raise(ThreadError) + @m.locked?.should == false end it "unlocks the mutex when locked" do @m.lock @s.rb_mutex_unlock(@m).should == @m - @m.locked?.should be_false + @m.locked?.should == false end end describe "rb_mutex_sleep" do it "throws an exception when the mutex is not locked" do - -> { @s.rb_mutex_sleep(@m, 0.1) }.should raise_error(ThreadError) - @m.locked?.should be_false + -> { @s.rb_mutex_sleep(@m, 0.1) }.should.raise(ThreadError) + @m.locked?.should == false end it "sleeps when the mutex is locked" do @@ -76,13 +76,13 @@ @s.rb_mutex_sleep(@m, 0.001) t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC) (t2 - t1).should >= 0 - @m.locked?.should be_true + @m.locked?.should == true end end describe "rb_mutex_synchronize" do it "calls the function while the mutex is locked" do - callback = -> { @m.locked?.should be_true } + callback = -> { @m.locked?.should == true } @s.rb_mutex_synchronize(@m, callback) end diff --git a/spec/ruby/optional/capi/numeric_spec.rb b/spec/ruby/optional/capi/numeric_spec.rb index e9667da5ba1b9b..abfed1350352a6 100644 --- a/spec/ruby/optional/capi/numeric_spec.rb +++ b/spec/ruby/optional/capi/numeric_spec.rb @@ -9,7 +9,7 @@ describe "NUM2INT" do it "raises a TypeError if passed nil" do - -> { @s.NUM2INT(nil) }.should raise_error(TypeError) + -> { @s.NUM2INT(nil) }.should.raise(TypeError) end it "converts a Float" do @@ -33,7 +33,7 @@ end it "raises a RangeError if the value is more than 32bits" do - -> { @s.NUM2INT(0xffff_ffff+1) }.should raise_error(RangeError) + -> { @s.NUM2INT(0xffff_ffff+1) }.should.raise(RangeError) end it "calls #to_int to coerce the value" do @@ -45,7 +45,7 @@ describe "NUM2UINT" do it "raises a TypeError if passed nil" do - -> { @s.NUM2UINT(nil) }.should raise_error(TypeError) + -> { @s.NUM2UINT(nil) }.should.raise(TypeError) end it "converts a Float" do @@ -69,17 +69,17 @@ end it "raises a RangeError if the value is more than 32bits" do - -> { @s.NUM2UINT(0xffff_ffff+1) }.should raise_error(RangeError) + -> { @s.NUM2UINT(0xffff_ffff+1) }.should.raise(RangeError) end it "raises a RangeError if the value is less than 32bits negative" do - -> { @s.NUM2UINT(-0x8000_0000-1) }.should raise_error(RangeError) + -> { @s.NUM2UINT(-0x8000_0000-1) }.should.raise(RangeError) end it "raises a RangeError if the value is more than 64bits" do -> do @s.NUM2UINT(0xffff_ffff_ffff_ffff+1) - end.should raise_error(RangeError) + end.should.raise(RangeError) end it "calls #to_int to coerce the value" do @@ -91,7 +91,7 @@ describe "NUM2LONG" do it "raises a TypeError if passed nil" do - -> { @s.NUM2LONG(nil) }.should raise_error(TypeError) + -> { @s.NUM2LONG(nil) }.should.raise(TypeError) end it "converts a Float" do @@ -116,7 +116,7 @@ end it "raises a RangeError if the value is more than 32bits" do - -> { @s.NUM2LONG(0xffff_ffff+1) }.should raise_error(RangeError) + -> { @s.NUM2LONG(0xffff_ffff+1) }.should.raise(RangeError) end end @@ -132,7 +132,7 @@ it "raises a RangeError if the value is more than 64bits" do -> do @s.NUM2LONG(0xffff_ffff_ffff_ffff+1) - end.should raise_error(RangeError) + end.should.raise(RangeError) end end @@ -145,7 +145,7 @@ describe "NUM2SHORT" do it "raises a TypeError if passed nil" do - -> { @s.NUM2SHORT(nil) }.should raise_error(TypeError) + -> { @s.NUM2SHORT(nil) }.should.raise(TypeError) end it "converts a Float" do @@ -161,7 +161,7 @@ end it "raises a RangeError if the value is more than 32bits" do - -> { @s.NUM2SHORT(0xffff_ffff+1) }.should raise_error(RangeError) + -> { @s.NUM2SHORT(0xffff_ffff+1) }.should.raise(RangeError) end it "calls #to_int to coerce the value" do @@ -173,7 +173,7 @@ describe "INT2NUM" do it "raises a TypeError if passed nil" do - -> { @s.INT2NUM(nil) }.should raise_error(TypeError) + -> { @s.INT2NUM(nil) }.should.raise(TypeError) end it "converts a Float" do @@ -181,7 +181,7 @@ end it "raises a RangeError when passed a Bignum" do - -> { @s.INT2NUM(bignum_value) }.should raise_error(RangeError) + -> { @s.INT2NUM(bignum_value) }.should.raise(RangeError) end it "converts a Fixnum" do @@ -195,7 +195,7 @@ describe "NUM2ULONG" do it "raises a TypeError if passed nil" do - -> { @s.NUM2ULONG(nil) }.should raise_error(TypeError) + -> { @s.NUM2ULONG(nil) }.should.raise(TypeError) end it "converts a Float" do @@ -227,7 +227,7 @@ end it "raises a RangeError if the value is more than 32bits" do - -> { @s.NUM2ULONG(0xffff_ffff+1) }.should raise_error(RangeError) + -> { @s.NUM2ULONG(0xffff_ffff+1) }.should.raise(RangeError) end end @@ -250,7 +250,7 @@ it "raises a RangeError if the value is more than 64bits" do -> do @s.NUM2ULONG(0xffff_ffff_ffff_ffff+1) - end.should raise_error(RangeError) + end.should.raise(RangeError) end end @@ -308,11 +308,11 @@ describe "NUM2DBL" do it "raises a TypeError if passed nil" do - -> { @s.NUM2DBL(nil) }.should raise_error(TypeError) + -> { @s.NUM2DBL(nil) }.should.raise(TypeError) end it "raises a TypeError if passed a String" do - -> { @s.NUM2DBL("1.2") }.should raise_error(TypeError) + -> { @s.NUM2DBL("1.2") }.should.raise(TypeError) end it "converts a Float" do @@ -348,13 +348,13 @@ end it "raises a TypeError when passed an empty String" do - -> { @s.NUM2CHR("") }.should raise_error(TypeError) + -> { @s.NUM2CHR("") }.should.raise(TypeError) end end describe "rb_num_zerodiv" do it "raises a RuntimeError" do - -> { @s.rb_num_zerodiv() }.should raise_error(ZeroDivisionError, 'divided by 0') + -> { @s.rb_num_zerodiv() }.should.raise(ZeroDivisionError, 'divided by 0') end end @@ -386,7 +386,7 @@ it "raises an ArgumentError when passed nil" do -> { @s.rb_cmpint(nil, 4) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end end @@ -410,7 +410,7 @@ obj = mock("rb_num_coerce_bin") obj.should_receive(:coerce).with(2).and_return(nil) - -> { @s.rb_num_coerce_bin(2, obj, :+) }.should raise_error(TypeError) + -> { @s.rb_num_coerce_bin(2, obj, :+) }.should.raise(TypeError) end end @@ -435,14 +435,14 @@ obj.should_receive(:coerce).with(2).and_raise(RuntimeError.new("my error")) -> { @s.rb_num_coerce_cmp(2, obj, :<=>) - }.should raise_error(RuntimeError, "my error") + }.should.raise(RuntimeError, "my error") end it "returns nil if #coerce does not return an Array" do obj = mock("rb_num_coerce_cmp") obj.should_receive(:coerce).with(2).and_return(nil) - @s.rb_num_coerce_cmp(2, obj, :<=>).should be_nil + @s.rb_num_coerce_cmp(2, obj, :<=>).should == nil end end @@ -451,7 +451,7 @@ obj = mock("rb_num_coerce_relop") obj.should_receive(:coerce).with(2).and_return([1, 2]) - @s.rb_num_coerce_relop(2, obj, :<).should be_true + @s.rb_num_coerce_relop(2, obj, :<).should == true end it "calls the specified method on the first argument returned by #coerce" do @@ -459,7 +459,7 @@ obj.should_receive(:coerce).with(2).and_return([obj, 2]) obj.should_receive(:<).with(2).and_return(false) - @s.rb_num_coerce_relop(2, obj, :<).should be_false + @s.rb_num_coerce_relop(2, obj, :<).should == false end it "raises an ArgumentError if # returns nil" do @@ -467,14 +467,14 @@ obj.should_receive(:coerce).with(2).and_return([obj, 2]) obj.should_receive(:<).with(2).and_return(nil) - -> { @s.rb_num_coerce_relop(2, obj, :<) }.should raise_error(ArgumentError) + -> { @s.rb_num_coerce_relop(2, obj, :<) }.should.raise(ArgumentError) end it "raises an ArgumentError if #coerce does not return an Array" do obj = mock("rb_num_coerce_relop") obj.should_receive(:coerce).with(2).and_return(nil) - -> { @s.rb_num_coerce_relop(2, obj, :<) }.should raise_error(ArgumentError) + -> { @s.rb_num_coerce_relop(2, obj, :<) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/optional/capi/object_spec.rb b/spec/ruby/optional/capi/object_spec.rb index 6716fd9e33766c..8e907a5a8ca50b 100644 --- a/spec/ruby/optional/capi/object_spec.rb +++ b/spec/ruby/optional/capi/object_spec.rb @@ -64,7 +64,7 @@ def six(a, b, *c, &d); end it "allocates a new uninitialized object" do o = @o.rb_obj_alloc(CApiObjectSpecs::Alloc) o.class.should == CApiObjectSpecs::Alloc - o.initialized.should be_nil + o.initialized.should == nil end end @@ -77,17 +77,17 @@ def six(a, b, *c, &d); end obj2.foo.should == obj1.foo - obj2.should_not equal(obj1) + obj2.should_not.equal?(obj1) end end describe "rb_obj_call_init" do it "sends #initialize" do o = @o.rb_obj_alloc(CApiObjectSpecs::Alloc) - o.initialized.should be_nil + o.initialized.should == nil @o.rb_obj_call_init(o, 2, [:one, :two]) - o.initialized.should be_true + o.initialized.should == true o.arguments.should == [:one, :two] end @@ -235,7 +235,7 @@ def six(a, b, *c, &d); end describe "rb_obj_instance_variables" do it "returns an array with instance variable names as symbols" do o = ObjectTest.new - @o.rb_obj_instance_variables(o).should include(:@foo) + @o.rb_obj_instance_variables(o).should.include?(:@foo) end end @@ -244,21 +244,21 @@ def six(a, b, *c, &d); end ary = [1, 2] ary.should_not_receive(:to_ary) - @o.rb_check_convert_type(ary, "Array", "to_ary").should equal(ary) + @o.rb_check_convert_type(ary, "Array", "to_ary").should.equal?(ary) end it "returns the passed object and does not call the converting method if the object is a subclass of the specified type" do obj = CApiObjectSpecs::SubArray.new obj.should_not_receive(:to_array) - @o.rb_check_convert_type(obj, "Array", "to_array").should equal(obj) + @o.rb_check_convert_type(obj, "Array", "to_array").should.equal?(obj) end it "returns nil if the converting method returns nil" do obj = mock("rb_check_convert_type") obj.should_receive(:to_array).and_return(nil) - @o.rb_check_convert_type(obj, "Array", "to_array").should be_nil + @o.rb_check_convert_type(obj, "Array", "to_array").should == nil end it "raises a TypeError if the converting method returns an object that is not the specified type" do @@ -267,7 +267,7 @@ def six(a, b, *c, &d); end -> do @o.rb_check_convert_type(obj, "Array", "to_array") - end.should raise_error(TypeError) + end.should.raise(TypeError) end end @@ -276,14 +276,14 @@ def six(a, b, *c, &d); end ary = [1, 2] ary.should_not_receive(:to_ary) - @o.rb_convert_type(ary, "Array", "to_ary").should equal(ary) + @o.rb_convert_type(ary, "Array", "to_ary").should.equal?(ary) end it "returns the passed object and does not call the converting method if the object is a subclass of the specified type" do obj = CApiObjectSpecs::SubArray.new obj.should_not_receive(:to_array) - @o.rb_convert_type(obj, "Array", "to_array").should equal(obj) + @o.rb_convert_type(obj, "Array", "to_array").should.equal?(obj) end it "raises a TypeError if the converting method returns nil" do @@ -292,7 +292,7 @@ def six(a, b, *c, &d); end -> do @o.rb_convert_type(obj, "Array", "to_array") - end.should raise_error(TypeError) + end.should.raise(TypeError) end it "raises a TypeError if the converting method returns an object that is not the specified type" do @@ -301,109 +301,109 @@ def six(a, b, *c, &d); end -> do @o.rb_convert_type(obj, "Array", "to_array") - end.should raise_error(TypeError) + end.should.raise(TypeError) end end describe "rb_check_array_type" do it "returns the argument if it's an Array" do x = Array.new - @o.rb_check_array_type(x).should equal(x) + @o.rb_check_array_type(x).should.equal?(x) end it "returns the argument if it's a kind of Array" do x = AryChild.new - @o.rb_check_array_type(x).should equal(x) + @o.rb_check_array_type(x).should.equal?(x) end it "returns nil when the argument does not respond to #to_ary" do - @o.rb_check_array_type(Object.new).should be_nil + @o.rb_check_array_type(Object.new).should == nil end it "sends #to_ary to the argument and returns the result if it's nil" do obj = mock("to_ary") obj.should_receive(:to_ary).and_return(nil) - @o.rb_check_array_type(obj).should be_nil + @o.rb_check_array_type(obj).should == nil end it "sends #to_ary to the argument and returns the result if it's an Array" do x = Array.new obj = mock("to_ary") obj.should_receive(:to_ary).and_return(x) - @o.rb_check_array_type(obj).should equal(x) + @o.rb_check_array_type(obj).should.equal?(x) end it "sends #to_ary to the argument and returns the result if it's a kind of Array" do x = AryChild.new obj = mock("to_ary") obj.should_receive(:to_ary).and_return(x) - @o.rb_check_array_type(obj).should equal(x) + @o.rb_check_array_type(obj).should.equal?(x) end it "sends #to_ary to the argument and raises TypeError if it's not a kind of Array" do obj = mock("to_ary") obj.should_receive(:to_ary).and_return(Object.new) - -> { @o.rb_check_array_type obj }.should raise_error(TypeError) + -> { @o.rb_check_array_type obj }.should.raise(TypeError) end it "does not rescue exceptions raised by #to_ary" do obj = mock("to_ary") obj.should_receive(:to_ary).and_raise(FrozenError) - -> { @o.rb_check_array_type obj }.should raise_error(FrozenError) + -> { @o.rb_check_array_type obj }.should.raise(FrozenError) end end describe "rb_check_string_type" do it "returns the argument if it's a String" do x = String.new - @o.rb_check_string_type(x).should equal(x) + @o.rb_check_string_type(x).should.equal?(x) end it "returns the argument if it's a kind of String" do x = StrChild.new - @o.rb_check_string_type(x).should equal(x) + @o.rb_check_string_type(x).should.equal?(x) end it "returns nil when the argument does not respond to #to_str" do - @o.rb_check_string_type(Object.new).should be_nil + @o.rb_check_string_type(Object.new).should == nil end it "sends #to_str to the argument and returns the result if it's nil" do obj = mock("to_str") obj.should_receive(:to_str).and_return(nil) - @o.rb_check_string_type(obj).should be_nil + @o.rb_check_string_type(obj).should == nil end it "sends #to_str to the argument and returns the result if it's a String" do x = String.new obj = mock("to_str") obj.should_receive(:to_str).and_return(x) - @o.rb_check_string_type(obj).should equal(x) + @o.rb_check_string_type(obj).should.equal?(x) end it "sends #to_str to the argument and returns the result if it's a kind of String" do x = StrChild.new obj = mock("to_str") obj.should_receive(:to_str).and_return(x) - @o.rb_check_string_type(obj).should equal(x) + @o.rb_check_string_type(obj).should.equal?(x) end it "sends #to_str to the argument and raises TypeError if it's not a kind of String" do obj = mock("to_str") obj.should_receive(:to_str).and_return(Object.new) - -> { @o.rb_check_string_type obj }.should raise_error(TypeError) + -> { @o.rb_check_string_type obj }.should.raise(TypeError) end it "does not rescue exceptions raised by #to_str" do obj = mock("to_str") obj.should_receive(:to_str).and_raise(RuntimeError) - -> { @o.rb_check_string_type obj }.should raise_error(RuntimeError) + -> { @o.rb_check_string_type obj }.should.raise(RuntimeError) end end describe "rb_check_to_integer" do it "returns the object when passed a Fixnum" do - @o.rb_check_to_integer(5, "to_int").should equal(5) + @o.rb_check_to_integer(5, "to_int").should.equal?(5) end it "returns the object when passed a Bignum" do @@ -414,7 +414,7 @@ def six(a, b, *c, &d); end obj = mock("rb_check_to_integer") obj.should_receive(:to_integer).and_return(10) - @o.rb_check_to_integer(obj, "to_integer").should equal(10) + @o.rb_check_to_integer(obj, "to_integer").should.equal?(10) end it "calls the converting method and returns a Bignum value" do @@ -428,23 +428,23 @@ def six(a, b, *c, &d); end obj = mock("rb_check_to_integer") obj.should_receive(:to_integer).and_return(nil) - @o.rb_check_to_integer(obj, "to_integer").should be_nil + @o.rb_check_to_integer(obj, "to_integer").should == nil end it "returns nil when the converting method does not return an Integer" do obj = mock("rb_check_to_integer") obj.should_receive(:to_integer).and_return("string") - @o.rb_check_to_integer(obj, "to_integer").should be_nil + @o.rb_check_to_integer(obj, "to_integer").should == nil end end describe "FL_ABLE" do it "returns correct boolean for type" do - @o.FL_ABLE(Object.new).should be_true - @o.FL_ABLE(true).should be_false - @o.FL_ABLE(nil).should be_false - @o.FL_ABLE(1).should be_false + @o.FL_ABLE(Object.new).should == true + @o.FL_ABLE(true).should == false + @o.FL_ABLE(nil).should == false + @o.FL_ABLE(1).should == false end end @@ -476,9 +476,9 @@ def six(a, b, *c, &d); end it "returns the singleton class if it exists" do o = ObjectTest.new - @o.rb_class_of(o).should equal ObjectTest + @o.rb_class_of(o).should.equal? ObjectTest s = o.singleton_class - @o.rb_class_of(o).should equal s + @o.rb_class_of(o).should.equal? s end end @@ -493,7 +493,7 @@ def six(a, b, *c, &d); end it "does not return the singleton class if it exists" do o = ObjectTest.new o.singleton_class - @o.rb_obj_class(o).should equal ObjectTest + @o.rb_obj_class(o).should.equal? ObjectTest end end @@ -553,15 +553,15 @@ class DescArray < Array it "raises an exception if the object is not of the expected type" do -> { @o.rb_check_type([], Object.new) - }.should raise_error(TypeError, 'wrong argument type Array (expected Object)') + }.should.raise(TypeError, 'wrong argument type Array (expected Object)') -> { @o.rb_check_type(ObjectTest, Module.new) - }.should raise_error(TypeError, 'wrong argument type Class (expected Module)') + }.should.raise(TypeError, 'wrong argument type Class (expected Module)') -> { @o.rb_check_type(nil, "string") - }.should raise_error(TypeError, 'wrong argument type nil (expected String)') + }.should.raise(TypeError, 'wrong argument type nil (expected String)') end end @@ -592,49 +592,49 @@ class DescArray < Array describe "RTEST" do it "returns C false if passed Qfalse" do - @o.RTEST(false).should be_false + @o.RTEST(false).should == false end it "returns C false if passed Qnil" do - @o.RTEST(nil).should be_false + @o.RTEST(nil).should == false end it "returns C true if passed Qtrue" do - @o.RTEST(true).should be_true + @o.RTEST(true).should == true end it "returns C true if passed a Symbol" do - @o.RTEST(:test).should be_true + @o.RTEST(:test).should == true end it "returns C true if passed an Object" do - @o.RTEST(Object.new).should be_true + @o.RTEST(Object.new).should == true end end describe "rb_special_const_p" do it "returns true if passed Qfalse" do - @o.rb_special_const_p(false).should be_true + @o.rb_special_const_p(false).should == true end it "returns true if passed Qtrue" do - @o.rb_special_const_p(true).should be_true + @o.rb_special_const_p(true).should == true end it "returns true if passed Qnil" do - @o.rb_special_const_p(nil).should be_true + @o.rb_special_const_p(nil).should == true end it "returns true if passed a Symbol" do - @o.rb_special_const_p(:test).should be_true + @o.rb_special_const_p(:test).should == true end it "returns true if passed a Fixnum" do - @o.rb_special_const_p(10).should be_true + @o.rb_special_const_p(10).should == true end it "returns false if passed an Object" do - @o.rb_special_const_p(Object.new).should be_false + @o.rb_special_const_p(Object.new).should == false end end @@ -665,7 +665,7 @@ def reach it "freezes the object passed to it" do obj = "" @o.rb_obj_freeze(obj).should == obj - obj.frozen?.should be_true + obj.frozen?.should == true end end @@ -674,7 +674,7 @@ def reach obj = ObjectTest -> do @o.rb_obj_instance_eval(obj) { include Kernel } - end.should_not raise_error(NoMethodError) + end.should_not.raise(NoMethodError) end end @@ -706,12 +706,12 @@ def reach describe "rb_check_frozen" do it "raises a FrozenError if the obj is frozen" do - -> { @o.rb_check_frozen("".freeze) }.should raise_error(FrozenError) + -> { @o.rb_check_frozen("".freeze) }.should.raise(FrozenError) end it "does nothing when object isn't frozen" do obj = +"" - -> { @o.rb_check_frozen(obj) }.should_not raise_error(TypeError) + -> { @o.rb_check_frozen(obj) }.should_not.raise(TypeError) end end @@ -719,13 +719,13 @@ def reach it "converts an Integer to string" do obj = 1 i = @o.rb_any_to_s(obj) - i.should be_kind_of(String) + i.should.is_a?(String) end it "converts an Object to string" do obj = Object.new i = @o.rb_any_to_s(obj) - i.should be_kind_of(String) + i.should.is_a?(String) end end @@ -751,61 +751,61 @@ def reach it "raises a TypeError if #to_int does not return an Integer" do x = mock("to_int") x.should_receive(:to_int).and_return("5") - -> { @o.rb_to_int(x) }.should raise_error(TypeError) + -> { @o.rb_to_int(x) }.should.raise(TypeError) end it "raises a TypeError if called with nil" do - -> { @o.rb_to_int(nil) }.should raise_error(TypeError) + -> { @o.rb_to_int(nil) }.should.raise(TypeError) end it "raises a TypeError if called with true" do - -> { @o.rb_to_int(true) }.should raise_error(TypeError) + -> { @o.rb_to_int(true) }.should.raise(TypeError) end it "raises a TypeError if called with false" do - -> { @o.rb_to_int(false) }.should raise_error(TypeError) + -> { @o.rb_to_int(false) }.should.raise(TypeError) end it "raises a TypeError if called with a String" do - -> { @o.rb_to_int("1") }.should raise_error(TypeError) + -> { @o.rb_to_int("1") }.should.raise(TypeError) end end describe "rb_equal" do it "returns true if the arguments are the same exact object" do s = "hello" - @o.rb_equal(s, s).should be_true + @o.rb_equal(s, s).should == true end it "calls == to check equality and coerces to true/false" do m = mock("string") m.should_receive(:==).and_return(8) - @o.rb_equal(m, "hello").should be_true + @o.rb_equal(m, "hello").should == true m2 = mock("string") m2.should_receive(:==).and_return(nil) - @o.rb_equal(m2, "hello").should be_false + @o.rb_equal(m2, "hello").should == false end end describe "rb_class_inherited_p" do it "returns true if mod equals arg" do - @o.rb_class_inherited_p(Array, Array).should be_true + @o.rb_class_inherited_p(Array, Array).should == true end it "returns true if mod is a subclass of arg" do - @o.rb_class_inherited_p(Array, Object).should be_true + @o.rb_class_inherited_p(Array, Object).should == true end it "returns nil if mod is not a subclass of arg" do - @o.rb_class_inherited_p(Array, Hash).should be_nil + @o.rb_class_inherited_p(Array, Hash).should == nil end it "raises a TypeError if arg is no class or module" do ->{ @o.rb_class_inherited_p(1, 2) - }.should raise_error(TypeError) + }.should.raise(TypeError) end end @@ -929,7 +929,7 @@ def reach @o.rb_define_alloc_func(klass) obj = klass.allocate obj.class.should.equal?(klass) - obj.should have_instance_variable(:@from_custom_allocator) + obj.should.instance_variable_defined?(:@from_custom_allocator) end it "sets up the allocator for a subclass of String" do @@ -937,7 +937,7 @@ def reach @o.rb_define_alloc_func(klass) obj = klass.allocate obj.class.should.equal?(klass) - obj.should have_instance_variable(:@from_custom_allocator) + obj.should.instance_variable_defined?(:@from_custom_allocator) obj.should == "" end @@ -946,7 +946,7 @@ def reach @o.rb_define_alloc_func(klass) obj = klass.allocate obj.class.should.equal?(klass) - obj.should have_instance_variable(:@from_custom_allocator) + obj.should.instance_variable_defined?(:@from_custom_allocator) obj.should == [] end end diff --git a/spec/ruby/optional/capi/proc_spec.rb b/spec/ruby/optional/capi/proc_spec.rb index 8b94432f3e28a7..1c250fee761167 100644 --- a/spec/ruby/optional/capi/proc_spec.rb +++ b/spec/ruby/optional/capi/proc_spec.rb @@ -36,7 +36,7 @@ it "calls the C function with arguments in argv" do @prc2.call(1, :foo).should == :foo @prc2.call(2, :foo, :bar).should == :bar - -> { @prc2.call(3, :foo, :bar) }.should raise_error(ArgumentError) + -> { @prc2.call(3, :foo, :bar) }.should.raise(ArgumentError) end it "calls the C function with the block passed in blockarg" do @@ -95,7 +95,7 @@ it "raises TypeError if the last argument is not a Hash" do -> { @p.rb_proc_call_kw(proc {}, [42]) - }.should raise_error(TypeError, 'no implicit conversion of Integer into Hash') + }.should.raise(TypeError, 'no implicit conversion of Integer into Hash') end end @@ -125,7 +125,7 @@ it "raises TypeError if the last argument is not a Hash" do -> { @p.rb_proc_call_with_block_kw(proc {}, [42], proc {}) - }.should raise_error(TypeError, 'no implicit conversion of Integer into Hash') + }.should.raise(TypeError, 'no implicit conversion of Integer into Hash') end it "passes keyword arguments to the proc when a block is nil" do @@ -138,19 +138,19 @@ describe "rb_obj_is_proc" do it "returns true for Proc" do prc = Proc.new {|a,b| a * b } - @p.rb_obj_is_proc(prc).should be_true + @p.rb_obj_is_proc(prc).should == true end it "returns true for subclass of Proc" do prc = Class.new(Proc).new {} - @p.rb_obj_is_proc(prc).should be_true + @p.rb_obj_is_proc(prc).should == true end it "returns false for non Proc instances" do - @p.rb_obj_is_proc("aoeui").should be_false - @p.rb_obj_is_proc(123).should be_false - @p.rb_obj_is_proc(true).should be_false - @p.rb_obj_is_proc([]).should be_false + @p.rb_obj_is_proc("aoeui").should == false + @p.rb_obj_is_proc(123).should == false + @p.rb_obj_is_proc(true).should == false + @p.rb_obj_is_proc([]).should == false end end end @@ -172,17 +172,17 @@ it "raises an ArgumentError when the C function calls a Ruby method that calls Proc.new" do -> { @p.rb_Proc_new(2) { :called } - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end # Ruby -> C -> Ruby -> C -> rb_funcall(Proc.new) it "raises an ArgumentError when the C function calls a Ruby method and that method calls a C function that calls Proc.new" do def @p.redispatch() rb_Proc_new(0) end - -> { @p.rb_Proc_new(3) { :called } }.should raise_error(ArgumentError) + -> { @p.rb_Proc_new(3) { :called } }.should.raise(ArgumentError) end # Ruby -> C -> Ruby -> block_given? it "returns false from block_given? in a Ruby method called by the C function" do - @p.rb_Proc_new(6).should be_false + @p.rb_Proc_new(6).should == false end end diff --git a/spec/ruby/optional/capi/range_spec.rb b/spec/ruby/optional/capi/range_spec.rb index 80c052e79a3f8f..9213862aa43ffa 100644 --- a/spec/ruby/optional/capi/range_spec.rb +++ b/spec/ruby/optional/capi/range_spec.rb @@ -31,8 +31,8 @@ end it "raises an ArgumentError when the given start and end can't be compared by using #<=>" do - -> { @s.rb_range_new(1, mock('x')) }.should raise_error(ArgumentError) - -> { @s.rb_range_new(mock('x'), mock('y')) }.should raise_error(ArgumentError) + -> { @s.rb_range_new(1, mock('x')) }.should.raise(ArgumentError) + -> { @s.rb_range_new(mock('x'), mock('y')) }.should.raise(ArgumentError) end end @@ -41,7 +41,7 @@ beg, fin, excl = @s.rb_range_values(10..20) beg.should == 10 fin.should == 20 - excl.should be_false + excl.should == false end it "stores the range properties of non-Range object" do @@ -62,7 +62,7 @@ def range_like.exclude_end? beg, fin, excl = @s.rb_range_values(range_like) beg.should == 10 fin.should == 20 - excl.should be_false + excl.should == false end end @@ -70,7 +70,7 @@ def range_like.exclude_end? it "returns correct begin, length and result" do r = 2..5 begp, lenp, result = @s.rb_range_beg_len(r, 10, 0) - result.should be_true + result.should == true begp.should == 2 lenp.should == 4 end @@ -78,18 +78,18 @@ def range_like.exclude_end? it "returns nil when not in range" do r = 2..5 begp, lenp, result = @s.rb_range_beg_len(r, 1, 0) - result.should be_nil + result.should == nil end it "raises a RangeError when not in range and err is 1" do r = -5..-1 - -> { @s.rb_range_beg_len(r, 1, 1) }.should raise_error(RangeError) + -> { @s.rb_range_beg_len(r, 1, 1) }.should.raise(RangeError) end it "returns nil when not in range and err is 0" do r = -5..-1 begp, lenp, result = @s.rb_range_beg_len(r, 1, 0) - result.should be_nil + result.should == nil end end @@ -133,7 +133,7 @@ def object.exclude_end? error_code = 0 success, beg, len, step = @s.rb_arithmetic_sequence_beg_len_step(as, 6, error_code) - success.should be_true + success.should == true beg.should == 2 len.should == 4 @@ -145,7 +145,7 @@ def object.exclude_end? error_code = 0 success, _, len, _ = @s.rb_arithmetic_sequence_beg_len_step(as, 6, error_code) - success.should be_true + success.should == true len.should == 3 end @@ -154,7 +154,7 @@ def object.exclude_end? error_code = 0 success, beg, len, _ = @s.rb_arithmetic_sequence_beg_len_step(as, 6, error_code) - success.should be_true + success.should == true beg.should == 4 len.should == 2 @@ -165,7 +165,7 @@ def object.exclude_end? error_code = 0 success, beg, len, _ = @s.rb_arithmetic_sequence_beg_len_step(as, 6, error_code) - success.should be_true + success.should == true beg.should == 2 len.should == 4 @@ -176,7 +176,7 @@ def object.exclude_end? error_code = 0 success, _, len, _ = @s.rb_arithmetic_sequence_beg_len_step(as, 6, error_code) - success.should be_true + success.should == true len.should == 4 end @@ -185,7 +185,7 @@ def object.exclude_end? error_code = 0 success, beg, len, step = @s.rb_arithmetic_sequence_beg_len_step(as, 6, error_code) - success.should be_true + success.should == true beg.should == 5 len.should == 0 @@ -197,7 +197,7 @@ def object.exclude_end? error_code = 0 success, = @s.rb_arithmetic_sequence_beg_len_step(as, 1, error_code) - success.should be_nil + success.should == nil end it "returns nil when not in range, negative boundaries and error code = 0" do @@ -205,7 +205,7 @@ def object.exclude_end? error_code = 0 success, = @s.rb_arithmetic_sequence_beg_len_step(as, 1, 0) - success.should be_nil + success.should == nil end it "returns begin, length and step and doesn't raise a RangeError when not in range and error code = 1" do @@ -213,7 +213,7 @@ def object.exclude_end? error_code = 1 success, beg, len, step = @s.rb_arithmetic_sequence_beg_len_step(as, 1, error_code) - success.should be_true + success.should == true beg.should == 2 len.should == 4 @@ -225,7 +225,7 @@ def object.exclude_end? error_code = 1 success, = @s.rb_arithmetic_sequence_beg_len_step(as, 1, error_code) - success.should be_nil + success.should == nil end end end diff --git a/spec/ruby/optional/capi/regexp_spec.rb b/spec/ruby/optional/capi/regexp_spec.rb index 49ac79f5c48637..f233b5e3b3ce02 100644 --- a/spec/ruby/optional/capi/regexp_spec.rb +++ b/spec/ruby/optional/capi/regexp_spec.rb @@ -104,7 +104,7 @@ end Thread.pass while thr.status and !running - $~.should be_nil + $~.should == nil thr.join end diff --git a/spec/ruby/optional/capi/set_spec.rb b/spec/ruby/optional/capi/set_spec.rb index 3e35be0505fffa..21a9756236e912 100644 --- a/spec/ruby/optional/capi/set_spec.rb +++ b/spec/ruby/optional/capi/set_spec.rb @@ -64,7 +64,7 @@ describe "rb_set_clear" do it "empties and returns self" do set = Set[1] - @s.rb_set_clear(set).should equal(set) + @s.rb_set_clear(set).should.equal?(set) set.should == Set[] end end diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb index 6861366dd3e033..3e095f05c83c44 100644 --- a/spec/ruby/optional/capi/string_spec.rb +++ b/spec/ruby/optional/capi/string_spec.rb @@ -286,13 +286,13 @@ def inspect it "returns a dup of the original String" do a = "abc" b = @s.rb_str_encode("abc", "us-ascii", 0, nil) - a.should_not equal(b) + a.should_not.equal?(b) end it "returns a duplicate of the original when the encoding doesn't change" do a = "abc" b = @s.rb_str_encode("abc", Encoding::UTF_8, 0, nil) - a.should_not equal(b) + a.should_not.equal?(b) end it "accepts encoding flags" do @@ -320,7 +320,7 @@ def inspect str1 = "hi" str2 = @s.rb_str_new3 str1 str1.should == str2 - str1.should_not equal str2 + str1.should_not.equal? str2 end end @@ -330,7 +330,7 @@ def inspect str1.freeze str2 = @s.rb_str_new4 str1 str1.should == str2 - str1.should equal(str2) + str1.should.equal?(str2) str1.should.frozen? str2.should.frozen? end @@ -339,7 +339,7 @@ def inspect str1 = "hi" str2 = @s.rb_str_new4 str1 str1.should == str2 - str1.should_not equal(str2) + str1.should_not.equal?(str2) str2.should.frozen? end end @@ -349,7 +349,7 @@ def inspect str1 = "hi" str2 = @s.rb_str_dup str1 str1.should == str2 - str1.should_not equal str2 + str1.should_not.equal? str2 end end @@ -370,7 +370,7 @@ def inspect end it "raises a TypeError trying to append non-String-like object" do - -> { @s.rb_str_append("Hello", 32323)}.should raise_error(TypeError) + -> { @s.rb_str_append("Hello", 32323)}.should.raise(TypeError) end it "changes Encoding if a string is appended to an empty string" do @@ -499,7 +499,7 @@ def inspect end it "converts a C string to a Fixnum strictly if base is 0" do - -> { @s.rb_cstr2inum("1234a", 0) }.should raise_error(ArgumentError) + -> { @s.rb_cstr2inum("1234a", 0) }.should.raise(ArgumentError) end end @@ -517,7 +517,7 @@ def inspect end it "converts a C string to a Fixnum strictly" do - -> { @s.rb_cstr_to_inum("1234a", 10, true) }.should raise_error(ArgumentError) + -> { @s.rb_cstr_to_inum("1234a", 10, true) }.should.raise(ArgumentError) end end @@ -575,7 +575,7 @@ def inspect end it "returns nil for a negative offset that is out of range" do - @s.rb_str_subpos("hello", -6).should be_nil + @s.rb_str_subpos("hello", -6).should == nil end it "returns the correct position for a negative offset" do @@ -587,7 +587,7 @@ def inspect end it "returns nil when offset is beyond string length" do - @s.rb_str_subpos("hello", 6).should be_nil + @s.rb_str_subpos("hello", 6).should == nil end end @@ -598,8 +598,8 @@ def inspect end it "raises a TypeError if coercion fails" do - -> { @s.rb_str_to_str(0) }.should raise_error(TypeError) - -> { @s.rb_str_to_str(CApiStringSpecs::InvalidTostrTest.new) }.should raise_error(TypeError) + -> { @s.rb_str_to_str(0) }.should.raise(TypeError) + -> { @s.rb_str_to_str(CApiStringSpecs::InvalidTostrTest.new) }.should.raise(TypeError) end end @@ -723,7 +723,7 @@ def inspect it "does not call #to_s on non-String objects" do str = mock("fake") str.should_not_receive(:to_s) - -> { @s.send(@method, str) }.should raise_error(TypeError) + -> { @s.send(@method, str) }.should.raise(TypeError) end end @@ -736,7 +736,7 @@ def inspect describe "rb_str_modify" do it "raises an error if the string is frozen" do - -> { @s.rb_str_modify("frozen".freeze) }.should raise_error(FrozenError) + -> { @s.rb_str_modify("frozen".freeze) }.should.raise(FrozenError) end end @@ -767,7 +767,7 @@ def inspect end it "raises an error if the string is frozen" do - -> { @s.rb_str_modify_expand("frozen".freeze, 10) }.should raise_error(FrozenError) + -> { @s.rb_str_modify_expand("frozen".freeze, 10) }.should.raise(FrozenError) end end @@ -823,14 +823,14 @@ def inspect it "freezes the string" do s = "" @s.rb_str_freeze(s).should == s - s.frozen?.should be_true + s.frozen?.should == true end end describe "rb_str_hash" do it "hashes the string into a number" do s = "hello" - @s.rb_str_hash(s).should be_kind_of(Integer) + @s.rb_str_hash(s).should.is_a?(Integer) end end @@ -846,7 +846,7 @@ def inspect # is available. There is no guarantee this even does # anything at all it "indicates data for a string might be freed" do - @s.rb_str_free("xyz").should be_nil + @s.rb_str_free("xyz").should == nil end end @@ -888,12 +888,12 @@ def inspect describe "rb_str_equal" do it "compares two same strings" do s = "hello" - @s.rb_str_equal(s, "hello").should be_true + @s.rb_str_equal(s, "hello").should == true end it "compares two different strings" do s = "hello" - @s.rb_str_equal(s, "hella").should be_false + @s.rb_str_equal(s, "hella").should == false end end @@ -928,7 +928,7 @@ def inspect # - s.should == "\xA4\xA2\xA4\xEC".dup.force_encoding("euc-jp") # + x = [0xA4, 0xA2, 0xA4, 0xEC].pack('C4')#.force_encoding('binary') # + s.should == x -# s.encoding.should equal(Encoding::EUC_JP) +# s.encoding.should.equal?(Encoding::EUC_JP) # end it "transcodes a String to Encoding.default_internal if it is set" do @@ -938,7 +938,7 @@ def inspect s = @s.rb_external_str_new_with_enc(a, a.bytesize, Encoding::UTF_8) x = [0xA4, 0xA2, 0xA4, 0xEC].pack('C4').force_encoding('euc-jp') s.should == x - s.encoding.should equal(Encoding::EUC_JP) + s.encoding.should.equal?(Encoding::EUC_JP) end end @@ -946,7 +946,7 @@ def inspect it "returns a String with 'locale' encoding" do s = @s.rb_locale_str_new("abc", 3) s.should == "abc".dup.force_encoding(Encoding.find("locale")) - s.encoding.should equal(Encoding.find("locale")) + s.encoding.should.equal?(Encoding.find("locale")) end end @@ -954,14 +954,14 @@ def inspect it "returns a String with 'locale' encoding" do s = @s.rb_locale_str_new_cstr("abc") s.should == "abc".dup.force_encoding(Encoding.find("locale")) - s.encoding.should equal(Encoding.find("locale")) + s.encoding.should.equal?(Encoding.find("locale")) end end describe "rb_str_conv_enc" do it "returns the original String when to encoding is not specified" do a = "abc".dup.force_encoding("us-ascii") - @s.rb_str_conv_enc(a, Encoding::US_ASCII, nil).should equal(a) + @s.rb_str_conv_enc(a, Encoding::US_ASCII, nil).should.equal?(a) end it "returns the original String if a transcoding error occurs" do @@ -984,17 +984,17 @@ def inspect describe "when the String encoding is equal to the destination encoding" do it "returns the original String" do a = "abc".dup.force_encoding("us-ascii") - @s.rb_str_conv_enc(a, Encoding::US_ASCII, Encoding::US_ASCII).should equal(a) + @s.rb_str_conv_enc(a, Encoding::US_ASCII, Encoding::US_ASCII).should.equal?(a) end it "returns the original String if the destination encoding is ASCII compatible and the String has no high bits set" do a = "abc".encode("us-ascii") - @s.rb_str_conv_enc(a, Encoding::UTF_8, Encoding::US_ASCII).should equal(a) + @s.rb_str_conv_enc(a, Encoding::UTF_8, Encoding::US_ASCII).should.equal?(a) end it "returns the origin String if the destination encoding is BINARY" do a = "abc".dup.force_encoding("binary") - @s.rb_str_conv_enc(a, Encoding::US_ASCII, Encoding::BINARY).should equal(a) + @s.rb_str_conv_enc(a, Encoding::US_ASCII, Encoding::BINARY).should.equal?(a) end end end @@ -1002,13 +1002,13 @@ def inspect describe "rb_str_conv_enc_opts" do it "returns the original String when to encoding is not specified" do a = "abc".dup.force_encoding("us-ascii") - @s.rb_str_conv_enc_opts(a, Encoding::US_ASCII, nil, 0, nil).should equal(a) + @s.rb_str_conv_enc_opts(a, Encoding::US_ASCII, nil, 0, nil).should.equal?(a) end it "returns the original String if a transcoding error occurs" do a = [0xEE].pack('C').force_encoding("utf-8") @s.rb_str_conv_enc_opts(a, Encoding::UTF_8, - Encoding::EUC_JP, 0, nil).should equal(a) + Encoding::EUC_JP, 0, nil).should.equal?(a) end it "returns a transcoded String" do @@ -1016,26 +1016,26 @@ def inspect result = @s.rb_str_conv_enc_opts(a, Encoding::UTF_8, Encoding::EUC_JP, 0, nil) x = [0xA4, 0xA2, 0xA4, 0xEC].pack('C4').force_encoding('utf-8') result.should == x.force_encoding("euc-jp") - result.encoding.should equal(Encoding::EUC_JP) + result.encoding.should.equal?(Encoding::EUC_JP) end describe "when the String encoding is equal to the destination encoding" do it "returns the original String" do a = "abc".dup.force_encoding("us-ascii") @s.rb_str_conv_enc_opts(a, Encoding::US_ASCII, - Encoding::US_ASCII, 0, nil).should equal(a) + Encoding::US_ASCII, 0, nil).should.equal?(a) end it "returns the original String if the destination encoding is ASCII compatible and the String has no high bits set" do a = "abc".encode("us-ascii") @s.rb_str_conv_enc_opts(a, Encoding::UTF_8, - Encoding::US_ASCII, 0, nil).should equal(a) + Encoding::US_ASCII, 0, nil).should.equal?(a) end it "returns the origin String if the destination encoding is BINARY" do a = "abc".dup.force_encoding("binary") @s.rb_str_conv_enc_opts(a, Encoding::US_ASCII, - Encoding::BINARY, 0, nil).should equal(a) + Encoding::BINARY, 0, nil).should.equal?(a) end end end @@ -1044,7 +1044,7 @@ def inspect it "returns the original String with the external encoding" do Encoding.default_external = Encoding::ISO_8859_1 s = @s.rb_str_export("Hëllo") - s.encoding.should equal(Encoding::ISO_8859_1) + s.encoding.should.equal?(Encoding::ISO_8859_1) end end @@ -1052,7 +1052,7 @@ def inspect it "returns the original String with the locale encoding" do s = @s.rb_str_export_locale("abc") s.should == "abc".dup.force_encoding(Encoding.find("locale")) - s.encoding.should equal(Encoding.find("locale")) + s.encoding.should.equal?(Encoding.find("locale")) end end @@ -1067,7 +1067,7 @@ def inspect it "returns the source string if it can not be converted" do source = ["00ff"].pack("H*"); result = @s.rb_str_export_to_enc(source, Encoding::UTF_8) - result.should equal(source) + result.should.equal?(source) end it "does not alter the source string if it can not be converted" do @@ -1181,7 +1181,7 @@ def inspect end it "raises a TypeError if #to_str does not return a string" do - -> { @s.rb_String(CApiStringSpecs::InvalidTostrTest.new) }.should raise_error(TypeError) + -> { @s.rb_String(CApiStringSpecs::InvalidTostrTest.new) }.should.raise(TypeError) end it "tries to convert the passed argument to a string by calling #to_s" do @@ -1199,11 +1199,11 @@ def inspect end it "raises an error if a string contains a null" do - -> { @s.rb_string_value_cstr("Hello\0 with a null.") }.should raise_error(ArgumentError) + -> { @s.rb_string_value_cstr("Hello\0 with a null.") }.should.raise(ArgumentError) end it "raises an error if a UTF-16 string contains a null" do - -> { @s.rb_string_value_cstr("Hello\0 with a null.".encode('UTF-16BE')) }.should raise_error(ArgumentError) + -> { @s.rb_string_value_cstr("Hello\0 with a null.".encode('UTF-16BE')) }.should.raise(ArgumentError) end end @@ -1278,23 +1278,23 @@ def inspect it "raises an error when trying to lock an already locked string" do str = +"test" @s.rb_str_locktmp(str).should == str - -> { @s.rb_str_locktmp(str) }.should raise_error(RuntimeError, 'temporal locking already locked string') + -> { @s.rb_str_locktmp(str) }.should.raise(RuntimeError, 'temporal locking already locked string') end it "locks a string so that modifications would raise an error" do str = +"test" @s.rb_str_locktmp(str).should == str - -> { str.upcase! }.should raise_error(RuntimeError, 'can\'t modify string; temporarily locked') + -> { str.upcase! }.should.raise(RuntimeError, 'can\'t modify string; temporarily locked') end ruby_version_is "4.0" do it "raises FrozenError if string is frozen" do str = -"rb_str_locktmp" - -> { @s.rb_str_locktmp(str) }.should raise_error(FrozenError) + -> { @s.rb_str_locktmp(str) }.should.raise(FrozenError) str = +"rb_str_locktmp" str.freeze - -> { @s.rb_str_locktmp(str) }.should raise_error(FrozenError) + -> { @s.rb_str_locktmp(str) }.should.raise(FrozenError) end end end @@ -1308,17 +1308,17 @@ def inspect end it "raises an error when trying to unlock an already unlocked string" do - -> { @s.rb_str_unlocktmp(+"test") }.should raise_error(RuntimeError, 'temporal unlocking already unlocked string') + -> { @s.rb_str_unlocktmp(+"test") }.should.raise(RuntimeError, 'temporal unlocking already unlocked string') end ruby_version_is "4.0" do it "raises FrozenError if string is frozen" do str = -"rb_str_locktmp" - -> { @s.rb_str_unlocktmp(str) }.should raise_error(FrozenError) + -> { @s.rb_str_unlocktmp(str) }.should.raise(FrozenError) str = +"rb_str_locktmp" str.freeze - -> { @s.rb_str_unlocktmp(str) }.should raise_error(FrozenError) + -> { @s.rb_str_unlocktmp(str) }.should.raise(FrozenError) end end end diff --git a/spec/ruby/optional/capi/struct_spec.rb b/spec/ruby/optional/capi/struct_spec.rb index 3f9eff52bc0b10..843387bc193c30 100644 --- a/spec/ruby/optional/capi/struct_spec.rb +++ b/spec/ruby/optional/capi/struct_spec.rb @@ -25,11 +25,11 @@ it "has a value of nil for the member of a newly created instance" do # Verify that attributes are on an instance basis - Struct::CAPIStruct.new.b.should be_nil + Struct::CAPIStruct.new.b.should == nil end it "creates a constant scoped under Struct for the named Struct" do - Struct.should have_constant(:CAPIStruct) + Struct.should.const_defined?(:CAPIStruct, false) end it "returns the member names as Symbols" do @@ -80,15 +80,15 @@ it "has a value of nil for the member of a newly created instance" do # Verify that attributes are on an instance basis - CApiStructSpecs::CAPIStructUnder.new.b.should be_nil + CApiStructSpecs::CAPIStructUnder.new.b.should == nil end it "does not create a constant scoped under Struct for the named Struct" do - Struct.should_not have_constant(:CAPIStructUnder) + Struct.should_not.const_defined?(:CAPIStructUnder) end it "creates a constant scoped under the namespace of the given class" do - CApiStructSpecs.should have_constant(:CAPIStructUnder) + CApiStructSpecs.should.const_defined?(:CAPIStructUnder, false) end it "returns the member names as Symbols" do @@ -106,11 +106,11 @@ describe "rb_struct_define" do it "raises an ArgumentError if arguments contain duplicate member name" do - -> { @s.rb_struct_define(nil, "a", "b", "a") }.should raise_error(ArgumentError) + -> { @s.rb_struct_define(nil, "a", "b", "a") }.should.raise(ArgumentError) end it "raises a NameError if an invalid constant name is given" do - -> { @s.rb_struct_define("foo", "a", "b", "c") }.should raise_error(NameError) + -> { @s.rb_struct_define("foo", "a", "b", "c") }.should.raise(NameError) end end @@ -131,12 +131,12 @@ end it "raises a NameError if the struct member does not exist" do - -> { @s.rb_struct_aref(@struct, :d) }.should raise_error(NameError) + -> { @s.rb_struct_aref(@struct, :d) }.should.raise(NameError) end it "raises an IndexError if the given index is out of range" do - -> { @s.rb_struct_aref(@struct, -4) }.should raise_error(IndexError) - -> { @s.rb_struct_aref(@struct, 3) }.should raise_error(IndexError) + -> { @s.rb_struct_aref(@struct, -4) }.should.raise(IndexError) + -> { @s.rb_struct_aref(@struct, 3) }.should.raise(IndexError) end end @@ -147,7 +147,7 @@ end it "raises a NameError if the struct member does not exist" do - -> { @s.rb_struct_getmember(@struct, :d) }.should raise_error(NameError) + -> { @s.rb_struct_getmember(@struct, :d) }.should.raise(NameError) end end @@ -180,17 +180,17 @@ end it "raises a NameError if the struct member does not exist" do - -> { @s.rb_struct_aset(@struct, :d, 1) }.should raise_error(NameError) + -> { @s.rb_struct_aset(@struct, :d, 1) }.should.raise(NameError) end it "raises an IndexError if the given index is out of range" do - -> { @s.rb_struct_aset(@struct, -4, 1) }.should raise_error(IndexError) - -> { @s.rb_struct_aset(@struct, 3, 1) }.should raise_error(IndexError) + -> { @s.rb_struct_aset(@struct, -4, 1) }.should.raise(IndexError) + -> { @s.rb_struct_aset(@struct, 3, 1) }.should.raise(IndexError) end it "raises a FrozenError if the struct is frozen" do @struct.freeze - -> { @s.rb_struct_aset(@struct, :a, 1) }.should raise_error(FrozenError) + -> { @s.rb_struct_aset(@struct, :a, 1) }.should.raise(FrozenError) end end @@ -227,7 +227,7 @@ end it "raises ArgumentError if too many values" do - -> { @s.rb_struct_initialize(@struct, [1, 2, 3, 4]) }.should raise_error(ArgumentError, "struct size differs") + -> { @s.rb_struct_initialize(@struct, [1, 2, 3, 4]) }.should.raise(ArgumentError, "struct size differs") end it "treats missing values as nil" do @@ -274,11 +274,11 @@ end it "raises an ArgumentError if arguments contain duplicate member name" do - -> { @s.rb_data_define(nil, "a", "b", "a") }.should raise_error(ArgumentError) + -> { @s.rb_data_define(nil, "a", "b", "a") }.should.raise(ArgumentError) end it "raises when first argument is not a class" do - -> { @s.rb_data_define([], "a", "b", "c") }.should raise_error(TypeError, "wrong argument type Array (expected Class)") + -> { @s.rb_data_define([], "a", "b", "c") }.should.raise(TypeError, "wrong argument type Array (expected Class)") end end @@ -295,12 +295,12 @@ data = @klass.allocate @s.rb_struct_initialize(data, [1, 2, 3]).should == nil data.should.frozen? - -> { @s.rb_struct_initialize(data, [1, 2, 3]) }.should raise_error(FrozenError) + -> { @s.rb_struct_initialize(data, [1, 2, 3]) }.should.raise(FrozenError) end it "raises ArgumentError if too many values" do data = @klass.allocate - -> { @s.rb_struct_initialize(data, [1, 2, 3, 4]) }.should raise_error(ArgumentError, "struct size differs") + -> { @s.rb_struct_initialize(data, [1, 2, 3, 4]) }.should.raise(ArgumentError, "struct size differs") end it "treats missing values as nil" do diff --git a/spec/ruby/optional/capi/thread_spec.rb b/spec/ruby/optional/capi/thread_spec.rb index 117726f0e2a392..75e0b94fdf926b 100644 --- a/spec/ruby/optional/capi/thread_spec.rb +++ b/spec/ruby/optional/capi/thread_spec.rb @@ -50,7 +50,7 @@ def call_capi_rb_thread_wakeup end it "returns nil if the value has not been set" do - @t.rb_thread_local_aref(Thread.current, :thread_capi_specs_undefined).should be_nil + @t.rb_thread_local_aref(Thread.current, :thread_capi_specs_undefined).should == nil end end @@ -72,7 +72,7 @@ def call_capi_rb_thread_wakeup obj = Object.new proc = -> x { ScratchPad.record x } thr = @t.rb_thread_create(proc, obj) - thr.should be_kind_of(Thread) + thr.should.is_a?(Thread) thr.join ScratchPad.recorded.should == obj end @@ -83,18 +83,18 @@ def call_capi_rb_thread_wakeup raise "my error" } thr = @t.rb_thread_create(prc, nil) - thr.should be_kind_of(Thread) + thr.should.is_a?(Thread) -> { thr.join - }.should raise_error(RuntimeError, "my error") + }.should.raise(RuntimeError, "my error") end it "sets the thread's group" do thr = @t.rb_thread_create(-> x { }, nil) begin thread_group = thr.group - thread_group.should be_an_instance_of(ThreadGroup) + thread_group.should.instance_of?(ThreadGroup) ensure thr.join end @@ -103,11 +103,11 @@ def call_capi_rb_thread_wakeup describe "ruby_native_thread_p" do it "returns non-zero for a ruby thread" do - @t.ruby_native_thread_p.should be_true + @t.ruby_native_thread_p.should == true end it "returns zero for a non ruby thread" do - @t.ruby_native_thread_p_new_thread.should be_false + @t.ruby_native_thread_p_new_thread.should == false end end @@ -128,7 +128,7 @@ def call_capi_rb_thread_wakeup thr.wakeup # Make sure it stopped and we got a proper value - thr.value.should be_true + thr.value.should == true end platform_is_not :windows do @@ -159,7 +159,7 @@ def call_capi_rb_thread_wakeup going_to_block = true # Make sure it stopped and we got a proper value - @t.rb_thread_call_without_gvl.should be_true + @t.rb_thread_call_without_gvl.should == true interrupter.join end @@ -181,14 +181,14 @@ def call_capi_rb_thread_wakeup thr.wakeup # Make sure it stopped and we got a proper value - thr.value.should be_true + thr.value.should == true end end ruby_version_is "4.0" do describe "ruby_thread_has_gvl_p" do it "returns true if the current thread has the GVL" do - @t.ruby_thread_has_gvl_p.should be_true + @t.ruby_thread_has_gvl_p.should == true end end end diff --git a/spec/ruby/optional/capi/time_spec.rb b/spec/ruby/optional/capi/time_spec.rb index ca5fc5952af289..dc0b09376e1b8b 100644 --- a/spec/ruby/optional/capi/time_spec.rb +++ b/spec/ruby/optional/capi/time_spec.rb @@ -16,7 +16,7 @@ describe "TIMET2NUM" do it "returns an Integer" do - @s.TIMET2NUM.should be_kind_of(Integer) + @s.TIMET2NUM.should.is_a?(Integer) end end @@ -32,7 +32,7 @@ it "creates a Time in the local zone with only a timestamp" do with_timezone("Europe/Amsterdam") do time = @s.rb_time_num_new(1232141421, nil) - time.should be_an_instance_of(Time) + time.should.instance_of?(Time) time.to_i.should == 1232141421 platform_is_not :windows do time.gmt_offset.should == 3600 @@ -43,7 +43,7 @@ it "creates a Time with the given offset" do with_timezone("Europe/Amsterdam") do time = @s.rb_time_num_new(1232141421, 7200) - time.should be_an_instance_of(Time) + time.should.instance_of?(Time) time.to_i.should == 1232141421 time.gmt_offset.should == 7200 end @@ -52,7 +52,7 @@ it "creates a Time with a Float timestamp" do with_timezone("Europe/Amsterdam") do time = @s.rb_time_num_new(1.5, 7200) - time.should be_an_instance_of(Time) + time.should.instance_of?(Time) time.to_i.should == 1 time.nsec.should == 500000000 time.gmt_offset.should == 7200 @@ -62,7 +62,7 @@ it "creates a Time with a Rational timestamp" do with_timezone("Europe/Amsterdam") do time = @s.rb_time_num_new(Rational(3, 2), 7200) - time.should be_an_instance_of(Time) + time.should.instance_of?(Time) time.to_i.should == 1 time.nsec.should == 500000000 time.gmt_offset.should == 7200 @@ -73,32 +73,32 @@ describe "rb_time_interval" do it "creates a timeval interval for a Fixnum" do sec, usec = @s.rb_time_interval(1232141421) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1232141421 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 0 end it "creates a timeval interval for a Float" do sec, usec = @s.rb_time_interval(1.5) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 500000 end it "creates a timeval interval for a Rational" do sec, usec = @s.rb_time_interval(Rational(3, 2)) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 500000 end it "throws an argument error for a negative value" do - -> { @s.rb_time_interval(-1232141421) }.should raise_error(ArgumentError) - -> { @s.rb_time_interval(Rational(-3, 2)) }.should raise_error(ArgumentError) - -> { @s.rb_time_interval(-1.5) }.should raise_error(ArgumentError) + -> { @s.rb_time_interval(-1232141421) }.should.raise(ArgumentError) + -> { @s.rb_time_interval(Rational(-3, 2)) }.should.raise(ArgumentError) + -> { @s.rb_time_interval(-1.5) }.should.raise(ArgumentError) end end @@ -106,36 +106,36 @@ describe "rb_time_interval" do it "creates a timeval interval for a Fixnum" do sec, usec = @s.rb_time_interval(1232141421) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1232141421 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 0 end it "creates a timeval interval for a Float" do sec, usec = @s.rb_time_interval(1.5) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 500000 end it "creates a timeval interval for a Rational" do sec, usec = @s.rb_time_interval(Rational(3, 2)) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 500000 end it "throws an argument error for a negative value" do - -> { @s.rb_time_interval(-1232141421) }.should raise_error(ArgumentError) - -> { @s.rb_time_interval(Rational(-3, 2)) }.should raise_error(ArgumentError) - -> { @s.rb_time_interval(-1.5) }.should raise_error(ArgumentError) + -> { @s.rb_time_interval(-1232141421) }.should.raise(ArgumentError) + -> { @s.rb_time_interval(Rational(-3, 2)) }.should.raise(ArgumentError) + -> { @s.rb_time_interval(-1.5) }.should.raise(ArgumentError) end it "throws an argument error when given a Time instance" do - -> { @s.rb_time_interval(Time.now) }.should raise_error(TypeError) + -> { @s.rb_time_interval(Time.now) }.should.raise(TypeError) end end @@ -143,49 +143,49 @@ describe "rb_time_timeval" do it "creates a timeval for a Fixnum" do sec, usec = @s.rb_time_timeval(1232141421) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1232141421 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 0 end it "creates a timeval for a Float" do sec, usec = @s.rb_time_timeval(1.5) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 500000 end it "creates a timeval for a Rational" do sec, usec = @s.rb_time_timeval(Rational(3, 2)) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 500000 end it "creates a timeval for a negative Fixnum" do sec, usec = @s.rb_time_timeval(-1232141421) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == -1232141421 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 0 end it "creates a timeval for a negative Float" do sec, usec = @s.rb_time_timeval(-1.5) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == -2 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 500000 end it "creates a timeval for a negative Rational" do sec, usec = @s.rb_time_timeval(Rational(-3, 2)) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == -2 - usec.should be_kind_of(Integer) + usec.should.is_a?(Integer) usec.should == 500000 end @@ -200,49 +200,49 @@ describe "rb_time_timespec" do it "creates a timespec for a Fixnum" do sec, nsec = @s.rb_time_timespec(1232141421) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1232141421 - nsec.should be_kind_of(Integer) + nsec.should.is_a?(Integer) nsec.should == 0 end it "creates a timespec for a Float" do sec, nsec = @s.rb_time_timespec(1.5) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1 - nsec.should be_kind_of(Integer) + nsec.should.is_a?(Integer) nsec.should == 500000000 end it "creates a timespec for a Rational" do sec, nsec = @s.rb_time_timespec(Rational(3, 2)) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == 1 - nsec.should be_kind_of(Integer) + nsec.should.is_a?(Integer) nsec.should == 500000000 end it "creates a timespec for a negative Fixnum" do sec, nsec = @s.rb_time_timespec(-1232141421) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == -1232141421 - nsec.should be_kind_of(Integer) + nsec.should.is_a?(Integer) nsec.should == 0 end it "creates a timespec for a negative Float" do sec, nsec = @s.rb_time_timespec(-1.5) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == -2 - nsec.should be_kind_of(Integer) + nsec.should.is_a?(Integer) nsec.should == 500000000 end it "creates a timespec for a negative Rational" do sec, nsec = @s.rb_time_timespec(Rational(-3, 2)) - sec.should be_kind_of(Integer) + sec.should.is_a?(Integer) sec.should == -2 - nsec.should be_kind_of(Integer) + nsec.should.is_a?(Integer) nsec.should == 500000000 end @@ -261,7 +261,7 @@ describe "when offset given is within range of -86400 and 86400 (exclusive)" do it "sets time's is_gmt to false" do - @s.rb_time_timespec_new(1447087832, 476451125, 0).gmt?.should be_false + @s.rb_time_timespec_new(1447087832, 476451125, 0).gmt?.should == false end it "sets time's offset to the offset given" do @@ -270,7 +270,7 @@ end it "returns time object in UTC if offset given equals INT_MAX - 1" do - @s.rb_time_timespec_new(1447087832, 476451125, 0x7ffffffe).utc?.should be_true + @s.rb_time_timespec_new(1447087832, 476451125, 0x7ffffffe).utc?.should == true end it "returns time object in localtime if offset given equals INT_MAX" do @@ -280,13 +280,13 @@ end it "raises an ArgumentError if offset passed is not within range of -86400 and 86400 (exclusive)" do - -> { @s.rb_time_timespec_new(1447087832, 476451125, 86400) }.should raise_error(ArgumentError) - -> { @s.rb_time_timespec_new(1447087832, 476451125, -86400) }.should raise_error(ArgumentError) + -> { @s.rb_time_timespec_new(1447087832, 476451125, 86400) }.should.raise(ArgumentError) + -> { @s.rb_time_timespec_new(1447087832, 476451125, -86400) }.should.raise(ArgumentError) end it "doesn't call Time.at directly" do Time.should_not_receive(:at) - @s.rb_time_timespec_new(1447087832, 476451125, 32400).should be_kind_of(Time) + @s.rb_time_timespec_new(1447087832, 476451125, 32400).should.is_a?(Time) end end @@ -294,7 +294,7 @@ it "fills a struct timespec with the current time" do now = Time.now time = @s.rb_time_from_timespec(now.utc_offset) - time.should be_an_instance_of(Time) + time.should.instance_of?(Time) (time - now).should be_close(0, TIME_TOLERANCE) end end diff --git a/spec/ruby/optional/capi/tracepoint_spec.rb b/spec/ruby/optional/capi/tracepoint_spec.rb index 2043b7c9418d71..8775715e04c47e 100644 --- a/spec/ruby/optional/capi/tracepoint_spec.rb +++ b/spec/ruby/optional/capi/tracepoint_spec.rb @@ -14,7 +14,7 @@ describe "rb_tracepoint_new" do it "returns a tracepoint object" do @trace = @s.rb_tracepoint_new(7) - @trace.should be_an_instance_of(TracePoint) + @trace.should.instance_of?(TracePoint) @trace.should_not.enabled? end diff --git a/spec/ruby/optional/capi/typed_data_spec.rb b/spec/ruby/optional/capi/typed_data_spec.rb index 6d1398a1a0b9ab..8eaf7751ba7bf0 100644 --- a/spec/ruby/optional/capi/typed_data_spec.rb +++ b/spec/ruby/optional/capi/typed_data_spec.rb @@ -30,7 +30,7 @@ it "throws an exception for a wrong type" do a = @s.typed_wrap_struct(1024) - -> { @s.typed_get_struct_other(a) }.should raise_error(TypeError) + -> { @s.typed_get_struct_other(a) }.should.raise(TypeError) end it "unwraps data for a parent type" do @@ -63,7 +63,7 @@ -> { a = @s.typed_wrap_struct(1024) @s.rb_check_type(a, a) - }.should raise_error(TypeError) { |e| + }.should.raise(TypeError) { |e| e.message.should == 'wrong argument type Object (expected Data)' } end @@ -82,7 +82,7 @@ it "raises an error for different types" do a = @s.typed_wrap_struct(1024) - -> { @s.rb_check_typeddata_different_type(a) }.should raise_error(TypeError) + -> { @s.rb_check_typeddata_different_type(a) }.should.raise(TypeError) end end diff --git a/spec/ruby/optional/capi/util_spec.rb b/spec/ruby/optional/capi/util_spec.rb index 31754af0510b34..dd3cbb654982cf 100644 --- a/spec/ruby/optional/capi/util_spec.rb +++ b/spec/ruby/optional/capi/util_spec.rb @@ -21,11 +21,11 @@ end it "raises an ArgumentError if there are insufficient arguments" do - -> { @o.rb_scan_args([1, 2], "3", 0, @acc) }.should raise_error(ArgumentError, "wrong number of arguments (given 2, expected 3)") + -> { @o.rb_scan_args([1, 2], "3", 0, @acc) }.should.raise(ArgumentError, "wrong number of arguments (given 2, expected 3)") end it "raises an ArgumentError if there are too many arguments" do - -> { @o.rb_scan_args([1, 2, 3, 4], "3", 0, @acc) }.should raise_error(ArgumentError, "wrong number of arguments (given 4, expected 3)") + -> { @o.rb_scan_args([1, 2, 3, 4], "3", 0, @acc) }.should.raise(ArgumentError, "wrong number of arguments (given 4, expected 3)") end it "assigns the required and optional arguments scanned" do @@ -118,14 +118,14 @@ it "rejects the use of nil as a hash" do -> { @o.rb_scan_args([1, nil], "1:", 2, @acc) - }.should raise_error(ArgumentError, "wrong number of arguments (given 2, expected 1)") + }.should.raise(ArgumentError, "wrong number of arguments (given 2, expected 1)") ScratchPad.recorded.should == [] end it "rejects the use of of a non-Hash as keywords" do -> { @o.rb_scan_args([42], ":", 1, @acc) - }.should raise_error(ArgumentError, "wrong number of arguments (given 1, expected 0)") + }.should.raise(ArgumentError, "wrong number of arguments (given 1, expected 0)") ScratchPad.recorded.should == [] end @@ -193,7 +193,7 @@ it "raises an error if a required argument is not in the hash" do h = { :a => 7, :c => 12, :b => 5 } - -> { @o.rb_get_kwargs(h, [:b, :d], 2, 0) }.should raise_error(ArgumentError, "missing keyword: :d") + -> { @o.rb_get_kwargs(h, [:b, :d], 2, 0) }.should.raise(ArgumentError, "missing keyword: :d") h.should == {:a => 7, :c => 12} end @@ -205,7 +205,7 @@ it "raises an error if there are additional arguments and optional is positive" do h = { :a => 7, :c => 12, :b => 5 } - -> { @o.rb_get_kwargs(h, [:b, :a], 2, 0) }.should raise_error(ArgumentError, "unknown keyword: :c") + -> { @o.rb_get_kwargs(h, [:b, :a], 2, 0) }.should.raise(ArgumentError, "unknown keyword: :c") h.should == {:c => 12} end @@ -219,7 +219,7 @@ platform_is c_long_size: 64 do describe "rb_long2int" do it "raises a RangeError if the value is outside the range of a C int" do - -> { @o.rb_long2int(0xffff_ffff_ffff) }.should raise_error(RangeError) + -> { @o.rb_long2int(0xffff_ffff_ffff) }.should.raise(RangeError) end end @@ -265,7 +265,7 @@ describe "rb_sourceline" do it "returns the current ruby file" do - @o.rb_sourceline.should be_kind_of(Integer) + @o.rb_sourceline.should.is_a?(Integer) end end diff --git a/spec/ruby/security/cve_2010_1330_spec.rb b/spec/ruby/security/cve_2010_1330_spec.rb index 25944395500adb..8867fb71354b5e 100644 --- a/spec/ruby/security/cve_2010_1330_spec.rb +++ b/spec/ruby/security/cve_2010_1330_spec.rb @@ -14,6 +14,6 @@ str.force_encoding Encoding::UTF_8 -> { str.gsub(/ { "0123456789".unpack("@#{pos}C10") - }.should raise_error(RangeError, /pack length too big/) + }.should.raise(RangeError, /pack length too big/) end end diff --git a/spec/ruby/security/cve_2018_8779_spec.rb b/spec/ruby/security/cve_2018_8779_spec.rb index 603dcf497bfe41..6d573ea7fd0d35 100644 --- a/spec/ruby/security/cve_2018_8779_spec.rb +++ b/spec/ruby/security/cve_2018_8779_spec.rb @@ -18,13 +18,13 @@ it "UNIXServer.open by raising an exception when there is a NUL byte" do -> { UNIXServer.open(@path+"\0") - }.should raise_error(ArgumentError, /(path name|string) contains null byte/) + }.should.raise(ArgumentError, /(path name|string) contains null byte/) end it "UNIXSocket.open by raising an exception when there is a NUL byte" do -> { UNIXSocket.open(@path+"\0") - }.should raise_error(ArgumentError, /(path name|string) contains null byte/) + }.should.raise(ArgumentError, /(path name|string) contains null byte/) end end end diff --git a/spec/ruby/security/cve_2018_8780_spec.rb b/spec/ruby/security/cve_2018_8780_spec.rb index 9942e07ee2ff96..dc8c6bcc9b70b6 100644 --- a/spec/ruby/security/cve_2018_8780_spec.rb +++ b/spec/ruby/security/cve_2018_8780_spec.rb @@ -8,36 +8,36 @@ it "Dir.glob by raising an exception when there is a NUL byte" do -> { Dir.glob([[@root, File.join(@root, "*")].join("\0")]) - }.should raise_error(ArgumentError, /(path name|string) contains null byte/) + }.should.raise(ArgumentError, /(path name|string) contains null byte/) end it "Dir.entries by raising an exception when there is a NUL byte" do -> { Dir.entries(@root+"\0") - }.should raise_error(ArgumentError, /(path name|string) contains null byte/) + }.should.raise(ArgumentError, /(path name|string) contains null byte/) end it "Dir.foreach by raising an exception when there is a NUL byte" do -> { Dir.foreach(@root+"\0").to_a - }.should raise_error(ArgumentError, /(path name|string) contains null byte/) + }.should.raise(ArgumentError, /(path name|string) contains null byte/) end it "Dir.empty? by raising an exception when there is a NUL byte" do -> { Dir.empty?(@root+"\0") - }.should raise_error(ArgumentError, /(path name|string) contains null byte/) + }.should.raise(ArgumentError, /(path name|string) contains null byte/) end it "Dir.children by raising an exception when there is a NUL byte" do -> { Dir.children(@root+"\0") - }.should raise_error(ArgumentError, /(path name|string) contains null byte/) + }.should.raise(ArgumentError, /(path name|string) contains null byte/) end it "Dir.each_child by raising an exception when there is a NUL byte" do -> { Dir.each_child(@root+"\0").to_a - }.should raise_error(ArgumentError, /(path name|string) contains null byte/) + }.should.raise(ArgumentError, /(path name|string) contains null byte/) end end diff --git a/spec/ruby/shared/basicobject/method_missing.rb b/spec/ruby/shared/basicobject/method_missing.rb index 4871603dcef1bb..330f6a49223790 100644 --- a/spec/ruby/shared/basicobject/method_missing.rb +++ b/spec/ruby/shared/basicobject/method_missing.rb @@ -24,15 +24,15 @@ describe :method_missing_module, shared: true do describe "for a Module" do it "raises a NoMethodError when an undefined method is called" do - -> { @object.no_such_method }.should raise_error(NoMethodError) + -> { @object.no_such_method }.should.raise(NoMethodError) end it "raises a NoMethodError when a protected method is called" do - -> { @object.method_protected }.should raise_error(NoMethodError) + -> { @object.method_protected }.should.raise(NoMethodError) end it "raises a NoMethodError when a private method is called" do - -> { @object.method_private }.should raise_error(NoMethodError) + -> { @object.method_private }.should.raise(NoMethodError) end end end @@ -60,15 +60,15 @@ describe :method_missing_class, shared: true do describe "for a Class" do it "raises a NoMethodError when an undefined method is called" do - -> { @object.no_such_method }.should raise_error(NoMethodError) + -> { @object.no_such_method }.should.raise(NoMethodError) end it "raises a NoMethodError when a protected method is called" do - -> { @object.method_protected }.should raise_error(NoMethodError) + -> { @object.method_protected }.should.raise(NoMethodError) end it "raises a NoMethodError when a private method is called" do - -> { @object.method_private }.should raise_error(NoMethodError) + -> { @object.method_private }.should.raise(NoMethodError) end end end @@ -100,15 +100,15 @@ describe :method_missing_instance, shared: true do describe "for an instance" do it "raises a NoMethodError when an undefined method is called" do - -> { @object.new.no_such_method }.should raise_error(NoMethodError) + -> { @object.new.no_such_method }.should.raise(NoMethodError) end it "raises a NoMethodError when a protected method is called" do - -> { @object.new.method_protected }.should raise_error(NoMethodError) + -> { @object.new.method_protected }.should.raise(NoMethodError) end it "raises a NoMethodError when a private method is called" do - -> { @object.new.method_private }.should raise_error(NoMethodError) + -> { @object.new.method_private }.should.raise(NoMethodError) end it 'sets the receiver of the raised NoMethodError' do diff --git a/spec/ruby/shared/basicobject/send.rb b/spec/ruby/shared/basicobject/send.rb index 625aaa29179679..d38aea975e3be2 100644 --- a/spec/ruby/shared/basicobject/send.rb +++ b/spec/ruby/shared/basicobject/send.rb @@ -30,10 +30,10 @@ def self.bar end it "raises a TypeError if the method name is not a string or symbol" do - -> { SendSpecs.send(@method, nil) }.should raise_error(TypeError, /not a symbol nor a string/) - -> { SendSpecs.send(@method, 42) }.should raise_error(TypeError, /not a symbol nor a string/) - -> { SendSpecs.send(@method, 3.14) }.should raise_error(TypeError, /not a symbol nor a string/) - -> { SendSpecs.send(@method, true) }.should raise_error(TypeError, /not a symbol nor a string/) + -> { SendSpecs.send(@method, nil) }.should.raise(TypeError, /not a symbol nor a string/) + -> { SendSpecs.send(@method, 42) }.should.raise(TypeError, /not a symbol nor a string/) + -> { SendSpecs.send(@method, 3.14) }.should.raise(TypeError, /not a symbol nor a string/) + -> { SendSpecs.send(@method, true) }.should.raise(TypeError, /not a symbol nor a string/) end it "raises a NameError if the corresponding method can't be found" do @@ -42,7 +42,7 @@ def bar 'done' end end - -> { SendSpecs::Foo.new.send(@method, :syegsywhwua) }.should raise_error(NameError) + -> { SendSpecs::Foo.new.send(@method, :syegsywhwua) }.should.raise(NameError) end it "raises a NameError if the corresponding singleton method can't be found" do @@ -51,12 +51,12 @@ def self.bar 'done' end end - -> { SendSpecs::Foo.send(@method, :baz) }.should raise_error(NameError) + -> { SendSpecs::Foo.send(@method, :baz) }.should.raise(NameError) end it "raises an ArgumentError if no arguments are given" do class SendSpecs::Foo; end - -> { SendSpecs::Foo.new.send @method }.should raise_error(ArgumentError) + -> { SendSpecs::Foo.new.send @method }.should.raise(ArgumentError) end it "raises an ArgumentError if called with more arguments than available parameters" do @@ -64,7 +64,7 @@ class SendSpecs::Foo def bar; end end - -> { SendSpecs::Foo.new.send(@method, :bar, :arg) }.should raise_error(ArgumentError) + -> { SendSpecs::Foo.new.send(@method, :bar, :arg) }.should.raise(ArgumentError) end it "raises an ArgumentError if called with fewer arguments than required parameters" do @@ -72,7 +72,7 @@ class SendSpecs::Foo def foo(arg); end end - -> { SendSpecs::Foo.new.send(@method, :foo) }.should raise_error(ArgumentError) + -> { SendSpecs::Foo.new.send(@method, :foo) }.should.raise(ArgumentError) end it "succeeds if passed an arbitrary number of arguments as a splat parameter" do diff --git a/spec/ruby/shared/enumerable/minmax.rb b/spec/ruby/shared/enumerable/minmax.rb index 8af2626d2a779d..db95ef9c78374a 100644 --- a/spec/ruby/shared/enumerable/minmax.rb +++ b/spec/ruby/shared/enumerable/minmax.rb @@ -14,11 +14,11 @@ end it "raises a NoMethodError for elements without #<=>" do - -> { @incomparable_enum.minmax }.should raise_error(NoMethodError) + -> { @incomparable_enum.minmax }.should.raise(NoMethodError) end it "raises an ArgumentError when elements are incompatible" do - -> { @incompatible_enum.minmax }.should raise_error(ArgumentError) - -> { @enum.minmax{ |a, b| nil } }.should raise_error(ArgumentError) + -> { @incompatible_enum.minmax }.should.raise(ArgumentError) + -> { @enum.minmax{ |a, b| nil } }.should.raise(ArgumentError) end end diff --git a/spec/ruby/shared/file/directory.rb b/spec/ruby/shared/file/directory.rb index 8ba933a601ffab..84f8f1a958b332 100644 --- a/spec/ruby/shared/file/directory.rb +++ b/spec/ruby/shared/file/directory.rb @@ -12,24 +12,24 @@ end it "returns true if the argument is a directory" do - @object.send(@method, @dir).should be_true + @object.send(@method, @dir).should == true end it "returns false if the argument is not a directory" do - @object.send(@method, @file).should be_false + @object.send(@method, @file).should == false end it "accepts an object that has a #to_path method" do - @object.send(@method, mock_to_path(@dir)).should be_true + @object.send(@method, mock_to_path(@dir)).should == true end it "raises a TypeError when passed an Integer" do - -> { @object.send(@method, 1) }.should raise_error(TypeError) - -> { @object.send(@method, bignum_value) }.should raise_error(TypeError) + -> { @object.send(@method, 1) }.should.raise(TypeError) + -> { @object.send(@method, bignum_value) }.should.raise(TypeError) end it "raises a TypeError when passed nil" do - -> { @object.send(@method, nil) }.should raise_error(TypeError) + -> { @object.send(@method, nil) }.should.raise(TypeError) end end @@ -47,13 +47,13 @@ end it "returns false if the argument is an IO that's not a directory" do - @object.send(@method, STDIN).should be_false + @object.send(@method, STDIN).should == false end platform_is_not :windows do it "returns true if the argument is an IO that is a directory" do File.open(@dir, "r") do |f| - @object.send(@method, f).should be_true + @object.send(@method, f).should == true end end end @@ -61,6 +61,6 @@ it "calls #to_io to convert a non-IO object" do io = mock('FileDirectoryIO') io.should_receive(:to_io).and_return(STDIN) - @object.send(@method, io).should be_false + @object.send(@method, io).should == false end end diff --git a/spec/ruby/shared/file/executable.rb b/spec/ruby/shared/file/executable.rb index baa156de9862dd..0fc65cf8669fa4 100644 --- a/spec/ruby/shared/file/executable.rb +++ b/spec/ruby/shared/file/executable.rb @@ -31,13 +31,13 @@ end it "raises an ArgumentError if not passed one argument" do - -> { @object.send(@method) }.should raise_error(ArgumentError) + -> { @object.send(@method) }.should.raise(ArgumentError) end it "raises a TypeError if not passed a String type" do - -> { @object.send(@method, 1) }.should raise_error(TypeError) - -> { @object.send(@method, nil) }.should raise_error(TypeError) - -> { @object.send(@method, false) }.should raise_error(TypeError) + -> { @object.send(@method, 1) }.should.raise(TypeError) + -> { @object.send(@method, nil) }.should.raise(TypeError) + -> { @object.send(@method, false) }.should.raise(TypeError) end platform_is_not :windows do diff --git a/spec/ruby/shared/file/executable_real.rb b/spec/ruby/shared/file/executable_real.rb index bf2734ea071fdf..90b7a41ba76413 100644 --- a/spec/ruby/shared/file/executable_real.rb +++ b/spec/ruby/shared/file/executable_real.rb @@ -29,13 +29,13 @@ end it "raises an ArgumentError if not passed one argument" do - -> { @object.send(@method) }.should raise_error(ArgumentError) + -> { @object.send(@method) }.should.raise(ArgumentError) end it "raises a TypeError if not passed a String type" do - -> { @object.send(@method, 1) }.should raise_error(TypeError) - -> { @object.send(@method, nil) }.should raise_error(TypeError) - -> { @object.send(@method, false) }.should raise_error(TypeError) + -> { @object.send(@method, 1) }.should.raise(TypeError) + -> { @object.send(@method, nil) }.should.raise(TypeError) + -> { @object.send(@method, false) }.should.raise(TypeError) end platform_is_not :windows do diff --git a/spec/ruby/shared/file/exist.rb b/spec/ruby/shared/file/exist.rb index 67424146c58134..5075fa74b9b1fe 100644 --- a/spec/ruby/shared/file/exist.rb +++ b/spec/ruby/shared/file/exist.rb @@ -5,12 +5,12 @@ end it "raises an ArgumentError if not passed one argument" do - -> { @object.send(@method) }.should raise_error(ArgumentError) - -> { @object.send(@method, __FILE__, __FILE__) }.should raise_error(ArgumentError) + -> { @object.send(@method) }.should.raise(ArgumentError) + -> { @object.send(@method, __FILE__, __FILE__) }.should.raise(ArgumentError) end it "raises a TypeError if not passed a String type" do - -> { @object.send(@method, nil) }.should raise_error(TypeError) + -> { @object.send(@method, nil) }.should.raise(TypeError) end it "accepts an object that has a #to_path method" do diff --git a/spec/ruby/shared/file/file.rb b/spec/ruby/shared/file/file.rb index c1748a88b31437..18477cff554ebe 100644 --- a/spec/ruby/shared/file/file.rb +++ b/spec/ruby/shared/file/file.rb @@ -34,12 +34,12 @@ end it "raises an ArgumentError if not passed one argument" do - -> { @object.send(@method) }.should raise_error(ArgumentError) - -> { @object.send(@method, @null, @file) }.should raise_error(ArgumentError) + -> { @object.send(@method) }.should.raise(ArgumentError) + -> { @object.send(@method, @null, @file) }.should.raise(ArgumentError) end it "raises a TypeError if not passed a String type" do - -> { @object.send(@method, nil) }.should raise_error(TypeError) - -> { @object.send(@method, 1) }.should raise_error(TypeError) + -> { @object.send(@method, nil) }.should.raise(TypeError) + -> { @object.send(@method, 1) }.should.raise(TypeError) end end diff --git a/spec/ruby/shared/file/grpowned.rb b/spec/ruby/shared/file/grpowned.rb index 24e84c28e3c4c3..07a5a69e1adb8b 100644 --- a/spec/ruby/shared/file/grpowned.rb +++ b/spec/ruby/shared/file/grpowned.rb @@ -11,11 +11,11 @@ platform_is_not :windows do it "returns true if the file exist" do - @object.send(@method, @file).should be_true + @object.send(@method, @file).should == true end it "accepts an object that has a #to_path method" do - @object.send(@method, mock_to_path(@file)).should be_true + @object.send(@method, mock_to_path(@file)).should == true end it 'takes non primary groups into account' do @@ -33,7 +33,7 @@ platform_is :windows do it "returns false if the file exist" do - @object.send(@method, @file).should be_false + @object.send(@method, @file).should == false end end end diff --git a/spec/ruby/shared/file/identical.rb b/spec/ruby/shared/file/identical.rb index b7a2904839a603..628abd4f48716e 100644 --- a/spec/ruby/shared/file/identical.rb +++ b/spec/ruby/shared/file/identical.rb @@ -25,9 +25,9 @@ end it "returns false if any of the files doesn't exist" do - @object.send(@method, @file1, @non_exist).should be_false - @object.send(@method, @non_exist, @file1).should be_false - @object.send(@method, @non_exist, @non_exist).should be_false + @object.send(@method, @file1, @non_exist).should == false + @object.send(@method, @non_exist, @file1).should == false + @object.send(@method, @non_exist, @non_exist).should == false end it "accepts an object that has a #to_path method" do @@ -35,17 +35,17 @@ end it "raises an ArgumentError if not passed two arguments" do - -> { @object.send(@method, @file1, @file2, @link) }.should raise_error(ArgumentError) - -> { @object.send(@method, @file1) }.should raise_error(ArgumentError) + -> { @object.send(@method, @file1, @file2, @link) }.should.raise(ArgumentError) + -> { @object.send(@method, @file1) }.should.raise(ArgumentError) end it "raises a TypeError if not passed String types" do - -> { @object.send(@method, 1,1) }.should raise_error(TypeError) + -> { @object.send(@method, 1,1) }.should.raise(TypeError) end it "returns true if both named files are identical" do - @object.send(@method, @file1, @file1).should be_true - @object.send(@method, @link, @link).should be_true - @object.send(@method, @file1, @file2).should be_false + @object.send(@method, @file1, @file1).should == true + @object.send(@method, @link, @link).should == true + @object.send(@method, @file1, @file2).should == false end end diff --git a/spec/ruby/shared/file/size.rb b/spec/ruby/shared/file/size.rb index cba99fe6a5803c..fa198ed23263f7 100644 --- a/spec/ruby/shared/file/size.rb +++ b/spec/ruby/shared/file/size.rb @@ -56,7 +56,7 @@ end it "raises an error if file_name doesn't exist" do - -> {@object.send(@method, @missing)}.should raise_error(Errno::ENOENT) + -> {@object.send(@method, @missing)}.should.raise(Errno::ENOENT) end end diff --git a/spec/ruby/shared/file/world_readable.rb b/spec/ruby/shared/file/world_readable.rb index 1dce7a580fe9bc..c8946366ad86b9 100644 --- a/spec/ruby/shared/file/world_readable.rb +++ b/spec/ruby/shared/file/world_readable.rb @@ -14,24 +14,24 @@ platform_is_not :windows do it "returns nil if the file is chmod 600" do File.chmod(0600, @file) - @object.world_readable?(@file).should be_nil + @object.world_readable?(@file).should == nil end it "returns nil if the file is chmod 000" do File.chmod(0000, @file) - @object.world_readable?(@file).should be_nil + @object.world_readable?(@file).should == nil end it "returns nil if the file is chmod 700" do File.chmod(0700, @file) - @object.world_readable?(@file).should be_nil + @object.world_readable?(@file).should == nil end end # We don't specify what the Integer is because it's system dependent it "returns an Integer if the file is chmod 644" do File.chmod(0644, @file) - @object.world_readable?(@file).should be_an_instance_of(Integer) + @object.world_readable?(@file).should.instance_of?(Integer) end it "returns an Integer if the file is a directory and chmod 644" do @@ -39,7 +39,7 @@ Dir.mkdir(dir) Dir.should.exist?(dir) File.chmod(0644, dir) - @object.world_readable?(dir).should be_an_instance_of(Integer) + @object.world_readable?(dir).should.instance_of?(Integer) Dir.rmdir(dir) end diff --git a/spec/ruby/shared/file/world_writable.rb b/spec/ruby/shared/file/world_writable.rb index 7ed252dcf3c0f1..fcff09636e22a0 100644 --- a/spec/ruby/shared/file/world_writable.rb +++ b/spec/ruby/shared/file/world_writable.rb @@ -14,23 +14,23 @@ platform_is_not :windows do it "returns nil if the file is chmod 600" do File.chmod(0600, @file) - @object.world_writable?(@file).should be_nil + @object.world_writable?(@file).should == nil end it "returns nil if the file is chmod 000" do File.chmod(0000, @file) - @object.world_writable?(@file).should be_nil + @object.world_writable?(@file).should == nil end it "returns nil if the file is chmod 700" do File.chmod(0700, @file) - @object.world_writable?(@file).should be_nil + @object.world_writable?(@file).should == nil end # We don't specify what the Integer is because it's system dependent it "returns an Integer if the file is chmod 777" do File.chmod(0777, @file) - @object.world_writable?(@file).should be_an_instance_of(Integer) + @object.world_writable?(@file).should.instance_of?(Integer) end it "returns an Integer if the file is a directory and chmod 777" do @@ -38,7 +38,7 @@ Dir.mkdir(dir) Dir.should.exist?(dir) File.chmod(0777, dir) - @object.world_writable?(dir).should be_an_instance_of(Integer) + @object.world_writable?(dir).should.instance_of?(Integer) Dir.rmdir(dir) end end diff --git a/spec/ruby/shared/file/writable_real.rb b/spec/ruby/shared/file/writable_real.rb index b4a0a58c6e4391..4602996187b1c2 100644 --- a/spec/ruby/shared/file/writable_real.rb +++ b/spec/ruby/shared/file/writable_real.rb @@ -16,13 +16,13 @@ end it "raises an ArgumentError if not passed one argument" do - -> { File.writable_real? }.should raise_error(ArgumentError) + -> { File.writable_real? }.should.raise(ArgumentError) end it "raises a TypeError if not passed a String type" do - -> { @object.send(@method, 1) }.should raise_error(TypeError) - -> { @object.send(@method, nil) }.should raise_error(TypeError) - -> { @object.send(@method, false) }.should raise_error(TypeError) + -> { @object.send(@method, 1) }.should.raise(TypeError) + -> { @object.send(@method, nil) }.should.raise(TypeError) + -> { @object.send(@method, false) }.should.raise(TypeError) end platform_is_not :windows do diff --git a/spec/ruby/shared/file/zero.rb b/spec/ruby/shared/file/zero.rb index 6a9399a0214756..94285c14c57248 100644 --- a/spec/ruby/shared/file/zero.rb +++ b/spec/ruby/shared/file/zero.rb @@ -40,13 +40,13 @@ end it "raises an ArgumentError if not passed one argument" do - -> { File.zero? }.should raise_error(ArgumentError) + -> { File.zero? }.should.raise(ArgumentError) end it "raises a TypeError if not passed a String type" do - -> { @object.send(@method, nil) }.should raise_error(TypeError) - -> { @object.send(@method, true) }.should raise_error(TypeError) - -> { @object.send(@method, false) }.should raise_error(TypeError) + -> { @object.send(@method, nil) }.should.raise(TypeError) + -> { @object.send(@method, true) }.should.raise(TypeError) + -> { @object.send(@method, false) }.should.raise(TypeError) end it "returns true inside a block opening a file if it is empty" do @@ -57,7 +57,7 @@ # See https://bugs.ruby-lang.org/issues/449 for background it "returns true or false for a directory" do - @object.send(@method, @dir).should be_true_or_false + [true, false].should.include? @object.send(@method, @dir) end end diff --git a/spec/ruby/shared/hash/key_error.rb b/spec/ruby/shared/hash/key_error.rb index 54dcb89e919b52..0044cd5de238ea 100644 --- a/spec/ruby/shared/hash/key_error.rb +++ b/spec/ruby/shared/hash/key_error.rb @@ -2,21 +2,21 @@ it "raises a KeyError" do -> { @method.call(@object, 'foo') - }.should raise_error(KeyError) + }.should.raise(KeyError) end it "sets the Hash as the receiver of KeyError" do -> { @method.call(@object, 'foo') - }.should raise_error(KeyError) { |err| - err.receiver.should equal(@object) + }.should.raise(KeyError) { |err| + err.receiver.should.equal?(@object) } end it "sets the unmatched key as the key of KeyError" do -> { @method.call(@object, 'foo') - }.should raise_error(KeyError) { |err| + }.should.raise(KeyError) { |err| err.key.to_s.should == 'foo' } end diff --git a/spec/ruby/shared/io/putc.rb b/spec/ruby/shared/io/putc.rb index cdf18ac9fd6313..56902ccad5e125 100644 --- a/spec/ruby/shared/io/putc.rb +++ b/spec/ruby/shared/io/putc.rb @@ -40,18 +40,18 @@ it "raises IOError on a closed stream" do @io.close - -> { @io_object.send(@method, "a") }.should raise_error(IOError) + -> { @io_object.send(@method, "a") }.should.raise(IOError) end it "raises a TypeError when passed nil" do - -> { @io_object.send(@method, nil) }.should raise_error(TypeError) + -> { @io_object.send(@method, nil) }.should.raise(TypeError) end it "raises a TypeError when passed false" do - -> { @io_object.send(@method, false) }.should raise_error(TypeError) + -> { @io_object.send(@method, false) }.should.raise(TypeError) end it "raises a TypeError when passed true" do - -> { @io_object.send(@method, true) }.should raise_error(TypeError) + -> { @io_object.send(@method, true) }.should.raise(TypeError) end end diff --git a/spec/ruby/shared/kernel/at_exit.rb b/spec/ruby/shared/kernel/at_exit.rb index d57ab73920f3fa..a868ed1e0ec36b 100644 --- a/spec/ruby/shared/kernel/at_exit.rb +++ b/spec/ruby/shared/kernel/at_exit.rb @@ -60,7 +60,7 @@ result = ruby_exe('{', options: "-r#{script}", args: "2>&1", exit_status: 1) $?.should_not.success? result.should.include?("handler ran\n") - result.should include("SyntaxError") + result.should.include?("SyntaxError") end it "calls the nested handler right after the outer one if a handler is nested into another handler" do diff --git a/spec/ruby/shared/kernel/complex.rb b/spec/ruby/shared/kernel/complex.rb index 98ee0b2b3fbea7..6e0764dd3d2ea1 100644 --- a/spec/ruby/shared/kernel/complex.rb +++ b/spec/ruby/shared/kernel/complex.rb @@ -2,7 +2,7 @@ describe :kernel_complex, shared: true do it "returns a Complex object" do - @object.send(@method, '9').should be_an_instance_of(Complex) + @object.send(@method, '9').should.instance_of?(Complex) end it "understands integers" do diff --git a/spec/ruby/shared/kernel/equal.rb b/spec/ruby/shared/kernel/equal.rb index 0a70aec639451e..3b74232922fa5d 100644 --- a/spec/ruby/shared/kernel/equal.rb +++ b/spec/ruby/shared/kernel/equal.rb @@ -2,13 +2,13 @@ describe :object_equal, shared: true do it "returns true if other is identical to self" do obj = Object.new - obj.__send__(@method, obj).should be_true + obj.__send__(@method, obj).should == true end it "returns false if other is not identical to self" do a = Object.new b = Object.new - a.__send__(@method, b).should be_false + a.__send__(@method, b).should == false end it "returns true only if self and other are the same object" do diff --git a/spec/ruby/shared/kernel/object_id.rb b/spec/ruby/shared/kernel/object_id.rb index 099df8ff94c4d2..6469e499039ba4 100644 --- a/spec/ruby/shared/kernel/object_id.rb +++ b/spec/ruby/shared/kernel/object_id.rb @@ -2,7 +2,7 @@ describe :object_id, shared: true do it "returns an integer" do o1 = @object.new - o1.__send__(@method).should be_kind_of(Integer) + o1.__send__(@method).should.is_a?(Integer) end it "returns the same value on all calls to id for a given object" do diff --git a/spec/ruby/shared/kernel/raise.rb b/spec/ruby/shared/kernel/raise.rb index c15eb926bc7b95..07b6a30de2c5f1 100644 --- a/spec/ruby/shared/kernel/raise.rb +++ b/spec/ruby/shared/kernel/raise.rb @@ -7,9 +7,9 @@ -> do @object.raise Exception, "abort" ScratchPad.record :no_abort - end.should raise_error(Exception, "abort") + end.should.raise(Exception, "abort") - ScratchPad.recorded.should be_nil + ScratchPad.recorded.should == nil end it "accepts an exception that implements to_hash" do @@ -19,7 +19,7 @@ def to_hash end end error = custom_error.new - -> { @object.raise(error) }.should raise_error(custom_error) + -> { @object.raise(error) }.should.raise(custom_error) end it "allows the message parameter to be a hash" do @@ -30,7 +30,7 @@ def initialize(data) end end - -> { @object.raise(data_error, {data: 42}) }.should raise_error(data_error) do |ex| + -> { @object.raise(data_error, {data: 42}) }.should.raise(data_error) do |ex| ex.data.should == {data: 42} end end @@ -44,22 +44,22 @@ def initialize(data) end end - -> { @object.raise(data_error, data: 42) }.should raise_error(data_error) do |ex| + -> { @object.raise(data_error, data: 42) }.should.raise(data_error) do |ex| ex.data.should == {data: 42} end end it "raises RuntimeError if no exception class is given" do - -> { @object.raise }.should raise_error(RuntimeError, "") + -> { @object.raise }.should.raise(RuntimeError, "") end it "raises a given Exception instance" do error = RuntimeError.new - -> { @object.raise(error) }.should raise_error(error) + -> { @object.raise(error) }.should.raise(error) end it "raises a RuntimeError if string given" do - -> { @object.raise("a bad thing") }.should raise_error(RuntimeError, "a bad thing") + -> { @object.raise("a bad thing") }.should.raise(RuntimeError, "a bad thing") end it "passes no arguments to the constructor when given only an exception class" do @@ -67,29 +67,29 @@ def initialize(data) def initialize end end - -> { @object.raise(klass) }.should raise_error(klass) { |e| e.message.should == klass.to_s } + -> { @object.raise(klass) }.should.raise(klass) { |e| e.message.should == klass.to_s } end it "raises a TypeError when passed a non-Exception object" do - -> { @object.raise(Object.new) }.should raise_error(TypeError, "exception class/object expected") - -> { @object.raise(Object.new, "message") }.should raise_error(TypeError, "exception class/object expected") - -> { @object.raise(Object.new, "message", []) }.should raise_error(TypeError, "exception class/object expected") + -> { @object.raise(Object.new) }.should.raise(TypeError, "exception class/object expected") + -> { @object.raise(Object.new, "message") }.should.raise(TypeError, "exception class/object expected") + -> { @object.raise(Object.new, "message", []) }.should.raise(TypeError, "exception class/object expected") end it "raises a TypeError when passed true" do - -> { @object.raise(true) }.should raise_error(TypeError, "exception class/object expected") + -> { @object.raise(true) }.should.raise(TypeError, "exception class/object expected") end it "raises a TypeError when passed false" do - -> { @object.raise(false) }.should raise_error(TypeError, "exception class/object expected") + -> { @object.raise(false) }.should.raise(TypeError, "exception class/object expected") end it "raises a TypeError when passed nil" do - -> { @object.raise(nil) }.should raise_error(TypeError, "exception class/object expected") + -> { @object.raise(nil) }.should.raise(TypeError, "exception class/object expected") end it "raises a TypeError when passed a message and an extra argument" do - -> { @object.raise("message", {cause: RuntimeError.new()}) }.should raise_error(TypeError, "exception class/object expected") + -> { @object.raise("message", {cause: RuntimeError.new()}) }.should.raise(TypeError, "exception class/object expected") end it "raises TypeError when passed a non-Exception object but it responds to #exception method that doesn't return an instance of Exception class" do @@ -100,7 +100,7 @@ def e.exception -> { @object.raise e - }.should raise_error(TypeError, "exception object expected") + }.should.raise(TypeError, "exception object expected") end it "re-raises a previously rescued exception without overwriting the backtrace" do @@ -127,7 +127,7 @@ def e.exception it "allows Exception, message, and backtrace parameters" do -> do @object.raise(ArgumentError, "message", caller) - end.should raise_error(ArgumentError, "message") + end.should.raise(ArgumentError, "message") end ruby_version_is "3.4" do @@ -135,7 +135,7 @@ def e.exception it "allows Exception, message, and backtrace_locations parameters" do -> do @object.raise(ArgumentError, "message", locations) - end.should raise_error(ArgumentError, "message") { |error| + end.should.raise(ArgumentError, "message") { |error| error.backtrace_locations.map(&:to_s).should == locations.map(&:to_s) } end @@ -147,21 +147,14 @@ def e.exception it "sets cause to nil when there is no previous exception" do -> do @object.raise("error without a cause") - end.should raise_error(RuntimeError, "error without a cause") do |error| - error.cause.should == nil - end + end.should.raise(RuntimeError, "error without a cause", cause: nil) end it "supports automatic cause chaining from a previous exception" do - -> do - begin - raise StandardError,"first error" - rescue - @object.raise("second error") - end - end.should raise_error(RuntimeError, "second error") do |error| - error.cause.should be_kind_of(StandardError) - error.cause.message.should == "first error" + begin + raise StandardError,"first error" + rescue => cause + -> { @object.raise("second error") }.should.raise(RuntimeError, "second error", cause:) end end end @@ -171,16 +164,14 @@ def e.exception cause = StandardError.new("original error") -> do - @object.raise("new error", cause: cause) - end.should raise_error(RuntimeError, "new error") do |error| - error.cause.should == cause - end + @object.raise("new error", cause:) + end.should.raise(RuntimeError, "new error", cause:) end it "allows setting cause to nil" do -> do @object.raise("error without a cause", cause: nil) - end.should raise_error(RuntimeError, "error without a cause") do |error| + end.should.raise(RuntimeError, "error without a cause") do |error| error.cause.should == nil end end @@ -188,32 +179,29 @@ def e.exception it "raises an ArgumentError when only cause is given" do cause = StandardError.new("cause") -> do - @object.raise(cause: cause) - end.should raise_error(ArgumentError, "only cause is given with no arguments") + @object.raise(cause:) + end.should.raise(ArgumentError, "only cause is given with no arguments") end it "raises an ArgumentError when only cause is given and is nil" do -> do @object.raise(cause: nil) - end.should raise_error(ArgumentError, "only cause is given with no arguments") + end.should.raise(ArgumentError, "only cause is given with no arguments") end it "raises a TypeError when given cause is not an instance of Exception or nil" do cause = Object.new -> do - @object.raise("message", cause: cause) - end.should raise_error(TypeError, "exception object expected") + @object.raise("message", cause:) + end.should.raise(TypeError, "exception object expected") end it "doesn't set given cause when it equals the raised exception" do cause = StandardError.new("cause") -> do - @object.raise(cause, cause: cause) - end.should raise_error(StandardError, "cause") do |error| - error.should == cause - error.cause.should == nil - end + @object.raise(cause, cause:) + end.should.raise(StandardError, "cause", cause: nil) end it "raises ArgumentError when cause creates a circular reference" do @@ -231,19 +219,15 @@ def e.exception end end end - }.should raise_error(ArgumentError, "circular causes") + }.should.raise(ArgumentError, "circular causes") end it "supports exception class with message and cause" do cause = StandardError.new("cause message") -> do - @object.raise(ArgumentError, "argument error message", cause: cause) - end.should raise_error(ArgumentError, "argument error message") do |error| - error.should be_kind_of(ArgumentError) - error.message.should == "argument error message" - error.cause.should == cause - end + @object.raise(ArgumentError, "argument error message", cause:) + end.should.raise(ArgumentError, "argument error message", cause:) end it "supports exception class with message, backtrace and cause" do @@ -251,11 +235,8 @@ def e.exception backtrace = ["line1", "line2"] -> do - @object.raise(ArgumentError, "argument error message", backtrace, cause: cause) - end.should raise_error(ArgumentError, "argument error message") do |error| - error.should be_kind_of(ArgumentError) - error.message.should == "argument error message" - error.cause.should == cause + @object.raise(ArgumentError, "argument error message", backtrace, cause:) + end.should.raise(ArgumentError, "argument error message", cause:) do |error| error.backtrace.should == backtrace end end @@ -268,10 +249,7 @@ def e.exception rescue @object.raise("second error", cause: custom_error) end - end.should raise_error(RuntimeError, "second error") do |error| - error.cause.should be_kind_of(StandardError) - error.cause.message.should == "custom error" - end + end.should.raise(RuntimeError, "second error", cause: custom_error) end it "supports cause: nil, discarding previous exception" do @@ -282,9 +260,7 @@ def e.exception # Explicit nil prevents chaining: @object.raise("second error", cause: nil) end - end.should raise_error(RuntimeError, "second error") do |error| - error.cause.should == nil - end + end.should.raise(RuntimeError, "second error", cause: nil) end end end @@ -310,7 +286,7 @@ def e.exception end end - result.should be_kind_of(RuntimeError) + result.should.is_a?(RuntimeError) result.message.should == "second error" result.cause.should == nil end @@ -338,7 +314,7 @@ def e.exception end end - result.should be_kind_of(RuntimeError) + result.should.is_a?(RuntimeError) result.message.should == "second error" result.cause.should == override_cause end @@ -358,7 +334,7 @@ def e.exception end end - result.should be_kind_of(RuntimeError) + result.should.is_a?(RuntimeError) result.message.should == "new error" # Calling context has no current exception: result.cause.should == nil @@ -382,7 +358,7 @@ def e.exception end end - result.should be_kind_of(RuntimeError) + result.should.is_a?(RuntimeError) result.message.should == "new error" result.cause.should == nil end @@ -397,7 +373,7 @@ def e.exception # Ignore - we expect the TypeError to be raised in the calling context end end - }.should raise_error(TypeError, "exception object expected") + }.should.raise(TypeError, "exception object expected") end it "raises ArgumentError when only cause is given with no arguments" do @@ -409,7 +385,7 @@ def e.exception # Ignore - we expect the ArgumentError to be raised in the calling context end end - }.should raise_error(ArgumentError, "only cause is given with no arguments") + }.should.raise(ArgumentError, "only cause is given with no arguments") end end end diff --git a/spec/ruby/shared/process/abort.rb b/spec/ruby/shared/process/abort.rb index 935637e1c20a15..19f9f1e6a5dab7 100644 --- a/spec/ruby/shared/process/abort.rb +++ b/spec/ruby/shared/process/abort.rb @@ -8,29 +8,29 @@ end it "raises a SystemExit exception" do - -> { @object.abort }.should raise_error(SystemExit) + -> { @object.abort }.should.raise(SystemExit) end it "sets the exception message to the given message" do - -> { @object.abort "message" }.should raise_error { |e| e.message.should == "message" } + -> { @object.abort "message" }.should.raise { |e| e.message.should == "message" } end it "sets the exception status code of 1" do - -> { @object.abort }.should raise_error { |e| e.status.should == 1 } + -> { @object.abort }.should.raise { |e| e.status.should == 1 } end it "prints the specified message to STDERR" do - -> { @object.abort "a message" }.should raise_error(SystemExit) + -> { @object.abort "a message" }.should.raise(SystemExit) $stderr.should =~ /a message/ end it "coerces the argument with #to_str" do str = mock('to_str') str.should_receive(:to_str).any_number_of_times.and_return("message") - -> { @object.abort str }.should raise_error(SystemExit, "message") + -> { @object.abort str }.should.raise(SystemExit, "message") end it "raises TypeError when given a non-String object" do - -> { @object.abort 123 }.should raise_error(TypeError) + -> { @object.abort 123 }.should.raise(TypeError) end end diff --git a/spec/ruby/shared/process/exit.rb b/spec/ruby/shared/process/exit.rb index 1e073614a3c1d0..cacf2f87744920 100644 --- a/spec/ruby/shared/process/exit.rb +++ b/spec/ruby/shared/process/exit.rb @@ -1,13 +1,13 @@ describe :process_exit, shared: true do it "raises a SystemExit with status 0" do - -> { @object.exit }.should raise_error(SystemExit) { |e| + -> { @object.exit }.should.raise(SystemExit) { |e| e.status.should == 0 } end it "raises a SystemExit with the specified status" do [-2**16, -2**8, -8, -1, 0, 1 , 8, 2**8, 2**16].each do |value| - -> { @object.exit(value) }.should raise_error(SystemExit) { |e| + -> { @object.exit(value) }.should.raise(SystemExit) { |e| e.status.should == value } end @@ -15,14 +15,14 @@ it "raises a SystemExit with the specified boolean status" do { true => 0, false => 1 }.each do |value, status| - -> { @object.exit(value) }.should raise_error(SystemExit) { |e| + -> { @object.exit(value) }.should.raise(SystemExit) { |e| e.status.should == status } end end it "raises a SystemExit with message 'exit'" do - -> { @object.exit }.should raise_error(SystemExit) { |e| + -> { @object.exit }.should.raise(SystemExit) { |e| e.message.should == "exit" } end @@ -30,24 +30,24 @@ it "tries to convert the passed argument to an Integer using #to_int" do obj = mock('5') obj.should_receive(:to_int).and_return(5) - -> { @object.exit(obj) }.should raise_error(SystemExit) { |e| + -> { @object.exit(obj) }.should.raise(SystemExit) { |e| e.status.should == 5 } end it "converts the passed Float argument to an Integer" do { -2.2 => -2, -0.1 => 0, 5.5 => 5, 827.999 => 827 }.each do |value, status| - -> { @object.exit(value) }.should raise_error(SystemExit) { |e| + -> { @object.exit(value) }.should.raise(SystemExit) { |e| e.status.should == status } end end it "raises TypeError if can't convert the argument to an Integer" do - -> { @object.exit(Object.new) }.should raise_error(TypeError) - -> { @object.exit('0') }.should raise_error(TypeError) - -> { @object.exit([0]) }.should raise_error(TypeError) - -> { @object.exit(nil) }.should raise_error(TypeError) + -> { @object.exit(Object.new) }.should.raise(TypeError) + -> { @object.exit('0') }.should.raise(TypeError) + -> { @object.exit([0]) }.should.raise(TypeError) + -> { @object.exit(nil) }.should.raise(TypeError) end it "raises the SystemExit in the main thread if it reaches the top-level handler of another thread" do @@ -75,7 +75,7 @@ ScratchPad.recorded.should == [:in_thread, :in_main] # the thread also keeps the exception as its value - -> { t.value }.should raise_error(SystemExit) + -> { t.value }.should.raise(SystemExit) end end diff --git a/spec/ruby/shared/process/fork.rb b/spec/ruby/shared/process/fork.rb index 35e712572f105f..dd595cd93ed13c 100644 --- a/spec/ruby/shared/process/fork.rb +++ b/spec/ruby/shared/process/fork.rb @@ -3,12 +3,12 @@ it "returns false from #respond_to?" do # Workaround for Kernel::Method being public and losing the "non-respond_to? magic" mod = @object.class.name == "KernelSpecs::Method" ? Object.new : @object - mod.respond_to?(:fork).should be_false - mod.respond_to?(:fork, true).should be_false + mod.respond_to?(:fork).should == false + mod.respond_to?(:fork, true).should == false end it "raises a NotImplementedError when called" do - -> { @object.fork }.should raise_error(NotImplementedError) + -> { @object.fork }.should.raise(NotImplementedError) end end diff --git a/spec/ruby/shared/queue/clear.rb b/spec/ruby/shared/queue/clear.rb index 5db5a5b49735ff..742468a859800b 100644 --- a/spec/ruby/shared/queue/clear.rb +++ b/spec/ruby/shared/queue/clear.rb @@ -3,9 +3,9 @@ queue = @object.call queue << Object.new queue << 1 - queue.empty?.should be_false + queue.empty?.should == false queue.clear - queue.empty?.should be_true + queue.empty?.should == true end # TODO: test for atomicity of Queue#clear diff --git a/spec/ruby/shared/queue/close.rb b/spec/ruby/shared/queue/close.rb index 0e7c69acbaeaa6..1b0908c27c746c 100644 --- a/spec/ruby/shared/queue/close.rb +++ b/spec/ruby/shared/queue/close.rb @@ -2,9 +2,9 @@ it "may be called multiple times" do q = @object.call q.close - q.closed?.should be_true + q.closed?.should == true q.close # no effect - q.closed?.should be_true + q.closed?.should == true end it "returns self" do diff --git a/spec/ruby/shared/queue/closed.rb b/spec/ruby/shared/queue/closed.rb index b3cea0c5245293..8a7d65055f228e 100644 --- a/spec/ruby/shared/queue/closed.rb +++ b/spec/ruby/shared/queue/closed.rb @@ -1,12 +1,12 @@ describe :queue_closed?, shared: true do it "returns false initially" do queue = @object.call - queue.closed?.should be_false + queue.closed?.should == false end it "returns true when the queue is closed" do queue = @object.call queue.close - queue.closed?.should be_true + queue.closed?.should == true end end diff --git a/spec/ruby/shared/queue/deque.rb b/spec/ruby/shared/queue/deque.rb index fbd00143f8b810..45cbc4a995ded6 100644 --- a/spec/ruby/shared/queue/deque.rb +++ b/spec/ruby/shared/queue/deque.rb @@ -116,7 +116,7 @@ q = @object.call -> { q.send(@method, true, timeout: 1) - }.should raise_error(ArgumentError, "can't set a timeout if non_block is enabled") + }.should.raise(ArgumentError, "can't set a timeout if non_block is enabled") end it "returns nil for a closed empty queue" do @@ -137,7 +137,7 @@ it "raises a ThreadError if the queue is empty" do q = @object.call - -> { q.send(@method, true) }.should raise_error(ThreadError) + -> { q.send(@method, true) }.should.raise(ThreadError) end it "removes an item from a closed queue" do @@ -150,15 +150,15 @@ it "raises a ThreadError for a closed empty queue" do q = @object.call q.close - -> { q.send(@method, true) }.should raise_error(ThreadError) + -> { q.send(@method, true) }.should.raise(ThreadError) end it "converts true-ish non_blocking argument to true" do q = @object.call - -> { q.send(@method, true) }.should raise_error(ThreadError) - -> { q.send(@method, 1) }.should raise_error(ThreadError) - -> { q.send(@method, "") }.should raise_error(ThreadError) + -> { q.send(@method, true) }.should.raise(ThreadError) + -> { q.send(@method, 1) }.should.raise(ThreadError) + -> { q.send(@method, "") }.should.raise(ThreadError) end end end diff --git a/spec/ruby/shared/queue/empty.rb b/spec/ruby/shared/queue/empty.rb index 4acd831d485615..052ce6ac23ac47 100644 --- a/spec/ruby/shared/queue/empty.rb +++ b/spec/ruby/shared/queue/empty.rb @@ -1,12 +1,12 @@ describe :queue_empty?, shared: true do it "returns true on an empty Queue" do queue = @object.call - queue.empty?.should be_true + queue.empty?.should == true end it "returns false when Queue is not empty" do queue = @object.call queue << Object.new - queue.empty?.should be_false + queue.empty?.should == false end end diff --git a/spec/ruby/shared/queue/enque.rb b/spec/ruby/shared/queue/enque.rb index 8aba02e544d7a0..61d962b78876a1 100644 --- a/spec/ruby/shared/queue/enque.rb +++ b/spec/ruby/shared/queue/enque.rb @@ -13,6 +13,6 @@ q.close -> { q.send @method, Object.new - }.should raise_error(ClosedQueueError) + }.should.raise(ClosedQueueError) end end diff --git a/spec/ruby/shared/queue/freeze.rb b/spec/ruby/shared/queue/freeze.rb index 5dedd005df4975..7f1f72fd7eb6ec 100644 --- a/spec/ruby/shared/queue/freeze.rb +++ b/spec/ruby/shared/queue/freeze.rb @@ -3,6 +3,6 @@ queue = @object.call -> { queue.freeze - }.should raise_error(TypeError, "cannot freeze #{queue}") + }.should.raise(TypeError, "cannot freeze #{queue}") end end diff --git a/spec/ruby/shared/sizedqueue/enque.rb b/spec/ruby/shared/sizedqueue/enque.rb index bab4c407e1df7f..014056acdabfc0 100644 --- a/spec/ruby/shared/sizedqueue/enque.rb +++ b/spec/ruby/shared/sizedqueue/enque.rb @@ -29,7 +29,7 @@ q.size.should == 1 add_to_queue.call q.size.should == 2 - add_to_queue.should raise_error(ThreadError) + add_to_queue.should.raise(ThreadError) end it "interrupts enqueuing threads with ClosedQueueError when the queue is closed" do @@ -37,7 +37,7 @@ q << 1 t = Thread.new { - -> { q.send(@method, 2) }.should raise_error(ClosedQueueError, "queue closed") + -> { q.send(@method, 2) }.should.raise(ClosedQueueError, "queue closed") } Thread.pass until q.num_waiting == 1 @@ -101,13 +101,13 @@ q = @object.call(1) -> { q.send(@method, 2, true, timeout: 1) - }.should raise_error(ArgumentError, "can't set a timeout if non_block is enabled") + }.should.raise(ArgumentError, "can't set a timeout if non_block is enabled") end it "raise ClosedQueueError when closed before enqueued" do q = @object.call(1) q.close - -> { q.send(@method, 2, timeout: 1) }.should raise_error(ClosedQueueError, "queue closed") + -> { q.send(@method, 2, timeout: 1) }.should.raise(ClosedQueueError, "queue closed") end it "interrupts enqueuing threads with ClosedQueueError when the queue is closed" do @@ -115,7 +115,7 @@ q << 1 t = Thread.new { - -> { q.send(@method, 1, timeout: TIME_TOLERANCE) }.should raise_error(ClosedQueueError, "queue closed") + -> { q.send(@method, 1, timeout: TIME_TOLERANCE) }.should.raise(ClosedQueueError, "queue closed") } Thread.pass until q.num_waiting == 1 diff --git a/spec/ruby/shared/sizedqueue/max.rb b/spec/ruby/shared/sizedqueue/max.rb index ea10d24be03b20..167f6692758849 100644 --- a/spec/ruby/shared/sizedqueue/max.rb +++ b/spec/ruby/shared/sizedqueue/max.rb @@ -19,7 +19,7 @@ q.enq 2 q.enq 3 q.max = 2 - (q.size > q.max).should be_true + (q.size > q.max).should == true q.deq.should == 1 q.deq.should == 2 q.deq.should == 3 @@ -27,21 +27,21 @@ it "raises a TypeError when given a non-numeric value" do q = @object.call(5) - -> { q.max = "foo" }.should raise_error(TypeError) - -> { q.max = Object.new }.should raise_error(TypeError) + -> { q.max = "foo" }.should.raise(TypeError) + -> { q.max = Object.new }.should.raise(TypeError) end it "raises an argument error when set to zero" do q = @object.call(5) q.max.should == 5 - -> { q.max = 0 }.should raise_error(ArgumentError) + -> { q.max = 0 }.should.raise(ArgumentError) q.max.should == 5 end it "raises an argument error when set to a negative number" do q = @object.call(5) q.max.should == 5 - -> { q.max = -1 }.should raise_error(ArgumentError) + -> { q.max = -1 }.should.raise(ArgumentError) q.max.should == 5 end end diff --git a/spec/ruby/shared/sizedqueue/new.rb b/spec/ruby/shared/sizedqueue/new.rb index 2573194efb21ae..2904422a45b41f 100644 --- a/spec/ruby/shared/sizedqueue/new.rb +++ b/spec/ruby/shared/sizedqueue/new.rb @@ -1,7 +1,7 @@ describe :sizedqueue_new, shared: true do it "raises a TypeError when the given argument doesn't respond to #to_int" do - -> { @object.call("12") }.should raise_error(TypeError) - -> { @object.call(Object.new) }.should raise_error(TypeError) + -> { @object.call("12") }.should.raise(TypeError) + -> { @object.call(Object.new) }.should.raise(TypeError) @object.call(12.9).max.should == 12 object = Object.new @@ -10,14 +10,14 @@ end it "raises an argument error when no argument is given" do - -> { @object.call }.should raise_error(ArgumentError) + -> { @object.call }.should.raise(ArgumentError) end it "raises an argument error when the given argument is zero" do - -> { @object.call(0) }.should raise_error(ArgumentError) + -> { @object.call(0) }.should.raise(ArgumentError) end it "raises an argument error when the given argument is negative" do - -> { @object.call(-1) }.should raise_error(ArgumentError) + -> { @object.call(-1) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/shared/string/end_with.rb b/spec/ruby/shared/string/end_with.rb index 08f43c1bce7071..8eb9693395454e 100644 --- a/spec/ruby/shared/string/end_with.rb +++ b/spec/ruby/shared/string/end_with.rb @@ -30,9 +30,9 @@ it "ignores arguments not convertible to string" do "hello".send(@method).should_not.end_with?() - -> { "hello".send(@method).end_with?(1) }.should raise_error(TypeError) - -> { "hello".send(@method).end_with?(["o"]) }.should raise_error(TypeError) - -> { "hello".send(@method).end_with?(1, nil, "o") }.should raise_error(TypeError) + -> { "hello".send(@method).end_with?(1) }.should.raise(TypeError) + -> { "hello".send(@method).end_with?(["o"]) }.should.raise(TypeError) + -> { "hello".send(@method).end_with?(1, nil, "o") }.should.raise(TypeError) end it "uses only the needed arguments" do @@ -49,7 +49,7 @@ pat = "ア".encode Encoding::EUC_JP -> do "あれ".send(@method).end_with?(pat) - end.should raise_error(Encoding::CompatibilityError) + end.should.raise(Encoding::CompatibilityError) end it "checks that we are starting to match at the head of a character" do diff --git a/spec/ruby/shared/string/start_with.rb b/spec/ruby/shared/string/start_with.rb index 9592eda4d43d31..fe12e2896920d9 100644 --- a/spec/ruby/shared/string/start_with.rb +++ b/spec/ruby/shared/string/start_with.rb @@ -26,9 +26,9 @@ it "ignores arguments not convertible to string" do "hello".send(@method).should_not.start_with?() - -> { "hello".send(@method).start_with?(1) }.should raise_error(TypeError) - -> { "hello".send(@method).start_with?(["h"]) }.should raise_error(TypeError) - -> { "hello".send(@method).start_with?(1, nil, "h") }.should raise_error(TypeError) + -> { "hello".send(@method).start_with?(1) }.should.raise(TypeError) + -> { "hello".send(@method).start_with?(["h"]) }.should.raise(TypeError) + -> { "hello".send(@method).start_with?(1, nil, "h") }.should.raise(TypeError) end it "uses only the needed arguments" do @@ -60,14 +60,14 @@ it "sets Regexp.last_match if it returns true" do regexp = /test-(\d+)/ - "test-1337".send(@method).start_with?(regexp).should be_true - Regexp.last_match.should_not be_nil + "test-1337".send(@method).start_with?(regexp).should == true + Regexp.last_match.should_not == nil Regexp.last_match[1].should == "1337" $1.should == "1337" - "test-asdf".send(@method).start_with?(regexp).should be_false - Regexp.last_match.should be_nil - $1.should be_nil + "test-asdf".send(@method).start_with?(regexp).should == false + Regexp.last_match.should == nil + $1.should == nil end it "checks that we are not matching part of a character" do diff --git a/spec/ruby/shared/string/times.rb b/spec/ruby/shared/string/times.rb index 4814f894cf0217..0a16ba8b822e6c 100644 --- a/spec/ruby/shared/string/times.rb +++ b/spec/ruby/shared/string/times.rb @@ -18,14 +18,14 @@ class MyString < String; end end it "raises an ArgumentError when given integer is negative" do - -> { @object.call("cool", -3) }.should raise_error(ArgumentError) - -> { @object.call("cool", -3.14) }.should raise_error(ArgumentError) - -> { @object.call("cool", min_long) }.should raise_error(ArgumentError) + -> { @object.call("cool", -3) }.should.raise(ArgumentError) + -> { @object.call("cool", -3.14) }.should.raise(ArgumentError) + -> { @object.call("cool", min_long) }.should.raise(ArgumentError) end it "raises a RangeError when given integer is a Bignum" do - -> { @object.call("cool", 999999999999999999999) }.should raise_error(RangeError) - -> { @object.call("", 999999999999999999999) }.should raise_error(RangeError) + -> { @object.call("cool", 999999999999999999999) }.should.raise(RangeError) + -> { @object.call("", 999999999999999999999) }.should.raise(RangeError) end it "works with huge long values when string is empty" do @@ -33,26 +33,26 @@ class MyString < String; end end it "returns String instances" do - @object.call(MyString.new("cool"), 0).should be_an_instance_of(String) - @object.call(MyString.new("cool"), 1).should be_an_instance_of(String) - @object.call(MyString.new("cool"), 2).should be_an_instance_of(String) + @object.call(MyString.new("cool"), 0).should.instance_of?(String) + @object.call(MyString.new("cool"), 1).should.instance_of?(String) + @object.call(MyString.new("cool"), 2).should.instance_of?(String) end it "returns a String in the same encoding as self" do str = "\xE3\x81\x82".dup.force_encoding Encoding::UTF_8 result = @object.call(str, 2) - result.encoding.should equal(Encoding::UTF_8) + result.encoding.should.equal?(Encoding::UTF_8) end platform_is c_long_size: 32 do it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do - -> { @object.call("abc", (2 ** 31) - 1) }.should raise_error(ArgumentError) + -> { @object.call("abc", (2 ** 31) - 1) }.should.raise(ArgumentError) end end platform_is c_long_size: 64 do it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do - -> { @object.call("abc", (2 ** 63) - 1) }.should raise_error(ArgumentError) + -> { @object.call("abc", (2 ** 63) - 1) }.should.raise(ArgumentError) end end end From d4727cd4e63c7bc1bc95a96b7f3c6de568bc5b6e Mon Sep 17 00:00:00 2001 From: dak2 Date: Tue, 5 May 2026 19:45:48 +0900 Subject: [PATCH 06/34] Ruby::Box fix stale cached values for exception-related global variables ($! and $@) Ruby::Box fix stale cached values for exception-related global variables ($! and $@) The exception-related virtual variables $! (current exception) and $@ (its backtrace) are stored on the execution context (ec->errinfo and the rescue/ensure frame's local slot accessed via errinfo_place), not in box->gvar_tbl. Caching their values in box->gvar_tbl makes the second read return a stale value from the previous raise/rescue: ``` begin; raise "first"; rescue; p $!; end begin; raise "second"; rescue; p $!; end # before: # / # # after: # / # ``` ``` begin; raise "first"; rescue; p $@.first; end begin; raise "second"; rescue; p $@.first; end # before: same backtrace returned for both # after: distinct backtrace per raise ``` Fixes [Bug #21991](https://bugs.ruby-lang.org/issues/21991) Related PR: https://github.com/ruby/ruby/pull/16303 --- eval.c | 3 ++ test/ruby/test_box.rb | 120 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/eval.c b/eval.c index e3630c246ae1f0..2b613ffff3e007 100644 --- a/eval.c +++ b/eval.c @@ -2224,6 +2224,9 @@ Init_eval(void) rb_gvar_ractor_local("$@"); rb_gvar_ractor_local("$!"); + rb_gvar_box_dynamic("$@"); + rb_gvar_box_dynamic("$!"); + rb_define_global_function("raise", f_raise, -1); rb_define_global_function("fail", f_raise, -1); diff --git a/test/ruby/test_box.rb b/test/ruby/test_box.rb index 8644b84bcd9b1a..9d609415266eec 100644 --- a/test/ruby/test_box.rb +++ b/test/ruby/test_box.rb @@ -626,6 +626,126 @@ def test_lastline_not_cached_in_nested_boxes end; end + def test_errinfo_not_cached_in_box + assert_separately([ENV_ENABLE_BOX], __FILE__, __LINE__, "#{<<~"begin;"}\n#{<<~'end;'}", ignore_stderr: true) + begin; + first, second = Ruby::Box.new.eval(<<~'CODE') + a = begin; raise "first"; rescue RuntimeError; $!.message; end + b = begin; raise "second"; rescue RuntimeError; $!.message; end + [a, b] + CODE + assert_equal "first", first + assert_equal "second", second + end; + end + + def test_errinfo_not_cached_in_nested_boxes + assert_separately([ENV_ENABLE_BOX], __FILE__, __LINE__, "#{<<~"begin;"}\n#{<<~'end;'}", ignore_stderr: true) + begin; + inner_msg, outer_msg = Ruby::Box.new.eval(<<~'CODE') + outer_a = begin; raise "outer1"; rescue RuntimeError; $!.message; end + + inner_msg = Ruby::Box.new.eval(<<~'INNER') + begin; raise "inner1"; rescue RuntimeError; $!; end + begin; raise "inner2"; rescue RuntimeError; $!.message; end + INNER + + outer_b = begin; raise "outer2"; rescue RuntimeError; $!.message; end + [inner_msg, outer_b] + CODE + assert_equal "inner2", inner_msg + assert_equal "outer2", outer_msg + end; + end + + def test_backtrace_not_cached_in_box + assert_separately([ENV_ENABLE_BOX], __FILE__, __LINE__, "#{<<~"begin;"}\n#{<<~'end;'}", ignore_stderr: true) + begin; + a_actual, b_actual = Ruby::Box.new.eval(<<~'CODE') + a_actual = begin; raise "first"; rescue RuntimeError; $@.first[/:(\d+):/, 1].to_i; end + b_actual = begin; raise "second"; rescue RuntimeError; $@.first[/:(\d+):/, 1].to_i; end + [a_actual, b_actual] + CODE + assert_equal 1, a_actual + assert_equal 2, b_actual + end; + end + + def test_backtrace_not_cached_in_nested_boxes + assert_separately([ENV_ENABLE_BOX], __FILE__, __LINE__, "#{<<~"begin;"}\n#{<<~'end;'}", ignore_stderr: true) + begin; + inner_actual, outer_actual = Ruby::Box.new.eval(<<~'CODE') + begin; raise "outer1"; rescue RuntimeError; $@; end + inner_actual = Ruby::Box.new.eval(<<~'INNER') + begin; raise "inner1"; rescue RuntimeError; $@; end + begin; raise "inner2"; rescue RuntimeError; $@.first[/:(\d+):/, 1].to_i; end + INNER + outer_actual = begin; raise "outer2"; rescue RuntimeError; $@.first[/:(\d+):/, 1].to_i; end + [inner_actual, outer_actual] + CODE + assert_equal 2, inner_actual + assert_equal 6, outer_actual + end; + end + + def test_errinfo_isolated_between_boxes + assert_separately([ENV_ENABLE_BOX], __FILE__, __LINE__, "#{<<~"begin;"}\n#{<<~'end;'}", ignore_stderr: true) + begin; + box_a = Ruby::Box.new + box_b = Ruby::Box.new + + a = box_a.eval('begin; raise "a"; rescue; $!.message; end') + b = box_b.eval('begin; raise "b"; rescue; $!.message; end') + + assert_equal "a", a + assert_equal "b", b + end; + end + + def test_backtrace_isolated_between_boxes + assert_separately([ENV_ENABLE_BOX], __FILE__, __LINE__, "#{<<~"begin;"}\n#{<<~'end;'}", ignore_stderr: true) + begin; + box_a = Ruby::Box.new + box_b = Ruby::Box.new + + a_line = box_a.eval("\nbegin; raise; rescue; $@.first[/:(\\d+):/, 1].to_i; end") + b_line = box_b.eval('begin; raise; rescue; $@.first[/:(\d+):/, 1].to_i; end') + + assert_equal 2, a_line + assert_equal 1, b_line + end; + end + + def test_inner_box_rescue_does_not_disturb_outer_box_errinfo + assert_separately([ENV_ENABLE_BOX], __FILE__, __LINE__, "#{<<~"begin;"}\n#{<<~'end;'}", ignore_stderr: true) + begin; + box_a = Ruby::Box.new + errinfo_in_inner_rescue, errinfo_after_inner_rescue, errinfo_back_in_outer_rescue = box_a.eval(<<~'A') + errinfo_in_inner_rescue = errinfo_after_inner_rescue = errinfo_back_in_outer_rescue = nil + begin + raise "outer" + rescue + errinfo_in_inner_rescue, errinfo_after_inner_rescue = Ruby::Box.new.eval(<<~'B') + in_rescue = after_rescue = nil + begin + raise "inner" + rescue + in_rescue = $! && $!.message + end + after_rescue = $! && $!.message + [in_rescue, after_rescue] + B + errinfo_back_in_outer_rescue = $! && $!.message + end + [errinfo_in_inner_rescue, errinfo_after_inner_rescue, errinfo_back_in_outer_rescue] + A + + assert_equal "inner", errinfo_in_inner_rescue + assert_equal "outer", errinfo_after_inner_rescue + assert_equal "outer", errinfo_back_in_outer_rescue + end; + end + def test_load_path_and_loaded_features setup_box From 834a828f9b0ee5701697bedc7bc3ddaf345855cd Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Thu, 7 May 2026 20:06:46 -0400 Subject: [PATCH 07/34] [DOC] Improve docs for ObjectSpace.count_objects_size --- ext/objspace/objspace.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index ffe184573592f3..63aa56332480ab 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -221,23 +221,26 @@ type2sym(enum ruby_value_type i) /* * call-seq: - * ObjectSpace.count_objects_size([result_hash]) -> hash + * ObjectSpace.count_objects_size(result_hash = {}) -> result_hash * * Counts objects size (in bytes) for each type. * - * Note that this information is incomplete. You need to deal with - * this information as only a *HINT*. Especially, total size of - * T_DATA may be wrong. + * Note that the returned size may not be accurate, so it should only + * be used as a hint. Specifically, the size for +T_DATA+ may be + * inaccurate because these are custom objects defined in Ruby and + * native extensions and so they may not accurately report their + * memory size. + * + * It returns a hash that looks like: * - * It returns a hash as: * {TOTAL: 1461154, T_CLASS: 158280, T_MODULE: 20672, T_STRING: 527249, ...} * - * If the optional argument, result_hash, is given, - * it is overwritten and returned. - * This is intended to avoid probe effect. + * The contents of the returned hash are implementation specific and + * may be changed in future versions without notice. * - * The contents of the returned hash is implementation defined. - * It may be changed in future. + * If the optional argument, +result_hash+, is given, + * it is overwritten and returned. + * This is intended to avoid the probe effect. * * This method is only expected to work with C Ruby. */ From 4658d6bd78bc742942b1408b571fdec17ef784a0 Mon Sep 17 00:00:00 2001 From: Andrii Furmanets Date: Thu, 30 Apr 2026 18:46:44 +0300 Subject: [PATCH 08/34] [ruby/rubygems] Fix bundle config gemfile unset behavior https://github.com/ruby/rubygems/commit/38f87aa2bc --- lib/bundler/cli.rb | 20 +++++++++++-------- spec/bundler/commands/config_spec.rb | 30 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 9a0f756bcf827f..7a04f3da239019 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -61,14 +61,18 @@ def initialize(*args) current_cmd = args.last[:current_command].name - Bundler.configure_custom_gemfile(options[:gemfile]) - - # lock --lockfile works differently than install --lockfile - unless current_cmd == "lock" - custom_lockfile = options[:lockfile] || ENV["BUNDLE_LOCKFILE"] || Bundler.settings[:lockfile] - if custom_lockfile && !custom_lockfile.empty? - Bundler::SharedHelpers.set_env "BUNDLE_LOCKFILE", File.expand_path(custom_lockfile) - reset_settings = true + # `bundle config` manages stored settings, so avoid promoting settings + # like `gemfile` or `lockfile` to environment variables before it runs. + unless current_cmd == "config" + Bundler.configure_custom_gemfile(options[:gemfile]) + + # lock --lockfile works differently than install --lockfile + unless current_cmd == "lock" + custom_lockfile = options[:lockfile] || ENV["BUNDLE_LOCKFILE"] || Bundler.settings[:lockfile] + if custom_lockfile && !custom_lockfile.empty? + Bundler::SharedHelpers.set_env "BUNDLE_LOCKFILE", File.expand_path(custom_lockfile) + reset_settings = true + end end end diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb index 954cae09d8464a..5cafbe346810bc 100644 --- a/spec/bundler/commands/config_spec.rb +++ b/spec/bundler/commands/config_spec.rb @@ -577,6 +577,36 @@ end RSpec.describe "setting gemfile via config" do + context "when a default Gemfile exists" do + before do + gemfile <<-G + source "https://gem.repo1" + G + + gemfile bundled_app("foo/bar_gemfile"), <<-G + source "https://gem.repo1" + G + end + + it "reports the local gemfile setting without promoting it to the environment" do + bundle "config set gemfile foo/bar_gemfile" + + bundle "config list" + expect(out).to include("Set for your local app (#{bundled_app(".bundle/config")}): \"foo/bar_gemfile\"") + expect(out).not_to include("Set via BUNDLE_GEMFILE") + end + + it "unsets the local gemfile setting from the app config" do + bundle "config set gemfile foo/bar_gemfile" + + bundle "config unset gemfile" + bundle "config get gemfile" + + expect(out).to include("You have not configured a value for `gemfile`") + expect(File.read(bundled_app(".bundle/config"))).not_to include("BUNDLE_GEMFILE") + end + end + context "when only the non-default Gemfile exists" do it "persists the gemfile location to .bundle/config" do gemfile bundled_app("NotGemfile"), <<-G From af7605d3c818ddb488bba74c9e6a86115915aabf Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 May 2026 11:20:37 +0900 Subject: [PATCH 09/34] Move conditional variable declarations To the code where they are actually initialized. --- file.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/file.c b/file.c index 894abdbecf78dc..6050dbb676c856 100644 --- a/file.c +++ b/file.c @@ -3913,10 +3913,6 @@ static VALUE copy_home_path(VALUE result, const char *dir) { char *buf; -#if defined DOSISH || defined __CYGWIN__ - char *p, *bend; - rb_encoding *enc; -#endif long dirlen; int encidx; @@ -3926,10 +3922,10 @@ copy_home_path(VALUE result, const char *dir) encidx = rb_filesystem_encindex(); rb_enc_associate_index(result, encidx); #if defined DOSISH || defined __CYGWIN__ - enc = rb_enc_from_index(encidx); + rb_encoding *enc = rb_enc_from_index(encidx); bool mb_enc = enc_mbclen_needed(enc); - for (bend = (p = buf) + dirlen; p < bend; Inc(p, bend, mb_enc, enc)) { - if (*p == '\\') { + for (char *p = buf, *bend = p + dirlen; p < bend; Inc(p, bend, mb_enc, enc)) { + if (*p == FILE_ALT_SEPARATOR) { *p = '/'; } } @@ -4985,9 +4981,6 @@ static inline const char * enc_find_basename(const char *name, long *baselen, long *alllen, bool mb_enc, rb_encoding *enc) { const char *p, *q, *e, *end; -#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC - const char *root; -#endif long f = 0, n = -1; long len = (alllen ? (size_t)*alllen : strlen(name)); @@ -4999,7 +4992,7 @@ enc_find_basename(const char *name, long *baselen, long *alllen, bool mb_enc, rb end = name + len; name = skipprefix(name, end, mb_enc, enc); #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC - root = name; + const char *root = name; #endif while (name < end && isdirsep(*name)) { From 216c49f5d35fc9054188175be2640b97033253b7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 8 May 2026 11:29:44 +0900 Subject: [PATCH 10/34] Use macros for specific purposes --- file.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/file.c b/file.c index 6050dbb676c856..53a1ac0934a969 100644 --- a/file.c +++ b/file.c @@ -3921,7 +3921,7 @@ copy_home_path(VALUE result, const char *dir) memcpy(buf = RSTRING_PTR(result), dir, dirlen); encidx = rb_filesystem_encindex(); rb_enc_associate_index(result, encidx); -#if defined DOSISH || defined __CYGWIN__ +#if defined FILE_ALT_SEPARATOR rb_encoding *enc = rb_enc_from_index(encidx); bool mb_enc = enc_mbclen_needed(enc); for (char *p = buf, *bend = p + dirlen; p < bend; Inc(p, bend, mb_enc, enc)) { @@ -4169,14 +4169,14 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na BUFINIT(); p = e; } -#if defined DOSISH || defined __CYGWIN__ +#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC if (s < fend && isdirsep(*s)) { /* specified full path, but not drive letter nor UNC */ /* we need to get the drive letter or UNC share name */ p = skipprefix(buf, p, mb_enc, enc); } else -#endif /* defined DOSISH || defined __CYGWIN__ */ +#endif /* defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC */ p = chompdirsep(skiproot(buf, p), p, mb_enc, enc); } else { @@ -4233,8 +4233,8 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na #endif /* USE_NTFS */ break; case '/': -#if defined DOSISH || defined __CYGWIN__ - case '\\': +#if defined FILE_ALT_SEPARATOR + case FILE_ALT_SEPARATOR: #endif b = ++s; break; @@ -4258,8 +4258,8 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na #endif /* USE_NTFS */ break; case '/': -#if defined DOSISH || defined __CYGWIN__ - case '\\': +#if defined FILE_ALT_SEPARATOR + case FILE_ALT_SEPARATOR: #endif if (s > b) { WITH_ROOTDIFF(BUFCOPY(b, s-b)); From ee9e92082784761849b4f9d5244af22c3bf407ba Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Sat, 2 May 2026 21:53:04 -0700 Subject: [PATCH 11/34] [ruby/rubygems] Switch bundle add to use optimistic versioning by default Add the recent developer meeting, we discussed switching from using pessimistic versioning by default to using optimistic versioning by default. This is the a step in that direction. It makes bundle add without a explicit version given to use >= (optimistic) instead of ~> (pessimistic). With this, the bundle add --optimistic option is now ignored, since the behavior is now the default. This add a --pessimistic option to set a pessimistic version. https://github.com/ruby/rubygems/commit/eed378086b --- lib/bundler/cli.rb | 3 +- lib/bundler/cli/add.rb | 4 +- lib/bundler/injector.rb | 6 +-- lib/bundler/man/bundle-add.1 | 7 ++- lib/bundler/man/bundle-add.1.ronn | 7 ++- spec/bundler/commands/add_spec.rb | 76 +++++++++++++++++-------------- 6 files changed, 59 insertions(+), 44 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 7a04f3da239019..40a9dc35b82c85 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -403,7 +403,8 @@ def binstubs(*gems) method_option "glob", type: :string, banner: "The location of a dependency's .gemspec, expanded within Ruby (single quotes recommended)" method_option "quiet", type: :boolean, banner: "Only output warnings and errors." method_option "skip-install", type: :boolean, banner: "Adds gem to the Gemfile but does not install it" - method_option "optimistic", type: :boolean, banner: "Adds optimistic declaration of version to gem" + method_option "optimistic", type: :boolean, banner: "Ignored (now default behavior)" + method_option "pessimistic", type: :boolean, banner: "Adds pessimistic declaration of version to gem" method_option "strict", type: :boolean, banner: "Adds strict declaration of version to gem" def add(*gems) require_relative "cli/add" diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb index 9f1760409617d2..d65ed68b4af87e 100644 --- a/lib/bundler/cli/add.rb +++ b/lib/bundler/cli/add.rb @@ -31,7 +31,7 @@ def inject_dependencies Injector.inject(dependencies, conservative_versioning: options[:version].nil?, # Perform conservative versioning only when version is not specified - optimistic: options[:optimistic], + pessimistic: options[:pessimistic], strict: options[:strict]) end @@ -46,7 +46,7 @@ def validate_options! raise InvalidOption, "You cannot specify `--branch` and `--ref` at the same time." if options["branch"] && options["ref"] - raise InvalidOption, "You cannot specify `--strict` and `--optimistic` at the same time." if options[:strict] && options[:optimistic] + raise InvalidOption, "You cannot specify `--strict` and `--pessimistic` at the same time." if options[:strict] && options[:pessimistic] # raise error when no gems are specified raise InvalidOption, "Please specify gems to add." if gems.empty? diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb index 3f8bf14e38e3ba..6aa9179024dca3 100644 --- a/lib/bundler/injector.rb +++ b/lib/bundler/injector.rb @@ -89,10 +89,10 @@ def conservative_version(spec) def version_prefix if @options[:strict] "= " - elsif @options[:optimistic] - ">= " - else + elsif @options[:pessimistic] "~> " + else + ">= " end end diff --git a/lib/bundler/man/bundle-add.1 b/lib/bundler/man/bundle-add.1 index 031eef686c9427..5b1e3e23406268 100644 --- a/lib/bundler/man/bundle-add.1 +++ b/lib/bundler/man/bundle-add.1 @@ -46,7 +46,10 @@ Do not print progress information to the standard output\. Adds the gem to the Gemfile but does not install it\. .TP \fB\-\-optimistic\fR -Adds optimistic declaration of version\. +Ignored (now default behavior) +.TP +\fB\-\-pessimistic\fR +Adds pessimistic declaration of version\. .TP \fB\-\-strict\fR Adds strict declaration of version\. @@ -62,7 +65,7 @@ You can add the \fBrails\fR gem with version greater than 1\.1 (not including 1\ .IP "3." 4 You can use the \fBhttps://gems\.example\.com\fR custom source and assign the gem to a group\. .IP -\fBbundle add rails \-\-version "~> 5\.0\.0" \-\-source "https://gems\.example\.com" \-\-group "development"\fR +\fBbundle add rails \-\-version ">= 5\.0\.0" \-\-source "https://gems\.example\.com" \-\-group "development"\fR .IP "4." 4 The following adds the \fBgem\fR entry to the Gemfile without installing the gem\. You can install gems later via \fBbundle install\fR\. .IP diff --git a/lib/bundler/man/bundle-add.1.ronn b/lib/bundler/man/bundle-add.1.ronn index 48c0c66b0946f5..1741e8e3759d37 100644 --- a/lib/bundler/man/bundle-add.1.ronn +++ b/lib/bundler/man/bundle-add.1.ronn @@ -51,7 +51,10 @@ Adds the named gem to the [`Gemfile(5)`][Gemfile(5)] and run `bundle install`. Adds the gem to the Gemfile but does not install it. * `--optimistic`: - Adds optimistic declaration of version. + Ignored (now default behavior) + +* `--pessimistic`: + Adds pessimistic declaration of version. * `--strict`: Adds strict declaration of version. @@ -70,7 +73,7 @@ Adds the named gem to the [`Gemfile(5)`][Gemfile(5)] and run `bundle install`. 3. You can use the `https://gems.example.com` custom source and assign the gem to a group. - `bundle add rails --version "~> 5.0.0" --source "https://gems.example.com" --group "development"` + `bundle add rails --version ">= 5.0.0" --source "https://gems.example.com" --group "development"` 4. The following adds the `gem` entry to the Gemfile without installing the gem. You can install gems later via `bundle install`. diff --git a/spec/bundler/commands/add_spec.rb b/spec/bundler/commands/add_spec.rb index a7eacfbd7f180a..162650f2e5c578 100644 --- a/spec/bundler/commands/add_spec.rb +++ b/spec/bundler/commands/add_spec.rb @@ -38,34 +38,34 @@ end describe "without version specified" do - it "version requirement becomes ~> major.minor.patch when resolved version is < 1.0" do + it "version requirement becomes >= major.minor.patch when resolved version is < 1.0" do bundle "add 'bar'" - expect(bundled_app_gemfile.read).to match(/gem "bar", "~> 0.12.3"/) + expect(bundled_app_gemfile.read).to match(/gem "bar", ">= 0.12.3"/) expect(the_bundle).to include_gems "bar 0.12.3" end - it "version requirement becomes ~> major.minor when resolved version is > 1.0" do + it "version requirement becomes >= major.minor when resolved version is > 1.0" do bundle "add 'baz'" - expect(bundled_app_gemfile.read).to match(/gem "baz", "~> 1.2"/) + expect(bundled_app_gemfile.read).to match(/gem "baz", ">= 1.2"/) expect(the_bundle).to include_gems "baz 1.2.3" end - it "version requirement becomes ~> major.minor.patch.pre when resolved version is < 1.0" do + it "version requirement becomes >= major.minor.patch.pre when resolved version is < 1.0" do bundle "add 'cat'" - expect(bundled_app_gemfile.read).to match(/gem "cat", "~> 0.12.3.pre"/) + expect(bundled_app_gemfile.read).to match(/gem "cat", ">= 0.12.3.pre"/) expect(the_bundle).to include_gems "cat 0.12.3.pre" end - it "version requirement becomes ~> major.minor.pre when resolved version is > 1.0.pre" do + it "version requirement becomes >= major.minor.pre when resolved version is >= 1.0.pre" do bundle "add 'dog'" - expect(bundled_app_gemfile.read).to match(/gem "dog", "~> 1.1.pre"/) + expect(bundled_app_gemfile.read).to match(/gem "dog", ">= 1.1.pre"/) expect(the_bundle).to include_gems "dog 1.1.3.pre" end - it "version requirement becomes ~> major.minor.pre.tail when resolved version has a very long tail pre version" do + it "version requirement becomes >= major.minor.pre.tail when resolved version has a very long tail pre version" do bundle "add 'lemur'" # the trailing pre purposely matches the release version to ensure that subbing the release doesn't change the pre.version" - expect(bundled_app_gemfile.read).to match(/gem "lemur", "~> 3.1.pre.2023.1.1"/) + expect(bundled_app_gemfile.read).to match(/gem "lemur", ">= 3.1.pre.2023.1.1"/) expect(the_bundle).to include_gems "lemur 3.1.1.pre.2023.1.1" end end @@ -100,13 +100,13 @@ describe "with --group" do it "adds dependency for the specified group" do bundle "add 'foo' --group='development'" - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", group: :development/) + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", group: :development/) expect(the_bundle).to include_gems "foo 2.0" end it "adds dependency to more than one group" do bundle "add 'foo' --group='development, test'" - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", groups: \[:development, :test\]/) + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", groups: \[:development, :test\]/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -115,7 +115,7 @@ it "adds dependency with specified source" do bundle "add 'foo' --source='https://gem.repo2'" - expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", source: "https://gem.repo2"}) + expect(bundled_app_gemfile.read).to match(%r{gem "foo", ">= 2.0", source: "https://gem.repo2"}) expect(the_bundle).to include_gems "foo 2.0" end end @@ -124,7 +124,7 @@ it "adds dependency with specified path" do bundle "add 'foo' --path='#{lib_path("foo-2.0")}'" - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", path: "#{lib_path("foo-2.0")}"/) + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", path: "#{lib_path("foo-2.0")}"/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -133,7 +133,7 @@ it "adds dependency with specified git source" do bundle "add foo --git=#{lib_path("foo-2.0")}" - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}"/) + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", git: "#{lib_path("foo-2.0")}"/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -146,7 +146,7 @@ it "adds dependency with specified git source and branch" do bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test" - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}", branch: "test"/) + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2.0", git: "#{lib_path("foo-2.0")}", branch: "test"/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -155,7 +155,7 @@ it "adds dependency with specified git source and branch" do bundle "add foo --git=#{lib_path("foo-2.0")} --ref=#{revision_for(lib_path("foo-2.0"))}" - expect(bundled_app_gemfile.read).to match(/gem "foo", "~> 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}"/) + expect(bundled_app_gemfile.read).to match(/gem "foo", ">= 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}"/) expect(the_bundle).to include_gems "foo 2.0" end end @@ -169,39 +169,39 @@ it "adds dependency with specified github source" do bundle "add rake --github=ruby/rake" - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake"}) + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake"}) end it "adds dependency with specified github source and branch" do bundle "add rake --github=ruby/rake --branch=main" - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", branch: "main"}) + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", branch: "main"}) end it "adds dependency with specified github source and ref" do ref = revision_for(lib_path("rake-13.0")) bundle "add rake --github=ruby/rake --ref=#{ref}" - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", ref: "#{ref}"}) + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", ref: "#{ref}"}) end it "adds dependency with specified github source and glob" do bundle "add rake --github=ruby/rake --glob='./*.gemspec'" - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", glob: "\.\/\*\.gemspec"}) + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", glob: "\.\/\*\.gemspec"}) end it "adds dependency with specified github source, branch and glob" do bundle "add rake --github=ruby/rake --branch=main --glob='./*.gemspec'" - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", branch: "main", glob: "\.\/\*\.gemspec"}) + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", branch: "main", glob: "\.\/\*\.gemspec"}) end it "adds dependency with specified github source, ref and glob" do ref = revision_for(lib_path("rake-13.0")) bundle "add rake --github=ruby/rake --ref=#{ref} --glob='./*.gemspec'" - expect(bundled_app_gemfile.read).to match(%r{gem "rake", "~> 13\.\d+", github: "ruby\/rake", ref: "#{ref}", glob: "\.\/\*\.gemspec"}) + expect(bundled_app_gemfile.read).to match(%r{gem "rake", ">= 13\.\d+", github: "ruby\/rake", ref: "#{ref}", glob: "\.\/\*\.gemspec"}) end end @@ -209,7 +209,7 @@ it "adds dependency with specified git source" do bundle "add foo --git=#{lib_path("foo-2.0")} --glob='./*.gemspec'" - expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}", glob: "\./\*\.gemspec"}) + expect(bundled_app_gemfile.read).to match(%r{gem "foo", ">= 2.0", git: "#{lib_path("foo-2.0")}", glob: "\./\*\.gemspec"}) expect(the_bundle).to include_gems "foo 2.0" end end @@ -222,7 +222,7 @@ it "adds dependency with specified git source and branch" do bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test --glob='./*.gemspec'" - expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2.0", git: "#{lib_path("foo-2.0")}", branch: "test", glob: "\./\*\.gemspec"}) + expect(bundled_app_gemfile.read).to match(%r{gem "foo", ">= 2.0", git: "#{lib_path("foo-2.0")}", branch: "test", glob: "\./\*\.gemspec"}) expect(the_bundle).to include_gems "foo 2.0" end end @@ -231,7 +231,7 @@ it "adds dependency with specified git source and branch" do bundle "add foo --git=#{lib_path("foo-2.0")} --ref=#{revision_for(lib_path("foo-2.0"))} --glob='./*.gemspec'" - expect(bundled_app_gemfile.read).to match(%r{gem "foo", "~> 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}", glob: "\./\*\.gemspec"}) + expect(bundled_app_gemfile.read).to match(%r{gem "foo", ">= 2\.0", git: "#{lib_path("foo-2.0")}", ref: "#{revision_for(lib_path("foo-2.0"))}", glob: "\./\*\.gemspec"}) expect(the_bundle).to include_gems "foo 2.0" end end @@ -308,13 +308,21 @@ end describe "with --optimistic" do - it "adds optimistic version" do + it "ignores option" do bundle "add 'foo' --optimistic" expect(bundled_app_gemfile.read).to include %(gem "foo", ">= 2.0") expect(the_bundle).to include_gems "foo 2.0" end end + describe "with --pessimistic" do + it "adds pessimistic version" do + bundle "add 'foo' --pessimistic" + expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 2.0") + expect(the_bundle).to include_gems "foo 2.0" + end + end + describe "with --quiet option" do it "is quiet when there are no warnings" do bundle "add 'foo' --quiet" @@ -356,18 +364,18 @@ def run end describe "with no option" do - it "adds pessimistic version" do + it "adds optimistic version" do bundle "add 'foo'" - expect(bundled_app_gemfile.read).to include %(gem "foo", "~> 2.0") + expect(bundled_app_gemfile.read).to include %(gem "foo", ">= 2.0") expect(the_bundle).to include_gems "foo 2.0" end end - describe "with --optimistic and --strict" do + describe "with --pessimistic and --strict" do it "throws error" do - bundle "add 'foo' --strict --optimistic", raise_on_error: false + bundle "add 'foo' --strict --pessimistic", raise_on_error: false - expect(err).to include("You cannot specify `--strict` and `--optimistic` at the same time") + expect(err).to include("You cannot specify `--strict` and `--pessimistic` at the same time") end end @@ -375,8 +383,8 @@ def run it "adds multiple gems to gemfile" do bundle "add bar baz" - expect(bundled_app_gemfile.read).to match(/gem "bar", "~> 0.12.3"/) - expect(bundled_app_gemfile.read).to match(/gem "baz", "~> 1.2"/) + expect(bundled_app_gemfile.read).to match(/gem "bar", ">= 0.12.3"/) + expect(bundled_app_gemfile.read).to match(/gem "baz", ">= 1.2"/) end it "throws error if any of the specified gems are present in the gemfile with different version" do From 29229d82bec6256e6b4f93486d772014cead9d8c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:37:04 +0900 Subject: [PATCH 12/34] [ruby/rubygems] Consolidate Override lookup with Override.find_for Definition#apply_override_to, Definition#converge_dependencies, and Resolver#apply_overrides each duplicated the same find expression. Centralizing it on Override prepares for upcoming fields (and the :all target) without repeating the predicate in every call site. https://github.com/ruby/rubygems/commit/0c4424d5f3 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/definition.rb | 2 +- lib/bundler/override.rb | 4 ++++ lib/bundler/resolver.rb | 2 +- spec/bundler/bundler/override_spec.rb | 22 ++++++++++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index a64b67cb44d020..3cfe401d2ac15f 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -644,7 +644,7 @@ def apply_overrides_to(deps) end def apply_override_to(dep) - override = @overrides.find {|o| o.target == dep.name && o.field == :version } + override = Override.find_for(@overrides, dep.name, :version) return dep unless override new_dep = dep.dup new_dep.instance_variable_set(:@requirement, override.apply_to(dep.requirement)) diff --git a/lib/bundler/override.rb b/lib/bundler/override.rb index 1ca6d2fde5d4e6..9d0db30d6a9127 100644 --- a/lib/bundler/override.rb +++ b/lib/bundler/override.rb @@ -4,6 +4,10 @@ module Bundler class Override UPPER_BOUND_OPERATORS = ["<", "<="].freeze + def self.find_for(overrides, name, field) + overrides.find {|o| o.target == name && o.field == field } + end + attr_reader :target, :field, :operation def initialize(target, field, operation) diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 5e934e2a12e6b1..e8dc349e503473 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -530,7 +530,7 @@ def apply_overrides(dependencies) return dependencies if @base.overrides.empty? dependencies.map do |dep| - override = @base.overrides.find {|o| o.target == dep.name && o.field == :version } + override = Override.find_for(@base.overrides, dep.name, :version) next dep unless override Gem::Dependency.new(dep.name, override.apply_to(dep.requirement)) end diff --git a/spec/bundler/bundler/override_spec.rb b/spec/bundler/bundler/override_spec.rb index da3b5aad87a086..e0ef4ed54d85ab 100644 --- a/spec/bundler/bundler/override_spec.rb +++ b/spec/bundler/bundler/override_spec.rb @@ -1,6 +1,28 @@ # frozen_string_literal: true RSpec.describe Bundler::Override do + describe ".find_for" do + it "returns the matching override by target and field" do + a = described_class.new("rails", :version, ">= 8.0") + b = described_class.new("nokogiri", :version, :ignore_upper) + expect(described_class.find_for([a, b], "rails", :version)).to be(a) + end + + it "returns nil when no override matches the target" do + a = described_class.new("rails", :version, ">= 8.0") + expect(described_class.find_for([a], "sinatra", :version)).to be_nil + end + + it "returns nil when no override matches the field" do + a = described_class.new("rails", :version, ">= 8.0") + expect(described_class.find_for([a], "rails", :required_ruby_version)).to be_nil + end + + it "returns nil for an empty overrides list" do + expect(described_class.find_for([], "rails", :version)).to be_nil + end + end + describe "#apply_to" do context "when operation is a version spec string" do it "replaces the existing requirement entirely" do From c0a9fdc030b92930cef3ed398ad274a12e44ef97 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:38:46 +0900 Subject: [PATCH 13/34] [ruby/rubygems] Validate override version requirement at Gemfile evaluation time Before this change, `override "rails", version: "not a version"` was accepted by Bundler::Dsl#override and only failed later when the resolver tried to instantiate Gem::Requirement. Surface the error at the Gemfile evaluation step so the user sees it on the offending line. https://github.com/ruby/rubygems/commit/2ae83fbb4f Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/dsl.rb | 6 +++++- spec/bundler/bundler/dsl_spec.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index c7a7d855eef179..05eb493677f3cf 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -279,7 +279,9 @@ def validate_override_field!(field) def validate_override_operation!(operation) case operation - when String, nil + when String + Gem::Requirement.new(operation) + when nil # ok when Symbol return if SUPPORTED_OVERRIDE_SYMBOL_OPERATIONS.include?(operation) @@ -287,6 +289,8 @@ def validate_override_operation!(operation) else raise ArgumentError, "override operation must be a String, Symbol, or nil, got #{operation.inspect}" end + rescue Gem::Requirement::BadRequirementError => e + raise ArgumentError, "invalid override version requirement #{operation.inspect}: #{e.message}" end def validate_override_uniqueness!(target, field) diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb index 39f745c05efe63..99ab9088f9ff3f 100644 --- a/spec/bundler/bundler/dsl_spec.rb +++ b/spec/bundler/bundler/dsl_spec.rb @@ -441,6 +441,19 @@ end.to raise_error(ArgumentError, /unsupported override operation/) end + it "raises ArgumentError for an unparsable version string" do + expect do + subject.override("rails", version: "not a version") + end.to raise_error(ArgumentError, /invalid override version requirement/) + end + + it "does not record an override when the version string is invalid" do + expect do + subject.override("rails", version: "not a version") + end.to raise_error(ArgumentError) + expect(subject.overrides).to eq([]) + end + it "rejects atomically when one field in a multi-field call is invalid" do expect do subject.override("rails", version: ">= 8.0", required_ruby_version: :ignore_upper) From 13313f9436fb75e3da965a8ce8db9e4b96849111 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:40:15 +0900 Subject: [PATCH 14/34] [ruby/rubygems] Assert that override directives never leak into the lockfile Lock the byroot policy decision (overrides are a Gemfile concept and must not be serialized into Gemfile.lock) with a regression test, so a future change that starts emitting override metadata in the lock would fail loudly. https://github.com/ruby/rubygems/commit/9524b785c5 Co-Authored-By: Claude Opus 4.7 (1M context) --- spec/bundler/install/gemfile/override_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/bundler/install/gemfile/override_spec.rb b/spec/bundler/install/gemfile/override_spec.rb index 7a7f8078a81753..410bf96737fedd 100644 --- a/spec/bundler/install/gemfile/override_spec.rb +++ b/spec/bundler/install/gemfile/override_spec.rb @@ -129,4 +129,16 @@ expect(the_bundle).to include_gems "myrack 1.0.0", "myrack_middleware 1.0" end end + + context "lockfile contents" do + it "does not record the override directive in Gemfile.lock" do + install_gemfile <<-G + source "https://gem.repo1" + override "myrack", version: "= 0.9.1" + gem "myrack" + G + + expect(lockfile).not_to match(/override/i) + end + end end From e58a72eb5db505e5784a282d87d0d86df48bf789 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:44:50 +0900 Subject: [PATCH 15/34] [ruby/rubygems] Accept required_ruby_version and required_rubygems_version overrides Extend the override DSL whitelist so per-gem metadata fields can be declared. The :all target is rejected for now with a "not yet supported" error so the field is purely per-gem until the next step adds :all propagation. https://github.com/ruby/rubygems/commit/f9e4d7bf29 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/dsl.rb | 9 +++++++-- spec/bundler/bundler/dsl_spec.rb | 27 ++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 05eb493677f3cf..92abd07a84dffa 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -185,7 +185,7 @@ def github(repo, options = {}) with_source(git_source) { yield } end - SUPPORTED_OVERRIDE_FIELDS = [:version].freeze + SUPPORTED_OVERRIDE_FIELDS = [:version, :required_ruby_version, :required_rubygems_version].freeze SUPPORTED_OVERRIDE_SYMBOL_OPERATIONS = [:ignore_upper].freeze def override(target, **operations) @@ -195,6 +195,10 @@ def override(target, **operations) raise ArgumentError, "`override :all, version:` is not allowed; version requirements are per-gem" end + if target == :all && operations.any? + raise ArgumentError, "`override :all` is not yet supported" + end + operations.each do |field, operation| validate_override_field!(field) validate_override_operation!(operation) @@ -274,7 +278,8 @@ def validate_override_target!(target) def validate_override_field!(field) return if SUPPORTED_OVERRIDE_FIELDS.include?(field) - raise ArgumentError, "unsupported override field `#{field}:`; only `version:` is currently supported" + supported = SUPPORTED_OVERRIDE_FIELDS.map {|f| "`#{f}:`" }.join(", ") + raise ArgumentError, "unsupported override field `#{field}:`; supported fields: #{supported}" end def validate_override_operation!(operation) diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb index 99ab9088f9ff3f..6df665e3d9df7d 100644 --- a/spec/bundler/bundler/dsl_spec.rb +++ b/spec/bundler/bundler/dsl_spec.rb @@ -425,8 +425,29 @@ it "raises ArgumentError for an unsupported field" do expect do - subject.override("rails", required_ruby_version: :ignore_upper) - end.to raise_error(ArgumentError, /unsupported override field `required_ruby_version:`/) + subject.override("rails", as: "y") + end.to raise_error(ArgumentError, /unsupported override field `as:`/) + end + + it "stores an Override for a gem with a required_ruby_version: operation" do + subject.override("rails", required_ruby_version: :ignore_upper) + override = subject.overrides.first + expect(override.target).to eq("rails") + expect(override.field).to eq(:required_ruby_version) + expect(override.operation).to eq(:ignore_upper) + end + + it "stores an Override for a gem with a required_rubygems_version: operation" do + subject.override("rails", required_rubygems_version: nil) + override = subject.overrides.first + expect(override.field).to eq(:required_rubygems_version) + expect(override.operation).to be_nil + end + + it "raises ArgumentError for `override :all, required_ruby_version:` until :all is implemented" do + expect do + subject.override(:all, required_ruby_version: :ignore_upper) + end.to raise_error(ArgumentError, /`override :all` is not yet supported/) end it "raises ArgumentError for a non-string, non-symbol, non-nil operation" do @@ -456,7 +477,7 @@ it "rejects atomically when one field in a multi-field call is invalid" do expect do - subject.override("rails", version: ">= 8.0", required_ruby_version: :ignore_upper) + subject.override("rails", version: ">= 8.0", as: "y") end.to raise_error(ArgumentError, /unsupported override field/) expect(subject.overrides).to eq([]) end From acbdd87e02a46d1e096e68662d0706da354bf21d Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:46:26 +0900 Subject: [PATCH 16/34] [ruby/rubygems] Apply per-gem metadata overrides in Resolver When a spec's runtime dependencies are gathered for the resolver, its required_ruby_version / required_rubygems_version metadata flow as synthetic Ruby\0 / RubyGems\0 dependencies. Rewrite those before they reach the dependency hash so per-gem overrides on those fields take effect during resolution. https://github.com/ruby/rubygems/commit/853e00f778 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/resolver.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index e8dc349e503473..5b575f15e6cb08 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -64,7 +64,9 @@ def setup_solver @cached_dependencies = Hash.new do |dependencies, package| dependencies[package] = Hash.new do |versions, version| - versions[version] = to_dependency_hash(version.dependencies.reject {|d| d.name == package.name }, @packages) + deps = version.dependencies.reject {|d| d.name == package.name } + deps = apply_metadata_overrides(deps, package.name) + versions[version] = to_dependency_hash(deps, @packages) end end @@ -536,6 +538,23 @@ def apply_overrides(dependencies) end end + METADATA_DEP_FIELD = { + "Ruby\0" => :required_ruby_version, + "RubyGems\0" => :required_rubygems_version, + }.freeze + + def apply_metadata_overrides(dependencies, name) + return dependencies if @base.overrides.empty? + + dependencies.map do |dep| + field = METADATA_DEP_FIELD[dep.name] + next dep unless field + override = Override.find_for(@base.overrides, name, field) + next dep unless override + Gem::Dependency.new(dep.name, override.apply_to(dep.requirement)) + end + end + def bundler_not_found_message(conflict_dependencies) candidate_specs = filter_matching_specs(default_bundler_source.specs.search("bundler"), conflict_dependencies) From 266e33c86cfb100294ba92bd8e9f799b3d9e4b44 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:47:55 +0900 Subject: [PATCH 17/34] [ruby/rubygems] Unlock direct deps too for metadata-field overrides The per-dep loop in converge_dependencies only knows about version: overrides via apply_override_to + matches_spec?. Metadata overrides on direct deps were therefore invisible to lockfile change detection and would silently no-op against an existing lock. Extend converge_overrides_outside_dependencies to also unlock direct deps when the override targets a non-version field. https://github.com/ruby/rubygems/commit/fdd4c30523 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/definition.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 3cfe401d2ac15f..7f5a72f0ebf0ec 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -1065,8 +1065,11 @@ def converge_overrides_outside_dependencies name = override.target next if @changed_dependencies.include?(name) - next if @dependencies.any? {|d| d.name == name } next if @originally_locked_specs[name].empty? + # version: overrides on direct deps are detected in the per-dep + # converge_dependencies loop via apply_override_to + matches_spec?. + # Other fields are not visible there, so they always reach here. + next if override.field == :version && @dependencies.any? {|d| d.name == name } @gems_to_unlock << name @changed_dependencies << name From 4fa0924fb4f62583b4b5d30ca6d9fab9cf11149a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:52:29 +0900 Subject: [PATCH 18/34] [ruby/rubygems] Cover required_ruby_version and required_rubygems_version overrides Add integration coverage exercising :ignore_upper and nil overrides against per-gem metadata fields, transitive propagation, and lockfile re-resolution when a metadata override is added against an existing lockfile. The cases drive `bundle lock` so they exercise the resolver without RubyGems' install-time required_ruby_version gate, which is addressed in a later step. https://github.com/ruby/rubygems/commit/ec3a549df7 Co-Authored-By: Claude Opus 4.7 (1M context) --- spec/bundler/install/gemfile/override_spec.rb | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/spec/bundler/install/gemfile/override_spec.rb b/spec/bundler/install/gemfile/override_spec.rb index 410bf96737fedd..20e812a553a971 100644 --- a/spec/bundler/install/gemfile/override_spec.rb +++ b/spec/bundler/install/gemfile/override_spec.rb @@ -141,4 +141,106 @@ expect(lockfile).not_to match(/override/i) end end + + context "with a required_ruby_version: operation" do + it "lets the resolver pick a gem whose required_ruby_version excludes the current Ruby with :ignore_upper" do + build_repo2 do + build_gem "needs_old_ruby", "1.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + end + + gemfile <<-G + source "https://gem.repo2" + override "needs_old_ruby", required_ruby_version: :ignore_upper + gem "needs_old_ruby" + G + + bundle :lock + expect(lockfile).to include("needs_old_ruby (1.0)") + end + + it "lets the resolver pick the gem with required_ruby_version: nil" do + build_repo2 do + build_gem "needs_old_ruby", "1.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + end + + gemfile <<-G + source "https://gem.repo2" + override "needs_old_ruby", required_ruby_version: nil + gem "needs_old_ruby" + G + + bundle :lock + expect(lockfile).to include("needs_old_ruby (1.0)") + end + + it "applies to a transitive dependency's required_ruby_version" do + build_repo2 do + build_gem "needs_old_ruby", "1.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + build_gem "wraps_old", "1.0" do |s| + s.add_dependency "needs_old_ruby" + end + end + + gemfile <<-G + source "https://gem.repo2" + override "needs_old_ruby", required_ruby_version: :ignore_upper + gem "wraps_old" + G + + bundle :lock + expect(lockfile).to include("needs_old_ruby (1.0)") + expect(lockfile).to include("wraps_old (1.0)") + end + + it "re-resolves a direct dep when a metadata override is added against an existing lockfile" do + build_repo2 do + build_gem "selectable", "1.0" + build_gem "selectable", "2.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + end + + gemfile <<-G + source "https://gem.repo2" + gem "selectable" + G + + bundle :lock + expect(lockfile).to include("selectable (1.0)") + + gemfile <<-G + source "https://gem.repo2" + override "selectable", required_ruby_version: :ignore_upper + gem "selectable" + G + + bundle :lock + expect(lockfile).to include("selectable (2.0)") + end + end + + context "with a required_rubygems_version: operation" do + it "lets the resolver pick a gem whose required_rubygems_version excludes the current RubyGems with :ignore_upper" do + build_repo2 do + build_gem "needs_old_rubygems", "1.0" do |s| + s.required_rubygems_version = "< #{Gem.rubygems_version}" + end + end + + gemfile <<-G + source "https://gem.repo2" + override "needs_old_rubygems", required_rubygems_version: :ignore_upper + gem "needs_old_rubygems" + G + + bundle :lock + expect(lockfile).to include("needs_old_rubygems (1.0)") + end + end end From 36b2ed2b129556bd76ffd4cad0fe750c4bbb4388 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:54:02 +0900 Subject: [PATCH 19/34] [ruby/rubygems] Allow :all target for metadata-field overrides MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the temporary "not yet supported" guard so a Gemfile may write `override :all, required_ruby_version: :ignore_upper` and similar forms. The version: ban for :all stays — version requirements are inherently per-gem. https://github.com/ruby/rubygems/commit/af09f0360a Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/dsl.rb | 4 ---- spec/bundler/bundler/dsl_spec.rb | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 92abd07a84dffa..46389b6c68693b 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -195,10 +195,6 @@ def override(target, **operations) raise ArgumentError, "`override :all, version:` is not allowed; version requirements are per-gem" end - if target == :all && operations.any? - raise ArgumentError, "`override :all` is not yet supported" - end - operations.each do |field, operation| validate_override_field!(field) validate_override_operation!(operation) diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb index 6df665e3d9df7d..a04528a57fc7d0 100644 --- a/spec/bundler/bundler/dsl_spec.rb +++ b/spec/bundler/bundler/dsl_spec.rb @@ -444,10 +444,19 @@ expect(override.operation).to be_nil end - it "raises ArgumentError for `override :all, required_ruby_version:` until :all is implemented" do - expect do - subject.override(:all, required_ruby_version: :ignore_upper) - end.to raise_error(ArgumentError, /`override :all` is not yet supported/) + it "stores an Override targeting :all with a metadata field" do + subject.override(:all, required_ruby_version: :ignore_upper) + override = subject.overrides.first + expect(override.target).to eq(:all) + expect(override.field).to eq(:required_ruby_version) + expect(override.operation).to eq(:ignore_upper) + end + + it "stores an Override targeting :all with required_rubygems_version" do + subject.override(:all, required_rubygems_version: nil) + override = subject.overrides.first + expect(override.target).to eq(:all) + expect(override.field).to eq(:required_rubygems_version) end it "raises ArgumentError for a non-string, non-symbol, non-nil operation" do From 54a07500ef98aac350afaa22fd06be5648807424 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:54:39 +0900 Subject: [PATCH 20/34] [ruby/rubygems] Fall back from per-gem lookup to an :all override Override.find_for now returns the per-gem entry when present and otherwise the matching :all entry on the same field. This is the single dispatch point for overrides in Definition and Resolver, so the fallback is what wires :all into resolution and lockfile change detection without further plumbing. https://github.com/ruby/rubygems/commit/ef24b4eef9 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/override.rb | 3 ++- spec/bundler/bundler/override_spec.rb | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/bundler/override.rb b/lib/bundler/override.rb index 9d0db30d6a9127..ed5b51281f6339 100644 --- a/lib/bundler/override.rb +++ b/lib/bundler/override.rb @@ -5,7 +5,8 @@ class Override UPPER_BOUND_OPERATORS = ["<", "<="].freeze def self.find_for(overrides, name, field) - overrides.find {|o| o.target == name && o.field == field } + overrides.find {|o| o.target == name && o.field == field } || + overrides.find {|o| o.target == :all && o.field == field } end attr_reader :target, :field, :operation diff --git a/spec/bundler/bundler/override_spec.rb b/spec/bundler/bundler/override_spec.rb index e0ef4ed54d85ab..78f7a62900ce87 100644 --- a/spec/bundler/bundler/override_spec.rb +++ b/spec/bundler/bundler/override_spec.rb @@ -21,6 +21,22 @@ it "returns nil for an empty overrides list" do expect(described_class.find_for([], "rails", :version)).to be_nil end + + it "falls back to an :all override on the same field" do + a = described_class.new(:all, :required_ruby_version, :ignore_upper) + expect(described_class.find_for([a], "rails", :required_ruby_version)).to be(a) + end + + it "prefers a per-gem override over a matching :all override" do + per_gem = described_class.new("rails", :required_ruby_version, ">= 3.4") + all_target = described_class.new(:all, :required_ruby_version, :ignore_upper) + expect(described_class.find_for([all_target, per_gem], "rails", :required_ruby_version)).to be(per_gem) + end + + it "does not fall back to :all when the field differs" do + a = described_class.new(:all, :required_ruby_version, :ignore_upper) + expect(described_class.find_for([a], "rails", :required_rubygems_version)).to be_nil + end end describe "#apply_to" do From 217d53b0a6db31927bd1e2325e9385c267eedb8a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:56:28 +0900 Subject: [PATCH 21/34] [ruby/rubygems] Unlock every locked spec when an :all override is present An :all override applies to every gem's metadata, so we have no way to know which locked entries it affects without re-resolving. Force-unlock them all when an :all override appears so the resolver gets a fresh chance to apply the override. https://github.com/ruby/rubygems/commit/4f61f6813e Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/definition.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 7f5a72f0ebf0ec..aa21b5eb0177fe 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -1061,6 +1061,11 @@ def converge_dependencies def converge_overrides_outside_dependencies @overrides.each do |override| + if override.target == :all + unlock_all_locked_specs_for_override + next + end + next unless override.target.is_a?(String) name = override.target @@ -1076,6 +1081,15 @@ def converge_overrides_outside_dependencies end end + def unlock_all_locked_specs_for_override + @originally_locked_specs.each do |locked_spec| + name = locked_spec.name + next if @changed_dependencies.include?(name) + @gems_to_unlock << name + @changed_dependencies << name + end + end + # Remove elements from the locked specs that are expired. This will most # commonly happen if the Gemfile has changed since the lockfile was last # generated From 139e281962b8a3859b9c338c99ede86bfc61c2ce Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 18:57:50 +0900 Subject: [PATCH 22/34] [ruby/rubygems] Cover :all target metadata-field override end-to-end Exercise :all required_ruby_version overrides applied to multiple gems at once, the per-gem precedence rule, and re-resolution against an existing lockfile when an :all override is introduced. https://github.com/ruby/rubygems/commit/81f2bfcf9b Co-Authored-By: Claude Opus 4.7 (1M context) --- spec/bundler/install/gemfile/override_spec.rb | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/spec/bundler/install/gemfile/override_spec.rb b/spec/bundler/install/gemfile/override_spec.rb index 20e812a553a971..64fd9d0442554e 100644 --- a/spec/bundler/install/gemfile/override_spec.rb +++ b/spec/bundler/install/gemfile/override_spec.rb @@ -243,4 +243,78 @@ expect(lockfile).to include("needs_old_rubygems (1.0)") end end + + context "with an :all target" do + it "applies required_ruby_version: :ignore_upper to every gem" do + build_repo2 do + build_gem "needs_old_ruby_a", "1.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + build_gem "needs_old_ruby_b", "1.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + end + + gemfile <<-G + source "https://gem.repo2" + override :all, required_ruby_version: :ignore_upper + gem "needs_old_ruby_a" + gem "needs_old_ruby_b" + G + + bundle :lock + expect(lockfile).to include("needs_old_ruby_a (1.0)") + expect(lockfile).to include("needs_old_ruby_b (1.0)") + end + + it "is overridden by a per-gem override on the same field" do + build_repo2 do + build_gem "permissive", "1.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + build_gem "still_blocked", "1.0" do |s| + s.required_ruby_version = "= #{Gem.ruby_version}.999" + end + end + + # :all says ignore_upper (would unblock both), but per-gem on + # still_blocked nails it to a hard requirement that still fails. + gemfile <<-G + source "https://gem.repo2" + override :all, required_ruby_version: :ignore_upper + override "still_blocked", required_ruby_version: "= #{Gem.ruby_version}.999" + gem "permissive" + gem "still_blocked" + G + + bundle :lock, raise_on_error: false + expect(err).to include("still_blocked") + end + + it "re-resolves a previously locked spec when an :all metadata override is added" do + build_repo2 do + build_gem "selectable", "1.0" + build_gem "selectable", "2.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + end + + gemfile <<-G + source "https://gem.repo2" + gem "selectable" + G + + bundle :lock + expect(lockfile).to include("selectable (1.0)") + + gemfile <<-G + source "https://gem.repo2" + override :all, required_ruby_version: :ignore_upper + gem "selectable" + G + + bundle :lock + expect(lockfile).to include("selectable (2.0)") + end + end end From 3e1a5faa1a7c02aa2ac8dd07dc98b74c55c130e4 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 19:08:22 +0900 Subject: [PATCH 23/34] [ruby/rubygems] Honor metadata overrides in MatchMetadata matches_current_ruby? / matches_current_rubygems? now look up the current Definition's overrides via Bundler.overrides and apply them before checking against the runtime Ruby/RubyGems version. This covers Installer#ensure_specs_are_compatible! and the materialize- layer choose_compatible / SpecSet#valid? checks uniformly without plumbing overrides through every materialization site. When no Definition is set yet (e.g. RubyGems-side calls outside a Bundler.definition block), Bundler.overrides returns an empty list and the methods fall through to their original behavior. https://github.com/ruby/rubygems/commit/afe9313b6e Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler.rb | 5 +++++ lib/bundler/match_metadata.rb | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/bundler.rb b/lib/bundler.rb index 12dde90fc5d835..c686b106c737c0 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -244,6 +244,11 @@ def frozen_bundle? Bundler.settings[:deployment] end + def overrides + return [] unless defined?(@definition) && @definition + @definition.overrides + end + def locked_gems @locked_gems ||= if defined?(@definition) && @definition diff --git a/lib/bundler/match_metadata.rb b/lib/bundler/match_metadata.rb index 6fd2994a85f2ab..75b0e4357c4df4 100644 --- a/lib/bundler/match_metadata.rb +++ b/lib/bundler/match_metadata.rb @@ -7,11 +7,11 @@ def matches_current_metadata? end def matches_current_ruby? - @required_ruby_version.satisfied_by?(Gem.ruby_version) + effective_required_ruby_version.satisfied_by?(Gem.ruby_version) end def matches_current_rubygems? - @required_rubygems_version.satisfied_by?(Gem.rubygems_version) + effective_required_rubygems_version.satisfied_by?(Gem.rubygems_version) end def expanded_dependencies @@ -26,5 +26,21 @@ def metadata_dependency(name, requirement) Gem::Dependency.new("#{name}\0", requirement) end + + private + + def effective_required_ruby_version + apply_metadata_override(@required_ruby_version, :required_ruby_version) + end + + def effective_required_rubygems_version + apply_metadata_override(@required_rubygems_version, :required_rubygems_version) + end + + def apply_metadata_override(requirement, field) + override = Override.find_for(Bundler.overrides, name, field) + return requirement unless override + override.apply_to(requirement) + end end end From 3a93bdcbbdd5b52877fa62205fc69f050848d8b8 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 19:08:26 +0900 Subject: [PATCH 24/34] [ruby/rubygems] Cover install-time compatibility for metadata overrides Drive bundle install end-to-end with a gem whose required_ruby_version or required_rubygems_version excludes the current runtime, asserting that a per-gem override (and an :all override) makes the install succeed instead of erroring at the install-time compatibility gate. https://github.com/ruby/rubygems/commit/dbc9f24269 Co-Authored-By: Claude Opus 4.7 (1M context) --- spec/bundler/install/gemfile/override_spec.rb | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/spec/bundler/install/gemfile/override_spec.rb b/spec/bundler/install/gemfile/override_spec.rb index 64fd9d0442554e..54dd03185338e0 100644 --- a/spec/bundler/install/gemfile/override_spec.rb +++ b/spec/bundler/install/gemfile/override_spec.rb @@ -317,4 +317,58 @@ expect(lockfile).to include("selectable (2.0)") end end + + context "install-time compatibility" do + it "installs a gem whose required_ruby_version excludes the current Ruby when an override removes the constraint" do + build_repo2 do + build_gem "needs_old_ruby", "1.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + end + + install_gemfile <<-G + source "https://gem.repo2" + override "needs_old_ruby", required_ruby_version: nil + gem "needs_old_ruby" + G + + expect(the_bundle).to include_gems "needs_old_ruby 1.0" + end + + it "installs a gem whose required_rubygems_version excludes the current RubyGems when an override removes it" do + build_repo2 do + build_gem "needs_old_rubygems", "1.0" do |s| + s.required_rubygems_version = "< #{Gem.rubygems_version}" + end + end + + install_gemfile <<-G + source "https://gem.repo2" + override "needs_old_rubygems", required_rubygems_version: nil + gem "needs_old_rubygems" + G + + expect(the_bundle).to include_gems "needs_old_rubygems 1.0" + end + + it "installs every gem when :all required_ruby_version override is in effect" do + build_repo2 do + build_gem "needs_old_ruby_a", "1.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + build_gem "needs_old_ruby_b", "1.0" do |s| + s.required_ruby_version = "< #{Gem.ruby_version}" + end + end + + install_gemfile <<-G + source "https://gem.repo2" + override :all, required_ruby_version: :ignore_upper + gem "needs_old_ruby_a" + gem "needs_old_ruby_b" + G + + expect(the_bundle).to include_gems "needs_old_ruby_a 1.0", "needs_old_ruby_b 1.0" + end + end end From f451ea9c9f8c5d11798cdd1ecf8f8865cd3654d2 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 19:11:54 +0900 Subject: [PATCH 25/34] [ruby/rubygems] Capture Gemfile source location for each override Bundler::Dsl#override now records caller_locations(1, 1).first on each Override so the originating Gemfile line can be surfaced in later diagnostics. https://github.com/ruby/rubygems/commit/ef73385cdc Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/dsl.rb | 3 ++- lib/bundler/override.rb | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 46389b6c68693b..d67291514bd807 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -201,8 +201,9 @@ def override(target, **operations) validate_override_uniqueness!(target, field) end + source_location = caller_locations(1, 1)&.first operations.each do |field, operation| - @overrides << Override.new(target, field, operation) + @overrides << Override.new(target, field, operation, source_location: source_location) end end diff --git a/lib/bundler/override.rb b/lib/bundler/override.rb index ed5b51281f6339..7b71415290c903 100644 --- a/lib/bundler/override.rb +++ b/lib/bundler/override.rb @@ -9,12 +9,18 @@ def self.find_for(overrides, name, field) overrides.find {|o| o.target == :all && o.field == field } end - attr_reader :target, :field, :operation + attr_reader :target, :field, :operation, :source_location - def initialize(target, field, operation) + def initialize(target, field, operation, source_location: nil) @target = target @field = field @operation = operation + @source_location = source_location + end + + def source_location_label + return nil unless @source_location + "#{File.basename(@source_location.path)}:#{@source_location.lineno}" end def apply_to(requirement) From 501fecb264ce104ae90560787f2d847bc52db626 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 19:11:57 +0900 Subject: [PATCH 26/34] [ruby/rubygems] Show active overrides when resolution fails Append the list of currently active overrides (with Gemfile location, when known) to the SolveFailure message so a user investigating a "could not find compatible versions" error sees what override changed the constraint set instead of being misled by the resolver-reported requirement. https://github.com/ruby/rubygems/commit/10b8b53270 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/resolver.rb | 16 ++++++++++++++ spec/bundler/install/gemfile/override_spec.rb | 21 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 5b575f15e6cb08..fb69becd6991d8 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -122,9 +122,25 @@ def solve_versions(root:, logger:) explanation << extended_explanation end + override_summary = override_diagnostic_summary + explanation << override_summary if override_summary + raise SolveFailure.new(explanation) end + def override_diagnostic_summary + return nil if @base.overrides.empty? + + lines = ["Bundler applied the following overrides while resolving:"] + @base.overrides.each do |override| + target = override.target == :all ? ":all" : override.target.inspect + location = override.source_location_label + lines << " override #{target}, #{override.field}: #{override.operation.inspect}" \ + "#{location ? " (declared at #{location})" : ""}" + end + "\n\n#{lines.join("\n")}" + end + def find_names_to_relax(incompatibility) names_to_unlock = [] names_to_allow_prereleases_for = [] diff --git a/spec/bundler/install/gemfile/override_spec.rb b/spec/bundler/install/gemfile/override_spec.rb index 54dd03185338e0..19fa2ee9151e3c 100644 --- a/spec/bundler/install/gemfile/override_spec.rb +++ b/spec/bundler/install/gemfile/override_spec.rb @@ -318,6 +318,27 @@ end end + context "diagnostic on resolve failure" do + it "lists active overrides with their Gemfile location" do + build_repo2 do + build_gem "needs_old_ruby", "1.0" do |s| + s.required_ruby_version = "= #{Gem.ruby_version}.999" + end + end + + gemfile <<-G + source "https://gem.repo2" + override "needs_old_ruby", required_ruby_version: "= #{Gem.ruby_version}.999" + gem "needs_old_ruby" + G + + bundle :lock, raise_on_error: false + expect(err).to include("Bundler applied the following overrides") + expect(err).to include("override \"needs_old_ruby\", required_ruby_version:") + expect(err).to match(/declared at Gemfile:\d+/) + end + end + context "install-time compatibility" do it "installs a gem whose required_ruby_version excludes the current Ruby when an override removes the constraint" do build_repo2 do From 0d5a5a613fc4c77586166e2a663315b083a0a451 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 8 May 2026 12:06:09 +0900 Subject: [PATCH 27/34] [ruby/rubygems] Document Phase 2 override DSL extensions in gemfile.5 Update the OVERRIDE section to cover the :all target, the required_ruby_version / required_rubygems_version fields, and the diagnostic shown on resolve failure. https://github.com/ruby/rubygems/commit/ac90c83b1b Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/man/gemfile.5 | 16 ++++++++++++---- lib/bundler/man/gemfile.5.ronn | 28 +++++++++++++++++++++------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lib/bundler/man/gemfile.5 b/lib/bundler/man/gemfile.5 index 0874bb5a4a7baf..64e93c4b153588 100644 --- a/lib/bundler/man/gemfile.5 +++ b/lib/bundler/man/gemfile.5 @@ -461,22 +461,24 @@ The \fBgemspec\fR method supports optional \fB:path\fR, \fB:glob\fR, \fB:name\fR .P When a \fBgemspec\fR dependency encounters version conflicts during resolution, the local version under development will always be selected \-\- even if there are remote versions that better match other requirements for the \fBgemspec\fR gem\. .SH "OVERRIDE" -The \fBoverride\fR directive rewrites the version requirement on another gem before resolution runs\. It targets the common case where an upstream gem's published metadata is too narrow on the current project's machine \-\- a stale upper bound, an unwanted floor, or a transitive pin that has to be lifted\. +The \fBoverride\fR directive rewrites a constraint on another gem before resolution runs\. It targets the common case where an upstream gem's published metadata is too narrow on the current project's machine \-\- a stale upper bound, an unwanted floor, or a transitive pin that has to be lifted\. .IP "" 4 .nf override , : .fi .IP "" 0 .P -\fB\fR is a gem name string\. \fB\fR is \fBversion:\fR\. \fB\fR is one of: +\fB\fR is a gem name string or \fB:all\fR\. \fB\fR is one of \fBversion:\fR, \fBrequired_ruby_version:\fR, or \fBrequired_rubygems_version:\fR\. \fB\fR is one of: .IP "\(bu" 4 -a version requirement string (e\.g\. \fB">= 8\.0"\fR), which \fBreplaces\fR the target's version requirement absolutely\. The original requirement, both direct and transitive, is discarded in favour of the override\. +a version requirement string (e\.g\. \fB">= 8\.0"\fR), which \fBreplaces\fR the target's requirement absolutely\. The original requirement, both direct and transitive, is discarded in favour of the override\. .IP "\(bu" 4 \fB:ignore_upper\fR, which removes upper\-bound operators (\fB<\fR and \fB<=\fR) from the existing requirement and folds \fB~>\fR into its lower bound (\fB~> 1\.5\fR becomes \fB>= 1\.5\fR)\. Other operators, including \fB!=\fR, are preserved\. .IP "\(bu" 4 \fBnil\fR, which collapses the requirement to \fB>= 0\fR (no constraint at all)\. .IP "" 0 .P +\fB:all\fR only applies to \fBrequired_ruby_version:\fR and \fBrequired_rubygems_version:\fR\. A per\-gem override on the same field takes precedence over an \fB:all\fR override\. \fB:all + version:\fR is rejected: version requirements only make sense per gem\. +.P Multiple \fBoverride\fR calls for distinct targets are allowed; declaring the same \fBtarget\fR and \fBfield\fR twice is an error\. .IP "" 4 .nf @@ -491,11 +493,17 @@ override "nokogiri", version: :ignore_upper # Drop the version pin on legacy entirely\. override "legacy", version: nil +# Loosen every gem's required_ruby_version upper bound\. +override :all, required_ruby_version: :ignore_upper + +# Override one specific gem's required_rubygems_version\. +override "tricky", required_rubygems_version: nil + gem "rails", "~> 7\.0" .fi .IP "" 0 .P -The override only affects resolution; \fBGemfile\.lock\fR continues to reflect the resolved versions, not the rewritten requirements\. +The override only affects resolution and the install\-time Ruby/RubyGems compatibility checks; \fBGemfile\.lock\fR continues to reflect the resolved versions, not the rewritten requirements\. When resolution still fails, Bundler appends the active overrides (with their Gemfile location) to the error message so it is clear which override shaped the constraint set\. .SH "SOURCE PRIORITY" When attempting to locate a gem to satisfy a gem requirement, bundler uses the following priority order: .IP "1." 4 diff --git a/lib/bundler/man/gemfile.5.ronn b/lib/bundler/man/gemfile.5.ronn index 1779fc0a015209..69fef906549d19 100644 --- a/lib/bundler/man/gemfile.5.ronn +++ b/lib/bundler/man/gemfile.5.ronn @@ -543,24 +543,29 @@ remote versions that better match other requirements for the `gemspec` gem. ## OVERRIDE -The `override` directive rewrites the version requirement on another gem -before resolution runs. It targets the common case where an upstream gem's +The `override` directive rewrites a constraint on another gem before +resolution runs. It targets the common case where an upstream gem's published metadata is too narrow on the current project's machine -- a stale upper bound, an unwanted floor, or a transitive pin that has to be lifted. override , : -`` is a gem name string. `` is `version:`. `` is +`` is a gem name string or `:all`. `` is one of `version:`, +`required_ruby_version:`, or `required_rubygems_version:`. `` is one of: * a version requirement string (e.g. `">= 8.0"`), which **replaces** the - target's version requirement absolutely. The original requirement, both - direct and transitive, is discarded in favour of the override. + target's requirement absolutely. The original requirement, both direct + and transitive, is discarded in favour of the override. * `:ignore_upper`, which removes upper-bound operators (`<` and `<=`) from the existing requirement and folds `~>` into its lower bound (`~> 1.5` becomes `>= 1.5`). Other operators, including `!=`, are preserved. * `nil`, which collapses the requirement to `>= 0` (no constraint at all). +`:all` only applies to `required_ruby_version:` and `required_rubygems_version:`. +A per-gem override on the same field takes precedence over an `:all` override. +`:all + version:` is rejected: version requirements only make sense per gem. + Multiple `override` calls for distinct targets are allowed; declaring the same `target` and `field` twice is an error. @@ -575,10 +580,19 @@ same `target` and `field` twice is an error. # Drop the version pin on legacy entirely. override "legacy", version: nil + # Loosen every gem's required_ruby_version upper bound. + override :all, required_ruby_version: :ignore_upper + + # Override one specific gem's required_rubygems_version. + override "tricky", required_rubygems_version: nil + gem "rails", "~> 7.0" -The override only affects resolution; `Gemfile.lock` continues to reflect -the resolved versions, not the rewritten requirements. +The override only affects resolution and the install-time Ruby/RubyGems +compatibility checks; `Gemfile.lock` continues to reflect the resolved +versions, not the rewritten requirements. When resolution still fails, +Bundler appends the active overrides (with their Gemfile location) to the +error message so it is clear which override shaped the constraint set. ## SOURCE PRIORITY From 0beb804ef79c3355c19ed272106c42b02780b607 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 20:07:14 +0900 Subject: [PATCH 28/34] [ruby/rubygems] Thread overrides explicitly instead of through a Bundler global Phase 2.C wired overrides into MatchMetadata via Bundler.overrides, a process-wide accessor read every time a spec answered matches_current_metadata?. That leaked the user's Gemfile overrides into Bundler-internal callers like SelfManager#remote_specs, where overrides have no business: a Gemfile override could let bundle self-update consider Bundler releases that are actually incompatible with the running Ruby/RubyGems. Revert MatchMetadata's matches_current_ruby? and matches_current_rubygems? to evaluate the spec's own metadata, and add explicit matches_current_*_with_overrides? variants. Pass overrides explicitly: Installer#ensure_specs_are_compatible! gets them from @definition, LazySpecification#choose_compatible reads its newly-added @overrides attribute, and SpecSet#valid? reads @overrides set on the SpecSet. Definition propagates @overrides to the SpecSets it constructs and to the LazySpecs they contain. SelfManager and other callers that should keep evaluating real gemspec metadata reach the strict path unchanged. https://github.com/ruby/rubygems/commit/e0ff753bbb Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler.rb | 5 ---- lib/bundler/definition.rb | 12 +++++----- lib/bundler/installer.rb | 5 ++-- lib/bundler/lazy_specification.rb | 5 ++-- lib/bundler/match_metadata.rb | 32 ++++++++++++++----------- lib/bundler/match_remote_metadata.rb | 27 ++++++++++++++++----- lib/bundler/spec_set.rb | 13 ++++++++-- spec/bundler/bundler/override_spec.rb | 34 +++++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 37 deletions(-) diff --git a/lib/bundler.rb b/lib/bundler.rb index c686b106c737c0..12dde90fc5d835 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -244,11 +244,6 @@ def frozen_bundle? Bundler.settings[:deployment] end - def overrides - return [] unless defined?(@definition) && @definition - @definition.overrides - end - def locked_gems @locked_gems ||= if defined?(@definition) && @definition diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index aa21b5eb0177fe..2fe28f7656be9c 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -111,12 +111,12 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti @locked_bundler_version = @locked_gems.bundler_version @locked_ruby_version = @locked_gems.ruby_version @locked_deps = @locked_gems.dependencies - @originally_locked_specs = SpecSet.new(@locked_gems.specs) + @originally_locked_specs = SpecSet.new(@locked_gems.specs).with_overrides(@overrides) @originally_locked_sources = @locked_gems.sources @locked_checksums = @locked_gems.checksums if @unlocking_all - @locked_specs = SpecSet.new([]) + @locked_specs = SpecSet.new([]).with_overrides(@overrides) @locked_sources = [] else @locked_specs = @originally_locked_specs @@ -137,7 +137,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti @most_specific_locked_platform = nil @platforms = [] @locked_deps = {} - @locked_specs = SpecSet.new([]) + @locked_specs = SpecSet.new([]).with_overrides(@overrides) @locked_sources = [] @originally_locked_specs = @locked_specs @originally_locked_sources = @locked_sources @@ -506,7 +506,7 @@ def validate_platforms! def normalize_platforms resolve.normalize_platforms!(current_dependencies, platforms) - @resolve = SpecSet.new(resolve.for(current_dependencies, @platforms)) + @resolve = SpecSet.new(resolve.for(current_dependencies, @platforms)).with_overrides(@overrides) end def add_platform(platform) @@ -762,7 +762,7 @@ def start_resolution local_platform_needed_for_resolvability = @most_specific_non_local_locked_platform && !@platforms.include?(Bundler.local_platform) @platforms << Bundler.local_platform if local_platform_needed_for_resolvability - result = SpecSet.new(resolver.start) + result = SpecSet.new(resolver.start).with_overrides(@overrides) @resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version @@ -788,7 +788,7 @@ def start_resolution result.add_originally_invalid_platforms!(platforms, @originally_invalid_platforms) end - SpecSet.new(result.for(dependencies, @platforms | [Gem::Platform::RUBY])) + SpecSet.new(result.for(dependencies, @platforms | [Gem::Platform::RUBY])).with_overrides(@overrides) end def precompute_source_requirements_for_indirect_dependencies? diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 3455f72c2143b5..ef607cabdbf198 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -211,12 +211,13 @@ def load_plugins end def ensure_specs_are_compatible! + overrides = @definition.overrides @definition.specs.each do |spec| - unless spec.matches_current_ruby? + unless spec.matches_current_ruby_with_overrides?(overrides) raise InstallError, "#{spec.full_name} requires ruby version #{spec.required_ruby_version}, " \ "which is incompatible with the current version, #{Gem.ruby_version}" end - unless spec.matches_current_rubygems? + unless spec.matches_current_rubygems_with_overrides?(overrides) raise InstallError, "#{spec.full_name} requires rubygems version #{spec.required_rubygems_version}, " \ "which is incompatible with the current version, #{Gem.rubygems_version}" end diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 46b1e905d398e3..86b29ee1150820 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -9,7 +9,7 @@ class LazySpecification include ForcePlatform attr_reader :name, :version, :platform, :materialization - attr_accessor :source, :remote, :force_ruby_platform, :dependencies, :required_ruby_version, :required_rubygems_version + attr_accessor :source, :remote, :force_ruby_platform, :dependencies, :required_ruby_version, :required_rubygems_version, :overrides # # For backwards compatibility with existing lockfiles, if the most specific @@ -234,8 +234,9 @@ def materialize(query) # about the mismatch higher up the stack, right before trying to install the # bad gem. def choose_compatible(candidates, fallback_to_non_installable: Bundler.frozen_bundle?) + override_list = overrides || [] search = candidates.reverse.find do |spec| - spec.is_a?(StubSpecification) || spec.matches_current_metadata? + spec.is_a?(StubSpecification) || spec.matches_current_metadata_with_overrides?(override_list) end if search.nil? && fallback_to_non_installable search = candidates.last diff --git a/lib/bundler/match_metadata.rb b/lib/bundler/match_metadata.rb index 75b0e4357c4df4..92aeb2e893cb69 100644 --- a/lib/bundler/match_metadata.rb +++ b/lib/bundler/match_metadata.rb @@ -7,11 +7,23 @@ def matches_current_metadata? end def matches_current_ruby? - effective_required_ruby_version.satisfied_by?(Gem.ruby_version) + @required_ruby_version.satisfied_by?(Gem.ruby_version) end def matches_current_rubygems? - effective_required_rubygems_version.satisfied_by?(Gem.rubygems_version) + @required_rubygems_version.satisfied_by?(Gem.rubygems_version) + end + + def matches_current_metadata_with_overrides?(overrides) + matches_current_ruby_with_overrides?(overrides) && matches_current_rubygems_with_overrides?(overrides) + end + + def matches_current_ruby_with_overrides?(overrides) + effective_required_version(@required_ruby_version, :required_ruby_version, overrides).satisfied_by?(Gem.ruby_version) + end + + def matches_current_rubygems_with_overrides?(overrides) + effective_required_version(@required_rubygems_version, :required_rubygems_version, overrides).satisfied_by?(Gem.rubygems_version) end def expanded_dependencies @@ -29,18 +41,10 @@ def metadata_dependency(name, requirement) private - def effective_required_ruby_version - apply_metadata_override(@required_ruby_version, :required_ruby_version) - end - - def effective_required_rubygems_version - apply_metadata_override(@required_rubygems_version, :required_rubygems_version) - end - - def apply_metadata_override(requirement, field) - override = Override.find_for(Bundler.overrides, name, field) - return requirement unless override - override.apply_to(requirement) + def effective_required_version(requirement, field, overrides) + return requirement if overrides.nil? || overrides.empty? + override = Override.find_for(overrides, name, field) + override ? override.apply_to(requirement) : requirement end end end diff --git a/lib/bundler/match_remote_metadata.rb b/lib/bundler/match_remote_metadata.rb index 5e46d524410e03..601af7e55de25c 100644 --- a/lib/bundler/match_remote_metadata.rb +++ b/lib/bundler/match_remote_metadata.rb @@ -6,19 +6,34 @@ module FetchMetadata # API didn't include that field, so some marshalled specs in the index have it # set to +nil+. def matches_current_ruby? - @required_ruby_version ||= _remote_specification.required_ruby_version || Gem::Requirement.default - + ensure_required_ruby_version_loaded super end def matches_current_rubygems? - # A fallback is included because the original version of the specification - # API didn't include that field, so some marshalled specs in the index have it - # set to +nil+. - @required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default + ensure_required_rubygems_version_loaded + super + end + + def matches_current_ruby_with_overrides?(overrides) + ensure_required_ruby_version_loaded + super + end + def matches_current_rubygems_with_overrides?(overrides) + ensure_required_rubygems_version_loaded super end + + private + + def ensure_required_ruby_version_loaded + @required_ruby_version ||= _remote_specification.required_ruby_version || Gem::Requirement.default # rubocop:disable Naming/MemoizedInstanceVariableName + end + + def ensure_required_rubygems_version_loaded + @required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default # rubocop:disable Naming/MemoizedInstanceVariableName + end end module MatchRemoteMetadata diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index e8d990d207a877..84f20d90d0adbd 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -7,8 +7,17 @@ class SpecSet include Enumerable include TSort + attr_accessor :overrides + def initialize(specs) @specs = specs + @overrides = [] + end + + def with_overrides(overrides) + @overrides = overrides || [] + @specs.each {|s| s.overrides = @overrides if s.respond_to?(:overrides=) } + self end def for(dependencies, platforms = [nil], legacy_platforms = [nil], skips: []) @@ -125,7 +134,7 @@ def to_hash def materialize(deps) materialize_dependencies(deps) - SpecSet.new(materialized_specs) + SpecSet.new(materialized_specs).with_overrides(@overrides) end # Materialize for all the specs in the spec set, regardless of what platform they're for @@ -229,7 +238,7 @@ def names end def valid?(s) - s.matches_current_metadata? && valid_dependencies?(s) + s.matches_current_metadata_with_overrides?(@overrides) && valid_dependencies?(s) end def to_s diff --git a/spec/bundler/bundler/override_spec.rb b/spec/bundler/bundler/override_spec.rb index 78f7a62900ce87..d1a5568bd8e845 100644 --- a/spec/bundler/bundler/override_spec.rb +++ b/spec/bundler/bundler/override_spec.rb @@ -1,5 +1,39 @@ # frozen_string_literal: true +RSpec.describe "MatchMetadata override-aware checks" do + let(:spec_class) do + Class.new do + include Bundler::MatchMetadata + attr_accessor :name + def initialize(name, ruby_req, rubygems_req) + @name = name + @required_ruby_version = ruby_req + @required_rubygems_version = rubygems_req + end + end + end + + it "matches_current_metadata? ignores overrides (strict path)" do + spec = spec_class.new("rails", Gem::Requirement.new("< #{Gem.ruby_version}"), Gem::Requirement.default) + overrides = [Bundler::Override.new("rails", :required_ruby_version, :ignore_upper)] + # Strict method MUST NOT apply overrides; guards SelfManager and other generic callers. + expect(spec.matches_current_metadata?).to be(false) + expect(spec.matches_current_metadata_with_overrides?(overrides)).to be(true) + end + + it "matches_current_ruby_with_overrides? returns the strict result for an empty override list" do + spec = spec_class.new("rails", Gem::Requirement.new(">= #{Gem.ruby_version}"), Gem::Requirement.default) + expect(spec.matches_current_ruby_with_overrides?([])).to be(true) + expect(spec.matches_current_ruby_with_overrides?(nil)).to be(true) + end + + it "matches_current_rubygems_with_overrides? honors :all override" do + spec = spec_class.new("rails", Gem::Requirement.default, Gem::Requirement.new("< #{Gem.rubygems_version}")) + overrides = [Bundler::Override.new(:all, :required_rubygems_version, :ignore_upper)] + expect(spec.matches_current_rubygems_with_overrides?(overrides)).to be(true) + end +end + RSpec.describe Bundler::Override do describe ".find_for" do it "returns the matching override by target and field" do From dff3200e5ca078977a40d92ad4236b9c8d60499e Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 20:08:37 +0900 Subject: [PATCH 29/34] [ruby/rubygems] Stop blanket-unlocking the lockfile on :all overrides Previously, any :all override called unlock_all_locked_specs_for_override which pushed every locked spec into @gems_to_unlock. A user adding a narrow `override :all, required_ruby_version: :ignore_upper` thus paid for a full re-resolve that could pull unrelated dependency upgrades/downgrades. Make :all overrides leave the lockfile alone at converge time. They take effect on a fresh resolution (no lockfile) or when the user opts in via `bundle update`. Per-gem overrides retain their unlock for the named gem since the user explicitly named the target. https://github.com/ruby/rubygems/commit/3c95ab99e3 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/definition.rb | 18 ++++-------------- spec/bundler/install/gemfile/override_spec.rb | 8 +++++++- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 2fe28f7656be9c..2aa74804ba5d86 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -1061,11 +1061,10 @@ def converge_dependencies def converge_overrides_outside_dependencies @overrides.each do |override| - if override.target == :all - unlock_all_locked_specs_for_override - next - end - + # :all overrides are intentionally not pre-unlocked. They take effect on + # fresh resolution (no lockfile) or when the user runs `bundle update`. + # Forcing a full re-resolve from a single :all directive would surprise + # users with unrelated dependency churn. next unless override.target.is_a?(String) name = override.target @@ -1081,15 +1080,6 @@ def converge_overrides_outside_dependencies end end - def unlock_all_locked_specs_for_override - @originally_locked_specs.each do |locked_spec| - name = locked_spec.name - next if @changed_dependencies.include?(name) - @gems_to_unlock << name - @changed_dependencies << name - end - end - # Remove elements from the locked specs that are expired. This will most # commonly happen if the Gemfile has changed since the lockfile was last # generated diff --git a/spec/bundler/install/gemfile/override_spec.rb b/spec/bundler/install/gemfile/override_spec.rb index 19fa2ee9151e3c..02b0e7d772a211 100644 --- a/spec/bundler/install/gemfile/override_spec.rb +++ b/spec/bundler/install/gemfile/override_spec.rb @@ -291,7 +291,7 @@ expect(err).to include("still_blocked") end - it "re-resolves a previously locked spec when an :all metadata override is added" do + it "preserves locked versions when an :all metadata override is added without bundle update" do build_repo2 do build_gem "selectable", "1.0" build_gem "selectable", "2.0" do |s| @@ -313,7 +313,13 @@ gem "selectable" G + # :all override alone does not pre-unlock locked specs; narrow change + # should not trigger unrelated lockfile churn. bundle :lock + expect(lockfile).to include("selectable (1.0)") + + # bundle update opts the user into re-resolution under the override. + bundle "update selectable" expect(lockfile).to include("selectable (2.0)") end end From 7988b2c524e7b86a30945919d61ee54b23bf5486 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 20:38:58 +0900 Subject: [PATCH 30/34] [ruby/rubygems] Propagate overrides into Definition#resolve lockfile-reuse paths Definition#resolve falls back to an existing lockfile when nothing about the Gemfile or the locked deps changed. The two SpecSet rebuild paths (deleted_deps subset and the redundant-platform-specific-gems fallback) constructed fresh SpecSet instances without carrying @overrides forward, so any LazySpec produced from them lost its override context. After Step G that mattered: an :all metadata override does not pre-unlock anything by design, which means it must flow through these reuse paths intact. Without it, the materialize layer either silently re-resolved (which churns the lockfile) or, on the install-time check, fell back to the spec's strict required_ruby_version metadata. Calling with_overrides on both rebuilt SpecSets keeps the install-time behavior consistent across resolve and lockfile-reuse paths. https://github.com/ruby/rubygems/commit/81fb91a8b1 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/definition.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 2aa74804ba5d86..45c6e9a693b98e 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -338,11 +338,11 @@ def resolve elsif no_resolve_needed? if deleted_deps.any? Bundler.ui.debug "Some dependencies were deleted, using a subset of the resolution from the lockfile" - SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps)) + SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps)).with_overrides(@overrides) else Bundler.ui.debug "Found no changes, using resolution from the lockfile" if @removed_platforms.any? || @locked_gems.may_include_redundant_platform_specific_gems? - SpecSet.new(filter_specs(@locked_specs, @dependencies)) + SpecSet.new(filter_specs(@locked_specs, @dependencies)).with_overrides(@overrides) else @locked_specs end From 5ef1dc036934efe8dcdba042fd3e876b0cce92b1 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 7 May 2026 20:43:28 +0900 Subject: [PATCH 31/34] [ruby/rubygems] Preserve overrides when SpecSet self-derives a validation set SpecSet#incomplete_specs_for_platform constructed a fresh self.class.new(@specs) for platform validation but never copied @overrides. Platform-validity decisions therefore evaluated strict required_ruby_version / required_rubygems_version metadata even when resolution was running with overrides, so a metadata override could allow a gem everywhere except platform validation, where the platform might be marked incomplete and pruned. Carry @overrides forward via with_overrides on the cloned SpecSet. https://github.com/ruby/rubygems/commit/11b7c58a5a Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/spec_set.rb | 2 +- spec/bundler/bundler/spec_set_spec.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 84f20d90d0adbd..163e16863baba2 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -155,7 +155,7 @@ def incomplete_for_platform?(deps, platform) def incomplete_specs_for_platform(deps, platform) return [] if @specs.empty? - validation_set = self.class.new(@specs) + validation_set = self.class.new(@specs).with_overrides(@overrides) validation_set.for(deps, [platform]) validation_set.incomplete_specs end diff --git a/spec/bundler/bundler/spec_set_spec.rb b/spec/bundler/bundler/spec_set_spec.rb index d69d0bf8fd48f0..dce86793b9155d 100644 --- a/spec/bundler/bundler/spec_set_spec.rb +++ b/spec/bundler/bundler/spec_set_spec.rb @@ -92,4 +92,30 @@ ] end end + + describe "#with_overrides" do + it "defaults to an empty override list" do + expect(described_class.new([]).overrides).to eq([]) + end + + it "stores the overrides supplied" do + override = Bundler::Override.new("rails", :version, ">= 8.0") + expect(described_class.new([]).with_overrides([override]).overrides).to eq([override]) + end + + it "treats nil as an empty override list" do + set = described_class.new([]) + override = Bundler::Override.new("rails", :version, ">= 8.0") + set.with_overrides([override]) + set.with_overrides(nil) + expect(set.overrides).to eq([]) + end + + it "cascades overrides to contained specs that accept them" do + lazy = Bundler::LazySpecification.new("rails", "8.0", Gem::Platform::RUBY) + override = Bundler::Override.new("rails", :version, ">= 8.0") + described_class.new([lazy]).with_overrides([override]) + expect(lazy.overrides).to eq([override]) + end + end end From 6a506224a25f4e105c7ea76cb7074347a2a0aeae Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 8 May 2026 09:41:45 +0900 Subject: [PATCH 32/34] [ruby/rubygems] Avoid forcing a remote gemspec load when seeding LazySpec overrides SpecSet#with_overrides cascaded into each contained spec via `respond_to?(:overrides=)`. RemoteSpecification#respond_to? forwards to _remote_specification, which materializes the backing gemspec just to answer the predicate. spec/runtime/require_spec.rb verifies that Bundler does not load gemspecs it does not need by deliberately poisoning one with `raise 'broken gemspec'`; the cascade tripped that guard and made `Bundler.setup` blow up. Gate the cascade on `is_a?(LazySpecification)` instead. Only LazySpecification declares `attr_accessor :overrides` (used by `#choose_compatible`), so the predicate is equivalent for any spec we ever set overrides on, and it never triggers the lazy gemspec load. https://github.com/ruby/rubygems/commit/2a1e7d5c23 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/spec_set.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 163e16863baba2..72e4d9c1dd4f73 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -16,7 +16,11 @@ def initialize(specs) def with_overrides(overrides) @overrides = overrides || [] - @specs.each {|s| s.overrides = @overrides if s.respond_to?(:overrides=) } + # Only LazySpecification carries an overrides accessor. Avoid + # respond_to?(:overrides=) here because RemoteSpecification#respond_to? + # forwards to _remote_specification, which would force-load the + # backing gemspec to answer the question. + @specs.each {|s| s.overrides = @overrides if s.is_a?(LazySpecification) } self end From 5970638803840297c2daaca1635c9a98453d740c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 8 May 2026 11:55:13 +0900 Subject: [PATCH 33/34] [ruby/rubygems] Move overrides off SpecSet onto LazySpecification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SpecSet previously kept its own @overrides and a with_overrides setter that had to be chained on every SpecSet.new(...) site (~13 sites in Definition alone). Two Codex review rounds both flagged forgotten chains in different SpecSet construction paths, which is exactly the class of bug the chain pattern invites: it is purely "remember to write" with no compiler help. Move the override list to LazySpecification#overrides instead. The LazySpec is the natural carrier — it is the value object the resolver and install paths already pass around, and choose_compatible already read overrides off it. Override.attach(specs, overrides) is added as the dual of Override.find_for so Definition (after lockfile load) and Resolver (after solve_versions) can populate the overrides on every LazySpec they hand out, and LazySpecification.from_spec carries the list forward when one LazySpec spawns another. Generic spec types (StubSpecification, plain Gem::Specification, RemoteSpecification) are intentionally ignored so generic metadata callers (SelfManager, materialize-time strict checks) keep their current strict semantics. SpecSet drops attr_accessor :overrides, the @overrides initialisation, the with_overrides cascade, and reverts SpecSet#valid? to the strict matches_current_metadata? check. Every SpecSet.new(...) site in Definition stops chaining .with_overrides — the LazySpecs already carry the context. https://github.com/ruby/rubygems/commit/fc1e8d4d7e Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/definition.rb | 17 +++++++++-------- lib/bundler/lazy_specification.rb | 1 + lib/bundler/override.rb | 10 ++++++++++ lib/bundler/resolver.rb | 1 + lib/bundler/spec_set.rb | 19 +++---------------- spec/bundler/bundler/override_spec.rb | 27 +++++++++++++++++++++++++++ spec/bundler/bundler/spec_set_spec.rb | 25 ------------------------- 7 files changed, 51 insertions(+), 49 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 45c6e9a693b98e..6f5ab29b1556da 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -111,12 +111,13 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti @locked_bundler_version = @locked_gems.bundler_version @locked_ruby_version = @locked_gems.ruby_version @locked_deps = @locked_gems.dependencies - @originally_locked_specs = SpecSet.new(@locked_gems.specs).with_overrides(@overrides) + Override.attach(@locked_gems.specs, @overrides) + @originally_locked_specs = SpecSet.new(@locked_gems.specs) @originally_locked_sources = @locked_gems.sources @locked_checksums = @locked_gems.checksums if @unlocking_all - @locked_specs = SpecSet.new([]).with_overrides(@overrides) + @locked_specs = SpecSet.new([]) @locked_sources = [] else @locked_specs = @originally_locked_specs @@ -137,7 +138,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti @most_specific_locked_platform = nil @platforms = [] @locked_deps = {} - @locked_specs = SpecSet.new([]).with_overrides(@overrides) + @locked_specs = SpecSet.new([]) @locked_sources = [] @originally_locked_specs = @locked_specs @originally_locked_sources = @locked_sources @@ -338,11 +339,11 @@ def resolve elsif no_resolve_needed? if deleted_deps.any? Bundler.ui.debug "Some dependencies were deleted, using a subset of the resolution from the lockfile" - SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps)).with_overrides(@overrides) + SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps)) else Bundler.ui.debug "Found no changes, using resolution from the lockfile" if @removed_platforms.any? || @locked_gems.may_include_redundant_platform_specific_gems? - SpecSet.new(filter_specs(@locked_specs, @dependencies)).with_overrides(@overrides) + SpecSet.new(filter_specs(@locked_specs, @dependencies)) else @locked_specs end @@ -506,7 +507,7 @@ def validate_platforms! def normalize_platforms resolve.normalize_platforms!(current_dependencies, platforms) - @resolve = SpecSet.new(resolve.for(current_dependencies, @platforms)).with_overrides(@overrides) + @resolve = SpecSet.new(resolve.for(current_dependencies, @platforms)) end def add_platform(platform) @@ -762,7 +763,7 @@ def start_resolution local_platform_needed_for_resolvability = @most_specific_non_local_locked_platform && !@platforms.include?(Bundler.local_platform) @platforms << Bundler.local_platform if local_platform_needed_for_resolvability - result = SpecSet.new(resolver.start).with_overrides(@overrides) + result = SpecSet.new(resolver.start) @resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version @@ -788,7 +789,7 @@ def start_resolution result.add_originally_invalid_platforms!(platforms, @originally_invalid_platforms) end - SpecSet.new(result.for(dependencies, @platforms | [Gem::Platform::RUBY])).with_overrides(@overrides) + SpecSet.new(result.for(dependencies, @platforms | [Gem::Platform::RUBY])) end def precompute_source_requirements_for_indirect_dependencies? diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 86b29ee1150820..0da621d21fb57c 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -30,6 +30,7 @@ def self.from_spec(s) lazy_spec.dependencies = s.runtime_dependencies lazy_spec.required_ruby_version = s.required_ruby_version lazy_spec.required_rubygems_version = s.required_rubygems_version + lazy_spec.overrides = s.overrides if s.is_a?(LazySpecification) lazy_spec end diff --git a/lib/bundler/override.rb b/lib/bundler/override.rb index 7b71415290c903..0e0ec59fd73e8e 100644 --- a/lib/bundler/override.rb +++ b/lib/bundler/override.rb @@ -9,6 +9,16 @@ def self.find_for(overrides, name, field) overrides.find {|o| o.target == :all && o.field == field } end + # Attach the given overrides onto every LazySpecification in `specs` so + # downstream consumers (LazySpecification#choose_compatible, the install- + # time compatibility check, etc.) can read the override list off the spec + # itself. Non-LazySpec entries (StubSpecification, Gem::Specification, ...) + # are left untouched. + def self.attach(specs, overrides) + return if overrides.nil? || overrides.empty? + specs.each {|s| s.overrides = overrides if s.is_a?(LazySpecification) } + end + attr_reader :target, :field, :operation, :source_location def initialize(target, field, operation, source_location: nil) diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index fb69becd6991d8..096a349249168b 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -82,6 +82,7 @@ def solve_versions(root:, logger:) solver = PubGrub::VersionSolver.new(source: self, root: root, strategy: Strategy.new(self), logger: logger) result = solver.solve resolved_specs = result.flat_map {|package, version| version.to_specs(package, @most_specific_locked_platform) } + Override.attach(resolved_specs, @base.overrides) SpecSet.new(resolved_specs).specs_with_additional_variants_from(@base.locked_specs) rescue PubGrub::SolveFailure => e incompatibility = e.incompatibility diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 72e4d9c1dd4f73..e8d990d207a877 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -7,21 +7,8 @@ class SpecSet include Enumerable include TSort - attr_accessor :overrides - def initialize(specs) @specs = specs - @overrides = [] - end - - def with_overrides(overrides) - @overrides = overrides || [] - # Only LazySpecification carries an overrides accessor. Avoid - # respond_to?(:overrides=) here because RemoteSpecification#respond_to? - # forwards to _remote_specification, which would force-load the - # backing gemspec to answer the question. - @specs.each {|s| s.overrides = @overrides if s.is_a?(LazySpecification) } - self end def for(dependencies, platforms = [nil], legacy_platforms = [nil], skips: []) @@ -138,7 +125,7 @@ def to_hash def materialize(deps) materialize_dependencies(deps) - SpecSet.new(materialized_specs).with_overrides(@overrides) + SpecSet.new(materialized_specs) end # Materialize for all the specs in the spec set, regardless of what platform they're for @@ -159,7 +146,7 @@ def incomplete_for_platform?(deps, platform) def incomplete_specs_for_platform(deps, platform) return [] if @specs.empty? - validation_set = self.class.new(@specs).with_overrides(@overrides) + validation_set = self.class.new(@specs) validation_set.for(deps, [platform]) validation_set.incomplete_specs end @@ -242,7 +229,7 @@ def names end def valid?(s) - s.matches_current_metadata_with_overrides?(@overrides) && valid_dependencies?(s) + s.matches_current_metadata? && valid_dependencies?(s) end def to_s diff --git a/spec/bundler/bundler/override_spec.rb b/spec/bundler/bundler/override_spec.rb index d1a5568bd8e845..ad8be75520b5e8 100644 --- a/spec/bundler/bundler/override_spec.rb +++ b/spec/bundler/bundler/override_spec.rb @@ -34,6 +34,33 @@ def initialize(name, ruby_req, rubygems_req) end end +RSpec.describe "LazySpecification override propagation" do + let(:overrides) { [Bundler::Override.new("rails", :required_ruby_version, :ignore_upper)] } + + it "carries overrides forward from a source LazySpec via from_spec" do + src = Bundler::LazySpecification.new("rails", "8.0", Gem::Platform::RUBY) + src.overrides = overrides + derived = Bundler::LazySpecification.from_spec(src) + expect(derived.overrides).to eq(overrides) + end + + it "does not call respond_to? on the source spec, avoiding gemspec lazy load" do + # If from_spec used respond_to?(:overrides), a RemoteSpec source would + # force-load the backing gemspec. Use a stand-in object whose + # respond_to? raises to prove it is never asked. + src = Object.new + src.define_singleton_method(:name) { "rails" } + src.define_singleton_method(:version) { Gem::Version.new("8.0") } + src.define_singleton_method(:platform) { Gem::Platform::RUBY } + src.define_singleton_method(:source) { nil } + src.define_singleton_method(:runtime_dependencies) { [] } + src.define_singleton_method(:required_ruby_version) { Gem::Requirement.default } + src.define_singleton_method(:required_rubygems_version) { Gem::Requirement.default } + src.define_singleton_method(:respond_to?) {|*| raise "from_spec must not call respond_to?" } + expect { Bundler::LazySpecification.from_spec(src) }.not_to raise_error + end +end + RSpec.describe Bundler::Override do describe ".find_for" do it "returns the matching override by target and field" do diff --git a/spec/bundler/bundler/spec_set_spec.rb b/spec/bundler/bundler/spec_set_spec.rb index dce86793b9155d..3e630555e6252e 100644 --- a/spec/bundler/bundler/spec_set_spec.rb +++ b/spec/bundler/bundler/spec_set_spec.rb @@ -93,29 +93,4 @@ end end - describe "#with_overrides" do - it "defaults to an empty override list" do - expect(described_class.new([]).overrides).to eq([]) - end - - it "stores the overrides supplied" do - override = Bundler::Override.new("rails", :version, ">= 8.0") - expect(described_class.new([]).with_overrides([override]).overrides).to eq([override]) - end - - it "treats nil as an empty override list" do - set = described_class.new([]) - override = Bundler::Override.new("rails", :version, ">= 8.0") - set.with_overrides([override]) - set.with_overrides(nil) - expect(set.overrides).to eq([]) - end - - it "cascades overrides to contained specs that accept them" do - lazy = Bundler::LazySpecification.new("rails", "8.0", Gem::Platform::RUBY) - override = Bundler::Override.new("rails", :version, ">= 8.0") - described_class.new([lazy]).with_overrides([override]) - expect(lazy.overrides).to eq([override]) - end - end end From 95ce1c5228a86fffdce7535a374008e7cbcd076c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 8 May 2026 11:56:53 +0900 Subject: [PATCH 34/34] [ruby/rubygems] Honor LazySpec overrides in SpecSet#complete_platform complete_platform validates platform-specific candidates returned by spec.source.specs.search, which are remote specs that do not carry the override list. Borrow the override list from the LazySpec exemplar already in scope so platform-variant validation uses the same effective metadata as the install/resolve path. Also propagate the overrides onto the synthesized LazySpec built from platform_spec. Without this, the next complete_platform call could pick the synthesized variant as its exemplar (it is now in the set returned by lookup) and fall back to strict matching, dropping platforms that the user's override would otherwise allow. https://github.com/ruby/rubygems/commit/205955c5b3 Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/spec_set.rb | 16 +++++++-- spec/bundler/bundler/spec_set_spec.rb | 52 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index e8d990d207a877..ae5e5cbaa9852d 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -274,13 +274,25 @@ def complete_platform(platform) valid_platform = lookup.all? do |_, specs| spec = specs.first + # The matching candidates returned by source.specs.search are remote + # specs that do not carry the override list themselves. Borrow it from + # the LazySpec we are validating so platform-variant validation honors + # the same overrides the install/resolve path already applies. + overrides = spec.is_a?(LazySpecification) ? Array(spec.overrides) : [] matching_specs = spec.source.specs.search([spec.name, spec.version]) platform_spec = MatchPlatform.select_best_platform_match(matching_specs, platform).find do |s| - valid?(s) + s.matches_current_metadata_with_overrides?(overrides) && valid_dependencies?(s) end if platform_spec - new_specs << LazySpecification.from_spec(platform_spec) unless specs.include?(platform_spec) + unless specs.include?(platform_spec) + new_lazy = LazySpecification.from_spec(platform_spec) + # Carry the overrides forward so a follow-up complete_platform + # call that picks this synthesized variant as its exemplar still + # honors the user's override list. + new_lazy.overrides = overrides if overrides.any? + new_specs << new_lazy + end true else false diff --git a/spec/bundler/bundler/spec_set_spec.rb b/spec/bundler/bundler/spec_set_spec.rb index 3e630555e6252e..1e1ceadf26efdd 100644 --- a/spec/bundler/bundler/spec_set_spec.rb +++ b/spec/bundler/bundler/spec_set_spec.rb @@ -93,4 +93,56 @@ end end + describe "#complete_platform" do + let(:platform) { Gem::Platform.new("x86_64-linux") } + + let(:platform_variant) do + build_spec("needs_old_ruby", "1.0", platform).first.tap do |s| + s.required_ruby_version = Gem::Requirement.new("< #{Gem.ruby_version}") + end + end + + let(:lazy_spec) do + lazy = Bundler::LazySpecification.new("needs_old_ruby", Gem::Version.new("1.0"), Gem::Platform::RUBY) + lazy.required_ruby_version = Gem::Requirement.new("< #{Gem.ruby_version}") + source = double("source") + source_specs = double("source_specs") + allow(source).to receive(:specs).and_return(source_specs) + allow(source_specs).to receive(:search). + with(["needs_old_ruby", Gem::Version.new("1.0")]).and_return([platform_variant]) + lazy.source = source + lazy + end + + it "rejects a platform variant whose strict metadata is incompatible when no override is attached" do + set = described_class.new([lazy_spec]) + expect(set.send(:complete_platform, platform)).to be(false) + end + + it "accepts a platform variant when the LazySpec carries an override that allows it" do + lazy_spec.overrides = [Bundler::Override.new("needs_old_ruby", :required_ruby_version, :ignore_upper)] + set = described_class.new([lazy_spec]) + expect(set.send(:complete_platform, platform)).to be(true) + end + + it "carries overrides onto a synthesized LazySpec so a follow-up complete_platform still honors them" do + override = Bundler::Override.new("needs_old_ruby", :required_ruby_version, :ignore_upper) + lazy_spec.overrides = [override] + second_platform = Gem::Platform.new("aarch64-linux") + second_variant = build_spec("needs_old_ruby", "1.0", second_platform).first.tap do |s| + s.required_ruby_version = Gem::Requirement.new("< #{Gem.ruby_version}") + end + allow(lazy_spec.source.specs).to receive(:search). + with(["needs_old_ruby", Gem::Version.new("1.0")]).and_return([platform_variant, second_variant]) + + set = described_class.new([lazy_spec]) + expect(set.send(:complete_platform, platform)).to be(true) + # The synthesized x86_64-linux variant is now in the set. If lookup + # picks it as exemplar for the next platform check, the override list + # must still be reachable via its overrides accessor. + synthesized = set.to_a.find {|s| s.platform == platform } + expect(synthesized.overrides).to eq([override]) + expect(set.send(:complete_platform, second_platform)).to be(true) + end + end end