Skip to content

Commit d6d1fb9

Browse files
committed
Add specs for the it variable in blocks
1 parent 2ca97d4 commit d6d1fb9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

language/it_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require_relative '../spec_helper'
2+
3+
describe "The it parameter" do
4+
it "should use the local variable if exists" do
5+
it = 123
6+
[1, 2, 3].map { it }.should == [123, 123, 123]
7+
end
8+
9+
ruby_version_is ""..."3.4" do
10+
it "should use the method if no local variable exists" do
11+
# This test is hacky: we now depend on the `it` method of the specs
12+
suppress_warning do
13+
-> {
14+
eval("[1, 2, 3].map { it }")
15+
}.should raise_error(ArgumentError, "wrong number of arguments (given 0, expected 1)")
16+
end
17+
end
18+
end
19+
20+
ruby_version_is "3.4" do
21+
it "should act as the first argument if no local variable exists" do
22+
# eval is required for suppress_warning
23+
eval("[1, 2, 3].map { it }").should == [1, 2, 3]
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)