diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-17 16:00:39 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-17 16:00:39 +0000 |
commit | e886720060a5bda9e11fdf06d101f6891f52e8c0 (patch) | |
tree | 49c9e7a63ff0b377e7c9386f5a41f584ce1f98d5 | |
parent | 8f6049f5650e92e30d79845655405bae347e6715 (diff) |
Flexible location for validate utility
Allow the WDG HTML validation utility "validate" to be anywhere
in UTILITY_SEARCH_PATH, rather than hard-coding /usr/bin.
-rw-r--r-- | spec/spec_helper.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6c3a947ba..e58c3890a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -121,16 +121,24 @@ def validate_as_body(html) end def basic_auth_login(request, username = nil, password = nil) - username = MySociety::Config.get('ADMIN_USERNAME') if username.nil? + username = MySociety::Config.get('ADMIN_USERNAME') if username.nil? password = MySociety::Config.get('ADMIN_PASSWORD') if password.nil? request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("#{username}:#{password}") end # Monkeypatch! Validate HTML in tests. -$html_validation_script = "/usr/bin/validate" # from Debian package wdg-html-validator +utility_search_path = MySociety::Config.get("UTILITY_SEARCH_PATH", ["/usr/bin", "/usr/local/bin"]) +$html_validation_script_found = false +utility_search_path.each do |d| + $html_validation_script = File.join(d, "validate") + if File.file? $html_validation_script and File.executable? $html_validation_script + $html_validation_script_found = true + break + end +end if $tempfilecount.nil? $tempfilecount = 0 - if File.exist?($html_validation_script) + if $html_validation_script_found module ActionController module TestProcess # Hook into the process function, so can automatically get HTML after each request |