Git Product home page Git Product logo

ring-mock's People

Contributors

boechat107 avatar glenjamin avatar jcf avatar jgeraerts avatar lvh avatar morganastra avatar nukemberg avatar senior avatar sorsasampo avatar weavejester avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ring-mock's Issues

Add support for mocking multipart uploads

A built-in support for mocking multipart uploads would be nice.

In #9, @danielcompton gives a workaround using Peridot's peridot.multipart/build:

(-> (ring.mock.request/request :post "/my-file-upload")
    (merge (peridot.multipart/build {:data (io/file (io/resource "data.csv"))}))
    (app))

Peridot's implementation uses org.apache.httpcomponents/httpmime.

Maybe a similar function signature like (ring.mock.request/multipart request map) could be used, where the map keys would be strings and values could be either strings or files.

No license file

There's no LICENSE.md file for the specified MIT license. More and more OSS tools are scanning for these and concluding ring-mock doesn't have a specified license.

What is `json-body`

Hi - In the 3rd example, I am not sure what the function json-body is doing:

(is (= (your-handler (-> (mock/request :post "/api/endpoint")
(json-body {:foo "bar"})))

:protocol missing

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

post form-params bug

:content-type "application/x-www-form-urlencoded",
must in
:headers {"cookie" "ring-session=testuser" "content-type" "application/x-www-form-urlencoded; charset=UTF-8"}

Support mocking websocket requests?

Would it be possible to support mocking websocket requests, so that websocket servers could be tested without starting a server?

I have not been able to find any Clojure project that would test websockets without starting a server.

Old Clojure dependency means you can't open a REPL with current release of CIDER

Found while trying to fix #3. Upgrading dependency to clojure 1.7.0 fixed the issue; not sure how you'd like to proceed.

error in process sentinel: Could not start nREPL server: Error loading cider.nrepl.middleware.apropos: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.classpath: java.lang.RuntimeException: Unable to resolve symbol: response-for in this context, compiling:(cider/nrepl/middleware/classpath.clj:15)
Error loading cider.nrepl.middleware.complete: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.debug: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.format: java.lang.RuntimeException: Unable to resolve symbol: defprotocol+ in this context, compiling:(deps/cljfmt/v0v1v10/deps/rewrite_clj/v0v4v12/rewrite_clj/node/protocols.clj:9)
Error loading cider.nrepl.middleware.info: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.inspect: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.macroexpand: java.lang.RuntimeException: Unable to resolve symbol: response-for in this context, compiling:(cider/nrepl/middleware/macroexpand.clj:73)
Error loading cider.nrepl.middleware.ns: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.pprint: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.refresh: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.resource: java.lang.RuntimeException: Unable to resolve symbol: defsource in this context, compiling:(deps/compliment/v0v2v4/compliment/sources/resources.clj:42)
Error loading cider.nrepl.middleware.stacktrace: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.test: java.lang.RuntimeException: Unable to resolve symbol: some-> in this context, compiling:(cider/nrepl/middleware/util/cljs.clj:57)
Error loading cider.nrepl.middleware.trace: java.lang.RuntimeException: Unable to resolve symbol: response-for in this context, compiling:(cider/nrepl/middleware/trace.clj:16)
Error loading cider.nrepl.middleware.undef: java.lang.RuntimeException: Unable to resolve symbol: response-for in this context, compiling:(cider/nrepl/middleware/undef.clj:19)
Error loading refactor-nrepl.middleware: java.lang.RuntimeException: Unable to resolve symbol: reduce-kv in this context, compiling:(deps/toolsanalyzerjvm/v0v6v6/deps/toolsanalyzer/v0v6v5/clojure/tools/analyzer/utils.clj:49)
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: cider.nrepl.middleware.apropos/wrap-apropos in this context, compiling:(/private/var/folders/2w/kffqc_pj6m38rgrxlhk8z6nr0000gn/T/form-init7593186812270114693.clj:1)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6416)
    at clojure.lang.Compiler.analyze(Compiler.java:6216)
    at clojure.lang.Compiler.analyze(Compiler.java:6177)
    at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3503)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6411)
    at clojure.lang.Compiler.analyze(Compiler.java:6216)
    at clojure.lang.Compiler.analyze(Compiler.java:6177)
    at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3503)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6411)
    at clojure.lang.Compiler.analyze(Compiler.java:6216)
    at clojure.lang.Compiler.access$100(Compiler.java:37)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5837)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6409)
    at clojure.lang.Compiler.analyze(Compiler.java:6216)
    at clojure.lang.Compiler.analyze(Compiler.java:6177)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5572)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5008)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3629)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6407)
    at clojure.lang.Compiler.analyze(Compiler.java:6216)
    at clojure.lang.Compiler.eval(Compiler.java:6462)
    at clojure.lang.Compiler.eval(Compiler.java:6455)
    at clojure.lang.Compiler.load(Compiler.java:6902)
    at clojure.lang.Compiler.loadFile(Compiler.java:6863)
    at clojure.main$load_script.invoke(main.clj:282)
    at clojure.main$init_opt.invoke(main.clj:287)
    at clojure.main$initialize.invoke(main.clj:315)
    at clojure.main$null_opt.invoke(main.clj:348)
    at clojure.main$main.doInvoke(main.clj:426)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:405)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:518)
    at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unable to resolve var: cider.nrepl.middleware.apropos/wrap-apropos in this context
    at clojure.lang.Util.runtimeException(Util.java:156)
    at clojure.lang.Compiler$TheVarExpr$Parser.parse(Compiler.java:613)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6409)
    ... 33 more
Subprocess failed

ring-mock 0.3.0 drops DELETE body

Hi!

It seems that the newest version of ring-mock ("0.3.0") no longer accepts a body
in a DELETE request?

I have some API here that I would like to test which requires to pass along
content as the body of a DELETE request. Sadly that doesn't work right now in
the latest version.

The http spec doesn't disallow having a body in the request, although it warns
that some servers may ignore it. (Jetty, the one I'm using, doesn't ignore it).

As per http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19

Bodies on DELETE requests have no defined semantics. Note that sending a body
on a DELETE request might cause some existing implementations to reject the
request.

Also see this stackoverflow answer.

an entity-body is explicitly forbidden in TRACE requests only, all other
request types are unrestricted
(section 9, and 9.8 specifically)

(emphasis mine)

Seems like this was introduced in 38471fa

As it stands, this seems like a decision that should be done by the server
(e.g Jetty) rather than by the client (this library).

Is there any hope in this being changed back to the original implementation?

If not, at least this should be noted somewhere in the documentation.

What's the right way to simulate file upload

Hi,

I'm currently simulating file upload via the following CURL command:

curl -v  -XPOST -F filedata=@my_file.png localhost:3000/upload_endpoint

I want to simulate file uploads in tests but setting the Content-Type header with boundaries and a proper body like HTTP multipart spec requires is kind of tiresome.

Is there a good way to simulate file uploads via ring-mock?

Thanks in advance.

New release?

Hi @weavejester,
Would you mind releasing a 0.3.3 version with changes related to codox, remote-addr and mock/cookie ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.