hspec-golden-aeson-0.3.0.0: Use tests to monitor changes in Aeson serialization

Copyright(c) Plow Technologies 2016
LicenseBSD3
Maintainermchaver@gmail.com
StabilityBeta
Safe HaskellNone
LanguageHaskell2010

Test.Aeson.Internal.GoldenSpecs

Description

Internal module, use at your own risk.

Synopsis

Documentation

goldenSpecs :: (Typeable a, Arbitrary a, ToJSON a, FromJSON a) => Settings -> Proxy a -> Spec Source #

Tests to ensure that JSON encoding has not unintentionally changed. This could be caused by the following:

  • A type's instances of ToJSON or FromJSON have changed.
  • Selectors have been edited, added or deleted.
  • You have changed version of Aeson the way Aeson serialization has changed works.

If you run this function and the golden files do not exist, it will create them for each constructor. It they do exist, it will compare with golden file if it exists. Golden file encodes json format of a type. It is recommended that you put the golden files under revision control to help monitor changes.

goldenSpecsWithNote :: forall a. (Typeable a, Arbitrary a, ToJSON a, FromJSON a) => Settings -> Proxy a -> Maybe String -> Spec Source #

same as goldenSpecs but has the option of passing a note to the describe function.

goldenSpecsWithNotePlain :: forall a. (Arbitrary a, ToJSON a, FromJSON a) => Settings -> TypeNameInfo a -> Maybe String -> Spec Source #

same as goldenSpecsWithNote but does not require a Typeable, Eq or Show instance.

compareWithGolden :: forall a. (Arbitrary a, ToJSON a, FromJSON a) => TypeNameInfo a -> Proxy a -> FilePath -> ComparisonFile -> IO () Source #

The golden files already exist. Serialize values with the same seed from the golden file and compare the with the JSON in the golden file.

createGoldenfile :: forall a. (Arbitrary a, ToJSON a) => Settings -> Proxy a -> FilePath -> IO () Source #

The golden files do not exist. Create it.

mkGoldenFile :: TypeNameInfo a -> FilePath Source #

Create the file path for the golden file. Optionally use the module name to help avoid name collissions. Different modules can have types of the same name.

mkFaultyFile :: TypeNameInfo a -> FilePath Source #

Create the file path to save results from a failed golden test. Optionally use the module name to help avoid name collisions. Different modules can have types of the same name.

mkRandomSamples :: forall a. Arbitrary a => Int -> Proxy a -> Int -> IO (RandomSamples a) Source #

Create a number of arbitrary instances of a type a sample size and a random seed.