Skip to content
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

:protocol missing #10

Closed
malcolmsparks opened this issue Nov 13, 2016 · 6 comments
Closed

:protocol missing #10

malcolmsparks opened this issue Nov 13, 2016 · 6 comments

Comments

@malcolmsparks
Copy link

Mock request does not generate :protocol as per Ring SPEC

:protocol
  (Required, String)
  The protocol the request was made with, e.g. "HTTP/1.1".

and fails to conform to the following spec:

(s/def :ring/request
  (s/keys :req-un [:ring.request/server-port
                   :ring.request/server-name
                   :ring.request/remote-addr
                   :ring.request/uri
                   :ring.request/scheme
                   :ring.request/protocol
                   :ring.request/headers
                   :ring.request/request-method]
          :opt-un [:ring.request/query-string
                   :ring.request/body]))

from ring-spec

@malcolmsparks
Copy link
Author

I found this when playing around with ring-spec - which is great btw. Is ring-mock deprecated now or does it just need a fix? Happy to send a PR.

@malcolmsparks
Copy link
Author

Also, :query-string is generated as nil, which fails the spec.

(s/explain-str :ring/request (assoc (request :get "/") :protocol "HTTP/1.1"))
=>
In: [:query-string] val: nil fails spec: :ring.request/query-string at: [:query-string] predicate: :clojure.spec/unknown

@weavejester
Copy link
Member

Needs a fix, I think! Ring-Mock is still useful for creating non-generative request maps. The :query-string key should probably be missing if it's not set.

@malcolmsparks
Copy link
Author

I don't know how you feel about the ring-mock project now, given that equivalent functionality could eventually form part of the ring-spec project (via generators). Personally, I like ring-mock and think it's worth keeping up-to-date. Feel free to delegate to me if you like, but I think the fixes are fairly trivial.

@weavejester
Copy link
Member

As far as I know, generators aren't designed for creating specific data structures, so Ring-Mock is still useful for creating non-generative request maps.

@jcf jcf mentioned this issue Apr 17, 2017
@jcf
Copy link
Member

jcf commented May 7, 2017

This should be fixed now that #12 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants