method-0.1.0.0: rebindable methods for improving testability
LicenseBSD-3
Maintainerautotaker@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Test.Method.Mock

Description

DSL to generate mock methods.

Synopsis

Documentation

type Mock method = Writer (MockSpec method) () Source #

data MockSpec method Source #

Instances

Instances details
Semigroup (MockSpec method) Source # 
Instance details

Defined in Test.Method.Mock

Methods

(<>) :: MockSpec method -> MockSpec method -> MockSpec method #

sconcat :: NonEmpty (MockSpec method) -> MockSpec method #

stimes :: Integral b => b -> MockSpec method -> MockSpec method #

Monoid (MockSpec method) Source # 
Instance details

Defined in Test.Method.Mock

Methods

mempty :: MockSpec method #

mappend :: MockSpec method -> MockSpec method -> MockSpec method #

mconcat :: [MockSpec method] -> MockSpec method #

mockup :: (Method method, MonadThrow (Base method)) => Mock method -> method Source #

generate a method from Mock DSL. Mock DSL consists of rules. On a call of generated method, the first rule matched the arguments is applied.

thenReturn :: (Method method, Applicative (Base method)) => Matcher (Args method) -> Ret method -> Mock method Source #

matcher `thenReturn` value means the method return value if the arguments matches matcher.

thenAction :: Method method => Matcher (Args method) -> Base method (Ret method) -> Mock method Source #

matcher `thenAction` action means the method executes action if the arguments matches matcher.

thenMethod :: Method method => Matcher (Args method) -> method -> Mock method Source #

matcher `thenMethod` action means the method call method with the arguments if the arguments matches matcher.

throwNoStubShow :: (Method method, Show (AsTuple (Args method)), MonadThrow (Base method), TupleLike (Args method)) => Matcher (Args method) -> Mock method Source #

throwNoStubShow matcher means the method throws a NoStubException if the arguments matches matcher. The argument tuple is converted to String by using show function.

throwNoStub :: (Method method, MonadThrow (Base method)) => (Args method -> String) -> (Args method -> Bool) -> Mock method Source #

throwNoStubShow fshow matcher means the method throws a NoStubException if the arguments matches matcher. The argument tuple is converted to String by using fshow function.