Skip to content

Commit e806bc5

Browse files
committed
Reorganized the specs
1 parent 6843c27 commit e806bc5

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

spec/rack/reverse_proxy_spec.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def dummy_app
1212
lambda { [200, {}, ['Dummy App']] }
1313
end
1414

15-
1615
describe "as middleware" do
1716
def app
1817
Rack::ReverseProxy.new(dummy_app) do
@@ -32,6 +31,18 @@ def app
3231
last_response.body.should == "Proxied App"
3332
end
3433

34+
it "the response header should never contain Status" do
35+
stub_request(:any, 'example.com/test/stuff').to_return(:headers => {'Status' => '200 OK'})
36+
get '/test/stuff'
37+
last_response.headers['Status'].should == nil
38+
end
39+
40+
it "should set the Host header" do
41+
stub_request(:any, 'example.com/test/stuff')
42+
get '/test/stuff'
43+
a_request(:get, 'http://example.com/test/stuff').with(:headers => {"Host" => "example.com"}).should have_been_made
44+
end
45+
3546
describe "with ambiguous routes" do
3647
def app
3748
Rack::ReverseProxy.new(dummy_app) do
@@ -66,11 +77,12 @@ def app
6677
end
6778
end
6879

69-
it "should rewrite HOST" do
70-
stub_request(:get, 'https://example.com/test/stuff').with(:headers => {"Host" => "example.com"}).to_return({:body => "Proxied App"})
80+
it "should make a secure request" do
81+
stub_request(:get, 'https://example.com/test/stuff').to_return({:body => "Proxied Secure App"})
7182
get '/test/stuff'
72-
last_response.body.should == "Proxied App"
83+
last_response.body.should == "Proxied Secure App"
7384
end
85+
7486
end
7587

7688
describe "with a route as a string" do

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require 'rubygems'
77
require 'rack/test'
88
require 'webmock'
9+
require 'webmock/rspec'
910

1011
Spec::Runner.configure do |config|
1112
WebMock.disable_net_connect!

0 commit comments

Comments
 (0)