From 8e7b296e820e7513c7846ceeb3fbd87d60bc95f4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Mar 2014 13:12:33 -0400 Subject: split out Property.FIle --- Property/File.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Property/File.hs (limited to 'Property/File.hs') diff --git a/Property/File.hs b/Property/File.hs new file mode 100644 index 00000000..a4b21961 --- /dev/null +++ b/Property/File.hs @@ -0,0 +1,22 @@ +module Property.File where + +import Property + +{- Replaces all the content of a file. -} +hasContent :: FilePath -> [Line] -> Property +f `hasContent` newcontent = FileProperty ("replace " ++ f) + f (\_oldcontent -> newcontent) + +{- Ensures that a line is present in a file, adding it to the end if not. -} +containsLine :: FilePath -> Line -> Property +f `containsLine` l = FileProperty (f ++ " contains:" ++ l) f go + where + go ls + | l `elem` ls = ls + | otherwise = ls++[l] + +{- Ensures that a line is not present in a file. + - Note that the file is ensured to exist, so if it doesn't, an empty + - file will be written. -} +lacksLine :: FilePath -> Line -> Property +f `lacksLine` l = FileProperty (f ++ " remove: " ++ l) f (filter (/= l)) -- cgit v1.3-2-g0d8e