diff options
Diffstat (limited to 'spec/ruby/shared')
| -rw-r--r-- | spec/ruby/shared/kernel/raise.rb | 15 | ||||
| -rw-r--r-- | spec/ruby/shared/process/fork.rb | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/spec/ruby/shared/kernel/raise.rb b/spec/ruby/shared/kernel/raise.rb index 8459166906..04eaa94e6a 100644 --- a/spec/ruby/shared/kernel/raise.rb +++ b/spec/ruby/shared/kernel/raise.rb @@ -92,6 +92,21 @@ describe :kernel_raise, shared: true do -> { @object.raise("message", {cause: RuntimeError.new()}) }.should.raise(TypeError, "exception class/object expected") end + it "raises result from #exception when passed a non-Exception object" do + e = Object.new + def e.exception = StandardError.new + + -> { @object.raise e }.should.raise(StandardError) + end + + it "raises result from #exception with given arguments when passed a non-Exception object" do + e = Object.new + def e.exception(msg) = StandardError.new(msg) + + -> { @object.raise e, "foo" }.should.raise(StandardError, "foo") + -> { @object.raise e }.should.raise(ArgumentError, "wrong number of arguments (given 0, expected 1)") + end + it "raises TypeError when passed a non-Exception object but it responds to #exception method that doesn't return an instance of Exception class" do e = Object.new def e.exception diff --git a/spec/ruby/shared/process/fork.rb b/spec/ruby/shared/process/fork.rb index dd595cd93e..6c7ea75980 100644 --- a/spec/ruby/shared/process/fork.rb +++ b/spec/ruby/shared/process/fork.rb @@ -1,5 +1,5 @@ describe :process_fork, shared: true do - platform_is :windows do + guard_not -> { Process.respond_to?(:fork) } do it "returns false from #respond_to?" do # Workaround for Kernel::Method being public and losing the "non-respond_to? magic" mod = @object.class.name == "KernelSpecs::Method" ? Object.new : @object @@ -12,7 +12,7 @@ describe :process_fork, shared: true do end end - platform_is_not :windows do + guard -> { Process.respond_to?(:fork) } do before :each do @file = tmp('i_exist') rm_r @file |
