The clack-pretend Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The clack-pretend Reference Manual

This is the clack-pretend Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Jun 15 04:11:17 2022 GMT+0.

Table of Contents


1 Introduction

Clack-pretend: a testing and debugging tool for Clack.

Are you tired of jumping to your web browser every time you need to test your work in Clack? Clack-pretend will capture and replay calls to your clack middleware stack. When developing a web application with clack, you will often find it inconvenient to run your code from the lisp REPL because it expects a clack environment, including perhaps, cookies or a logged-in user. With clack-pretend, you can run prior web requests from your REPL, moving development back where it belongs.

Setup

First, replace lack:builder or clack:builder:

(lack:builder
  ...

with pretend-builder:

(clack-pretend:pretend-builder (:insert 3)
  ...

Pretend builder, aside from its recording features, is a thin wrapper around lack:builder.

The :insert parameter is where pretend will capture the environment and output. For example given this app:

(clack-pretend:pretend-builder (:insert 3)
  (:static :path "~/public_html/")
  :accesslog
  :session
  (custom-middleware param)
  (my-app))

The collection point will be inserted just after the session middleware, and just before custom-middleware.

To use clack-pretend, restart your clack app and visit a page with your web browser.

Quick summary

(quick-summary)

This function gives a list of URLs that have been captured.

Info functions

Most of the info functions hava an optional parameter named index. The default is 0, or the last request received by the stack. By default clack-pretend stores up to 10 requests. Higher indices retrieve older requests.

(last-input (&optional (index 0))

The input environment as it was received from the middleware above the insertion point.

(last-output (&optional (index 0))

The output of the app below the insertion point.

(last-request-object (&optional (index 0))

A clack request object generated from the results of last-input.

(last-request-url ())        

The URL of the last request.

(last-session (&optional (index 0))

The session object from the last request.

(last-as-code (&optional (index 0))

Attempts to output the last environment and session as usable source code. This is useful for turning a web request into something usable as a unit test for your middleware.

Running your last request

> (run-pretend)

Runs the last web request starting below the insert point with the saved environment information from above the insert point.

Author

Ben McGunigle (bnmcgn at gmail.com)

Copyright

Copyright (c) 2017 Ben McGunigle

License

Apache License version 2.0


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 clack-pretend

A testing and debugging tool for Clack

Author

Ben McGunigle <bnmcgn@gmail.com>

License

Apache License, version 2.0

Dependencies
  • clack (system).
  • alexandria (system).
  • lack-request (system).
  • circular-streams (system).
  • cl-hash-util (system).
Source

clack-pretend.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 clack-pretend/clack-pretend.asd

Source

clack-pretend.asd.

Parent Component

clack-pretend (system).

ASDF Systems

clack-pretend.


3.1.2 clack-pretend/package.lisp

Source

clack-pretend.asd.

Parent Component

clack-pretend (system).

Packages

clack-pretend.


3.1.3 clack-pretend/clack-pretend.lisp

Dependency

package.lisp (file).

Source

clack-pretend.asd.

Parent Component

clack-pretend (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 clack-pretend

Source

package.lisp.

Use List
  • alexandria.
  • common-lisp.
  • lack.component.
  • lack.request.
Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Macros

Macro: pretend-builder ((&key insert watch-symbols errors-only logfile) &rest middles-and-app)
Package

clack-pretend.

Source

clack-pretend.lisp.

Macro: verbose-builder (&rest middles-and-app)
Package

clack-pretend.

Source

clack-pretend.lisp.


Previous: , Up: Public Interface   [Contents][Index]

5.1.2 Ordinary functions

Function: last-as-code (&optional index)
Package

clack-pretend.

Source

clack-pretend.lisp.

Function: last-input (&optional index)
Package

clack-pretend.

Source

clack-pretend.lisp.

Function: last-output (&optional index)
Package

clack-pretend.

Source

clack-pretend.lisp.

Function: last-request-object (&optional index)
Package

clack-pretend.

Source

clack-pretend.lisp.

Function: last-request-url ()
Package

clack-pretend.

Source

clack-pretend.lisp.

Function: last-session (&optional index)
Package

clack-pretend.

Source

clack-pretend.lisp.

Function: quick-summary ()
Package

clack-pretend.

Source

clack-pretend.lisp.

Function: run-pretend (&key index path-info app-chain)
Package

clack-pretend.

Source

clack-pretend.lisp.

Function: verbose-component (message)
Package

clack-pretend.

Source

clack-pretend.lisp.


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Special variables

Special Variable: *logfile*
Package

clack-pretend.

Source

clack-pretend.lisp.

Special Variable: *pretend-app-chain*
Package

clack-pretend.

Source

clack-pretend.lisp.

Special Variable: *pretend-storage*
Package

clack-pretend.

Source

clack-pretend.lisp.

Special Variable: *pretend-storage-size*
Package

clack-pretend.

Source

clack-pretend.lisp.

Special Variable: *watch-symbols*
Package

clack-pretend.

Source

clack-pretend.lisp.


Previous: , Up: Internals   [Contents][Index]

5.2.2 Ordinary functions

Function: hash-table->source (ht)

Returns a source code representation of a hash table.

Package

clack-pretend.

Source

clack-pretend.lisp.

Function: pretend-component (app watch-symbols error-only logfile)
Package

clack-pretend.

Source

clack-pretend.lisp.

Function: store-results (input output)
Package

clack-pretend.

Source

clack-pretend.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   F   H   L   M   P   Q   R   S   V  
Index Entry  Section

F
Function, hash-table->source: Private ordinary functions
Function, last-as-code: Public ordinary functions
Function, last-input: Public ordinary functions
Function, last-output: Public ordinary functions
Function, last-request-object: Public ordinary functions
Function, last-request-url: Public ordinary functions
Function, last-session: Public ordinary functions
Function, pretend-component: Private ordinary functions
Function, quick-summary: Public ordinary functions
Function, run-pretend: Public ordinary functions
Function, store-results: Private ordinary functions
Function, verbose-component: Public ordinary functions

H
hash-table->source: Private ordinary functions

L
last-as-code: Public ordinary functions
last-input: Public ordinary functions
last-output: Public ordinary functions
last-request-object: Public ordinary functions
last-request-url: Public ordinary functions
last-session: Public ordinary functions

M
Macro, pretend-builder: Public macros
Macro, verbose-builder: Public macros

P
pretend-builder: Public macros
pretend-component: Private ordinary functions

Q
quick-summary: Public ordinary functions

R
run-pretend: Public ordinary functions

S
store-results: Private ordinary functions

V
verbose-builder: Public macros
verbose-component: Public ordinary functions

Jump to:   F   H   L   M   P   Q   R   S   V