Sha256: f8f40f5aa02361aacc5da28d4c3c23c05eed67deb5fa02003a39a25aea705472
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
require 'spec_helper' module AccessPolicyRails describe RequestLocalStorage do subject { RequestLocalStorage } let(:storage) { subject.for } describe '.for' do it 'creates a new object for every thread' do subject.for threat_one_object_id = nil threat_two_object_id = nil threats = [] threats << Thread.new { threat_one_object_id = RequestLocalStorage.for } threats << Thread.new { threat_two_object_id = RequestLocalStorage.for } threats.each &:join expect(threat_one_object_id).not_to eq threat_two_object_id end it 'supports naming different scopes' do second_scope = subject.for 'the second scope' expect(second_scope.object_id).not_to be subject.for.object_id end end it 'supports hash like accessors' do storage['key'] = 1 expect(storage['key']).to eq 1 expect(storage.fetch 'key').to eq 1 storage.clear! expect(storage['key']).to be_nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
access_policy_rails-0.0.2 | spec/unit/lib/access_policy_rails/request_local_storage_spec.rb |
access_policy_rails-0.0.1 | spec/unit/lib/access_policy_rails/request_local_storage_spec.rb |