-
Notifications
You must be signed in to change notification settings - Fork 574
RSpec.describe with experimental flag #9484
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
base: master
Are you sure you want to change the base?
RSpec.describe with experimental flag #9484
Conversation
Add support for RSpec.describe to inherit from RSpec::Core::ExampleGroup. This allows before hooks and other test methods to access RSpec DSL methods like expect, subject, is_expected, etc. Based on prior work that was backed out in commit 5276b75. Committed-By-Agent: claude
This flag controls whether RSpec.describe will be transformed to inherit from RSpec::Core::ExampleGroup. When disabled (default), RSpec.describe behaves like a regular describe call. This allows users to opt-in to experimental RSpec support while keeping the default behavior unchanged. Committed-By-Agent: claude
The experimentalRSpecEnabled flag was being set in Options but not copied to GlobalState, so the rewriter couldn't see it. This caused RSpec.describe to not be recognized even when --enable-experimental-rspec was set. Committed-By-Agent: claude
Allow RSpec.shared_examples, RSpec.shared_context, and RSpec.shared_examples_for to be used at the top level (outside of describe blocks) when the --enable-experimental-rspec flag is enabled. This mirrors the RSpec.describe support and uses the same isRSpec check. Committed-By-Agent: claude
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think we should have a CLI flag. we can continue discussion in your doc internally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean for rspec_describe__experimental.rb
and rspec_describe.rb
to be typechecked in one unit?
filenames that have a __
in them are special. look for files named like __1.rb
and __2.rb
for more examples
We need to either:
- rename
rspec_describe.rb
→rspec_describe__stable.rb
, or - rename
rspec_describe__experimental.rb
→rspec_describe_experimental.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no, I meant for them to be separate tests – one with the experimental flag and no type errors, and one without the flag and with errors. I'll delete this anyways since we won't ship with a flag.
The goal of this PR is to activate
RSpec
typing behind a feature flag.Specifically, it makes it so with the flag,
RSpec.describe
will ensure thatRSpec::Core::ExampleGroup
API is available in the nestedit
blocks.