{"action":"created","issue":{"url":"https://api.github.com/repos/mperham/sidekiq/issues/2637","labels_url":"https://api.github.com/repos/mperham/sidekiq/issues/2637/labels{/name}","comments_url":"https://api.github.com/repos/mperham/sidekiq/issues/2637/comments","events_url":"https://api.github.com/repos/mperham/sidekiq/issues/2637/events","html_url":"https://github.com/mperham/sidekiq/issues/2637","id":114663791,"number":2637,"title":"Simulate processing?","user":{"login":"mhenrixon","id":106795,"avatar_url":"https://avatars.githubusercontent.com/u/106795?v=3","gravatar_id":"","url":"https://api.github.com/users/mhenrixon","html_url":"https://github.com/mhenrixon","followers_url":"https://api.github.com/users/mhenrixon/followers","following_url":"https://api.github.com/users/mhenrixon/following{/other_user}","gists_url":"https://api.github.com/users/mhenrixon/gists{/gist_id}","starred_url":"https://api.github.com/users/mhenrixon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhenrixon/subscriptions","organizations_url":"https://api.github.com/users/mhenrixon/orgs","repos_url":"https://api.github.com/users/mhenrixon/repos","events_url":"https://api.github.com/users/mhenrixon/events{/privacy}","received_events_url":"https://api.github.com/users/mhenrixon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-11-02T19:11:22Z","updated_at":"2015-11-07T20:24:21Z","closed_at":"2015-11-02T20:35:56Z","body":"Hi,\r\n\r\nI'm in the business of simulating Sidekiq processing. I want to get as close as possible to the real deal but I'd be fine using something like hawknewton/rspec-eventually, laserlemon/rspec-wait or http://myronmars.to/n/dev-blog/2012/03/building-an-around-hook-using-fibers. I want to make absolutely sure that for this edge case someone posted a while ago I am able to replicate what happens in production through a test case.\r\n\r\nLet me try to explain what I want to do\r\n\r\n```ruby\r\nit 'rejects nested subsequent jobs with the same arguments' do\r\n  Sidekiq::Testing.disable! do\r\n    jid = SimpleWorker.perform_async 1\r\n    expect(SimpleWorker.perform_async 1).to eq(nil)\r\n    expect(SpawnSimpleWorker.perform_async 1).not_to eq(nil)\r\n\r\n    Sidekiq.redis do |c|\r\n      wait_for { c.llen('queue:default') }.to eq(1)\r\n      wait_for { c.llen('queue:not_default') }.to eq(1)\r\n    end\r\n\r\n    launcher = Sidekiq::Launcher.new(queues: %w(not_default))\r\n    launcher.run\r\n\r\n    Sidekiq.redis do |c|\r\n      expect(c.llen('queue:default')).to eq(1)\r\n      wait_for { c.llen('queue:not_default') }.to eq(0)\r\n    end\r\n\r\n    launcher.stop\r\n\r\n    Sidekiq.redis do |c|\r\n      expect(c.llen('queue:default')).to eq(1)\r\n    end\r\n\r\n    launcher = Sidekiq::Launcher.new(queues: %w(default))\r\n    launcher.run\r\n\r\n    Sidekiq.redis do |c|\r\n      expect(c.llen('queue:not_default')).to eq(0)\r\n      wait_for { c.llen('queue:default') }.to eq(0)\r\n    end\r\n\r\n    launcher.stop\r\n  end\r\nend\r\n```\r\n\r\nForget about configuration etc. I am fine with all the code and cumbersome setup I am basically just in the business of making sure that things happen in the right order. Do you have any better suggestions on how to achieve something equally trustworthy? "},"comment":{"url":"https://api.github.com/repos/mperham/sidekiq/issues/comments/154745246","html_url":"https://github.com/mperham/sidekiq/issues/2637#issuecomment-154745246","issue_url":"https://api.github.com/repos/mperham/sidekiq/issues/2637","id":154745246,"user":{"login":"mhenrixon","id":106795,"avatar_url":"https://avatars.githubusercontent.com/u/106795?v=3","gravatar_id":"","url":"https://api.github.com/users/mhenrixon","html_url":"https://github.com/mhenrixon","followers_url":"https://api.github.com/users/mhenrixon/followers","following_url":"https://api.github.com/users/mhenrixon/following{/other_user}","gists_url":"https://api.github.com/users/mhenrixon/gists{/gist_id}","starred_url":"https://api.github.com/users/mhenrixon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhenrixon/subscriptions","organizations_url":"https://api.github.com/users/mhenrixon/orgs","repos_url":"https://api.github.com/users/mhenrixon/repos","events_url":"https://api.github.com/users/mhenrixon/events{/privacy}","received_events_url":"https://api.github.com/users/mhenrixon/received_events","type":"User","site_admin":false},"created_at":"2015-11-07T20:24:21Z","updated_at":"2015-11-07T20:24:21Z","body":"Not sure if anyone cares but this is what I came up with: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/lib/sidekiq/simulator.rb I have a test using the code here: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/spec/lib/sidekiq_unique_jobs/client/middleware_spec.rb#L25"}}