A few more expectations
First of all - thanks for Hspec, it's great! Really useful both in and out of work.
I've got a few small helper expectations (e.g. shouldExceed, shouldInclude, shouldExist) that increasingly I / we're using to help with descriptive failures (and extra readable tests especially for beginners).
Is this codebase taking PRs, or would you prefer these be published elsewhere / kept private?
@declension Sorry for the late reply!
I'm somewhat conservative with adding stuff to Test.Hspec.Expectations, however, we can add stuff to Test.Hspec.Expectations.Contrib and move them to Test.Hspec.Expectations if they proof useful.
If you want to create a separate package, say hspec-extras or something, then that's fine too, of course.
BTW, I would like to see the type signatures of shouldExceed, shouldInclude, shouldExist, if possible.
Great, thanks @sol and no worries!
I'm more than happy with the Contrib proposal. I'm not a Haskell expert, so am happy to take suggestions here.
Anyway I've dug out some of that code and will try to tidy a bit. Here are some ideas
shouldExceed :: (HasCallStack, Show a, Ord a) => a -> a -> Expectation
shouldExceed = shouldBeGreaterThan
shouldBeGreaterThan :: (HasCallStack, Show a, Ord a) => a -> a -> Expectation
shouldBeLessThan :: (HasCallStack, Show a, Ord a) => a -> a -> Expectation
Updated version of showInclude to be less monomorphic to Lists... but not sure what to think about Show (t a) but it's nice to have the actual container shown (as with the list expectations)...
shouldInclude :: (HasCallStack, Show a, Eq a, Foldable t, Show (t a))
=> t a
-> a
-> Expectation
Debatable if this one is useful, but can produce nicer error messages, and sometimes you don't want to specify the Just foo result
shouldExist :: (HasCallStack, Show a) => String -> Maybe a -> Expectation
@sol should I push a PR to see some code?