Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to test with collection_tests but getting error #158

Closed
jsirex opened this issue Jul 29, 2015 · 5 comments
Closed

Trying to test with collection_tests but getting error #158

jsirex opened this issue Jul 29, 2015 · 5 comments

Comments

@jsirex
Copy link
Contributor

jsirex commented Jul 29, 2015

  Fog::Compute[:or2] | Collections | servers (or2)
    success
      #new({"image"=>"image-94d5", "shape"=>"XL", "keyName"=>"keypair-dc10"}) + succeeds
      #create({"image"=>"image-94d5", "shape"=>"XL", "keyName"=>"keypair-dc10"}) + succeeds
      #all + succeeds
      #get(instance-302a) + succeeds
      Enumerable
        #all - succeeds
          expected => true
          returned => false
  1. Method collection.all testing twice.
  2. collection_tests tries to pass block to method all which actually doesn't accept blocks.

How it designed? Should I implement possibility to pass block to method "all" or this is really bug?

@geemus
Copy link
Member

geemus commented Aug 7, 2015

@jsirex could you share a link to where the test files are? I think that might help me narrow in on the issue. Thanks!

@jsirex
Copy link
Contributor Author

jsirex commented Aug 10, 2015

Here is collection_tests helper: https://github.com/fog/fog-core/blob/master/lib/fog/test_helpers/collection_helper.rb#L33-L49

You're testing Enumerable with list of methods. First of them is #all. Test again?

Here you're trying to pass block to method #all. https://github.com/fog/fog-core/blob/master/lib/fog/test_helpers/collection_helper.rb#L46

I've work-a-rounded this method by updating all my collections to accept block:

...
Class MyCollection < Fog::Collection
  # This one doesn't work
  def all
    data = service.get_data(...)
    ...
  end

  # Does work
  def all
    data = service.get_data(...)
    ...
    yield if block_given?
  end
end

@geemus
Copy link
Member

geemus commented Aug 10, 2015

Hmm. I'm not sure. We have examples in other places that seem to NOT yield, but still pass, ie:

I'm not seeing what the difference is there off hand though.

@jsirex
Copy link
Contributor Author

jsirex commented Aug 10, 2015

First time I've wrote exactly as in your example. But it doesn't work for me. Used ruby 2.1.5.

Actually, I'm not a "ruby profi" and can't understand why addresses_tests in your example works for you.
https://github.com/fog/fog-core/blob/master/lib/fog/test_helpers/collection_helper.rb#L46 - here method #all called with ruby block parameter. But in method itself this block never called (no yield statement, no block.call).

@geemus
Copy link
Member

geemus commented Aug 25, 2015

You know, as I dig deeper here, I think there is a typo. Namely, I think that is supposed to be all? and that the block part should work because it is a method mixed in from enumerable (where all those methods accept blocks) see: http://ruby-doc.org/core-2.2.3/Enumerable.html

Will push a fix in a moment, sorry for the confusion.

@geemus geemus closed this as completed in 774c600 Aug 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants