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

assert_file understands paths with special characters #20605

Merged
merged 1 commit into from
Jun 19, 2015

Conversation

dcrec1
Copy link
Contributor

@dcrec1 dcrec1 commented Jun 17, 2015

fixes #20042

@dcrec1
Copy link
Contributor Author

dcrec1 commented Jun 17, 2015

@senny is this fix valid?

@@ -23,7 +23,7 @@ module Assertions
# end
# end
def assert_file(relative, *contents)
absolute = File.expand_path(relative, destination_root).shellescape
absolute = File.expand_path(relative, destination_root).gsub(" ", "\\ ")
Copy link
Member

Choose a reason for hiding this comment

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

Can you point me in the direction why this gsub is needed?

Given:

$ ls spaces
file with spaces.txt v0.1.4~alpha+nightly

The following script outputs:

path = File.expand_path("../spaces/file with spaces.txt", __FILE__)
path # => /Users/senny/Projects/ruby/spaces/file with spaces.txt
File.exist?(path) # => true

path = File.expand_path("../spaces/v0.1.4~alpha+nightly", __FILE__)
path # => /Users/senny/Projects/ruby/spaces/v0.1.4~alpha+nightly
File.exist?(path) # => true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@senny Is to avoid breaking this test in #12606 . It breaks because the path got shellescaped. If shellescape is removed from this line, the test pass.

May I edit the test?

Copy link
Member

Choose a reason for hiding this comment

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

yes, please do.

@senny senny merged commit 6074d0f into rails:master Jun 19, 2015
senny added a commit that referenced this pull request Jun 19, 2015
assert_file understands paths with special characters
@senny
Copy link
Member

senny commented Jun 19, 2015

Thank you 💛

@senny senny added the railties label Jun 19, 2015
senny added a commit that referenced this pull request Jun 19, 2015
assert_file understands paths with special characters

Conflicts:
	railties/CHANGELOG.md
y-yagi added a commit to y-yagi/rails that referenced this pull request Oct 8, 2015
`shellwords` is no longer needed from rails#20605.
@y-yagi y-yagi mentioned this pull request Oct 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assert_file fails when filename has special characters (~, +)
2 participants