Skip to content

Instantly share code, notes, and snippets.

@jessedavis
Created March 3, 2013 19:38
Show Gist options
  • Save jessedavis/5077890 to your computer and use it in GitHub Desktop.
Save jessedavis/5077890 to your computer and use it in GitHub Desktop.
This is the error I get when trying to mock a call to Fog::Compute::AWS#associate_address in Fog 1.9.0.
Using rbenv, library versions are:
Fog 1.9.0
Ruby 1.9.3-p125
rspec 2.13.0
rake 10.0.3
To replicate:
describe Fog do
stack_name = 'stack-test'
before(:all) do
Fog.mock!
Fog::Mock.delay = 0
@mock_creds = { aws_access_key_id: 'foo', aws_secret_access_key: 'bar', }
@ec2 = Fog::Compute::AWS.new(@mock_creds)
end
before(:each) do
@ec2.vpcs.new('cidr_block' => '192.168.0.0/16').save
end
after(:each) do
@ec2.reset_data
end
# create 3 eips
# create 2 servers
# associate 1 server with 1 eip
# run your method
# check that other server is assigned
# check that 1 eip is left unassigned
it 'associates elastic ip with free instance' do
@ec2.allocate_address('vpc')
@ec2.allocate_address('vpc')
@ec2.allocate_address('vpc')
@ec2.run_instances("ami-foobar", 2, 2)
(instance_id1, instance_id2) = @ec2.describe_instances.body['reservationSet'][0]['instancesSet'].map { |i| i['instanceId']}
addresses = @ec2.describe_addresses.body['addressesSet']
@ec2.associate_address(instance_id1, nil, nil, addresses[0]['allocationId'])
end
end
Error:
2) Fog associates elastic ip with free instance
Failure/Error: @ec2.associate_address(instance_id1, nil, nil, addresses[0]['allocationId'])
TypeError:
can't convert String into Integer
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/fog-1.9.0/lib/fog/aws/requests/compute/associate_address.rb:52:in `[]'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/fog-1.9.0/lib/fog/aws/requests/compute/associate_address.rb:52:in `associate_address'
# ./spec/fog_spec.rb:36:in `block (2 levels) in <top (required)>'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/example.rb:114:in `instance_eval'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/example.rb:114:in `block in run'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/example.rb:254:in `with_around_each_hooks'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/example.rb:111:in `run'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/example_group.rb:386:in `block in run_examples'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/example_group.rb:382:in `map'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/example_group.rb:382:in `run_examples'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/example_group.rb:367:in `run'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/command_line.rb:28:in `map'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/command_line.rb:28:in `block in run'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/reporter.rb:34:in `report'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/command_line.rb:25:in `run'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/runner.rb:80:in `run'
# /Users/jdavis/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/rspec-core-2.13.0/lib/rspec/core/runner.rb:17:in `block in autorun'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment