Permalink
Browse files

Indent files correctly and remove trailing whitespace

This makes it much easier moving using motions and editing files in a
number of editors.
  • Loading branch information...
1 parent b986955 commit a251cb3657cd2032c8c03f02108a1bce9113e72b @jcf jcf committed May 28, 2011
Showing with 399 additions and 397 deletions.
  1. +118 −118 CHANGELOG.md
  2. +1 −1 Gemfile
  3. +1 −1 LICENSE
  4. +3 −3 lib/webmock/api.rb
  5. +1 −1 lib/webmock/assertion_failure.rb
  6. +1 −1 lib/webmock/callback_registry.rb
  7. +2 −2 lib/webmock/config.rb
  8. +1 −1 lib/webmock/cucumber.rb
  9. +2 −2 lib/webmock/errors.rb
  10. +9 −9 lib/webmock/http_lib_adapters/curb.rb
  11. +6 −6 lib/webmock/http_lib_adapters/httpclient.rb
  12. +4 −4 lib/webmock/http_lib_adapters/net_http.rb
  13. +2 −2 lib/webmock/http_lib_adapters/net_http_response.rb
  14. +3 −3 lib/webmock/http_lib_adapters/patron.rb
  15. +1 −1 lib/webmock/request_pattern.rb
  16. +2 −2 lib/webmock/request_stub.rb
  17. +2 −2 lib/webmock/responses_sequence.rb
  18. +2 −2 lib/webmock/rspec.rb
  19. +4 −4 lib/webmock/rspec/matchers.rb
  20. +1 −1 lib/webmock/rspec/matchers/webmock_matcher.rb
  21. +1 −1 lib/webmock/stub_registry.rb
  22. +4 −4 lib/webmock/util/hash_keys_stringifier.rb
  23. +3 −3 lib/webmock/util/headers.rb
  24. +1 −1 lib/webmock/util/uri.rb
  25. +2 −2 lib/webmock/webmock.rb
  26. +7 −7 spec/curb_spec.rb
  27. +2 −2 spec/curb_spec_helper.rb
  28. +9 −9 spec/em_http_request_spec_helper.rb
  29. +3 −3 spec/errors_spec.rb
  30. +22 −22 spec/example_curl_output.txt
  31. +1 −1 spec/httpclient_spec.rb
  32. +3 −3 spec/httpclient_spec_helper.rb
  33. +6 −6 spec/net_http_spec_helper.rb
  34. +1 −1 spec/network_connection.rb
  35. +2 −2 spec/patron_spec_helper.rb
  36. +8 −8 spec/request_execution_verifier_spec.rb
  37. +3 −3 spec/request_pattern_spec.rb
  38. +19 −19 spec/request_stub_spec.rb
  39. +8 −8 spec/response_spec.rb
  40. +2 −2 spec/spec_helper.rb
  41. +7 −7 spec/stub_request_snippet_spec.rb
  42. +5 −5 spec/util/headers_spec.rb
  43. +1 −1 spec/util/uri_spec.rb
  44. +1 −0 spec/vendor/addressable/lib/uri.rb
  45. +1 −0 spec/vendor/crack/lib/crack.rb
  46. +4 −4 spec/vendor/right_http_connection-1.2.4/History.txt
  47. +4 −4 spec/vendor/right_http_connection-1.2.4/README.txt
  48. +3 −3 spec/vendor/right_http_connection-1.2.4/Rakefile
  49. +4 −4 spec/vendor/right_http_connection-1.2.4/lib/net_fix.rb
  50. +4 −4 spec/vendor/right_http_connection-1.2.4/setup.rb
  51. +92 −92 spec/webmock_shared.rb
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -9,4 +9,4 @@ end
platforms :jruby do
gem 'jruby-openssl', '~> 0.7'
-end
+end
View
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,7 +1,7 @@
module WebMock
module API
extend self
-
+
def stub_request(method, uri)
WebMock::StubRegistry.instance.register_request_stub(WebMock::RequestStub.new(method, uri))
end
@@ -11,7 +11,7 @@ def stub_request(method, uri)
def a_request(method, uri)
WebMock::RequestPattern.new(method, uri)
end
-
+
class << self
alias :request :a_request
end
@@ -29,4 +29,4 @@ def assert_not_requested(method, uri, options = {}, &block)
WebMock::AssertionFailure.failure(verifier.negative_failure_message) unless verifier.does_not_match?
end
end
-end
+end
@@ -8,4 +8,4 @@ def failure(message)
end
end
end
-end
+end
@@ -26,7 +26,7 @@ def self.invoke_callbacks(options, request_signature, response)
def self.reset
@@callbacks = []
end
-
+
def self.any_callbacks?
!@@callbacks.empty?
end
View
@@ -1,7 +1,7 @@
module WebMock
- class Config
+ class Config
include Singleton
-
+
attr_accessor :allow_net_connect
attr_accessor :allow_localhost
attr_accessor :allow
View
@@ -5,4 +5,4 @@
After do
WebMock.reset!
-end
+end
View
@@ -1,5 +1,5 @@
module WebMock
-
+
class NetConnectNotAllowedError < StandardError
def initialize(request_signature)
text = "Real HTTP connections are disabled. Unregistered request: #{request_signature}"
@@ -18,4 +18,4 @@ def stubbing_instructions(request_signature)
end
end
-end
+end
@@ -19,7 +19,7 @@ def curb_or_webmock
webmock_response = build_webmock_response
WebMock::CallbackRegistry.invoke_callbacks(
{:lib => :curb, :real_request => true}, request_signature,
- webmock_response)
+ webmock_response)
end
res
else
@@ -54,15 +54,15 @@ def build_request_signature
end
def build_curb_response(webmock_response)
- raise Curl::Err::TimeoutError if webmock_response.should_timeout
+ raise Curl::Err::TimeoutError if webmock_response.should_timeout
webmock_response.raise_error_if_any
-
+
@body_str = webmock_response.body
@response_code = webmock_response.status[0]
@header_str = "HTTP/1.1 #{webmock_response.status[0]} #{webmock_response.status[1]}\r\n"
if webmock_response.headers
- @header_str << webmock_response.headers.map do |k,v|
+ @header_str << webmock_response.headers.map do |k,v|
"#{k}: #{v.is_a?(Array) ? v.join(", ") : v}"
end.join("\r\n")
@@ -115,7 +115,7 @@ def build_webmock_response
###
### Mocks of Curl::Easy methods below here.
- ###
+ ###
def http_with_webmock(method)
@webmock_method = method
@@ -163,19 +163,19 @@ def perform_with_webmock
@webmock_method ||= :get
curb_or_webmock do
perform_without_webmock
- end
+ end
end
alias :perform_without_webmock :perform
alias :perform :perform_with_webmock
-
+
def put_data_with_webmock= data
@webmock_method = :put
@put_data = data
self.put_data_without_webmock = data
end
alias_method :put_data_without_webmock=, :put_data=
alias_method :put_data=, :put_data_with_webmock=
-
+
def post_body_with_webmock= data
@webmock_method = :post
self.post_body_without_webmock = data
@@ -261,7 +261,7 @@ def self.http_#{verb}(url, data, &block)
end
METHOD
end
-
+
module WebmockHelper
# Borrowed from Patron:
# http://github.com/toland/patron/blob/master/lib/patron/response.rb
@@ -20,7 +20,7 @@ def do_get_with_webmock(req, proxy, conn, stream = false, &block)
response = build_httpclient_response(webmock_response, stream, &block)
res = conn.push(response)
WebMock::CallbackRegistry.invoke_callbacks(
- {:lib => :http_client}, request_signature, webmock_response)
+ {:lib => :http_client}, request_signature, webmock_response)
res
elsif WebMock.net_connect_allowed?(request_signature.uri)
res = if stream
@@ -45,7 +45,7 @@ def do_get_with_webmock(req, proxy, conn, stream = false, &block)
def do_request_async_with_webmock(method, uri, query, body, extheader)
req = create_request(method, uri, query, body, extheader)
request_signature = build_request_signature(req)
-
+
if WebMock::StubRegistry.instance.registered_request?(request_signature) ||
WebMock.net_connect_allowed?(request_signature.uri)
do_request_async_without_webmock(method, uri, query, body, extheader)
@@ -70,15 +70,15 @@ def build_httpclient_response(webmock_response, stream = false, &block)
response.reason=webmock_response.status[1]
webmock_response.headers.to_a.each { |name, value| response.header.set(name, value) }
- raise HTTPClient::TimeoutError if webmock_response.should_timeout
+ raise HTTPClient::TimeoutError if webmock_response.should_timeout
webmock_response.raise_error_if_any
block.call(nil, body) if block
response
end
end
-
+
def build_webmock_response(httpclient_response)
webmock_response = WebMock::Response.new
webmock_response.status = [httpclient_response.status, httpclient_response.reason]
@@ -102,8 +102,8 @@ def build_request_signature(req)
auth = www_auth.basic_auth
auth.challenge(req.header.request_uri, nil)
-
- headers = req.header.all.inject({}) do |headers, header|
+
+ headers = req.header.all.inject({}) do |headers, header|
headers[header[0]] ||= [];
headers[header[0]] << header[1]
headers
@@ -92,12 +92,12 @@ def connect_with_webmock
def build_net_http_response(webmock_response, &block)
response = Net::HTTPResponse.send(:response_class, webmock_response.status[0].to_s).new("1.0", webmock_response.status[0].to_s, webmock_response.status[1])
response.instance_variable_set(:@body, webmock_response.body)
- webmock_response.headers.to_a.each do |name, values|
+ webmock_response.headers.to_a.each do |name, values|
values = [values] unless values.is_a?(Array)
values.each do |value|
response.add_field(name, value)
end
- end
+ end
response.instance_variable_set(:@read, true)
@@ -111,14 +111,14 @@ def build_net_http_response(webmock_response, &block)
response
end
-
+
def build_webmock_response(net_http_response)
webmock_response = WebMock::Response.new
webmock_response.status = [
net_http_response.code.to_i,
net_http_response.message]
webmock_response.headers = net_http_response.to_hash
- webmock_response.body = net_http_response.body
+ webmock_response.body = net_http_response.body
webmock_response
end
@@ -1,4 +1,4 @@
-# This code is entierly copied from VCR (http://github.com/myronmarston/vcr) by courtesy of Myron Marston
+# This code is entierly copied from VCR (http://github.com/myronmarston/vcr) by courtesy of Myron Marston
# A Net::HTTP response that has already been read raises an IOError when #read_body
# is called with a destination string or block.
@@ -29,4 +29,4 @@ def read_body(dest = nil, &block)
end
end
end
-end
+end
@@ -21,7 +21,7 @@ def handle_request_with_webmock(req)
webmock_response = build_webmock_response(res)
WebMock::CallbackRegistry.invoke_callbacks(
{:lib => :patron, :real_request => true}, request_signature,
- webmock_response)
+ webmock_response)
end
res
else
@@ -75,7 +75,7 @@ def build_request_signature(req)
end
def build_patron_response(webmock_response)
- raise Patron::TimeoutError if webmock_response.should_timeout
+ raise Patron::TimeoutError if webmock_response.should_timeout
webmock_response.raise_error_if_any
res = Patron::Response.new
res.instance_variable_set(:@body, webmock_response.body)
@@ -84,7 +84,7 @@ def build_patron_response(webmock_response)
res.instance_variable_set(:@headers, webmock_response.headers)
res
end
-
+
def build_webmock_response(patron_response)
webmock_response = WebMock::Response.new
reason = patron_response.status_line.scan(%r(\AHTTP/(\d+\.\d+)\s+(\d\d\d)\s*([^\r\n]+)?\r?\z))[0][2]
@@ -40,7 +40,7 @@ def assign_options(options)
@headers_pattern = HeadersPattern.new(options[:headers]) if options.has_key?(:headers)
@uri_pattern.add_query_params(options[:query]) if options.has_key?(:query)
end
-
+
def create_uri_pattern(uri)
if uri.is_a?(Regexp)
URIRegexpPattern.new(uri)
@@ -24,12 +24,12 @@ def to_return(*response_hashes, &block)
end
def to_raise(*exceptions)
- @responses_sequences << ResponsesSequence.new([*exceptions].flatten.map {|e|
+ @responses_sequences << ResponsesSequence.new([*exceptions].flatten.map {|e|
ResponseFactory.response_for(:exception => e)
})
self
end
-
+
def to_timeout
@responses_sequences << ResponsesSequence.new([ResponseFactory.response_for(:should_timeout => true)])
self
@@ -1,5 +1,5 @@
module WebMock
-
+
class ResponsesSequence
attr_accessor :times_to_repeat
@@ -36,5 +36,5 @@ def increase_position
end
end
-
+
end
View
@@ -6,7 +6,7 @@
elsif defined?(Spec)
RSPEC_NAMESPACE = Spec
RSPEC_CONFIGURER = Spec::Runner
-else
+else
begin
require 'rspec/core'
require 'rspec/expectations'
@@ -19,7 +19,7 @@
end
require 'webmock/rspec/matchers'
-
+
RSPEC_CONFIGURER.configure { |config|
config.include WebMock::API
@@ -7,17 +7,17 @@ module Matchers
def have_been_made
WebMock::RequestPatternMatcher.new
end
-
+
def have_not_been_made
WebMock::RequestPatternMatcher.new.times(0)
end
-
+
def have_requested(method, uri)
WebMock::WebMockMatcher.new(method, uri)
end
-
+
def have_not_requested(method, uri)
WebMock::WebMockMatcher.new(method, uri).times(0)
end
end
-end
+end
@@ -29,7 +29,7 @@ def times(times)
def matches?(webmock)
@request_execution_verifier.matches?
end
-
+
def does_not_match?(webmock)
@request_execution_verifier.does_not_match?
end
@@ -40,4 +40,4 @@ def evaluate_response_for_request(response, request_signature)
end
end
-end
+end
@@ -1,14 +1,14 @@
module WebMock
module Util
class HashKeysStringifier
-
+
def self.stringify_keys!(arg)
case arg
when Array
arg.map { |elem| stringify_keys!(elem) }
when Hash
Hash[
- *arg.map { |key, value|
+ *arg.map { |key, value|
k = key.is_a?(Symbol) ? key.to_s : key
v = stringify_keys!(value)
[k,v]
@@ -17,7 +17,7 @@ def self.stringify_keys!(arg)
arg
end
end
-
+
end
end
-end
+end
Oops, something went wrong.

0 comments on commit a251cb3

Please sign in to comment.