Sha256: 32638c0c2a78eb12636787a9af51098a8d39be1227705343005b5955681a87ee

Contents?: true

Size: 734 Bytes

Versions: 17

Compression:

Stored size: 734 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').should == '2'
        body('/a').should == '22'
        body('/a').should == '222'
        body('/b').should == '2'
        body('/b').should == '22'
        body('/b').should == '222'
      end
    end.map{|t| t.join}
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
roda-2.2.0 spec/plugin/per_thread_caching_spec.rb
roda-2.1.0 spec/plugin/per_thread_caching_spec.rb
roda-2.0.0 spec/plugin/per_thread_caching_spec.rb
roda-1.3.0 spec/plugin/per_thread_caching_spec.rb
roda-1.2.0 spec/plugin/per_thread_caching_spec.rb
roda-1.1.0 spec/plugin/per_thread_caching_spec.rb
roda-cj-1.0.5 spec/plugin/per_thread_caching_spec.rb
roda-cj-1.0.4 spec/plugin/per_thread_caching_spec.rb
roda-cj-1.0.3 spec/plugin/per_thread_caching_spec.rb
roda-cj-1.0.2 spec/plugin/per_thread_caching_spec.rb
roda-cj-1.0.1 spec/plugin/per_thread_caching_spec.rb
roda-cj-1.0.0 spec/plugin/per_thread_caching_spec.rb
roda-1.0.0 spec/plugin/per_thread_caching_spec.rb
roda-cj-0.9.6 spec/plugin/per_thread_caching_spec.rb
roda-cj-0.9.5 spec/plugin/per_thread_caching_spec.rb
roda-cj-0.9.4 spec/plugin/per_thread_caching_spec.rb
roda-cj-0.9.3 spec/plugin/per_thread_caching_spec.rb