{"id":16195940,"url":"https://github.com/pheymann/specdris","last_synced_at":"2026-01-20T20:33:47.945Z","repository":{"id":126852942,"uuid":"96308956","full_name":"pheymann/specdris","owner":"pheymann","description":"A test framework for Idris","archived":false,"fork":false,"pushed_at":"2019-03-21T08:23:25.000Z","size":62,"stargazers_count":54,"open_issues_count":1,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T16:43:17.879Z","etag":null,"topics":["idris","idris-ecosystem","test-framework","testing","unit-testing","unittest"],"latest_commit_sha":null,"homepage":null,"language":"Idris","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pheymann.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-05T10:47:43.000Z","updated_at":"2025-01-23T20:12:24.000Z","dependencies_parsed_at":"2023-06-18T08:00:10.327Z","dependency_job_id":null,"html_url":"https://github.com/pheymann/specdris","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/pheymann/specdris","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pheymann%2Fspecdris","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pheymann%2Fspecdris/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pheymann%2Fspecdris/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pheymann%2Fspecdris/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pheymann","download_url":"https://codeload.github.com/pheymann/specdris/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pheymann%2Fspecdris/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28612976,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T18:56:40.769Z","status":"ssl_error","status_checked_at":"2026-01-20T18:54:26.653Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["idris","idris-ecosystem","test-framework","testing","unit-testing","unittest"],"created_at":"2024-10-10T08:46:06.338Z","updated_at":"2026-01-20T20:33:47.930Z","avatar_url":"https://github.com/pheymann.png","language":"Idris","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/pheymann/specdris.svg?branch=master)](https://travis-ci.org/pheymann/specdris)\n\n# specdris\nWith this framework you can write spec-like **Unit Tests** in Idris:\n\n```Idris\nimport Specdris.Spec\n\nmain : IO ()\nmain = spec $ do\n  describe \"This is my math test\" $ do\n    it \"adds two natural numbers\" $ do\n      (1 + 1) `shouldBe` 2\n    it \"multiplies two natural numbers\" $ do\n      (2 * 2) `shouldBe` 3\n    it \"do fancy stuff with complex numbers\" $ do\n      pendingWith \"do this later\"\n```\nYou can also nest `describe`. When executed this spec it will produce the following output:\n\n```\nThis is my math test\n  + adds two natural numbers\n  + multiplies two natural numbers\n    [x] not equal --red\n        actual:   4\n        expected: 3\n  + do fancy stuff with complex numbers\n    [] pending: do this later -- yellow\n    \nFailed: Total = 3, Failed = 1, Pending = 1 -- red\n```\n\nYou can also test your `IO` code:\n\n```Idris\nimport Specdris.SpecIO\n\nmain : IO ()\nmain = specIO $ do\n  describe \"This is my side effect test\" $ do\n    it \"say my name\" $ do\n      name \u003c- loadName\n      \n      pure $ name `shouldBe` \"Foo\"\n```\n\nYou can find more information about `SpecIO` [here](#specio).\n\nBoth `spec` and `specIO` have backend-agnostic versions, respectively `spec'`\nand `specIO'`, that use `IO'` rather than `IO`.\n\n## Install\nThis testing framework is written with `Idris 1.0`.\n\nClone the repo from github with `git clone https://github.com/pheymann/specdris.git` and run:\n\n```\ncd specdris\n./project --install\n\n# under windows\n.\\Project.ps1 --install\n```\n\n### elba\nIf you use [elba](https://github.com/elba/elba) to manage your Idris packages,\nyou can also add specdris as a dev-dependency to be run during tests. Just add\nthe following to the `[dev_dependencies]` section of your package's\n`elba.toml` manifest:\n\n```toml\n[dev_dependencies]\n# snip\n\"pheymann/specdris\" = { git = \"https://github.com/pheymann/specdris\" }\n```\n\nThen you'll be able to use specdris from all test targets.\n\n## Documentation\n### Expectations\nCurrently this framework provides you with:\n\n|Expectation|Alias|Description|\n|----------|-----|-----------|\n|`a shouldBe b`|`===`|is `a` equal to `b`|\n|`a shouldNotBe b`|`/==`|is `a` unequal to `b`|\n|`a shouldBeTrue`| |is `a` `True`|\n|`a shouldBeFalse` | | is `a` `False`|\n|`a shouldSatisfy pred`| | satisfies `a` a given predicate|\n|`a shouldBeJust exp` | | if `a` is `Just a'` apply `exp` to `a'`; here `exp` is again a sequence of expectations |\n\n### Failed Test Cases\nIf an expectations in a test case failes the following expectations aren't executed and the\nwhole case is marked as failure:\n\n```Idris\n  it \"failing test\" $ do\n    1 `shouldBe` 1 -- success\n    2 `shouldBe` 1 -- failes\n    2 `shouldBe` 2 -- will not be executed\n```\n\n### SpecIO\nBesides the usual test cases you can also add effects as:\n\n#### BeforeAll\nExecutes an `IO ()` before running any test case:\n\n```Idris\nspecIO {beforeAll = putStrLn \"hello\"} $ do ...\n```\n\n#### AfterAll\nExecutes an `IO ()` after all test cases are executed:\n\n```Idris\nspecIO {afterAll = putStrLn \"bye\"} $ do ...\n```\n\n#### Around\nTakes a function `IO SpecResult -\u003e IO SpecResult` which can be used to execute `IO` code\nbefore and after every test case:\n\n```Idris\naround : IO SpecResult -\u003e IO SpecResult\naround resultIO = do putStrLn \"hello\"\n                     result \u003c- resultIO\n                     putStrLn \"bye\"\n                     \n                     pure result\n\nspecIO {around = around} $ do\n```\n\n### Shuffle/Randomise Test Case Execution\nYou can randomise your test case execution by applying `shuffle` to your spec:\n\n```Idris\nmySpec : SpecTree\nmySpec = \n  describe \"my test\"\n    it \"a\" $ 1 === 1\n    it \"b\" $ 2 === 2\n\n-- default seed\nspec $ shuffle mySpec\n\n-- static seed\nspec $ shuffle mySpec 1000\n\n-- current time\ndo seed \u003c- System.time\n   spec $ shuffle mySpec seed\n```\n\n`shuffle` only changes execution order for tests (`it`) under a `decribe` and thus preserves the logical test structure.\n\n### Creating your own Expectations\nIf you need other expections than these provided [here](https://github.com/pheymann/specdris/blob/master/src/Specdris/Expectations.idr) \nyou can implement them as follows:\n\n```Idris\nshouldParse: (Show a, Eq, a) =\u003e Parser -\u003e (actual : String) -\u003e (expected : a) -\u003e SpecResult\nshouldParse: parser actual expected \n  = case parser actual of\n      (Right result) =\u003e result === expected\n      (Left err)     =\u003e UnaryFailure actual $ \"couldn't parse: \" ++ err\n```\n\n### Working with SpecState\nIt is possible to get the [SpecState](https://github.com/pheymann/specdris/blob/master/src/Specdris/Data/SpecState.idr#L8-L16)\nrecord of a spec after its execution by using `specWithState` from *Spec* or *SpecIO*.\n\n#### Storing Console Output in SpecState\nIf you want to process the output after spec execution you can store it in [SpecState](https://github.com/pheymann/specdris/blob/master/src/Specdris/Data/SpecState.idr#L8-L16)\nby setting `spec {storeOutput = True}` or `specIO {storeOutput = True}`. This also stops *specdris* from printing\nit to the console.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpheymann%2Fspecdris","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpheymann%2Fspecdris","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpheymann%2Fspecdris/lists"}