Sha256: e5402c39096b28a048c9e894ebbd61f164787cfbf0fe792ce74ffa459c01ab2c
Contents?: true
Size: 1.58 KB
Versions: 19
Compression:
Stored size: 1.58 KB
Contents
require "spec_helper" describe ApiClient::Base do describe '.always' do it "registers a new default_scope" do AlwaysTestProc = lambda {} class AlwaysTest < ApiClient::Base always &AlwaysTestProc end AlwaysTest.default_scopes.size.should == 1 AlwaysTest.default_scopes.should == [AlwaysTestProc] end end describe '.scope' do it "returns a ApiClient::Scope instance" do ApiClient::Base.scope.should be_an_instance_of(ApiClient::Scope) end end describe '.scope_thread_attribute_name' do it "returns the key under which all .scoped calls should be stored" do ApiClient::Base.scope_thread_attribute_name.should == "ApiClient::Base_scope" end end describe '.scoped' do it "stores the scope in the thread context, attached to class name" do mock_scope3 = mock ApiClient::Base.scoped(mock_scope3) do Thread.new { mock_scope2 = mock ApiClient::Base.scoped(mock_scope2) do ApiClient::Base.scope.should == mock_scope2 Thread.current[ApiClient::Base.scope_thread_attribute_name].should == [mock_scope2] end } ApiClient::Base.scope.should == mock_scope3 Thread.current[ApiClient::Base.scope_thread_attribute_name].should == [mock_scope3] end Thread.new { mock_scope = mock ApiClient::Base.scoped(mock_scope) do ApiClient::Base.scope.should == mock_scope Thread.current[ApiClient::Base.scope_thread_attribute_name].should == [mock_scope] end } end end end
Version data entries
19 entries across 19 versions & 1 rubygems