ruby-changes:60544
From: Benoit <ko1@a...>
Date: Sat, 28 Mar 2020 08:23:32 +0900 (JST)
Subject: [ruby-changes:60544] f234d51eab (master): Update to ruby/spec@ec84479
https://git.ruby-lang.org/ruby.git/commit/?id=f234d51eab From f234d51eaba861edea925eabb564a0bee41b96a0 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Sat, 28 Mar 2020 00:22:51 +0100 Subject: Update to ruby/spec@ec84479 diff --git a/spec/ruby/.rubocop_todo.yml b/spec/ruby/.rubocop_todo.yml index 36e41ae..8d9cd82 100644 --- a/spec/ruby/.rubocop_todo.yml +++ b/spec/ruby/.rubocop_todo.yml @@ -70,6 +70,7 @@ Lint/LiteralInInterpolation: https://github.com/ruby/ruby/blob/trunk/spec/ruby/.rubocop_todo.yml#L70 - 'language/alias_spec.rb' - 'language/defined_spec.rb' - 'language/fixtures/squiggly_heredoc.rb' + - 'language/string_spec.rb' - 'language/symbol_spec.rb' - 'language/undef_spec.rb' - 'library/net/ftp/connect_spec.rb' diff --git a/spec/ruby/core/comparable/lt_spec.rb b/spec/ruby/core/comparable/lt_spec.rb index 4db9271..bca95f8 100644 --- a/spec/ruby/core/comparable/lt_spec.rb +++ b/spec/ruby/core/comparable/lt_spec.rb @@ -40,4 +40,10 @@ describe "Comparable#<" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/comparable/lt_spec.rb#L40 a.should_receive(:<=>).any_number_of_times.and_return(nil) -> { (a < b) }.should raise_error(ArgumentError) end + + it "raises an argument error with a message containing the value" do + -> { ("foo" < 7) }.should raise_error(ArgumentError) { |e| + e.message.should == "comparison of String with 7 failed" + } + end end diff --git a/spec/ruby/core/enumerable/shared/collect.rb b/spec/ruby/core/enumerable/shared/collect.rb index 05e9477..71b8acd 100644 --- a/spec/ruby/core/enumerable/shared/collect.rb +++ b/spec/ruby/core/enumerable/shared/collect.rb @@ -34,5 +34,35 @@ describe :enumerable_collect, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/enumerable/shared/collect.rb#L34 enum.each { |i| -i }.should == [-2, -5, -3, -6, -1, -4] end + it "reports the same arity as the given block" do + entries = [0, 1, 3, 4, 5, 6] + numerous = EnumerableSpecs::Numerous.new(*entries) + + def numerous.each(&block) + ScratchPad << block.arity + super + end + + numerous.send(@method) { |a, b| a % 2 }.should == [0, 1, 1, 0, 1, 0] + ScratchPad.recorded.should == [2] + ScratchPad.clear + ScratchPad.record [] + numerous.send(@method) { |i| i }.should == entries + ScratchPad.recorded.should == [1] + end + + it "yields 2 arguments for a Hash" do + c = Class.new do + def register(a, b) + ScratchPad << [a, b] + end + end + m = c.new.method(:register) + + ScratchPad.record [] + { 1 => 'a', 2 => 'b' }.map(&m) + ScratchPad.recorded.should == [[1, 'a'], [2, 'b']] + end + it_should_behave_like :enumerable_enumeratorized_with_origin_size end diff --git a/spec/ruby/core/exception/errno_spec.rb b/spec/ruby/core/exception/errno_spec.rb index e76b293..78b3eaf 100644 --- a/spec/ruby/core/exception/errno_spec.rb +++ b/spec/ruby/core/exception/errno_spec.rb @@ -42,3 +42,9 @@ describe "Errno::EAGAIN" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/exception/errno_spec.rb#L42 end end end + +describe "Errno::ENOTSUP" do + it "is defined" do + Errno.should have_constant(:ENOTSUP) + 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 93224c0..55a5fcc 100644 --- a/spec/ruby/core/exception/no_method_error_spec.rb +++ b/spec/ruby/core/exception/no_method_error_spec.rb @@ -64,7 +64,7 @@ describe "NoMethodError#message" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/exception/no_method_error_spec.rb#L64 NoMethodErrorSpecs::NoMethodErrorC.new.a_private_method rescue Exception => e e.should be_kind_of(NoMethodError) - e.message.match(/private method/).should_not == nil + e.message.lines[0].should =~ /private method `a_private_method' called for #<NoMethodErrorSpecs::NoMethodErrorC:0x[\h]+>/ end end diff --git a/spec/ruby/core/file/ftype_spec.rb b/spec/ruby/core/file/ftype_spec.rb index 8ff70ba..cdddc40 100644 --- a/spec/ruby/core/file/ftype_spec.rb +++ b/spec/ruby/core/file/ftype_spec.rb @@ -35,6 +35,14 @@ describe "File.ftype" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/file/ftype_spec.rb#L35 end end + it "uses to_path to convert arguments" do + FileSpecs.normal_file do |file| + obj = mock('path') + obj.should_receive(:to_path).and_return(file) + File.ftype(obj).should == 'file' + end + end + # Both FreeBSD and Windows does not have block devices platform_is_not :freebsd, :windows do with_block_device do diff --git a/spec/ruby/core/io/print_spec.rb b/spec/ruby/core/io/print_spec.rb index 0e88053..04e971e 100644 --- a/spec/ruby/core/io/print_spec.rb +++ b/spec/ruby/core/io/print_spec.rb @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/io/print_spec.rb#L1 require_relative '../../spec_helper' require_relative 'fixtures/classes' -describe IO, "#print" do +describe "IO#print" do before :each do @old_separator = $\ suppress_warning {$\ = '->'} diff --git a/spec/ruby/core/kernel/Float_spec.rb b/spec/ruby/core/kernel/Float_spec.rb index 6580c38..af64fcb 100644 --- a/spec/ruby/core/kernel/Float_spec.rb +++ b/spec/ruby/core/kernel/Float_spec.rb @@ -54,6 +54,12 @@ describe :kernel_float, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/Float_spec.rb#L54 -> { @object.send(:Float, "float") }.should raise_error(ArgumentError) end + it "raises an ArgumentError for a String with string in error message" do + -> { @object.send(:Float, "foo") }.should raise_error(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) end diff --git a/spec/ruby/core/kernel/instance_of_spec.rb b/spec/ruby/core/kernel/instance_of_spec.rb index 40e856b..d1170d5 100644 --- a/spec/ruby/core/kernel/instance_of_spec.rb +++ b/spec/ruby/core/kernel/instance_of_spec.rb @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/instance_of_spec.rb#L1 require_relative '../../spec_helper' require_relative 'fixtures/classes' -describe Kernel, "#instance_of?" do +describe "Kernel#instance_of?" do before :each do @o = KernelSpecs::InstanceClass.new end diff --git a/spec/ruby/core/kernel/shared/sprintf.rb b/spec/ruby/core/kernel/shared/sprintf.rb index 8defbfd..1ad6f8a 100644 --- a/spec/ruby/core/kernel/shared/sprintf.rb +++ b/spec/ruby/core/kernel/shared/sprintf.rb @@ -336,6 +336,12 @@ describe :kernel_sprintf, shared: true do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/kernel/shared/sprintf.rb#L336 @method.call("%s", obj) }.should raise_error(NoMethodError) end + + it "formats a partial substring without including omitted characters" do + long_string = "aabbccddhelloddccbbaa" + sub_string = long_string[8, 5] + sprintf("%.#{1 * 3}s", sub_string).should == "hel" + end end describe "%" do diff --git a/spec/ruby/core/module/alias_method_spec.rb b/spec/ruby/core/module/alias_method_spec.rb index 662e9101..571191f 100644 --- a/spec/ruby/core/module/alias_method_spec.rb +++ b/spec/ruby/core/module/alias_method_spec.rb @@ -42,6 +42,18 @@ describe "Module#alias_method" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/module/alias_method_spec.rb#L42 @object.was_private_one.should == 1 end + it "handles aliasing a method only present in a refinement" do + c = @class + Module.new do + refine c do + def uno_refined_method + end + alias_method :double_refined_method, :uno_refined_method + instance_method(:uno_refined_method).should == instance_method(:double_refined_method) + end + end + end + it "fails if origin method not found" do -> { @class.make_alias :ni, :san }.should raise_error(NameError) { |e| # a NameError and not a NoMethodError diff --git a/spec/ruby/core/module/refine_spec.rb b/spec/ruby/core/module/refine_spec.rb index 66c19dd..81dd492 100644 --- a/spec/ruby/core/module/refine_spec.rb +++ b/spec/ruby/core/module/refine_spec.rb @@ -704,6 +704,17 @@ describe "Module#refine" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/module/refine_spec.rb#L704 -> { [1,2].orig_count }.should raise_error(NoMethodError) end + it "and instance_methods returns a list of methods including those of the refined module" do + methods = Array.instance_methods + methods_2 = [] + Module.new do + refine Array do + methods_2 = instance_methods + end + end + methods.should == methods_2 + end + # Refinements are inherited by module inclusion. # That is, using activates all refinements in the ancestors of the specified module. # Refinements in a descendant have priority over refinements in an ancestor. diff --git a/spec/ruby/core/process/spawn_spec.rb b/spec/ruby/core/process/spawn_spec.rb index 79a5f4a..6b08e02 100644 --- a/spec/ruby/core/process/spawn_spec.rb +++ b/spec/ruby/core/process/spawn_spec.rb @@ -207,13 +207,9 @@ describe "Process.spawn" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/process/spawn_spec.rb#L207 it "unsets environment variables whose value is nil" do ENV["FOO"] = "BAR" - Process.wait Process.spawn({"FOO" => nil}, "echo #{@var}>#{@name}") - expected = "\n" - platform_is :windows do - # Windows does not expand the variable if it is unset - expected = "#{@var}\n" - end - File.read(@name).should == expected + -> do + Process.wait Process.spawn({"FOO" => nil}, ruby_cmd("p ENV['FOO']")) + end.should output_to_fd("nil\n") end it "calls #to_hash to convert the environment" do diff --git a/spec/ruby/core/random/default_spec.rb b/spec/ruby/co (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/