On Nov 2, 2011, at 10:34 AM, mar...@redhat.com wrote:

Hi,

I tried to run the tests but I got this error:

test_02_it_can_post_new_blob(GoogleTest::BucketsTest): 
Excon::Errors::SocketError:can't convert Tempfile into String
/Library/Ruby/Gems/1.8/gems/vcr-1.11.3/lib/vcr/structs/normalizers/body.rb:19:in
 `initialize'
/Library/Ruby/Gems/1.8/gems/vcr-1.11.3/lib/vcr/structs/normalizers/body.rb:19:in
 `new'
/Library/Ruby/Gems/1.8/gems/vcr-1.11.3/lib/vcr/structs/normalizers/body.rb:19:in
 `normalize_body'
/Library/Ruby/Gems/1.8/gems/vcr-1.11.3/lib/vcr/structs/normalizers/body.rb:6:in 
`initialize'
/Library/Ruby/Gems/1.8/gems/vcr-1.11.3/lib/vcr/http_stubbing_adapters/excon.rb:131:in
 `new'
/Library/Ruby/Gems/1.8/gems/vcr-1.11.3/lib/vcr/http_stubbing_adapters/excon.rb:131:in
 `vcr_request'
/Library/Ruby/Gems/1.8/gems/vcr-1.11.3/lib/vcr/http_stubbing_adapters/excon.rb:47:in
 `stubbed_response'
/Library/Ruby/Gems/1.8/gems/vcr-1.11.3/lib/vcr/http_stubbing_adapters/excon.rb:30:in
 `handle'
/Library/Ruby/Gems/1.8/gems/vcr-1.11.3/lib/vcr/http_stubbing_adapters/excon.rb:169
/Users/mfojtik/.gem/gems/excon-0.7.3/lib/excon/connection.rb:86:in `call'

I bet this has something to do with gem versions I have installed on my system:

firefly ~/code/core/server $ gem list | egrep 'excon|vcr|fog|net-ssh'
excon (0.7.3)
fog (1.0.0)
net-ssh (2.1.4)
vcr (1.11.3)

firefly ~/code/core/server $ ruby --version
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
  
  -- Michal

> Patch 1/2 contains fixes for google storage driver that came up when writing 
> the tests
> 
> Patch 2/2 contains the unit tests and vcr recordings. Invoke the tests by 'cd 
> /path/to/deltacloud/server; rake test:google'
> 
> 
> If you are interested in recording new vcr episodes for google storage, read 
> on:
> ===============================================================================
> 
> The mocking for vcr is done with excon; the google-storage driver uses fog to 
> talk to the google-storage service, and fog uses excon for http connections. 
> I came across a couple of issues when trying to make the vcr recordings, as 
> reported here for example 
> https://groups.google.com/group/ruby-fog/browse_thread/thread/737295ebb42e67d1/7e5a09463c4513c2?lnk=gst&q=fog+and+vcr#7e5a09463c4513c2
> 
> Another issue is that the vcr code tries to 'normalise' the HTTP body, as 
> described here https://github.com/myronmarston/vcr/issues/4  However, for the 
> 'create blob' test, the body is a tempfile which caused the normalisation to 
> fail (normalisation is done by String.new(body)). Thus, in order to record 
> 'new' episodes for google storage I had to change the normalisation code:
> 
> From 5ad2e93a1c0d38164953b0845b83e141ddd9b494 Mon Sep 17 00:00:00 2001
> From: marios <mar...@redhat.com>
> Date: Wed, 2 Nov 2011 11:17:14 +0200
> Subject: [PATCH] Fix normaliser - don't normalise body when body is a
> tempfile
> 
> ---
> lib/vcr/structs/normalizers/body.rb |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/vcr/structs/normalizers/body.rb 
> b/lib/vcr/structs/normalizers/body.rb
> index 6b013fc..e07ec75 100644
> --- a/lib/vcr/structs/normalizers/body.rb
> +++ b/lib/vcr/structs/normalizers/body.rb
> @@ -16,7 +16,7 @@ module VCR
>         # http://github.com/myronmarston/vcr/issues/4
>         self.body = case body
>           when nil, ''; nil
> -          else String.new(body)
> +          else String.new(body) unless body.is_a?(Tempfile)
>         end
>       end
>     end
> -- 
> 1.7.6.4
> 
> 
> 
> The above patch is for vcr version 1.11.3 (current @ Rubygems.org)... however 
> for v2.0.0 currently in beta (cloned from github) the noralisation code has 
> been moved to ./lib/vcr/cassette/migrator.rb:105 . I'll report the issue to 
> github.

------------------------------------------------------
Michal Fojtik, mfoj...@redhat.com
Deltacloud API: http://deltacloud.org

Reply via email to