Sha256: 63673c21becd5f84f22dcb41a8c6643b49f90b9996fe4feee77f1e1682f6f9a4

Contents?: true

Size: 1.37 KB

Versions: 6511

Compression:

Stored size: 1.37 KB

Contents

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("1.9.0")
  require 'dalli'
  require 'typhoeus/cache/dalli'
  require 'spec_helper'

  describe Typhoeus::Cache::Dalli do
    let(:dalli) { instance_double(Dalli::Client) }
    let(:cache) { Typhoeus::Cache::Dalli.new(dalli) }

    let(:base_url) { "localhost:3001" }
    let(:request) { Typhoeus::Request.new(base_url, {:method => :get}) }
    let(:response) { Typhoeus::Response.new(:response_code => 0, :return_code => 0, :mock => true) }

    describe "#set" do
      it "sends the request to Dalli" do
        expect(dalli).to receive(:set).with(request.cache_key, response, nil)

        cache.set(request, response)
      end
    end

    describe "#get" do
      it "returns nil when the key is not in the cache" do
        expect(dalli).to receive(:get).with(request.cache_key).and_return(nil)

        expect(cache.get(request)).to be_nil
      end

      it "returns the cached response when the key is in cache" do
        expect(dalli).to receive(:get).with(request.cache_key).and_return(response)

        result = cache.get(request)
        expect(result).to_not be_nil
        expect(result.response_code).to eq(response.response_code)
        expect(result.return_code).to eq(response.return_code)
        expect(result.headers).to eq(response.headers)
        expect(result.body).to eq(response.body)
      end
    end
  end
end

Version data entries

6,511 entries across 6,508 versions & 26 rubygems

Version Path
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_bank_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_organization_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_id_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_bank_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_organization_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_id_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_id_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_bank_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_organization_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_organization_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_id_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_bank_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_bank_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_id_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_organization_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_bank_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_organization_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb
cybrid_api_id_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/spec/typhoeus/cache/dalli_spec.rb