Skip to content
a basic api for interacting with ring apps
Clojure
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src/peridot
test/peridot/test
.gitignore
.travis.yml
README.md
project.clj

README.md

peridot

peridot is a testing API for ring apps. It can be used on its own or as a reusable starting point for Web frameworks and testing libraries to build on. Its initial functionality is based on an incomplete port of Rack::Test's test suite.

Features

  • Designed to be used with clojure.core/->
  • Maintains a cookie jar across requests
  • Set request headers to be used by all subsequent requests

Dependency Information

peridot is available from clojars.

[peridot/peridot "0.0.2"]

or to your Maven project's pom.xml (requires adding clojars repo):

<dependency>
  <groupId>peridot</groupId>
  <artifactId>peridot</artifactId>
  <version>0.0.2</version>
</dependency>

Example Usage

(use '[peridot.core])

(-> (session ring-app) ;Use your ring app
    (request "/login" :request-method :post
                      :params {"username" "someone"
                               "password" "password"})
    (follow-redirect)
    (has (in [:response :body] "Hi someone"))
    (request "/logout")
    (follow-redirect)
    (has (in [:response :body] "Hi unknown person")))

(-> (session app)
    (header "User-Agent" "Firefox")
    (request "/")
    (has (in [:request :headers "user-agent"] "Firefox")))

(-> (session ring-app)
    (authorize "bryan" "secret")
    (request "/")
    (has (in [:request :headers "authorization"] "Basic YnJ5YW46c2VjcmV0\n")))

session, request, headers, authorize, follow-redirect, and (has (in..)) are the main api methods. Each returns a state map with :request and :response being the ring request and response maps that were sent and recieved.

Additional docs to be created later. See tests until then.

Building

lein version 2 is used as the build tool.

License

Copyright (C) 2012 Nelson Morris

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.