Skip to content

Add a nice error message when calling stub_const with something other than a string

Created by: luispcosta

Sometimes, I'm calling .stub_const so frequently that I don't even understand why it doesn't work only to later figuring out that I was calling it with the actual constant to stub instead of a string with the namespace of the constant.

For example:

module A
    CONST = 10
end

# Instead of calling
stub_const("A::CONST", 1)

# I sometimes do
stub_const(A::CONST, 1)

# Giving me the error message:
NoMethodError:
       undefined method `sub' for 10:Fixnum

Thank you for this awesome project btw!

Merge request reports