diff options
Diffstat (limited to 'spec/ruby/core')
-rw-r--r-- | spec/ruby/core/thread/thread_variable_get_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/core/thread/thread_variable_set_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/thread/thread_variable_spec.rb | 6 |
3 files changed, 8 insertions, 8 deletions
diff --git a/spec/ruby/core/thread/thread_variable_get_spec.rb b/spec/ruby/core/thread/thread_variable_get_spec.rb index e8e03e3d18..1ea34cf2b3 100644 --- a/spec/ruby/core/thread/thread_variable_get_spec.rb +++ b/spec/ruby/core/thread/thread_variable_get_spec.rb @@ -43,18 +43,18 @@ describe "Thread#thread_variable_get" do 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_error(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_error(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, "#{key.inspect} is not a symbol") + -> { @t.thread_variable_get(key) }.should raise_error(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 c262a6614e..eadee76afb 100644 --- a/spec/ruby/core/thread/thread_variable_set_spec.rb +++ b/spec/ruby/core/thread/thread_variable_set_spec.rb @@ -51,12 +51,12 @@ describe "Thread#thread_variable_set" do 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_error(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, "#{key.inspect} is not a symbol") + -> { @t.thread_variable_set(key, 42) }.should raise_error(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 465b985365..1b021e9404 100644 --- a/spec/ruby/core/thread/thread_variable_spec.rb +++ b/spec/ruby/core/thread/thread_variable_spec.rb @@ -43,18 +43,18 @@ describe "Thread#thread_variable?" do 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_error(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_error(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, "#{key.inspect} is not a symbol") + -> { @t.thread_variable?(key) }.should raise_error(TypeError, /#{Regexp.escape(key.inspect)} is not a symbol/) end end end |