Using WebMock to stub an Oauth 2 Provider. The issue is that I want to use Rack Test.
Rack Test only runs against an instance of the app, and does not know about external HTTP hosts like the Oauth 2 Provider.
WebMock.stub_request(:get, "https://test.oauth-provider.com/oauth/authorize")
won't work because the request is sent to the app as /oauth/authorize
.
Is there a way for WebMock to respond to local requests? For example:
WebMock.stub_request(:get, "/oauth/authorize")
It seems to me, you're a little bit confused about what you're testing, and must draw the clear border, where your system is (so-called SuT, system under test) and where are the external parties.
It is very important since:
That means that if you're trying to use WebMock for any part of your application (which it looks like what you're doing due to the question about mocking a relative URL), you're clearly doing something wrong.
Closer to your task, if I were you, I would:
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.