Sha256: f9db556a35f3d93b3a2b902b6dc8a4dd5f13f648190afa7cef3f213355783b82

Contents?: true

Size: 1.43 KB

Versions: 12

Compression:

Stored size: 1.43 KB

Contents

require "spec_helper"

module Switchman
  module ActionController
    describe Caching do
      include RSpecHelper

      shared_examples_for "sharded cache store" do
        describe "cache_store" do
          before do
            DatabaseServer.all.each do |ds|
              ds.instance_variable_set(:@cache_store, stub("cache_store #{ds.id}"))
            end
          end

          after do
            DatabaseServer.all.each do |ds|
              ds.instance_variable_set(:@cache_store, nil)
            end
          end

          it "should share the cache across shards on the same server" do
            @shard1.activate{ subject.cache_store }.
              should == @shard3.activate{ subject.cache_store }
          end

          it "should not share the cache across shards on different servers" do
            @shard1.activate{ subject.cache_store }.
              should_not == @shard2.activate{ subject.cache_store }
          end
        end

        it "should not be assignable" do
          expect{ subject.cache_store = :memory_store }.to raise_exception(NoMethodError)
        end
      end

      describe "ActionController::Base class" do
        subject { ::ActionController::Base }
        it_should_behave_like "sharded cache store"
      end

      describe "ActionController::Base instance" do
        subject { ::ActionController::Base.new }
        it_should_behave_like "sharded cache store"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
switchman-1.2.10 spec/lib/action_controller/caching_spec.rb
switchman-1.2.9 spec/lib/action_controller/caching_spec.rb
switchman-1.2.8 spec/lib/action_controller/caching_spec.rb
switchman-1.2.7 spec/lib/action_controller/caching_spec.rb
switchman-1.2.5 spec/lib/action_controller/caching_spec.rb
switchman-1.2.4 spec/lib/action_controller/caching_spec.rb
switchman-1.2.3 spec/lib/action_controller/caching_spec.rb
switchman-1.2.2 spec/lib/action_controller/caching_spec.rb
switchman-1.2.1 spec/lib/action_controller/caching_spec.rb
switchman-1.2.0 spec/lib/action_controller/caching_spec.rb
switchman-1.1.0 spec/lib/action_controller/caching_spec.rb
switchman-1.0.0 spec/lib/action_controller/caching_spec.rb