deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marios@redhat.com" <mandr...@redhat.com>
Subject Re: [PATCH 2/4] API TESTS: adds images and instances tests
Date Fri, 03 Aug 2012 08:11:39 GMT
On 02/08/12 23:53, Ronelle Landy wrote:
>> From: marios@redhat.com
>> To: dev@deltacloud.apache.org
>> Sent: Thursday, August 2, 2012 11:07:39 AM
>> Subject: [PATCH 2/4] API TESTS: adds images and instances tests
>>
>> From: marios <marios@redhat.com>
>>
>>
>> Signed-off-by: marios <marios@redhat.com>
>> ---
>>  tests/config.yaml                  |   19 ++-
>>  tests/deltacloud/images_test.rb    |   73 ++++++++
>>  tests/deltacloud/instances_test.rb |  351
>>  ++++++++++++++++++++++++++++++++++++
>>  3 files changed, 440 insertions(+), 3 deletions(-)
>>

-----8<-----------8<---------SNIP-------8<-----------8<---------
>>
>>
> 
> Running >> rake test:deltacloud 
> returns the error below (irrespective of the driver - tried mock and vsphere).
> Running >> rake test:deltacloud:images TEST_OPTS="-v"
> works for me.
> 
> -----------------
> 
> /home/dcloud/workspace/deltacloud/tests/deltacloud/instances_test.rb:28: warning: class
variable access from toplevel
> /home/dcloud/workspace/deltacloud/tests/deltacloud/instances_test.rb:33:in `block in
<top (required)>': undefined method `choice' for #<Array:0x00000001bc0768> (NoMethodError)
> 	from /usr/local/share/gems/gems/minitest-3.3.0/lib/minitest/spec.rb:71:in `class_eval'
> 	from /usr/local/share/gems/gems/minitest-3.3.0/lib/minitest/spec.rb:71:in `describe'
> 	from /home/dcloud/workspace/deltacloud/tests/deltacloud/instances_test.rb:22:in `<top
(required)>'
> 	from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
> 	from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
> 	from /usr/local/share/gems/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:15:in `block
in <main>'
> 	from /usr/local/share/gems/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
> 	from /usr/local/share/gems/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `<main>'
> rake aborted!
> Command failed with status (1): [/usr/bin/ruby -I"lib" -I"/usr/local/share/...]
> 
> Tasks: TOP => test:deltacloud
> (See full trace by running task with --trace)
> 


<sigh> seems we've hit another ruby 1.8/1.9 compatibility issue </sigh>

 [].choice is not defined for ruby 1.9. If I recall correctly you were
running these under 1.9.3:

[marios@name tests]$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [i386-linux]
[marios@name tests]$ irb
irb(main):001:0> [1,2,3,4,5].choice
=> 3
irb(main):002:0> exit

[marios@name tests]$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
[marios@name tests]$ irb
[11.9.2p290 :001 > [1,2,3,4,5].choice
NoMethodError: undefined method `choice' for [1, 2, 3, 4, 5]:Array
	from (irb):1
	from /home/marios/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
1.9.2p290 :002 > [1,2,3,4,5].sample
 => 4

The 1.9 method for random array element is 'sample' - no idea why they
*had* to use a different name/didn't just alias "sample" for "choice"
</rant>

I'll find some way to make this work for both before pushing- either
alias choice for sample or 'manually' implement a 'select random
element' method (likely the second).

marios

Mime
View raw message