Sha256: 58e64053934724bb9e7f88f6bb88e9c57276ae0c2d2868808c805fee0faf4d2f
Contents?: true
Size: 942 Bytes
Versions: 1
Compression:
Stored size: 942 Bytes
Contents
require 'spec_helper' describe Synchronizable do context "when extended by an object" do let(:object) { String.new } it "creates an instance-level lock" do object.instance_variables.should_not include(:@__lock) object.extend(Synchronizable) object.instance_variables.should include(:@__lock) end it "creates a locked version of each original method" do class TestLock attr_reader :sync_invoked def initialize @sync_invoked = false end def synchronize(&block) @sync_invoked = true end end lock = TestLock.new object.extend(Synchronizable) object.instance_variable_set(:@__lock, lock) # methods from Object not wrapped object.object_id lock.sync_invoked.should == false # class-defined methods should be wrapped object.size lock.sync_invoked.should == true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
synchronizable-0.0.1 | spec/synchronizable/synchronizable_spec.rb |