Skip to content
This repository
Browse code

Disable identity map by default

The identity map was causing more issues than expected:
* #260
* #285
* #302
  • Loading branch information...
commit c6c5960bea998abdc3e82cbb8dd68766a2df52e1 1 parent 32de4f8
Erik Michaels-Ober authored September 06, 2012
2  README.md
Source Rendered
@@ -273,7 +273,7 @@ Here are some fun facts about the 3.0 release:
273 273
 
274 274
 * The entire library is implemented in just 2,000 lines of code
275 275
 * With over 5,000 lines of specs, the spec-to-code ratio is over 2.5:1
276  
-* The spec suite contains 674 examples and runs in under 2 seconds on a MacBook
  276
+* The spec suite contains 668 examples and runs in under 2 seconds on a MacBook
277 277
 * This project has 100% C0 code coverage (the tests execute every line of
278 278
   source code at least once)
279 279
 * At the time of release, this library is comprehensive: you can request all
2  lib/twitter/default.rb
@@ -22,7 +22,7 @@ module Default
22 22
       :ssl => {:verify => false},
23 23
       :timeout => 10,
24 24
     } unless defined? CONNECTION_OPTIONS
25  
-    IDENTITY_MAP = Twitter::IdentityMap unless defined? IDENTITY_MAP
  25
+    IDENTITY_MAP = false unless defined? IDENTITY_MAP
26 26
     MIDDLEWARE = Faraday::Builder.new(
27 27
       &Proc.new do |builder|
28 28
         # Convert file uploads to Faraday::UploadIO objects
19  spec/twitter/base_spec.rb
@@ -4,10 +4,15 @@
4 4
 
5 5
   context 'identity map enabled' do
6 6
     before do
  7
+      Twitter.identity_map = Twitter::IdentityMap
7 8
       object = Twitter::Base.new(:id => 1)
8 9
       @base = Twitter::Base.store(object)
9 10
     end
10 11
 
  12
+    after do
  13
+      Twitter.identity_map = false
  14
+    end
  15
+
11 16
     describe '.identity_map' do
12 17
       it 'returns an instance of the identity map' do
13 18
         Twitter::Base.identity_map.should be_a Twitter::IdentityMap
@@ -105,18 +110,4 @@
105 110
     end
106 111
   end
107 112
 
108  
-  context 'custom identity map enabled' do
109  
-    after(:all) do
110  
-      Twitter.identity_map = Twitter::IdentityMap
111  
-    end
112  
-
113  
-    describe '.identity_map' do
114  
-      it 'returns an instance of the custom identity map' do
115  
-        Twitter::Base.identity_map.should be_a Twitter::IdentityMap
116  
-        Twitter.identity_map = Hash
117  
-        Twitter::Base.identity_map.should_not be_a Twitter::IdentityMap
118  
-      end
119  
-    end
120  
-  end
121  
-
122 113
 end
26  spec/twitter/identifiable_spec.rb
@@ -10,16 +10,26 @@
10 10
     end
11 11
   end
12 12
 
13  
-  describe '.fetch' do
14  
-    it 'returns existing objects' do
15  
-      Twitter::Identity.store(Twitter::Identity.new(:id => 1))
16  
-      Twitter::Identity.fetch(:id => 1).should be
  13
+  context 'identity map enabled' do
  14
+    before do
  15
+      Twitter.identity_map = Twitter::IdentityMap
17 16
     end
18 17
 
19  
-    it "raises an error on objects that don't exist" do
20  
-      lambda {
21  
-        Twitter::Identity.fetch(:id => 6)
22  
-      }.should raise_error(Twitter::Error::IdentityMapKeyError)
  18
+    after do
  19
+      Twitter.identity_map = false
  20
+    end
  21
+
  22
+    describe '.fetch' do
  23
+      it 'returns existing objects' do
  24
+        Twitter::Identity.store(Twitter::Identity.new(:id => 1))
  25
+        Twitter::Identity.fetch(:id => 1).should be
  26
+      end
  27
+
  28
+      it "raises an error on objects that don't exist" do
  29
+        lambda {
  30
+          Twitter::Identity.fetch(:id => 6)
  31
+        }.should raise_error(Twitter::Error::IdentityMapKeyError)
  32
+      end
23 33
     end
24 34
   end
25 35
 

0 notes on commit c6c5960

Please sign in to comment.
Something went wrong with that request. Please try again.