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

Fog::Compute::AWS::Image not properly loaded #324

Closed
tisba opened this issue Nov 27, 2016 · 3 comments
Closed

Fog::Compute::AWS::Image not properly loaded #324

tisba opened this issue Nov 27, 2016 · 3 comments

Comments

@tisba
Copy link
Contributor

tisba commented Nov 27, 2016

Using fog-aws 0.12.0 on ruby 2.3.1p112

I was trying to test that my code works properly when receiving a Fog::Compute::AWS::Image. As I'm using RSpec I was trying this:

instance_double(Fog::Compute::AWS::Image)

This triggers a NameError: uninitialized constant Fog::Compute::AWS::Image though, even though fog is required and used.

I could only get it working in my specs reliabaly by explicitly requiring fog/aws/models/compute/image.

In non-test code this works fine, but only because we use other APIs to fetch a list of images (it seems in those cases the class is properly loaded).

Is this a bug? If not, what is the recommended best practice in those cases?

@lanej
Copy link
Member

lanej commented Nov 28, 2016

@tisba related classes are loaded after client instantiation.Fog::Compute::AWS.new will cause models, collections, and requests to be required.

See:

@tisba
Copy link
Contributor Author

tisba commented Nov 28, 2016

So the recommendation would be to set up the test/example by calling Fog::Compute::AWS.new?

Thanks, that works for me. It's not perfect, but better then requiring the file directly :)

@tisba tisba closed this as completed Nov 28, 2016
@lanej
Copy link
Member

lanej commented Nov 28, 2016

@tisba instantiating a client is the safest solution. Depending on your usage, requiring the individual file may be sufficient.

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