hspec-expectations-match

An hspec expectation that asserts a value matches a pattern. https://github.com/cjdev/hspec-expectations-match#readme

Latest on Hackage:0.2.0.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

ISC licensed and maintained by Alexis King

hspec-expectations-match Build Status

hspec-expectations-match is a Haskell package that provides expectations for use with hspec that use Template Haskell to assert that a value matches a particular pattern. The primary expectation is shouldMatch:

{-# LANGUAGE TemplateHaskell #-}

ghci> $([|Just True|] `shouldMatch` [p|Just _|])
ghci> $([|Nothing|] `shouldMatch` [p|Just _|])
*** Exception: Nothing failed to match pattern (Just x)

Additionally, any bindings created by the pattern will be returned if the pattern is successfully matched, making it easier to extract the result of some assertion and use it to make further assertions.

ghci> $([|Just True|] `shouldMatch` [p|Just x|])
True
ghci> $([|[1, 2]|] `shouldMatch` [p|[x, y]|])
(1, 2)

For more information, see the documentation on Hackage.

Changes

0.2.0.0 (November 17th, 2017)

  • Added assertDo, which automatically instruments a do block with uses of shouldReturnAndMatch.

0.1.1.0 (November 15th, 2017)

  • Added shouldReturnAndMatch, which combines the action-running behavior of shouldReturn with the pattern-matching behavior of shouldMatch.
  • Added a missing HasCallStack constraint to properly provide source location information for failed expectations.

0.1.0.0 (November 15th, 2017)

  • Initial release.
comments powered byDisqus