Permalink
Browse files

fixed POST spec to look for the params in the right place

  • Loading branch information...
1 parent ef7889e commit 96554eb05c5acbfdb195dbaff6b3d135bd792b38 @pauldix pauldix committed Nov 14, 2009
Showing with 21 additions and 21 deletions.
  1. +21 −21 spec/typhoeus/request_spec.rb
@@ -7,68 +7,68 @@
response.code.should == 200
JSON.parse(response.body)["REQUEST_METHOD"].should == "GET"
end
-
+
it "can run a POST synchronously" do
response = Typhoeus::Request.post("http://localhost:3000", :params => {:q => "hi"}, :headers => {:foo => "bar"})
response.code.should == 200
json = JSON.parse(response.body)
json["REQUEST_METHOD"].should == "POST"
- json["QUERY_STRING"].should == "q=hi"
+ json["rack.request.query_hash"]["q"].should == "hi"
end
-
+
it "can run a PUT synchronously" do
response = Typhoeus::Request.put("http://localhost:3000", :params => {:q => "hi"}, :headers => {:foo => "bar"})
response.code.should == 200
JSON.parse(response.body)["REQUEST_METHOD"].should == "PUT"
end
-
+
it "can run a DELETE synchronously" do
response = Typhoeus::Request.delete("http://localhost:3000", :params => {:q => "hi"}, :headers => {:foo => "bar"})
response.code.should == 200
- JSON.parse(response.body)["REQUEST_METHOD"].should == "DELETE"
+ JSON.parse(response.body)["REQUEST_METHOD"].should == "DELETE"
end
end
it "takes url as the first argument" do
Typhoeus::Request.new("http://localhost:3000").url.should == "http://localhost:3000"
end
-
+
it "should parse the host from the url" do
Typhoeus::Request.new("http://localhost:3000/whatever?hi=foo").host.should == "http://localhost:3000"
Typhoeus::Request.new("http://localhost:3000?hi=foo").host.should == "http://localhost:3000"
Typhoeus::Request.new("http://localhost:3000").host.should == "http://localhost:3000"
end
-
+
it "takes method as an option" do
Typhoeus::Request.new("http://localhost:3000", :method => :get).method.should == :get
end
-
+
it "takes headers as an option" do
headers = {:foo => :bar}
request = Typhoeus::Request.new("http://localhost:3000", :headers => headers)
request.headers.should == headers
end
-
+
it "takes params as an option and adds them to the url" do
Typhoeus::Request.new("http://localhost:3000", :params => {:foo => "bar"}).url.should == "http://localhost:3000?foo=bar"
end
-
+
it "takes request body as an option" do
Typhoeus::Request.new("http://localhost:3000", :body => "whatever").body.should == "whatever"
end
-
+
it "takes timeout as an option" do
Typhoeus::Request.new("http://localhost:3000", :timeout => 10).timeout.should == 10
end
-
+
it "takes cache_timeout as an option" do
Typhoeus::Request.new("http://localhost:3000", :cache_timeout => 60).cache_timeout.should == 60
end
-
+
it "has the associated response object" do
request = Typhoeus::Request.new("http://localhost:3000")
request.response = :foo
- request.response.should == :foo
+ request.response.should == :foo
end
it "has an on_complete handler that is called when the request is completed" do
@@ -81,7 +81,7 @@
request.call_handlers
foo.should == :bar
end
-
+
it "has an on_complete setter" do
foo = nil
proc = Proc.new {|response| foo = response}
@@ -91,7 +91,7 @@
request.call_handlers
foo.should == :bar
end
-
+
it "stores the handled response that is the return value from the on_complete block" do
request = Typhoeus::Request.new("http://localhost:3000")
request.on_complete do |response|
@@ -101,7 +101,7 @@
request.call_handlers
request.handled_response.should == "handled"
end
-
+
it "has an after_complete handler that recieves what on_complete returns" do
request = Typhoeus::Request.new("http://localhost:3000")
request.on_complete do |response|
@@ -114,7 +114,7 @@
request.call_handlers
good.should be_true
end
-
+
it "has an after_complete setter" do
request = Typhoeus::Request.new("http://localhost:3000")
request.on_complete do |response|
@@ -123,14 +123,14 @@
good = nil
proc = Proc.new {|object| good = object == "handled"}
request.after_complete = proc
-
+
request.call_handlers
good.should be_true
end
-
+
describe "retry" do
it "should take a retry option"
it "should count the number of times a request has failed"
end
-
+
end

0 comments on commit 96554eb

Please sign in to comment.