Skip to content

An easy setup stub framework in Clojure. Wrapping Moco.

License

Notifications You must be signed in to change notification settings

qianyan/clj-moco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj-moco Clojars Project

CircleCI An easy setup stub framework in Clojure, wrapping Moco.

Usage

1. matches jsonpath

(respond (matches (http-server 12306) (eq (json-path "$.book.price") "1")) "foo")
or
(-> (http-server 12306)
    (matches (eq (json-path "$.book.price") "1"))
    (respond "foo"))

2. matches json

(respond (matches (http-server 12306) (json "{\"foo\":\"bar\"}")) "foo")
or
(-> (http-server 12306)
    (matches (json "{\"foo\":\"bar\"}"))
    (respond "foo"))

3. matches map

(respond (matches (http-server 12306) (map->json {:code 1 :message "message"})) "foo")
or
(-> (http-server 12306)
    (matches (map->json {:code 1 :message "message"}))
    (respond "foo"))

4. exists jsonpath

(respond (matches (http-server 12306) (exists (json-path "$.book.price"))) "foo")
or
(-> (http-server 12306)
    (matches (exists (json-path "$.book.price")))
    (respond "foo"))

5. respond something

(-> (http-server 12306)
    (respond "foo"))

6. respond a file

(-> (http-server 12306)
    (respond (->file "resources/foo.response")))

7. by uri

(-> (http-server 12306)
    (matches (by (uri "/foo")))
    (respond "bar"))

8. and/or predicate

(require '[predicates :as p])
(-> (http-server 12306)
    (matches (p/and (by "foo") (by (uri "/foo"))))
    (respond "bar"))
    
(-> (http-server 12306)
    (matches (p/or (by "foo") (by (uri "/foo"))))
    (respond "bar"))    

License

Copyright © 2016 lambeta

Distributed under the Eclipse Public License either version 1.0

About

An easy setup stub framework in Clojure. Wrapping Moco.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published