diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
commit | da7976235fbc2986925969646071bebe3702e49f (patch) | |
tree | 83bbf6a8e03cf990369feabe6c1c9d45c69f4c85 /spec/ruby/core/kernel | |
parent | b8e389a0f3226c90e96e02e6396686a3bef6a456 (diff) | |
download | ruby-da7976235fbc2986925969646071bebe3702e49f.tar.gz |
Update to ruby/spec@7a16e01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/kernel')
-rw-r--r-- | spec/ruby/core/kernel/extend_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/kernel/fail_spec.rb | 17 | ||||
-rw-r--r-- | spec/ruby/core/kernel/instance_variable_set_spec.rb | 20 | ||||
-rw-r--r-- | spec/ruby/core/kernel/warn_spec.rb | 9 |
4 files changed, 29 insertions, 21 deletions
diff --git a/spec/ruby/core/kernel/extend_spec.rb b/spec/ruby/core/kernel/extend_spec.rb index 2dbc224177..f4f9dde098 100644 --- a/spec/ruby/core/kernel/extend_spec.rb +++ b/spec/ruby/core/kernel/extend_spec.rb @@ -46,10 +46,10 @@ describe "Kernel#extend" do end it "makes the class a kind_of? the argument" do - class C + c = Class.new do extend KernelSpecs::M end - (C.kind_of? KernelSpecs::M).should == true + (c.kind_of? KernelSpecs::M).should == true end it "raises an ArgumentError when no arguments given" do diff --git a/spec/ruby/core/kernel/fail_spec.rb b/spec/ruby/core/kernel/fail_spec.rb index 01dffa4a69..a5948cefae 100644 --- a/spec/ruby/core/kernel/fail_spec.rb +++ b/spec/ruby/core/kernel/fail_spec.rb @@ -1,7 +1,7 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' -describe "Kernel.fail" do +describe "Kernel#fail" do it "is a private method" do Kernel.should have_private_instance_method(:fail) end @@ -11,17 +11,16 @@ describe "Kernel.fail" do end it "accepts an Object with an exception method returning an Exception" do - class Boring - def self.exception(msg) - StandardError.new msg - end + obj = Object.new + def obj.exception(msg) + StandardError.new msg end - lambda { fail Boring, "..." }.should raise_error(StandardError) + lambda { fail obj, "..." }.should raise_error(StandardError, "...") end it "instantiates the specified exception class" do - class LittleBunnyFooFoo < RuntimeError; end - lambda { fail LittleBunnyFooFoo }.should raise_error(LittleBunnyFooFoo) + error_class = Class.new(RuntimeError) + lambda { fail error_class }.should raise_error(error_class) end it "uses the specified message" do @@ -38,6 +37,6 @@ describe "Kernel.fail" do end end -describe "Kernel#fail" do +describe "Kernel.fail" do it "needs to be reviewed for spec completeness" end diff --git a/spec/ruby/core/kernel/instance_variable_set_spec.rb b/spec/ruby/core/kernel/instance_variable_set_spec.rb index ce74b6fc29..6d84015f50 100644 --- a/spec/ruby/core/kernel/instance_variable_set_spec.rb +++ b/spec/ruby/core/kernel/instance_variable_set_spec.rb @@ -3,32 +3,32 @@ require_relative 'fixtures/classes' describe "Kernel#instance_variable_set" do it "sets the value of the specified instance variable" do - class Dog + dog = Class.new do def initialize(p1, p2) @a, @b = p1, p2 end end - Dog.new('cat', 99).instance_variable_set(:@a, 'dog').should == "dog" + dog.new('cat', 99).instance_variable_set(:@a, 'dog').should == "dog" end it "sets the value of the instance variable when no instance variables exist yet" do - class NoVariables; end - NoVariables.new.instance_variable_set(:@a, "new").should == "new" + no_variables = Class.new + no_variables.new.instance_variable_set(:@a, "new").should == "new" end it "raises a NameError exception if the argument is not of form '@x'" do - class NoDog; end - lambda { NoDog.new.instance_variable_set(:c, "cat") }.should raise_error(NameError) + no_dog = Class.new + lambda { no_dog.new.instance_variable_set(:c, "cat") }.should raise_error(NameError) end it "raises a NameError exception if the argument is an invalid instance variable name" do - class DigitDog; end - lambda { DigitDog.new.instance_variable_set(:"@0", "cat") }.should raise_error(NameError) + digit_dog = Class.new + lambda { digit_dog.new.instance_variable_set(:"@0", "cat") }.should raise_error(NameError) end it "raises a NameError when the argument is '@'" do - class DogAt; end - lambda { DogAt.new.instance_variable_set(:"@", "cat") }.should raise_error(NameError) + dog_at = Class.new + lambda { dog_at.new.instance_variable_set(:"@", "cat") }.should raise_error(NameError) end it "raises a TypeError if the instance variable name is a Fixnum" do diff --git a/spec/ruby/core/kernel/warn_spec.rb b/spec/ruby/core/kernel/warn_spec.rb index 7a0c431ff0..0b461ec25a 100644 --- a/spec/ruby/core/kernel/warn_spec.rb +++ b/spec/ruby/core/kernel/warn_spec.rb @@ -77,6 +77,15 @@ describe "Kernel#warn" do }.should output(nil, /\n/) end + it "writes to_s representation if passed a non-string" do + obj = mock("obj") + obj.should_receive(:to_s).and_return("to_s called") + lambda { + $VERBOSE = true + warn(obj) + }.should output(nil, "to_s called\n") + end + ruby_version_is "2.5" do describe ":uplevel keyword argument" do before :each do |