-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Experimental Hspec support for testing WAI applications
--   
--   Experimental Hspec support for testing WAI applications
@package hspec-wai
@version 0.11.1

module Test.Hspec.Wai.Matcher
data ResponseMatcher
ResponseMatcher :: Int -> [MatchHeader] -> MatchBody -> ResponseMatcher
[matchStatus] :: ResponseMatcher -> Int
[matchHeaders] :: ResponseMatcher -> [MatchHeader]
[matchBody] :: ResponseMatcher -> MatchBody
data MatchHeader
MatchHeader :: ([Header] -> Body -> Maybe String) -> MatchHeader
data MatchBody
MatchBody :: ([Header] -> Body -> Maybe String) -> MatchBody
type Body = ByteString
(<:>) :: HeaderName -> ByteString -> MatchHeader
bodyEquals :: Body -> MatchBody
match :: SResponse -> ResponseMatcher -> Maybe String
formatHeader :: Header -> String
instance GHC.Internal.Data.String.IsString Test.Hspec.Wai.Matcher.MatchBody
instance GHC.Internal.Data.String.IsString Test.Hspec.Wai.Matcher.ResponseMatcher
instance GHC.Internal.Num.Num Test.Hspec.Wai.Matcher.ResponseMatcher

module Test.Hspec.Wai.Internal

-- | An expectation in the <a>WaiSession</a> monad. Failing expectations
--   are communicated through exceptions (similar to <a>Expectation</a> and
--   <a>Assertion</a>).
type WaiExpectation st = WaiSession st ()

-- | A <a>WAI</a> test session that carries the <a>Application</a> under
--   test and some client state.
newtype WaiSession st a
WaiSession :: ReaderT st Session a -> WaiSession st a
[unWaiSession] :: WaiSession st a -> ReaderT st Session a
runWaiSession :: WaiSession () a -> Application -> IO a
runWithState :: WaiSession st a -> (st, Application) -> IO a
withApplication :: Application -> WaiSession () a -> IO a
getApp :: WaiSession st Application
getState :: WaiSession st st
formatHeader :: Header -> String
instance GHC.Internal.Base.Applicative (Test.Hspec.Wai.Internal.WaiSession st)
instance Test.Hspec.Core.Example.Example (Test.Hspec.Wai.Internal.WaiExpectation st)
instance GHC.Internal.Base.Functor (Test.Hspec.Wai.Internal.WaiSession st)
instance GHC.Internal.Control.Monad.Fail.MonadFail (Test.Hspec.Wai.Internal.WaiSession st)
instance Control.Monad.IO.Class.MonadIO (Test.Hspec.Wai.Internal.WaiSession st)
instance GHC.Internal.Base.Monad (Test.Hspec.Wai.Internal.WaiSession st)

module Test.Hspec.Wai.QuickCheck
property :: Testable a => a -> (State a, Application) -> Property
(==>) :: Testable prop => Bool -> prop -> WaiProperty (State prop)
infixr 0 ==>
class Arbitrary a
arbitrary :: Arbitrary a => Gen a
shrink :: Arbitrary a => a -> [a]
newtype Gen a
MkGen :: (QCGen -> Int -> a) -> Gen a
[unGen] :: Gen a -> QCGen -> Int -> a
variant :: Integral n => n -> Gen a -> Gen a
sized :: (Int -> Gen a) -> Gen a
getSize :: Gen Int
resize :: HasCallStack => Int -> Gen a -> Gen a
scale :: (Int -> Int) -> Gen a -> Gen a
choose :: Random a => (a, a) -> Gen a
chooseAny :: Random a => Gen a
chooseEnum :: Enum a => (a, a) -> Gen a
chooseInt :: (Int, Int) -> Gen Int
chooseBoundedIntegral :: (Bounded a, Integral a) => (a, a) -> Gen a
chooseInteger :: (Integer, Integer) -> Gen Integer
chooseWord64 :: (Word64, Word64) -> Gen Word64
chooseInt64 :: (Int64, Int64) -> Gen Int64
chooseUpTo :: Word64 -> Gen Word64
generate :: Gen a -> IO a
sample' :: Gen a -> IO [a]
sample :: Show a => Gen a -> IO ()
genDouble :: Gen Double
genFloat :: Gen Float
suchThat :: Gen a -> (a -> Bool) -> Gen a
suchThatMap :: Gen a -> (a -> Maybe b) -> Gen b
suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a)
oneof :: HasCallStack => [Gen a] -> Gen a
frequency :: HasCallStack => [(Int, Gen a)] -> Gen a
elements :: HasCallStack => [a] -> Gen a
sublistOf :: [a] -> Gen [a]
shuffle :: [a] -> Gen [a]
growingElements :: HasCallStack => [a] -> Gen a
listOf :: Gen a -> Gen [a]
listOf1 :: Gen a -> Gen [a]
vectorOf :: Int -> Gen a -> Gen [a]
infiniteListOf :: Gen a -> Gen [a]
class Testable a where {
    type State a;
}
toProperty :: Testable a => a -> WaiProperty (State a)
data WaiProperty st
WaiProperty :: ((st, Application) -> Property) -> WaiProperty st
[unWaiProperty] :: WaiProperty st -> (st, Application) -> Property
instance (Test.QuickCheck.Arbitrary.Arbitrary a, GHC.Internal.Show.Show a, Test.Hspec.Wai.QuickCheck.Testable prop) => Test.Hspec.Wai.QuickCheck.Testable (a -> prop)
instance Test.Hspec.Wai.QuickCheck.Testable (Test.Hspec.Wai.QuickCheck.WaiProperty st)
instance Test.Hspec.Wai.QuickCheck.Testable (Test.Hspec.Wai.Internal.WaiExpectation st)


-- | Have a look at the <a>README</a> for an example of how to use this
--   library.
module Test.Hspec.Wai

-- | A <a>WAI</a> test session that carries the <a>Application</a> under
--   test and some client state.
data WaiSession st a

-- | An expectation in the <a>WaiSession</a> monad. Failing expectations
--   are communicated through exceptions (similar to <a>Expectation</a> and
--   <a>Assertion</a>).
type WaiExpectation st = WaiSession st ()

-- | Perform a <tt>GET</tt> request to the application under test.
get :: ByteString -> WaiSession st SResponse

-- | Perform a <tt>POST</tt> request to the application under test.
post :: ByteString -> ByteString -> WaiSession st SResponse

-- | Perform a <tt>PUT</tt> request to the application under test.
put :: ByteString -> ByteString -> WaiSession st SResponse

-- | Perform a <tt>PATCH</tt> request to the application under test.
patch :: ByteString -> ByteString -> WaiSession st SResponse

-- | Perform an <tt>OPTIONS</tt> request to the application under test.
options :: ByteString -> WaiSession st SResponse

-- | Perform a <tt>DELETE</tt> request to the application under test.
delete :: ByteString -> WaiSession st SResponse

-- | Perform a request to the application under test, with specified HTTP
--   method, request path, headers and body.
request :: Method -> ByteString -> [Header] -> ByteString -> WaiSession st SResponse

-- | Perform a <tt>POST</tt> request to the application under test.
--   
--   The specified list of key-value pairs is encoded as
--   <tt>application/x-www-form-urlencoded</tt> and used as request body.
--   
--   In addition the <tt>Content-Type</tt> is set to
--   <tt>application/x-www-form-urlencoded</tt>.
postHtmlForm :: ByteString -> [(String, String)] -> WaiSession st SResponse

-- | Set the expectation that a response matches a specified
--   <a>ResponseMatcher</a>.
--   
--   A <tt>ResponseMatcher</tt> matches a response if:
--   
--   <ul>
--   <li>the specified status matches the HTTP response status code</li>
--   <li>the specified body (if any) matches the response body</li>
--   <li>the response has all of the specified <a>Header</a> fields (the
--   response may have arbitrary additional <a>Header</a> fields)</li>
--   </ul>
--   
--   You can use <tt>ResponseMatcher</tt>'s (broken) <a>Num</a> instance to
--   match for a HTTP status code:
--   
--   <pre>
--   get "/" `shouldRespondWith` 200
--   -- matches if status is 200
--   </pre>
--   
--   You can use <tt>ResponseMatcher</tt>'s <tt>IsString</tt> instance to
--   match for a HTTP status <tt>200</tt> and a body:
--   
--   <pre>
--   get "/" `shouldRespondWith` "foo"
--   -- matches if body is "foo" and status is 200
--   </pre>
--   
--   If you want to match for a different HTTP status, you can use record
--   update notation to specify <a>matchStatus</a> explicitly:
--   
--   <pre>
--   get "/" `shouldRespondWith` "foo" {matchStatus = 404}
--   -- matches if body is "foo" and status is 404
--   </pre>
--   
--   If you want to require a specific header field you can specify
--   <a>matchHeaders</a>:
--   
--   <pre>
--   get "/" `shouldRespondWith` "foo" {matchHeaders = ["Content-Type" &lt;:&gt; "text/plain"]}
--   -- matches if body is "foo", status is 200 and there is a header field "Content-Type: text/plain"
--   </pre>
shouldRespondWith :: HasCallStack => WaiSession st SResponse -> ResponseMatcher -> WaiExpectation st
data ResponseMatcher
ResponseMatcher :: Int -> [MatchHeader] -> MatchBody -> ResponseMatcher
[matchStatus] :: ResponseMatcher -> Int
[matchHeaders] :: ResponseMatcher -> [MatchHeader]
[matchBody] :: ResponseMatcher -> MatchBody
data MatchHeader
MatchHeader :: ([Header] -> Body -> Maybe String) -> MatchHeader
data MatchBody
MatchBody :: ([Header] -> Body -> Maybe String) -> MatchBody
type Body = ByteString
(<:>) :: HeaderName -> ByteString -> MatchHeader

-- | Lift a computation from the <a>IO</a> monad. This allows us to run IO
--   computations in any monadic stack, so long as it supports these kinds
--   of operations (i.e. <a>IO</a> is the base monad for the stack).
--   
--   <h3><b>Example</b></h3>
--   
--   <pre>
--   import Control.Monad.Trans.State -- from the "transformers" library
--   
--   printState :: Show s =&gt; StateT s IO ()
--   printState = do
--     state &lt;- get
--     liftIO $ print state
--   </pre>
--   
--   Had we omitted <tt><a>liftIO</a></tt>, we would have ended up with
--   this error:
--   
--   <pre>
--   • Couldn't match type ‘IO’ with ‘StateT s IO’
--    Expected type: StateT s IO ()
--      Actual type: IO ()
--   </pre>
--   
--   The important part here is the mismatch between <tt>StateT s IO
--   ()</tt> and <tt><a>IO</a> ()</tt>.
--   
--   Luckily, we know of a function that takes an <tt><a>IO</a> a</tt> and
--   returns an <tt>(m a)</tt>: <tt><a>liftIO</a></tt>, enabling us to run
--   the program and see the expected results:
--   
--   <pre>
--   &gt; evalStateT printState "hello"
--   "hello"
--   
--   &gt; evalStateT printState 3
--   3
--   </pre>
liftIO :: MonadIO m => IO a -> m a
with :: IO Application -> SpecWith ((), Application) -> Spec
withState :: IO (st, Application) -> SpecWith (st, Application) -> Spec
getState :: WaiSession st st

-- | A lifted version of <a>pending</a>.
pending :: WaiSession st ()

-- | A lifted version of <a>pendingWith</a>.
pendingWith :: String -> WaiSession st ()
