{"id":20748205,"url":"https://github.com/iredelmeier/pseudo","last_synced_at":"2025-04-28T12:04:05.728Z","repository":{"id":41675119,"uuid":"86017151","full_name":"iredelmeier/pseudo","owner":"iredelmeier","description":"A small mocking library for Rust","archived":false,"fork":false,"pushed_at":"2018-08-26T21:50:01.000Z","size":15,"stargazers_count":14,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T12:04:00.247Z","etag":null,"topics":["mock-library","rust","testing"],"latest_commit_sha":null,"homepage":"","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/iredelmeier.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-03-24T02:08:53.000Z","updated_at":"2023-07-07T15:10:25.000Z","dependencies_parsed_at":"2022-09-11T08:20:58.942Z","dependency_job_id":null,"html_url":"https://github.com/iredelmeier/pseudo","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iredelmeier%2Fpseudo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iredelmeier%2Fpseudo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iredelmeier%2Fpseudo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iredelmeier%2Fpseudo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iredelmeier","download_url":"https://codeload.github.com/iredelmeier/pseudo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251311332,"owners_count":21569009,"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":["mock-library","rust","testing"],"created_at":"2024-11-17T08:15:54.959Z","updated_at":"2025-04-28T12:04:05.710Z","avatar_url":"https://github.com/iredelmeier.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pseudo\n\n### A small mocking library for Rust.\n\n[![Crates.io Version](https://img.shields.io/crates/v/pseudo.svg)](https://crates.io/crates/pseudo) [![Docs](https://docs.rs/pseudo/badge.svg)](https://docs.rs/pseudo) [![Build Status](https://travis-ci.org/iredelmeier/pseudo.svg?branch=master)](https://travis-ci.org/iredelmeier/pseudo)\n\nPseudo lets you mock `Trait` implementations so that you can track function call arguments and set return values or overrides functions at test time.\n\nHere's a quick example:\n\n```rust\nextern crate pseudo;\n\nuse pseudo::Mock;\n\ntrait Foo: Clone {\n    fn expensive_fn(\u0026self, x: i64, y: i64) -\u003e i64;\n}\n\n#[derive(Clone)]\nstruct MockFoo {\n    pub expensive_fn: Mock\u003c(i64, i64), i64\u003e,\n}\n\nimpl Foo for MockFoo {\n    fn expensive_fn(\u0026self, x: i64, y: i64) -\u003e i64 {\n        self.expensive_fn.call((x + 10, y))\n    }\n}\n\nfn double_expensive_fn\u003cT: Foo\u003e(foo: \u0026T, x: i64, y: i64) -\u003e i64 {\n    foo.expensive_fn(x, y) * 2\n}\n\n#[test]\nfn doubles_return_value() {\n    let mock = MockFoo { expensive_fn: Mock::default() };\n\n    mock.expensive_fn.return_value(1000);\n\n    assert_eq!(double_expensive_fn(\u0026mock, 1, 2), 2000);\n}\n\n#[test]\nfn uses_correct_args() {\n    let mock = MockFoo { expensive_fn: Mock::default() };\n\n    assert!(!mock.expensive_fn.called());\n\n    double_expensive_fn(\u0026mock, 1, 2);\n\n    assert_eq!(mock.expensive_fn.num_calls(), 1);\n    assert!(mock.expensive_fn.called_with((11, 2)));\n}\n```\n\nMore examples are available in the [examples directory](./examples).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firedelmeier%2Fpseudo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firedelmeier%2Fpseudo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firedelmeier%2Fpseudo/lists"}