aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-04-16 11:01:54 +0100
committerLouise Crow <louise.crow@gmail.com>2015-04-16 11:01:54 +0100
commit38b519cb18f1dd9edf585f63b94c5b012949d71c (patch)
tree7995e5e0e1a43f4c47412677a2a0ae87025a346a /spec/lib
parent6557f7af1f529d3caaa944826c965fafa7e05f4c (diff)
Refactor a bit to allow testing of logic branches.
Add specs for current behaviour on failure to uncompress, failure to compress.
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/alaveteli_text_masker_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/lib/alaveteli_text_masker_spec.rb b/spec/lib/alaveteli_text_masker_spec.rb
index 1a4782a83..102d2582e 100644
--- a/spec/lib/alaveteli_text_masker_spec.rb
+++ b/spec/lib/alaveteli_text_masker_spec.rb
@@ -92,6 +92,23 @@ describe AlaveteliTextMasker do
pdf.should_not == ""
end
+ it 'should keep the uncensored original if uncompression of a PDF fails' do
+ orig_pdf = load_file_fixture('tfl.pdf')
+ pdf = orig_pdf.dup
+ stub!(:uncompress_pdf).and_return nil
+ apply_masks!(pdf, "application/pdf")
+ pdf.should == orig_pdf
+ end
+
+ it 'should use the uncompressed PDF text if re-compression of a compressed PDF fails' do
+ orig_pdf = load_file_fixture('tfl.pdf')
+ pdf = orig_pdf.dup
+ stub!(:uncompress_pdf).and_return "something about foi@tfl.gov.uk"
+ stub!(:compress_pdf).and_return nil
+ apply_masks!(pdf, "application/pdf")
+ pdf.should match "something about xxx@xxx.xxx.xx"
+ end
+
it "should apply hard-coded privacy rules to HTML files" do
data = "http://test.host/c/cheese"
apply_masks!(data, 'text/html')