Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add additional Spec examples for Yql::QueryBuilder#find_all

and expanded comments on the method
  • Loading branch information...
commit 9d2becad7bf18ef1d286b4b449e7bbf6676ba40a 1 parent 3aeb237
nas authored
Showing with 33 additions and 7 deletions.
  1. +2 −1  lib/yql/query_builder.rb
  2. +31 −6 spec/yql/query_builder_spec.rb
View
3  lib/yql/query_builder.rb
@@ -43,7 +43,8 @@ def find
# Can be optionally passed a limit for limiting the number of records returned
# object.find_all(:limit => 10)
# #=> will return only 10 records
- #
+ # object.find_all
+ # #=> will return all records
def find_all(args = {})
self.limit = args[:limit] || nil
construct_query
View
37 spec/yql/query_builder_spec.rb
@@ -66,14 +66,39 @@
@query_builder.stub!(:construct_query).and_return('The yql query')
end
- it "should set the limit of records to nil" do
- @query_builder.should_receive(:limit=).with(nil)
- @query_builder.find_all
+ context "when parameter hash has limit key" do
+
+ it "should set the limit with provided value" do
+ @query_builder.should_receive(:limit=).with(10)
+ @query_builder.find_all({:limit => 10})
+ end
+
+ it "should set attr reader limit with value 10" do
+ @query_builder.find_all({:limit => 10})
+ @query_builder.limit.should eql('limit 10')
+ end
+
end
- it "should set the with provided hash" do
- @query_builder.should_receive(:limit=).with(10)
- @query_builder.find_all({:limit => 10})
+ context "when parameter hash does not have limit key" do
+
+ it "should set the limit of records to nil" do
+ @query_builder.should_receive(:limit=).with(nil)
+ @query_builder.find_all
+ end
+
+ it "should set attr reader limit to nil" do
+ @query_builder.find_all
+ @query_builder.limit.should be_nil
+ end
+
+ it "should set attr reader limit to nil even if it was set previously" do
+ @query_builder.limit = 20
+ @query_builder.limit.should eql('limit 20')
+ @query_builder.find_all
+ @query_builder.limit.should be_nil
+ end
+
end
it "should construct the query" do
Please sign in to comment.
Something went wrong with that request. Please try again.