The clack-pretend Reference Manual

Table of Contents

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

The clack-pretend Reference Manual

This is the clack-pretend Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:38:12 2018 GMT+0.


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

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


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

2 Systems

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


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

2.1 clack-pretend

Author

Ben McGunigle <bnmcgn@gmail.com>

License

Apache License, version 2.0

Description

A testing and debugging tool for Clack

Dependencies
Source

clack-pretend.asd (file)

Components

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

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 files   [Contents][Index]

3.1.1 clack-pretend.asd

Location

clack-pretend.asd

Systems

clack-pretend (system)


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

3.1.2 clack-pretend/package.lisp

Parent

clack-pretend (system)

Location

package.lisp

Packages

clack-pretend


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

3.1.3 clack-pretend/clack-pretend.lisp

Dependency

package.lisp (file)

Parent

clack-pretend (system)

Location

clack-pretend.lisp

Exported Definitions
Internal Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 clack-pretend

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

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

5 Definitions

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


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

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: pretend-builder (&key INSERT WATCH-SYMBOLS) &rest MIDDLES-AND-APP
Package

clack-pretend

Source

clack-pretend.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: last-as-code &optional INDEX
Package

clack-pretend

Source

clack-pretend.lisp (file)

Function: last-input &optional INDEX
Package

clack-pretend

Source

clack-pretend.lisp (file)

Function: last-output &optional INDEX
Package

clack-pretend

Source

clack-pretend.lisp (file)

Function: last-request-object &optional INDEX
Package

clack-pretend

Source

clack-pretend.lisp (file)

Function: last-request-url ()
Package

clack-pretend

Source

clack-pretend.lisp (file)

Function: last-session &optional INDEX
Package

clack-pretend

Source

clack-pretend.lisp (file)

Function: quick-summary ()
Package

clack-pretend

Source

clack-pretend.lisp (file)

Function: run-pretend &key INDEX PATH-INFO
Package

clack-pretend

Source

clack-pretend.lisp (file)


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

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *pretend-app-chain*
Package

clack-pretend

Source

clack-pretend.lisp (file)

Special Variable: *pretend-storage*
Package

clack-pretend

Source

clack-pretend.lisp (file)

Special Variable: *pretend-storage-size*
Package

clack-pretend

Source

clack-pretend.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: hash-table->source HT

Returns a source code representation of a hash table.

Package

clack-pretend

Source

clack-pretend.lisp (file)

Function: pretend-component APP WATCH-SYMBOLS
Package

clack-pretend

Source

clack-pretend.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
clack-pretend.asd: The clack-pretend<dot>asd file
clack-pretend/clack-pretend.lisp: The clack-pretend/clack-pretend<dot>lisp file
clack-pretend/package.lisp: The clack-pretend/package<dot>lisp file

F
File, Lisp, clack-pretend.asd: The clack-pretend<dot>asd file
File, Lisp, clack-pretend/clack-pretend.lisp: The clack-pretend/clack-pretend<dot>lisp file
File, Lisp, clack-pretend/package.lisp: The clack-pretend/package<dot>lisp file

L
Lisp File, clack-pretend.asd: The clack-pretend<dot>asd file
Lisp File, clack-pretend/clack-pretend.lisp: The clack-pretend/clack-pretend<dot>lisp file
Lisp File, clack-pretend/package.lisp: The clack-pretend/package<dot>lisp file

Jump to:   C   F   L  

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

A.2 Functions

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

F
Function, hash-table->source: Internal functions
Function, last-as-code: Exported functions
Function, last-input: Exported functions
Function, last-output: Exported functions
Function, last-request-object: Exported functions
Function, last-request-url: Exported functions
Function, last-session: Exported functions
Function, pretend-component: Internal functions
Function, quick-summary: Exported functions
Function, run-pretend: Exported functions

H
hash-table->source: Internal functions

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

M
Macro, pretend-builder: Exported macros

P
pretend-builder: Exported macros
pretend-component: Internal functions

Q
quick-summary: Exported functions

R
run-pretend: Exported functions

Jump to:   F   H   L   M   P   Q   R  

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

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*pretend-app-chain*: Internal special variables
*pretend-storage*: Internal special variables
*pretend-storage-size*: Internal special variables

S
Special Variable, *pretend-app-chain*: Internal special variables
Special Variable, *pretend-storage*: Internal special variables
Special Variable, *pretend-storage-size*: Internal special variables

Jump to:   *  
S  

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

A.4 Data types

Jump to:   C   P   S  
Index Entry  Section

C
clack-pretend: The clack-pretend system
clack-pretend: The clack-pretend package

P
Package, clack-pretend: The clack-pretend package

S
System, clack-pretend: The clack-pretend system

Jump to:   C   P   S