Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ring-clojure/ring-mock
Library to create mock Ring requests for unit tests
https://github.com/ring-clojure/ring-mock
http mocks ring testing
Last synced: about 1 month ago
JSON representation
Library to create mock Ring requests for unit tests
- Host: GitHub
- URL: https://github.com/ring-clojure/ring-mock
- Owner: ring-clojure
- License: mit
- Fork: true (weavejester/ring-mock)
- Created: 2014-12-15T23:32:48.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T09:08:19.000Z (over 4 years ago)
- Last Synced: 2024-10-28T13:39:35.168Z (about 2 months ago)
- Topics: http, mocks, ring, testing
- Language: Clojure
- Homepage:
- Size: 157 KB
- Stars: 183
- Watchers: 9
- Forks: 18
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- stars - ring-clojure/ring-mock - Library to create mock Ring requests for unit tests \[*MIT License*\] (⭐️184) (Clojure)
- stars - ring-clojure/ring-mock - Library to create mock Ring requests for unit tests \[*MIT License*\] (⭐️184) (Clojure)
README
# Ring-Mock
[![Build Status](https://travis-ci.org/ring-clojure/ring-mock.svg?branch=master)](https://travis-ci.org/ring-clojure/ring-mock)
Ring-Mock is a library for creating [Ring][] request maps for testing
purposes.[ring]: https://github.com/ring-clojure/ring
## Installation
Add the following development dependency to your `project.clj` file:
[ring/ring-mock "0.4.0"]
## Documentation
* [API Documentation](https://ring-clojure.github.io/ring-mock/ring.mock.request.html)
## Example
```clojure
(ns your-app.core-test
(:require [clojure.test :refer :all]
[your-app.core :refer :all]
[ring.mock.request :as mock]))(deftest your-handler-test
(is (= (your-handler (mock/request :get "/doc/10"))
{:status 200
:headers {"content-type" "text/plain"}
:body "Your expected result"})))
(deftest your-json-handler-test
(is (= (your-handler (-> (mock/request :post "/api/endpoint")
(mock/json-body {:foo "bar"})))
{:status 201
:headers {"content-type" "application/json"}
:body {:key "your expected result"}})))
```## License
Copyright © 2019 James Reeves
Distributed under the MIT License.