{"id":13521240,"url":"https://github.com/danp/resque-mock","last_synced_at":"2025-08-01T16:34:04.021Z","repository":{"id":56891997,"uuid":"1907939","full_name":"danp/resque-mock","owner":"danp","description":"Resque mocking without redis","archived":false,"fork":false,"pushed_at":"2012-11-16T14:34:05.000Z","size":94,"stargazers_count":13,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-28T14:23:41.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/danp.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":"2011-06-16T21:08:35.000Z","updated_at":"2022-03-05T14:02:15.000Z","dependencies_parsed_at":"2022-08-21T00:20:51.060Z","dependency_job_id":null,"html_url":"https://github.com/danp/resque-mock","commit_stats":null,"previous_names":["dpiddy/resque-mock"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danp%2Fresque-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danp%2Fresque-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danp%2Fresque-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danp%2Fresque-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danp","download_url":"https://codeload.github.com/danp/resque-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228393610,"owners_count":17912864,"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-08-01T06:00:31.334Z","updated_at":"2024-12-06T00:43:09.749Z","avatar_url":"https://github.com/danp.png","language":"Ruby","funding_links":[],"categories":["Mocks"],"sub_categories":[],"readme":"# resque-mock\n\nIn memory mocks for running resque without redis in test mode.\n\n## Overview\n\nManaging forking/background processes in test \u0026 CI environments is a\npain. `resque-mock` allows you to run resque jobs in tests without\nforking or connecting to a redis server.\n\n## Usage\n\nActivate `resque-mock` by calling `Resque.mock!` in your test setup code.\n\n    require 'resque'\n    require 'resque/mock'\n\n    class VerifyUserTest \u003c Test::Unit::TestCase\n      def setup\n        Resque.mock!\n      end\n\n      def test_verify_user\n        # model with a some states\n        user = User.new(:state =\u003e :signup)\n\n        # resque job which verifies a user\n        VerifyUser.enqueue(user.id)\n\n        # probably have to reload this guy\n        user.reload!\n\n        # the job has ran, the user should be verified\n        assert_equal user.state, :verified\n      end\n    end\n\nThe `VerifyUser.enqueue` is synchronous and will block until the job\nreturns.\n\n## Async Jobs\n\nYou can run jobs asynchronously with `Resque.async`.\n\n    class AsyncTest \u003c Test::Unit::TestCase\n      def setup\n        Resque.mock!\n      end\n\n      def test_async_verify\n        user = User.new(:state =\u003e :signup)\n\n        Resque.async do\n          # this job might take a while, and spawn other jobs.\n          VerifyUser.enqueue(user.id)\n\n          # it's a slow job, so it probably won't be finished yet.\n          user.reload!\n          assert_not_equal user.state, :verified\n        end\n\n        # the block doesn't return until all jobs are finished, so\n        # the verify job should be done\n        assert_equal user.state, :verified\n      end\n    end\n\nAsync jobs are pushed onto a worker queue managed by a manager thread.\nEach job is then started in it's own thread.\n\n## resque-scheduler\n\n`resque-mock` can also mock `resque-scheduler`'s `Resque.enqueue_in` and\n`Resque.enqueue_at` methods.\n\n## Contributors\n\nDan Peterson (https://github.com/dpiddy)\n\nBen Burkert  (https://github.com/benburkert)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanp%2Fresque-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanp%2Fresque-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanp%2Fresque-mock/lists"}