Skip to content
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

Restore old expand path behavior #540

Merged
merged 11 commits into from
Mar 1, 2018

Conversation

mvz
Copy link
Contributor

@mvz mvz commented Feb 11, 2018

Summary

Allow absolute paths in #expand_path, but complain about it by default.

Details

Makes #expand_path correctly handle absolute paths (like in #539), but in addition emit a warning when an absolute path is passed. Adds a configuration option allow_absolute_paths that can be set to true to silence this warning.

Motivation and Context

Fixes #478.

How Has This Been Tested?

Specs were added for the case of handing absolute paths, for emission of a warning, and for silencing that warning.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I've added tests for my code
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@mvz mvz force-pushed the issue-478-restore-old-expand_path-behavior branch from 3bc18cc to 130a583 Compare February 11, 2018 11:59
@mvz mvz requested a review from olleolleolle February 23, 2018 19:22
Copy link
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this monumental change!

Most of my feedback is concentrated on keeping the specs easy to read when they fail. Some of the context and it description texts have a hard time forming easy-to-read sentences when run in the --format documentation mode in RSpec.

(I guess this is mostly an effect of this being a huge change with some repeating bits, so it's nothing bad, it's just me being a proof-reading editor of some prose – which can easily be changed.)

expect(Dir.pwd).not_to eq full_path
end

it 'does not touch non-directory environment the passed block' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A missing word in this sentence?

it { expect(all_paths).to include expand_path(name) }
end

context 'when directory exist' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists

it { expect(all_paths).to include expand_path(name) }
end

context 'when nothing exist' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists

let(:name) { @file_name }
let(:path) { @file_path }

context 'when file exist' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists

it { expect(all_files).to include expand_path(name) }
end

context 'when directory exist' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists

it { expect(all_files).to eq [] }
end

context 'when nothing exist' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists

let(:name) { @file_name }
let(:path) { @file_path }

context 'when file exist' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and so on. I will not make further comments on this.

@aruba.touch(name, options)
end

context 'when does not exist' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clause has a “when” too much.

let(:name) { %w(directory1) }
let(:path) { Array(name).map { |p| File.join(@aruba.aruba.current_directory, p) } }

context 'when exist' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When exist -> exists

let(:path) { Array(name).map { |p| File.join(@aruba.aruba.current_directory, p) } }

context 'when exist' do
before(:each) { Array(path).each { |p| Aruba.platform.mkdir p } }
Copy link
Contributor

@olleolleolle olleolleolle Feb 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pet peeve: use a name other than p since Kernel#p is a built-in debug function.

@@ -13,6 +13,3 @@
# Loading support files
Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }

# Avoid writing "describe LocalPac::MyClass do [..]" but "describe MyClass do [..]"
include Aruba
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making this change.

Copy link
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record: I am for a merge of this change.

@mvz
Copy link
Contributor Author

mvz commented Mar 1, 2018

Thanks, @olleolleolle. I fixed most of the odd wording.

@mvz mvz merged commit 31f69fd into master Mar 1, 2018
@mvz mvz deleted the issue-478-restore-old-expand_path-behavior branch March 1, 2018 07:16
@matthutchinson
Copy link

Great work! thanks for merging 👍

@matthutchinson
Copy link

Will this be pushed out in a 0.14 point release (soon) or as part of 1.0?

@mvz
Copy link
Contributor Author

mvz commented Mar 3, 2018

@matthutchinson This partiular PR will be part of 1.0, but #539 implements just the fix to expand_path and will be part of the next 0.14 point release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Absolute directory paths and existence check
3 participants