Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Conversation

JonRowe
Copy link
Member

@JonRowe JonRowe commented Oct 9, 2014

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 group
doesn't cause the bug to occur.

See #1697

/cc @myronmarston

@JonRowe JonRowe force-pushed the demonstrate_192_wonky_constant branch from 0bc94cf to 32a1f65 Compare October 9, 2014 11:09
@myronmarston
Copy link
Member

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?

@JonRowe
Copy link
Member Author

JonRowe commented Oct 9, 2014

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 << "_"
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

@JonRowe JonRowe force-pushed the demonstrate_192_wonky_constant branch from 25911b9 to c1cf893 Compare October 9, 2014 21:47
@JonRowe
Copy link
Member Author

JonRowe commented Oct 9, 2014

Ping @myronmarston, this now only affects 1.9.2

@JonRowe JonRowe force-pushed the demonstrate_192_wonky_constant branch from c1cf893 to 4354f9e Compare October 9, 2014 21:50
@myronmarston
Copy link
Member

LGTM.

@@ -638,6 +648,7 @@ def self.base_name_for(group)

name
end
private_class_method :_base_name_for
Copy link
Member

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.

@JonRowe JonRowe force-pushed the demonstrate_192_wonky_constant branch from 4354f9e to ce463cd Compare October 9, 2014 22:00
JonRowe added a commit that referenced this pull request Oct 9, 2014
@JonRowe JonRowe force-pushed the demonstrate_192_wonky_constant branch from ce463cd to bd154c6 Compare October 9, 2014 22:02
@JonRowe
Copy link
Member Author

JonRowe commented Oct 9, 2014

I took your advice.

JonRowe added a commit that referenced this pull request Oct 10, 2014
Demonstate issue with wonky constants on 1.9.2
@JonRowe JonRowe merged commit eca5422 into master Oct 10, 2014
@JonRowe JonRowe deleted the demonstrate_192_wonky_constant branch October 10, 2014 00:44
JonRowe added a commit that referenced this pull request Oct 10, 2014
Demonstate issue with wonky constants on 1.9.2
@JonRowe
Copy link
Member Author

JonRowe commented Oct 10, 2014

Picked to 3-1-maintenance

MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
Demonstate issue with wonky constants on 1.9.2
yujinakayama pushed a commit to yujinakayama/rspec-monorepo that referenced this pull request Oct 6, 2021
…e_192_wonky_constant

Demonstate issue with wonky constants on 1.9.2

---
This commit was imported from rspec/rspec-core@dc67db3.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants