Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specs for the it variable in blocks #1224

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions language/it_spec.rb
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
Loading