2016-06-09 9 views
0

나는이 오류가 :는 RSpec에와 WebMock : 다음 테스트를 실행하면 무시 요청

spec_helper.rb :

require 'webmock/rspec' 
require 'capybara/rspec' 
require 'factory_girl_rails' 

WebMock.disable_net_connect!(allow_localhost: true) 
RSpec.configure do |config| 
    config.before(:each) do 
    stub_request(:any, "https://api.travis-ci.org/") 
     .with(:headers => {'Accept'=>'application/vnd.travis-ci.2+json', 'User-Agent'=>'Travis/1.8.2 (Mac OS X 10.11.4 like Darwin; Ruby 2.3.1-p112; RubyGems 2.5.1) Faraday/0.9.2 Typhoeus/0.8.0'}) 
     .to_return(:status => 200, :body => "", :headers => {}) 
    end 
end 
나는이 문제를 해결하기 위해 무슨 짓을했는지

/gems/[email protected]/gems/webmock-2.1.0/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb:166:in `block in <class:TyphoeusAdapter>': Real HTTP connections are disabled. Unregistered request: HEAD https://api.travis-ci.org/ with headers {'Accept'=>'application/vnd.travis-ci.2+json', 'User-Agent'=>'Travis/1.8.2 (Mac OS X 10.11.4 like Darwin; Ruby 2.3.1-p112; RubyGems 2.5.1) Faraday/0.9.2 Typhoeus/0.8.0'} (WebMock::NetConnectNotAllowedError) 

You can stub this request with the following snippet: 

stub_request(:head, "https://api.travis-ci.org/"). 
    with(:headers => {'Accept'=>'application/vnd.travis-ci.2+json', 'User-Agent'=>'Travis/1.8.2 (Mac OS X 10.11.4 like Darwin; Ruby 2.3.1-p112; RubyGems 2.5.1) Faraday/0.9.2 Typhoeus/0.8.0'}). 
    to_return(:status => 200, :body => "", :headers => {}) 

하지만이 오류가 계속 발생합니다. 문제를 해결하는 방법에 대한 아이디어가 있습니까?

UPD :webmock gem을 사용하여 API 요청에 대한 사양을 작성하고 싶습니다. 하지만 travis-ci의 요청이 필요하지 않으며 이러한 요청을 '무시'에 추가하려고합니다.

WebMock.disable_net_connect!(:allow => 'api.travis-ci.org') 
+0

당신이 우리에게 컨텍스트를 줄 수 : –

+0

어떤 종류의 컨텍스트? 나는'webmock' 보석을 가지고 있는데, 나는이 트래비스의 요청을 무시하고 싶습니다. 나는이 요청을 무시하기위한 "규칙"을 올바르게 추가했다고 생각합니다. –

+0

난 단지 당신이 뭘하고 싶은지, 어떤 기술과 당신이 시도했는지를 설명하는 서한을 요구하고 있습니다. Beacuse는 "테스트"로 시작하고 있으며 컨텍스트가 무엇인지 전혀 알지 못합니다. 게시물에이 업데이트를 적용하면 사람들이 이해할 수 있으며 커뮤니티에서 여러 가지 답변을 얻을 수 있습니다.). –

답변

0

그것은 내 문제를 해결?