Closed axelson closed 8 years ago
@axelson can you provide us a more detailed use case, maybe an example?
I have a similar situation where one parameter of my job is a DateTime that could be anything. In my spec I can't test that it has been enqueued because that param is not known in the setup and not easily stubbed.
In fact I don't even care about testing the datetime, but the result is that I can't test that the job has been enqueued at all.
You could try passing the anything
matcher in RSpec for that argument. Something like expect(worker_class).to have_enqueued_job(anything, known_argument)
@packrat386 Just tested. Worked like a charm! Would you happen to know where I can find anything
in the RSpec docs? I think there are more wildcard-like argument matchers but I'm not sure where to look.
@packrat386 Thanks! That sounds like it'll work perfectly.
@packrat386 thank you from 2023 :D
Is there a way to use have_enqueued_job but only check the first argument? My use case is that for testing purposes it is only relevant to check the first argument, since the second argument is a detailed object hash that will change often in the future, thus making the test fragile.