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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion railties/lib/rails/generators/testing/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
assert File.exist?(absolute), "Expected file #{relative.inspect} to exist, but does not"

read = File.read(absolute) if block_given? || !contents.empty?
Expand Down
2 changes: 1 addition & 1 deletion railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def test_pretend_option
end

def test_application_name_with_spaces
path = File.join(destination_root, "foo bar".shellescape)
path = File.join(destination_root, "foo bar")

# This also applies to MySQL apps but not with SQLite
run_generator [path, "-d", 'postgresql']
Expand Down
8 changes: 8 additions & 0 deletions railties/test/railties/generators_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,13 @@ def test_helpers_are_not_namespaced_when_engine_is_not_mountable
assert_no_file "app/helpers/foo_bar/topics_helper.rb"
end
end

def test_assert_file_founds_files_with_special_characters
path = "#{app_path}/tmp"
file_name = "#{path}/v0.1.4~alpha+nightly"
FileUtils.mkdir_p path
FileUtils.touch file_name
assert_file file_name
end
end
end