Sha256: e8fe94f8364bac6837920a27ef7377352c8cadd5ed620df5b4ca340ac2fc0d69
Contents?: true
Size: 1.59 KB
Versions: 4
Compression:
Stored size: 1.59 KB
Contents
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 @resp.response.should be_a(@resp_class) end 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 @method = :get end it_should_behave_like "all requests" end describe "#post" do before do @method = :post end it_should_behave_like "all requests" end describe "#delete" do before do @method = :delete end it_should_behave_like "all requests" end end describe "Typhoeus", URL do before(:all) do require 'typhoeus' URL.req_handler = URL::TyHandler @resp_class = Typhoeus::Response end it_should_behave_like "all builds" end describe "Net::HTTP", URL do before(:all) do require 'net/http' URL.req_handler = URL::NetHandler @resp_class = Net::HTTPResponse end it_should_behave_like "all builds" end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
grape-extra_validators-1.0.0 | vendor/bundle/ruby/2.4.0/gems/url-0.3.2/spec/handler_spec.rb |
url-0.3.2 | spec/handler_spec.rb |
url-0.3.1 | spec/handler_spec.rb |
url-0.3.0 | spec/handler_spec.rb |