Sha256: d7be1ac4060312f5a3eeb958afd6075b9f9582a48eeba3f37c89c63074650fc9

Contents?: true

Size: 758 Bytes

Versions: 27

Compression:

Stored size: 758 Bytes

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

describe "per_thread_caching plugin" do 
  it "should use a per thread cache instead of a shared cache" do
    app(:bare) do
      plugin :per_thread_caching
      @c = thread_safe_cache
      def self.c; @c end
      route do |r|
        r.on :id do |i|
          ((self.class.c[i] ||= []) << 2).join
        end
      end
    end

    (0..10).map do |n|
      Thread.new do
        Thread.current[:n] = n
        _(body('/a')).must_equal '2'
        _(body('/a')).must_equal '22'
        _(body('/a')).must_equal '222'
        _(body('/b')).must_equal '2'
        _(body('/b')).must_equal '22'
        _(body('/b')).must_equal '222'
      end
    end.map{|t| t.join}
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
roda-2.28.0 spec/plugin/per_thread_caching_spec.rb
roda-2.27.0 spec/plugin/per_thread_caching_spec.rb
roda-2.26.0 spec/plugin/per_thread_caching_spec.rb
roda-2.25.0 spec/plugin/per_thread_caching_spec.rb
roda-2.24.0 spec/plugin/per_thread_caching_spec.rb
roda-2.23.0 spec/plugin/per_thread_caching_spec.rb
roda-2.22.0 spec/plugin/per_thread_caching_spec.rb
roda-2.21.0 spec/plugin/per_thread_caching_spec.rb
roda-2.20.0 spec/plugin/per_thread_caching_spec.rb
roda-2.19.0 spec/plugin/per_thread_caching_spec.rb
roda-2.18.0 spec/plugin/per_thread_caching_spec.rb
roda-2.17.0 spec/plugin/per_thread_caching_spec.rb
roda-2.16.0 spec/plugin/per_thread_caching_spec.rb
roda-2.15.0 spec/plugin/per_thread_caching_spec.rb
roda-2.14.0 spec/plugin/per_thread_caching_spec.rb
roda-2.13.0 spec/plugin/per_thread_caching_spec.rb
roda-2.12.0 spec/plugin/per_thread_caching_spec.rb
roda-2.11.0 spec/plugin/per_thread_caching_spec.rb
roda-2.10.0 spec/plugin/per_thread_caching_spec.rb
roda-2.9.0 spec/plugin/per_thread_caching_spec.rb