-
-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs for the it variable in blocks
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require_relative '../spec_helper' | ||
|
||
describe "The it parameter" do | ||
it "should use the local variable if exists" do | ||
it = 123 | ||
[1, 2, 3].map { it }.should == [123, 123, 123] | ||
end | ||
|
||
ruby_version_is ""..."3.4" do | ||
it "should use the method if no local variable exists" do | ||
# This test is hacky: we now depend on the `it` method of the specs | ||
suppress_warning do | ||
-> { | ||
eval("[1, 2, 3].map { it }") | ||
}.should raise_error(ArgumentError, "wrong number of arguments (given 0, expected 1)") | ||
end | ||
end | ||
end | ||
|
||
ruby_version_is "3.4" do | ||
it "should act as the first argument if no local variable exists" do | ||
# eval is required for suppress_warning | ||
eval("[1, 2, 3].map { it }").should == [1, 2, 3] | ||
end | ||
end | ||
end |