Skip to content

Commit

Permalink
Indent files correctly and remove trailing whitespace
Browse files Browse the repository at this point in the history
This makes it much easier moving using motions and editing files in a
number of editors.
  • Loading branch information
James Conroy-Finn committed May 28, 2011
1 parent b986955 commit a251cb3
Show file tree
Hide file tree
Showing 51 changed files with 399 additions and 397 deletions.
236 changes: 118 additions & 118 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ end

platforms :jruby do
gem 'jruby-openssl', '~> 0.7'
end
end
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 3 additions & 3 deletions lib/webmock/api.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/webmock/assertion_failure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def failure(message)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/webmock/callback_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def self.invoke_callbacks(options, request_signature, response)
def self.reset
@@callbacks = []
end

def self.any_callbacks?
!@@callbacks.empty?
end
Expand Down
4 changes: 2 additions & 2 deletions lib/webmock/config.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module WebMock
class Config
class Config
include Singleton

attr_accessor :allow_net_connect
attr_accessor :allow_localhost
attr_accessor :allow
Expand Down
2 changes: 1 addition & 1 deletion lib/webmock/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

After do
WebMock.reset!
end
end
4 changes: 2 additions & 2 deletions lib/webmock/errors.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module WebMock

class NetConnectNotAllowedError < StandardError
def initialize(request_signature)
text = "Real HTTP connections are disabled. Unregistered request: #{request_signature}"
Expand All @@ -18,4 +18,4 @@ def stubbing_instructions(request_signature)
end
end

end
end
18 changes: 9 additions & 9 deletions lib/webmock/http_lib_adapters/curb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -115,7 +115,7 @@ def build_webmock_response

###
### Mocks of Curl::Easy methods below here.
###
###

def http_with_webmock(method)
@webmock_method = method
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions lib/webmock/http_lib_adapters/httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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]
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/webmock/http_lib_adapters/net_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/webmock/http_lib_adapters/net_http_response.rb
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -29,4 +29,4 @@ def read_body(dest = nil, &block)
end
end
end
end
end
6 changes: 3 additions & 3 deletions lib/webmock/http_lib_adapters/patron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/webmock/request_pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/webmock/request_stub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/webmock/responses_sequence.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module WebMock

class ResponsesSequence

attr_accessor :times_to_repeat
Expand Down Expand Up @@ -36,5 +36,5 @@ def increase_position
end

end

end
4 changes: 2 additions & 2 deletions lib/webmock/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
elsif defined?(Spec)
RSPEC_NAMESPACE = Spec
RSPEC_CONFIGURER = Spec::Runner
else
else
begin
require 'rspec/core'
require 'rspec/expectations'
Expand All @@ -19,7 +19,7 @@
end

require 'webmock/rspec/matchers'

RSPEC_CONFIGURER.configure { |config|

config.include WebMock::API
Expand Down
8 changes: 4 additions & 4 deletions lib/webmock/rspec/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/webmock/rspec/matchers/webmock_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/webmock/stub_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def evaluate_response_for_request(response, request_signature)
end

end
end
end
8 changes: 4 additions & 4 deletions lib/webmock/util/hash_keys_stringifier.rb
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -17,7 +17,7 @@ def self.stringify_keys!(arg)
arg
end
end

end
end
end
end
Loading

0 comments on commit a251cb3

Please sign in to comment.