summaryrefslogtreecommitdiff
path: root/spec/ruby/language/if_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/if_spec.rb')
-rw-r--r--spec/ruby/language/if_spec.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/ruby/language/if_spec.rb b/spec/ruby/language/if_spec.rb
index a5da696000..53fcb853d5 100644
--- a/spec/ruby/language/if_spec.rb
+++ b/spec/ruby/language/if_spec.rb
@@ -305,6 +305,16 @@ describe "The if expression" do
6.times(&b)
ScratchPad.recorded.should == [4, 5, 4, 5]
end
+
+ it "warns when Integer literals are used instead of predicates" do
+ -> {
+ eval <<~RUBY
+ $. = 0
+ 10.times { |i| ScratchPad << i if 4..5 }
+ RUBY
+ }.should complain(/warning: integer literal in flip-flop/, verbose: true)
+ ScratchPad.recorded.should == []
+ end
end
describe "when a branch syntactically does not return a value" do
@@ -320,7 +330,7 @@ describe "The if expression" do
a
end
RUBY
- }.should raise_error(SyntaxError, /void value expression/)
+ }.should.raise(SyntaxError, /void value expression/)
end
it "does not raise SyntaxError if one branch returns a value" do