Open marknuzz opened 1 month ago
Added locally to sorbet/rbi/shims/actionpack.rbi as a workaround
module ActionDispatch
module Integration
module Runner
# @method_missing: delegated to ActionDispatch::Integration::Session
sig { returns(ActionDispatch::Request) }
def request; end
# @method_missing: delegated to ActionDispatch::Integration::Session
sig { returns(ActionDispatch::TestResponse) }
def response; end
end
end
class TestResponse
sig { returns(String) }
def body; end
end
end
https://rspec.info/features/6-0/rspec-rails/request-specs/request-spec/
RSpec.describe SomeClass, type: :request do
a 'response' method is often referenced in these tests.method_missing will delegate calls to the "integration_session" object, which has an anonymous class
Unfortunately this ActionDispatch::Integration::Session is a class and not a module so it can't easily be included. And I don't find any other modules which have this list of methods.
However, I do see that ActionPack's ActionDispatch::Integration::Runner has a couple of rbi annotations from rbi-central. And if you try using the method https! and "go to definition", the editor will in fact jump to that rbi. The two methods in the annotation have a comment:
# @method_missing: delegated to ActionDispatch::Integration::Session
So the thing to do here may be to submit a PR to rbi-central to update these annotations, and to use a shim in the meantime.
I don't think gems can provide shims or installed annotations (would be great if they did but maybe there's a good reason?). I'd rather find a way to fix it without updating the compiler to add all these methods separately for each module as that would bloat things even more.