Skip to content

Commit bbb4481

Browse files
authored
Merge pull request #7 from codewars/rename-to-new-formatter
2 parents c2efafc + 786b61a commit bbb4481

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ Specify `codewars` formatter:
88

99
```haskell
1010
-- test/Main.hs
11-
module Main where
11+
module Main (main) where
1212

1313
import Test.Hspec.Runner
14-
import Test.Hspec.Formatters.Codewars (codewars)
14+
import Test.Hspec.Formatters.Codewars (newFormatter)
15+
import Test.Hspec.Core.Formatters.V2 (formatterToFormat)
1516

1617
import qualified Spec
1718

1819
main :: IO ()
19-
main = hspecWith defaultConfig {configFormatter = Just codewars} Spec.spec
20+
main = do
21+
codewars <- newFormatter
22+
runSpec Spec.spec defaultConfig {configFormat = Just $ formatterToFormat codewars}
23+
>>= evaluateSummary
2024
```
2125

2226
```haskell

src/Test/Hspec/Formatters/Codewars.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# LANGUAGE OverloadedStrings #-}
22

3-
module Test.Hspec.Formatters.Codewars (codewars, escapeLF) where
3+
module Test.Hspec.Formatters.Codewars (newFormatter, escapeLF) where
44

55
import Data.Text (pack, replace, unpack)
66
import Text.Printf (printf)
@@ -23,8 +23,8 @@ import Test.Hspec.Core.Formatters.V2 (
2323
getName :: Path -> String
2424
getName (_, req) = escapeLF req
2525

26-
codewars :: IO Formatter
27-
codewars = do
26+
newFormatter :: IO Formatter
27+
newFormatter = do
2828
times <- newIORef ([ ]::[Seconds])
2929
pure $ silent
3030
{

test/Main.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ module Main (main) where
33
import System.Exit
44

55
import Test.Hspec.Runner
6-
import Test.Hspec.Formatters.Codewars (codewars, escapeLF)
6+
import Test.Hspec.Formatters.Codewars (newFormatter, escapeLF)
77
import Test.Hspec.Core.Formatters.V2 (formatterToFormat, formatException)
88
import Test.Hspec.Core.Util (safeTry)
99

1010
import qualified Spec
1111

1212
main :: IO ()
1313
main = do
14-
formatter <- codewars
15-
summary <- safeTry $ runSpec Spec.spec defaultConfig {configFormat = Just $ formatterToFormat formatter}
14+
codewars <- newFormatter
15+
summary <- safeTry $ runSpec Spec.spec defaultConfig {configFormat = Just $ formatterToFormat codewars}
1616
case summary of
1717
Left ex -> do
1818
putStrLn $ "\n<ERROR::>Test suite crashed<:LF:>" ++ (escapeLF $ formatException ex)

0 commit comments

Comments
 (0)