aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--spec/controllers/api_controller_spec.rb12
-rw-r--r--spec/fixtures/files/email-folding-example-1.txt.expected7
-rw-r--r--spec/fixtures/files/email-folding-example-10.txt12
-rw-r--r--spec/fixtures/files/email-folding-example-10.txt.expected13
-rw-r--r--spec/fixtures/files/email-folding-example-2.txt.expected1
-rw-r--r--spec/fixtures/files/email-folding-example-3.txt.expected7
-rw-r--r--spec/fixtures/files/email-folding-example-5.txt.expected12
-rw-r--r--spec/fixtures/files/email-folding-example-7.txt.expected3
-rw-r--r--spec/fixtures/files/email-folding-example-8.txt.expected3
-rw-r--r--spec/fixtures/files/email-folding-example-9.txt.expected6
-rw-r--r--spec/models/incoming_message_spec.rb4
-rw-r--r--spec/spec_helper.rb13
12 files changed, 59 insertions, 34 deletions
diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb
index 8e9d17fbe..e9a0f0be4 100644
--- a/spec/controllers/api_controller_spec.rb
+++ b/spec/controllers/api_controller_spec.rb
@@ -1,18 +1,6 @@
# coding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
-def normalise_whitespace(s)
- s = s.gsub(/\A\s+|\s+\Z/, "")
- s = s.gsub(/\s+/, " ")
- return s
-end
-
-RSpec::Matchers.define :be_equal_modulo_whitespace_to do |expected|
- match do |actual|
- normalise_whitespace(actual) == normalise_whitespace(expected)
- end
-end
-
describe ApiController, "when using the API" do
describe 'checking API keys' do
diff --git a/spec/fixtures/files/email-folding-example-1.txt.expected b/spec/fixtures/files/email-folding-example-1.txt.expected
index 801542288..45dabf156 100644
--- a/spec/fixtures/files/email-folding-example-1.txt.expected
+++ b/spec/fixtures/files/email-folding-example-1.txt.expected
@@ -8,3 +8,10 @@ On behalf of James Hall, Chief Executive
Identity and Passport Service
<<9032 C Pollard final response.doc>>
+FOLDED_QUOTED_SECTION
+
+FOLDED_QUOTED_SECTION
+
+
+FOLDED_QUOTED_SECTION
+
diff --git a/spec/fixtures/files/email-folding-example-10.txt b/spec/fixtures/files/email-folding-example-10.txt
index 0fabb7f9c..a0773e6ff 100644
--- a/spec/fixtures/files/email-folding-example-10.txt
+++ b/spec/fixtures/files/email-folding-example-10.txt
@@ -3,13 +3,13 @@ Department of Health, please visit the 'Contact us' page on the
Department’s website.
-----------------------------------------------------------------------------------------
-
- Apologies that you were not able to read our previous response of 4
- October. Please find the text of that email below.
-
+
+ Apologies that you were not able to read our previous response of 4
+ October. Please find the text of that email below.
+
Our ref: DE00000642471
-Dear Ms Peters Rock,
+Dear Ms Peters Rock,
You requested your correspondence to be treated under the Freedom of
Information Act.  However, as your correspondence asked for general
@@ -19,7 +19,7 @@ correspondence under the provisions of the Act.
I am sorry I cannot be more helpful.
-Yours sincerely,
+Yours sincerely,
Simon Dove
Customer Service Centre
Department of Health
diff --git a/spec/fixtures/files/email-folding-example-10.txt.expected b/spec/fixtures/files/email-folding-example-10.txt.expected
index e4f704c0e..5b609dc12 100644
--- a/spec/fixtures/files/email-folding-example-10.txt.expected
+++ b/spec/fixtures/files/email-folding-example-10.txt.expected
@@ -3,13 +3,13 @@ Department of Health, please visit the 'Contact us' page on the
Department’s website.
-----------------------------------------------------------------------------------------
-
- Apologies that you were not able to read our previous response of 4
- October. Please find the text of that email below.
-
+
+ Apologies that you were not able to read our previous response of 4
+ October. Please find the text of that email below.
+
Our ref: DE00000642471
-Dear Ms Peters Rock,
+Dear Ms Peters Rock,
You requested your correspondence to be treated under the Freedom of
Information Act.  However, as your correspondence asked for general
@@ -19,7 +19,8 @@ correspondence under the provisions of the Act.
I am sorry I cannot be more helpful.
-Yours sincerely,
+Yours sincerely,
Simon Dove
Customer Service Centre
Department of Health
+FOLDED_QUOTED_SECTION
diff --git a/spec/fixtures/files/email-folding-example-2.txt.expected b/spec/fixtures/files/email-folding-example-2.txt.expected
index e52fbe443..df578390d 100644
--- a/spec/fixtures/files/email-folding-example-2.txt.expected
+++ b/spec/fixtures/files/email-folding-example-2.txt.expected
@@ -2,3 +2,4 @@ Preface to the message which we are not interested in
-----------------------------------------------------------------------------------------
Important message about cheese
+FOLDED_QUOTED_SECTION
diff --git a/spec/fixtures/files/email-folding-example-3.txt.expected b/spec/fixtures/files/email-folding-example-3.txt.expected
index e2cca4933..accb40150 100644
--- a/spec/fixtures/files/email-folding-example-3.txt.expected
+++ b/spec/fixtures/files/email-folding-example-3.txt.expected
@@ -3,3 +3,10 @@ Reference : T3241/8
Thank you for your e-mail enquiry of 12th February.
A reply is attached.
+FOLDED_QUOTED_SECTION
+
+FOLDED_QUOTED_SECTION
+
+
+FOLDED_QUOTED_SECTION
+
diff --git a/spec/fixtures/files/email-folding-example-5.txt.expected b/spec/fixtures/files/email-folding-example-5.txt.expected
index fbb0f0f50..46d7f731a 100644
--- a/spec/fixtures/files/email-folding-example-5.txt.expected
+++ b/spec/fixtures/files/email-folding-example-5.txt.expected
@@ -1,11 +1,11 @@
Hi Simon
-My apologies for timescale of response. The data forwarded is a public
-register, and is updated on a frequent and regular basis; your request
-unfortunately coincided with annual leave and a monthly update of the
-spreadsheet. As the definition of an HMO under the Housing Act 2004
-differs to that under planning legislation, I have forwarded this and
-your original request on to Andy England, Development Control Manager to
+My apologies for timescale of response. The data forwarded is a public
+register, and is updated on a frequent and regular basis; your request
+unfortunately coincided with annual leave and a monthly update of the
+spreadsheet. As the definition of an HMO under the Housing Act 2004
+differs to that under planning legislation, I have forwarded this and
+your original request on to Andy England, Development Control Manager to
respond independantly.
If I can be of further assistance please contact me
diff --git a/spec/fixtures/files/email-folding-example-7.txt.expected b/spec/fixtures/files/email-folding-example-7.txt.expected
index 0ef8fd82b..cb6961038 100644
--- a/spec/fixtures/files/email-folding-example-7.txt.expected
+++ b/spec/fixtures/files/email-folding-example-7.txt.expected
@@ -13,4 +13,5 @@ Telephone +44 (0) 116 2222222
Extn 5221 VM No. 8035
Fax + 44 (0) 116 2485217
-<<0001_00035908_Resp_12RESPONSE LETTER_20080408_112311_01.TIF>> \ No newline at end of file
+<<0001_00035908_Resp_12RESPONSE LETTER_20080408_112311_01.TIF>>
+FOLDED_QUOTED_SECTION
diff --git a/spec/fixtures/files/email-folding-example-8.txt.expected b/spec/fixtures/files/email-folding-example-8.txt.expected
index b5dc10c0d..e8c08f4ca 100644
--- a/spec/fixtures/files/email-folding-example-8.txt.expected
+++ b/spec/fixtures/files/email-folding-example-8.txt.expected
@@ -3,4 +3,5 @@ I will be out of the office starting 11/04/2008 and will not return until
I will respond to your message when I return. If you have any urgent
queries please ring 02085419088 for Legal Business Support queries or
-contact Eileen Perren for FOI or DP queries \ No newline at end of file
+contact Eileen Perren for FOI or DP queries
+FOLDED_QUOTED_SECTION
diff --git a/spec/fixtures/files/email-folding-example-9.txt.expected b/spec/fixtures/files/email-folding-example-9.txt.expected
index 2d2381a34..d222e9438 100644
--- a/spec/fixtures/files/email-folding-example-9.txt.expected
+++ b/spec/fixtures/files/email-folding-example-9.txt.expected
@@ -7,3 +7,9 @@ Yours sincerely
MICHAEL HEGARTY
FOI Officer
+FOLDED_QUOTED_SECTION
+
+FOLDED_QUOTED_SECTION
+
+
+FOLDED_QUOTED_SECTION
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index c0a7e5340..c27870afc 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -165,7 +165,7 @@ describe IncomingMessage, " when dealing with incoming mail" do
message = File.read(file)
parsed = IncomingMessage.remove_quoted_sections(message)
expected = File.read("#{file}.expected")
- parsed.should include(expected)
+ parsed.should be_equal_modulo_whitespace_to expected
end
end
@@ -462,7 +462,7 @@ describe IncomingMessage, " when censoring data" do
data.should == "His email was x\000x\000x\000@\000x\000x\000x\000.\000x\000x\000x\000, indeed"
end
- it 'should handle multibyte characters correctly', :focus => true do
+ it 'should handle multibyte characters correctly' do
orig_data = 'á'
data = orig_data.dup
@regex_censor_rule = CensorRule.new()
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 52752dca5..dc5a0d6eb 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -220,3 +220,16 @@ Spork.each_run do
FactoryGirl.reload
# This code will be run each time you run your specs.
end
+
+def normalise_whitespace(s)
+ s = s.gsub(/\A\s+|\s+\Z/, "")
+ s = s.gsub(/\s+/, " ")
+ return s
+end
+
+RSpec::Matchers.define :be_equal_modulo_whitespace_to do |expected|
+ match do |actual|
+ normalise_whitespace(actual) == normalise_whitespace(expected)
+ end
+end
+