bundle exec ruby --version
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
bundle exec rails --version
Rails 6.0.2.2
bundle exec rspec --version
RSpec 3.9
- rspec-core 3.9.1
- rspec-expectations 3.9.1
- rspec-mocks 3.9.1
- rspec-rails 4.0.0
- rspec-support 3.9.2
Failure/Error: expect(::RedactedJob).to have_been_enqueued.exactly(2).times
NoMethodError:
undefined method `exactly' for #<RSpec::ActiveJob::Matchers::EnqueueA:0x00007feb2aa89d10>
# ./spec/redacted/enqueue_jobs_spec.rb:37:in `block (3 levels) in <module:Redacted>'
The 4.0 documentation has the following example, so I expected exactly to be defined.
UploadBackupsJob.perform_later('backup')
expect(UploadBackupsJob).to have_been_enqueued.exactly(:once)
expect(::RedactedJob).to have_been_enqueued.times(2)
Happy to, if determined to be needed.
Can you please set a breakpoint and check what is the source of the class an instance of which have_been_enqueued returns?
undefined method `exactly' for #<RSpec::ActiveJob::Matchers::EnqueueA:0x00007feb2aa89d10>
RSpec::ActiveJob::Matchers::EnqueueA doesn't look too similar to RSpec::Rails::Matchers::ActiveJob::HaveBeenEnqueued.
Pretty sure you are using rspec-activejob. It's high time to start using rspec-rails's matchers instead.
Pretty sure you are using
rspec-activejob. It's high time to start usingrspec-rails's matchers instead.
Thanks Phil, after uninstalling rspec-activejob, I can now use exactly.
Good to know @jaredbeck, happy to help 馃檶
Most helpful comment
Can you please set a breakpoint and check what is the source of the class an instance of which
have_been_enqueuedreturns?RSpec::ActiveJob::Matchers::EnqueueAdoesn't look too similar toRSpec::Rails::Matchers::ActiveJob::HaveBeenEnqueued.Pretty sure you are using
rspec-activejob. It's high time to start usingrspec-rails's matchers instead.