aboutsummaryrefslogtreecommitdiffstats
path: root/spec/spec_helper.rb
diff options
context:
space:
mode:
authorRobin Houston <robin.houston@gmail.com>2012-01-29 16:26:50 +0000
committerRobin Houston <robin.houston@gmail.com>2012-01-29 16:26:50 +0000
commit5aa2bd13042110e73212f83564c35b3a1d672bbb (patch)
treeba9cea38b8c326a8384da8848fad33e8ee650edb /spec/spec_helper.rb
parentcc3b87f5367679ba9f68e88f02ec16fa9172bb0a (diff)
Load all raw emails for testing
Previously there was just one raw email, and the test code relied on that fact. Generalise it to handle multiple raw emails. This change causes a number of tests to fail, because it exposes failures that should have happened when the second raw email was added but were masked by the fact that the text of this second raw email was never loaded. These failures will be fixed in the next commit.
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r--spec/spec_helper.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 33a28449e..065d9d080 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -107,7 +107,7 @@ def validate_html(html)
File.open(tempfilename, "w+") do |f|
f.puts html
end
- if not system($html_validation_script, tempfilename)
+ if not system($html_validation_script, *($html_validation_script_options +[tempfilename]))
raise "HTML validation error in " + tempfilename + " HTTP status: " + @response.response_code.to_s
end
File.unlink(tempfilename)
@@ -131,6 +131,7 @@ utility_search_path = MySociety::Config.get("UTILITY_SEARCH_PATH", ["/usr/bin",
$html_validation_script_found = false
utility_search_path.each do |d|
$html_validation_script = File.join(d, "validate")
+ $html_validation_script_options = ["--charset=utf-8"]
if File.file? $html_validation_script and File.executable? $html_validation_script
$html_validation_script_found = true
break
@@ -178,13 +179,12 @@ def safe_mock_model(model, args = {})
mock
end
-def load_raw_emails_data(raw_emails)
- raw_email = raw_emails(:useless_raw_email)
- begin
- raw_email.destroy_file_representation!
- rescue Errno::ENOENT
+def load_raw_emails_data
+ raw_emails_yml = File.join(Spec::Runner.configuration.fixture_path, "raw_emails.yml")
+ for raw_email_id in YAML::load_file(raw_emails_yml).map{|k,v| v["id"]} do
+ raw_email = RawEmail.find(raw_email_id)
+ raw_email.data = load_file_fixture("raw_emails/%d.email" % [raw_email_id])
end
- raw_email.data = load_file_fixture("useless_raw_email.email")
end
def parse_all_incoming_messages