The new `it` expression in ruby might be a problem for testing frameworks, no? Those often use `it “something" do` as syntax?
-
The new `it` expression in ruby might be a problem for testing frameworks, no? Those often use `it “something" do` as syntax?
Writing More Expressive Ruby with the it Shorthand
Ruby is a language that consistently evolves to make code more expressive, concise, and readable. With the release of Ruby 3.4, one of the exciting new features introduced is the use of it as a shortcut for the first parameter in a block. This enhancement aims to simplify code, especially in situations where blocks are used extensively, reducing the need to explicitly declare block parameters.
Mintbit (www.mintbit.com)
-
@thisismissem wow. This looks fun. /sarcasm
-
@polotek I mean, I get why, but also.. it just sounds like you're asking for problems.
-
Kerrick Long (code)replied to Emelia 👸🏻 last edited by
@thisismissem I’d imagine the test frameworks can pass the existing `it` as the first block parameter and things will align nicely.
```
describe "my feature" do
it "works like this" do
# …
end
end
```
-
Kerrick Long (code)replied to Kerrick Long (code) last edited by
-
Emelia 👸🏻replied to Kerrick Long (code) last edited by
@kerrick mmm yeah, maybe? Still a pretty breaking change in syntax
-
Kerrick Long (code)replied to Emelia 👸🏻 last edited by
@thisismissem I found a lot of discussion about exactly this here: https://bugs.ruby-lang.org/issues/18980
Most importantly it seems I forgot Ruby won’t confuse a message send with a local variable reference when the message is sent with arguments and/or a block. So my earlier example is not equivalent; `it "works"` will not refer to the first block parameter. They both coexist as `it`.
-
Emelia 👸🏻replied to Kerrick Long (code) last edited by
@kerrick so my gut instinct of "this feels like it'll break things" was wrong?
-
@thisismissem @polotek they finally went for it eh? Spent a while telling them the same thing, and I do not look forward to the special hell it will wreak on RSpec.
-
@thisismissem new to me - thanks!