summaryrefslogtreecommitdiff
path: root/spec/ruby/core
diff options
context:
space:
mode:
authorYO4 <[email protected]>2025-01-23 22:40:02 +0900
committerNobuyoshi Nakada <[email protected]>2025-03-19 01:28:59 +0900
commit0f6c647b1a1e313e3cb4fe79d4b63ffa2b7a6a6e (patch)
tree5b4565d977a45df627059c348ee6e69e4841f8aa /spec/ruby/core
parent3d6fc2916907a351c274449280a82b020208f084 (diff)
avoid platform dependent message
(Bug #21083) https://bugs.ruby-lang.org/issues/21083
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12622
Diffstat (limited to 'spec/ruby/core')
-rw-r--r--spec/ruby/core/exception/system_call_error_spec.rb19
1 files changed, 4 insertions, 15 deletions
diff --git a/spec/ruby/core/exception/system_call_error_spec.rb b/spec/ruby/core/exception/system_call_error_spec.rb
index f6995d3c5e..ea54e1ad4c 100644
--- a/spec/ruby/core/exception/system_call_error_spec.rb
+++ b/spec/ruby/core/exception/system_call_error_spec.rb
@@ -25,6 +25,7 @@ describe "SystemCallError.new" do
@example_errno_class = Errno::EINVAL
@last_known_errno = Errno.constants.size - 1
@unknown_errno = Errno.constants.size
+ @some_human_readable = "[[:graph:]]+"
end
it "requires at least one argument" do
@@ -96,23 +97,11 @@ describe "SystemCallError.new" do
end
it "sets an 'unknown error' message when an unknown error number" do
- platform_is_not :windows do
- SystemCallError.new(-1).message.should =~ /Unknown error(:)? -1/
- end
-
- platform_is :windows do
- SystemCallError.new(-1).message.should == "The operation completed successfully."
- end
+ SystemCallError.new(-1).message.should =~ Regexp.new(@some_human_readable)
end
it "adds a custom error message to an 'unknown error' message when an unknown error number and a custom message specified" do
- platform_is_not :windows do
- SystemCallError.new("custom message", -1).message.should =~ /Unknown error(:)? -1 - custom message/
- end
-
- platform_is :windows do
- SystemCallError.new("custom message", -1).message.should == "The operation completed successfully. - custom message"
- end
+ SystemCallError.new("custom message", -1).message.should =~ Regexp.new("#{@some_human_readable}.* - custom message")
end
it "converts to Integer if errno is a Complex convertible to Integer" do
@@ -153,7 +142,7 @@ describe "SystemCallError#message" do
SystemCallError.new(2**28).message.should =~ /Error .*occurred/i
end
platform_is_not :aix do
- SystemCallError.new(2**28).message.should =~ /Unknown error/i
+ SystemCallError.new(2**28).message.should =~ Regexp.new(@some_human_readable)
end
end