diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-08-14 14:14:35 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-08-14 14:14:35 +0100 |
commit | c6d5020a9a48226feaccd856df0c8f4584d5fd08 (patch) | |
tree | 0b86047eca0f3a5737203ca7e1953bb2d93ee98e /spec/models/censor_rule_spec.rb | |
parent | 03a875ae16520d7a5fc1c5e8f7e607c7fa6aded2 (diff) |
Handle regexp rules when running censor rules on binary files.
Diffstat (limited to 'spec/models/censor_rule_spec.rb')
-rw-r--r-- | spec/models/censor_rule_spec.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/spec/models/censor_rule_spec.rb b/spec/models/censor_rule_spec.rb index 6b48ac317..de9651f01 100644 --- a/spec/models/censor_rule_spec.rb +++ b/spec/models/censor_rule_spec.rb @@ -35,18 +35,18 @@ describe CensorRule, "substituting things" do @censor_rule.text = "--PRIVATE.*--PRIVATE" @censor_rule.replacement = "--REMOVED\nHidden private info\n--REMOVED" @censor_rule.regexp = true - end - - it "replaces with the regexp" do - body = + @body = <<BODY Some public information --PRIVATE Some private information --PRIVATE BODY - @censor_rule.apply_to_text!(body) - body.should == + end + + it "replaces the regexp with the replacement text when applied to text" do + @censor_rule.apply_to_text!(@body) + @body.should == <<BODY Some public information --REMOVED @@ -55,6 +55,18 @@ Hidden private info BODY end + it "replaces the regexp with the same number of 'x' characters as the text replaced + when applied to binary" do + @censor_rule.apply_to_binary!(@body) + @body.should == +<<BODY +Some public information +xxxxxxxxx +xxxxxxxxxxxxxxxxxxxxxxxx +xxxxxxxxx +BODY + end + end end |