Sha256: 1bfb0dd6f4f7ebc3483f5bf8ae858789c69292f25d4dbd3c7ac75bc5757f63b3
Contents?: true
Size: 1.55 KB
Versions: 5
Compression:
Stored size: 1.55 KB
Contents
require 'spec_helper' describe InfoparkComponentCache::Guards::ObjCount do 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) { 12314 } 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 } subject { described_class.new(cache_component_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 { subject.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 { subject.guard! } it { is_expected.to be_consistent } end context "after obj count increases" do before { subject.guard! } before { obj_stub.stub(:count).and_return(55555) } it { is_expected.not_to be_consistent } end context "after obj count decreases" do before { subject.guard! } before { obj_stub.stub(:count).and_return(500) } it { is_expected.not_to be_consistent } end end end
Version data entries
5 entries across 5 versions & 1 rubygems