Skip to content

Instantly share code, notes, and snippets.

@juniorz
Created October 15, 2013 19:16
Show Gist options
  • Save juniorz/6997114 to your computer and use it in GitHub Desktop.
Save juniorz/6997114 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'fog'
Fog.mock!
describe 'Bug' do
it 'should not fail' do
compute = Fog::Compute.new(
:provider => 'openstack',
:openstack_username => 'user',
:openstack_api_key => 'pass',
:openstack_tenant => 'tenant',
:openstack_auth_url => 'http://auth/url',
)
server_def = {
:name => 'name',
:image_ref => 'image_ref',
:flavor_ref => 'flavor',
:key_name => 'key_name',
:user_data => 'user_data',
}
server = compute.servers.create(server_def)
end
end
@juniorz
Copy link
Author

juniorz commented Oct 15, 2013

$ rspec test.rb
F

Failures:

  1) Bug should not fail
     Failure/Error: server = compute.servers.create(server_def)
     ArgumentError:
       Missing required arguments: openstack_auth_url
     # ./test.rb:24:in `block (2 levels) in <top (required)>'

Finished in 0.05619 seconds
1 example, 1 failure

Failed examples:

rspec ./test.rb:7 # Bug should not fail

The test fails with a misleading Missing required arguments: openstack_auth_url error message. Even adding :openstack_auth_url => 'http://foo/auth' doesn't fix the problem, because the error is propagated from the Fog::Identity creation (which happens in the mocking code for create_server).

  1) Bug should not fail
     Failure/Error: server = compute.servers.create(server_def)
     ArgumentError:
       Missing required arguments: openstack_auth_url
     # /Users/rjunior/.rvm/gems/ruby-1.9.3-p429/gems/fog-1.15.0/lib/fog/core/service.rb:208:in `validate_options'
     # /Users/rjunior/.rvm/gems/ruby-1.9.3-p429/gems/fog-1.15.0/lib/fog/core/service.rb:58:in `new'
     # /Users/rjunior/.rvm/gems/ruby-1.9.3-p429/gems/fog-1.15.0/lib/fog/identity.rb:17:in `new'
     # /Users/rjunior/.rvm/gems/ruby-1.9.3-p429/gems/fog-1.15.0/lib/fog/identity.rb:5:in `[]'
     # /Users/rjunior/.rvm/gems/ruby-1.9.3-p429/gems/fog-1.15.0/lib/fog/openstack/requests/compute/create_server.rb:94:in `create_server'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment