Permalink
Browse files

testing xhr? calling

  • Loading branch information...
1 parent ca42f52 commit 07766a757f7add2fac5d2c144fb05db2fe22bbcb xianhua.zhou@gmail.com committed Oct 4, 2009
Showing with 12 additions and 0 deletions.
  1. +6 −0 test/test_http_request.rb
  2. +6 −0 test/web_server.rb
@@ -22,6 +22,12 @@
hr.post(URL + "/method/get").body.should.equal 'No'
end
+ specify "xhr?" do
+ hr.get(:url => URL + "/ajax").body.should.equal 'N'
+ hr.get(:url => URL + "/ajax", :xhr => true).body.should.equal 'Y'
+ hr.get(:url => URL + "/ajax", :ajax => true).body.should.equal 'Y'
+ end
+
specify "available http methods" do
url = URL + '/get-method-name'
hr.get(url).body.should.equal 'GET'
View
@@ -23,6 +23,12 @@
}
end
+ map '/ajax' do
+ run lambda {|env|
+ [200, {'Content-Type' => 'text/html'}, Request.new(env).xhr? ? 'Y' : 'N']
+ }
+ end
+
map '/method/post' do
run lambda {|env|
body = Request.new(env).post? ? 'Yes' : 'No'

0 comments on commit 07766a7

Please sign in to comment.