Tags: sorbet/sorbet
Tags
Add support for RSpec `its` test DSL (#9435) * Add support for RSpec `its` test DSL * Add test with T.reveal_type * attempt to fix * Fix typing of subject * write better tests * try it for real * fix bad change * also support string args * Revert "also support string args" This reverts commit 4ff0bbc. * remove comment * Update rewriter/Minitest.cc Co-authored-by: Jake Zimmerman <[email protected]> * Update rewriter/Minitest.cc Co-authored-by: Jake Zimmerman <[email protected]> * convert send-> to send. * Update rewriter/Minitest.cc Co-authored-by: Jake Zimmerman <[email protected]> * test for string arg and fix send-> * use generate_names.cc * Move IsExpectedTransformer to anonymous namespace Per code review feedback, moved IsExpectedTransformer class from being defined inline in the its() case to the top-level anonymous namespace block in the file, following the existing pattern used by ConstantMover. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Committed-By-Agent: claude * Fix misleading comments in its() case Updated comments to accurately reflect what the code does: - We're creating a class, not a "describe block" - The class body only contains the it method, not a subject method The transformation in the its() DSL creates a nested class that contains an it method which calls subject.attribute directly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Committed-By-Agent: claude * remove comments * Add test for constant hoisting in its() blocks Following the pattern from d214650 which added ConstantMover support for let and test_each blocks, this test demonstrates that constants defined inside its() blocks are properly hoisted out. The test shows: - Constants (X = 1) are moved outside the it method definition - They are replaced with Module.const_set calls inside the method - The constant reference is transformed to use the hoisted constant This verifies the ConstantMover.apply and addConstantsToExpression calls on lines 717-718 and 725 are working correctly for its() blocks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Committed-By-Agent: claude --------- Co-authored-by: Jake Zimmerman <[email protected]> Co-authored-by: Claude <[email protected]>
Fix Kernel#p return type using type parameters (#9488) - Updated Kernel#p signature to use type_parameters(:T) with Object upper bound - Changed method definition from 'def p(*arg0)' to 'def p(arg0=nil, *arg1)' to support overloaded signatures - Added three overloaded signatures: 1. sig { returns(NilClass) } for p() with no arguments 2. sig with single arg returning T.type_parameter(:T) for p(x) 3. sig with multiple args returning T::Array[T.type_parameter(:T)] for p(x,y,...) - Updated test expectations in test/testdata/rbi/kernel.rb - Updated CFG test expectations in test/testdata/cfg/textoutput.rb.cfg-text.exp The new signature correctly preserves argument types: - p() returns NilClass - p(42) returns Integer - p('hello') returns String - p(1, 2) returns T::Array[Integer] - p(1, 'string') returns T::Array[T.any(Integer, String)] All 2184 curated tests pass.
PreviousNext