Skip to content

Commit

Permalink
Merge pull request #781 from cucumber/issue-726-deprecate-file-creati…
Browse files Browse the repository at this point in the history
…on-when-appending

Deprecate file creation when using append_to_file
  • Loading branch information
mvz committed Jan 31, 2021
2 parents 06566ee + 9298b84 commit 7e81690
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.8.1.
# using RuboCop version 1.9.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -56,7 +56,7 @@ Metrics/MethodLength:

# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 193
Max: 198

# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Expand Down Expand Up @@ -194,7 +194,7 @@ Style/Documentation:
- 'lib/aruba/setup.rb'
- 'lib/aruba/tasks/docker_helpers.rb'

# Configuration parameters: MaxUnannotatedPlaceholdersAllowed.
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
EnforcedStyle: unannotated
Expand Down
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 Down Expand Up @@ -48,7 +48,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 @@ -65,3 +65,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 7e81690

Please sign in to comment.