Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `exactly' for #<RSpec::ActiveJob::Matchers::EnqueueA .. #2310

Closed
jaredbeck opened this issue Mar 31, 2020 · 3 comments
Closed

Comments

@jaredbeck
Copy link

What Ruby, Rails and RSpec versions are you using?

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

Observed behaviour

     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>'

Expected behaviour

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)

Workaround

expect(::RedactedJob).to have_been_enqueued.times(2)

Can you provide an example app?

Happy to, if determined to be needed.

@pirj
Copy link
Member

pirj commented Apr 2, 2020

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.

@pirj pirj closed this as completed Apr 2, 2020
@jaredbeck
Copy link
Author

Pretty sure you are using rspec-activejob. It's high time to start using rspec-rails's matchers instead.

Thanks Phil, after uninstalling rspec-activejob, I can now use exactly.

@pirj
Copy link
Member

pirj commented Apr 2, 2020

Good to know @jaredbeck, happy to help 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants