diff options
-rw-r--r-- | lib/chef/util/file_edit.rb | 5 | ||||
-rw-r--r-- | spec/unit/util/file_edit_spec.rb | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/chef/util/file_edit.rb b/lib/chef/util/file_edit.rb index f4a3cde540..654a5c5514 100644 --- a/lib/chef/util/file_edit.rb +++ b/lib/chef/util/file_edit.rb @@ -34,6 +34,11 @@ class Chef @original_pathname = filepath end + # return if file has been edited + def file_edited? + file_edited + end + #search the file line by line and match each line with the given regex #if matched, replace the whole line with newline. def search_file_replace_line(regex, newline) diff --git a/spec/unit/util/file_edit_spec.rb b/spec/unit/util/file_edit_spec.rb index 9acfb1baea..f85c588699 100644 --- a/spec/unit/util/file_edit_spec.rb +++ b/spec/unit/util/file_edit_spec.rb @@ -213,4 +213,11 @@ twice expect(edited_file_contents).to eq(append_twice) end end + + describe "file_edited" do + it "should return true if a file got edited" do + @fedit.insert_line_if_no_match(/pattern/, "new line inserted") + @fedit.file_edited?.should == true + end + end end |