spec/caching_test.rb in faraday_middleware-0.8.3 vs spec/caching_test.rb in faraday_middleware-0.8.4

- old
+ new

@@ -20,19 +20,30 @@ def fetch(key) read(key) || yield.tap { |data| write(key, data) } end end + class Lint < Struct.new(:app) + def call(env) + app.call(env).on_complete do + raise "no headers" unless env[:response_headers].is_a? Hash + raise "no response" unless env[:response].is_a? Faraday::Response + raise "env not identical" unless env[:response].env.object_id == env.object_id + end + end + end + def setup @cache = TestCache.new request_count = 0 response = lambda { |env| [200, {'Content-Type' => 'text/plain'}, "request:#{request_count+=1}"] } @conn = Faraday.new do |b| + b.use Lint b.use FaradayMiddleware::Caching, @cache b.adapter :test do |stub| stub.get('/', &response) stub.get('/?foo=bar', &response) stub.post('/', &response) @@ -53,10 +64,10 @@ def test_response_has_request_params get('/') # make cache response = get('/') assert_equal :get, response.env[:method] - assert_equal '/', response.env[:url].to_s + assert_equal '/', response.env[:url].request_uri end def test_cache_query_params assert_equal 'request:1', get('/').body assert_equal 'request:2', get('/?foo=bar').body