Skip to content

have_enqueued_job not available by default in 3.4.0 #1488

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

Closed
morgoth opened this issue Nov 12, 2015 · 7 comments · Fixed by #1635
Closed

have_enqueued_job not available by default in 3.4.0 #1488

morgoth opened this issue Nov 12, 2015 · 7 comments · Fixed by #1635

Comments

@morgoth
Copy link
Contributor

morgoth commented Nov 12, 2015

When I try to use new matcher, I'm getting You must pass an argument rather than a block to use the provided matcher (have enqueued job), or the matcher must implement supports_block_expectations?
error.

After debugging it turns out that it's not autoloaded, I have to include RSpec::Rails::Matchers.

Any idea why is that?

@myronmarston
Copy link
Member

If there's no have_foo_bar matcher defined, rspec-matchers' dynamic matcher support and have_foo_bar is treated as a matcher that delegates to has_foo_bar?. That's why you're getting the error that you got.

As for having to include RSpec::Rails::Matchers....that's the module in which you defined have_enqueued_job:

https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/matchers/active_job.rb

That module isn't included automatically in all RSpec example groups. Although, perhaps it should. There are a lot of other matchers in that module that, IMO, should be usable in any context. @cupakromer, WDYT?

@morgoth
Copy link
Contributor Author

morgoth commented Nov 12, 2015

yes, I think it should be available out of the box in case when AJ is available, I thought that this is enough https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/matchers.rb#L22-L24 but it's not

@kyletolle
Copy link

I got tripped up by this same thing. I needed to include RSpec::Rails::Matchers in a class where I'd moved some code, even though the controller was automatically ready to use the have_enqueued_job matcher. I think it'd also be nice if the module were included by default.

Thanks for the explanation! It allowed me to get on my way.

@openbl
Copy link

openbl commented Feb 3, 2016

I just ran into this as well. It seems like either these matchers should be included by default or the docs should include the necessary set up to avoid similar confusion. Happy to help with either.

@Senjai
Copy link

Senjai commented Jun 3, 2016

Bump. Running into this as well.

@soulcutter
Copy link
Member

Myron said:

That module isn't included automatically in all RSpec example groups. Although, perhaps it should.

I think it should be automatically included in all example groups. Jobs can come out of anywhere, and any :type => . It's confusing right now.

@JonRowe
Copy link
Member

JonRowe commented Jun 10, 2016

@soulcutter It is automatically included, just only in Rails example groups, so lib code etc won't trigger it, PR incoming to fix this though

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

Successfully merging a pull request may close this issue.

7 participants