File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
spec/unit/spark_api/models Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ def find(*arguments)
8
8
scope = arguments . slice! ( 0 )
9
9
options = arguments . slice! ( 0 ) || { }
10
10
case scope
11
+ when nil then raise ArgumentError , "Argument for find() can't be nil"
11
12
when :all then find_every ( options )
12
13
when :first then find_every ( options ) . first
13
14
when :last then find_every ( options ) . last
Original file line number Diff line number Diff line change @@ -32,4 +32,21 @@ class MyResource < Base
32
32
resource . Id . should eq ( 1 )
33
33
end
34
34
35
+ describe "find" do
36
+
37
+ it "should throw an error if no argument is passed" do
38
+ stub_api_get ( "/my_resource/" , 'finders.json' )
39
+ lambda {
40
+ MyResource . find ( )
41
+ } . should raise_error ( ArgumentError )
42
+ end
43
+
44
+ it "should throw an error when the first argument is nil" do
45
+ stub_api_get ( "/my_resource/" , 'finders.json' , { :_limit => 1 } )
46
+ lambda {
47
+ MyResource . find ( nil , { :_limit => 1 } )
48
+ } . should raise_error ( ArgumentError )
49
+ end
50
+
51
+ end
35
52
end
You can’t perform that action at this time.
0 commit comments