Skip to content

Commit

Permalink
Use File.realpath with __dir__ instead of __FILE__ in source location…
Browse files Browse the repository at this point in the history
… specs

This removes the need to go one level up to remove the file from the
path.
  • Loading branch information
herwinw authored and eregon committed Aug 28, 2023
1 parent ab0932c commit bb5300b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/method/source_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
it "sets the first value to the path of the file in which the method was defined" do
file = @method.source_location.first
file.should be_an_instance_of(String)
file.should == File.realpath('../fixtures/classes.rb', __FILE__)
file.should == File.realpath('fixtures/classes.rb', __dir__)
end

it "sets the last value to an Integer representing the line on which the method was defined" do
Expand Down
8 changes: 4 additions & 4 deletions core/proc/source_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
it "sets the first value to the path of the file in which the proc was defined" do
file = @proc.source_location.first
file.should be_an_instance_of(String)
file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
file.should == File.realpath('fixtures/source_location.rb', __dir__)

file = @proc_new.source_location.first
file.should be_an_instance_of(String)
file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
file.should == File.realpath('fixtures/source_location.rb', __dir__)

file = @lambda.source_location.first
file.should be_an_instance_of(String)
file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
file.should == File.realpath('fixtures/source_location.rb', __dir__)

file = @method.source_location.first
file.should be_an_instance_of(String)
file.should == File.realpath('../fixtures/source_location.rb', __FILE__)
file.should == File.realpath('fixtures/source_location.rb', __dir__)
end

it "sets the last value to an Integer representing the line on which the proc was defined" do
Expand Down
2 changes: 1 addition & 1 deletion core/unboundmethod/source_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
it "sets the first value to the path of the file in which the method was defined" do
file = @method.source_location.first
file.should be_an_instance_of(String)
file.should == File.realpath('../fixtures/classes.rb', __FILE__)
file.should == File.realpath('fixtures/classes.rb', __dir__)
end

it "sets the last value to an Integer representing the line on which the method was defined" do
Expand Down

0 comments on commit bb5300b

Please sign in to comment.