Skip to content

Commit

Permalink
Merge 1d7e0ff into a338564
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogh committed Nov 23, 2015
2 parents a338564 + 1d7e0ff commit 949f118
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/filename_cleaner/filename_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ def sanitize_with_dot(name)

# Replace 'dot' string with a given string if specified
def replace_dot(string, replace = nil)
string.gsub!(/#{Regexp.quote(DOT)}+/, replace) if replace
string
result = string.clone
result.gsub!(/#{Regexp.quote(DOT)}+/, replace) if replace
result
end
end
end
7 changes: 7 additions & 0 deletions test/lib/filename_cleaner/test_filename_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,12 @@
end
end
end
describe "immutability" do
it "does not mutate the input" do
input_name = "Global Variables"
output_name = FilenameCleaner.sanitize(input_name, "_", false)
output_name.wont_equal input_name
end
end
end
end

0 comments on commit 949f118

Please sign in to comment.