Skip to content

Commit 512a29b

Browse files
committed
Merge pull request #8 from joliss/spec
Fix :preserve_host spec
2 parents 91dae03 + 8195c78 commit 512a29b

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

spec/rack/reverse_proxy_spec.rb

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,35 @@ def app
3838
last_response.body.should == "Proxied App2"
3939
end
4040

41-
it "the response header should never contain Status" do
42-
stub_request(:any, 'example.com/test/stuff').to_return(:headers => {'Status' => '200 OK'})
43-
get '/test/stuff'
44-
last_response.headers['Status'].should == nil
45-
end
46-
47-
it "the response header should never transfer-encoding" do
48-
stub_request(:any, 'example.com/test/stuff').to_return(:headers => {'transfer-encoding' => 'Chunked'})
49-
get '/test/stuff'
50-
last_response.headers['transfer-encoding'].should == nil
51-
end
52-
53-
it "should set the Host header" do
54-
stub_request(:any, 'example.com/test/stuff')
55-
get '/test/stuff'
56-
a_request(:get, 'http://example.com/test/stuff').with(:headers => {"Host" => "example.com"}).should have_been_made
57-
end
41+
it "the response header should never contain Status" do
42+
stub_request(:any, 'example.com/test/stuff').to_return(:headers => {'Status' => '200 OK'})
43+
get '/test/stuff'
44+
last_response.headers['Status'].should == nil
45+
end
46+
47+
it "the response header should never transfer-encoding" do
48+
stub_request(:any, 'example.com/test/stuff').to_return(:headers => {'transfer-encoding' => 'Chunked'})
49+
get '/test/stuff'
50+
last_response.headers['transfer-encoding'].should == nil
51+
end
52+
53+
it "should set the Host header" do
54+
stub_request(:any, 'example.com/test/stuff')
55+
get '/test/stuff'
56+
a_request(:get, 'http://example.com/test/stuff').with(:headers => {"Host" => "example.com"}).should have_been_made
57+
end
5858

5959
describe "with preserve host turned off" do
6060
def app
6161
Rack::ReverseProxy.new(dummy_app) do
62-
reverse_proxy '/test', 'http://example.com/'
62+
reverse_proxy '/test', 'http://example.com/', {:preserve_host => false}
6363
end
6464
end
6565

6666
it "should not set the Host header" do
6767
stub_request(:any, 'example.com/test/stuff')
6868
get '/test/stuff'
69+
a_request(:get, 'http://example.com/test/stuff').with(:headers => {"Host" => "example.com"}).should_not have_been_made
6970
a_request(:get, 'http://example.com/test/stuff').should have_been_made
7071
end
7172
end
@@ -108,9 +109,9 @@ def app
108109
end
109110

110111
it "should throw an exception" do
111-
stub_request(:get, 'http://example1.com/test').to_return({:body => "Proxied App"})
112-
get '/test'
113-
last_response.body.should == "Proxied App"
112+
stub_request(:get, 'http://example1.com/test').to_return({:body => "Proxied App"})
113+
get '/test'
114+
last_response.body.should == "Proxied App"
114115
end
115116
end
116117

@@ -128,20 +129,20 @@ def app
128129
end
129130
end
130131

131-
describe "with a https route" do
132+
describe "with a https route" do
132133
def app
133134
Rack::ReverseProxy.new(dummy_app) do
134135
reverse_proxy '/test', 'https://example.com'
135136
end
136137
end
137138

138-
it "should make a secure request" do
139+
it "should make a secure request" do
139140
stub_request(:get, 'https://example.com/test/stuff').to_return({:body => "Proxied Secure App"})
140141
get '/test/stuff'
141142
last_response.body.should == "Proxied Secure App"
142-
end
143+
end
143144

144-
end
145+
end
145146

146147
describe "with a route as a string" do
147148
def app

0 commit comments

Comments
 (0)