diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-04-16 11:01:54 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-04-16 11:01:54 +0100 |
commit | 38b519cb18f1dd9edf585f63b94c5b012949d71c (patch) | |
tree | 7995e5e0e1a43f4c47412677a2a0ae87025a346a /spec/lib | |
parent | 6557f7af1f529d3caaa944826c965fafa7e05f4c (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.rb | 17 |
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') |