Skip to content

Commit

Permalink
Fix uninitialized ivar warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Aug 27, 2011
1 parent 7eedbc8 commit edc2b5f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/vcr/extensions/net_http_response.rb
Expand Up @@ -12,6 +12,10 @@
module VCR
module Net
module HTTPResponse
def self.extended(response)
response.instance_variable_set(:@__read_body_previously_called, false)
end

def read_body(dest = nil, &block)
return super if @__read_body_previously_called
return @body if dest.nil? && block.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/vcr/http_stubbing_adapters/common.rb
Expand Up @@ -75,7 +75,7 @@ def raise_no_checkpoint_error(cassette)
attr_writer :http_connections_allowed

def http_connections_allowed?
!!@http_connections_allowed
defined?(@http_connections_allowed) && !!@http_connections_allowed
end

def ignored_hosts=(hosts)
Expand Down
6 changes: 6 additions & 0 deletions lib/vcr/http_stubbing_adapters/fakeweb.rb
Expand Up @@ -93,6 +93,12 @@ def validate_match_attributes(match_attributes)
raise UnsupportedRequestMatchAttributeError.new("FakeWeb does not support matching requests on #{invalid_attributes.join(' or ')}")
end
end

def initialize_ivars
@http_connections_allowed = nil
end

initialize_ivars # to avoid warnings
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/vcr/extensions/net_http_response_spec.rb
Expand Up @@ -45,7 +45,7 @@ def self.it_allows_the_body_to_be_read(expected_regex)
let(:http_verb_method) { :"request_#{http_verb}" }

def response(&block)
if @response && block
if defined?(@response) && block
block.call(@response)
return @response
end
Expand Down

0 comments on commit edc2b5f

Please sign in to comment.