{"id":13503170,"url":"https://github.com/afshinm/morq","last_synced_at":"2025-03-26T08:30:33.284Z","repository":{"id":57640337,"uuid":"106439249","full_name":"afshinm/morq","owner":"afshinm","description":"BDD/TDD assertion interface","archived":false,"fork":false,"pushed_at":"2017-11-25T12:31:31.000Z","size":48,"stargazers_count":83,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-07T23:35:15.180Z","etag":null,"topics":["rust","unit-testing"],"latest_commit_sha":null,"homepage":"http://morq.rs","language":"Rust","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/afshinm.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":"2017-10-10T15:58:14.000Z","updated_at":"2024-02-19T15:01:20.000Z","dependencies_parsed_at":"2022-09-05T05:31:59.317Z","dependency_job_id":null,"html_url":"https://github.com/afshinm/morq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afshinm%2Fmorq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afshinm%2Fmorq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afshinm%2Fmorq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afshinm%2Fmorq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afshinm","download_url":"https://codeload.github.com/afshinm/morq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222131009,"owners_count":16936304,"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":["rust","unit-testing"],"created_at":"2024-07-31T22:02:39.858Z","updated_at":"2024-10-29T23:16:55.396Z","avatar_url":"https://github.com/afshinm.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# morq \u003ca href=\"https://crates.io/crates/morq\"\u003e\u003cimg src='https://img.shields.io/crates/v/morq.svg'\u003e\u003c/a\u003e [![Build Status](https://travis-ci.com/afshinm/morq.svg?token=ACapzCFmBh92g8rnRsrq\u0026branch=master)](https://travis-ci.com/afshinm/morq)\n\nWrite unit tests like humans\n\n\n\u003cimg src=\"http://clipart-library.com/images/qcBAnE68i.png\" width=\"200\" /\u003e\n\n## Install\n\n```\ncargo install morq\n```\n\nMorq Crate: https://crates.io/crates/morq\n\n## Grammar\n\nSince we are using a macro here, you need to wrap the following rules in `morq!` macro.\n\nExample:  \n\n```rust\nmorq!(\n  expect(3).to.be.an(i32);\n);\n```\n\n### Chains\n\nYou use following chains to make the assertions more user friendly and readable.\n\n - to\n - be\n - have\n\n### Equal\n\n```rust\nexpect(30).to.be.equal(10 * 3);\nexpect(3).to.be.equal(1 + 2);\n```\n\n### Close\n\nTo compare two given `float` values\n\n```rust\nexpect(3f32).to.be.close(3.0001f32);\nexpect(3f32).to.be.close_to(3.0001f32);\n```\n\n### Not\n\nNegates the chain.\n\n\n```rust\nexpect(30).to.not.be.equal(10);\nexpect(3).to.not.be.equal(1);\nexpect(vec![1, 2, 3]).to.not.be.a(Vec\u003cchar\u003e);\n```\n\n### A / An\n\nTo check the data type.\n\n```rust\nexpect(30).to.be.an(i32);\nexpect(\"hola\".to_string()).to.not.be.a(f32);\nexpect(vec![1, 2, 3]).to.be.a(Vec\u003ci32\u003e);\n```\n\n### Empty\n\nTo check and see if the iterator is empty or not\n\n```rust\nexpect(vec![1, 2, 3]).to.not.be.empty();\nexpect(0..2).to.not.be.empty();\n```\n\n### LengthOf\n\nTo check the count of elements in an iterator\n\n```rust\nexpect(vec![1, 2, 3]).to.not.have.length_of(1usize);\nexpect(0..3).to.have.length_of(3usize);\n```\n\n### Contain\n\nGiven iterator must contain the element\n\n```rust\nexpect(vec![1, 2, 3]).to.contain(2);\nexpect(vec![false, false]).to.not.contain(true);\n```\n\n### Ok / Err\n\nTo check a Result enum\n\n```rust\nlet res: Result\u003cString, String\u003e = Ok(format!(\"boo\"));\n\nmorq!(\n    expect(res).to.be.ok();\n);\n```\n\n```rust\nlet res: Result\u003cString, String\u003e = Err(format!(\"boo\"));\n\nmorq!(\n    expect(res).to.be.err();\n);\n```\n\nOf course, you can combine it with `not`:\n\n\n```rust\nlet res: Result\u003cString, String\u003e = Err(format!(\"boo\"));\n\nmorq!(\n    expect(res).to.not.be.ok();\n);\n```\n\n## Roadmap\n\n- Adding more chain rules\n- Adding more assert (terminal) \n- Ability to add two or more asserts in one chain:\n\n  ```rust\n  expect(\"hello\").to.be.equal(\"hello\").and.not.be.a(i32);\n  ```\n\n## FAQ\n\n### morq?\n\nMeans chicken in Farsi. Like a lazy chicken, you know.  \n\nArtwork: clipart-library.com\n\n### Author\n\nAfshin Mehrabani\n\n### License\n\nMIT\n\nInspired by http://chaijs.com and https://github.com/carllerche/hamcrest-rust\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafshinm%2Fmorq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafshinm%2Fmorq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafshinm%2Fmorq/lists"}