-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhttpsender_spec.rb
More file actions
35 lines (32 loc) · 1.2 KB
/
httpsender_spec.rb
File metadata and controls
35 lines (32 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require File.dirname(__FILE__) + '/../lib/pswincom/httpsender'
require File.dirname(__FILE__) + '/mocks'
require 'rubygems'
require 'rspec'
module PSWinCom
describe HttpSender do
describe "#initialize" do
it "uses default host" do
# HttpSender.new.instance_variable_get(:@host).should == 'http://gw2-fro.pswin.com:81/'
expect(HttpSender.new.instance_variable_get(:@host)).to eq 'http://xml.pswin.com/'
end
it "uses custom host if specified" do
API.api_host = 'http://google.com/'
HttpSender.new.instance_variable_get(:@host).should == 'http://google.com/'
end
end
describe "#send" do
it "sends to specified host and port" do
API.api_host = 'http://server.com:8081/'
HttpSender.new.send(XmlMock.new(""))
Net::HTTP.host.should == "server.com"
Net::HTTP.port.should == 8081
end
it "sends XML with correct content type" do
post = HttpSender.new.send(XmlMock.new("<xml>foo</xml>"))
post.body.should == "<xml>foo</xml>"
# post.content_type.should == 'text/xml charset=ISO-8859-1'
expect(post.content_type).to eq 'application/xml charset=utf-8'
end
end
end
end