Sha256: 4076a8ae80df184504884b169967525319b8b879f2a54da21625964fa9dc58b2
Contents?: true
Size: 1.77 KB
Versions: 4
Compression:
Stored size: 1.77 KB
Contents
require 'spec_helper.rb' require 'active_support' describe HTTParty::DryIce do context "when being set up" do it "accepts a cache instance that quacks like a ActiveSupport cache" do expect do class MockApi cache(Object.new) end end.to raise_error expect do class MockApi cache(ActiveSupport::Cache::NullStore.new) end end.not_to raise_error end end context "when performing a request" do it "should not use read to check existance" do class MockApi cache(ActiveSupport::Cache::NullStore.new) end ActiveSupport::Cache::NullStore.any_instance.should_receive(:read) stub_request(:get, "http://example.com/").to_return(:status => 200, :body => "test", :headers => {}) MockApi.get('/') end it "does not cache requests without a cache header" do class MockApi cache(nil) end stub_request(:get, "http://example.com/").to_return(:status => 200, :body => "test", :headers => {:cache_control => 'max-age=10'}) response = MockApi.get('/') expect(MockApi.cache_response?(response)).to be 10 end end end describe HTTParty::DryIce::IceCache do it "should be able to marshel and store a HTTParty request" do stub_request(:get, "http://example.com/").to_return(:status => 200, :body => "hello world", :headers => {:cache_control => 'max-age=0'}) response = MockApi.get('/') cache = HTTParty::DryIce::IceCache.new(ActiveSupport::Cache::NullStore.new) serialised = cache.serialize_response(response) res = cache.build_response(serialised) res.body.should == response.body res.headers.should == response.headers end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dry_ice-0.1.1 | spec/dry_ice_spec.rb |
dry_ice-0.1.0 | spec/dry_ice_spec.rb |
dry_ice-0.0.2 | spec/dry_ice_spec.rb |
dry_ice-0.0.1 | spec/dry_ice_spec.rb |