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.8.0 spec/plugin/per_thread_caching_spec.rb
roda-2.7.0 spec/plugin/per_thread_caching_spec.rb
roda-2.6.0 spec/plugin/per_thread_caching_spec.rb
roda-2.5.1 spec/plugin/per_thread_caching_spec.rb
roda-2.5.0 spec/plugin/per_thread_caching_spec.rb
roda-2.4.0 spec/plugin/per_thread_caching_spec.rb
roda-2.3.0 spec/plugin/per_thread_caching_spec.rb