{"action":"opened","issue":{"url":"https://api.github.com/repos/jackfirth/racket-mock/issues/8","labels_url":"https://api.github.com/repos/jackfirth/racket-mock/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/jackfirth/racket-mock/issues/8/comments","events_url":"https://api.github.com/repos/jackfirth/racket-mock/issues/8/events","html_url":"https://github.com/jackfirth/racket-mock/issues/8","id":102589054,"number":8,"title":"Add support for test stubbing","user":{"login":"jackfirth","id":8175575,"avatar_url":"https://avatars.githubusercontent.com/u/8175575?v=3","gravatar_id":"","url":"https://api.github.com/users/jackfirth","html_url":"https://github.com/jackfirth","followers_url":"https://api.github.com/users/jackfirth/followers","following_url":"https://api.github.com/users/jackfirth/following{/other_user}","gists_url":"https://api.github.com/users/jackfirth/gists{/gist_id}","starred_url":"https://api.github.com/users/jackfirth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackfirth/subscriptions","organizations_url":"https://api.github.com/users/jackfirth/orgs","repos_url":"https://api.github.com/users/jackfirth/repos","events_url":"https://api.github.com/users/jackfirth/events{/privacy}","received_events_url":"https://api.github.com/users/jackfirth/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-23T05:21:30Z","updated_at":"2015-08-23T05:21:30Z","closed_at":null,"body":"When using mocks to write code in a TDD fashion that depends on code not yet existing, like this:\n\n```racket\n(define/mock (retrieve-admin-users)\n  ([retrieve-all-users (const-mock '(a b c))]\n   [filter-admin-users (case-mock '(a b c) '(a c))])\n  (filter-admin-users (retrieve-all-users)))\n\n(module+ test\n  (check-equal? (retrieve-admin-users) '(a c)))\n```\n\nThis implementation requires `retrieve-admin-users` and `filter-admin-users` both exist for testing, despite their implementations being mocked out. It would be nice to alleviate that problem by writing something like this:\n\n```\n(stub retrieve-all-users)\n(stub filter-admin-users)\n```\n\nWhich just defines each as `#f` or a function that throws an exception when you try to use it. This is also useful for \"contract first development\" where you export a function with it's contract before implementing it. In this case, the stub macro would need some information about what kind of fake function or value to use in order to ensure the value satisfies the contract's first-order properties."}}