Sha256: 8e7cbe09e00330136600fc5190b7e1bb263f1d9d34036e5c4873417f833d2d23

Contents?: true

Size: 947 Bytes

Versions: 1

Compression:

Stored size: 947 Bytes

Contents

module FilesystemTestHelper
  CACHE_TEST_PATH = File.join(File.dirname(__FILE__), "../amazon/caching/cache/")

protected
  def set_valid_caching_options(path = nil)
    path ||= File.join(File.dirname(__FILE__), "cache")
    if @path
      raise "Expected same path: #{path} != #{@path}" if path != @path
      return
    end

    @path = path

    #configure Amazon library for filesystem caching
    FileUtils.mkdir_p(@path)
    Amazon::Associates.configure do |options|
      options.merge!(:caching_strategy => :filesystem,
                     :caching_options => {
                         :cache_path => @path,
                         :disk_quota => 200
                     })
    end
  end

  def reset_cache
    #reset caching to off
    Amazon::Associates.configure do |options|
      options.delete(:caching_strategy)
      options.delete(:caching_options)
    end

    #remove all the cache files
    FileUtils.rm_rf(@path)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amazon-associates-0.6.3 test/utilities/filesystem_test_helper.rb