{"id":13483879,"url":"https://github.com/emancu/crotest","last_synced_at":"2025-05-12T20:53:53.908Z","repository":{"id":6110187,"uuid":"54094545","full_name":"emancu/crotest","owner":"emancu","description":"A tiny and simple test framework for crystal","archived":false,"fork":false,"pushed_at":"2022-01-10T17:40:47.000Z","size":36,"stargazers_count":28,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-15T09:11:32.589Z","etag":null,"topics":["assertions","crystal","crystal-lang","test-driven-development","testing","testing-framework"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/emancu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-17T06:34:59.000Z","updated_at":"2024-07-19T06:34:19.000Z","dependencies_parsed_at":"2022-08-06T19:15:16.195Z","dependency_job_id":null,"html_url":"https://github.com/emancu/crotest","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emancu%2Fcrotest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emancu%2Fcrotest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emancu%2Fcrotest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emancu%2Fcrotest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emancu","download_url":"https://codeload.github.com/emancu/crotest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246576054,"owners_count":20799448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["assertions","crystal","crystal-lang","test-driven-development","testing","testing-framework"],"created_at":"2024-07-31T17:01:16.386Z","updated_at":"2025-04-01T10:32:28.126Z","avatar_url":"https://github.com/emancu.png","language":"Crystal","funding_links":[],"categories":["Testing"],"sub_categories":[],"readme":"# crotest\n[![Build](https://github.com/emancu/crotest/actions/workflows/crystal.yml/badge.svg)](https://github.com/emancu/crotest/actions/workflows/crystal.yml)\n\nA tiny and simple test framework for Crystal with common assertions and no pollution into `Object` class.\n\n## Example\n\n```crystal\nrequire \"crotest\"\n\ndescribe \"DSL\" do\n  it \"defines small test cases\" do\n    assert true\n  end\n\n  describe \"nested describes for a better readability\" do\n    it \"has only a few assertions\" do\n      var = false\n\n      reject var\n      assert_equal false, var\n      assert_raise Exception do\n        raise Exception.new(\"Boom!\")\n      end\n    end\n  end\n\n  pending \"tests are defined without a block\"\n\n  pending \"tests can also be defined with a block, which will not be executed\" do\n    fail \"This won't be executed :)\"\n  end\nend\n```\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  crotest:\n    github: emancu/crotest\n```\n\n## Usage\n\n```crystal\nrequire \"crotest\"\n```\n\nRun your tests with `crystal spec`.\n\n### Assertions\n\n- `assert`\n- `reject`\n- `assert_equal`\n- `assert_raise`\n\n### Custom assertions\n\nExtend the assertions used by `Crotest` is really easy.\nYou need to open the module `Crotest::Assertions` and add your assertions like the example below:\n\n\n```crystal\nrequire \"crotest\"\n\nmodule Crotest::Assertions\n  macro assert_greater_than_4(value, file = __FILE__, line = __LINE__)\n    assert {{value}} \u003e 4, \"#{{{value}}} \u003c= 4\", {{file}}, {{line}}\n  end\nend\n\n\nit \"supports my custom assertion\" do\n  assert_greater_than_4 5\nend\n```\n\n### Before/After blocks\n\nIf you need to run code _before_ or _after_ each test, declare each block like in the example below.\nRemember to define `before/after` blocks before the corresponding `it` blocks.\nGiven this is not dynamically evaluated, we must define at the beginning of the file or `describe` block.\n\n```crystal\nbefore do\n  # First block to be executed\nend\n\nafter do\n  # Fifth and last block to be executed\nend\n\ndescribe \"a nested context\" do\n  before do\n    # Second block to be executed\n  end\n\n  after do\n    # Fourth block to be executed\n  end\n\n  it \"executes the before blocks and\" do\n    # Third block to be executed\n  end\nend\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/emancu/crotest/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [emancu](https://github.com/emancu) Emiliano Mancuso - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femancu%2Fcrotest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femancu%2Fcrotest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femancu%2Fcrotest/lists"}