hspec-golden-aeson-0.4.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.ADT.GoldenSpecs

Description

Internal module, use at your own risk.

Synopsis

Documentation

goldenADTSpecs :: forall a. (ToADTArbitrary a, Eq a, Show 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.

goldenADTSpecsWithNote :: forall a. (ToADTArbitrary a, Eq a, Show a, ToJSON a, FromJSON a) => Settings -> Proxy a -> Maybe String -> Spec Source #

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

testConstructor :: forall a. (Eq a, Show a, FromJSON a, ToJSON a, ToADTArbitrary a) => Settings -> String -> String -> ConstructorArbitraryPair a -> SpecWith (Arg (IO ())) Source #

test a single set of values from a constructor for a given type.

compareWithGolden :: forall a. (Show a, Eq a, FromJSON a, ToJSON a, ToADTArbitrary a) => String -> Maybe String -> String -> ConstructorArbitraryPair a -> FilePath -> IO () Source #

The golden files already exist. Serialize values with the same seed from the golden files of each constructor and compare.

createGoldenFile :: forall a. (ToJSON a, ToADTArbitrary a) => Int -> ConstructorArbitraryPair a -> FilePath -> IO () Source #

The golden files do not exist. Create them for each constructor.

mkGoldenFilePath :: forall a. FilePath -> Maybe FilePath -> FilePath -> ConstructorArbitraryPair 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.

mkFaultyFilePath :: forall a. FilePath -> Maybe FilePath -> FilePath -> ConstructorArbitraryPair 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.

mkRandomADTSamplesForConstructor :: forall a. ToADTArbitrary a => Int -> Proxy a -> String -> Int -> IO (RandomSamples a) Source #

Create a number of arbitrary instances of a particular constructor given a sample size and a random seed.

mkGoldenFileForType :: forall a. (ToJSON a, ToADTArbitrary a) => Int -> Proxy a -> FilePath -> IO () Source #

Make a Golden File for the Proxy of a type if the file does not exist.