Skip to content
Browse files

Update expected example.com behavior

IANA has recently changed http://example.com/ to redirect to
http://iana.org/domain/example instead of serving a proper page. As
WebMock specs rely on old example.com behavior, this change caused a
major test breakage.

This commit forces specs to expect a "302 Found" response from
example.com
  • Loading branch information...
1 parent cd68c86 commit 0e5360b19672ed18f50c508291d50d6aa0faf268 @grig grig committed Mar 5, 2011
Showing with 10 additions and 11 deletions.
  1. +3 −3 spec/net_http_spec.rb
  2. +2 −2 spec/spec_helper.rb
  3. +5 −6 spec/webmock_shared.rb
View
6 spec/net_http_spec.rb
@@ -57,7 +57,7 @@
req = Net::HTTP::Post.new("/")
Net::HTTP.start("www.example.com") {|http|
http.request(req, StringIO.new("my_params"))
- }.body.should =~ /Example Web Page/
+ }.body.should =~ /^$/
end
it "should handle requests with block passed to read_body", :net_connect => true do
@@ -71,7 +71,7 @@
end
end
end
- body.should =~ /Example Web Page/
+ body.should =~ /^$/
end
it "should return a Net::ReadAdapter from response.body when a stubbed request is made with a block and #read_body" do
@@ -128,7 +128,7 @@
end
describe 'after_request callback support', :net_connect => true do
- let(:expected_body_regex) { /You have reached this web page by typing.*example\.com/ }
+ let(:expected_body_regex) { /^$/ }
before(:each) do
WebMock.allow_net_connect!
View
4 spec/spec_helper.rb
@@ -42,8 +42,8 @@ def should_pass
def setup_expectations_for_real_example_com_request(options = {})
defaults = { :host => "www.example.com", :port => 80, :method => "GET",
:path => "/",
- :response_code => 200, :response_message => "OK",
- :response_body => "<title>example</title>" }
+ :response_code => 302, :response_message => "Found",
+ :response_body => "" }
setup_expectations_for_real_request(defaults.merge(options))
end
View
11 spec/webmock_shared.rb
@@ -4,7 +4,7 @@
SAMPLE_HEADERS = { "Content-Length" => "8888", "Accept" => "application/json" }
ESCAPED_PARAMS = "x=ab%20c&z=%27Stop%21%27%20said%20Fred"
NOT_ESCAPED_PARAMS = "z='Stop!' said Fred&x=ab c"
- WWW_EXAMPLE_COM_CONTENT_LENGTH = 596
+ WWW_EXAMPLE_COM_CONTENT_LENGTH = 0
end
class MyException < StandardError; end;
@@ -33,8 +33,7 @@ class MyException < StandardError; end;
it "should make a real web request if request is not stubbed" do
setup_expectations_for_real_example_com_request
- http_request(:get, "http://www.example.com/").
- body.should =~ /.*example.*/
+ http_request(:get, "http://www.example.com/").status.should == "302"
end
it "should make a real https request if request is not stubbed" do
@@ -128,7 +127,7 @@ class MyException < StandardError; end;
end
it "should allow a real request to allowed host", :net_connect => true do
- http_request(:get, "http://www.example.org/").status.should == "200"
+ http_request(:get, "http://www.example.org/").status.should == "302"
end
end
end
@@ -1493,8 +1492,8 @@ def call(request)
end
it "should pass response with status and message" do
- @response.status[0].should == 200
- @response.status[1].should == "OK"
+ @response.status[0].should == 302
+ @response.status[1].should == "Found"
end
it "should pass response with headers" do

0 comments on commit 0e5360b

Please sign in to comment.
Something went wrong with that request. Please try again.