Sha256: 2a3a0a2d01fb77fff4a15bd58d44cbcde8ab7486287696b67f7a3aca8615ee3a

Contents?: true

Size: 804 Bytes

Versions: 8

Compression:

Stored size: 804 Bytes

Contents

module CachingTestHelper
  class FakeResponseCache
    attr_accessor :expired_path, :expired_paths
    
    def initialize
      @expired_paths = []
      @cached_responses = {}
    end
    
    def clear
      @cached_responses.clear
      @cleared = true
    end
    
    def cache_response(path, response)
      @cached_responses[path] = response
      response
    end
    
    def update_response(path, response)
      if r = @cached_response[path]
        response.headers.merge!(r.headers)
        response.body = r.body
      end
      response
    end
    
    def expire_response(path)
      @expired_paths << path
      @expired_path = path
    end
    
    def response_cached?(path)
      @cached_responses.keys.include?(path)
    end
    
    def cleared?
      !!@cleared
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
radiant-0.5.1 test/helpers/caching_test_helper.rb
radiant-0.5.0 test/helpers/caching_test_helper.rb
radiant-0.6.0 test/helpers/caching_test_helper.rb
radiant-0.6.1 test/helpers/caching_test_helper.rb
radiant-0.5.2 test/helpers/caching_test_helper.rb
radiant-0.6.3 test/helpers/caching_test_helper.rb
radiant-0.6.2 test/helpers/caching_test_helper.rb
radiant-0.6.4 test/helpers/caching_test_helper.rb