THRIFT-4342: update ruby tests to use rspec 3, updated all dependencies for ruby
Client: rb
diff --git a/lib/rb/spec/http_client_spec.rb b/lib/rb/spec/http_client_spec.rb
index 70747ed..df472ab 100644
--- a/lib/rb/spec/http_client_spec.rb
+++ b/lib/rb/spec/http_client_spec.rb
@@ -31,26 +31,26 @@
end
it "should always be open" do
- @client.should be_open
+ expect(@client).to be_open
@client.close
- @client.should be_open
+ expect(@client).to 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").tap do |http|
- http.should_receive(:use_ssl=).with(false)
- http.should_receive(:post).with("/path/to/service?param=value", "a test frame", {"Content-Type"=>"application/x-thrift"}).and_return do
- mock("Net::HTTPOK").tap do |response|
- response.should_receive(:body).and_return "data"
+ expect(Net::HTTP).to receive(:new).with("my.domain.com", 80) do
+ double("Net::HTTP").tap do |http|
+ expect(http).to receive(:use_ssl=).with(false)
+ expect(http).to receive(:post).with("/path/to/service?param=value", "a test frame", {"Content-Type"=>"application/x-thrift"}) do
+ double("Net::HTTPOK").tap do |response|
+ expect(response).to receive(:body).and_return "data"
end
end
end
end
@client.flush
- @client.read(10).should == "data"
+ expect(@client.read(10)).to eq("data")
end
it "should send custom headers if defined" do
@@ -59,12 +59,12 @@
headers = {"Content-Type"=>"application/x-thrift"}.merge(custom_headers)
@client.add_headers(custom_headers)
- Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
- mock("Net::HTTP").tap do |http|
- http.should_receive(:use_ssl=).with(false)
- http.should_receive(:post).with("/path/to/service?param=value", "test", headers).and_return do
- mock("Net::HTTPOK").tap do |response|
- response.should_receive(:body).and_return "data"
+ expect(Net::HTTP).to receive(:new).with("my.domain.com", 80) do
+ double("Net::HTTP").tap do |http|
+ expect(http).to receive(:use_ssl=).with(false)
+ expect(http).to receive(:post).with("/path/to/service?param=value", "test", headers) do
+ double("Net::HTTPOK").tap do |response|
+ expect(response).to receive(:body).and_return "data"
end
end
end
@@ -75,15 +75,15 @@
it 'should reset the outbuf on HTTP failures' do
@client.write "test"
- Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
- mock("Net::HTTP").tap do |http|
- http.should_receive(:use_ssl=).with(false)
- http.should_receive(:post).with("/path/to/service?param=value", "test", {"Content-Type"=>"application/x-thrift"}) { raise Net::ReadTimeout }
+ expect(Net::HTTP).to receive(:new).with("my.domain.com", 80) do
+ double("Net::HTTP").tap do |http|
+ expect(http).to receive(:use_ssl=).with(false)
+ expect(http).to receive(:post).with("/path/to/service?param=value", "test", {"Content-Type"=>"application/x-thrift"}) { raise Net::ReadTimeout }
end
end
@client.flush rescue
- @client.instance_variable_get(:@outbuf).should eq(Thrift::Bytes.empty_byte_buffer)
+ expect(@client.instance_variable_get(:@outbuf)).to eq(Thrift::Bytes.empty_byte_buffer)
end
end
@@ -99,20 +99,20 @@
client.write "test"
- Net::HTTP.should_receive(:new).with("my.domain.com", 443).and_return do
- mock("Net::HTTP").tap do |http|
- http.should_receive(:use_ssl=).with(true)
- http.should_receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
- http.should_receive(:post).with(@service_path, "test",
- "Content-Type" => "application/x-thrift").and_return do
- mock("Net::HTTPOK").tap do |response|
- response.should_receive(:body).and_return "data"
+ expect(Net::HTTP).to receive(:new).with("my.domain.com", 443) do
+ double("Net::HTTP").tap do |http|
+ expect(http).to receive(:use_ssl=).with(true)
+ expect(http).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
+ expect(http).to receive(:post).with(@service_path, "test",
+ "Content-Type" => "application/x-thrift") do
+ double("Net::HTTPOK").tap do |response|
+ expect(response).to receive(:body).and_return "data"
end
end
end
end
client.flush
- client.read(4).should == "data"
+ expect(client.read(4)).to eq("data")
end
it "should set SSL verify mode when specified" do
@@ -120,20 +120,20 @@
:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE)
client.write "test"
- Net::HTTP.should_receive(:new).with("my.domain.com", 443).and_return do
- mock("Net::HTTP").tap do |http|
- http.should_receive(:use_ssl=).with(true)
- http.should_receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE)
- http.should_receive(:post).with(@service_path, "test",
- "Content-Type" => "application/x-thrift").and_return do
- mock("Net::HTTPOK").tap do |response|
- response.should_receive(:body).and_return "data"
+ expect(Net::HTTP).to receive(:new).with("my.domain.com", 443) do
+ double("Net::HTTP").tap do |http|
+ expect(http).to receive(:use_ssl=).with(true)
+ expect(http).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE)
+ expect(http).to receive(:post).with(@service_path, "test",
+ "Content-Type" => "application/x-thrift") do
+ double("Net::HTTPOK").tap do |response|
+ expect(response).to receive(:body).and_return "data"
end
end
end
end
client.flush
- client.read(4).should == "data"
+ expect(client.read(4)).to eq("data")
end
end
end