-
Notifications
You must be signed in to change notification settings - Fork 250
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
Add custom_request, remove duplication #184
Conversation
@iGEL Thanks for the PR. Just to make sure I am getting it right. The primary focus of the PR is to have a nicer syntax for non "standard verbs" like this |
@scepticulous Actually, I don't remember the exact details of this PR that I opened almost 3 years ago. I just rebased it and adjusted so the work wouldn't be lost. 😊 From what I remember and read from the changes here, it's not possible to send custom http verbs at all with rack-test (except of course using private APIs with Also, I removed some duplication at the same time, which is also a (small) improvement. |
@iGEL sorry, but I think we'll have to rebase it again. 😇 Can it be done? @scepticulous - what do you think about the change per se? |
@perlun @iGEL I agree with the objection of the PR but I am not quiet sure about the method name for a public API . I would rather prefer a lot of verb liked names and something like |
@scepticulous As mentioned in the description, def request(verb_or_uri, uri_or_env = nil, params = {}, env_or_nothing = {}, &block)
if uri_or_env.is_a(String)
uri = uri_or_env
env = env_for(uri, env_or_nothing.merge(:method => verb_or_uri.to_s.upcase, :params => params))
else
uri = verb_or_uri
env = env_for(uri, uri_or_env)
end
uri = parse_uri(uri, env)
process_request(uri, env, &block)
end So, I could rename To your second comment: I don't really get it. I basically just moved the spec to a better place (the shared example is only used here) and improved it a bit. |
@iGEL thanks a lot for the i depth explanation. And sorry I did not read the diff correctly with regards to the test. So refining my two complains:
@perlun @junaruga I suggest merging the PR after a final rebase, since it is an improvement in two ways. However it also showed that the touched code needs general improvement, however I would not block this PR because of that but would try to find time to take a look at it myself before we release 1.0. |
@scepticulous |
I believe, it's not useful to support every HTTP verb defined everywhere with a custom method. But it should be possible to use those verbs, thus we should introduce a method to trigger requests with a custom verb. Unfortunately, there is already a public request method, so I had to choose a different name.
RSpec is encouraging very long blocks, so I don't think there's a way around them. The block in the gemspec is just configuration.
@scepticulous @junaruga @perlun Thanks for the review 😄 I rebased the commit now, but I also added c32207e, because rubocop was complaining about very long blocks in the specs, which I don't consider a bad thing. WDYT? codeclimate is failing, because it uses an outdated version of rubocop. |
@iGEL thanks. I agree with you about the block length but not exactly with disabling it. In my opinion it is fine to have a higher value for tests but I would not disable it. Can you find the value that is appropriate / necessary at the moment, so something like 2-5 to the number necessary to make rubocop happy?. |
Thank you 😊 |
* Introduce custom_request to support all verbs I believe, it's not useful to support every HTTP verb defined everywhere with a custom method. But it should be possible to use those verbs, thus we should introduce a method to trigger requests with a custom verb. Unfortunately, there is already a public request method, so I had to choose a different name. * Avoid parsing the URI twice [Fixes rack#104] * Allow long blocks in spec & gemspec RSpec is encouraging very long blocks, so I don't think there's a way around them. The block in the gemspec is just configuration.
I believe, it's not useful to support every HTTP verb defined everywhere with a custom method. But it should be possible to use those verbs, thus we should introduce a method to trigger requests with a custom verb. Unfortunately, there is already a public request method, so I had to choose a different name.
As requested, this is a rebased & updated version of #111. I wanted to asked to reopen that one, but my changes didn't show up after force pushing, so I opened a new PR.