summaryrefslogtreecommitdiff
path: root/spec/ruby/language/predefined_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/predefined_spec.rb')
-rw-r--r--spec/ruby/language/predefined_spec.rb410
1 files changed, 302 insertions, 108 deletions
diff --git a/spec/ruby/language/predefined_spec.rb b/spec/ruby/language/predefined_spec.rb
index cc231e341e..d57b924bcf 100644
--- a/spec/ruby/language/predefined_spec.rb
+++ b/spec/ruby/language/predefined_spec.rb
@@ -1,4 +1,5 @@
require_relative '../spec_helper'
+require_relative '../core/exception/shared/set_backtrace'
require 'stringio'
# The following tables are excerpted from Programming Ruby: The Pragmatic Programmer's Guide'
@@ -39,12 +40,12 @@ require 'stringio'
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
@@ -71,7 +72,7 @@ describe "Predefined global $~" do
match2.should_not == nil
$~.should == match2
- eval 'match3 = /baz/.match("baz")'
+ match3 = /baz/.match("baz")
match3.should_not == nil
$~.should == match3
@@ -86,10 +87,10 @@ describe "Predefined global $~" do
$~ = nil
$~.should == nil
$~ = /foo/.match("foo")
- $~.should be_an_instance_of(MatchData)
+ $~.should.instance_of?(MatchData)
- -> { $~ = Object.new }.should raise_error(TypeError)
- -> { $~ = 1 }.should raise_error(TypeError)
+ -> { $~ = 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
@@ -134,7 +135,20 @@ describe "Predefined global $&" do
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(SyntaxError, /Can't set variable \$&/)
+ end
+
+ it "is read-only when aliased" do
+ alias $predefined_spec_ampersand $&
+ -> {
+ $predefined_spec_ampersand = ""
+ }.should.raise(NameError, '$predefined_spec_ampersand is a read-only variable')
end
end
@@ -147,12 +161,25 @@ describe "Predefined global $`" do
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(SyntaxError, /Can't set variable \$`/)
+ end
+
+ it "is read-only when aliased" do
+ alias $predefined_spec_backquote $`
+ -> {
+ $predefined_spec_backquote = ""
+ }.should.raise(NameError, '$predefined_spec_backquote is a read-only variable')
end
end
@@ -165,12 +192,25 @@ describe "Predefined global $'" do
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(SyntaxError, /Can't set variable \$'/)
+ end
+
+ it "is read-only when aliased" do
+ alias $predefined_spec_single_quote $'
+ -> {
+ $predefined_spec_single_quote = ""
+ }.should.raise(NameError, '$predefined_spec_single_quote is a read-only variable')
end
end
@@ -188,7 +228,20 @@ describe "Predefined global $+" do
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(SyntaxError, /Can't set variable \$\+/)
+ end
+
+ it "is read-only when aliased" do
+ alias $predefined_spec_plus $+
+ -> {
+ $predefined_spec_plus = ""
+ }.should.raise(NameError, '$predefined_spec_plus is a read-only variable')
end
end
@@ -215,7 +268,7 @@ describe "Predefined globals $1..N" do
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
@@ -229,16 +282,16 @@ describe "Predefined global $stdout" do
end
it "raises TypeError error if assigned to nil" do
- -> { $stdout = nil }.should raise_error(TypeError)
+ -> { $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
@@ -253,6 +306,12 @@ describe "Predefined global $!" do
$!.should == nil
end
+ it "is read-only" do
+ -> {
+ $! = []
+ }.should.raise(NameError, '$! is a read-only variable')
+ end
+
# See http://jira.codehaus.org/browse/JRUBY-5550
it "remains nil after a failed core class \"checked\" coercion against a class that defines method_missing" do
$!.should == nil
@@ -512,6 +571,75 @@ describe "Predefined global $!" do
end
end
+describe "Predefined global $@" do
+ it "is Fiber-local" do
+ Fiber.new do
+ raise "hi"
+ rescue
+ Fiber.yield
+ end.resume
+
+ $@.should == nil
+ end
+
+ it "is set to a backtrace of a rescued exception" do
+ begin
+ raise
+ rescue
+ $@.should.instance_of?(Array)
+ $@.should == $!.backtrace
+ end
+ end
+
+ it "is cleared when an exception is rescued" do
+ begin
+ raise
+ rescue
+ end
+
+ $@.should == nil
+ end
+
+ it "is not set when there is no current exception" do
+ $@.should == nil
+ end
+
+ it "is set to a backtrace of a rescued exception" do
+ begin
+ raise
+ rescue
+ $@.should.instance_of?(Array)
+ $@.should == $!.backtrace
+ end
+ end
+
+ it "is not read-only" do
+ begin
+ raise
+ rescue
+ $@ = []
+ $@.should == []
+ end
+ end
+
+ it_behaves_like :exception_set_backtrace, -> backtrace {
+ exception = nil
+ begin
+ raise
+ rescue
+ $@ = backtrace
+ exception = $!
+ end
+ exception
+ }
+
+ it "cannot be assigned when there is no a rescued exception" do
+ -> {
+ $@ = []
+ }.should.raise(ArgumentError, '$! not set')
+ end
+end
+
# Input/Output Variables
# ---------------------------------------------------------------------------------------------------
#
@@ -559,15 +687,43 @@ describe "Predefined global $/" do
$VERBOSE = @verbose
end
- it "can be assigned a String" do
- str = "abc"
- $/ = str
- $/.should equal(str)
+ ruby_version_is ""..."4.0" do
+ it "can be assigned a String" do
+ str = +"abc"
+ $/ = str
+ $/.should.equal?(str)
+ end
+ end
+
+ ruby_version_is "4.0" do
+ it "makes a new frozen String from the assigned String" do
+ string_subclass = Class.new(String)
+ str = string_subclass.new("abc")
+ str.instance_variable_set(:@ivar, 1)
+ $/ = str
+ $/.should.frozen?
+ $/.should.instance_of?(String)
+ $/.should_not.instance_variable_defined?(:@ivar)
+ $/.should == str
+ end
+
+ it "makes a new frozen String if it's not frozen" do
+ str = +"abc"
+ $/ = str
+ $/.should.frozen?
+ $/.should == str
+ end
+
+ it "assigns the given String if it's frozen and has no instance variables" do
+ str = "abc".freeze
+ $/ = 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
@@ -576,22 +732,26 @@ describe "Predefined global $/" do
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)
+ -> { $/ = obj }.should.raise(TypeError, 'value of $/ must be String')
end
it "raises a TypeError if assigned an Integer" do
- -> { $/ = 1 }.should raise_error(TypeError)
+ -> { $/ = 1 }.should.raise(TypeError, 'value of $/ must be String')
end
it "raises a TypeError if assigned a boolean" do
- -> { $/ = true }.should raise_error(TypeError)
+ -> { $/ = true }.should.raise(TypeError, 'value of $/ must be String')
+ end
+
+ it "warns if assigned non-nil" do
+ -> { $/ = "_" }.should complain(/warning: (?:non-nil )?[`']\$\/' is deprecated/)
end
end
@@ -608,15 +768,43 @@ describe "Predefined global $-0" do
$VERBOSE = @verbose
end
- it "can be assigned a String" do
- str = "abc"
- $-0 = str
- $-0.should equal(str)
+ ruby_version_is ""..."4.0" do
+ it "can be assigned a String" do
+ str = +"abc"
+ $-0 = str
+ $-0.should.equal?(str)
+ end
+ end
+
+ ruby_version_is "4.0" do
+ it "makes a new frozen String from the assigned String" do
+ string_subclass = Class.new(String)
+ str = string_subclass.new("abc")
+ str.instance_variable_set(:@ivar, 1)
+ $-0 = str
+ $-0.should.frozen?
+ $-0.should.instance_of?(String)
+ $-0.should_not.instance_variable_defined?(:@ivar)
+ $-0.should == str
+ end
+
+ it "makes a new frozen String if it's not frozen" do
+ str = +"abc"
+ $-0 = str
+ $-0.should.frozen?
+ $-0.should == str
+ end
+
+ it "assigns the given String if it's frozen and has no instance variables" do
+ str = "abc".freeze
+ $-0 = 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
@@ -625,22 +813,26 @@ describe "Predefined global $-0" do
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)
+ -> { $-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)
+ -> { $-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)
+ -> { $-0 = true }.should.raise(TypeError, 'value of $-0 must be String')
+ end
+
+ it "warns if assigned non-nil" do
+ -> { $-0 = "_" }.should complain(/warning: (?:non-nil )?[`']\$-0' is deprecated/)
end
end
@@ -658,12 +850,12 @@ describe "Predefined global $\\" do
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
@@ -674,12 +866,16 @@ describe "Predefined global $\\" do
obj = mock("$\\ value")
obj.should_not_receive(:to_str)
- -> { $\ = obj }.should raise_error(TypeError)
+ -> { $\ = obj }.should.raise(TypeError, 'value of $\ must be String')
end
it "raises a TypeError if assigned not String" do
- -> { $\ = 1 }.should raise_error(TypeError)
- -> { $\ = true }.should raise_error(TypeError)
+ -> { $\ = 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
+ -> { $\ = "_" }.should complain(/warning: (?:non-nil )?[`']\$\\' is deprecated/)
end
end
@@ -689,15 +885,15 @@ describe "Predefined global $," do
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)
+ -> { $, = Object.new }.should.raise(TypeError, 'value of $, must be String')
end
it "warns if assigned non-nil" do
- -> { $, = "_" }.should complain(/warning: [`']\$,' is deprecated/)
+ -> { $, = "_" }.should complain(/warning: (?:non-nil )?[`']\$,' is deprecated/)
end
end
@@ -724,7 +920,7 @@ describe "Predefined global $." do
obj = mock("bad-value")
obj.should_receive(:to_int).and_return('abc')
- -> { $. = obj }.should raise_error(TypeError)
+ -> { $. = obj }.should.raise(TypeError)
end
end
@@ -734,7 +930,7 @@ describe "Predefined global $;" do
end
it "warns if assigned non-nil" do
- -> { $; = "_" }.should complain(/warning: [`']\$;' is deprecated/)
+ -> { $; = "_" }.should complain(/warning: (?:non-nil )?[`']\$;' is deprecated/)
end
end
@@ -768,7 +964,7 @@ describe "Predefined global $_" do
match.should == "bar\n"
$_.should == match
- eval 'match = stdin.gets'
+ match = stdin.gets
match.should == "baz\n"
$_.should == match
@@ -789,7 +985,7 @@ describe "Predefined global $_" do
end
Thread.pass until running
- $_.should be_nil
+ $_.should == nil
thr.join
end
@@ -860,7 +1056,7 @@ describe "Execution variable $:" do
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
@@ -870,7 +1066,7 @@ describe "Execution variable $:" do
it "can be changed via <<" do
$: << "foo"
- $:.should include("foo")
+ $:.should.include?("foo")
ensure
$:.delete("foo")
end
@@ -878,41 +1074,47 @@ describe "Execution variable $:" do
it "is read-only" do
-> {
$: = []
- }.should raise_error(NameError)
+ }.should.raise(NameError, '$: is a read-only variable')
-> {
$LOAD_PATH = []
- }.should raise_error(NameError)
+ }.should.raise(NameError, '$LOAD_PATH is a read-only variable')
-> {
$-I = []
- }.should raise_error(NameError)
+ }.should.raise(NameError, '$-I is a read-only variable')
end
it "default $LOAD_PATH entries until sitelibdir included have @gem_prelude_index set" do
skip "no sense in ruby itself" if MSpecScript.instance_variable_defined?(:@testing_ruby)
- $:.should.include?(RbConfig::CONFIG['sitelibdir'])
- idx = $:.index(RbConfig::CONFIG['sitelibdir'])
+ if platform_is :windows
+ # See https://github.com/ruby/setup-ruby/pull/762#issuecomment-2917460440
+ $:.should.find { |e| File.realdirpath(e) == RbConfig::CONFIG['sitelibdir'] }
+ idx = $:.index { |e| File.realdirpath(e) == RbConfig::CONFIG['sitelibdir'] }
+ else
+ $:.should.include?(RbConfig::CONFIG['sitelibdir'])
+ 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)
+ }.should.raise(NameError, '$" is a read-only variable')
-> {
$LOADED_FEATURES = []
- }.should raise_error(NameError)
+ }.should.raise(NameError, '$LOADED_FEATURES is a read-only variable')
end
end
@@ -920,7 +1122,7 @@ describe "Global variable $<" do
it "is read-only" do
-> {
$< = nil
- }.should raise_error(NameError)
+ }.should.raise(NameError, '$< is a read-only variable')
end
end
@@ -928,7 +1130,7 @@ describe "Global variable $FILENAME" do
it "is read-only" do
-> {
$FILENAME = "-"
- }.should raise_error(NameError)
+ }.should.raise(NameError, '$FILENAME is a read-only variable')
end
end
@@ -936,30 +1138,30 @@ describe "Global variable $?" do
it "is read-only" do
-> {
$? = nil
- }.should raise_error(NameError)
+ }.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 = 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 = 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 = true }.should.raise(NameError, '$-p is a read-only variable')
end
end
@@ -974,9 +1176,9 @@ describe "Global variable $-d" do
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
@@ -990,24 +1192,24 @@ describe "Global variable $VERBOSE" do
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
@@ -1022,9 +1224,9 @@ describe :verbose_global_alias, shared: true do
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
@@ -1061,7 +1263,7 @@ describe "Global variable $0" do
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
@@ -1070,7 +1272,7 @@ describe "Global variable $0" do
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
@@ -1106,37 +1308,37 @@ 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)
+ -> { 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)
+ -> { 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)
+ -> { 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)
+ -> { eval("self = 1") }.should.raise(SyntaxError, /Can't change the value of self/)
end
end
@@ -1231,21 +1433,21 @@ describe "The predefined global constant" do
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
@@ -1265,12 +1467,12 @@ describe "The predefined global constant" do
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
@@ -1280,23 +1482,23 @@ describe "The predefined global constant" do
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
@@ -1306,12 +1508,12 @@ describe "The predefined global constant" do
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
@@ -1327,9 +1529,9 @@ end
describe "$LOAD_PATH.resolve_feature_path" do
it "returns what will be loaded without actual loading, .rb file" do
- extension, path = $LOAD_PATH.resolve_feature_path('set')
+ extension, path = $LOAD_PATH.resolve_feature_path('pp')
extension.should == :rb
- path.should.end_with?('/set.rb')
+ path.should.end_with?('/pp.rb')
end
it "returns what will be loaded without actual loading, .so file" do
@@ -1341,16 +1543,8 @@ describe "$LOAD_PATH.resolve_feature_path" do
path.should.end_with?("/etc.#{RbConfig::CONFIG['DLEXT']}")
end
- ruby_version_is ""..."3.1" do
- it "raises LoadError if feature cannot be found" do
- -> { $LOAD_PATH.resolve_feature_path('noop') }.should raise_error(LoadError)
- end
- end
-
- ruby_version_is "3.1" do
- it "return nil if feature cannot be found" do
- $LOAD_PATH.resolve_feature_path('noop').should be_nil
- end
+ it "return nil if feature cannot be found" do
+ $LOAD_PATH.resolve_feature_path('noop').should == nil
end
end