This file is indexed.

/usr/share/doc/libghc-yesod-test-doc/html/Yesod-Test.html is in libghc-yesod-test-doc 1.5.0.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Yesod.Test</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Yesod-Test.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Yesod-Test.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">yesod-test-1.5.0.1: integration testing for WAI/Yesod Applications</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Yesod.Test</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Declaring and running your test suite</a></li><li><a href="#g:2">Making requests</a><ul><li><a href="#g:3">Adding fields by label</a></li><li><a href="#g:4">CSRF Tokens</a></li></ul></li><li><a href="#g:5">Assertions</a></li><li><a href="#g:6">Grab information</a></li><li><a href="#g:7">Debug output</a></li><li><a href="#g:8">Utils for building your own assertions</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Yesod.Test is a pragmatic framework for testing web applications built
using wai and persistent.</p><p>By pragmatic I may also mean <code>dirty</code>. Its main goal is to encourage integration
and system testing of web applications by making everything <em>easy to test</em>.</p><p>Your tests are like browser sessions that keep track of cookies and the last
visited page. You can perform assertions on the content of HTML responses,
using CSS selectors to explore the document more easily.</p><p>You can also easily build requests using forms present in the current page.
This is very useful for testing web applications built in yesod, for example,
where your forms may have field names generated by the framework or a randomly
generated CSRF token input.</p><p>Your database is also directly available so you can use <code>runDB</code> to set up
backend pre-conditions, or to assert that your session is having the desired effect.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:yesodSpec">yesodSpec</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:YesodDispatch">YesodDispatch</a> site =&gt; site -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site -&gt; <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:Spec">Spec</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:YesodSpec">YesodSpec</a> site = <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-Writer-Lazy.html#t:Writer">Writer</a> [<a href="Yesod-Test.html#t:YesodSpecTree">YesodSpecTree</a> site] ()</li><li class="src short"><a href="#v:yesodSpecWithSiteGenerator">yesodSpecWithSiteGenerator</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:YesodDispatch">YesodDispatch</a> site =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> site -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site -&gt; <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:Spec">Spec</a></li><li class="src short"><a href="#v:yesodSpecApp">yesodSpecApp</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:YesodDispatch">YesodDispatch</a> site =&gt; site -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Application">Application</a> -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site -&gt; <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:Spec">Spec</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:YesodExample">YesodExample</a> site = <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-State-Lazy.html#t:StateT">StateT</a> (<a href="Yesod-Test.html#t:YesodExampleData">YesodExampleData</a> site) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:YesodExampleData">YesodExampleData</a> site = <a href="#v:YesodExampleData">YesodExampleData</a> {<ul class="subs"><li><a href="#v:yedApp">yedApp</a> :: !<a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Application">Application</a></li><li><a href="#v:yedSite">yedSite</a> :: !site</li><li><a href="#v:yedCookies">yedCookies</a> :: !Cookies</li><li><a href="#v:yedResponse">yedResponse</a> :: !(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/share/doc/libghc-wai-extra-doc/html/Network-Wai-Test.html#t:SResponse">SResponse</a>)</li></ul>}</li><li class="src short"><span class="keyword">type</span> <a href="#t:TestApp">TestApp</a> site = (site, <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Middleware">Middleware</a>)</li><li class="src short"><span class="keyword">type</span> <a href="#t:YSpec">YSpec</a> site = <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:SpecWith">SpecWith</a> (<a href="Yesod-Test.html#t:TestApp">TestApp</a> site)</li><li class="src short"><a href="#v:testApp">testApp</a> :: site -&gt; <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Middleware">Middleware</a> -&gt; <a href="Yesod-Test.html#t:TestApp">TestApp</a> site</li><li class="src short"><span class="keyword">data</span> <a href="#t:YesodSpecTree">YesodSpecTree</a> site<ul class="subs"><li>= <a href="#v:YesodSpecGroup">YesodSpecGroup</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> [<a href="Yesod-Test.html#t:YesodSpecTree">YesodSpecTree</a> site]</li><li>| <a href="#v:YesodSpecItem">YesodSpecItem</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> (<a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ())</li></ul></li><li class="src short"><a href="#v:ydescribe">ydescribe</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site</li><li class="src short"><a href="#v:yit">yit</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site</li><li class="src short"><a href="#v:get">get</a> :: (<a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site, <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#t:RedirectUrl">RedirectUrl</a> site url) =&gt; url -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:post">post</a> :: (<a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site, <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#t:RedirectUrl">RedirectUrl</a> site url) =&gt; url -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:postBody">postBody</a> :: (<a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site, <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#t:RedirectUrl">RedirectUrl</a> site url) =&gt; url -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:request">request</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site =&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:addRequestHeader">addRequestHeader</a> :: <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Header.html#t:Header">Header</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:setMethod">setMethod</a> :: <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Method.html#t:Method">Method</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:addPostParam">addPostParam</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:addGetParam">addGetParam</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:addFile">addFile</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:setRequestBody">setRequestBody</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><span class="keyword">type</span> <a href="#t:RequestBuilder">RequestBuilder</a> site = <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-State-Lazy.html#t:StateT">StateT</a> (RequestBuilderData site) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a></li><li class="src short"><a href="#v:setUrl">setUrl</a> :: (<a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site, <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#t:RedirectUrl">RedirectUrl</a> site url) =&gt; url -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:byLabel">byLabel</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:fileByLabel">fileByLabel</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a> -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:addToken">addToken</a> :: <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:addToken_">addToken_</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:addTokenFromCookie">addTokenFromCookie</a> :: <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:addTokenFromCookieNamedToHeaderNamed">addTokenFromCookieNamedToHeaderNamed</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="file:///usr/share/doc/libghc-case-insensitive-doc/html/Data-CaseInsensitive.html#t:CI">CI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</li><li class="src short"><a href="#v:assertEqual">assertEqual</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; a -&gt; a -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:assertHeader">assertHeader</a> :: <a href="file:///usr/share/doc/libghc-case-insensitive-doc/html/Data-CaseInsensitive.html#t:CI">CI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:assertNoHeader">assertNoHeader</a> :: <a href="file:///usr/share/doc/libghc-case-insensitive-doc/html/Data-CaseInsensitive.html#t:CI">CI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:statusIs">statusIs</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:bodyEquals">bodyEquals</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:bodyContains">bodyContains</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:htmlAllContain">htmlAllContain</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:htmlAnyContain">htmlAnyContain</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:htmlNoneContain">htmlNoneContain</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:htmlCount">htmlCount</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:getTestYesod">getTestYesod</a> :: <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site site</li><li class="src short"><a href="#v:getResponse">getResponse</a> :: <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/share/doc/libghc-wai-extra-doc/html/Network-Wai-Test.html#t:SResponse">SResponse</a>)</li><li class="src short"><a href="#v:getRequestCookies">getRequestCookies</a> :: <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site Cookies</li><li class="src short"><a href="#v:printBody">printBody</a> :: <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:printMatches">printMatches</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ()</li><li class="src short"><a href="#v:htmlQuery">htmlQuery</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site [<a href="Yesod-Test-TransversingCSS.html#t:HtmlLBS">HtmlLBS</a>]</li><li class="src short"><a href="#v:parseHTML">parseHTML</a> :: <a href="Yesod-Test-TransversingCSS.html#t:HtmlLBS">HtmlLBS</a> -&gt; <a href="file:///usr/share/doc/libghc-xml-conduit-doc/html/Text-XML-Cursor.html#t:Cursor">Cursor</a></li><li class="src short"><a href="#v:withResponse">withResponse</a> :: (<a href="file:///usr/share/doc/libghc-wai-extra-doc/html/Network-Wai-Test.html#t:SResponse">SResponse</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site a) -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site a</li></ul></div><div id="interface"><h1 id="g:1">Declaring and running your test suite</h1><div class="top"><p class="src"><a name="v:yesodSpec" class="def">yesodSpec</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:YesodDispatch">YesodDispatch</a> site =&gt; site -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site -&gt; <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:Spec">Spec</a> <a href="src/Yesod-Test.html#yesodSpec" class="link">Source</a></p></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:YesodSpec" class="def">YesodSpec</a> site = <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-Writer-Lazy.html#t:Writer">Writer</a> [<a href="Yesod-Test.html#t:YesodSpecTree">YesodSpecTree</a> site] () <a href="src/Yesod-Test.html#YesodSpec" class="link">Source</a></p><div class="doc"><p>Corresponds to hspec's <code>Spec</code>.</p><p>Since 1.2.0</p></div></div><div class="top"><p class="src"><a name="v:yesodSpecWithSiteGenerator" class="def">yesodSpecWithSiteGenerator</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:YesodDispatch">YesodDispatch</a> site =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> site -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site -&gt; <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:Spec">Spec</a> <a href="src/Yesod-Test.html#yesodSpecWithSiteGenerator" class="link">Source</a></p><div class="doc"><p>Same as yesodSpec, but instead of taking already built site it
 takes an action which produces site for each test.</p></div></div><div class="top"><p class="src"><a name="v:yesodSpecApp" class="def">yesodSpecApp</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:YesodDispatch">YesodDispatch</a> site =&gt; site -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Application">Application</a> -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site -&gt; <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:Spec">Spec</a> <a href="src/Yesod-Test.html#yesodSpecApp" class="link">Source</a></p><div class="doc"><p>Same as yesodSpec, but instead of taking a site it
 takes an action which produces the <code><a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Application">Application</a></code> for each test.
 This lets you use your middleware from makeApplication</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:YesodExample" class="def">YesodExample</a> site = <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-State-Lazy.html#t:StateT">StateT</a> (<a href="Yesod-Test.html#t:YesodExampleData">YesodExampleData</a> site) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> <a href="src/Yesod-Test.html#YesodExample" class="link">Source</a></p><div class="doc"><p>A single test case, to be run with <code><a href="Yesod-Test.html#v:yit">yit</a></code>.</p><p>Since 1.2.0</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:YesodExampleData" class="def">YesodExampleData</a> site <a href="src/Yesod-Test.html#YesodExampleData" class="link">Source</a></p><div class="doc"><p>The state used in a single test case defined using <code><a href="Yesod-Test.html#v:yit">yit</a></code></p><p>Since 1.2.4</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:YesodExampleData" class="def">YesodExampleData</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:yedApp" class="def">yedApp</a> :: !<a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Application">Application</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:yedSite" class="def">yedSite</a> :: !site</dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:yedCookies" class="def">yedCookies</a> :: !Cookies</dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:yedResponse" class="def">yedResponse</a> :: !(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/share/doc/libghc-wai-extra-doc/html/Network-Wai-Test.html#t:SResponse">SResponse</a>)</dt><dd class="doc empty">&nbsp;</dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:YesodExampleData" class="caption collapser" onclick="toggleSection('i:YesodExampleData')">Instances</p><div id="section.i:YesodExampleData" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:YesodDispatch">YesodDispatch</a> site =&gt; <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:Example">Example</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-State-Lazy.html#t:StateT">StateT</a> (<a href="Yesod-Test.html#t:YesodExampleData">YesodExampleData</a> site) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> a)</span> <a href="src/Yesod-Test.html#line-922" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src clearfix"><span class="inst-left"><span class="keyword">type</span> <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:Arg">Arg</a> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-State-Lazy.html#t:StateT">StateT</a> (<a href="Yesod-Test.html#t:YesodExampleData">YesodExampleData</a> site) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> a) = <a href="Yesod-Test.html#t:TestApp">TestApp</a> site</span> <a href="src/Yesod-Test.html#line-923" class="link">Source</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:TestApp" class="def">TestApp</a> site = (site, <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Middleware">Middleware</a>) <a href="src/Yesod-Test.html#TestApp" class="link">Source</a></p></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:YSpec" class="def">YSpec</a> site = <a href="file:///usr/share/doc/libghc-hspec-core-doc/html/Test-Hspec-Core-Spec.html#t:SpecWith">SpecWith</a> (<a href="Yesod-Test.html#t:TestApp">TestApp</a> site) <a href="src/Yesod-Test.html#YSpec" class="link">Source</a></p></div><div class="top"><p class="src"><a name="v:testApp" class="def">testApp</a> :: site -&gt; <a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Middleware">Middleware</a> -&gt; <a href="Yesod-Test.html#t:TestApp">TestApp</a> site <a href="src/Yesod-Test.html#testApp" class="link">Source</a></p></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:YesodSpecTree" class="def">YesodSpecTree</a> site <a href="src/Yesod-Test.html#YesodSpecTree" class="link">Source</a></p><div class="doc"><p>Internal data structure, corresponding to hspec's <code><a href="Yesod-Test.html#t:YesodSpecTree">YesodSpecTree</a></code>.</p><p>Since 1.2.0</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:YesodSpecGroup" class="def">YesodSpecGroup</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> [<a href="Yesod-Test.html#t:YesodSpecTree">YesodSpecTree</a> site]</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:YesodSpecItem" class="def">YesodSpecItem</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> (<a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site ())</td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="top"><p class="src"><a name="v:ydescribe" class="def">ydescribe</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site <a href="src/Yesod-Test.html#ydescribe" class="link">Source</a></p><div class="doc"><p>Start describing a Tests suite keeping cookies and a reference to the tested <code><a href="file:///usr/share/doc/libghc-wai-doc/html/Network-Wai.html#t:Application">Application</a></code>
 and <code>ConnectionPool</code></p></div></div><div class="top"><p class="src"><a name="v:yit" class="def">yit</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () -&gt; <a href="Yesod-Test.html#t:YesodSpec">YesodSpec</a> site <a href="src/Yesod-Test.html#yit" class="link">Source</a></p><div class="doc"><p>Describe a single test that keeps cookies, and a reference to the last response.</p></div></div><h1 id="g:2">Making requests</h1><div class="doc"><p>You can construct requests with the <code><a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a></code> monad, which lets you
 set the URL and add parameters, headers, and files. Helper functions are provided to
 lookup fields by label and to add the current CSRF token from your forms.
 Once built, the request can be executed with the <code><a href="Yesod-Test.html#v:request">request</a></code> method.</p><p>Convenience functions like <code><a href="Yesod-Test.html#v:get">get</a></code> and <code><a href="Yesod-Test.html#v:post">post</a></code> build and execute common requests.</p></div><div class="top"><p class="src"><a name="v:get" class="def">get</a> :: (<a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site, <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#t:RedirectUrl">RedirectUrl</a> site url) =&gt; url -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#get" class="link">Source</a></p><div class="doc"><p>Perform a GET request to <code>url</code>.</p><h4 id="control.ch:get0" class="caption collapser" onclick="toggleSection('ch:get0')">Examples</h4><div id="section.ch:get0" class="hide"><pre>get HomeR</pre><pre>get (&quot;http://google.com&quot; :: Text)</pre></div></div></div><div class="top"><p class="src"><a name="v:post" class="def">post</a> :: (<a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site, <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#t:RedirectUrl">RedirectUrl</a> site url) =&gt; url -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#post" class="link">Source</a></p><div class="doc"><p>Perform a POST request to <code>url</code>.</p><h4 id="control.ch:post0" class="caption collapser" onclick="toggleSection('ch:post0')">Examples</h4><div id="section.ch:post0" class="hide"><pre>post HomeR</pre></div></div></div><div class="top"><p class="src"><a name="v:postBody" class="def">postBody</a> :: (<a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site, <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#t:RedirectUrl">RedirectUrl</a> site url) =&gt; url -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#postBody" class="link">Source</a></p><div class="doc"><p>Perform a POST request to <code>url</code> with the given body.</p><h4 id="control.ch:postBody0" class="caption collapser" onclick="toggleSection('ch:postBody0')">Examples</h4><div id="section.ch:postBody0" class="hide"><pre>postBody HomeR &quot;foobar&quot;</pre><pre>import Data.Aeson
postBody HomeR (encode $ object [&quot;age&quot; .= (1 :: Integer)])</pre></div></div></div><div class="top"><p class="src"><a name="v:request" class="def">request</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site =&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#request" class="link">Source</a></p><div class="doc"><p>The general interface for performing requests. <code><a href="Yesod-Test.html#v:request">request</a></code> takes a <code><a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a></code>,
 constructs a request, and executes it.</p><p>The <code><a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a></code> allows you to build up attributes of the request, like the
 headers, parameters, and URL of the request.</p><h4 id="control.ch:request0" class="caption collapser" onclick="toggleSection('ch:request0')">Examples</h4><div id="section.ch:request0" class="hide"><pre>request $ do
  addToken
  byLabel &quot;First Name&quot; &quot;Felipe&quot;
  setMethod &quot;PUT&quot;
  setUrl NameR</pre></div></div></div><div class="top"><p class="src"><a name="v:addRequestHeader" class="def">addRequestHeader</a> :: <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Header.html#t:Header">Header</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () <a href="src/Yesod-Test.html#addRequestHeader" class="link">Source</a></p><div class="doc"><p>Adds the given header to the request; see <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Header.html">Network.HTTP.Types.Header</a> for creating <code><a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Types.html#t:Header">Header</a></code>s.</p><h4 id="control.ch:addRequestHeader0" class="caption collapser" onclick="toggleSection('ch:addRequestHeader0')">Examples</h4><div id="section.ch:addRequestHeader0" class="hide"><pre>import Network.HTTP.Types.Header
request $ do
  addRequestHeader (hUserAgent, &quot;Chrome/41.0.2228.0&quot;)</pre></div></div></div><div class="top"><p class="src"><a name="v:setMethod" class="def">setMethod</a> :: <a href="file:///usr/share/doc/libghc-http-types-doc/html/Network-HTTP-Types-Method.html#t:Method">Method</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () <a href="src/Yesod-Test.html#setMethod" class="link">Source</a></p><div class="doc"><p>Sets the HTTP method used by the request.</p><h4 id="control.ch:setMethod0" class="caption collapser" onclick="toggleSection('ch:setMethod0')">Examples</h4><div id="section.ch:setMethod0" class="hide"><pre>request $ do
  setMethod &quot;POST&quot;</pre><pre>import Network.HTTP.Types.Method
request $ do
  setMethod methodPut</pre></div></div></div><div class="top"><p class="src"><a name="v:addPostParam" class="def">addPostParam</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () <a href="src/Yesod-Test.html#addPostParam" class="link">Source</a></p><div class="doc"><p>Add a parameter with the given name and value to the request body.</p></div></div><div class="top"><p class="src"><a name="v:addGetParam" class="def">addGetParam</a> :: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () <a href="src/Yesod-Test.html#addGetParam" class="link">Source</a></p><div class="doc"><p>Add a parameter with the given name and value to the query string.</p></div></div><div class="top"><p class="src"><a name="v:addFile" class="def">addFile</a> <a href="src/Yesod-Test.html#addFile" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></td><td class="doc"><p>The parameter name for the file.</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The path to the file.</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></td><td class="doc"><p>The MIME type of the file, e.g. &quot;image/png&quot;.</p></td></tr><tr><td class="src">-&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Add a file to be posted with the current request.</p><p>Adding a file will automatically change your request content-type to be multipart/form-data.</p><h4 id="control.ch:addFile0" class="caption collapser" onclick="toggleSection('ch:addFile0')">Examples</h4><div id="section.ch:addFile0" class="hide"><pre>request $ do
  addFile &quot;profile_picture&quot; &quot;static/img/picture.png&quot; &quot;img/png&quot;</pre></div></div></div><div class="top"><p class="src"><a name="v:setRequestBody" class="def">setRequestBody</a> :: <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () <a href="src/Yesod-Test.html#setRequestBody" class="link">Source</a></p><div class="doc"><p>Simple way to set HTTP request body</p><h4 id="control.ch:setRequestBody0" class="caption collapser" onclick="toggleSection('ch:setRequestBody0')"> Examples</h4><div id="section.ch:setRequestBody0" class="hide"><pre>request $ do
  setRequestBody &quot;foobar&quot;</pre><pre>import Data.Aeson
request $ do
  setRequestBody $ encode $ object [&quot;age&quot; .= (1 :: Integer)]</pre></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:RequestBuilder" class="def">RequestBuilder</a> site = <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-State-Lazy.html#t:StateT">StateT</a> (RequestBuilderData site) <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:IO">IO</a> <a href="src/Yesod-Test.html#RequestBuilder" class="link">Source</a></p><div class="doc"><p>The <code><a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a></code> state monad constructs a URL encoded string of arguments
 to send with your requests. Some of the functions that run on it use the current
 response to analyze the forms that the server is expecting to receive.</p></div></div><div class="top"><p class="src"><a name="v:setUrl" class="def">setUrl</a> :: (<a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html#t:Yesod">Yesod</a> site, <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#t:RedirectUrl">RedirectUrl</a> site url) =&gt; url -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () <a href="src/Yesod-Test.html#setUrl" class="link">Source</a></p><div class="doc"><p>Sets the URL used by the request.</p><h4 id="control.ch:setUrl0" class="caption collapser" onclick="toggleSection('ch:setUrl0')">Examples</h4><div id="section.ch:setUrl0" class="hide"><pre>request $ do
  setUrl HomeR</pre><pre>request $ do
  setUrl (&quot;http://google.com/&quot; :: Text)</pre></div></div></div><h3 id="g:3">Adding fields by label</h3><div class="doc"><p>Yesod can auto generate field names, so you are never sure what
 the argument name should be for each one of your inputs when constructing
 your requests. What you do know is the <em>label</em> of the field.
 These functions let you add parameters to your request based
 on currently displayed label names.</p></div><div class="top"><p class="src"><a name="v:byLabel" class="def">byLabel</a> <a href="src/Yesod-Test.html#byLabel" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></td><td class="doc"><p>The text contained in the <code>&lt;label&gt;</code>.</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></td><td class="doc"><p>The value to set the parameter to.</p></td></tr><tr><td class="src">-&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Finds the <code>&lt;label&gt;</code> with the given value, finds its corresponding <code>&lt;input&gt;</code>, then adds a parameter
 for that input to the request body.</p><h4 id="control.ch:byLabel0" class="caption collapser" onclick="toggleSection('ch:byLabel0')">Examples</h4><div id="section.ch:byLabel0" class="hide"><p>Given this HTML, we want to submit <code>f1=Michael</code> to the server:</p><pre>&lt;form method=&quot;POST&quot;&gt;
  &lt;label for=&quot;user&quot;&gt;Username&lt;/label&gt;
  &lt;input id=&quot;user&quot; name=&quot;f1&quot; /&gt;
&lt;/form&gt;</pre><p>You can set this parameter like so:</p><pre>request $ do
  byLabel &quot;Username&quot; &quot;Michael&quot;</pre><p>This function also supports the implicit label syntax, in which
 the <code>&lt;input&gt;</code> is nested inside the <code>&lt;label&gt;</code> rather than specified with <code>for</code>:</p><pre>&lt;form method=&quot;POST&quot;&gt;
  &lt;label&gt;Username &lt;input name=&quot;f1&quot;&gt; &lt;/label&gt;
&lt;/form&gt;</pre></div></div></div><div class="top"><p class="src"><a name="v:fileByLabel" class="def">fileByLabel</a> <a href="src/Yesod-Test.html#fileByLabel" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></td><td class="doc"><p>The text contained in the <code>&lt;label&gt;</code>.</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>The path to the file.</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/libghc-text-doc/html/Data-Text.html#t:Text">Text</a></td><td class="doc"><p>The MIME type of the file, e.g. &quot;image/png&quot;.</p></td></tr><tr><td class="src">-&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Finds the <code>&lt;label&gt;</code> with the given value, finds its corresponding <code>&lt;input&gt;</code>, then adds a file for that input to the request body.</p><h4 id="control.ch:fileByLabel0" class="caption collapser" onclick="toggleSection('ch:fileByLabel0')">Examples</h4><div id="section.ch:fileByLabel0" class="hide"><p>Given this HTML, we want to submit a file with the parameter name <code>f1</code> to the server:</p><pre>&lt;form method=&quot;POST&quot;&gt;
  &lt;label for=&quot;imageInput&quot;&gt;Please submit an image&lt;/label&gt;
  &lt;input id=&quot;imageInput&quot; type=&quot;file&quot; name=&quot;f1&quot; accept=&quot;image/*&quot;&gt;
&lt;/form&gt;</pre><p>You can set this parameter like so:</p><pre>request $ do
  fileByLabel &quot;Please submit an image&quot; &quot;static/img/picture.png&quot; &quot;img/png&quot;</pre><p>This function also supports the implicit label syntax, in which
 the <code>&lt;input&gt;</code> is nested inside the <code>&lt;label&gt;</code> rather than specified with <code>for</code>:</p><pre>&lt;form method=&quot;POST&quot;&gt;
  &lt;label&gt;Please submit an image &lt;input type=&quot;file&quot; name=&quot;f1&quot;&gt; &lt;/label&gt;
&lt;/form&gt;</pre></div></div></div><h3 id="g:4">CSRF Tokens</h3><div class="doc"><p>In order to prevent CSRF exploits, yesod-form adds a hidden input
 to your forms with the name &quot;_token&quot;. This token is a randomly generated,
 per-session value.</p><p>In order to prevent your forms from being rejected in tests, use one of
 these functions to add the token to your request.</p></div><div class="top"><p class="src"><a name="v:addToken" class="def">addToken</a> :: <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () <a href="src/Yesod-Test.html#addToken" class="link">Source</a></p><div class="doc"><p>For responses that display a single form, just lookup the only CSRF token available.</p><h4 id="control.ch:addToken0" class="caption collapser" onclick="toggleSection('ch:addToken0')">Examples</h4><div id="section.ch:addToken0" class="hide"><pre>request $ do
  addToken</pre></div></div></div><div class="top"><p class="src"><a name="v:addToken_" class="def">addToken_</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () <a href="src/Yesod-Test.html#addToken_" class="link">Source</a></p><div class="doc"><p>Lookups the hidden input named &quot;_token&quot; and adds its value to the params.
 Receives a CSS selector that should resolve to the form element containing the token.</p><h4 id="control.ch:addToken_0" class="caption collapser" onclick="toggleSection('ch:addToken_0')">Examples</h4><div id="section.ch:addToken_0" class="hide"><pre>request $ do
  addToken_ &quot;#formID&quot;</pre></div></div></div><div class="top"><p class="src"><a name="v:addTokenFromCookie" class="def">addTokenFromCookie</a> :: <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site () <a href="src/Yesod-Test.html#addTokenFromCookie" class="link">Source</a></p><div class="doc"><p>Calls <code><a href="Yesod-Test.html#v:addTokenFromCookieNamedToHeaderNamed">addTokenFromCookieNamedToHeaderNamed</a></code> with the <code><a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#v:defaultCsrfCookieName">defaultCsrfCookieName</a></code> and <code><a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html#v:defaultCsrfHeaderName">defaultCsrfHeaderName</a></code>.</p><p>Use this function if you're using the CSRF middleware from <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html">Yesod.Core</a> and haven't customized the cookie or header name.</p><h4 id="control.ch:addTokenFromCookie0" class="caption collapser" onclick="toggleSection('ch:addTokenFromCookie0')">Examples</h4><div id="section.ch:addTokenFromCookie0" class="hide"><pre>request $ do
  addTokenFromCookie</pre><p>Since 1.4.3.2</p></div></div></div><div class="top"><p class="src"><a name="v:addTokenFromCookieNamedToHeaderNamed" class="def">addTokenFromCookieNamedToHeaderNamed</a> <a href="src/Yesod-Test.html#addTokenFromCookieNamedToHeaderNamed" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a></td><td class="doc"><p>The name of the cookie</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/share/doc/libghc-case-insensitive-doc/html/Data-CaseInsensitive.html#t:CI">CI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a></td><td class="doc"><p>The name of the header</p></td></tr><tr><td class="src">-&gt; <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site ()</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Looks up the CSRF token stored in the cookie with the given name and adds it to the request headers. An error is thrown if the cookie can't be found.</p><p>Use this function if you're using the CSRF middleware from <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core.html">Yesod.Core</a> and have customized the cookie or header name.</p><p>See <a href="file:///usr/share/doc/libghc-yesod-core-doc/html/Yesod-Core-Handler.html">Yesod.Core.Handler</a> for details on this approach to CSRF protection.</p><h4 id="control.ch:addTokenFromCookieNamedToHeaderNamed0" class="caption collapser" onclick="toggleSection('ch:addTokenFromCookieNamedToHeaderNamed0')">Examples</h4><div id="section.ch:addTokenFromCookieNamedToHeaderNamed0" class="hide"><pre>import Data.CaseInsensitive (CI)
request $ do
  addTokenFromCookieNamedToHeaderNamed &quot;cookieName&quot; (CI &quot;headerName&quot;)</pre><p>Since 1.4.3.2</p></div></div></div><h1 id="g:5">Assertions</h1><div class="top"><p class="src"><a name="v:assertEqual" class="def">assertEqual</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Eq.html#t:Eq">Eq</a> a =&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; a -&gt; a -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#assertEqual" class="link">Source</a></p><div class="doc"><p>Asserts that the two given values are equal.</p></div></div><div class="top"><p class="src"><a name="v:assertHeader" class="def">assertHeader</a> :: <a href="file:///usr/share/doc/libghc-case-insensitive-doc/html/Data-CaseInsensitive.html#t:CI">CI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#assertHeader" class="link">Source</a></p><div class="doc"><p>Assert the given header key/value pair was returned.</p></div></div><div class="top"><p class="src"><a name="v:assertNoHeader" class="def">assertNoHeader</a> :: <a href="file:///usr/share/doc/libghc-case-insensitive-doc/html/Data-CaseInsensitive.html#t:CI">CI</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.6.0/Data-ByteString.html#t:ByteString">ByteString</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#assertNoHeader" class="link">Source</a></p><div class="doc"><p>Assert the given header was not included in the response.</p></div></div><div class="top"><p class="src"><a name="v:statusIs" class="def">statusIs</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#statusIs" class="link">Source</a></p><div class="doc"><p>Assert the last response status is as expected.</p></div></div><div class="top"><p class="src"><a name="v:bodyEquals" class="def">bodyEquals</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#bodyEquals" class="link">Source</a></p><div class="doc"><p>Assert the last response is exactly equal to the given text. This is
 useful for testing API responses.</p></div></div><div class="top"><p class="src"><a name="v:bodyContains" class="def">bodyContains</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#bodyContains" class="link">Source</a></p><div class="doc"><p>Assert the last response has the given text. The check is performed using the response
 body in full text form.</p></div></div><div class="top"><p class="src"><a name="v:htmlAllContain" class="def">htmlAllContain</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#htmlAllContain" class="link">Source</a></p><div class="doc"><p>Queries the HTML using a CSS selector, and all matched elements must contain
 the given string.</p></div></div><div class="top"><p class="src"><a name="v:htmlAnyContain" class="def">htmlAnyContain</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#htmlAnyContain" class="link">Source</a></p><div class="doc"><p>Queries the HTML using a CSS selector, and passes if any matched
 element contains the given string.</p><p>Since 0.3.5</p></div></div><div class="top"><p class="src"><a name="v:htmlNoneContain" class="def">htmlNoneContain</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-String.html#t:String">String</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#htmlNoneContain" class="link">Source</a></p><div class="doc"><p>Queries the HTML using a CSS selector, and fails if any matched
 element contains the given string (in other words, it is the logical
 inverse of htmlAnyContains).</p><p>Since 1.2.2</p></div></div><div class="top"><p class="src"><a name="v:htmlCount" class="def">htmlCount</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Int.html#t:Int">Int</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#htmlCount" class="link">Source</a></p><div class="doc"><p>Performs a CSS query on the last response and asserts the matched elements
 are as many as expected.</p></div></div><h1 id="g:6">Grab information</h1><div class="top"><p class="src"><a name="v:getTestYesod" class="def">getTestYesod</a> :: <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site site <a href="src/Yesod-Test.html#getTestYesod" class="link">Source</a></p><div class="doc"><p>Get the foundation value used for the current test.</p><p>Since 1.2.0</p></div></div><div class="top"><p class="src"><a name="v:getResponse" class="def">getResponse</a> :: <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/share/doc/libghc-wai-extra-doc/html/Network-Wai-Test.html#t:SResponse">SResponse</a>) <a href="src/Yesod-Test.html#getResponse" class="link">Source</a></p><div class="doc"><p>Get the most recently provided response value, if available.</p><p>Since 1.2.0</p></div></div><div class="top"><p class="src"><a name="v:getRequestCookies" class="def">getRequestCookies</a> :: <a href="Yesod-Test.html#t:RequestBuilder">RequestBuilder</a> site Cookies <a href="src/Yesod-Test.html#getRequestCookies" class="link">Source</a></p><div class="doc"><p>Returns the <code>Cookies</code> from the most recent request. If a request hasn't been made, an error is raised.</p><h4 id="control.ch:getRequestCookies0" class="caption collapser" onclick="toggleSection('ch:getRequestCookies0')">Examples</h4><div id="section.ch:getRequestCookies0" class="hide"><pre>request $ do
  cookies &lt;- getRequestCookies
  liftIO $ putStrLn $ &quot;Cookies are: &quot; ++ show cookies</pre><p>Since 1.4.3.2</p></div></div></div><h1 id="g:7">Debug output</h1><div class="top"><p class="src"><a name="v:printBody" class="def">printBody</a> :: <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#printBody" class="link">Source</a></p><div class="doc"><p>Outputs the last response body to stderr (So it doesn't get captured by HSpec)</p></div></div><div class="top"><p class="src"><a name="v:printMatches" class="def">printMatches</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site () <a href="src/Yesod-Test.html#printMatches" class="link">Source</a></p><div class="doc"><p>Performs a CSS query and print the matches to stderr.</p></div></div><h1 id="g:8">Utils for building your own assertions</h1><div class="doc"><p>Please consider generalizing and contributing the assertions you write.</p></div><div class="top"><p class="src"><a name="v:htmlQuery" class="def">htmlQuery</a> :: <a href="Yesod-Test-TransversingCSS.html#t:Query">Query</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site [<a href="Yesod-Test-TransversingCSS.html#t:HtmlLBS">HtmlLBS</a>] <a href="src/Yesod-Test.html#htmlQuery" class="link">Source</a></p><div class="doc"><p>Query the last response using CSS selectors, returns a list of matched fragments</p></div></div><div class="top"><p class="src"><a name="v:parseHTML" class="def">parseHTML</a> :: <a href="Yesod-Test-TransversingCSS.html#t:HtmlLBS">HtmlLBS</a> -&gt; <a href="file:///usr/share/doc/libghc-xml-conduit-doc/html/Text-XML-Cursor.html#t:Cursor">Cursor</a> <a href="src/Yesod-Test.html#parseHTML" class="link">Source</a></p><div class="doc"><p>Use HXT to parse a value from an HTML tag.
 Check for usage examples in this module's source.</p></div></div><div class="top"><p class="src"><a name="v:withResponse" class="def">withResponse</a> :: (<a href="file:///usr/share/doc/libghc-wai-extra-doc/html/Network-Wai-Test.html#t:SResponse">SResponse</a> -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site a) -&gt; <a href="Yesod-Test.html#t:YesodExample">YesodExample</a> site a <a href="src/Yesod-Test.html#withResponse" class="link">Source</a></p><div class="doc"><p>Performs a given action using the last response. Use this to create
 response-level assertions</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>