Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix HTTPInteraction filtering to handle integers (e.g. port) correctly.

Previously, we would get an error:
  TypeError: can't convert Fixnum into String

Closes #167.
  • Loading branch information...
commit 04cd2433bfca8281e7596924d17337821e795aac 1 parent 8575ba5
Myron Marston authored
2  CHANGELOG.md
Source Rendered
@@ -20,6 +20,8 @@
20 20 `WebMock.net_connect_allowed?` with arguments. Thanks to
21 21 [Gordon Wilson](https://github.com/gordoncww) for reporting the bug and
22 22 providing a fix.
  23 +* Fix `filter_sensitive_data`/`define_cassette_placeholder` so that they
  24 + handle non-strings gracefully (e.g. the port number as a Fixnum).
23 25
24 26 ## 2.1.1 (April 24, 2012)
25 27
7 lib/vcr/structs.rb
@@ -502,10 +502,11 @@ def ignored?
502 502 # Replaces a string in any part of the HTTP interaction (headers, request body,
503 503 # response body, etc) with the given replacement text.
504 504 #
505   - # @param [String] text the text to replace
506   - # @param [String] replacement_text the text to put in its place
  505 + # @param [#to_s] text the text to replace
  506 + # @param [#to_s] replacement_text the text to put in its place
507 507 def filter!(text, replacement_text)
508   - return self if [text, replacement_text].any? { |t| t.to_s.empty? }
  508 + text, replacement_text = text.to_s, replacement_text.to_s
  509 + return self if [text, replacement_text].any? { |t| t.empty? }
509 510 filter_object!(self, text, replacement_text)
510 511 end
511 512
6 spec/vcr/structs_spec.rb
@@ -354,6 +354,12 @@ def assert_yielded_keys(hash, *keys)
354 354 it 'replaces sensitive text in the request URI' do
355 355 filtered.request.uri.should eq('http://example-AAA.com/AAA/')
356 356 end
  357 +
  358 + it 'handles numbers (such as the port) properly' do
  359 + request.uri = "http://foo.com:9000/bar"
  360 + subject.filter!(9000, "<PORT>")
  361 + request.uri.should eq("http://foo.com:<PORT>/bar")
  362 + end
357 363 end
358 364 end
359 365

0 comments on commit 04cd243

Please sign in to comment.
Something went wrong with that request. Please try again.