diff --git a/lib/akamai_rspec/matchers/honour_origin_headers.rb b/lib/akamai_rspec/matchers/honour_origin_headers.rb index 5225e09..a55051d 100644 --- a/lib/akamai_rspec/matchers/honour_origin_headers.rb +++ b/lib/akamai_rspec/matchers/honour_origin_headers.rb @@ -18,7 +18,7 @@ end def fix_date_header(origin_response) - origin_response.headers[:date] = Time.now.httpdate unless origin_response.headers[:date] + origin_response.headers[:date] ||= Time.now.httpdate origin_response end diff --git a/spec/functional/matchers_spec.rb b/spec/functional/matchers_spec.rb index 1ff26b6..e99a232 100644 --- a/spec/functional/matchers_spec.rb +++ b/spec/functional/matchers_spec.rb @@ -3,6 +3,6 @@ describe 'be_forwarded_to_index' do it 'should have tests' do pending - Fail + fail end end diff --git a/spec/unit/matchers/honour_origin_cache_headers_spec.rb b/spec/unit/matchers/honour_origin_cache_headers_spec.rb index e36ec8f..6f6aaa1 100644 --- a/spec/unit/matchers/honour_origin_cache_headers_spec.rb +++ b/spec/unit/matchers/honour_origin_cache_headers_spec.rb @@ -5,6 +5,8 @@ describe 'honour_origin_cache_headers' do context 'fix_date_header' do + let(:date) { Time.now } + let(:headers) { {} } it 'should leave filled in date unchanged' do origin_response = double(RestClient::Response) allow(origin_response).to receive(:headers) { { :date => 'something' } } @@ -12,10 +14,10 @@ end it 'should fill in date if it is absent' do - pending + allow(Time).to receive(:now).and_return(date) origin_response = double(RestClient::Response) - allow(origin_response).to receive(:headers) { { } } - expect(fix_date_header(origin_response).headers[:date]).to eq(Time.now.httpdate) + allow(origin_response).to receive(:headers).and_return(headers) + expect(fix_date_header(origin_response).headers[:date]).to eq(date.httpdate) end end