All Projects → unrelentingtech → clj-http-fake

unrelentingtech / clj-http-fake

Licence: MIT license
Helper for faking clj-http requests.

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to clj-http-fake

extractors
Data extractors for import demo-date to the api
Stars: ✭ 44 (-64.52%)
Mutual labels:  mock
kmpapp
👨‍💻 Kotlin Mobile Multiplatform App (Android & iOS). One Code To Rule Them All. MVVM, DI (Kodein), coroutines, livedata, ktor, serialization, mockk, detekt, ktlint, jacoco
Stars: ✭ 34 (-72.58%)
Mutual labels:  mock
vue-admin-better
🚀🚀🚀vue admin,vue3 admin,vue3.0 admin,vue后台管理,vue-admin,vue3.0-admin,admin,vue-admin,vue-element-admin,ant-design,vue-admin-beautiful-pro,vab admin pro,vab admin plus,vue admin plus,vue admin pro
Stars: ✭ 12,962 (+10353.23%)
Mutual labels:  mock
jest-ts-auto-mock
Jest test utility with automatic mock creation for interfaces and classes
Stars: ✭ 150 (+20.97%)
Mutual labels:  mock
IOS-CoreBluetooth-Mock
Mocking library for CoreBluetooth framework.
Stars: ✭ 142 (+14.52%)
Mutual labels:  mock
sinon-mongoose
Extend Sinon stubs for Mongoose methods to test chained methods easily
Stars: ✭ 87 (-29.84%)
Mutual labels:  mock
chrome-extension-mocker
The most convenient tool to mock requests for axios, with built-in Chrome extension support.
Stars: ✭ 37 (-70.16%)
Mutual labels:  mock
laika
Log, test, intercept and modify Apollo Client's operations
Stars: ✭ 99 (-20.16%)
Mutual labels:  mock
network-monitor-ios
Network Monitor SDK for iOS
Stars: ✭ 70 (-43.55%)
Mutual labels:  mock
vue-admin-work
🎉🎉🚀🚀🚀🚀vue-admin-work是一个中后台系统管理方案。使用 vue2.x 及周边全家桶工具开发而来。支持多种功能,不同角色权限🚀🚀🚀🎉🎉
Stars: ✭ 74 (-40.32%)
Mutual labels:  mock
main
Mocks Server monorepo
Stars: ✭ 109 (-12.1%)
Mutual labels:  mock
spydriver
🕵️ Lightweight utility to intercept WebDriver and WebElement method calls.
Stars: ✭ 24 (-80.65%)
Mutual labels:  mock
electron-admin-element-vue
Electron Vue3.x Element-UI Admin
Stars: ✭ 37 (-70.16%)
Mutual labels:  mock
MockAlamofire
A simple example showing how to override the URLProtocol to return mock data on Alamofire responses. Helpful if you are looking for a simple way to mock an Alamofire response, with out any additional dependencies.
Stars: ✭ 22 (-82.26%)
Mutual labels:  mock
FireMock
Mock and stub HTTP requests. Test your apps with fake data and files responses.
Stars: ✭ 25 (-79.84%)
Mutual labels:  mock
racket-mock
Mocking library for Racket
Stars: ✭ 22 (-82.26%)
Mutual labels:  mock
h-blog
vue+elementUI模仿我的博客,简单的写的几个练习页面
Stars: ✭ 14 (-88.71%)
Mutual labels:  mock
electron-mock-ipc
Mock Electron's ipcMain, and ipcRenderer
Stars: ✭ 21 (-83.06%)
Mutual labels:  mock
gadgeto
Gadgeto! is a collection of tools that aim to facilitate the development of REST APIs in Go.
Stars: ✭ 38 (-69.35%)
Mutual labels:  mock
nei-toolkit
NEI 接口文档管理平台配套自动化工具
Stars: ✭ 814 (+556.45%)
Mutual labels:  mock

clj-http-fake Build Status MIT License Clojars Project

Basically, fakeweb in Clojure, for clj-http.

Usage

(ns myapp.test.core
  (:require [clj-http.client :as c])
  (:use clj-http.fake))

The public interface consists of macros:

  • with-fake-routes - lets you override clj-http requests that match keys in the provided map
  • with-fake-routes-in-isolation - does the same but throws if a request does not match any key
  • with-global-fake-routes
  • with-global-fake-routes-in-isolation

'Global' counterparts use with-redefs instead of binding internally so they can be used in a multi-threaded environment.

Examples

(with-fake-routes {
  ;; Exact string match:
  "http://google.com/apps" (fn [request] {:status 200 :headers {} :body "Hey, do I look like Google.com?"})
  ;; matches (c/get "http://google.com/apps")

  ;; Exact string match with query params:
  "http://google.com/?query=param" (fn [request] {:status 200 :headers {} :body "Nah, that can't be Google!"})
  ;; matches (c/get "http://google.com/" {:query-params {:query "param"}})

  ;; Regexp match:
  #"https://([a-z]+).unrelenting.technology" (fn [req] {:status 200 :headers {} :body "Hello world"})
  ;; matches (c/get "https://labs.unrelenting.technology"), (c/get "https://server.unrelenting.technology") and so on, based on regexp.

  ;; Match based an HTTP method:
  "http://shmoogle.com/" {:get (fn [req] {:status 200 :headers {} :body "What is Scmoogle anyways?"})}
  ;; will match only (c/get "http://google.com/")

  ;; Match multiple HTTP methods:
  "http://doogle.com/" {:get    (fn [req] {:status 200 :headers {} :body "Nah, that can't be Google!"})
                        :delete (fn [req] {:status 401 :headers {} :body "Do you think you can delete me?!"})}

  ;; Match using query params as a map
   {:address "http://google.com/search"
    :query-params {:q "aardark"}} (fn [req] {:status 200 :headers {} :body "Searches have results"})

   ;; If not given, the fake response status will be 200 and the body will be "".
   "https://duckduckgo.com/?q=ponies" (constantly {})}

 ;; Your tests with requests here
 )

Development

Use Leiningen with profiles. E.g.:

$ lein with-profile +latest-3.x,+1.8 repl

There are aliases to run the tests with the oldest and newest supported versions of clj-http:

$ lein test-3.x  # Testing under clj-http 3.x
$ lein test-2.x  # Testing under clj-http 2.x

License

Released under the MIT License.

Contributing

Please feel free to submit pull requests!

By participating in this project you agree to follow the Contributor Code of Conduct.

The list of contributors is available on GitHub.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].