deve-dingus contém um matcher personalizado para que você pode usar should_dsl com Dingus chama.
Um pequeno aviso: A | corte operador de should_dsl de realmente não vão bem com o __ __or () de um Dingus. Eu acho que a | corte é desagradável, e eu não sei se gosto should_dsl para ele. Este é o lugar onde o Ruby parece realmente bonito para mim.
Você só precisa importá-lo
>>> From importação should_dsl deveria, should_not
>>> From dingus importação Dingus
>>> should_dingus importação
chamada
Verifica insta a Dingus
>>> Stub = Dingus ('stub')
>>> Def some_function ():
... Stub ()
...
>>> Some_function | deve | chamada (stub)
chamada também pode verificar que ele deve ser chamado uma vez:
>>> Def some_function ():
... Stub ()
... Stub ()
...
>>> Stub.reset ()
>>> Some_function | deve | chamada (stub)
>>> Stub.reset ()
>>> Some_function | deve | chamada (stub) .Uma vez
Traceback (most recent call last):
...
ShouldNotSatisfied:
chamar pode até mesmo verificar os parâmetros com with_params:
>>> Def some_function ():
... Stub (True, kwak = 'tuut', Braat = 'AAP')
...
>>> Stub.reset ()
>>> Some_function | deve | chamadas (stub) .with_params (True, kwak = 'tuut', Braat = 'AAP')
>>> Stub.reset ()
>>> Some_function | deve | chamadas (stub) .with_params (True, kwak = 'tuut')
Traceback (most recent call last):
...
ShouldNotSatisfied:
with_params de chamadas podem ser combinados com uma só vez:
>>> Def some_function ():
... Stub (True, kwak = 'tuut', Braat = 'AAP')
...
>>> Stub.reset ()
>>> Some_function | deve | chamadas (stub) .once.with_params (True, kwak = 'tuut', Braat = 'AAP')
>>> Stub.reset ()
>>> Some_function | deve | chamadas (stub) .with_params (True, kwak = 'tuut', Braat = "AAP") uma vez
Requisitos :.
- Python
Comentários não encontrado