You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2011/11/08 16:04:40 UTC

[PATCH 3/3] Monkey patch fix for VCR normalisation code

From: marios <ma...@redhat.com>

Needed in order to run google unit tests -
see https://github.com/myronmarston/vcr/issues/101

Signed-off-by: marios <ma...@redhat.com>
---
 server/tests/drivers/google/setup.rb |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/server/tests/drivers/google/setup.rb b/server/tests/drivers/google/setup.rb
index 09aea62..95924e5 100644
--- a/server/tests/drivers/google/setup.rb
+++ b/server/tests/drivers/google/setup.rb
@@ -11,3 +11,28 @@ VCR.config do |c|
   c.stub_with :excon
   c.default_cassette_options = { :record => :new_episodes}
 end
+
+#monkey patch fix for VCR normalisation code:
+#see https://github.com/myronmarston/vcr/issues/4
+#when body is a tempfile, like when creating new blob
+#this method of normalisation fails and excon throws errors
+#(Excon::Errors::SocketError:can't convert Tempfile into String)
+#
+#RELEVANT: https://github.com/myronmarston/vcr/issues/101
+#(will need revisiting when vcr 2 comes along)
+
+module VCR
+  module Normalizers
+    module Body
+
+    private
+    def normalize_body
+     self.body = case body
+          when nil, ''; nil
+          else
+            String.new(body) unless body.is_a?(Tempfile)
+        end
+      end
+    end
+  end
+end
-- 
1.7.6.4


Re: [PATCH 3/3] Monkey patch fix for VCR normalisation code

Posted by Michal Fojtik <mf...@redhat.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Finished in 4.764091 seconds.
13 tests, 0 assertions, 0 failures, 0 errors

ACK! :-)

 -- Michal

marios@redhat.com wrote:
> From: marios <ma...@redhat.com>
> 
> Needed in order to run google unit tests - see
> https://github.com/myronmarston/vcr/issues/101
> 
> Signed-off-by: marios <ma...@redhat.com> --- 
> server/tests/drivers/google/setup.rb |   25
> +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0
> deletions(-)
> 
> diff --git a/server/tests/drivers/google/setup.rb
> b/server/tests/drivers/google/setup.rb index 09aea62..95924e5 100644 
> --- a/server/tests/drivers/google/setup.rb +++
> b/server/tests/drivers/google/setup.rb @@ -11,3 +11,28 @@ VCR.config
> do |c| c.stub_with :excon c.default_cassette_options = { :record =>
> :new_episodes} end + +#monkey patch fix for VCR normalisation code: 
> +#see https://github.com/myronmarston/vcr/issues/4 +#when body is a
> tempfile, like when creating new blob +#this method of normalisation
> fails and excon throws errors +#(Excon::Errors::SocketError:can't
> convert Tempfile into String) +# +#RELEVANT:
> https://github.com/myronmarston/vcr/issues/101 +#(will need
> revisiting when vcr 2 comes along) + +module VCR +  module
> Normalizers +    module Body + +    private +    def normalize_body +
> self.body = case body +          when nil, ''; nil +          else +
> String.new(body) unless body.is_a?(Tempfile) +        end +      end 
> +    end +  end +end

- -- 
- --
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOunUcAAoJEEnFpmY+LvFR05QH/Ry7jZdYnb9qSovv6t0yQLCY
/MM2NVzyfUrgvbsxjpNsihB7Q4yqRoNKnrQ4Ip6Zjy0+dGghwg4MKqXoQSjCZXqc
i1T9ncoiw6xjbkYvTnaUT6YqUxLcFGuheJpB5948GDDR1ADzCpAQQHjC90xfDoIn
R88/B2F0GBHHeoxNWkNVLd+ejk3MMwsLjBuWEtX0s9HwiXKa/SOxLkaJGaLSjLk2
8NErle4LkssPaPuY3mde+LR90kjkUUxn3nOA651Y+iCcf5TYh8b+kBcB5DEKgqKZ
zg1WiixtNYG9+3JwCNwaPgbtNoK6FdXWcRScjxmRUP/evhOQwjjHUx9EkUPYDs8=
=LNQX
-----END PGP SIGNATURE-----