You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/06/18 03:11:18 UTC
svn commit: r668970 - /incubator/thrift/trunk/lib/rb/spec/httpclient_spec.rb
Author: kclark
Date: Tue Jun 17 18:11:18 2008
New Revision: 668970
URL: http://svn.apache.org/viewvc?rev=668970&view=rev
Log:
Spec out HTTPClient
Added:
incubator/thrift/trunk/lib/rb/spec/httpclient_spec.rb
Added: incubator/thrift/trunk/lib/rb/spec/httpclient_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/httpclient_spec.rb?rev=668970&view=auto
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/httpclient_spec.rb (added)
+++ incubator/thrift/trunk/lib/rb/spec/httpclient_spec.rb Tue Jun 17 18:11:18 2008
@@ -0,0 +1,30 @@
+require File.dirname(__FILE__) + '/spec_helper'
+require 'thrift/transport/httpclient'
+
+class ThriftHTTPClientSpec < Spec::ExampleGroup
+ include Thrift
+
+ describe HTTPClient do
+ before(:each) do
+ @client = HTTPClient.new("http://my.domain.com/path/to/service")
+ end
+
+ it "should always be open" do
+ @client.should be_open
+ @client.close
+ @client.should be_open
+ end
+
+ it "should post via HTTP and return the results" do
+ @client.write "a test"
+ @client.write " frame"
+ Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
+ mock("Net::HTTP").tee do |http|
+ http.should_receive(:post).with("/path/to/service", "a test frame").and_return([nil, "data"])
+ end
+ end
+ @client.flush
+ @client.read(10).should == "data"
+ end
+ end
+end