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

Fixes #34064 - don't override magic klass variable #8963

Merged
merged 1 commit into from Dec 2, 2021

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Dec 2, 2021

when you let(:klass), it somehow touches the Mocha::Mock class,
instead of creating a new thing, freaking out Mocha in the process.

before:

$ bundle exec rake test TEST=test/unit/parameter_filter_test.rb TESTOPTS=-v
#<Mocha::Mock:0x0000557bf12cf750>#test_0002_permits plugin-added attributes from blocks = 0.49 s = .
#<Mocha::Mock:0x0000557bf1f22e30>#test_0001_permits plugin-added attribute = 0.04 s = .
…

after:

$ bundle exec rake test TEST=test/unit/parameter_filter_test.rb TESTOPTS=-v
ParameterFilterTest::with nested object#test_0001_constructs permit() args for nested attribute through second filter 0.52 = .
ParameterFilterTest::with nested object#test_0002_permits nested attribute through second filter 0.04 = .
…

when you let(:klass), it somehow touches the `Mocha::Mock` class,
instead of creating a new thing, freaking out Mocha in the process.

before:

    $ bundle exec rake test TEST=test/unit/parameter_filter_test.rb TESTOPTS=-v
    #<Mocha::Mock:0x0000557bf12cf750>#test_0002_permits plugin-added attributes from blocks = 0.49 s = .
    #<Mocha::Mock:0x0000557bf1f22e30>#test_0001_permits plugin-added attribute = 0.04 s = .
    …

after:

    $ bundle exec rake test TEST=test/unit/parameter_filter_test.rb TESTOPTS=-v
    ParameterFilterTest::with nested object#test_0001_constructs permit() args for nested attribute through second filter 0.52 = .
    ParameterFilterTest::with nested object#test_0002_permits nested attribute through second filter 0.04 = .
    …
@theforeman-bot
Copy link
Member

Issues: #34064

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea why, but I am not going to dig into mocha to figure that out.

@evgeni
Copy link
Member Author

evgeni commented Dec 2, 2021

no idea why, but I am not going to dig into mocha to figure that out.

same

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well something probably keeps the class that is currently being tested in klass variable.

@evgeni evgeni merged commit 104493b into theforeman:develop Dec 2, 2021
@evgeni evgeni deleted the mocha-wtf branch March 10, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants