aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/alaveteli_text_masker_spec.rb2
-rw-r--r--spec/lib/health_checks/checks/days_ago_check_spec.rb6
-rw-r--r--spec/lib/health_checks/health_checkable_spec.rb22
-rw-r--r--spec/lib/health_checks/health_checks_spec.rb6
-rw-r--r--spec/lib/languages_spec.rb22
-rw-r--r--spec/lib/mail_handler/mail_handler_spec.rb10
6 files changed, 43 insertions, 25 deletions
diff --git a/spec/lib/alaveteli_text_masker_spec.rb b/spec/lib/alaveteli_text_masker_spec.rb
index 8f7c530b3..f2d52c1cc 100644
--- a/spec/lib/alaveteli_text_masker_spec.rb
+++ b/spec/lib/alaveteli_text_masker_spec.rb
@@ -60,7 +60,7 @@ describe AlaveteliTextMasker do
end
def pdf_replacement_test(use_ghostscript_compression)
- config = MySociety::Config.load_default()
+ config = MySociety::Config.load_default
previous = config['USE_GHOSTSCRIPT_COMPRESSION']
config['USE_GHOSTSCRIPT_COMPRESSION'] = use_ghostscript_compression
orig_pdf = load_file_fixture('tfl.pdf')
diff --git a/spec/lib/health_checks/checks/days_ago_check_spec.rb b/spec/lib/health_checks/checks/days_ago_check_spec.rb
index 829b8e71e..4fbc1913b 100644
--- a/spec/lib/health_checks/checks/days_ago_check_spec.rb
+++ b/spec/lib/health_checks/checks/days_ago_check_spec.rb
@@ -16,16 +16,16 @@ describe HealthChecks::Checks::DaysAgoCheck do
expect(check.days).to eq(4)
end
- describe :check do
+ describe :ok? do
it 'is successful if the subject is in the last day' do
check = HealthChecks::Checks::DaysAgoCheck.new { Time.now }
- expect(check.check).to be_true
+ expect(check.ok?).to be_true
end
it 'fails if the subject is over a day ago' do
check = HealthChecks::Checks::DaysAgoCheck.new { 2.days.ago }
- expect(check.check).to be_false
+ expect(check.ok?).to be_false
end
end
diff --git a/spec/lib/health_checks/health_checkable_spec.rb b/spec/lib/health_checks/health_checkable_spec.rb
index 301585bbd..59d76c337 100644
--- a/spec/lib/health_checks/health_checkable_spec.rb
+++ b/spec/lib/health_checks/health_checkable_spec.rb
@@ -32,24 +32,10 @@ describe HealthChecks::HealthCheckable do
end
- describe :check do
-
- it 'is intended to be overridden by the includer' do
- expect{ @subject.check }.to raise_error(NotImplementedError)
- end
-
- end
-
describe :ok? do
- it 'returns true if the check was successful' do
- @subject.stub(:check => true)
- expect(@subject.ok?).to be_true
- end
-
- it 'returns false if the check failed' do
- @subject.stub(:check => false)
- expect(@subject.ok?).to be_false
+ it 'is intended to be overridden by the includer' do
+ expect{ @subject.ok? }.to raise_error(NotImplementedError)
end
end
@@ -93,7 +79,7 @@ describe HealthChecks::HealthCheckable do
context 'if the check succeeds' do
before(:each) do
- @subject.stub(:check => true)
+ @subject.stub(:ok? => true)
end
it 'returns the default success message' do
@@ -110,7 +96,7 @@ describe HealthChecks::HealthCheckable do
context 'if the check fails' do
before(:each) do
- @subject.stub(:check => false)
+ @subject.stub(:ok? => false)
end
it 'returns the default failure message' do
diff --git a/spec/lib/health_checks/health_checks_spec.rb b/spec/lib/health_checks/health_checks_spec.rb
index 335e10b3a..0b97725db 100644
--- a/spec/lib/health_checks/health_checks_spec.rb
+++ b/spec/lib/health_checks/health_checks_spec.rb
@@ -7,7 +7,7 @@ describe HealthChecks do
describe :add do
it 'adds a check to the collection and returns the check' do
- check = double('MockCheck', :check => true)
+ check = double('MockCheck', :ok? => true)
expect(add(check)).to eq(check)
end
@@ -21,8 +21,8 @@ describe HealthChecks do
describe :all do
it 'returns all the checks' do
- check1 = double('MockCheck', :check => true)
- check2 = double('AnotherCheck', :check => false)
+ check1 = double('MockCheck', :ok? => true)
+ check2 = double('AnotherCheck', :ok? => false)
add(check1)
add(check2)
expect(all).to include(check1, check2)
diff --git a/spec/lib/languages_spec.rb b/spec/lib/languages_spec.rb
new file mode 100644
index 000000000..38f611087
--- /dev/null
+++ b/spec/lib/languages_spec.rb
@@ -0,0 +1,22 @@
+# -*- encoding : utf-8 -*-
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe LanguageNames do
+
+ describe :get_language_name do
+
+ it 'should return the name assigned to the language' do
+ LanguageNames.get_language_name('en').should == 'English'
+ end
+
+ it 'should return the name assigned to the language when there is no specific location' do
+ LanguageNames.get_language_name('pt_BR').should == 'Português'
+ end
+
+ it 'should return the name assigned to the language/location combination' do
+ LanguageNames.get_language_name('zh_HK').should == '中文(香港)'
+ end
+
+ end
+
+end
diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb
index 7f0070a8a..27a7a3db4 100644
--- a/spec/lib/mail_handler/mail_handler_spec.rb
+++ b/spec/lib/mail_handler/mail_handler_spec.rb
@@ -158,6 +158,16 @@ describe 'when asked for all the addresses a mail has been sent to' do
mail = MailHandler.mail_from_raw_email(mail_data)
MailHandler.get_all_addresses(mail).should == ["request-5555-xxxxxxxx@whatdotheyknow.com"]
end
+
+ it 'should not return invalid addresses' do
+ mail_data = load_file_fixture('autoresponse-header.email')
+ mail_data.gsub!('To: FOI Person <EMAIL_TO>',
+ 'To: <request-5555-xxxxxxxx>')
+ mail = MailHandler.mail_from_raw_email(mail_data)
+ MailHandler.get_all_addresses(mail).should == []
+ end
+
+
end
describe 'when asked for auto_submitted' do