Skip to content

Commit

Permalink
Deprecate file creation when using append_to_file
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Jan 24, 2021
1 parent 5327c26 commit db3c021
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: Append content to file

You might want to append some content to a file.
You might want to append some content to an existing file.

Background:
Given I use a fixture named "cli-app"
Expand All @@ -26,7 +26,7 @@ Feature: Append content to file
When I run `cucumber`
Then the features should all pass

Scenario: Append to a non-existing file
Scenario: Append to a non-existing file (deprecated)
Given a file named "features/non-existence.feature" with:
"""
Feature: Existence
Expand All @@ -43,3 +43,7 @@ Feature: Append content to file
"""
When I run `cucumber`
Then the features should all pass
And the output should contain:
"""
The ability to call #append_to_file with a file that does not exist is deprecated
"""
7 changes: 6 additions & 1 deletion lib/aruba/api/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ def chmod(*args)
def append_to_file(file_name, file_content)
file_name = expand_path(file_name)

Aruba.platform.mkdir(File.dirname(file_name))
unless File.exist? file_name
Aruba.platform.deprecated("The ability to call #append_to_file with a file that" \
" does not exist is deprecated and will be removed in" \
" Aruba 2.0.")
Aruba.platform.mkdir(File.dirname(file_name))
end
File.open(file_name, "a") { |f| f << file_content }
end

Expand Down

0 comments on commit db3c021

Please sign in to comment.