Fix NoMethodError that is raised when the environment variable CUCUMBER_COLORS is defined#1641
Fix NoMethodError that is raised when the environment variable CUCUMBER_COLORS is defined#1641aurelien-reeves merged 6 commits intocucumber:mainfrom
Conversation
Signed-off-by: Stephan Kämper <the.tester@seasidetesting.com>
Signed-off-by: Stephan Kämper <the.tester@seasidetesting.com>
|
As a question for the reviewers: I wonder if there should be additional tests for this. While the existing tests had to be adapted to reflect the code change, I'm not (entirely) sure whether this is sufficient (given that the bug slipped through with the tests). Even though would have revealed the bug, I'm not sure this would be a good fit for another scenario in a feature file. |
aurelien-reeves
left a comment
There was a problem hiding this comment.
Thanks for your PR @s2k :)
Would it be possible to keep an instance methods - which would just call the class one - in order to prevent anything to break for users who would have hacked their cucumber?
And thus we could make sure to test the two methods actually
Also there is a call to apply_custom_colors right after it has been defined. I am surprised you did not had to change that call actually, but I may have missed something with ruby here 🤔
…e specs Signed-off-by: Stephan Kämper <the.tester@seasidetesting.com>
|
Thanks for the feedback. I had to change the definition of Here's an example: module Example
def for_instances(arg)
p arg
end
def self.for_class(arg)
p arg
end
begin
for_class('Calling the class method is OK')
rescue NoMethodError => e
p e
end
begin
for_instances('The instance method is not available in the class')
rescue NoMethodError => e
puts "That didn't work"
puts "Message:"
puts "*" * 40
puts e.message
puts "*" * 40
end
endRunning it yields: In other words: I hesitate to provide an instance method, because the method is not meant to be called on an instance (but provided it anyway 🙂), so we can discuss it. |
|
Thanks for the update. @luke-hill what is your opinion on this? |
Co-authored-by: Aurélien Reeves <aurelien.reeves@smartbear.com>
…it in the specs" This reverts commit 1560c6e.
|
No worries, I'll just need to revert 1560c6e, right? |
Yes, in addition to the last comments from @luke-hill |
|
OK, as far as I can see we could now merge this PR, no? |
|
This needs releasing. The bug with CUCUMBER_COLORS is in the current release 8.0.0 7 months after it has been fixed in cucumber:main. Can we get a point release out to address this? |
Description
This fixes a NoMethodError exception that is raised, when the environment variable
CUCUMBER_COLORSis set, by allowingapply_custom_colorsto be called right after its definition inCucumber::Formatter::ANSIColor.Defining the method as a class method of the module allows it to be called in the module itself.
Type of change