|
1 | 1 | **Welcome @wspurgin as new maintainer for `rspec-sidekiq`!**
|
2 | 2 |
|
3 |
| -# RSpec for Sidekiq |
4 |
| - |
5 | 3 | [![RubyGems][gem_version_badge]][ruby_gems]
|
6 | 4 | [![Github Actions CI][github_actions_badge]][github_actions]
|
7 | 5 |
|
@@ -65,33 +63,31 @@ expect { AwesomeJob.set(queue: "high").perform_async }.to enqueue_sidekiq_job.on
|
65 | 63 | specific_time = 1.hour.from_now
|
66 | 64 | expect { AwesomeJob.perform_at(specific_time) }.to enqueue_sidekiq_job.at(specific_time)
|
67 | 65 |
|
| 66 | +# In a specific interval (be mindful of freezing or managing time here) |
| 67 | +freeze_time do |
| 68 | + expect { AwesomeJob.perform_in(1.hour) }.to enqueue_sidekiq_job.in(1.hour) |
| 69 | +end |
| 70 | + |
68 | 71 | # Combine and chain them as desired
|
69 | 72 | expect { AwesomeJob.perform_at(specific_time, "Awesome!") }.to(
|
70 | 73 | enqueue_sidekiq_job(AwesomeJob)
|
71 | 74 | .with("Awesome!")
|
72 | 75 | .on("default")
|
73 | 76 | .at(specific_time)
|
74 | 77 | )
|
75 |
| - |
76 |
| -# In a specific interval (be mindful of freezing or managing time here) |
77 |
| -freeze_time do |
78 |
| - expect { AwesomeJob.perform_in(1.hour) }.to enqueue_sidekiq_job.in(1.hour) |
79 |
| -end |
80 | 78 | ```
|
81 | 79 |
|
82 | 80 | ### have_enqueued_sidekiq_job
|
83 |
| -*Describes that there should be an enqueued job with the specified arguments* |
84 |
| - |
85 |
| -**Note:** When using rspec-rails >= 3.4, use `have_enqueued_sidekiq_job` instead to |
86 |
| -prevent a name clash with rspec-rails' ActiveJob matcher. |
| 81 | +*Describes that there should be an enqueued job with the **specified |
| 82 | +arguments*** |
87 | 83 |
|
88 | 84 | ```ruby
|
89 | 85 | AwesomeJob.perform_async 'Awesome', true
|
90 | 86 | # test with...
|
91 | 87 | expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true)
|
92 | 88 | ```
|
93 | 89 |
|
94 |
| -You can use the built-in args matchers too: |
| 90 | +You can use the built-in RSpec args matchers too: |
95 | 91 | ```ruby
|
96 | 92 | AwesomeJob.perform_async({"something" => "Awesome", "extra" => "stuff"})
|
97 | 93 |
|
@@ -157,10 +153,10 @@ expect(Sidekiq::Worker).to have_enqueued_sidekiq_job(
|
157 | 153 | #### Testing a job is _not_ enqueued
|
158 | 154 |
|
159 | 155 | The negative case for `have_enqueued_sidekiq_job` is provided, but it's
|
160 |
| -important to remember that `have_enqueued_sidekiq_job` is an expectation of |
161 |
| -specific _arguments_. In other words, passing no arguments to |
162 |
| -`have_enqueued_sidekiq_job` is implicitly telling the matcher to look for jobs |
163 |
| -_without_ arguments. |
| 156 | +important to remember that `have_enqueued_sidekiq_job` is an expectation that a |
| 157 | +job is enqueued _with specific arguments_. In other words, passing no arguments |
| 158 | +to `have_enqueued_sidekiq_job` is implicitly telling the matcher to look for |
| 159 | +jobs _without_ arguments. |
164 | 160 |
|
165 | 161 | In short, unless you tell the matcher that _no_ jobs with _any_ arguments should be enqueued, you'll get the wrong result:
|
166 | 162 |
|
|
0 commit comments