Sha256: 072436cdaddf6aa0f9058bfa92104d47e76a78cdac9eb7ddaa60dbed66bd29a2
Contents?: true
Size: 1.58 KB
Versions: 6
Compression:
Stored size: 1.58 KB
Contents
require "spec_helper" describe InfoparkComponentCache::Guards::ObjCount do subject(:guard) { described_class.new(cache_component_stub) } let(:cache_component_stub) do double.tap do |cache_component_stub| cache_component_stub.stub(:cache_key) do |input| input.inspect end end end let(:count) { 12_314 } let(:obj_stub) do double.tap do |obj_stub| obj_stub.stub(:scoped).and_return(obj_stub) obj_stub.stub(:where).and_return(obj_stub) obj_stub.stub(:count).and_return(count) end end before { InfoparkComponentCache::CmsStateGuard.obj_root_class = obj_stub } context "with cache disabled" do disable_cache context "without a call to guard!" do it { is_expected.not_to be_consistent } end context "with a call to guard!" do before { guard.guard! } it { is_expected.not_to be_consistent } end end context "with cache enabled" do enable_cache before { Rails.cache.clear } context "without a call to guard!" do it { is_expected.not_to be_consistent } end context "with a call to guard!" do before { guard.guard! } it { is_expected.to be_consistent } end context "when after obj count increases" do before do guard.guard! obj_stub.stub(:count).and_return(55_555) end it { is_expected.not_to be_consistent } end context "when after obj count decreases" do before do guard.guard! obj_stub.stub(:count).and_return(500) end it { is_expected.not_to be_consistent } end end end
Version data entries
6 entries across 6 versions & 1 rubygems