-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 local variable or method `tagged_logger' during perform_enqueued_jobs #2545
Comments
Thanks for reporting. |
I'll take a deeper dive into this and report what I find. |
It feels like they are checking for a tagged logger by assuming it exists, they could easily fix this by checking its defined |
Inside the Rails PR that added the block I included in the description above, one finds this comment which suggests checking if |
I think rspec-rails should be responsible for making sure the features of |
Thanks for the hints @rafaelfranca, @ghiculescu. @jkwuc89 Does it fix the issue if you add the following to extend ActiveSupport::Concern
+ include ActiveSupport::Testing::TaggedLogging
include RSpec::Rails::SetupAndTeardownAdapter |
Here is a quick monkey patch using @pirj suggested solution # spec/rspec_helper.rb
if Rails::VERSION::MAJOR >= 7
require 'rspec/rails/version'
if Gem::Version.create(RSpec::Rails::Version::STRING) < Gem::Version.create("5.1.0")
RSpec::Rails::RailsExampleGroup.module_eval do
include ActiveSupport::Testing::TaggedLogging
end
end
end |
Adding the following to if Rails::VERSION::MAJOR >= 7
include ActiveSupport::Testing::TaggedLogging
end Unfortunately, it causes another issue when I run the spec in question. When
|
I'm using the following crappy patch, as including the module into Also defined a dummy if Rails::VERSION::MAJOR >= 7
require 'rspec/rails/version'
RSpec::Core::ExampleGroup.module_eval do
include ActiveSupport::Testing::TaggedLogging
def name
'foobar'
end
end
end |
PRs would be accepted to solve this, |
This was fixed in |
@JonRowe the problem still persists, version |
Please provide a reproduction snippet. |
I am getting this error in 6.0.1 with this test: it "test description" do
expect {
perform_enqueued_jobs do
# failing LOC here, due to raised exception (uncaught, unexpected)
end
}.to change { ActionMailer::Base.deliveries.size }.by(2)
end I get just enough of the actual backtrace in the stdout to then pry in and figure out the exception / failure myself but yeah, ultimately it's slowing me down |
I also see the same error with 6.0.1, my code looks similar
Ruby 3.2.1, rails 7.0.4 |
@pirj I just saw this error in 6.0.1, and the monkey patch above #2545 (comment) can fix the issue. However, I find I missed |
If it’s not a Rails example group (no ‘type:’ set), why it is expected to include the code introduced in #2587 ? |
Still see this issue and #2545 (comment) helps resolve it but would like to understand why #2587 doesn't fix things? |
Because this is only for Rails example groups. But the patch you refer to does patch it for all example groups. |
I'm running this code:
and am getting this error:
I got past the first "tagged logger" error by adding |
I see some ‘fixture_builder’ gem in the log. And i see you’ve filed a bug there, too rdy/fixture_builder#70 Can you check if this branch would fix your issue? rdy/fixture_builder#68 |
I'm still seeing this issue with Ruby (3.3.5), Rails (7.1.4), rspec (3.13.0), rspec-rails (7.0.1). To me it's pointing here:
But don't think is has to do with FactoryBot, it's seems is just because I have my perform_enqueued_jobs in a factory. |
@sebaherrera07 Can you please:
|
I don't know, that looks to me like the factory needs to have the tagger logger included and thats out of scope for us. |
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-darwin21]
Rails version: 7.0.0
RSpec 3.10
Observed behaviour
Inside an rspec support module, my app is calling
perform_enqueued_jobs
. The spec in question that is using this support module is expecting this call to raise an exception.When I attempt to run this spec, the following is raised:
When I debug into
perform_enqueued_jobs
, I am taken into_assert_nothing_raised_or_warn
insideactivesupport-7.0.0/lib/active_support/testing/assertions.rb
, When debugging the block below, it showse
as having the expected exception.Debugging further reveals that the
if tagged_logger
check above is causing the undefined error.I reported this on Rails forum here and a member of the core team suggested the following:
"This seems to be a bug in RSpec that doesn’t implement the tagged_logger. Please report the issue in the RSpec issue tracker."
Expected behaviour
The spec should finish and allow
to raise_error
to check for the expected exception. This spec is working as expected in Rails 6.The text was updated successfully, but these errors were encountered: