Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

When environment variable NO_CONNECTION is set, rspec only runs examp…

…les which do not make real network connections
  • Loading branch information...
commit 161225c1b201b805965d231002785fb75dbb6d63 1 parent e4a3b6b
@bblimke authored
View
8 spec/net_http_spec.rb
@@ -52,7 +52,7 @@
}.should raise_error("both of body argument and HTTPRequest#body set")
end
- it "should handle real requests with readable body" do
+ it "should handle real requests with readable body", :net_connect => true do
WebMock.allow_net_connect!
req = Net::HTTP::Post.new("/")
Net::HTTP.start("www.example.com") {|http|
@@ -60,7 +60,7 @@
}.body.should =~ /Example Web Page/
end
- it "should handle requests with block passed to read_body" do
+ it "should handle requests with block passed to read_body", :net_connect => true do
body = ""
WebMock.allow_net_connect!
req = Net::HTTP::Get.new("/")
@@ -80,13 +80,13 @@
response.body.should be_a(Net::ReadAdapter)
end
- it "should return a Net::ReadAdapter from response.body when a real request is made with a block and #read_body" do
+ it "should return a Net::ReadAdapter from response.body when a real request is made with a block and #read_body", :net_connect => true do
WebMock.allow_net_connect!
response = Net::HTTP.new('example.com', 80).request_get('/') { |r| r.read_body { } }
response.body.should be_a(Net::ReadAdapter)
end
- describe 'after_request callback support' do
+ describe 'after_request callback support', :net_connect => true do
let(:expected_body_regex) { /You have reached this web page by typing.*example\.com/ }
before(:each) do
View
5 spec/spec_helper.rb
@@ -15,7 +15,10 @@
require 'json'
RSpec.configure do |config|
- config.include WebMock::API
+ config.include WebMock::API
+ if ENV["NO_CONNECTION"]
+ config.filter_run_excluding :net_connect => true
+ end
end
def fail()
View
10 spec/webmock_shared.rb
@@ -26,7 +26,7 @@ class MyException < StandardError; end;
describe "when web connect" do
- describe "is allowed" do
+ describe "is allowed", :net_connect => true do
before(:each) do
WebMock.allow_net_connect!
end
@@ -122,7 +122,7 @@ class MyException < StandardError; end;
}.should raise_error(WebMock::NetConnectNotAllowedError, client_specific_request_string("Real HTTP connections are disabled. Unregistered request: GET http://www.example.com/"))
end
- it "should allow a real request to allowed host" do
+ it "should allow a real request to allowed host", :net_connect => true do
http_request(:get, "http://www.example.org/").status.should == "200"
end
end
@@ -1381,7 +1381,7 @@ def call(request)
end
- describe "when net connect allowed" do
+ describe "when net connect allowed", :net_connect => true do
before(:each) do
WebMock.allow_net_connect!
end
@@ -1485,7 +1485,7 @@ def call(request)
end
- describe "for real requests" do
+ describe "for real requests", :net_connect => true do
before(:each) do
WebMock.reset_webmock
WebMock.allow_net_connect!
@@ -1519,7 +1519,7 @@ def call(request)
@called.should == 2
end
- it "should invoke callbacks only for real requests if requested" do
+ it "should invoke callbacks only for real requests if requested", :net_connect => true do
WebMock.after_request(:real_requests_only => true) { @called = true }
http_request(:get, "http://www.example.com/")
@called.should == nil
Please sign in to comment.
Something went wrong with that request. Please try again.