{"id":17185368,"url":"https://github.com/purcell/mockr","last_synced_at":"2026-02-25T23:33:06.799Z","repository":{"id":396567,"uuid":"14609","full_name":"purcell/mockr","owner":"purcell","description":"Tiny Ruby mock object library inspired by JMock","archived":false,"fork":false,"pushed_at":"2024-11-07T07:08:11.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-13T06:42:58.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://dev.sanityinc.com/mockr","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purcell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2008-05-05T08:06:41.000Z","updated_at":"2024-11-07T07:08:15.000Z","dependencies_parsed_at":"2024-12-07T06:17:54.653Z","dependency_job_id":null,"html_url":"https://github.com/purcell/mockr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/purcell/mockr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purcell%2Fmockr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purcell%2Fmockr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purcell%2Fmockr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purcell%2Fmockr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purcell","download_url":"https://codeload.github.com/purcell/mockr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purcell%2Fmockr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29844875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T22:37:40.667Z","status":"ssl_error","status_checked_at":"2026-02-25T22:37:25.960Z","response_time":61,"last_error":"SSL_read: 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":[],"created_at":"2024-10-15T00:46:25.199Z","updated_at":"2026-02-25T23:33:06.783Z","avatar_url":"https://github.com/purcell.png","language":"Ruby","funding_links":["https://www.patreon.com/sanityinc"],"categories":[],"sub_categories":[],"readme":"# Mockr\n\nMockr is a pure Ruby library to support the Mock Objects approach to\nunit testing, and is inspired by Java's JMock.\n\nSeveral other Mock Object libraries exist for Ruby. In addition to its\nunusually natural syntax for setting expectations, Mockr has two main\ndistinguishing features:\n\n1. Support for the distinction between mocking and stubbing\n2. A constraint-based mechanism for matching call parameters\n\nMockR was initially presented by author Steve Purcell at the\n2005 European Ruby Conference, and was written entirely test-first.\n\nFor more information or to contact the author, see\nhttps://github.com/mockr\n\n## Introduction\n\nAn instance of `Mockr::Mock` can be programmed with responses to\nmethods calls expected during the course of a unit test.  At the\nend of the test, the instance can verify whether its expectations\nwere met, signalling a test failure if they were not.\n\nMocks distinguish between 'expected' method calls, which trigger\ntest failures if they are not made, and 'stub' method calls, which\nare not verified.  'Expected' calls are typically those considered\ncritical to the proper use of the mocked class, and 'stub' calls are\nthose considered more flexible in their use.\n\n## Example\n\nThe following is an example of a set of tests written entirely using MockR\n\n```ruby\nrequire 'test/unit'\nrequire 'mockr'\n\n\nclass BurglarAlarmTest \u003c Test::Unit::TestCase\n  include Mockr::TestCaseHelpers\n\n  def setup\n    @laser_grid, @police_link = new_mock, new_mock\n    @alarm = BurglarAlarm.new(@laser_grid.proxy, @police_link.proxy)\n  end\n\n  def test_police_station_not_contacted_if_grid_okay\n    @laser_grid.expects.intact?.as { true }\n    @alarm.check\n  end\n\n  def test_police_station_is_contacted_if_grid_not_okay\n    @laser_grid.expects.intact?.as { false }\n    @police_link.expects.incident(\"Grid breached\")\n    @alarm.check\n  end\n\n  def test_police_station_warned_if_grid_down\n    @laser_grid.expects.intact?.as { raise IOError.new(\"comms down\") }\n    @police_link.expects.warning(/down/)   # A loose parameter constraint\n    @alarm.check\n  end\n\nend\n```\n\nThese tests would be satisfied by the following class:\n\n```ruby\n## Collaborates with a LaserGrid and a PoliceStationUplink\nclass BurglarAlarm\n  def initialize(laser_grid, police_link)\n    @laser_grid = laser_grid\n    @police_link = police_link\n  end\n\n  def check\n    begin\n      @police_link.incident(\"Grid breached\") unless @laser_grid.intact?\n    rescue\n      @police_link.warning(\"Grid down\")\n    end\n  end\nend\n```\n\n## Resources\n\n* [Home page](https://github.com/purcell/mockr)\n\n## Copyright\n\nCopyright (c) 2005-2006 Steve Purcell.\n\n## Licence\n\nMockR is distributed under the same terms as Ruby itself.\n\n\u003chr\u003e\n\n[💝 Support this project and my other Open Source work](https://www.patreon.com/sanityinc)\n\n[💼 LinkedIn profile](https://uk.linkedin.com/in/stevepurcell)\n\n[✍ sanityinc.com](http://www.sanityinc.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurcell%2Fmockr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurcell%2Fmockr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurcell%2Fmockr/lists"}