spec/handler_spec.rb in url-0.2.2 vs spec/handler_spec.rb in url-0.3.0

- old
+ new

@@ -1,8 +1,11 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') shared_examples_for "all requests" do + before do + @resp = @url.send(@method) + end it "should work" do @resp.should be_success end it "should have a response of the correct class" do @@ -12,35 +15,49 @@ it "shoudl have all attribures" do @resp.time.should be_a(Float) @resp.code.should be_a(Integer) @resp.url.should be_a(String) end + + it "should not error when making request" do + test_connection_issue(@method) + end + end +def test_connection_issue(sym) + u = URL.new('http://localhost:5280') + resp = nil + expect {resp = u.send(sym)}.to_not raise_error + resp.should_not be_successful + resp.connection_refused.should be true +end + shared_examples_for "all builds" do before do @url = URL.new('http://www.omgpop.com') end describe "#get" do before do - @resp = @url.get + @method = :get end + it_should_behave_like "all requests" end describe "#post" do before do - @resp = @url.post + @method = :post end it_should_behave_like "all requests" end describe "#delete" do before do - @resp = @url.delete + @method = :delete end it_should_behave_like "all requests" end end