-
-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds Module#const_source_location specs #815
Conversation
5e0b9d1
to
3bc89e7
Compare
a85d7a2
to
e59722f
Compare
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.
This looks good in general.
Sorry for the late review.
describe "with dynamically assigned constants" do | ||
it "searches a path in the immediate class or module first" do | ||
ConstantSpecs::ClassA::CS_CONST301 = :const301_1 | ||
ConstantSpecs::ClassA.const_source_location(:CS_CONST301).should == [__FILE__, 14] |
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.
Could you use something like __LINE__ - 1
to avoid hardcoding line numbers?
|
||
describe "with statically assigned constants" do | ||
it "searches location path the immediate class or module first" do | ||
ConstantSpecs::ClassA.const_source_location(:CS_CONST10).should == [@constants_fixture_path, 78] |
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.
For these cases, it would be better to define some constants in that file like CS_CONST10_LINE = __LINE__ - 1
.
@eregon thanks for review! Your ideas is very reasonable and brilliant! I will implement it as soon as possible |
b129b5b
to
9af4b34
Compare
done! 🏁 |
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.
Thank you for the new specs!
Solving #745
Hello, I'm not sure about how detailed this specs should be.
I've just take examples from https://github.com/ruby/spec/blob/master/core/module/const_get_spec.rb
Is it right? Or better to write different examples?
Also add some special cases from docs https://ruby-doc.org/core-2.7.0/Module.html#method-i-const_source_location