spec/routemaster/integration/cache_spec.rb in routemaster-drain-1.1.0 vs spec/routemaster/integration/cache_spec.rb in routemaster-drain-2.0.0

- old
+ new

@@ -31,25 +31,32 @@ end subject { Routemaster::Cache.new } describe 'GET request' do - let(:cache_keys) { ["cache:#{url}", "v:,l:"] } + let(:body_cache_keys) { ["cache:#{url}", "v:,l:,body"] } + let(:headers_cache_keys) { ["cache:#{url}", "v:,l:,headers"] } let(:url) { 'http://localhost:8000/test' } context 'when there is no previous cached response' do it 'makes an http call' do response = subject.get(url) expect(response.headers['server']).to be end it 'sets the new response onto the cache' do expect { subject.get(url) } - .to change { Routemaster::Config.cache_redis.hget(*cache_keys)} + .to change { Routemaster::Config.cache_redis.hget(*body_cache_keys)} .from(nil) .to({ field: 'test'}.to_json) end + + it 'sets the response headers onto the cache' do + expect { subject.get(url) } + .to change { Routemaster::Config.cache_redis.hget(*headers_cache_keys)} + .from(nil) + end end context 'when there is a previous cached response' do before do subject.get(url) @@ -59,10 +66,10 @@ expect(subject.get(url).body).to eq({ field: 'test' }.to_json) end it 'does not make an http call' do response = subject.get(url) - expect(response.headers['server']).to be_nil + expect(response.env.request).to be_empty end end end end