summaryrefslogtreecommitdiff
path: root/spec/ruby/language
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language')
-rw-r--r--spec/ruby/language/rescue_spec.rb36
1 files changed, 22 insertions, 14 deletions
diff --git a/spec/ruby/language/rescue_spec.rb b/spec/ruby/language/rescue_spec.rb
index 66a493cd34..5336265775 100644
--- a/spec/ruby/language/rescue_spec.rb
+++ b/spec/ruby/language/rescue_spec.rb
@@ -195,26 +195,34 @@ describe "The rescue keyword" do
ScratchPad.recorded.should == [:one, :else_ran, :ensure_ran, :outside_begin]
end
- else_without_rescue = lambda {
- eval <<-ruby
- begin
- ScratchPad << :begin
- else
- ScratchPad << :else
- end
- ruby
- }
-
- ruby_version_is ""..."2.6" do
+ ruby_version_is ''...'2.6' do
it "will execute an else block even without rescue and ensure" do
- else_without_rescue.should complain(/else without rescue is useless/)
+ lambda {
+ eval <<-ruby
+ begin
+ ScratchPad << :begin
+ else
+ ScratchPad << :else
+ end
+ ruby
+ }.should complain(/else without rescue is useless/)
ScratchPad.recorded.should == [:begin, :else]
end
end
- ruby_version_is "2.6" do
- else_without_rescue.should raise_error(SyntaxError)
+ ruby_version_is '2.6' do
+ it "raises SyntaxError when else is used without rescue and ensure" do
+ lambda {
+ eval <<-ruby
+ begin
+ ScratchPad << :begin
+ else
+ ScratchPad << :else
+ end
+ ruby
+ }.should raise_error(SyntaxError, /else without rescue is useless/)
+ end
end
it "will not execute an else block if an exception was raised" do