Closed AlexWayfer closed 4 years ago
Blocked by #1147.
I don't know how to implement this.
Specifically, I don't know how can I access Connection
object from Adapter
object.
I'm about to close this issue and write a code like:
MY_CONNECTION = Faraday.new(
url: "https://api.twitch.tv/kraken"
)
stub.get("#{MY_CONNECTION.url_prefix}users/#{user_id}") { [200, {}, stubbed_user] }
(although it's not beautiful)
@AlexWayfer the adapter should definitely NOT be able to access the connection, it doesn't make sense from a design point of view.
I still don't understand why you have this issue, as the requests are stubbed anyway, you could just create the faraday connection without a prefix, or add the prefix the all the stubs.
If that's not viable (but I'd be curious to know why), then the TestAdapter also support regexp as of #552, so that would be another viable solution.
I still don't understand why you have this issue, as the requests are stubbed anyway, you could just create the faraday connection without a prefix, or add the prefix the all the stubs.
If that's not viable (but I'd be curious to know why)
DRY. The reason is "Don't Repeat Yourself". I can re-use base path any number of times, but I don't want to.
My PR doesn't break anything except something like Responsibility abstraction.
Then before we break anything, can you let me know if the regex solution works for you and keeps your tests DRY?
I'm going to close this issue and related PR. Sorry, but I want to use cassettes (VCR) for now. And I guess I can use regexp or something else. With time I've got the point of requests stubs, I guess. For example, if I change API base URI (API version) — tests should fails.
Thank you.
Completely agree, cassettes are also my personal favourite testing system, much more flexible and powerful than the test adapter.
Basic Info
1.0.1
2.7.1
Issue description
I have such connection:
And such code with this connection:
And I want to test it. But with regular adapter connection accepts relative paths (see above), and with
:test
adapter it does not:If I add
/kraken
to stub — it works.Steps to reproduce
See code above.