Project

General

Profile

Actions

Bug #19396

closed

Tests failing with "ArgumentError: let 'X' cannot override a method in Minitest::Spec. Please use another name."

Added by Sebastian Gräßl almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
hard
Triaged:
Fixed in Releases:
Found in Releases:

Description

After the recent upgrade of minitest1 test started failing with error like this:

    ArgumentError: let 'image' cannot override a method in Minitest::Spec. Please use another name.
      /usr/local/var/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest/spec.rb:242:in `let'
    /Users/bastilian/RedHat/Foreman/Repos/foreman/test/models/image_test.rb:20:in `block in <class:ImageTest>'
    /usr/local/var/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/minitest-spec-rails-5.4.0/lib/minitest-spec-rails/dsl.rb:14:in `class_eval'
    /usr/local/var/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/minitest-spec-rails-5.4.0/lib/minitest-spec-rails/dsl.rb:14:in `block in describe'
    /usr/local/var/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/minitest-5.10.1/lib/minitest/spec.rb:83:in `class_eval'
    ...

Before these let() calls did not raise any issue. In this case the method image is not a Minitest::Spec, but a method included from Rake::DSL.
image is not a a method of Rake::DSL either, but a method introduced by the docker-api gem2, which is a dependency of the foreman-docker plugin.

Another case occurred in remote_execution3 and core1 with location and is a legitimate failure as in this case it actually is a `Minitest::Spec` method, the change of organization is presumably just for context.

Right now it is not clear if this was introduced by the latest minitest or if this only surfaced due to the update.
The issue is reproducible only with an updated minitest gem and is not introduced by a change in the same commit.

Clear is that after updating minitest, methods from unrelated sources have been introduced into the test scopes that were not there before.

For now when these warnings happen we can simply change the name and avoid the collision, but we should figure out why this is happening now.
To do so if these errors are encountered verify that they are legitimate. A quick and dirty way is using the following in the test after adjusting the name used in let()*

puts self.method(:METHODNAME).secure_location

If the method definition is nowhere near minitest you can report it here.

[1] https://github.com/theforeman/foreman/commit/edd5310fc97828d306a06ecca861543def61cac8
[2] https://github.com/swipely/docker-api/blob/2b306bad803a2df9a12dab4fc673486365872666/lib/docker/rake_task.rb#L36
[3] https://github.com/theforeman/foreman_remote_execution/pull/243/files#diff-2c6075570be0c5cd68e20ce023b3d550L97


Related issues 1 (0 open1 closed)

Related to Foreman - Bug #19475: Rename test variables to more specific termClosedSebastian Gräßl05/08/2017Actions
Actions #1

Updated by Anonymous almost 7 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100
Actions #2

Updated by Dominic Cleal almost 7 years ago

  • Project changed from Foreman to Docker
  • Category deleted (Tests)
Actions #3

Updated by Sebastian Gräßl almost 7 years ago

  • Project changed from Docker to Foreman
Actions #4

Updated by Dominic Cleal almost 7 years ago

This issue has been fixed by a commit in the Docker subproject, it shouldn't be in Foreman. Can you please move it back?

Actions #5

Updated by Sebastian Gräßl almost 7 years ago

Both the issue and the test mentioned in this issue (and a few others) are in foreman-core.
The fixes in foreman-docker involve the same workaround as in the PR attached to this issue in core.

The issue was introduced with the update of minitest in core. This issue is actually not addressed by the PR, but rather another workaround.
The `image` method does not belong into the scope of tests, as it is a `Rake::DSL` method, which I believe should not be there in `TestCase`.

Actions #6

Updated by Dominic Cleal almost 7 years ago

  • Project changed from Foreman to Docker

Please use a new ticket then for changes to Foreman, this one has a commit in foreman-docker associated.

Actions #7

Updated by Sebastian Gräßl almost 7 years ago

Will do that!

Actions #8

Updated by Marek Hulán almost 7 years ago

  • Related to Bug #19475: Rename test variables to more specific term added
Actions

Also available in: Atom PDF