-
-
Notifications
You must be signed in to change notification settings - Fork 752
Demonstate issue with wonky constants on 1.9.2 #1737
Conversation
0bc94cf
to
32a1f65
Compare
The spec looks good. Thanks for figuring out how to trigger the 1.9.2 weirdness! Do you want to work on a fix or would you like me to? |
I took a stab at it. |
@@ -636,6 +636,10 @@ def self.base_name_for(group) | |||
# as necessary to enforce that. | |||
name.gsub!(/\A([^A-Z]|\z)/, 'Nested\1') | |||
|
|||
# We append a _ to force it to be different to potentially real top level | |||
# constants, which is a real bug on 1.9.2 see rspec/rspec-core#1697 | |||
name << "_" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is an ugly hack for an old version of ruby that is no longer maintained, I'd like for this hack to only apply to that version. In the tests you can define a special version of have_class_const
for 1.9.2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that was the approach I took initially, but I also need to special case all of the inspect specs and/or special case inspect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that was the approach I took initially, but I also need to special case all of the inspect specs and/or special case inspect.
If it's simpler just to skip those specs on 1.9.2 I'm fine with that.
25911b9
to
c1cf893
Compare
Ping @myronmarston, this now only affects 1.9.2 |
c1cf893
to
4354f9e
Compare
LGTM. |
@@ -638,6 +648,7 @@ def self.base_name_for(group) | |||
|
|||
name | |||
end | |||
private_class_method :_base_name_for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better way to do this is:
def self.base_name_for(group)
# existing logic
end
if RUBY_VERSION == '1.9.2'
alias _base_name_for base_name_for
private_class_method :_base_name_for
def base_name_for(group)
_base_name_for(group) + '_'
end
end
That way, there's no _base_name_for
method on other versions since it's not needed.
4354f9e
to
ce463cd
Compare
ce463cd
to
bd154c6
Compare
I took your advice. |
Demonstate issue with wonky constants on 1.9.2
Demonstate issue with wonky constants on 1.9.2
Picked to 3-1-maintenance |
[skip ci]
Demonstate issue with wonky constants on 1.9.2
…e_192_wonky_constant Demonstate issue with wonky constants on 1.9.2 --- This commit was imported from rspec/rspec-core@dc67db3.
I'm expecting this to fail, the reason why the spec is a new file is that 1.9.2's issue with wonky constants seems to stem from the first
instance_exec
not the last, so having this inside an existing example groupdoesn't cause the bug to occur.
See #1697
/cc @myronmarston