Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adjusted expectations

  • Loading branch information...
commit 2d777901d3b03506075395fd6678e8e515b499c4 1 parent 46a0e14
@moonglum moonglum authored
Showing with 20 additions and 28 deletions.
  1. +20 −28 spec/unit/query_spec.rb
View
48 spec/unit/query_spec.rb
@@ -15,9 +15,7 @@
describe "get all" do
it "should list all documents" do
- collection.stub(:send_request).with("/simple/all",
- put: {"collection" => "example_1"}
- ).and_return { server_response('simple-queries/all') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/all') }
collection.should_receive(:send_request).with("/simple/all", put: {"collection" => "example_1"})
Ashikawa::Core::Cursor.should_receive(:new)
@@ -26,7 +24,7 @@
end
it "should be able to limit the number of documents" do
- collection.stub(:send_request).with("/simple/all", put: {"collection" => "example_1", "limit" => 1}).and_return { server_response('simple-queries/all_skip') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/all_skip') }
collection.should_receive(:send_request).with("/simple/all", put: {"collection" => "example_1", "limit" => 1})
Ashikawa::Core::Cursor.should_receive(:new)
@@ -35,7 +33,7 @@
end
it "should be able to skip documents" do
- collection.stub(:send_request).with("/simple/all", put: {"collection" => "example_1", "skip" => 1}).and_return { server_response('simple-queries/all_limit') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/all_limit') }
collection.should_receive(:send_request).with("/simple/all", put: {"collection" => "example_1", "skip" => 1})
Ashikawa::Core::Cursor.should_receive(:new)
@@ -50,9 +48,7 @@
it "should find exactly one fitting document" do
collection.stub(:database).and_return { double }
- collection.stub(:send_request).with("/simple/first-example", put:
- {"collection" => "example_1", "example" => { :hello => "world"}}
- ).and_return { server_response('simple-queries/example') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/example') }
collection.should_receive(:send_request).with("/simple/first-example", put:
{"collection" => "example_1", "example" => { :hello => "world"}})
@@ -66,9 +62,7 @@
let(:example) { {:hello => "world"} }
it "should find all fitting documents" do
- collection.stub(:send_request).with("/simple/by-example", put:
- {"collection" => "example_1", "example" => { :hello => "world"}}
- ).and_return { server_response('simple-queries/example') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/example') }
collection.should_receive(:send_request).with("/simple/by-example", put:
{"collection" => "example_1", "example" => { :hello => "world"}})
@@ -78,7 +72,7 @@
end
it "should be able to limit the number of documents" do
- collection.stub(:send_request).with("/simple/by-example", put: {"collection" => "example_1", "limit" => 2, "example" => { :hello => "world"}}).and_return { server_response('simple-queries/example') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/example') }
collection.should_receive(:send_request).with("/simple/by-example", put: {"collection" => "example_1", "limit" => 2, "example" => { :hello => "world"}})
Ashikawa::Core::Cursor.should_receive(:new)
@@ -87,9 +81,7 @@
end
it "should be able to skip documents" do
- collection.stub(:send_request).with("/simple/by-example", put:
- {"collection" => "example_1", "skip" => 1, "example" => { :hello => "world"}}
- ).and_return { server_response('simple-queries/example') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/example') }
collection.should_receive(:send_request).with("/simple/by-example", put:
{"collection" => "example_1", "skip" => 1, "example" => { :hello => "world"}})
@@ -101,7 +93,7 @@
describe "near a geolocation" do
it "should find documents based on latitude/longitude" do
- collection.stub(:send_request).with("/simple/near", put: { "collection" => "example_1", "latitude" => 0, "longitude" => 0 }).and_return { server_response('simple-queries/near') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/near') }
collection.should_receive(:send_request).with("/simple/near", put: { "collection" => "example_1", "latitude" => 0, "longitude" => 0 })
Ashikawa::Core::Cursor.should_receive(:new)
@@ -112,7 +104,7 @@
describe "within a radious of a geolocation" do
it "should look for documents based on latidude/longitude" do
- collection.stub(:send_request).with("/simple/within", put: { "collection" => "example_1", "latitude" => 0, "longitude" => 0, "radius" => 2 }).and_return { server_response('simple-queries/within') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/within') }
collection.should_receive(:send_request).with("/simple/within" , put: { "collection" => "example_1", "latitude" => 0, "longitude" => 0, "radius" => 2 })
Ashikawa::Core::Cursor.should_receive(:new)
@@ -124,7 +116,7 @@
describe "in a certain range" do
it "should look for documents with an attribute in that range" do
arguments = { "collection" => "example_1", "attribute" => "age", "left" => 50, "right" => 60, "closed" => false}
- collection.stub(:send_request).with("/simple/range", put: arguments).and_return { server_response('simple-queries/range') }
+ collection.stub(:send_request).and_return { server_response('simple-queries/range') }
collection.should_receive(:send_request).with("/simple/range" , put: arguments)
Ashikawa::Core::Cursor.should_receive(:new)
@@ -138,9 +130,9 @@
collection.stub(:database).and_return double
collection.stub(:send_request).and_return { server_response("cursor/query") }
collection.should_receive(:send_request).with("/cursor", post: {
- query: "FOR u IN users LIMIT 2 RETURN u",
- count: true,
- batchSize: 2
+ "query" => "FOR u IN users LIMIT 2 RETURN u",
+ "count" => true,
+ "batchSize" => 2
})
Ashikawa::Core::Cursor.should_receive(:new).with(collection.database, server_response("cursor/query"))
@@ -152,7 +144,7 @@
collection.stub(:send_request).and_return { server_response("query/valid") }
collection.should_receive(:send_request).with("/query", post: {
- query: query
+ "query" => query
})
subject.valid?(query).should be_true
@@ -165,7 +157,7 @@
raise RestClient::BadRequest
end
collection.should_receive(:send_request).with("/query", post: {
- query: query
+ "query" => query
})
subject.valid?(query).should be_false
@@ -186,9 +178,9 @@
it "should be able to execute it" do
database.stub(:send_request).and_return { server_response("cursor/query") }
database.should_receive(:send_request).with("/cursor", post: {
- query: "FOR u IN users LIMIT 2 RETURN u",
- count: true,
- batchSize: 2
+ "query" => "FOR u IN users LIMIT 2 RETURN u",
+ "count" => true,
+ "batchSize" => 2
})
Ashikawa::Core::Cursor.should_receive(:new).with(database, server_response("cursor/query"))
@@ -200,7 +192,7 @@
database.stub(:send_request).and_return { server_response("query/valid") }
database.should_receive(:send_request).with("/query", post: {
- query: query
+ "query" => query
})
subject.valid?(query).should be_true
@@ -213,7 +205,7 @@
raise RestClient::BadRequest
end
database.should_receive(:send_request).with("/query", post: {
- query: query
+ "query" => query
})
subject.valid?(query).should be_false
Please sign in to comment.
Something went wrong with that request. Please try again.