{"id":15685157,"url":"https://github.com/pat/not-a-mock","last_synced_at":"2025-05-07T16:22:34.955Z","repository":{"id":394481,"uuid":"12418","full_name":"pat/not-a-mock","owner":"pat","description":"A cleaner and DRYer alternative to mocking and stubbing with RSpec.","archived":false,"fork":false,"pushed_at":"2015-11-15T13:01:58.000Z","size":231,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T11:51:11.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://notahat.com/not_a_mock","language":"Ruby","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/pat.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2008-04-25T07:47:19.000Z","updated_at":"2019-08-13T13:23:33.000Z","dependencies_parsed_at":"2022-07-04T14:00:45.869Z","dependency_job_id":null,"html_url":"https://github.com/pat/not-a-mock","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/pat%2Fnot-a-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pat%2Fnot-a-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pat%2Fnot-a-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pat%2Fnot-a-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pat","download_url":"https://codeload.github.com/pat/not-a-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252913190,"owners_count":21824116,"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":[],"created_at":"2024-10-03T17:24:05.379Z","updated_at":"2025-05-07T16:22:34.932Z","avatar_url":"https://github.com/pat.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Not A Mock\n\nA cleaner and DRYer alternative to mocking and stubbing with RSpec.\n\nhttps://github.com/notahat/not_a_mock\n\n== A Quick Introduction\n\n=== Mocking (Not)\n\nWhen you're setting up for a spec, you can ask that method calls on an object be recorded:\n\n  object.track_methods(:name, :length)\n  \nOnce your code has run, you can make assertions about what methods were called, what arguments\nthey took, their results, etc.\n\n  object.should have_received(:length).without_args.and_returned(42)\n  object.should have_received(:name).twice\n  \nSee NotAMock::Matchers for an explanation of the available assertions, plus\nObject#track_methods and Object#untrack_methods.\n  \n=== Stubbing\n\n==== Stubbing Methods\n\nYou can replace a method on an object with a stub version like this:\n\n  object.stub_method(:method =\u003e return_value)\n  \nAny call to +method+ after this will return +return_value+ without invoking\nthe method's usual code.\n  \nCalls to stub methods are recorded as if you had called +track_methods+\non them, so you can make assertions about them as shown above.\n  \nSee Object#stub_methods, Object#unstub_methods.\n\n==== Stubbing Objects\n\nYou can also replace an entire object with a stub version like this:\n\n  my_object = MyClass.stub_instance(:method_a =\u003e return_value, :method_b =\u003e return_value, ...)\n\nThe returned +my_object+ is a stub instance of MyClass with the given methods\ndefined to provide the corresponding return values.\n  \nSee Object.stub_instance.\n\n==== Stubbing ActiveRecord Instances\n\nWhen you call +stub_instance+ on an ActiveRecord::Base subclass,\nNot A Mock automatically provides an +id+ method and generates an\nid for the object.\n\n== Installation\n\n(The following describes using NotAMock with Rails. It should also be possible\nto use it outside of Rails, but I haven't tried it.)\n\nFirst, install the rspec and rspec_on_rails plugins, then install the not_a_mock plugin:\n\n  ruby script/plugin install http://github.com/notahat/not_a_mock.git\n\nFinally, add the following to your project's spec/spec_helper.rb:\n\n  config.mock_with NotAMock::RspecMockFrameworkAdapter\n\n== Contributing\n\nSend bugs, patches, and suggestions to Pete Yandell (pete@notahat.com)\n\nThanks to Pat Allan and Steve Hayes for contributing patches.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpat%2Fnot-a-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpat%2Fnot-a-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpat%2Fnot-a-mock/lists"}