summaryrefslogtreecommitdiff
path: root/spec/ruby/shared
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2021-03-27 13:02:41 +0100
committerBenoit Daloze <eregontp@gmail.com>2021-03-27 13:02:41 +0100
commit95d9fe9538441eb57ee6752aa1c5088fc6608e34 (patch)
tree9a0bb070fd8042b83470f7a0bf9cd462c919c7c0 /spec/ruby/shared
parent44736a6b7a2b3475db2d05187f33e3c1a7b4b4e5 (diff)
Update to ruby/spec@fd6eddd
Diffstat (limited to 'spec/ruby/shared')
-rw-r--r--spec/ruby/shared/kernel/raise.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/ruby/shared/kernel/raise.rb b/spec/ruby/shared/kernel/raise.rb
index f00a6ef294..765ba0f929 100644
--- a/spec/ruby/shared/kernel/raise.rb
+++ b/spec/ruby/shared/kernel/raise.rb
@@ -12,6 +12,28 @@ describe :kernel_raise, shared: true do
ScratchPad.recorded.should be_nil
end
+ it "accepts an exception that implements to_hash" do
+ custom_error = Class.new(StandardError) do
+ def to_hash
+ {}
+ end
+ end
+ error = custom_error.new
+ -> { @object.raise(error) }.should raise_error(custom_error)
+ end
+
+ it "allows the message parameter to be a hash" do
+ data_error = Class.new(StandardError) do
+ attr_reader :data
+ def initialize(data)
+ @data = data
+ end
+ end
+ -> { @object.raise(data_error, {:data => 42}) }.should raise_error(data_error) do |ex|
+ ex.data.should == {:data => 42}
+ end
+ end
+
it "raises RuntimeError if no exception class is given" do
-> { @object.raise }.should raise_error(RuntimeError, "")
end