public
Fork of yrashk/strokedb
Description: StrokeDB is a lightweight approach to document-oriented database, currently featuring pure Ruby/JRuby implementation.
Homepage: http://groups.google.com/group/strokedb
Clone URL: git://github.com/tmm1/strokedb.git
Minor Document#find tweaking
yrashk (author)
Sat Apr 19 03:37:00 -0700 2008
commit  3184e7d03e9ff30b9914904a52660a9929e70cb0
tree    b25b98647a91179add6ebbf6d0127879d038f04f
parent  35542863a55e54446471d4f9546e1371eb0232ce
...
352
353
354
355
 
356
357
358
...
366
367
368
369
 
370
371
372
...
352
353
354
 
355
356
357
358
...
366
367
368
 
369
370
371
372
0
@@ -352,7 +352,7 @@ module StrokeDB
0
       if (txns = Thread.current[:strokedb_transactions]) && !txns.nil? && !txns.empty?
0
         store = txns.last
0
       else
0
- if args.empty? || args.first.is_a?(String) || args.first.is_a?(Hash)
0
+ if args.empty? || args.first.is_a?(String) || args.first.is_a?(Hash) || args.first.nil?
0
           store = StrokeDB.default_store
0
         else
0
           store = args.shift
0
@@ -366,7 +366,7 @@ module StrokeDB
0
       when Hash
0
         store.search(query)
0
       else
0
- raise TypeError
0
+ raise ArgumentError, "use UUID or query to find document(s)"
0
       end
0
     end
0
 
...
19
20
21
22
 
23
24
 
 
 
25
26
27
...
19
20
21
 
22
23
 
24
25
26
27
28
29
0
@@ -19,9 +19,11 @@ describe "Document class" do
0
     Document.find(@store, :uuid => @document.uuid).should == [@document]
0
   end
0
 
0
- it "should raise TypeError when find with wrong argument" do
0
+ it "should raise ArgumentError when invoking #find with wrong argument" do
0
     @document = Document.create!
0
- lambda { Document.find([]) }.should raise_error(TypeError)
0
+ [ [], nil, 1 ].each do |arg|
0
+ lambda { Document.find(arg) }.should raise_error(ArgumentError)
0
+ end
0
   end
0
   
0
 end

Comments

    No one has commented yet.