From: Kevin Clark Date: Wed, 18 Jun 2008 01:11:18 +0000 (+0000) Subject: Spec out HTTPClient X-Git-Tag: 0.2.0~580 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=dd330253ae03579fba90b87be7944f58d8394959;p=common%2Fthrift.git Spec out HTTPClient git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668970 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/rb/spec/httpclient_spec.rb b/lib/rb/spec/httpclient_spec.rb new file mode 100644 index 00000000..67fb0697 --- /dev/null +++ b/lib/rb/spec/httpclient_spec.rb @@ -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